public IClassifier GetClassifier(ITextBuffer textBuffer)
        {
            Debug.Assert(_classificationRegistry != null);
              Debug.Assert(_standardClassification != null);

              var classifierKey = typeof(SyntaxClassifier);
              SyntaxClassifier classifier;
              if (!textBuffer.Properties.TryGetProperty(classifierKey, out classifier))
              {
            classifier = new SyntaxClassifier(_standardClassification, _classificationRegistry, textBuffer);
            textBuffer.Properties.AddProperty(classifierKey, classifier);
              }
              return classifier;
        }
        public IClassifier GetClassifier(ITextBuffer textBuffer)
        {
            Debug.Assert(_classificationRegistry != null);
            Debug.Assert(_standardClassification != null);

            var classifierKey = typeof(SyntaxClassifier);
            SyntaxClassifier classifier;

            if (!textBuffer.Properties.TryGetProperty(classifierKey, out classifier))
            {
                classifier = new SyntaxClassifier(_standardClassification, _classificationRegistry, textBuffer);
                textBuffer.Properties.AddProperty(classifierKey, classifier);
            }
            return(classifier);
        }
Example #3
0
        private int GetTokenExtent(NemerleSource source, ITextSnapshot snapshot, SyntaxClassifier.SpanInfo spanInfo, out int line, out int startIdx, out int endIdx)
        {
            switch (spanInfo.Type)
              {
            case SyntaxClassifier.SpanType.String:
            case SyntaxClassifier.SpanType.RecursiveString:
            case SyntaxClassifier.SpanType.VerbatimString:
              // TODO: implement logic for $" $(x.|)  "
              goto default;

            case SyntaxClassifier.SpanType.Operator:
              if (!spanInfo.Span.IsEmpty && snapshot[spanInfo.Span.End - 1] == '.')
            return GetDefaultExtent(out line, out startIdx, out endIdx);
              else
            goto default;

            default:
              var loc = Utils.ToNLocation(source.FileIndex, new SnapshotSpan(snapshot, spanInfo.Span));
              Debug.Assert(loc.Line == loc.EndLine);
              line = loc.Line - 1;
              startIdx = loc.Column - 1;
              endIdx = loc.EndColumn - 1;
              return VSConstants.S_OK;
              }
        }
Example #4
0
 public static void InsertClassification(List<SyntaxClassifier.SpanInfo> items, SyntaxClassifier.SpanInfo span)
 {
     var index = items.BinarySearch(span);
       items.Insert(index >= 0 ? index : ~index, span);
 }