Esempio n. 1
0
        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))));
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }