Fix: server crash on semantic hightlight request

This commit is contained in:
全卓 2022-12-06 10:15:21 +08:00
parent 2a1c4709ff
commit 4d17b328f7
2 changed files with 8 additions and 8 deletions

View File

@ -14,10 +14,10 @@ class CMakeInfo {
public major: number;
public minor: number;
public patch: number;
public modules: string[];
public policies: string[];
public variables: string[];
public properties: string[];
public modules: string[] = [];
public policies: string[] = [];
public variables: string[] = [];
public properties: string[] = [];
public async init() {
[

View File

@ -67,15 +67,15 @@ export function getTokenBuilder(uri: string): SemanticTokensBuilder {
}
export function getTokenTypes(): string[] {
tokenTypes = tokenTypes.filter((value, index, arr) => {
return initParams.capabilities.textDocument.semanticTokens.tokenTypes.includes(value);
tokenTypes = tokenTypes.filter(value => {
return initParams.capabilities.textDocument?.semanticTokens?.tokenTypes.includes(value);
});
return tokenTypes;
}
export function getTokenModifiers(): string[] {
tokenModifiers = tokenModifiers.filter((value, index, arr) => {
return initParams.capabilities.textDocument.semanticTokens.tokenModifiers.includes(value);
tokenModifiers = tokenModifiers.filter(value => {
return initParams.capabilities.textDocument?.semanticTokens?.tokenModifiers.includes(value);
});
return tokenModifiers;
}