diff --git a/packages/markers/src/browser/problem/problem-widget.tsx b/packages/markers/src/browser/problem/problem-widget.tsx
index c00b32ced6bf3..4ed13eddc4382 100644
--- a/packages/markers/src/browser/problem/problem-widget.tsx
+++ b/packages/markers/src/browser/problem/problem-widget.tsx
@@ -104,7 +104,7 @@ export class ProblemWidget extends TreeWidget {
- {'[' + problemMarker.owner + ']'}
+ {'[' + (problemMarker.data.source || problemMarker.owner) + ']'}
{problemMarker.data.message}
{
diff --git a/packages/plugin-ext/package.json b/packages/plugin-ext/package.json
index 804c7da56dfa4..923ccb1558dc2 100644
--- a/packages/plugin-ext/package.json
+++ b/packages/plugin-ext/package.json
@@ -10,6 +10,7 @@
"@theia/editor": "^0.3.19",
"@theia/file-search": "^0.3.19",
"@theia/filesystem": "^0.3.19",
+ "@theia/markers": "^0.3.19",
"@theia/messages": "^0.3.19",
"@theia/monaco": "^0.3.19",
"@theia/navigator": "^0.3.19",
diff --git a/packages/plugin-ext/src/api/model.ts b/packages/plugin-ext/src/api/model.ts
index 0f958ed306b88..0d4f64c88f81f 100644
--- a/packages/plugin-ext/src/api/model.ts
+++ b/packages/plugin-ext/src/api/model.ts
@@ -197,7 +197,7 @@ export interface MarkerData {
}
export interface RelatedInformation {
- resource: UriComponents;
+ resource: string;
message: string;
startLineNumber: number;
startColumn: number;
diff --git a/packages/plugin-ext/src/api/plugin-api.ts b/packages/plugin-ext/src/api/plugin-api.ts
index af739b9979f9c..3665643acc762 100644
--- a/packages/plugin-ext/src/api/plugin-api.ts
+++ b/packages/plugin-ext/src/api/plugin-api.ts
@@ -900,7 +900,7 @@ export interface LanguagesMain {
$registerDocumentHighlightProvider(handle: number, selector: SerializedDocumentFilter[]): void;
$registerQuickFixProvider(handle: number, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void;
$clearDiagnostics(id: string): void;
- $changeDiagnostics(id: string, delta: [UriComponents, MarkerData[]][]): void;
+ $changeDiagnostics(id: string, delta: [string, MarkerData[]][]): void;
$registerDocumentFormattingSupport(handle: number, selector: SerializedDocumentFilter[]): void;
$registerRangeFormattingProvider(handle: number, selector: SerializedDocumentFilter[]): void;
$registerOnTypeFormattingProvider(handle: number, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void;
diff --git a/packages/plugin-ext/src/main/browser/languages-main.ts b/packages/plugin-ext/src/main/browser/languages-main.ts
index 86396760d02dd..75127997662c9 100644
--- a/packages/plugin-ext/src/main/browser/languages-main.ts
+++ b/packages/plugin-ext/src/main/browser/languages-main.ts
@@ -27,25 +27,29 @@ import {
ResourceFileEditDto,
} from '../../api/plugin-api';
import { interfaces } from 'inversify';
-import { SerializedDocumentFilter, MarkerData, Range, WorkspaceSymbolProvider } from '../../api/model';
+import { SerializedDocumentFilter, MarkerData, Range, WorkspaceSymbolProvider, RelatedInformation, MarkerSeverity } from '../../api/model';
import { RPCProtocol } from '../../api/rpc-protocol';
import { fromLanguageSelector } from '../../plugin/type-converters';
-import { UriComponents } from '../../common/uri-components';
import { LanguageSelector } from '../../plugin/languages';
import { DocumentFilter, MonacoModelIdentifier, testGlob, getLanguages } from 'monaco-languageclient/lib';
import { DisposableCollection, Emitter } from '@theia/core';
import { MonacoLanguages } from '@theia/monaco/lib/browser/monaco-languages';
import URI from 'vscode-uri/lib/umd';
+import CoreURI from '@theia/core/lib/common/uri';
+import { ProblemManager } from '@theia/markers/lib/browser';
+import * as vst from 'vscode-languageserver-types';
export class LanguagesMainImpl implements LanguagesMain {
private ml: MonacoLanguages;
+ private problemManager: ProblemManager;
private readonly proxy: LanguagesExt;
private readonly disposables = new Map();
constructor(rpc: RPCProtocol, container: interfaces.Container) {
this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.LANGUAGES_EXT);
this.ml = container.get(MonacoLanguages);
+ this.problemManager = container.get(ProblemManager);
}
$getLanguages(): Promise {
@@ -158,24 +162,15 @@ export class LanguagesMainImpl implements LanguagesMain {
}
$clearDiagnostics(id: string): void {
- const markers = monaco.editor.getModelMarkers({ owner: id });
- const clearedEditors = new Set(); // uri to resource
- for (const marker of markers) {
- const uri = marker.resource;
- const uriString = uri.toString();
- if (!clearedEditors.has(uriString)) {
- const textModel = monaco.editor.getModel(uri);
- monaco.editor.setModelMarkers(textModel, id, []);
- clearedEditors.add(uriString);
- }
+ for (const uri of this.problemManager.getUris()) {
+ this.problemManager.setMarkers(new CoreURI(uri), id, []);
}
}
- $changeDiagnostics(id: string, delta: [UriComponents, MarkerData[]][]): void {
- for (const [uriComponents, markers] of delta) {
- const uri = monaco.Uri.revive(uriComponents);
- const textModel = monaco.editor.getModel(uri);
- monaco.editor.setModelMarkers(textModel, id, markers.map(reviveMarker));
+ $changeDiagnostics(id: string, delta: [string, MarkerData[]][]): void {
+ for (const [uriString, markers] of delta) {
+ const uri = new CoreURI(uriString);
+ this.problemManager.setMarkers(uri, id, markers.map(reviveMarker));
}
}
@@ -698,35 +693,56 @@ export class LanguagesMainImpl implements LanguagesMain {
}
}
-function reviveMarker(marker: MarkerData): monaco.editor.IMarkerData {
- const monacoMarker: monaco.editor.IMarkerData = {
+function reviveMarker(marker: MarkerData): vst.Diagnostic {
+ const monacoMarker: vst.Diagnostic = {
code: marker.code,
- severity: marker.severity,
+ severity: reviveSeverity(marker.severity),
+ range: reviveRange(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn),
message: marker.message,
source: marker.source,
- startLineNumber: marker.startLineNumber,
- startColumn: marker.startColumn,
- endLineNumber: marker.endLineNumber,
- endColumn: marker.endColumn,
relatedInformation: undefined
};
+
if (marker.relatedInformation) {
- monacoMarker.relatedInformation = [];
- for (const ri of marker.relatedInformation) {
- monacoMarker.relatedInformation.push({
- resource: monaco.Uri.revive(ri.resource),
- message: ri.message,
- startLineNumber: ri.startLineNumber,
- startColumn: ri.startColumn,
- endLineNumber: ri.endLineNumber,
- endColumn: ri.endColumn
- });
- }
+ monacoMarker.relatedInformation = marker.relatedInformation.map(reviveRelated);
}
return monacoMarker;
}
+function reviveSeverity(severity: MarkerSeverity): vst.DiagnosticSeverity {
+ switch (severity) {
+ case MarkerSeverity.Error: return vst.DiagnosticSeverity.Error;
+ case MarkerSeverity.Warning: return vst.DiagnosticSeverity.Warning;
+ case MarkerSeverity.Info: return vst.DiagnosticSeverity.Information;
+ case MarkerSeverity.Hint: return vst.DiagnosticSeverity.Hint;
+ }
+}
+
+function reviveRange(startLine: number, startColumn: number, endLine: number, endColumn: number): vst.Range {
+ // note: language server range is 0-based, marker is 1-based, so need to deduct 1 here
+ return {
+ start: {
+ line: startLine - 1,
+ character: startColumn - 1
+ },
+ end: {
+ line: endLine - 1,
+ character: endColumn - 1
+ }
+ };
+}
+
+function reviveRelated(related: RelatedInformation): vst.DiagnosticRelatedInformation {
+ return {
+ message: related.message,
+ location: {
+ uri: related.resource,
+ range: reviveRange(related.startLineNumber, related.startColumn, related.endLineNumber, related.endColumn)
+ }
+ };
+}
+
function reviveRegExp(regExp?: SerializedRegExp): RegExp | undefined {
if (typeof regExp === 'undefined' || regExp === null) {
return undefined;
diff --git a/packages/plugin-ext/src/plugin/languages/diagnostics.ts b/packages/plugin-ext/src/plugin/languages/diagnostics.ts
index 7951ce82f628d..3ef2bc0392f9b 100644
--- a/packages/plugin-ext/src/plugin/languages/diagnostics.ts
+++ b/packages/plugin-ext/src/plugin/languages/diagnostics.ts
@@ -114,7 +114,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
if (this.has(uri)) {
this.fireDiagnosticChangeEvent(uri);
this.diagnostics.delete(uri.toString());
- this.proxy.$changeDiagnostics(this.name, [[uri, []]]);
+ this.proxy.$changeDiagnostics(this.name, [[uri.toString(), []]]);
}
}
@@ -204,7 +204,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
}
private sendChangesToEditor(uris: URI[]): void {
- const markers: [URI, MarkerData[]][] = [];
+ const markers: [string, MarkerData[]][] = [];
nextUri:
for (const uri of uris) {
const uriMarkers: MarkerData[] = [];
@@ -224,7 +224,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
endLineNumber: lastMarker.endLineNumber,
endColumn: lastMarker.endColumn
});
- markers.push([uri, uriMarkers]);
+ markers.push([uri.toString(), uriMarkers]);
continue nextUri;
}
}
@@ -232,10 +232,10 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
}
} else {
uriDiagnostics.forEach(diagnostic => uriMarkers.push(convertDiagnosticToMarkerData(diagnostic)));
- markers.push([uri, uriMarkers]);
+ markers.push([uri.toString(), uriMarkers]);
}
} else {
- markers.push([uri, []]);
+ markers.push([uri.toString(), []]);
}
}
diff --git a/packages/plugin-ext/src/plugin/type-converters.ts b/packages/plugin-ext/src/plugin/type-converters.ts
index e3309a24b1043..4c4709c4ea281 100644
--- a/packages/plugin-ext/src/plugin/type-converters.ts
+++ b/packages/plugin-ext/src/plugin/type-converters.ts
@@ -347,7 +347,7 @@ function convertRelatedInformation(diagnosticsRelatedInformation: theia.Diagnost
const relatedInformation: model.RelatedInformation[] = [];
for (const item of diagnosticsRelatedInformation) {
relatedInformation.push({
- resource: item.location.uri,
+ resource: item.location.uri.toString(),
message: item.message,
startLineNumber: item.location.range.start.line + 1,
startColumn: item.location.range.start.character + 1,