Example #1
0
 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
 }
Example #2
0
 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);            
 }
Example #3
0
        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;
        }
Example #4
0
 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);
 }
Example #5
0
        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);
        }
Example #6
0
        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);
            }
        }
Example #7
0
 public void UpdateDefinition(Cursor c)
 {
  //   Debug.Assert(c.Kind == CursorKind.VarDecl);
     Debug.Assert(c.IsDefinition);
     if (_definition == null)
         _definition = c;
 }
Example #8
0
 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);
     }
 }
Example #9
0
 public void UpdateDefinition(Cursor c)
 {
     Debug.Assert(CursorKinds.IsFunctionEtc(c.Kind));
     Debug.Assert(c.IsDefinition);
     if (_definition == null)
         _definition = c;
 }
Example #10
0
 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);
 }
Example #11
0
 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));
     }
 }
Example #12
0
 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);
 }
Example #13
0
        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);
            }
        }
Example #14
0
 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;
 }
Example #15
0
        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);
            }
        }
Example #16
0
 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;
 }
Example #17
0
 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;
     }
 }
Example #18
0
 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);
     }
 }
Example #19
0
        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);
            }
        }
Example #20
0
 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;
 }
Example #21
0
 public static extern CXType clang_getCursorType(Cursor c);
Example #22
0
 public static extern Cursor clang_getCursorSemanticParent(Cursor c);
Example #23
0
 public static extern Cursor clang_getCursorLexicalParent(Cursor c);
Example #24
0
 static Cursor()
 {
     NullCursor = Library.clang_getNullCursor();
 }
Example #25
0
 internal static extern uint clang_visitChildren(Cursor parent, CursorVisitor visitor, IntPtr clientData);
Example #26
0
 internal static extern uint clang_isCursorDefinition(Cursor c);
Example #27
0
 internal static extern uint clang_hashCursor(Cursor c);
Example #28
0
 internal static extern ClangString clang_getCursorUSR(Cursor c);
Example #29
0
 internal static extern ClangString clang_getCursorSpelling(Cursor c);
Example #30
0
 internal static extern Cursor clang_getCursorReferenced(Cursor c);