microsoft / microsoft/vscode-cpptools

Semantic highlighting - variables vs constants

Open
#11,788 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Feature: Colorization Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Feature Request

At the moment the semantic highlighting is rather limited. For example if you create a constant member variable with constexpr in a class it cannot be distinguished compared to a local variable.

The same applies to constants used in a function, for example.

Solution: Provide more information so users can colorize things differently. For example it would be nice to have the following:

  • variable.global.const
  • variable.local.const
  • property.const (I would prefervariable.member.const, but well property is already used)

For example:

class X {
public:
  int _member;
  static constexpr int memberConst = 222;

  void doSomething(int param) {
    int localVar = 5555;
    constexpr int localConst = 1234;

    // I want the following to possibly have different colors:
    //   _member     -> member variable
    //   memberConst -> member constant
    //   param       -> function parameter (visualize differently)
    //   localVar    -> local variable
    //   localConst  -> local constant
    return _member + memberConst + param + localVar + localConst;
  }
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C++ example in the issue and inspect how semantic highlighting currently classifies variables and constants. Determine where scopes for global, local, member, and parameter symbols are exposed. Done means users can distinguish the requested categories through semantic highlighting, with coverage for the example cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.