Log document that can't perform semanticTokens

This commit is contained in:
Qiming Zhao 2022-01-20 21:29:43 +08:00
parent 021073e4fc
commit 4e9d171a23
No known key found for this signature in database
GPG key ID: 9722CD0E8D4DCB8C
2 changed files with 10 additions and 0 deletions

View file

@ -1,3 +1,7 @@
# 1.9.8
- Log to output when document content exceed limit of semantic tokens.
# 1.9.7 # 1.9.7
- Change default of `javascript.autoClosingTags` and `typescript.autoClosingTags` to `true`. - Change default of `javascript.autoClosingTags` and `typescript.autoClosingTags` to `true`.

View file

@ -29,9 +29,14 @@ export default class TypeScriptDocumentSemanticTokensProvider implements Documen
} }
} }
private logIgnored(uri: string): void {
this.client.logger.warn(`${uri} content length exceed limit 100000`)
}
async provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): Promise<SemanticTokens | null> { async provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): Promise<SemanticTokens | null> {
const file = this.client.toOpenedFilePath(document.uri) const file = this.client.toOpenedFilePath(document.uri)
if (!file || document.getText().length > CONTENT_LENGTH_LIMIT) { if (!file || document.getText().length > CONTENT_LENGTH_LIMIT) {
this.logIgnored(document.uri)
return null return null
} }
return this._provideSemanticTokens(document, { file, start: 0, length: document.getText().length }, token) return this._provideSemanticTokens(document, { file, start: 0, length: document.getText().length }, token)
@ -40,6 +45,7 @@ export default class TypeScriptDocumentSemanticTokensProvider implements Documen
async provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): Promise<SemanticTokens | null> { async provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): Promise<SemanticTokens | null> {
const file = this.client.toOpenedFilePath(document.uri) const file = this.client.toOpenedFilePath(document.uri)
if (!file || (document.offsetAt(range.end) - document.offsetAt(range.start) > CONTENT_LENGTH_LIMIT)) { if (!file || (document.offsetAt(range.end) - document.offsetAt(range.start) > CONTENT_LENGTH_LIMIT)) {
this.logIgnored(document.uri)
return null return null
} }