Skip to content

Commit

Permalink
Fix class assignment color
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed May 15, 2024
1 parent cdd0feb commit f9a06d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ describe('BrsFileSemanticTokensProcessor', () => {
]);
});

it('matches class name in assignment statement', () => {
const file = program.setFile<BrsFile>('source/main.bs', `
sub test()
ctor = Person
end sub
class Person
end class
`);
expectSemanticTokensIncludes(file, [
// ctor = |Person|
[SemanticTokenTypes.class, 2, 23, 2, 29]
]);
});

it('matches namespace-relative parts', () => {
const file = program.setFile<BrsFile>('source/main.bs', `
namespace alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { SymbolTypeFlag } from '../../SymbolTypeFlag';
import type { BscType } from '../../types/BscType';
import { WalkMode, createVisitor } from '../../astUtils/visitors';
import type { AstNode } from '../../parser/AstNode';
import { DynamicType } from '../../types';

export class BrsFileSemanticTokensProcessor {
public constructor(
Expand Down Expand Up @@ -102,6 +101,12 @@ export class BrsFileSemanticTokensProcessor {
return { type: SemanticTokenTypes.class };
//function statements and expressions
} else if (isCallableType(type)) {
//if the typetime type is a class, then color this like a class
const typetimeType = node.getType({ flags: SymbolTypeFlag.typetime });
if (isClassType(typetimeType)) {
return { type: SemanticTokenTypes.class };
}

//if this is a function statement or expression, treat it as a function
if (isFunctionExpression(node) || isFunctionStatement(node)) {
return { type: SemanticTokenTypes.function };
Expand Down

0 comments on commit f9a06d7

Please sign in to comment.