private void TokensChanged(object src, TokensChangedEventArgs args) { if (args.NewTokens.Count == 0) { return; } DocumentState state = src as DocumentState; if (state == null) { return; } var temp = TagsChanged; if (temp == null) { return; } int start = args.NewTokens[0].GetStart(state.CurrentSnapshot); int end = args.NewTokens[args.NewTokens.Count - 1].GetEnd(state.CurrentSnapshot); temp(this, new SnapshotSpanEventArgs(new SnapshotSpan(state.CurrentSnapshot, new Span(start, end - start)))); }
public static DocumentState CreateAndRegister(IRustLexer lexer, ITextBuffer buffer) { DocumentState state; if(buffer.Properties.TryGetProperty<DocumentState>(Key, out state)) return state; state = new DocumentState(lexer, buffer.CurrentSnapshot); buffer.Changed += (src, arg) => state.ApplyTextChanges(arg); buffer.Properties.AddProperty(Key, state); return state; }
public static bool TryGet(ITextBuffer b, out DocumentState t) { DocumentState temp; if(!b.Properties.TryGetProperty<DocumentState>(Key, out temp)) { t = null; return false; } t = temp; return true; }