提交 a7e5a795 编写于 作者: M Matt Bierner

Use Uri to identify file in Diagnostics manager

上级 9da3b7e3
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Diagnostic, DiagnosticCollection, languages } from 'vscode';
import { Diagnostic, DiagnosticCollection, languages, Uri } from 'vscode';
import { ITypeScriptServiceClient } from '../typescriptService';
export default class DiagnosticsManager {
......@@ -42,31 +42,35 @@ export default class DiagnosticsManager {
}
}
public syntaxDiagnosticsReceived(file: string, syntaxDiagnostics: Diagnostic[]): void {
this.syntaxDiagnostics[file] = syntaxDiagnostics;
public syntaxDiagnosticsReceived(file: Uri, syntaxDiagnostics: Diagnostic[]): void {
this.syntaxDiagnostics[this.key(file)] = syntaxDiagnostics;
this.updateCurrentDiagnostics(file);
}
public semanticDiagnosticsReceived(file: string, semanticDiagnostics: Diagnostic[]): void {
this.semanticDiagnostics[file] = semanticDiagnostics;
public semanticDiagnosticsReceived(file: Uri, semanticDiagnostics: Diagnostic[]): void {
this.semanticDiagnostics[this.key(file)] = semanticDiagnostics;
this.updateCurrentDiagnostics(file);
}
public configFileDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
this.currentDiagnostics.set(this.client.asUrl(file), diagnostics);
public configFileDiagnosticsReceived(file: Uri, diagnostics: Diagnostic[]): void {
this.currentDiagnostics.set(file, diagnostics);
}
public delete(file: string): void {
this.currentDiagnostics.delete(this.client.asUrl(file));
}
private updateCurrentDiagnostics(file: string) {
private key(file: Uri): string {
return file.toString(true);
}
private updateCurrentDiagnostics(file: Uri) {
if (!this._validate) {
return;
}
const semanticDiagnostics = this.semanticDiagnostics[file] || [];
const syntaxDiagnostics = this.syntaxDiagnostics[file] || [];
this.currentDiagnostics.set(this.client.asUrl(file), semanticDiagnostics.concat(syntaxDiagnostics));
const semanticDiagnostics = this.semanticDiagnostics[this.key(file)] || [];
const syntaxDiagnostics = this.syntaxDiagnostics[this.key(file)] || [];
this.currentDiagnostics.set(file, semanticDiagnostics.concat(syntaxDiagnostics));
}
}
\ No newline at end of file
......@@ -403,15 +403,15 @@ class LanguageProvider {
this.bufferSyncSupport.requestAllDiagnostics();
}
public syntaxDiagnosticsReceived(file: string, syntaxDiagnostics: Diagnostic[]): void {
public syntaxDiagnosticsReceived(file: Uri, syntaxDiagnostics: Diagnostic[]): void {
this.diagnosticsManager.syntaxDiagnosticsReceived(file, syntaxDiagnostics);
}
public semanticDiagnosticsReceived(file: string, semanticDiagnostics: Diagnostic[]): void {
public semanticDiagnosticsReceived(file: Uri, semanticDiagnostics: Diagnostic[]): void {
this.diagnosticsManager.semanticDiagnosticsReceived(file, semanticDiagnostics);
}
public configFileDiagnosticsReceived(file: string, diagnostics: Diagnostic[]): void {
public configFileDiagnosticsReceived(file: Uri, diagnostics: Diagnostic[]): void {
this.diagnosticsManager.configFileDiagnosticsReceived(file, diagnostics);
}
}
......@@ -631,7 +631,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost {
if (body && body.diagnostics) {
this.findLanguage(body.file).then(language => {
if (language) {
language.syntaxDiagnosticsReceived(body.file, this.createMarkerDatas(body.diagnostics, language.diagnosticSource));
language.syntaxDiagnosticsReceived(this.client.asUrl(body.file), this.createMarkerDatas(body.diagnostics, language.diagnosticSource));
}
});
}
......@@ -642,7 +642,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost {
if (body && body.diagnostics) {
this.findLanguage(body.file).then(language => {
if (language) {
language.semanticDiagnosticsReceived(body.file, this.createMarkerDatas(body.diagnostics, language.diagnosticSource));
language.semanticDiagnosticsReceived(this.client.asUrl(body.file), this.createMarkerDatas(body.diagnostics, language.diagnosticSource));
}
});
}
......@@ -660,7 +660,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost {
return;
}
if (body.diagnostics.length === 0) {
language.configFileDiagnosticsReceived(body.configFile, []);
language.configFileDiagnosticsReceived(this.client.asUrl(body.configFile), []);
} else if (body.diagnostics.length >= 1) {
workspace.openTextDocument(Uri.file(body.configFile)).then((document) => {
let curly: [number, number, number] | undefined = undefined;
......@@ -690,10 +690,10 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost {
}
if (diagnostic) {
diagnostic.source = language.diagnosticSource;
language.configFileDiagnosticsReceived(body.configFile, [diagnostic]);
language.configFileDiagnosticsReceived(this.client.asUrl(body.configFile), [diagnostic]);
}
}, _error => {
language.configFileDiagnosticsReceived(body.configFile, [new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text)]);
language.configFileDiagnosticsReceived(this.client.asUrl(body.configFile), [new Diagnostic(new Range(0, 0, 0, 0), body.diagnostics[0].text)]);
});
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册