@opensumi/ide-editor 2.21.13 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/breadcrumb/default.js.map +1 -1
- package/lib/browser/breadcrumb/document-symbol.js.map +1 -1
- package/lib/browser/breadcrumb/index.js.map +1 -1
- package/lib/browser/component.js.map +1 -1
- package/lib/browser/decoration-applier.js.map +1 -1
- package/lib/browser/diff/compare.js.map +1 -1
- package/lib/browser/diff/index.d.ts.map +1 -1
- package/lib/browser/diff/index.js +1 -1
- package/lib/browser/diff/index.js.map +1 -1
- package/lib/browser/doc-cache/empty-doc-cache.js.map +1 -1
- package/lib/browser/doc-cache/local-storage-cache.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model-service.js +3 -3
- package/lib/browser/doc-model/editor-document-model-service.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts +8 -0
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +61 -11
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/doc-model/editor-document-registry.js.map +1 -1
- package/lib/browser/doc-model/override.js.map +1 -1
- package/lib/browser/doc-model/save-task.js +1 -1
- package/lib/browser/doc-model/save-task.js.map +1 -1
- package/lib/browser/doc-model/saveParticipants.d.ts +7 -7
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.js +69 -38
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -1
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +8 -3
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +75 -66
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/editor-opener.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +31 -3
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.decoration.service.d.ts +5 -6
- package/lib/browser/editor.decoration.service.d.ts.map +1 -1
- package/lib/browser/editor.decoration.service.js +9 -1
- package/lib/browser/editor.decoration.service.js.map +1 -1
- package/lib/browser/editor.override.js +2 -2
- package/lib/browser/editor.override.js.map +1 -1
- package/lib/browser/editor.status-bar.service.js.map +1 -1
- package/lib/browser/editor.view.d.ts.map +1 -1
- package/lib/browser/editor.view.js +20 -23
- package/lib/browser/editor.view.js.map +1 -1
- package/lib/browser/error.d.ts +1 -1
- package/lib/browser/error.d.ts.map +1 -1
- package/lib/browser/feature.js.map +1 -1
- package/lib/browser/format/format.service.js.map +1 -1
- package/lib/browser/format/formatterSelect.js.map +1 -1
- package/lib/browser/fs-resource/file-tree-set.js +6 -6
- package/lib/browser/fs-resource/file-tree-set.js.map +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.js +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.js.map +1 -1
- package/lib/browser/fs-resource/fs-resource.js.map +1 -1
- package/lib/browser/fs-resource/index.js.map +1 -1
- package/lib/browser/history/index.d.ts.map +1 -1
- package/lib/browser/history/index.js +2 -1
- package/lib/browser/history/index.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/language/diagnostic-collection.d.ts +5 -5
- package/lib/browser/language/diagnostic-collection.d.ts.map +1 -1
- package/lib/browser/language/diagnostic-collection.js +1 -1
- package/lib/browser/language/diagnostic-collection.js.map +1 -1
- package/lib/browser/language/language-status.contribution.js.map +1 -1
- package/lib/browser/language/language-status.service.js.map +1 -1
- package/lib/browser/language/language.service.d.ts +4 -3
- package/lib/browser/language/language.service.d.ts.map +1 -1
- package/lib/browser/language/language.service.js +8 -2
- package/lib/browser/language/language.service.js.map +1 -1
- package/lib/browser/menu/editor.context.js +3 -3
- package/lib/browser/menu/editor.context.js.map +1 -1
- package/lib/browser/menu/editor.menu.d.ts +2 -2
- package/lib/browser/menu/editor.menu.d.ts.map +1 -1
- package/lib/browser/menu/editor.menu.js +6 -8
- package/lib/browser/menu/editor.menu.js.map +1 -1
- package/lib/browser/menu/open-type-menu.contribution.js +9 -9
- package/lib/browser/menu/open-type-menu.contribution.js.map +1 -1
- package/lib/browser/menu/title-context.menu.js.map +1 -1
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts +8 -0
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts.map +1 -0
- package/lib/browser/merge-editor/merge-editor.contribution.js +29 -0
- package/lib/browser/merge-editor/merge-editor.contribution.js.map +1 -0
- package/lib/browser/merge-editor/merge-editor.provider.d.ts +8 -0
- package/lib/browser/merge-editor/merge-editor.provider.d.ts.map +1 -0
- package/lib/browser/merge-editor/merge-editor.provider.js +44 -0
- package/lib/browser/merge-editor/merge-editor.provider.js.map +1 -0
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.js.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js +7 -7
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate-registry.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts +2 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js +5 -2
- package/lib/browser/monaco-contrib/tokenizer/textmate.service.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.contribution.js.map +1 -1
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js +7 -7
- package/lib/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.js.map +1 -1
- package/lib/browser/navigation.module.less +1 -1
- package/lib/browser/navigation.view.d.ts.map +1 -1
- package/lib/browser/navigation.view.js +26 -15
- package/lib/browser/navigation.view.js.map +1 -1
- package/lib/browser/preference/contribution.js.map +1 -1
- package/lib/browser/preference/converter.d.ts +3 -3
- package/lib/browser/preference/converter.d.ts.map +1 -1
- package/lib/browser/preference/schema.d.ts +1 -1
- package/lib/browser/preference/schema.d.ts.map +1 -1
- package/lib/browser/preference/schema.js +8 -8
- package/lib/browser/preference/schema.js.map +1 -1
- package/lib/browser/quick-open/go-to-line.js.map +1 -1
- package/lib/browser/quick-open/workspace-symbol-quickopen.d.ts.map +1 -1
- package/lib/browser/quick-open/workspace-symbol-quickopen.js +2 -2
- package/lib/browser/quick-open/workspace-symbol-quickopen.js.map +1 -1
- package/lib/browser/resource.service.js.map +1 -1
- package/lib/browser/tab.view.d.ts +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +2 -2
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/types.d.ts +5 -5
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/untitled-resource.js +1 -1
- package/lib/browser/untitled-resource.js.map +1 -1
- package/lib/browser/view/suggest-widget.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts +17 -0
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +259 -176
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/doc-cache.d.ts +2 -2
- package/lib/common/doc-cache.d.ts.map +1 -1
- package/lib/common/editor.d.ts +20 -6
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js +12 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/language.d.ts +18 -7
- package/lib/common/language.d.ts.map +1 -1
- package/lib/common/language.js +15 -7
- package/lib/common/language.js.map +1 -1
- package/lib/common/mocks/workbench-editor.service.js.map +1 -1
- package/lib/common/resource.d.ts +8 -2
- package/lib/common/resource.d.ts.map +1 -1
- package/lib/common/resource.js +1 -0
- package/lib/common/resource.js.map +1 -1
- package/package.json +17 -16
- package/src/browser/breadcrumb/default.ts +299 -0
- package/src/browser/breadcrumb/document-symbol.ts +187 -0
- package/src/browser/breadcrumb/index.ts +96 -0
- package/src/browser/component.ts +204 -0
- package/src/browser/decoration-applier.ts +256 -0
- package/src/browser/diff/compare.ts +99 -0
- package/src/browser/diff/index.ts +81 -0
- package/src/browser/doc-cache/empty-doc-cache.ts +26 -0
- package/src/browser/doc-cache/index.ts +2 -0
- package/src/browser/doc-cache/local-storage-cache.ts +67 -0
- package/src/browser/doc-model/editor-document-error.ts +10 -0
- package/src/browser/doc-model/editor-document-model-service.ts +346 -0
- package/src/browser/doc-model/editor-document-model.ts +690 -0
- package/src/browser/doc-model/editor-document-registry.ts +119 -0
- package/src/browser/doc-model/editor-is-fn.ts +9 -0
- package/src/browser/doc-model/main.ts +4 -0
- package/src/browser/doc-model/override.ts +49 -0
- package/src/browser/doc-model/save-task.ts +88 -0
- package/src/browser/doc-model/saveParticipants.ts +227 -0
- package/src/browser/doc-model/types.ts +350 -0
- package/src/browser/editor-collection.service.ts +790 -0
- package/src/browser/editor-opener.ts +44 -0
- package/src/browser/editor.contribution.ts +1438 -0
- package/src/browser/editor.decoration.service.ts +247 -0
- package/src/browser/editor.less +4 -0
- package/src/browser/editor.module.less +548 -0
- package/src/browser/editor.override.ts +133 -0
- package/src/browser/editor.status-bar.service.ts +116 -0
- package/src/browser/editor.view.tsx +623 -0
- package/src/browser/error.ts +21 -0
- package/src/browser/feature.ts +63 -0
- package/src/browser/format/format.service.ts +95 -0
- package/src/browser/format/formatterSelect.ts +82 -0
- package/src/browser/fs-resource/file-tree-set.ts +126 -0
- package/src/browser/fs-resource/fs-editor-doc.ts +213 -0
- package/src/browser/fs-resource/fs-resource.ts +247 -0
- package/src/browser/fs-resource/index.ts +27 -0
- package/src/browser/grid/grid.service.ts +288 -0
- package/src/browser/history/index.ts +228 -0
- package/src/browser/index.ts +236 -0
- package/src/browser/language/diagnostic-collection.ts +83 -0
- package/src/browser/language/language-status.contribution.ts +81 -0
- package/src/browser/language/language-status.service.ts +32 -0
- package/src/browser/language/language.service.ts +185 -0
- package/src/browser/menu/editor.context.ts +186 -0
- package/src/browser/menu/editor.menu.ts +45 -0
- package/src/browser/menu/open-type-menu.contribution.ts +90 -0
- package/src/browser/menu/title-context.menu.ts +54 -0
- package/src/browser/merge-editor/merge-editor.contribution.ts +25 -0
- package/src/browser/merge-editor/merge-editor.provider.ts +36 -0
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.contribution.ts +78 -0
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +160 -0
- package/src/browser/monaco-contrib/command/command.service.ts +438 -0
- package/src/browser/monaco-contrib/index.ts +4 -0
- package/src/browser/monaco-contrib/tokenizer/textmate-registry.ts +107 -0
- package/src/browser/monaco-contrib/tokenizer/textmate-tokenizer.ts +104 -0
- package/src/browser/monaco-contrib/tokenizer/textmate.service.ts +925 -0
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.contribution.ts +78 -0
- package/src/browser/monaco-contrib/typeHierarchy/typeHierarchy.service.ts +154 -0
- package/src/browser/navigation.module.less +96 -0
- package/src/browser/navigation.view.tsx +254 -0
- package/src/browser/preference/contribution.ts +8 -0
- package/src/browser/preference/converter.ts +793 -0
- package/src/browser/preference/schema.ts +1896 -0
- package/src/browser/preference/util.ts +14 -0
- package/src/browser/quick-open/go-to-line.ts +164 -0
- package/src/browser/quick-open/workspace-symbol-quickopen.ts +276 -0
- package/src/browser/resource.service.ts +263 -0
- package/src/browser/tab.view.tsx +514 -0
- package/src/browser/types.ts +467 -0
- package/src/browser/untitled-resource.ts +223 -0
- package/src/browser/view/editor.react.tsx +82 -0
- package/src/browser/view/react-hook.tsx +7 -0
- package/src/browser/view/suggest-widget.ts +77 -0
- package/src/browser/view/topPadding.ts +18 -0
- package/src/browser/workbench-editor.service.ts +2291 -0
- package/src/common/doc-cache.ts +117 -0
- package/src/common/editor.ts +799 -0
- package/src/common/index.ts +6 -0
- package/src/common/language-status.ts +33 -0
- package/src/common/language.ts +206 -0
- package/src/common/mocks/workbench-editor.service.ts +52 -0
- package/src/common/resource.ts +147 -0
- package/src/common/utils.ts +10 -0
- package/src/index.ts +1 -0
- package/lib/browser/component/scroll/scroll.d.ts +0 -2
- package/lib/browser/component/scroll/scroll.d.ts.map +0 -1
- package/lib/browser/component/scroll/scroll.js +0 -5
- package/lib/browser/component/scroll/scroll.js.map +0 -1
- package/lib/browser/component/scroll/scroll.module.less +0 -86
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
URI,
|
|
4
|
+
IDisposable,
|
|
5
|
+
Disposable,
|
|
6
|
+
MarkerManager,
|
|
7
|
+
IMarkerData,
|
|
8
|
+
IRelatedInformation,
|
|
9
|
+
MarkerSeverity,
|
|
10
|
+
} from '@opensumi/ide-core-common';
|
|
11
|
+
import { ITextmateTokenizer, ITextmateTokenizerService } from '@opensumi/ide-monaco/lib/browser/contrib/tokenizer';
|
|
12
|
+
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
DiagnosticSeverity,
|
|
16
|
+
DiagnosticRelatedInformation,
|
|
17
|
+
Diagnostic,
|
|
18
|
+
Language,
|
|
19
|
+
WorkspaceSymbolProvider,
|
|
20
|
+
ILanguageService,
|
|
21
|
+
} from '../../common';
|
|
22
|
+
|
|
23
|
+
import { MonacoDiagnosticCollection } from './diagnostic-collection';
|
|
24
|
+
|
|
25
|
+
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
|
26
|
+
|
|
27
|
+
function reviveSeverity(severity: MarkerSeverity): DiagnosticSeverity {
|
|
28
|
+
switch (severity) {
|
|
29
|
+
case MarkerSeverity.Error:
|
|
30
|
+
return DiagnosticSeverity.Error;
|
|
31
|
+
case MarkerSeverity.Warning:
|
|
32
|
+
return DiagnosticSeverity.Warning;
|
|
33
|
+
case MarkerSeverity.Info:
|
|
34
|
+
return DiagnosticSeverity.Information;
|
|
35
|
+
case MarkerSeverity.Hint:
|
|
36
|
+
return DiagnosticSeverity.Hint;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function reviveRange(startLine: number, startColumn: number, endLine: number, endColumn: number): any {
|
|
41
|
+
// note: language server range is 0-based, marker is 1-based, so need to deduct 1 here
|
|
42
|
+
return {
|
|
43
|
+
start: {
|
|
44
|
+
line: startLine - 1,
|
|
45
|
+
character: startColumn - 1,
|
|
46
|
+
},
|
|
47
|
+
end: {
|
|
48
|
+
line: endLine - 1,
|
|
49
|
+
character: endColumn - 1,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function reviveRelated(related: IRelatedInformation): DiagnosticRelatedInformation {
|
|
55
|
+
return {
|
|
56
|
+
message: related.message,
|
|
57
|
+
location: {
|
|
58
|
+
uri: related.resource,
|
|
59
|
+
range: reviveRange(related.startLineNumber, related.startColumn, related.endLineNumber, related.endColumn),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function reviveMarker(marker: IMarkerData): Diagnostic {
|
|
65
|
+
const monacoMarker: Diagnostic = {
|
|
66
|
+
code:
|
|
67
|
+
typeof marker.codeHref !== 'undefined'
|
|
68
|
+
? {
|
|
69
|
+
value: String(marker.code),
|
|
70
|
+
target: marker.codeHref.codeUri,
|
|
71
|
+
}
|
|
72
|
+
: marker.code,
|
|
73
|
+
severity: reviveSeverity(marker.severity) as any,
|
|
74
|
+
range: reviveRange(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn),
|
|
75
|
+
message: marker.message,
|
|
76
|
+
source: marker.source,
|
|
77
|
+
relatedInformation: undefined,
|
|
78
|
+
tags: marker.tags as number[],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (marker.relatedInformation) {
|
|
82
|
+
monacoMarker.relatedInformation = marker.relatedInformation.map(reviveRelated);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return monacoMarker;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Injectable()
|
|
89
|
+
export class LanguageService implements ILanguageService {
|
|
90
|
+
@Autowired()
|
|
91
|
+
private markerManager: MarkerManager;
|
|
92
|
+
|
|
93
|
+
@Autowired(ITextmateTokenizer)
|
|
94
|
+
private textmateService: ITextmateTokenizerService;
|
|
95
|
+
|
|
96
|
+
protected readonly markers = new Map<string, MonacoDiagnosticCollection>();
|
|
97
|
+
|
|
98
|
+
readonly workspaceSymbolProviders: WorkspaceSymbolProvider[] = [];
|
|
99
|
+
|
|
100
|
+
constructor() {
|
|
101
|
+
for (const uri of this.markerManager.getResources()) {
|
|
102
|
+
this.updateMarkers(new URI(uri));
|
|
103
|
+
}
|
|
104
|
+
this.markerManager.onMarkerChanged((uris) => {
|
|
105
|
+
if (uris) {
|
|
106
|
+
uris.forEach((uri) => this.updateMarkers(new URI(uri)));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
get languages(): Language[] {
|
|
112
|
+
return [...this.mergeLanguages(this.textmateService.getLanguages()).values()];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getLanguage(languageId: string): Language | undefined {
|
|
116
|
+
return this.mergeLanguages(
|
|
117
|
+
this.textmateService.getLanguages().filter((language) => language.id === languageId),
|
|
118
|
+
).get(languageId);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
protected mergeLanguages(registered: monaco.languages.ILanguageExtensionPoint[]): Map<string, Mutable<Language>> {
|
|
122
|
+
const languages = new Map<string, Mutable<Language>>();
|
|
123
|
+
for (const { id, aliases, extensions, filenames } of registered) {
|
|
124
|
+
const merged = languages.get(id) || {
|
|
125
|
+
id,
|
|
126
|
+
name: '',
|
|
127
|
+
extensions: new Set(),
|
|
128
|
+
filenames: new Set(),
|
|
129
|
+
};
|
|
130
|
+
if (!merged.name && aliases && aliases.length) {
|
|
131
|
+
merged.name = aliases[0];
|
|
132
|
+
}
|
|
133
|
+
if (extensions && extensions.length) {
|
|
134
|
+
for (const extension of extensions) {
|
|
135
|
+
merged.extensions.add(extension);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (filenames && filenames.length) {
|
|
139
|
+
for (const filename of filenames) {
|
|
140
|
+
merged.filenames.add(filename);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
languages.set(id, merged);
|
|
144
|
+
}
|
|
145
|
+
for (const [id, language] of languages) {
|
|
146
|
+
if (!language.name) {
|
|
147
|
+
language.name = id;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return languages;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
registerWorkspaceSymbolProvider(provider: WorkspaceSymbolProvider): IDisposable {
|
|
154
|
+
this.workspaceSymbolProviders.push(provider);
|
|
155
|
+
return Disposable.create(() => {
|
|
156
|
+
const index = this.workspaceSymbolProviders.indexOf(provider);
|
|
157
|
+
if (index !== -1) {
|
|
158
|
+
this.workspaceSymbolProviders.splice(index, 1);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
protected updateMarkers(uri: URI): void {
|
|
164
|
+
const uriString = uri.toString();
|
|
165
|
+
const owners = new Map<string, Diagnostic[]>();
|
|
166
|
+
for (const marker of this.markerManager.getMarkers({ resource: uri.toString() })) {
|
|
167
|
+
const diagnostics = owners.get(marker.type) || [];
|
|
168
|
+
diagnostics.push(reviveMarker(marker));
|
|
169
|
+
owners.set(marker.type, diagnostics);
|
|
170
|
+
}
|
|
171
|
+
const toClean = new Set<string>(this.markers.keys());
|
|
172
|
+
for (const [owner, diagnostics] of owners) {
|
|
173
|
+
toClean.delete(owner);
|
|
174
|
+
const collection = this.markers.get(owner) || new MonacoDiagnosticCollection(owner);
|
|
175
|
+
collection.set(uriString, diagnostics);
|
|
176
|
+
this.markers.set(owner, collection);
|
|
177
|
+
}
|
|
178
|
+
for (const owner of toClean) {
|
|
179
|
+
const collection = this.markers.get(owner);
|
|
180
|
+
if (collection) {
|
|
181
|
+
collection.set(uriString, []);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Disposable, IContextKeyService } from '@opensumi/ide-core-browser';
|
|
2
|
+
import { AbstractContextMenuService, MenuId, ICtxMenuRenderer } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
3
|
+
import { ICodeEditor } from '@opensumi/ide-monaco/lib/common/types';
|
|
4
|
+
import * as dom from '@opensumi/monaco-editor-core/esm/vs/base/browser/dom';
|
|
5
|
+
import { IAnchor } from '@opensumi/monaco-editor-core/esm/vs/base/browser/ui/contextview/contextview';
|
|
6
|
+
import { KeyCode } from '@opensumi/monaco-editor-core/esm/vs/base/common/keyCodes';
|
|
7
|
+
import { IEditorMouseEvent, MouseTargetType } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
8
|
+
import { EditorOption } from '@opensumi/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
9
|
+
import { IEditorContribution } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorCommon';
|
|
10
|
+
import { ContextMenuController } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/contextmenu/browser/contextmenu';
|
|
11
|
+
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
12
|
+
|
|
13
|
+
export class EditorContextMenuController extends Disposable implements IEditorContribution {
|
|
14
|
+
public static readonly ID = 'editor.contrib.contextmenu';
|
|
15
|
+
|
|
16
|
+
public static get(editor: ICodeEditor): ContextMenuController | null {
|
|
17
|
+
return editor.getContribution<ContextMenuController>(ContextMenuController.ID);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private readonly contextKeyService: IContextKeyService;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly contextMenuService: AbstractContextMenuService,
|
|
24
|
+
private readonly globalContextKeyService: IContextKeyService,
|
|
25
|
+
private readonly contextMenuRenderer: ICtxMenuRenderer,
|
|
26
|
+
private codeEditor: ICodeEditor,
|
|
27
|
+
) {
|
|
28
|
+
super();
|
|
29
|
+
this.contextKeyService = this.registerDispose(
|
|
30
|
+
this.globalContextKeyService.createScoped((this.codeEditor as any)._contextKeyService),
|
|
31
|
+
);
|
|
32
|
+
this.addDispose(this.codeEditor.onContextMenu((e) => this.onContextMenu(e)));
|
|
33
|
+
this.addDispose(
|
|
34
|
+
this.codeEditor.onKeyDown((e) => {
|
|
35
|
+
if (e.keyCode === KeyCode.ContextMenu) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
this.showContextMenu();
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
showContextMenu(anchor?: IAnchor | null): void {
|
|
45
|
+
if (!this.codeEditor.getOption(EditorOption.contextmenu)) {
|
|
46
|
+
return; // Context menu is turned off through configuration
|
|
47
|
+
}
|
|
48
|
+
if (!this.codeEditor.hasModel()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!this.contextMenuService) {
|
|
53
|
+
this.codeEditor.focus();
|
|
54
|
+
return; // We need the context menu service to function
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Find actions available for menu
|
|
58
|
+
const menuNodes = this.getMenuNodes();
|
|
59
|
+
// Show menu if we have actions to show
|
|
60
|
+
if (menuNodes.length > 0) {
|
|
61
|
+
this._doShowContextMenu(menuNodes, anchor);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ref: https://github.com/microsoft/vscode/blob/1498d0f34053f854e75e1364adaca6f99e43de08/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
|
|
66
|
+
private onContextMenu(e: IEditorMouseEvent) {
|
|
67
|
+
if (!this.codeEditor.hasModel()) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!this.codeEditor.getOption(EditorOption.contextmenu)) {
|
|
72
|
+
this.codeEditor.focus();
|
|
73
|
+
// Ensure the cursor is at the position of the mouse click
|
|
74
|
+
if (e.target.position && !this.codeEditor.getSelection().containsPosition(e.target.position)) {
|
|
75
|
+
this.codeEditor.setPosition(e.target.position);
|
|
76
|
+
}
|
|
77
|
+
return; // Context menu is turned off through configuration
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (e.target.type === MouseTargetType.OVERLAY_WIDGET) {
|
|
81
|
+
return; // allow native menu on widgets to support right click on input field for example in find
|
|
82
|
+
}
|
|
83
|
+
if (e.target.type === MouseTargetType.CONTENT_TEXT && e.target.detail.injectedText) {
|
|
84
|
+
return; // allow native menu on injected text
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
e.event.preventDefault();
|
|
88
|
+
e.event.stopPropagation();
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
e.target.type !== MouseTargetType.CONTENT_TEXT &&
|
|
92
|
+
e.target.type !== MouseTargetType.CONTENT_EMPTY &&
|
|
93
|
+
e.target.type !== MouseTargetType.TEXTAREA
|
|
94
|
+
) {
|
|
95
|
+
return; // only support mouse click into text or native context menu key for now
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Ensure the editor gets focus if it hasn't, so the right events are being sent to other contributions
|
|
99
|
+
this.codeEditor.focus();
|
|
100
|
+
|
|
101
|
+
// Ensure the cursor is at the position of the mouse click
|
|
102
|
+
if (e.target.position) {
|
|
103
|
+
let hasSelectionAtPosition = false;
|
|
104
|
+
for (const selection of this.codeEditor.getSelections()) {
|
|
105
|
+
if (selection.containsPosition(e.target.position)) {
|
|
106
|
+
hasSelectionAtPosition = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!hasSelectionAtPosition) {
|
|
112
|
+
this.codeEditor.setPosition(e.target.position);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Unless the user triggerd the context menu through Shift+F10, use the mouse position as menu position
|
|
117
|
+
let anchor: IAnchor | null = null;
|
|
118
|
+
if (e.target.type !== MouseTargetType.TEXTAREA) {
|
|
119
|
+
anchor = { x: e.event.posx - 1, width: 2, y: e.event.posy - 1, height: 2 };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Show the context menu
|
|
123
|
+
this.showContextMenu(anchor);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private _doShowContextMenu(menuNodes: any[], anchor?: IAnchor | null) {
|
|
127
|
+
const editor = this.codeEditor;
|
|
128
|
+
// https://github.com/microsoft/vscode/blob/master/src/vs/editor/contrib/contextmenu/contextmenu.ts#L196
|
|
129
|
+
if (!editor.hasModel()) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Disable hover
|
|
134
|
+
const oldHoverSetting = editor.getOption(monaco.editor.EditorOption.hover);
|
|
135
|
+
editor.updateOptions({
|
|
136
|
+
hover: {
|
|
137
|
+
enabled: false,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (!anchor) {
|
|
142
|
+
// Ensure selection is visible
|
|
143
|
+
editor.revealPosition(editor.getPosition(), monaco.editor.ScrollType.Immediate);
|
|
144
|
+
|
|
145
|
+
editor.render();
|
|
146
|
+
const cursorCoords = editor.getScrolledVisiblePosition(editor.getPosition());
|
|
147
|
+
|
|
148
|
+
// Translate to absolute editor position
|
|
149
|
+
const editorCoords = dom.getDomNodePagePosition(editor.getDomNode());
|
|
150
|
+
const posx = editorCoords.left + cursorCoords.left;
|
|
151
|
+
const posy = editorCoords.top + cursorCoords.top + cursorCoords.height;
|
|
152
|
+
|
|
153
|
+
anchor = { x: posx, y: posy };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Show the context menu
|
|
157
|
+
this.contextMenuRenderer.show({
|
|
158
|
+
anchor: {
|
|
159
|
+
x: anchor.x - window.scrollX,
|
|
160
|
+
y: anchor.y - window.scrollY,
|
|
161
|
+
},
|
|
162
|
+
menuNodes,
|
|
163
|
+
args: [editor.getModel().uri],
|
|
164
|
+
onHide: () => {
|
|
165
|
+
// 无论是否取消都应该恢复 hover 的设置
|
|
166
|
+
this.codeEditor.updateOptions({
|
|
167
|
+
hover: oldHoverSetting,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// 右键菜单关闭后应该使编辑器重新 focus
|
|
171
|
+
// 原因是一些内置的 command (copy/cut/paste) 在执行时会在对应的 focusedEditor 执行,如果找不到 focusedEditor 则不会执行命令
|
|
172
|
+
this.codeEditor.focus();
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private getMenuNodes() {
|
|
178
|
+
const contextMenu = this.contextMenuService.createMenu({
|
|
179
|
+
id: MenuId.EditorContext,
|
|
180
|
+
contextKeyService: this.contextKeyService,
|
|
181
|
+
});
|
|
182
|
+
const menuNodes = contextMenu.getMergedMenuNodes();
|
|
183
|
+
contextMenu.dispose();
|
|
184
|
+
return menuNodes;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
+
import { IDisposable, Disposable, IContextKeyService, ILogger } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { MenuId, AbstractContextMenuService, IContextMenu } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
4
|
+
|
|
5
|
+
import { IEditorGroup } from '../../common';
|
|
6
|
+
import { IEditorActionRegistry } from '../types';
|
|
7
|
+
import { EditorGroup } from '../workbench-editor.service';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class EditorActionRegistryImpl extends Disposable implements IEditorActionRegistry {
|
|
11
|
+
private _cachedMenus = new Map<string, IContextMenu>();
|
|
12
|
+
|
|
13
|
+
@Autowired(IContextKeyService)
|
|
14
|
+
private contextKeyService: IContextKeyService;
|
|
15
|
+
|
|
16
|
+
@Autowired(AbstractContextMenuService)
|
|
17
|
+
private readonly menuService: AbstractContextMenuService;
|
|
18
|
+
|
|
19
|
+
@Autowired(ILogger)
|
|
20
|
+
logger: ILogger;
|
|
21
|
+
|
|
22
|
+
registerEditorAction(): IDisposable {
|
|
23
|
+
this.logger.warn(new Error('registerEditorAction has been deprecated, use menu apis instead'));
|
|
24
|
+
return new Disposable();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getMenu(group: IEditorGroup): IContextMenu {
|
|
28
|
+
const key = group.currentFocusedEditor
|
|
29
|
+
? 'editor-menu-' + group.currentFocusedEditor.getId()
|
|
30
|
+
: 'editor-group-menu-' + group.name;
|
|
31
|
+
if (!this._cachedMenus.has(key)) {
|
|
32
|
+
const contextKeyService = group.currentFocusedEditor
|
|
33
|
+
? this.contextKeyService.createScoped((group.currentFocusedEditor.monacoEditor as any)._contextKeyService)
|
|
34
|
+
: (group as EditorGroup).contextKeyService;
|
|
35
|
+
const menus = this.registerDispose(
|
|
36
|
+
this.menuService.createMenu({
|
|
37
|
+
id: MenuId.EditorTitle,
|
|
38
|
+
contextKeyService,
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
this._cachedMenus.set(key, menus);
|
|
42
|
+
}
|
|
43
|
+
return this._cachedMenus.get(key)!;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import { getIcon } from '@opensumi/ide-core-browser';
|
|
3
|
+
import {
|
|
4
|
+
IMenuRegistry,
|
|
5
|
+
ISubmenuItem,
|
|
6
|
+
MenuId,
|
|
7
|
+
MenuContribution,
|
|
8
|
+
IMenuItem,
|
|
9
|
+
MenuCommandDesc,
|
|
10
|
+
} from '@opensumi/ide-core-browser/lib/menu/next';
|
|
11
|
+
import { Command, CommandContribution, CommandRegistry, Disposable, localize } from '@opensumi/ide-core-common';
|
|
12
|
+
import { Domain } from '@opensumi/ide-core-common/lib/di-helper';
|
|
13
|
+
|
|
14
|
+
import { WorkbenchEditorService } from '../types';
|
|
15
|
+
|
|
16
|
+
import { IEditorOpenType } from './../../common/editor';
|
|
17
|
+
import { WorkbenchEditorServiceImpl } from './../workbench-editor.service';
|
|
18
|
+
|
|
19
|
+
namespace OPEN_TYPE_COMMANDS {
|
|
20
|
+
export const EDITOR_OPEN_TYPE: Command = {
|
|
21
|
+
id: 'editor.opentype',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Domain(CommandContribution, MenuContribution)
|
|
26
|
+
export class OpenTypeMenuContribution extends Disposable implements CommandContribution, MenuContribution {
|
|
27
|
+
@Autowired(WorkbenchEditorService)
|
|
28
|
+
private readonly workbenchEditorService: WorkbenchEditorServiceImpl;
|
|
29
|
+
|
|
30
|
+
@Autowired(IMenuRegistry)
|
|
31
|
+
private readonly menuRegistry: IMenuRegistry;
|
|
32
|
+
|
|
33
|
+
registerCommands(commands: CommandRegistry): void {
|
|
34
|
+
commands.registerCommand(OPEN_TYPE_COMMANDS.EDITOR_OPEN_TYPE, {
|
|
35
|
+
execute: (id: string) => {
|
|
36
|
+
if (id) {
|
|
37
|
+
this.workbenchEditorService.currentEditorGroup.changeOpenType(id);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
this.disposables.push(
|
|
46
|
+
this.workbenchEditorService.onActiveResourceChange((e) => {
|
|
47
|
+
const openTypes = this.workbenchEditorService.currentEditorGroup.availableOpenTypes;
|
|
48
|
+
// 如果打开方式没有两个以上,则不需要展示
|
|
49
|
+
const preMenu = this.menuRegistry
|
|
50
|
+
.getMenuItems(MenuId.OpenTypeSubmenuContext)
|
|
51
|
+
.map((e) => (e as IMenuItem).command as MenuCommandDesc);
|
|
52
|
+
preMenu.forEach((c) => {
|
|
53
|
+
this.menuRegistry.unregisterMenuItem(MenuId.OpenTypeSubmenuContext, c.id);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.menuRegistry.unregisterMenuItem(MenuId.EditorTitle, MenuId.OpenTypeSubmenuContext);
|
|
57
|
+
|
|
58
|
+
if (openTypes.length >= 2) {
|
|
59
|
+
this.registerMenuItem(openTypes);
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
registerMenus(menuRegistry: IMenuRegistry) {}
|
|
66
|
+
|
|
67
|
+
private registerMenuItem(openTypes: IEditorOpenType[]) {
|
|
68
|
+
const openTypeMenus = {
|
|
69
|
+
submenu: MenuId.OpenTypeSubmenuContext,
|
|
70
|
+
label: localize('editor.openType'),
|
|
71
|
+
group: 'navigation',
|
|
72
|
+
order: Number.MIN_SAFE_INTEGER,
|
|
73
|
+
iconClass: getIcon('setting'),
|
|
74
|
+
type: 'default',
|
|
75
|
+
} as ISubmenuItem;
|
|
76
|
+
|
|
77
|
+
this.menuRegistry.registerMenuItem(MenuId.EditorTitle, openTypeMenus);
|
|
78
|
+
|
|
79
|
+
openTypes.forEach((type) => {
|
|
80
|
+
this.menuRegistry.registerMenuItem(MenuId.OpenTypeSubmenuContext, {
|
|
81
|
+
command: {
|
|
82
|
+
id: OPEN_TYPE_COMMANDS.EDITOR_OPEN_TYPE.id,
|
|
83
|
+
label: type.title || type.componentId || type.type,
|
|
84
|
+
},
|
|
85
|
+
extraTailArgs: [type.componentId ?? type.type],
|
|
86
|
+
group: 'navigation',
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
+
import { IContextKeyService } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { ResourceContextKey } from '@opensumi/ide-core-browser/lib/contextkey/resource';
|
|
4
|
+
import { AbstractContextMenuService, ICtxMenuRenderer, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
5
|
+
import { URI } from '@opensumi/ide-core-common';
|
|
6
|
+
|
|
7
|
+
import { IEditorGroup } from '../../common';
|
|
8
|
+
import { EditorGroup } from '../workbench-editor.service';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class TabTitleMenuService {
|
|
12
|
+
@Autowired(AbstractContextMenuService)
|
|
13
|
+
ctxMenuService: AbstractContextMenuService;
|
|
14
|
+
|
|
15
|
+
@Autowired(ICtxMenuRenderer)
|
|
16
|
+
ctxMenuRenderer: ICtxMenuRenderer;
|
|
17
|
+
|
|
18
|
+
@Autowired(IContextKeyService)
|
|
19
|
+
contextKeyService: IContextKeyService;
|
|
20
|
+
|
|
21
|
+
private _editorTitleContextKey;
|
|
22
|
+
|
|
23
|
+
private get editorTitleContextKey() {
|
|
24
|
+
if (!this._editorTitleContextKey) {
|
|
25
|
+
this._editorTitleContextKey = this.contextKeyService.createKey('editorTitleContext', false);
|
|
26
|
+
}
|
|
27
|
+
return this._editorTitleContextKey;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
show(x: number, y: number, uri: URI, group: IEditorGroup) {
|
|
31
|
+
// 设置resourceScheme
|
|
32
|
+
const titleContext = (group as EditorGroup).contextKeyService.createScoped();
|
|
33
|
+
const resourceContext = new ResourceContextKey(titleContext);
|
|
34
|
+
resourceContext.set(uri);
|
|
35
|
+
this.editorTitleContextKey.set(true);
|
|
36
|
+
|
|
37
|
+
const menus = this.ctxMenuService.createMenu({
|
|
38
|
+
id: MenuId.EditorTitleContext,
|
|
39
|
+
contextKeyService: titleContext,
|
|
40
|
+
});
|
|
41
|
+
const menuNodes = menus.getMergedMenuNodes();
|
|
42
|
+
menus.dispose();
|
|
43
|
+
titleContext.dispose();
|
|
44
|
+
|
|
45
|
+
this.ctxMenuRenderer.show({
|
|
46
|
+
anchor: { x, y },
|
|
47
|
+
menuNodes,
|
|
48
|
+
args: [{ uri, group }],
|
|
49
|
+
onHide: () => {
|
|
50
|
+
this.editorTitleContextKey.set(false);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import { Domain } from '@opensumi/ide-core-browser';
|
|
3
|
+
|
|
4
|
+
import { ResourceService } from '../../common';
|
|
5
|
+
import { BrowserEditorContribution, EditorComponentRegistry, EditorOpenType } from '../types';
|
|
6
|
+
|
|
7
|
+
import { MergeEditorResourceProvider } from './merge-editor.provider';
|
|
8
|
+
|
|
9
|
+
@Domain(BrowserEditorContribution)
|
|
10
|
+
export class MergeEditorContribution implements BrowserEditorContribution {
|
|
11
|
+
@Autowired()
|
|
12
|
+
private readonly mergeEditorResourceProvider: MergeEditorResourceProvider;
|
|
13
|
+
|
|
14
|
+
registerResource(resourceService: ResourceService): void {
|
|
15
|
+
resourceService.registerResourceProvider(this.mergeEditorResourceProvider);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
registerEditorComponent(registry: EditorComponentRegistry) {
|
|
19
|
+
registry.registerEditorComponentResolver('mergeEditor', (_, results) => {
|
|
20
|
+
results.push({
|
|
21
|
+
type: EditorOpenType.mergeEditor,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
+
import { URI, WithEventBus, MaybePromise, LabelService } from '@opensumi/ide-core-browser';
|
|
3
|
+
|
|
4
|
+
import { IResourceProvider, IResource } from '../../common';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class MergeEditorResourceProvider extends WithEventBus implements IResourceProvider {
|
|
8
|
+
scheme = 'mergeEditor';
|
|
9
|
+
|
|
10
|
+
@Autowired(LabelService)
|
|
11
|
+
private readonly labelService: LabelService;
|
|
12
|
+
|
|
13
|
+
public provideResource(uri: URI): MaybePromise<IResource<any>> {
|
|
14
|
+
const { openMetadata, name } = uri.getParsedQuery();
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const parseMetaData = JSON.parse(openMetadata);
|
|
18
|
+
const { ancestor, input1, input2, output } = parseMetaData;
|
|
19
|
+
const resultEditorUri = new URI(output);
|
|
20
|
+
const icon = this.labelService.getIcon(resultEditorUri);
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
icon,
|
|
24
|
+
uri,
|
|
25
|
+
metadata: {
|
|
26
|
+
ancestor,
|
|
27
|
+
input1,
|
|
28
|
+
input2,
|
|
29
|
+
output,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw Error('invalid merge editor resource parse');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|