public Reference(Cursor c, IDeclaration decl, ISymbolTable table) { _cursor = c; _decl = decl; _table = table; _location = new CodeLocation(c.Extent.Start); //todo - replace for doc tracking }
public MethodDecl(Cursor declaration, ISymbolTable table) : base(declaration, table) { Debug.Assert(CursorKinds.IsClassStructEtc(declaration.SemanticParentCurosr.Kind)); _class = table.FindClassDeclaration(declaration.SemanticParentCurosr.Usr); Debug.Assert(_class != null); }
static private bool FilterCursor(Cursor c) { if (IsIndexCursorKind(c.Kind) == false) return false; if (c.Location == null || c.Location.File == null) return false; return true; }
public FieldDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.FieldDecl); _class = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_class != null); }
private ICodeLocation JumpTo(Cursor c) { LibClang.Cursor result = null; if (c.Kind == CursorKind.InclusionDirective) return JumpToInclude(c); if (JumpToDeclaration(c)) { //For constructor and method definitions we browse to the declaration result = FindDeclaration(c.SemanticParentCurosr, c.Usr); } else { if (c.CursorReferenced != null) result = c.CursorReferenced; else if (c.Definition != null) result = c.Definition; else result = c.CanonicalCursor; } if (result == null) return null; return new CodeLocation(result.Location.File.Name, result.Location.Offset); }
public ClassDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(CursorKinds.IsClassStructEtc(c.Kind)); _templateKind = Symbols.TemplateKind.NonTemplate; if (c.Kind == CursorKind.ClassTemplate) _templateKind = Symbols.TemplateKind.Template; else if (c.Kind == CursorKind.ClassTemplatePartialSpecialization) _templateKind = Symbols.TemplateKind.TemplatePartialSpecialization; else if (c.TemplateSpecialisedCursorTemplate != null) _templateKind = Symbols.TemplateKind.TemplateSpecialization; if(c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (c.SemanticParentCurosr.Kind == CursorKind.TranslationUnit || c.SemanticParentCurosr.Kind == CursorKind.UnexposedDecl) { _parent = null; } else if(CursorKinds.IsClassStructEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else { Debug.Assert(false); } }
public void UpdateDefinition(Cursor c) { // Debug.Assert(c.Kind == CursorKind.VarDecl); Debug.Assert(c.IsDefinition); if (_definition == null) _definition = c; }
public VariableDecl(Cursor c, ISymbolTable table) : base(c, table) { // Debug.Assert(c.Kind == CursorKind.VarDecl); if (c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (CursorKinds.IsClassStructEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if(CursorKinds.IsFunctionEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindFunctionDeclaration(c.SemanticParentCurosr.Usr); } else if (c.SemanticParentCurosr.Kind == CursorKind.TranslationUnit || c.SemanticParentCurosr.Kind == CursorKind.UnexposedDecl) { _parent = null; } else { Debug.Assert(false); } }
public void UpdateDefinition(Cursor c) { Debug.Assert(CursorKinds.IsFunctionEtc(c.Kind)); Debug.Assert(c.IsDefinition); if (_definition == null) _definition = c; }
public ConstructorDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.Constructor); _class = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); //could be classtemplate //Debug.Assert(_class != null); }
public FunctionDeclBase(Cursor declaration, ISymbolTable table) : base(declaration, table) { _args = new List<MethodArgumentSymbol>(); foreach (Cursor arg in declaration.ArgumentCursors) { _args.Add(new MethodArgumentSymbol(arg, table)); } }
public EnumConstantDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.EnumConstantDecl); Debug.Assert(c.SemanticParentCurosr != null); Debug.Assert(c.SemanticParentCurosr.Kind == CursorKind.EnumDecl); _parent = table.FindEnumDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); }
public NamespaceDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.Namespace); if(c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } }
internal unsafe static OverriddenCursorSet CreateOverriddenCursorSet(Cursor c, ITranslationUnitItemFactory factory) { Library.CXCursor* overrides; uint count; Library.clang_getOverriddenCursors(c.Handle, &overrides, &count); if (count == 0) return Empty; OverriddenCursorSet result = new OverriddenCursorSet(overrides, count, factory); //Assuming that this only deletes the array allocated above and that the handles remain valid Library.clang_disposeOverriddenCursors(overrides); return result; }
private void Highlight(Cursor c) { Highlighting.IHighlightedRange range = _underliner.AddRange(c.Extent.Start.Offset, c.Extent.Length); range.ForegroundColour = GetNextColour(); foreach (Cursor child in c.Children) { if (child.Location.File == null) continue; if(System.IO.Path.GetFullPath(child.Location.File.Name) == _path) Highlight(child); } }
private Cursor FindDeclaration(Cursor parent, string usr) { Cursor result = null; parent.VisitChildren(delegate(Cursor cursor, Cursor p) { if (cursor.Usr == usr && cursor.IsDefinition == false) { result = cursor; return Cursor.ChildVisitResult.Break; } return Cursor.ChildVisitResult.Continue; }); return result; }
public EnumDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.EnumDecl); if (c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (CursorKinds.IsClassStructEtc(c.SemanticParentCurosr.Kind)) { _parent = table.FindClassDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else { CursorKind k = c.SemanticParentCurosr.Kind; } }
public FunctionDecl(Cursor c, ISymbolTable table) : base(c, table) { Debug.Assert(c.Kind == CursorKind.FunctionDecl); if (c.SemanticParentCurosr.Kind == CursorKind.Namespace) { _parent = table.FindNamespaceDeclaration(c.SemanticParentCurosr.Usr); Debug.Assert(_parent != null); } else if (c.SemanticParentCurosr.Kind == CursorKind.TranslationUnit || c.SemanticParentCurosr.Kind == CursorKind.UnexposedDecl) { _parent = null; } else { Debug.Assert(false); } }
static private void IndexCursor(IProjectIndex index, Cursor c) { if (FilterCursor(c) == false) return; if (c.Kind == CursorKind.InclusionDirective) { int i = 0; } if (CursorKinds.IsDefinition(c.Kind) || c.Kind == CursorKind.InclusionDirective) { index.Symbols.UpdateDefinition(c); } else if (c.CursorReferenced != null)// && c.Kind != CursorKind.CallExpr) { if (FilterCursor(c.CursorReferenced)) index.Symbols.UpdateReference(c); } foreach (Cursor child in c.Children) { IndexCursor(index, child); } }
public bool FindReferencesTo(Cursor c, File f, FindReferencesDelegate callback) { Library.CXCursorAndRangeVisitor visitor = new Library.CXCursorAndRangeVisitor(); visitor.context = IntPtr.Zero; visitor.visit = delegate(IntPtr ctx, Library.Cursor cur, Library.SourceRange range) { if(callback(_itemStore.CreateCursor(cur), _itemStore.CreateSourceRange(range)) == true) return Library.CXVisitorResult.CXVisit_Continue; return Library.CXVisitorResult.CXVisit_Break; }; return Library.clang_findReferencesInFile(c.Handle, f.Handle, visitor) != Library.CXResult.CXResult_Invalid; }
public static extern CXType clang_getCursorType(Cursor c);
public static extern Cursor clang_getCursorSemanticParent(Cursor c);
public static extern Cursor clang_getCursorLexicalParent(Cursor c);
static Cursor() { NullCursor = Library.clang_getNullCursor(); }
internal static extern uint clang_visitChildren(Cursor parent, CursorVisitor visitor, IntPtr clientData);
internal static extern uint clang_isCursorDefinition(Cursor c);
internal static extern uint clang_hashCursor(Cursor c);
internal static extern ClangString clang_getCursorUSR(Cursor c);
internal static extern ClangString clang_getCursorSpelling(Cursor c);
internal static extern Cursor clang_getCursorReferenced(Cursor c);