Support syntax diagnostics in partial mode
For https://github.com/microsoft/TypeScript/pull/44859
This commit is contained in:
parent
601afb43f8
commit
8b3d6668bd
|
@ -57,7 +57,7 @@ export function activate(
|
|||
new TypeScriptVersion(
|
||||
TypeScriptVersionSource.Bundled,
|
||||
vscode.Uri.joinPath(context.extensionUri, 'dist/browser/typescript/tsserver.web.js').toString(),
|
||||
API.fromSimpleString('4.2.0')));
|
||||
API.fromSimpleString('4.3.5')));
|
||||
|
||||
const lazyClientHost = createLazyClientHost(context, false, {
|
||||
pluginManager,
|
||||
|
|
|
@ -303,19 +303,26 @@ class GetErrRequest {
|
|||
private readonly _token: vscode.CancellationTokenSource = new vscode.CancellationTokenSource();
|
||||
|
||||
private constructor(
|
||||
client: ITypeScriptServiceClient,
|
||||
private readonly client: ITypeScriptServiceClient,
|
||||
public readonly files: ResourceMap<void>,
|
||||
onDone: () => void
|
||||
) {
|
||||
if (!this.isErrorReportingEnabled()) {
|
||||
this._done = true;
|
||||
setImmediate(onDone);
|
||||
return;
|
||||
}
|
||||
|
||||
const supportsSyntaxGetErr = this.client.apiVersion.gte(API.v440);
|
||||
const allFiles = coalesce(Array.from(files.entries)
|
||||
.filter(entry => client.hasCapabilityForResource(entry.resource, ClientCapability.Semantic))
|
||||
.filter(entry => supportsSyntaxGetErr || client.hasCapabilityForResource(entry.resource, ClientCapability.Semantic))
|
||||
.map(entry => client.normalizedPath(entry.resource)));
|
||||
|
||||
if (!allFiles.length || !client.capabilities.has(ClientCapability.Semantic)) {
|
||||
if (!allFiles.length) {
|
||||
this._done = true;
|
||||
setImmediate(onDone);
|
||||
} else {
|
||||
const request = client.configuration.enableProjectDiagnostics
|
||||
const request = this.areProjectDiagnosticsEnabled()
|
||||
// Note that geterrForProject is almost certainly not the api we want here as it ends up computing far
|
||||
// too many diagnostics
|
||||
? client.executeAsync('geterrForProject', { delay: 0, file: allFiles[0] }, this._token.token)
|
||||
|
@ -331,6 +338,19 @@ class GetErrRequest {
|
|||
}
|
||||
}
|
||||
|
||||
private isErrorReportingEnabled() {
|
||||
if (this.client.apiVersion.gte(API.v440)) {
|
||||
return true;
|
||||
} else {
|
||||
// Older TS versions only support `getErr` on semantic server
|
||||
return this.client.capabilities.has(ClientCapability.Semantic);
|
||||
}
|
||||
}
|
||||
|
||||
private areProjectDiagnosticsEnabled() {
|
||||
return this.client.configuration.enableProjectDiagnostics && this.client.capabilities.has(ClientCapability.Semantic);
|
||||
}
|
||||
|
||||
public cancel(): any {
|
||||
if (!this._done) {
|
||||
this._token.cancel();
|
||||
|
|
Loading…
Reference in a new issue