Acuminator Coloring

Acuminator Dalek

Good day, everyone!
This is a second post in the series dedicated to the Acuminator. Today I would like to tell you more about the Acuminator syntax coloring.

Feature Overview

Syntax coloring is one of the most common and useful features given to programmers by development tools. It uses a simple idea – to emphasize some text in program by coloring it in different colors. This allows quickly and clearly show to a reader keywords, variable declarations and many other useful things. Our attention is drawn to words with a different color and this is used to show us the important parts of the code. The color itself also gives some useful info. You can quickly see if some type is a struct, interface, enum or a class. Such things greatly improve developer’s productivity. Of course, you can figure out all this information by yourself but this will take a little bit more time. And it is not a secret that today the most expensive part of the software development is the programmer’s time.

The same idea to emphasize key syntax constructs in BQL lies behind the Acuminator syntax coloring. It was rather inconvenient to look through a large BQL queries like the one on a picture below. It sure wasn’t easy for me to find out what parameters does this query require.

A large BQL query example
BQL query

So, it was quite natural to wish to colorize BQL. And after we started development we quickly came up with a little classification for BQL parts:

  • BQL Operators – commands like PXSelect, logical operators like Or and functions like Max;
  • BQL Parameters – the “keywords” which define parameters for a query: Required, Optional, Current and etc;
  • DAC and its fields;
  • DAC cache extension is colored differently to allow user to differentiate between DAC and its extension;
  • BQL Constants – there are actually two parts: the “prefix” and the ” ending “. In Acumatica the BQL constants usually consists of two parts. For example, APDocStatus.hold. This is actually quite similar to the <DAC>.<Dac field> pattern which appears in BQL frequently. Therefore we decided to add separate coloring for prefix and ending.

Check out the same BQL query colored by Acuminator

A big colored  BQL query example
Colored BQL query

The DAC and DAC fields types actually are colored even outside of the BQL scope. Later we added two more types to color – PXAction and PXGraph.

There is also another small thing colored by Acuminator – the angle braces. Sometimes there are quite a few angle braces stacked up together in a BQL query. This makes it difficult to edit the query. The matching opening and closing angle brackets of the query are colored with the same color by Acuminator. This feature was inspired by Viasfora – a Visual Studio extension which does the same thing for the normal braces.
There are 14 different colors for braces – each for a different nesting level. If there are more than 14 nesting levels of angle braces in a BQL query then the colors will be cycled all over again.

Custom Colors

Our designer worked very hard on the default colors but in case they doesn’t suit your taste you can specify your own in the Visual Studio settings – Tools -> Options -> Environment -> Fonts and Colors:

Acuminator Fonts And Colors section
Acuminator Fonts And Colors section

The picture above shows the section of Acuminator coloring settings. You can specify custom color for:

  • BQL operators, parameters and constants (for prefix and ending separately) ;
  • DACs, DAC cache extensions and DAC fields;
  • actions;
  • graphs.
  • for each nesting level of angle braces in BQL

The red squares on the picture indicate the customizable settings for the selected item. You can change foreground color, background color, change the font, font size or make the font bold.

Acuminator supports custom Visual Studio themes. It has two default color sets – for light and dark themes. The set for the dark theme will be applied if Acuminator decides that the code editor background is “dark”.
You can specify and maintain custom colors for different themes independently. For example, you can set red color for DACs in the dark theme then switch to the blue theme and the default DAC’s color for a light theme will be used. Then you can switch back to the dark theme and see that the DAC’s color is still red.

Coloring Settings

Besides the ability to set custom colors there are also different settings for the coloring mechanism. To see them you need to open Tools -> Options -> Acuminator -> General -> BQL Coloring:

Acuminator Visual Studio Settings, coloring section selected
Acuminator Visual Studio Settings

You can see BQL coloring options on a picture above. Here is a description of what they do:

  • Colorize code only inside BQL commands.
    Some people prefer to colorize only BQL queries and nothing else. This mode exists to satisfy their needs. All code outside of the BQL query won’t be colored. The mode is turned off by default.
  • Enable coloring – enable/disable the Acuminator coloring.
    We want to give a programmer an ability to turn off the unused feature anytime. We also know that every feature has its toll on performance. So, if you use Acuminator only for its static analysis or other features and you don’t need syntax coloring you can just turn it off. This will increase your IDE’s performance and you can continue using other Acuminator features.
  • Enable PXGraph/PXAction coloring – enable or disable the coloring of graph/graph’s actions. We added these features to the coloring later therefore there is an option to disable them. They are turned on by default.
  • Use RegEx colorizer. This is a legacy mode. The first version of the Acuminator coloring didn’t use Roslyn. Instead it was based on regular expressions and was quite primitive with no support for complex BQL operators or FBQL. It also colorizes incorrectly in some rare scenarios. We do not recommend to use it and this feature is turned off by default.
    However, there is one use case when you may want to use it – when you look at the separate code file with no solution. The Roslyn-based coloring in order to work correctly requires a complete project with metada and references to Acumatica Platform. The RegEx colorizer parses BQL instead of analysing its metadata. Therefore it will work on any provided code file.
CategoriesUncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *