Skip to content

Commit

Permalink
fix Any being coloured as a variable instead of a type
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed May 21, 2024
1 parent bd4ce29 commit ba7d848
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ export class SemanticTokensWalker extends ParseTreeWalker {
case TypeCategory.Module:
this._addItem(node.start, node.length, SemanticTokenTypes.namespace, []);
return;
// handled bellow
case TypeCategory.Any:
if (type.specialForm) {
this._addItem(node.start, node.length, SemanticTokenTypes.type, []);
return;
}
// eslint-disable-next-line no-fallthrough -- intentional fallthrough. these are handled below
case TypeCategory.Unknown:
case TypeCategory.TypeVar:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ if (process.platform !== 'win32' || !process.env['CI']) {
const result = semanticTokenizeSampleFile('unknown.py');
expect(result).toStrictEqual([
{ type: 'namespace', modifiers: [], start: 5, length: 6 }, // typing
{ type: 'variable', modifiers: [], start: 19, length: 3 }, // Any
{ type: 'type', modifiers: [], start: 19, length: 3 }, // Any
{ type: 'variable', modifiers: [], start: 19, length: 3 },
{ type: 'function', modifiers: ['definition'], start: 28, length: 1 }, // f
{ type: 'function', modifiers: [], start: 28, length: 1 },
{ type: 'parameter', modifiers: ['definition'], start: 30, length: 1 }, // l
{ type: 'class', modifiers: ['defaultLibrary', 'builtin'], start: 33, length: 4 }, // list
{ type: 'variable', modifiers: [], start: 42, length: 3 }, // Any
{ type: 'type', modifiers: [], start: 42, length: 3 }, // Any
{ type: 'variable', modifiers: [], start: 51, length: 1 }, // v
{ type: 'parameter', modifiers: [], start: 55, length: 1 }, // l
{ type: 'variable', modifiers: [], start: 71, length: 1 }, // v
Expand Down

0 comments on commit ba7d848

Please sign in to comment.