Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
 public TokenSet GetTokens(SourceRange range)
 {
     TokenSet set = TokenSet.Create(_tu, range);
     return set;
 }
Ejemplo n.º 6
0
 static SourceRange()
 {
     NullRange = Library.clang_getNullRange();
 }
Ejemplo n.º 7
0
 internal static unsafe extern void clang_tokenize(IntPtr tu, SourceRange Range, Token** Tokens, uint* NumTokens);
Ejemplo n.º 8
0
 internal static extern SourceLocation clang_getRangeStart(SourceRange range);
Ejemplo n.º 9
0
 internal static unsafe extern ClangString clang_getDiagnosticFixIt(IntPtr diagnostic, uint fixIt, SourceRange* replacementRange);
Ejemplo n.º 10
0
 internal static extern uint clang_equalRanges(SourceRange r1, SourceRange r2);
Ejemplo n.º 11
0
 public bool Accumulate(Cursor c, SourceRange r)
 {
     _curs.Add(c);
     return true;
 }
Ejemplo n.º 12
0
        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;
        }