mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
more tests
This commit is contained in:
parent
8bbe5ce092
commit
43394dee80
|
@ -30,8 +30,11 @@ export function getSemanticTokens(jsLanguageService: ts.LanguageService, current
|
|||
if (symbol) {
|
||||
let typeIdx = tokenFromDeclarationMapping[symbol.valueDeclaration.kind];
|
||||
let modifierSet = 0;
|
||||
if (node.parent && (<ts.NamedDeclaration>node.parent).name === node) {
|
||||
modifierSet = TokenModifier.declaration;
|
||||
if (node.parent) {
|
||||
const parentTypeIdx = tokenFromDeclarationMapping[node.parent.kind];
|
||||
if (parentTypeIdx === typeIdx && (<ts.NamedDeclaration>node.parent).name === node) {
|
||||
modifierSet = TokenModifier.declaration;
|
||||
}
|
||||
}
|
||||
if (typeIdx !== undefined) {
|
||||
resultTokens.push({ offset: node.getStart(), length: node.getWidth(), typeIdx, modifierSet });
|
||||
|
@ -130,5 +133,7 @@ const tokenFromDeclarationMapping: { [name: string]: TokenType } = {
|
|||
[ts.SyntaxKind.EnumDeclaration]: TokenType.enum,
|
||||
[ts.SyntaxKind.EnumMember]: TokenType.property,
|
||||
[ts.SyntaxKind.ClassDeclaration]: TokenType.property,
|
||||
[ts.SyntaxKind.MethodDeclaration]: TokenType.function
|
||||
[ts.SyntaxKind.MethodDeclaration]: TokenType.member,
|
||||
[ts.SyntaxKind.FunctionDeclaration]: TokenType.function,
|
||||
[ts.SyntaxKind.MethodSignature]: TokenType.member,
|
||||
};
|
||||
|
|
|
@ -83,9 +83,34 @@ suite('JavaScript Semantic Tokens', () => {
|
|||
];
|
||||
assertTokens(input, [
|
||||
t(3, 11, 3, 'function.declaration'), t(3, 15, 2, 'parameter.declaration'),
|
||||
t(4, 11, 3, 'function'), t(4, 15, 3, 'namespace'), t(4, 20, 3, 'member'), t(4, 24, 2, 'parameter')
|
||||
t(4, 11, 3, 'function'), t(4, 15, 4, 'variable'), t(4, 20, 3, 'member'), t(4, 24, 2, 'parameter')
|
||||
]);
|
||||
});
|
||||
|
||||
test('members', () => {
|
||||
const input = [
|
||||
/*0*/'<html>',
|
||||
/*1*/'<head>',
|
||||
/*2*/'<script>',
|
||||
/*3*/' class A {',
|
||||
/*4*/' static x = 9;',
|
||||
/*5*/' f = 9;',
|
||||
/*6*/' m() { return A.x; };',
|
||||
/*7*/' get s() { return this.f + this.m() }',
|
||||
/*8*/' }',
|
||||
/*9*/'</script>',
|
||||
/*10*/'</head>',
|
||||
/*11*/'</html>',
|
||||
];
|
||||
assertTokens(input, [
|
||||
t(3, 8, 1, 'class.declaration'),
|
||||
t(4, 11, 1, 'member.declaration'),
|
||||
t(5, 4, 1, 'property.declaration'),
|
||||
t(6, 4, 1, 'member.declaration'), t(6, 17, 1, 'class'), t(6, 19, 1, 'property'),
|
||||
t(7, 8, 1, 'member.declaration'),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue