示例#1
0
文件: Reference.cs 项目: JadeHub/Jade
 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
 }
示例#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);            
 }
示例#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;
        }
示例#4
0
文件: FieldDecl.cs 项目: JadeHub/Jade
 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);
 }
示例#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);
        }
示例#6
0
文件: ClassDecl.cs 项目: JadeHub/Jade
        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);
            }
        }
示例#7
0
 public void UpdateDefinition(Cursor c)
 {
  //   Debug.Assert(c.Kind == CursorKind.VarDecl);
     Debug.Assert(c.IsDefinition);
     if (_definition == null)
         _definition = c;
 }
示例#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);
     }
 }
示例#9
0
 public void UpdateDefinition(Cursor c)
 {
     Debug.Assert(CursorKinds.IsFunctionEtc(c.Kind));
     Debug.Assert(c.IsDefinition);
     if (_definition == null)
         _definition = c;
 }
示例#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);
 }
示例#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));
     }
 }
示例#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);
 }
示例#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);
            }
        }
示例#14
0
文件: Cursor.cs 项目: JadeHub/Jade
 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;
 }
示例#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);
            }
        }
示例#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;
 }
示例#17
0
文件: EnumDecl.cs 项目: JadeHub/Jade
 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;
     }
 }
示例#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);
     }
 }
示例#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);
            }
        }
示例#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;
 }
示例#21
0
 public static extern CXType clang_getCursorType(Cursor c);
示例#22
0
 public static extern Cursor clang_getCursorSemanticParent(Cursor c);
示例#23
0
 public static extern Cursor clang_getCursorLexicalParent(Cursor c);
示例#24
0
 static Cursor()
 {
     NullCursor = Library.clang_getNullCursor();
 }
示例#25
0
 internal static extern uint clang_visitChildren(Cursor parent, CursorVisitor visitor, IntPtr clientData);
示例#26
0
 internal static extern uint clang_isCursorDefinition(Cursor c);
示例#27
0
 internal static extern uint clang_hashCursor(Cursor c);
示例#28
0
 internal static extern ClangString clang_getCursorUSR(Cursor c);
示例#29
0
 internal static extern ClangString clang_getCursorSpelling(Cursor c);
示例#30
0
 internal static extern Cursor clang_getCursorReferenced(Cursor c);