GetClassificationSpans in Visual Studio 2015 returns nothing

I have a tagger (subclass of ITagger) and I'm trying to call GetClassificationSpans, so I can use the classification to search for comments for formatting using tags. This worked in Visual Studio 2013, but now when it starts in Visual Studio 2015, GetClassificationSpans always returns an empty list - even when I examined the range in the debugger, and it definitely passes the range with a comment in it.

Does anyone know what could change in 2015 regarding the call to GetClassificationSpans?

BTW: I get the classifier by importing the IClassifierAggregatorService service in my tag provider (subclass ITaggerProvider) and passing it along with the tagger constructor:

[import]
IClassifierAggregatorService aggregator;

Then I use the following call to tagger in the aggregator that I received from the provider:

IList<ClassificationSpan> lstClassifiers = aggregator.GetClassifier(span.Snapshot.TextBuffer).GetClassificationSpans(span);

And, as I said, the lstClassifiers list is always empty. Exactly the same code worked in VS2013. I can not find anything on the network that mentions any VS2015 changes that might cause this.

Thanks,

+4
source share
3 answers

, . googling, , , ... , GetClassificationSpans() . MSFT , VS Connect.

( MSFT) , TagAggregator IClassifier. :

var service = container.GetService<IClassifierAggregatorService>();
var classifier = service.GetClassifier(textView.TextBuffer);
var spans = classifier.GetClassificationSpans(new SnapshotSpan(...));

:

var service = container.GetService<IViewTagAggregatorFactoryService>();
var aggregator = service.CreateTagAggregator<IClassificationTag>(textView);
var tags = aggregator.GetTags(new SnapshotSpan(...)));

IMappingTagSpan<IClassificationTag> ClassificationSpan, . , -, --- .. . (. VS Connect), .

+2

. , , , :

  • , , GetClassificationSpans. ( -- [ - ].) GetCLassificationSpans BufferChanged/LayoutChanged. ( , , , , , BufferChanged, . , .)
  • , , , , ( ).
  • , v14 DLL SDK , .

, , .

+1

, API- ITagger , "" . API, " , ". , , # VB, , VS2015 Roslyn, , GetClassificationSpans/GetTags , . API, IAccurateTagger, , , "" , , , .

VS2015, , , # VB, API- Roslyn, . , , , IAccurateTagger, , , - .

( , , , . VS2013, , # , .)

0

Source: https://habr.com/ru/post/1614888/


All Articles