示例#1
0
/*
	Reparse the source files that produced this translation unit.

	This routine can be used to re-parse the source files that originally
	created the given translation unit, for example because those source files
	have changed (either on disk or as passed via \p unsaved_files). The
	source code will be reparsed with the same command-line options as it
	was originally parsed.

	Reparsing a translation unit invalidates all cursors and source locations
	that refer into that translation unit. This makes reparsing a translation
	unit semantically equivalent to destroying the translation unit and then
	creating a new translation unit with the same command-line arguments.
	However, it may be more efficient to reparse a translation
	unit using this routine.

	Parameter TU The translation unit whose contents will be re-parsed. The
	translation unit must originally have been built with
	clang_createTranslationUnitFromSourceFile().

	Parameter num_unsaved_files The number of unsaved file entries in \p
	unsaved_files.

	Parameter unsaved_files The files that have not yet been saved to disk
	but may be required for parsing, including the contents of
	those files. The contents and name of these files (as specified by
	CXUnsavedFile) are copied when necessary, so the client only needs to
	guarantee their validity until the call to this function returns.

	Parameter options A bitset of options composed of the flags in CXReparse_Flags.
	The function clang_defaultReparseOptions() produces a default set of
	options recommended for most uses, based on the translation unit.

	Returns 0 if the sources could be reparsed. A non-zero value will be
	returned if reparsing was impossible, such that the translation unit is
	invalid. In such cases, the only valid call for \p TU is
	clang_disposeTranslationUnit(TU).
*/
func (tu TranslationUnit) ReparseTranslationUnit(unsavedFiles []UnsavedFile, options uint32) int32 {
	gos_unsavedFiles := (*reflect.SliceHeader)(unsafe.Pointer(&unsavedFiles))
	cp_unsavedFiles := (*C.struct_CXUnsavedFile)(unsafe.Pointer(gos_unsavedFiles.Data))

	return int32(C.clang_reparseTranslationUnit(tu.c, C.uint(len(unsavedFiles)), cp_unsavedFiles, C.uint(options)))
}
示例#2
0
/**
 * \brief Reparse the source files that produced this translation unit.
 *
 * This routine can be used to re-parse the source files that originally
 * created the given translation unit, for example because those source files
 * have changed (either on disk or as passed via \p unsaved_files). The
 * source code will be reparsed with the same command-line options as it
 * was originally parsed.
 *
 * Reparsing a translation unit invalidates all cursors and source locations
 * that refer into that translation unit. This makes reparsing a translation
 * unit semantically equivalent to destroying the translation unit and then
 * creating a new translation unit with the same command-line arguments.
 * However, it may be more efficient to reparse a translation
 * unit using this routine.
 *
 * \param TU The translation unit whose contents will be re-parsed. The
 * translation unit must originally have been built with
 * \c clang_createTranslationUnitFromSourceFile().
 *
 * \param num_unsaved_files The number of unsaved file entries in \p
 * unsaved_files.
 *
 * \param unsaved_files The files that have not yet been saved to disk
 * but may be required for parsing, including the contents of
 * those files.  The contents and name of these files (as specified by
 * CXUnsavedFile) are copied when necessary, so the client only needs to
 * guarantee their validity until the call to this function returns.
 *
 * \param options A bitset of options composed of the flags in CXReparse_Flags.
 * The function \c clang_defaultReparseOptions() produces a default set of
 * options recommended for most uses, based on the translation unit.
 *
 * \returns 0 if the sources could be reparsed. A non-zero value will be
 * returned if reparsing was impossible, such that the translation unit is
 * invalid. In such cases, the only valid call for \p TU is
 * \c clang_disposeTranslationUnit(TU).
 */
func (tu TranslationUnit) Reparse(us UnsavedFiles, options TranslationUnitFlags) int {
	c_us := us.to_c()
	defer c_us.Dispose()
	return int(C.clang_reparseTranslationUnit(tu.c, C.uint(len(c_us)), c_us.ptr(), C.uint(options)))
}