Skip to content

Benio101/Color.Attribute

Repository files navigation

Color.Attribute

Visual Studio extension: Color C++ Attributes.

Status

Branch Build Status
2022 Build status
2019 Build status
2017 Build status

Description

Extension adds options to overwrite colors of certain C++ Attributes.
Extension works in files of ContentType "C/C++", eg .cpp or .h files.

Usage

New entries will appear in ToolsOptionsEnvironmentFonts and ColorsText Editor.
Each will begin with C++ Attribute: prefix.

  • Edit their color values, until you want to keep extension default ones (listed below).
  • If you don't want to change some attribute's color at all, set it's Item foreground value to Automatic.

Preview

Default Attributes without extension Color Attributes with extension enabled

Limitations

In order to provide fast execution, some rare syntax patterns are not supported by extension right now. There are no plans to waive those restrictions until intellisense shall classify C++ attributes.

Nested [[ & ]]

Due to high cost of parsing balanced-token, extension non greedily matches anything between [[ and ]] in SnapshotSpan, splits content by , and trims, then finally matches standard attributes. Thus, attribute containing nested double squares can be incorrectly colored, eg [[test::covered([[likely]])]].

Comments

Comments in attributes are not supported. They are treated as text for faster execution. This can cause some attributes to be incorrectly colored, eg [[using/*civ1*/civ2: fast, nodiscard]].

Multiline attributes

If multiline attribute will be split into multiple spans upon classification, it won't be matched at all.

deprecated and nodiscard reason

deprecated and nodiscard attribute's reason, if present, must be enclosed in ", and such created string-literal can be prefixed by any number of characters different than ", eg [[deprecated(u8"Use API v2 instead.")]], but not [[deprecated(CMacro_Reason)]].

assume expression

Assume's expression can be a balanced-token, eg [[assume(max(a, b) > 0)]].

List of Attributes

Extension exposes all Standard Attributes for customization.

Full list of customizable Attribute entries, with their default colors:

Attribute entry Type Color RGB (0 – 255)
C++ Attribute Plain Dark White 176, 176, 176
assume Positive Green 176, 224, 128
assume: Expression Plain Dark White 176, 176, 176
carries_dependency Keyword Blue 128, 176, 224
deprecated Warning Yellow 224, 224, 128
deprecated: Reason String Red 224, 128, 128
fallthrough Flow Violet 128, 128, 224
likely Positive Green 128, 224, 128
maybe_unused Warning Yellow 224, 224, 128
no_unique_address Keyword Blue 128, 176, 224
nodiscard Keyword Blue 128, 176, 224
nodiscard: Reason String Red 224, 128, 128
noreturn Warning Yellow 224, 224, 128
optimize_for_synchronized Keyword Blue 128, 176, 224
unlikely Negative Red 224, 128, 128

Older versions

2019

2017