internal unsafe TokenSet(TranslationUnit tu, TokenSetHandle handle, SourceRange range) { _tu = tu; Handle = handle; _tokens = new SortedList<int, Token>(); for (uint i = 0; i < handle.Count; i++) { Library.Token tokHandle = handle.GetToken(i); Token tok = new Token(tokHandle, _tu); _tokens.Add(tok.Location.Offset, tok); } }
public static unsafe TokenSet Create(TranslationUnit tu, SourceRange range) { Library.Token* tokens; uint count = 0; Library.clang_tokenize(tu.Handle, range.Handle, &tokens, &count); if (count == 0) return null; TokenSetHandle handle = new TokenSetHandle(tu, tokens, count); if (handle == null) return null; return new TokenSet(tu, handle, range); }
/// <summary> /// The EnsureItemAt /// </summary> /// <param name="index">The index<see cref="int"/></param> /// <returns>The <see cref="CompletionResult"/></returns> protected unsafe override CompletionResult EnsureItemAt(int index) { uint fixitCount = clang.clang_getCompletionNumFixIts(this.m_value, (uint)index); FixIt[] fixIts = new FixIt[fixitCount]; for (uint J = 0; J < fixitCount; J++) { CXSourceRange xSourceRange; string text = clang.clang_getCompletionFixIt(this.m_value, (uint)index, J, out xSourceRange).ToStringAndDispose(); SourceRange sourceRange = new SourceRange(xSourceRange); fixIts[J] = new FixIt(text, sourceRange); } return(new CompletionResult(this.m_value->Results[index], fixIts)); }
/// <summary> /// The FindReferencesInFiles /// </summary> /// <param name="file">The file<see cref="File"/></param> /// <param name="searchFunc">The searchFunc<see cref="Func{Cursor, SourceRange, bool}"/></param> /// <returns>The <see cref="CXResult"/></returns> public CXResult FindReferencesInFiles(File file, Func <Cursor, SourceRange, bool> searchFunc) { CXCursorAndRangeVisitor cursorAndRangeVisitor = default(CXCursorAndRangeVisitor); cursorAndRangeVisitor.Visit = Marshal.GetFunctionPointerForDelegate(new visit((context, cxCursor, cxRange) => { if (searchFunc != null) { Cursor cursor = new Cursor(cxCursor); SourceRange sourceRange = new SourceRange(cxRange); bool result = searchFunc(cursor, sourceRange); return(result ? CXVisitorResult.CXVisit_Continue : CXVisitorResult.CXVisit_Break); } return(CXVisitorResult.CXVisit_Break); })); return(clang.clang_findReferencesInFile(this.m_value, (IntPtr)file.Value, cursorAndRangeVisitor)); }
public TokenSet GetTokens(SourceRange range) { TokenSet set = TokenSet.Create(_tu, range); return set; }
static SourceRange() { NullRange = Library.clang_getNullRange(); }
internal static unsafe extern void clang_tokenize(IntPtr tu, SourceRange Range, Token** Tokens, uint* NumTokens);
internal static extern SourceLocation clang_getRangeStart(SourceRange range);
internal static unsafe extern ClangString clang_getDiagnosticFixIt(IntPtr diagnostic, uint fixIt, SourceRange* replacementRange);
internal static extern uint clang_equalRanges(SourceRange r1, SourceRange r2);
public bool Accumulate(Cursor c, SourceRange r) { _curs.Add(c); return true; }
public static unsafe TokenSetHandle Create(TranslationUnit tu, SourceRange range) { Library.Token* tokens; uint count = 0; Library.clang_tokenize(tu.Handle, range.Handle, &tokens, &count); return count > 0 ? new TokenSetHandle(tu, tokens, count) : null; }