static private void IndexTranslationUnit(IProjectIndex index, TranslationUnit tu) { foreach (Cursor c in tu.Cursor.Children) { IndexCursor(index, c); } }
internal Token(Library.CXToken handle, TranslationUnit tu) { //we dont save the handle here as it will be destroyed when the CXTokenSet id disposed Kind = Library.clang_getTokenKind(handle); Spelling = Library.clang_getTokenSpelling(tu.Handle, handle).ManagedString; Location = tu.ItemFactory.CreateSourceLocation(Library.clang_getTokenLocation(tu.Handle, handle)); Extent = tu.ItemFactory.CreateSourceRange(Library.clang_getTokenExtent(tu.Handle, handle)); }
public void Dispose() { if (_translationUnit != null) { _translationUnit.Dispose(); _translationUnit = null; } }
public TranslationUnitItemStore(TranslationUnit tu) { _tu = tu; _cursorStore = new CursorStore(this); _fileStore = new FileStore(this); _locationStore = new SourceLocationStore(this); _sourceRangeStore = new SourceRangeStore(this); _typeStore = new TypeStore(this); }
public void ParseAndBecomeValid() { using (TranslationUnit tu = new TranslationUnit(TestCode.TranslationUnits.Index, TestCode.SimpleClassCppFile.Path)) { Assert.IsFalse(tu.Valid); tu.Parse(null, null); Assert.IsTrue(tu.Valid); } }
public ParseResult(IProjectIndex index, FilePath path, IEnumerable<ParseFile> files, LibClang.TranslationUnit tu) { _index = index; _path = path; _translationUnit = tu; _files = new Dictionary<FilePath, ParseFile>(); foreach(ParseFile pf in files) { _files.Add(pf.Path, pf); } }
internal unsafe TokenSet(TranslationUnit tu, TokenSetHandle handle, SourceRange range) { _tu = tu; Handle = handle; _tokens = new SortedList<int, Token>(); for (uint i = 0; i < handle.Count; i++) { Library.Token tokHandle = handle.GetToken(i); Token tok = new Token(tokHandle, _tu); _tokens.Add(tok.Location.Offset, tok); } }
public static unsafe TokenSet Create(TranslationUnit tu, SourceRange range) { Library.Token* tokens; uint count = 0; Library.clang_tokenize(tu.Handle, range.Handle, &tokens, &count); if (count == 0) return null; TokenSetHandle handle = new TokenSetHandle(tu, tokens, count); if (handle == null) return null; return new TokenSet(tu, handle, range); }
public void ParseNonExistantFileThrows() { try { using (TranslationUnit tu = new TranslationUnit(TestCode.TranslationUnits.Index, "BlahBlah")) { tu.Parse(null, null); } } catch (System.IO.FileNotFoundException) { return; } Assert.Fail(); }
public static ParseResult Parse(IProjectIndex index, FilePath path, string[] compilerArgs, IUnsavedFileProvider unsavedFiles) { TranslationUnit tu = new TranslationUnit(index.LibClangIndex, path.Str); //Take a snapshot of the source IEnumerable<ParseFile> files = unsavedFiles.UnsavedFiles; List<Tuple<string, string>> unsavedList = new List<Tuple<string, string>>(); foreach (var i in files) { unsavedList.Add(new Tuple<string, string>(i.Path.Str, i.Content)); } if (tu.Parse(compilerArgs, unsavedList) == false) { tu.Dispose(); return null; } return new ParseResult(index, path, files, tu); ; }
private void RecordHeader(TranslationUnit.HeaderInfo headerInfo, TranslationUnit tu) { string path = System.IO.Path.GetFullPath(headerInfo.Path); IProjectItem item; if (_items.TryGetValue(path, out item) == false) { item = new HeaderFile(path); _items.Add(path, item); } if (item.Type != ProjectItemType.HeaderFile || !(item is HeaderFile)) throw new ApplicationException(headerInfo.Path + " previously seen as a source file."); HeaderFile header = item as HeaderFile; header.AddTranslationUnit(tu); IEnumerable<Diagnostic> ds = header.Diagnostics; }
/// <summary> /// Initializes a new instance of the <see cref="Token"/> class. /// </summary> /// <param name="translationUnit">The translationUnit<see cref="TranslationUnit"/></param> /// <param name="token">The token<see cref="CXToken"/></param> internal Token(TranslationUnit translationUnit, CXToken token) { this._translationUnit = translationUnit; this.m_value = token; }
private ICodeLocation JumpTo(TranslationUnit tu, ICodeLocation loc) { Cursor c = tu.GetCursorAt(loc.Path, loc.Offset); return c == null || c.Kind == CursorKind.NoDeclFound ? null : JumpTo(c); }
/// <summary> /// Create a new Cursor object. /// </summary> /// <param name="handle">Handle to a non null cursor obect.</param> /// <param name="itemFactory">TranslationUnit's item factory / item cache.</param> internal Cursor(Library.CXCursor handle, ITranslationUnitItemFactory itemFactory) { Debug.Assert(!handle.IsNull); Debug.Assert(handle.IsValid); Handle = handle; _itemFactory = itemFactory; _translationUnit = _itemFactory.TranslationUnit; Kind = Library.clang_getCursorKind(Handle); Library.CXType typeHandle = Library.clang_getCursorType(Handle); if (typeHandle.IsValid) _type = _itemFactory.CreateType(typeHandle); }
public SourceFileIndex(LibClang.TranslationUnit tu) { _tu = tu; }
static TranslationUnit CreateTranslationUnit(string path) { TranslationUnit tu = new TranslationUnit(Index, path); tu.Parse(new string[] { "-Weverything" }, null); return tu; }
internal Token(Library.Token handle, TranslationUnit tu) { _tu = tu; Handle = handle; }
internal static extern int clang_indexSourceFile(CXIndexAction session, CXClientData clientData, IndexerCallbacks[] cbs, uint cbsSize, uint indexOptions, string fileName, string[] cmdLineArgs, int cmdLineCount, UnsavedFile[] unsavedFiles, uint numUnsavedFiles, out TranslationUnit translationUnit, uint tuOptions);
/// <summary> /// Initializes a new instance of the <see cref="TokenList"/> class. /// </summary> /// <param name="translationUnit">The translationUnit<see cref="TranslationUnit"/></param> /// <param name="pTokens">The pTokens<see cref="CXToken*"/></param> /// <param name="tokensCount">The tokensCount<see cref="int"/></param> internal unsafe TokenList(TranslationUnit translationUnit, CXToken *pTokens, int tokensCount) { this._translationUnit = translationUnit; this.m_value = pTokens; this._tokensCount = tokensCount; }
public static unsafe TokenSetHandle Create(TranslationUnit tu, SourceRange range) { Library.Token* tokens; uint count = 0; Library.clang_tokenize(tu.Handle, range.Handle, &tokens, &count); return count > 0 ? new TokenSetHandle(tu, tokens, count) : null; }
internal unsafe TokenSetHandle(TranslationUnit tu, Library.Token* toks, uint count) { _tu = tu; _tokens = toks; _count = count; }