Skip to content

Add InstanceMember flag to DeclarationFlags to enable membervar semantic token modifier for self.member#7890

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/investigate-membervar-modifier-issue
Closed

Add InstanceMember flag to DeclarationFlags to enable membervar semantic token modifier for self.member#7890
Copilot wants to merge 3 commits intomainfrom
copilot/investigate-membervar-modifier-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

self.member instance variables were not receiving the membervar semantic token modifier because the protocol had no way to distinguish instance-level assignments (self.x = value) from class-level declarations (class Foo: x = value).

Protocol changes

  • tsp.json (v0.2.0 → v0.3.0): Added InstanceMember = 131072 (1 << 17) to DeclarationFlags; renamed ClassMemberClassAttribute with corrected documentation (it marks any class attribute — method, class variable, or instance variable — as opposed to a standalone local variable or function)
  • typeServerProtocol.ts (v0.4.0 → v0.5.0): Added DeclarationFlags const enum and optional flags?: DeclarationFlags field to RegularDeclaration
export const enum DeclarationFlags {
    ClassAttribute = 1 << 0,  // class attribute (method, class variable, or instance variable)
    // ...
    InstanceMember = 1 << 17, // instance variable assigned via self in a method
}

export interface RegularDeclaration extends DeclarationBase<DeclarationKind.Regular> {
    category: DeclarationCategory;
    flags?: DeclarationFlags;  // new: carries ClassAttribute / InstanceMember etc.
    node: Node;
    name: string | undefined;
}

Test file

Updated semanticToken.py to include both a class-level variable (expected classvar modifier) and a self-assigned instance variable (expected membervar modifier) to make the distinction explicit and testable.

Original prompt

This section details on the original issue you should resolve

<issue_title>self.member does not show membervar modifier</issue_title>
<issue_description>Description:This issue references #7887.

It points out the following behavior:

• self.member does not show a membervar modifier.

• Only variables explicitly declared using the syntax Class c: member = xx are marked as classvar.

This discrepancy makes it difficult to identify member variables consistently.

Request:Please investigate the behavior and provide clarification or a potential fix.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… modifier

Co-authored-by: heejaechang <1333179+heejaechang@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate self.member not showing membervar modifier Add InstanceMember flag to DeclarationFlags to enable membervar semantic token modifier for self.member Feb 20, 2026
Copilot AI requested a review from heejaechang February 20, 2026 18:45
@heejaechang
Copy link
Copy Markdown
Contributor

@copilot for now, class member indicates whether symbol is standalone symbol like local variable or function vs class arributes like method, class variable, instance varialbe. It doesnt indicate @classvar

If classmember is confusing, change it to classattributes or something similar

Co-authored-by: heejaechang <1333179+heejaechang@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 20, 2026

@copilot for now, class member indicates whether symbol is standalone symbol like local variable or function vs class arributes like method, class variable, instance varialbe. It doesnt indicate @clas...

Renamed ClassMemberClassAttribute in both tsp.json and typeServerProtocol.ts and updated the documentation to reflect that it marks any class attribute (method, class variable, or instance variable) as opposed to a standalone local variable or function (commit aac803e).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

self.member does not show membervar modifier

2 participants