Exemplo n.º 1
0
 private IResult FindItem(string name, LibClang.CursorKind k)
 {
     IResult result;
     if(_items.TryGetValue(new Tuple<string, LibClang.CursorKind>(name, k), out result) == false)
         return null;
     return result;
 }
Exemplo n.º 2
0
        private string GetTypeString(LibClang.Type type)        
        {
            string result;

            string name = _declaration.Spelling;

            if (type.PointeeType != null)
                result = GetTypeString(type.PointeeType);
            else if (type.DeclarationCursor != null)
                //If there is a declaration, use its name. This removes any namespaces from class / struct types. eg "ClassFoo" rather than "NamespaceBar::ClassFoo"
                result = type.DeclarationCursor.Spelling;
            else
                result = type.Spelling;
                        
            if (type.Kind == LibClang.TypeKind.Pointer)
                result = result + "*";

            if (type.Kind == LibClang.TypeKind.LValueReference)
                result = result + "&";

            if (type.Kind == LibClang.TypeKind.RValueReference)
                result = result + "&&";

            if (type.IsConstQualified)
                result = result + " const ";

            return result;
        }
Exemplo n.º 3
0
 private static bool JumpToDeclaration(LibClang.Cursor c)
 {
     return ((c.Kind == CursorKind.Constructor ||
                 c.Kind == CursorKind.Destructor ||
                 c.Kind == CursorKind.CXXMethod ||
                 c.Kind == CursorKind.FunctionDecl)
         && c.IsDefinition);
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        public void AddSourceFile(string path, LibClang.TranslationUnit tu)
        {
            IProjectItem item = new SourceFile(path, tu);

            _items.Add(path, item);

            foreach (TranslationUnit.HeaderInfo header in tu.HeaderFiles)
            {
                RecordHeader(header, tu);
            }
        }
Exemplo n.º 6
0
 static unsafe internal Results CompleteAt(TranslationUnit tu, string fileName, int line, int col, LibClang.Library.UnsavedFile[] unsaved)
 {
     uint options = CodeCompletion.Library.clang_defaultCodeCompleteOptions();
     CodeCompletion.Library.CXCodeCompleteResults* results = CodeCompletion.Library.clang_codeCompleteAt(tu.Handle, fileName, (uint)line, (uint)col,
                                                                                     unsaved.Length > 0 ? unsaved : null,
                                                                                     (uint)unsaved.Length,
                                                                                     3);/*
                                                                                     CodeCompletion.Library.clang_defaultCodeCompleteOptions());*/
     Int64 p = Library.clang_codeCompleteGetContexts(results);
     if (results != null && results->NumberResults > 0)
     {
         Results rs = new Results(results, tu);
         return rs;
     }
     return null;
 }
Exemplo n.º 7
0
 public static ClangSourceLocation GetNullLocation()
 {
     return(new ClangSourceLocation(LibClang.clang_getNullLocation()));
 }
Exemplo n.º 8
0
 public static ClangCursorSet CreateCursorSet()
 {
     return(new ClangCursorSet(LibClang.clang_createCXCursorSet()));
 }
Exemplo n.º 9
0
 public static bool IsTranslationUnit(CursorKind kind)
 {
     return(LibClang.clang_isTranslationUnit(kind) != 0);
 }
Exemplo n.º 10
0
 public static bool IsReference(CursorKind kind)
 {
     return(LibClang.clang_isReference(kind) != 0);
 }
Exemplo n.º 11
0
 public TypeViewModel(LibClang.Type t)
 {
     _t = t;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Get Clang File
 /// </summary>
 /// <param name="file_name">File Name</param>
 /// <returns>Clang</returns>
 public ClangFile GetFile(string file_name)
 {
     return(LibClang.clang_getFile(this.Handle, file_name).ToManaged <ClangFile>());
 }
Exemplo n.º 13
0
 /// <summary>
 /// Get Argument
 /// </summary>
 /// <param name="i">Index</param>
 /// <returns>Argument</returns>
 public string GetArgument(int i)
 {
     return(LibClang.clang_CompileCommand_getArg(this.Handle, (uint)i).ToManaged());
 }
Exemplo n.º 14
0
 public ClangCompileCommand GetCommand(int index)
 {
     return(new ClangCompileCommand(LibClang.clang_CompileCommands_getCommand(Handle, (uint)index)));
 }
Exemplo n.º 15
0
 public void OnDisplayCursorInspector(LibClang.Cursor c)
 {
     _cursorInspectorViewModel.SetCursor(c);
     _cursorInspectorViewModel.IsSelected = true;
 }
Exemplo n.º 16
0
 internal SourceFile(FilePath path, LibClang.TranslationUnit tu)
 {
     Path = path;
     _tu = tu;
     _fileSymbolMap = new Symbols.FileMapping.FileMap(path);
 }
Exemplo n.º 17
0
 public CompletionData(LibClang.CodeCompletion.Result r, CompletionSelection selection)
 {
     _result = r;
     _selection = selection;
 }
Exemplo n.º 18
0
 private string GetInsertionText(LibClang.CodeCompletion.Result result, EventArgs insertionRequestEventArgs, out int caretLocation)
 {
     StringBuilder sb = new StringBuilder();
     
     caretLocation = -1;
     foreach(ResultChunk rc in result.Chunks)
     {
         switch(rc.Kind)
         {
             case (ChunkKind.TypedText):
             case (ChunkKind.Text):                    
                 sb.Append(rc.Text);
                 break;
             case (ChunkKind.Placeholder):
                 if (caretLocation == -1)
                     caretLocation = sb.Length;
                 break;
             case (ChunkKind.LeftParen):
                 sb.Append('(');
                 break;
             case (ChunkKind.RightParen):
                 sb.Append(')');
                 break;
             case (ChunkKind.LeftBracket):
                 sb.Append(']');
                 break;
             case (ChunkKind.RightBracket):
                 sb.Append('[');
                 break;
             case (ChunkKind.LeftBrace):
                 sb.Append('{');
                 break;
             case (ChunkKind.RightBrace):
                 sb.Append('}');
                 break;
             case (ChunkKind.LeftAngle):
                 sb.Append('<');
                 break;
             case (ChunkKind.RightAngle):
                 sb.Append('>');
                 break;
             case (ChunkKind.Comma):
                 sb.Append(", ");
                 break;
             case (ChunkKind.Colon):
                 sb.Append(':');
                 break;
             case (ChunkKind.SemiColon):
                 sb.Append(';');
                 break;
             case (ChunkKind.Equal):
                 sb.Append('=');
                 break;
             case (ChunkKind.HorizontalSpace):
                 sb.Append(' ');
                 break;
             case (ChunkKind.VerticalSpace):
                 sb.Append('\n');
                 break;
         }
     }
     if (insertionRequestEventArgs is System.Windows.Input.TextCompositionEventArgs)
     {
       //  sb.Append((insertionRequestEventArgs as System.Windows.Input.TextCompositionEventArgs).Text);
     }
     
     return sb.ToString();
 }
Exemplo n.º 19
0
        public void IncludeFile(LibClang.Indexer.Indexer indexer, string path, LibClang.SourceLocation[] includeStack)
        {

        }
Exemplo n.º 20
0
 /// <summary>
 /// Get Clang Compile Command
 /// </summary>
 /// <param name="complete_filename">Complete Filename</param>
 /// <returns>Clang Compile Command</returns>
 public ClangCompileCommands GetCompileCommands(string complete_filename)
 {
     return(LibClang.clang_CompilationDatabase_getCompileCommands(this.Handle, complete_filename).ToManaged <ClangCompileCommands>());
 }
Exemplo n.º 21
0
 public static ClangIndex CreateIndex(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false)
 {
     return(new ClangIndex(LibClang.clang_createIndex(excludeDeclarationsFromPch ? 1 : 0, displayDiagnostics ? 1 : 0)));
 }
Exemplo n.º 22
0
 public void AddTranslationUnit(LibClang.TranslationUnit tu)
 {
     _tus.Add(tu);
 }
Exemplo n.º 23
0
        // RemappingFunctions

        public static ClangRemapping GetRemappings(string path)
        {
            return(new ClangRemapping(LibClang.clang_getRemappings(path)));
        }
Exemplo n.º 24
0
        private static bool CanJumpTo(LibClang.Cursor cursor, int offset)
        {
            if (cursor.Extent == null)
                return false;

            if (cursor.Kind == LibClang.CursorKind.InclusionDirective ||
                cursor.Kind == LibClang.CursorKind.CXXMethod) // Added CXXMethod to improve usage with operator over loads eg 'operator=' which are almost entirely TokenKind.Keyword not TokenKind.Identifier             
                return true;

            LibClang.Token tok = cursor.Extent.GetTokenAtOffset(offset);
            return (tok != null && tok.Kind == LibClang.TokenKind.Identifier);
        }
Exemplo n.º 25
0
 public static ClangRemapping GetRemappingsFromList(string [] filePaths)
 {
     return(new ClangRemapping(LibClang.clang_getRemappingsFromFileList(filePaths, (uint)filePaths.Length)));
 }
Exemplo n.º 26
0
 public OverloadProvider(LibClang.CodeCompletion.Result r, CompletionSelection selection)
 {
     _result = r;
     _selection = selection;
 }
Exemplo n.º 27
0
 public static void ToggleCrashRecovery(bool isEnabled)
 {
     LibClang.clang_toggleCrashRecovery((uint)(isEnabled ? 1 : 0));
 }
Exemplo n.º 28
0
 public static bool IsStatement(CursorKind kind)
 {
     return(LibClang.clang_isStatement(kind) != 0);
 }
Exemplo n.º 29
0
        // HighLevelAPI

        public static bool IsEntityObjCContainerKind(IndexEntityKind kind)
        {
            return(LibClang.clang_index_isEntityObjCContainerKind(kind) != 0);
        }
Exemplo n.º 30
0
 public static bool IsUnexposed(CursorKind kind)
 {
     return(LibClang.clang_isUnexposed(kind) != 0);
 }
Exemplo n.º 31
0
 public static ClangString ConstructUSRObjCClassNative(string className)
 {
     return(LibClang.clang_constructUSR_ObjCClass(className));
 }
Exemplo n.º 32
0
 public static void EnableStackTraces()
 {
     LibClang.clang_enableStackTraces();
 }
Exemplo n.º 33
0
 public static ClangString ConstructUSRObjCCategoryNative(string className, string categoryName)
 {
     return(LibClang.clang_constructUSR_ObjCCategory(className, categoryName));
 }
Exemplo n.º 34
0
 public static ClangSourceRange GetNullRange()
 {
     return(new ClangSourceRange(LibClang.clang_getNullRange()));
 }
Exemplo n.º 35
0
 public static ClangString ConstructUSRObjCProtocolNative(string protocolName)
 {
     return(LibClang.clang_constructUSR_ObjCProtocol(protocolName));
 }
Exemplo n.º 36
0
 public void Dispose()
 {
     LibClang.clang_IndexAction_dispose(Handle);
 }
Exemplo n.º 37
0
 public static ClangCursor GetNullCursor()
 {
     return(new ClangCursor(LibClang.clang_getNullCursor()));
 }
Exemplo n.º 38
0
 /// <summary>
 /// Dispose Clang Compilation Database
 /// </summary>
 public void Dispose()
 {
     LibClang.clang_CompilationDatabase_dispose(this.Handle);
 }
Exemplo n.º 39
0
 public static ClangString ConstructUSRObjCIvarNative(string name, ClangString classUSR)
 {
     return(LibClang.clang_constructUSR_ObjCIvar(name, classUSR));
 }
Exemplo n.º 40
0
 /// <summary>
 /// Get Mapped Source Content
 /// </summary>
 /// <param name="i">Index</param>
 /// <returns>Mapped Source Content</returns>
 public string GetMappedSourceContent(int i)
 {
     return(LibClang.clang_CompileCommand_getMappedSourceContent(this.Handle, (uint)i).ToManaged());
 }
Exemplo n.º 41
0
 public static extern ClangString clang_getTypeKindSpelling(LibClang.TypeKind k);
Exemplo n.º 42
0
 internal SourceFile(string path, LibClang.TranslationUnit tu)
 {
     Path = path;
     _tu = tu;
 }
Exemplo n.º 43
0
 public SymbolViewModelBase(LibClang.Cursor c)
 {
     Cursor = c;
 }
Exemplo n.º 44
0
 public static bool IsAttribute(CursorKind kind)
 {
     return(LibClang.clang_isAttribute(kind) != 0);
 }
Exemplo n.º 45
0
 public void SelectResult(LibClang.CodeCompletion.Result result, ISegment completionSegment, EventArgs insertionRequestEventArgs)
 {
     _context.Callback(result, completionSegment, insertionRequestEventArgs);
 }
Exemplo n.º 46
0
 public SourceFileIndex(LibClang.TranslationUnit tu)
 {
     _tu = tu;
 }
Exemplo n.º 47
0
 public static bool IsDeclaration(CursorKind kind)
 {
     return(LibClang.clang_isDeclaration(kind) != 0);
 }
Exemplo n.º 48
0
 public CodeLocation(LibClang.SourceLocation loc) : this()
 {
     Path = FilePath.Make(loc.File.Name);
     Offset = loc.Offset;            
 }
Exemplo n.º 49
0
 public static bool IsExpression(CursorKind kind)
 {
     return(LibClang.clang_isExpression(kind) != 0);
 }
Exemplo n.º 50
0
 private object ReturnType(LibClang.Type t)
 {
     if (t == null) return "null";
     return new TypeViewModel(t);
 }
Exemplo n.º 51
0
 public static bool IsInvalid(CursorKind kind)
 {
     return(LibClang.clang_isInvalid(kind) != 0);
 }
Exemplo n.º 52
0
 public static bool IsPreprocessing(CursorKind kind)
 {
     return(LibClang.clang_isPreprocessing(kind) != 0);
 }
Exemplo n.º 53
0
 static private string FormatMsg(LibClang.Diagnostic diag)
 {
     return diag.DiagnosticSeverity.ToString() + " : " + diag.Location + " : " + diag.Spelling;
 }