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; }
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; }
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); }
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); } }
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); } }
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; }
public static ClangSourceLocation GetNullLocation() { return(new ClangSourceLocation(LibClang.clang_getNullLocation())); }
public static ClangCursorSet CreateCursorSet() { return(new ClangCursorSet(LibClang.clang_createCXCursorSet())); }
public static bool IsTranslationUnit(CursorKind kind) { return(LibClang.clang_isTranslationUnit(kind) != 0); }
public static bool IsReference(CursorKind kind) { return(LibClang.clang_isReference(kind) != 0); }
public TypeViewModel(LibClang.Type t) { _t = t; }
/// <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>()); }
/// <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()); }
public ClangCompileCommand GetCommand(int index) { return(new ClangCompileCommand(LibClang.clang_CompileCommands_getCommand(Handle, (uint)index))); }
public void OnDisplayCursorInspector(LibClang.Cursor c) { _cursorInspectorViewModel.SetCursor(c); _cursorInspectorViewModel.IsSelected = true; }
internal SourceFile(FilePath path, LibClang.TranslationUnit tu) { Path = path; _tu = tu; _fileSymbolMap = new Symbols.FileMapping.FileMap(path); }
public CompletionData(LibClang.CodeCompletion.Result r, CompletionSelection selection) { _result = r; _selection = selection; }
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(); }
public void IncludeFile(LibClang.Indexer.Indexer indexer, string path, LibClang.SourceLocation[] includeStack) { }
/// <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>()); }
public static ClangIndex CreateIndex(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false) { return(new ClangIndex(LibClang.clang_createIndex(excludeDeclarationsFromPch ? 1 : 0, displayDiagnostics ? 1 : 0))); }
public void AddTranslationUnit(LibClang.TranslationUnit tu) { _tus.Add(tu); }
// RemappingFunctions public static ClangRemapping GetRemappings(string path) { return(new ClangRemapping(LibClang.clang_getRemappings(path))); }
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); }
public static ClangRemapping GetRemappingsFromList(string [] filePaths) { return(new ClangRemapping(LibClang.clang_getRemappingsFromFileList(filePaths, (uint)filePaths.Length))); }
public OverloadProvider(LibClang.CodeCompletion.Result r, CompletionSelection selection) { _result = r; _selection = selection; }
public static void ToggleCrashRecovery(bool isEnabled) { LibClang.clang_toggleCrashRecovery((uint)(isEnabled ? 1 : 0)); }
public static bool IsStatement(CursorKind kind) { return(LibClang.clang_isStatement(kind) != 0); }
// HighLevelAPI public static bool IsEntityObjCContainerKind(IndexEntityKind kind) { return(LibClang.clang_index_isEntityObjCContainerKind(kind) != 0); }
public static bool IsUnexposed(CursorKind kind) { return(LibClang.clang_isUnexposed(kind) != 0); }
public static ClangString ConstructUSRObjCClassNative(string className) { return(LibClang.clang_constructUSR_ObjCClass(className)); }
public static void EnableStackTraces() { LibClang.clang_enableStackTraces(); }
public static ClangString ConstructUSRObjCCategoryNative(string className, string categoryName) { return(LibClang.clang_constructUSR_ObjCCategory(className, categoryName)); }
public static ClangSourceRange GetNullRange() { return(new ClangSourceRange(LibClang.clang_getNullRange())); }
public static ClangString ConstructUSRObjCProtocolNative(string protocolName) { return(LibClang.clang_constructUSR_ObjCProtocol(protocolName)); }
public void Dispose() { LibClang.clang_IndexAction_dispose(Handle); }
public static ClangCursor GetNullCursor() { return(new ClangCursor(LibClang.clang_getNullCursor())); }
/// <summary> /// Dispose Clang Compilation Database /// </summary> public void Dispose() { LibClang.clang_CompilationDatabase_dispose(this.Handle); }
public static ClangString ConstructUSRObjCIvarNative(string name, ClangString classUSR) { return(LibClang.clang_constructUSR_ObjCIvar(name, classUSR)); }
/// <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()); }
public static extern ClangString clang_getTypeKindSpelling(LibClang.TypeKind k);
internal SourceFile(string path, LibClang.TranslationUnit tu) { Path = path; _tu = tu; }
public SymbolViewModelBase(LibClang.Cursor c) { Cursor = c; }
public static bool IsAttribute(CursorKind kind) { return(LibClang.clang_isAttribute(kind) != 0); }
public void SelectResult(LibClang.CodeCompletion.Result result, ISegment completionSegment, EventArgs insertionRequestEventArgs) { _context.Callback(result, completionSegment, insertionRequestEventArgs); }
public SourceFileIndex(LibClang.TranslationUnit tu) { _tu = tu; }
public static bool IsDeclaration(CursorKind kind) { return(LibClang.clang_isDeclaration(kind) != 0); }
public CodeLocation(LibClang.SourceLocation loc) : this() { Path = FilePath.Make(loc.File.Name); Offset = loc.Offset; }
public static bool IsExpression(CursorKind kind) { return(LibClang.clang_isExpression(kind) != 0); }
private object ReturnType(LibClang.Type t) { if (t == null) return "null"; return new TypeViewModel(t); }
public static bool IsInvalid(CursorKind kind) { return(LibClang.clang_isInvalid(kind) != 0); }
public static bool IsPreprocessing(CursorKind kind) { return(LibClang.clang_isPreprocessing(kind) != 0); }
static private string FormatMsg(LibClang.Diagnostic diag) { return diag.DiagnosticSeverity.ToString() + " : " + diag.Location + " : " + diag.Spelling; }