A C # syntax highlighting plugin

Source: Internet
Author: User

Syntax highlighting is very helpful for programmers to read code, although VisualStudio itself supports C # syntax highlighting, but only a few elements, such as keywords, class names, strings, and so on, and our code theme: variables, functions, properties, events, etc. are not highlighted, as follows:

????Varnodes =FromIdInchGetidentifiersinspans (Doc. Workspace, Doc. SemanticModel, spans)
????????????????Letnode = doc. Syntaxroot.findnode (ID. Textspan)
????????????????let symbol = doc. Semanticmodel.getsymbolinfo (getexpression (node)). Symbol
???????????????? where symbol! = null
???????????????? let type = roslynsymbolparser???????????????? where type! = null
???????????????? let Classficationtype = _classificationmap[type]
???????????????? select ID. Textspan.totagspan (Spans[0]. Snapshot, Classficationtype);
/span>

Some third-party controls, such as visual assist, have been enhanced for this shortcoming, but Visualassist is a charge control, and I found a control that, although it worked very well, was too weak to parse in the middle of the code, and once there was a syntax error , its syntax highlighting is aging, resulting in a constant flicker of the interface. This bug causes the syntax highlighting feature to be largely unavailable. Originally wanted to write their own, the results found that VisualStudio extension of the relevant documents too little, and there is no time to devote to research it, it was once shelved.

Today, on GitHub, I found a project with a syntax highlighting control, and the project itself was not roslyn-colorizer, so it was not released as a plugin. But a good example of code, based on its simple change, adding parameters, member variables, attributes, events, enumerations, functions and other elements of the syntax highlighting, the preceding code plus syntax highlighting plugin has become the following form:

????Varnodes =FromIdInchGetidentifiersinspans(Doc.Workspace,Doc.SemanticModel,Spans)
????????????????Letnode =Doc.Syntaxroot.FindNode(ID.Textspan)
????????????????LetSymbol =Doc.SemanticModel.Getsymbolinfo(GetExpression(node)).Symbol
????????????????whereSymbol! =Null
????????????????LetType =Roslynsymbolparser. Getsymboltype(symbol)
???????????????? where type! = NULL
???????????????? let classficationtype = _classificationmap[Type]
???????????????? select ID. Textspan. Totagspan(spans[0]. Snapshot, Classficationtype);

?

A C # syntax highlighting plugin

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.