IXmlAnalysisProvider.OnlyPrimary

5 views
Skip to first unread message

Dmitry Dolotovskikh

unread,
Sep 7, 2017, 12:25:10 PM9/7/17
to resharper-plugins
Hi

My plugin class implements IXmlAnalysisProvider interface. In 2017.2 SDK the new property OnlyPrimary has been added.


How to implement it in my class? I checked that in JetBrains classes it sometime returns true or false. What is it meaning?

Thanks.


Matt Ellis

unread,
Sep 12, 2017, 8:31:34 AM9/12/17
to resharper-plugins
Hi Dmitry. The OnlyPrimary property is used to see if the analysis provider should be called only when the primary PSI file is IXmlFile (return true) or when it should also be called for injected XML PSI files (return false).

An injected PSI is built on top of a node of another language. ReSharper supports injecting XML into C# and JS string literals - alt+enter and "Mark as injected language". If you do this, R# will treat that string literal as an individual IXmlFile.

In R#, the only providers that return false (and are used for injections as well) are XmlSyntaxAnalysisProvider and XmlIdentifierHighlightingAnalysisProvider, which makes sense - you always want to know if an XML file is invalid, and get syntax highlighting, even if it's injected. Conversely, you won't be doing web.config analysis on injected XML, only a web.config file.

Regards
Matt
Reply all
Reply to author
Forward
0 new messages