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); }