@opensumi/ide-core-common 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.
Files changed (159) hide show
  1. package/lib/command.d.ts +15 -5
  2. package/lib/command.d.ts.map +1 -1
  3. package/lib/command.js +11 -1
  4. package/lib/command.js.map +1 -1
  5. package/lib/const/application.d.ts +6 -1
  6. package/lib/const/application.d.ts.map +1 -1
  7. package/lib/const/application.js +8 -3
  8. package/lib/const/application.js.map +1 -1
  9. package/lib/declare.d.ts +2 -2
  10. package/lib/declare.d.ts.map +1 -1
  11. package/lib/editor.d.ts +4 -0
  12. package/lib/editor.d.ts.map +1 -1
  13. package/lib/electron.d.ts +1 -1
  14. package/lib/electron.d.ts.map +1 -1
  15. package/lib/event-bus/event-bus-types.d.ts +1 -1
  16. package/lib/event-bus/event-bus-types.d.ts.map +1 -1
  17. package/lib/event-bus/event-bus.js.map +1 -1
  18. package/lib/event-bus/event-decorator.js.map +1 -1
  19. package/lib/extension.schema.d.ts +1 -1
  20. package/lib/extension.schema.d.ts.map +1 -1
  21. package/lib/hash-calculate/WASMInterface.d.ts +2 -2
  22. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
  23. package/lib/hash-calculate/hash-calculate.js.map +1 -1
  24. package/lib/hash-calculate/util.d.ts +2 -2
  25. package/lib/hash-calculate/util.d.ts.map +1 -1
  26. package/lib/json-schema.d.ts +9 -0
  27. package/lib/json-schema.d.ts.map +1 -1
  28. package/lib/keyboard/keymap.d.ts +1 -1
  29. package/lib/keyboard/keymap.d.ts.map +1 -1
  30. package/lib/localize.d.ts +1 -1
  31. package/lib/localize.d.ts.map +1 -1
  32. package/lib/log.d.ts +2 -2
  33. package/lib/log.d.ts.map +1 -1
  34. package/lib/mime.d.ts +6 -6
  35. package/lib/module.js.map +1 -1
  36. package/lib/preferences/preference-schema.d.ts +13 -3
  37. package/lib/preferences/preference-schema.d.ts.map +1 -1
  38. package/lib/preferences/preference-schema.js +11 -1
  39. package/lib/preferences/preference-schema.js.map +1 -1
  40. package/lib/preferences/preference-scope.d.ts +8 -1
  41. package/lib/preferences/preference-scope.d.ts.map +1 -1
  42. package/lib/preferences/preference-scope.js +11 -2
  43. package/lib/preferences/preference-scope.js.map +1 -1
  44. package/lib/problem-matcher.d.ts +1 -1
  45. package/lib/problem-matcher.d.ts.map +1 -1
  46. package/lib/problem-matcher.js.map +1 -1
  47. package/lib/problem-pattern.d.ts +4 -2
  48. package/lib/problem-pattern.d.ts.map +1 -1
  49. package/lib/problem-pattern.js +24 -1
  50. package/lib/problem-pattern.js.map +1 -1
  51. package/lib/reference.d.ts +2 -1
  52. package/lib/reference.d.ts.map +1 -1
  53. package/lib/reference.js +11 -6
  54. package/lib/reference.js.map +1 -1
  55. package/lib/reporter.js.map +1 -1
  56. package/lib/storage.d.ts +1 -1
  57. package/lib/storage.d.ts.map +1 -1
  58. package/lib/storage.js.map +1 -1
  59. package/lib/task-definition.js.map +1 -1
  60. package/lib/types/common.d.ts +1 -1
  61. package/lib/types/common.d.ts.map +1 -1
  62. package/lib/types/editor.d.ts +2 -2
  63. package/lib/types/editor.d.ts.map +1 -1
  64. package/lib/types/file-watch.d.ts +1 -1
  65. package/lib/types/file-watch.d.ts.map +1 -1
  66. package/lib/types/markers/markers-manager.d.ts.map +1 -1
  67. package/lib/types/markers/markers-manager.js +4 -10
  68. package/lib/types/markers/markers-manager.js.map +1 -1
  69. package/lib/types/markers/markers.d.ts +2 -0
  70. package/lib/types/markers/markers.d.ts.map +1 -1
  71. package/lib/types/markers/markers.js.map +1 -1
  72. package/package.json +7 -6
  73. package/src/LifeCyclePhase.ts +6 -0
  74. package/src/application-error.ts +77 -0
  75. package/src/application-props.ts +28 -0
  76. package/src/application.lifecycle.ts +15 -0
  77. package/src/browser-fs/ensure-dir.ts +46 -0
  78. package/src/browser-fs/util.ts +52 -0
  79. package/src/clipboard.ts +31 -0
  80. package/src/command.ts +726 -0
  81. package/src/commands/terminal.ts +0 -0
  82. package/src/comparers.ts +152 -0
  83. package/src/connection.ts +7 -0
  84. package/src/const/application.ts +11 -0
  85. package/src/const/index.ts +1 -0
  86. package/src/contribution-provider.ts +47 -0
  87. package/src/credential.ts +21 -0
  88. package/src/crypto.ts +8 -0
  89. package/src/declare.ts +3 -0
  90. package/src/di-helper/domain-helper.ts +48 -0
  91. package/src/di-helper/index.ts +1 -0
  92. package/src/editor.ts +6 -0
  93. package/src/electron.ts +168 -0
  94. package/src/env.ts +1 -0
  95. package/src/event-bus/basic-event.ts +3 -0
  96. package/src/event-bus/event-bus-types.ts +68 -0
  97. package/src/event-bus/event-bus.ts +57 -0
  98. package/src/event-bus/event-decorator.ts +32 -0
  99. package/src/event-bus/index.ts +4 -0
  100. package/src/extension.schema.ts +16 -0
  101. package/src/hash-calculate/WASMInterface.ts +266 -0
  102. package/src/hash-calculate/hash-calculate.ts +53 -0
  103. package/src/hash-calculate/lockedCreate.ts +17 -0
  104. package/src/hash-calculate/md5.wasm.json +1 -0
  105. package/src/hash-calculate/mutex.ts +30 -0
  106. package/src/hash-calculate/util.ts +190 -0
  107. package/src/id-generator.ts +15 -0
  108. package/src/index.ts +39 -0
  109. package/src/json-schema.ts +80 -0
  110. package/src/keyboard/index.ts +2 -0
  111. package/src/keyboard/keyboard-layout-provider.ts +46 -0
  112. package/src/keyboard/keymap.ts +224 -0
  113. package/src/line-text.ts +93 -0
  114. package/src/localize.ts +203 -0
  115. package/src/log.ts +338 -0
  116. package/src/markdown.ts +8 -0
  117. package/src/menu.ts +31 -0
  118. package/src/mime.ts +8 -0
  119. package/src/mocks/electron/browserMock.ts +10 -0
  120. package/src/mocks/electron/ipcRenderer.ts +30 -0
  121. package/src/module.ts +31 -0
  122. package/src/network.ts +47 -0
  123. package/src/node/cli.ts +5 -0
  124. package/src/node/port.ts +134 -0
  125. package/src/preferences/index.ts +2 -0
  126. package/src/preferences/preference-schema.ts +122 -0
  127. package/src/preferences/preference-scope.ts +65 -0
  128. package/src/problem-matcher.ts +389 -0
  129. package/src/problem-pattern.ts +574 -0
  130. package/src/range.ts +24 -0
  131. package/src/reference.ts +141 -0
  132. package/src/reporter.ts +64 -0
  133. package/src/settings/general.ts +5 -0
  134. package/src/settings/index.ts +3 -0
  135. package/src/settings/search.ts +7 -0
  136. package/src/settings/terminal.ts +9 -0
  137. package/src/storage.ts +99 -0
  138. package/src/task-definition.ts +172 -0
  139. package/src/theme.ts +7 -0
  140. package/src/types/accessibility.ts +4 -0
  141. package/src/types/application.ts +14 -0
  142. package/src/types/authentication.ts +120 -0
  143. package/src/types/common.ts +14 -0
  144. package/src/types/dnd.ts +8 -0
  145. package/src/types/editor.ts +246 -0
  146. package/src/types/extension.ts +96 -0
  147. package/src/types/file-watch.ts +100 -0
  148. package/src/types/file.ts +262 -0
  149. package/src/types/index.ts +15 -0
  150. package/src/types/markdown.ts +10 -0
  151. package/src/types/markers/index.ts +2 -0
  152. package/src/types/markers/markers-manager.ts +392 -0
  153. package/src/types/markers/markers.ts +125 -0
  154. package/src/types/message.ts +6 -0
  155. package/src/types/reporter.ts +96 -0
  156. package/src/types/statusbar.ts +6 -0
  157. package/src/types/string.ts +3 -0
  158. package/src/utils/index.ts +1 -0
  159. package/src/utils/ipc.ts +28 -0
@@ -0,0 +1,122 @@
1
+ /** ******************************************************************************
2
+ * Copyright (C) 2018 Red Hat, Inc. and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/core/src/common/preferences/preference-schema.ts
17
+
18
+ import { PreferenceScope } from './preference-scope';
19
+
20
+ export interface PreferenceSchema {
21
+ [name: string]: any;
22
+ scope?: 'application' | 'window' | 'resource' | PreferenceScope;
23
+ overridable?: boolean;
24
+ overrideIdentifier?: string;
25
+ properties: PreferenceSchemaProperties;
26
+ }
27
+ export namespace PreferenceSchema {
28
+ export function is(obj: any): obj is PreferenceSchema {
29
+ return !!obj && 'properties' in obj && PreferenceSchemaProperties.is(obj['properties']);
30
+ }
31
+ export function getDefaultScope(schema: PreferenceSchema): PreferenceScope {
32
+ let defaultScope: PreferenceScope = PreferenceScope.Workspace;
33
+ if (!PreferenceScope.is(schema.scope)) {
34
+ defaultScope = PreferenceScope.fromString(schema.scope as string) || PreferenceScope.Workspace;
35
+ } else {
36
+ defaultScope = schema.scope;
37
+ }
38
+ return defaultScope;
39
+ }
40
+ }
41
+
42
+ export interface PreferenceSchemaProperties {
43
+ [name: string]: PreferenceSchemaProperty;
44
+ }
45
+ export namespace PreferenceSchemaProperties {
46
+ export function is(obj: any): obj is PreferenceSchemaProperties {
47
+ return !!obj && typeof obj === 'object';
48
+ }
49
+ }
50
+
51
+ export interface PreferenceDataSchema {
52
+ [name: string]: any;
53
+ scope?: PreferenceScope;
54
+ properties: {
55
+ [name: string]: PreferenceDataProperty;
56
+ };
57
+ patternProperties: {
58
+ [name: string]: PreferenceDataProperty;
59
+ };
60
+ }
61
+
62
+ export interface PreferenceItem {
63
+ type?: PreferencePropertyType | PreferencePropertyType[];
64
+ minimum?: number;
65
+ /**
66
+ * content assist (UI) default value
67
+ */
68
+ default?: any;
69
+ /**
70
+ * preference default value, if `undefined` then `default`
71
+ */
72
+ defaultValue?: any;
73
+ enum?: Array<string | number | boolean>;
74
+ enumDescriptions?: Array<string>;
75
+ items?: PreferenceItem;
76
+ properties?: { [name: string]: PreferenceItem };
77
+ additionalProperties?: object;
78
+ overridable?: boolean;
79
+
80
+ description?: string;
81
+ markdownDescription?: string;
82
+
83
+ deprecationMessage?: string;
84
+ markdownDeprecationMessage?: string;
85
+ [name: string]: any;
86
+ }
87
+
88
+ export interface PreferenceSchemaProperty extends PreferenceItem {
89
+ description?: string;
90
+ scope?: 'application' | 'window' | 'resource' | PreferenceScope;
91
+ }
92
+
93
+ export interface PreferenceDataProperty extends PreferenceItem {
94
+ description?: string;
95
+ scope?: PreferenceScope;
96
+ }
97
+ export namespace PreferenceDataProperty {
98
+ export function fromPreferenceSchemaProperty(
99
+ schemaProps: PreferenceSchemaProperty,
100
+ defaultScope: PreferenceScope = PreferenceScope.Workspace,
101
+ ): PreferenceDataProperty {
102
+ if (!schemaProps.scope) {
103
+ schemaProps.scope = defaultScope;
104
+ } else if (typeof schemaProps.scope === 'string') {
105
+ return Object.assign(schemaProps, { scope: PreferenceScope.fromString(schemaProps.scope) || defaultScope });
106
+ }
107
+ return schemaProps as PreferenceDataProperty;
108
+ }
109
+ }
110
+
111
+ export const PREFERENCE_PROPERTY_TYPE = {
112
+ STRING: 'string',
113
+ ARRAY: 'array',
114
+ INT: 'integer',
115
+ NUMBER: 'number',
116
+ OBJECT: 'object',
117
+ BOOLEAN: 'boolean',
118
+ NULL: 'null',
119
+ STRING_ARRAY: 'string[]',
120
+ } as const;
121
+
122
+ export type PreferencePropertyType = typeof PREFERENCE_PROPERTY_TYPE[keyof typeof PREFERENCE_PROPERTY_TYPE];
@@ -0,0 +1,65 @@
1
+ export enum PreferenceScope {
2
+ Default,
3
+ User,
4
+ Workspace,
5
+ Folder,
6
+ }
7
+
8
+ export interface PreferenceScopeWithLabel {
9
+ id: PreferenceScope;
10
+ label: string;
11
+ }
12
+
13
+ export const WorkspaceScope: PreferenceScopeWithLabel = {
14
+ id: PreferenceScope.Workspace,
15
+ label: 'preference.tab.workspace',
16
+ };
17
+
18
+ export const UserScope: PreferenceScopeWithLabel = {
19
+ id: PreferenceScope.User,
20
+ label: 'preference.tab.user',
21
+ };
22
+
23
+ export namespace PreferenceScope {
24
+ export function is(scope: any): scope is PreferenceScope {
25
+ return typeof scope === 'number' && getScopes().findIndex((s) => s === scope) >= 0;
26
+ }
27
+
28
+ export function getScopes(): PreferenceScope[] {
29
+ return Object.keys(PreferenceScope)
30
+ .filter((k) => typeof PreferenceScope[k as any] === 'string')
31
+ .map((v) => Number(v));
32
+ }
33
+
34
+ export function getReversedScopes(): PreferenceScope[] {
35
+ return getScopes().reverse();
36
+ }
37
+
38
+ export function getScopeNames(scope?: PreferenceScope): string[] {
39
+ const names: string[] = [];
40
+ const allNames = Object.keys(PreferenceScope).filter((k) => typeof PreferenceScope[k as any] === 'number');
41
+ if (scope) {
42
+ for (const name of allNames) {
43
+ if (PreferenceScope[name] <= scope) {
44
+ names.push(name);
45
+ }
46
+ }
47
+ }
48
+ return names;
49
+ }
50
+
51
+ // 转义 vscode 中对configuration中scope的定义
52
+ export function fromString(strScope: string): PreferenceScope | undefined {
53
+ switch (strScope) {
54
+ case 'application':
55
+ return PreferenceScope.User;
56
+ case 'window':
57
+ return PreferenceScope.Folder;
58
+ case 'resource':
59
+ return PreferenceScope.Folder;
60
+ }
61
+ }
62
+ }
63
+
64
+ export const DEFAULT_WORKSPACE_CONFIGURATION_DIR_NAME = '.sumi';
65
+ export const VSCODE_WORKSPACE_CONFIGURATION_DIR_NAME = '.vscode';
@@ -0,0 +1,389 @@
1
+ /** ******************************************************************************
2
+ * Copyright (C) 2018 Red Hat, Inc. and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/task/src/browser/task-problem-matcher-registry.ts
17
+
18
+ import { Injectable, Autowired } from '@opensumi/di';
19
+ import { URI, Emitter, DisposableCollection, Disposable, IDisposable } from '@opensumi/ide-utils';
20
+
21
+ import {
22
+ IProblemPatternRegistry,
23
+ ApplyToKind,
24
+ FileLocationKind,
25
+ Severity,
26
+ ProblemPatternContribution,
27
+ ProblemPattern,
28
+ WatchingPattern,
29
+ } from './problem-pattern';
30
+
31
+ export interface WatchingMatcherContribution {
32
+ // If set to true the background monitor is in active mode when the task starts.
33
+ // This is equals of issuing a line that matches the beginPattern
34
+ activeOnStart?: boolean;
35
+ beginsPattern: string | WatchingPattern;
36
+ endsPattern: string | WatchingPattern;
37
+ }
38
+
39
+ export interface ProblemMatcherContribution {
40
+ base?: string;
41
+ name?: string;
42
+ label: string;
43
+ deprecated?: boolean;
44
+
45
+ owner: string;
46
+ source?: string;
47
+ applyTo?: string;
48
+ fileLocation?: 'absolute' | 'relative' | string[];
49
+ pattern: string | ProblemPatternContribution | ProblemPatternContribution[];
50
+ severity?: string;
51
+ watching?: WatchingMatcherContribution; // deprecated. Use `background`.
52
+ background?: WatchingMatcherContribution;
53
+ }
54
+
55
+ export interface WatchingMatcher {
56
+ // If set to true the background monitor is in active mode when the task starts.
57
+ // This is equals of issuing a line that matches the beginPattern
58
+ activeOnStart: boolean;
59
+ beginsPattern: WatchingPattern;
60
+ endsPattern: WatchingPattern;
61
+ }
62
+
63
+ export namespace WatchingMatcher {
64
+ export function fromWatchingMatcherContribution(
65
+ value: WatchingMatcherContribution | undefined,
66
+ ): WatchingMatcher | undefined {
67
+ if (!value) {
68
+ return undefined;
69
+ }
70
+ return {
71
+ activeOnStart: !!value.activeOnStart,
72
+ beginsPattern: typeof value.beginsPattern === 'string' ? { regexp: value.beginsPattern } : value.beginsPattern,
73
+ endsPattern: typeof value.endsPattern === 'string' ? { regexp: value.endsPattern } : value.endsPattern,
74
+ };
75
+ }
76
+ }
77
+
78
+ export interface ProblemMatcher {
79
+ owner: string;
80
+ source?: string;
81
+ applyTo?: ApplyToKind | string;
82
+ fileLocation: FileLocationKind | string[];
83
+ filePrefix?: string;
84
+ pattern: ProblemPattern | ProblemPattern[];
85
+ severity?: Severity | string;
86
+ watching?: WatchingMatcher;
87
+ uriProvider?: (path: string) => URI;
88
+ }
89
+
90
+ export type ProblemMatcherType = string | ProblemMatcher | Array<string | ProblemMatcher>;
91
+
92
+ export interface NamedProblemMatcher extends ProblemMatcher {
93
+ /**
94
+ * This name can be used to refer to the
95
+ * problem matcher from within a task.
96
+ */
97
+ name: string;
98
+
99
+ /**
100
+ * A human readable label.
101
+ */
102
+ label?: string;
103
+ deprecated?: boolean;
104
+ }
105
+
106
+ export const IProblemMatcherRegistry = Symbol('IProblemMatcherRegistry');
107
+
108
+ export interface IProblemMatcherRegistry {
109
+ register(matcher: ProblemMatcherContribution): IDisposable;
110
+ get(name: string): NamedProblemMatcher | undefined;
111
+ getAll(): NamedProblemMatcher[];
112
+ }
113
+
114
+ @Injectable()
115
+ export class ProblemMatchersRegistryImpl implements IProblemMatcherRegistry {
116
+ @Autowired(IProblemPatternRegistry)
117
+ problemPattern: IProblemPatternRegistry;
118
+
119
+ protected readonly onDidChangeProblemMatcherEmitter = new Emitter<void>();
120
+
121
+ private readonly matchers = new Map<string, NamedProblemMatcher>();
122
+
123
+ constructor() {
124
+ this.init();
125
+ }
126
+
127
+ private init() {
128
+ this.fillDefaults();
129
+ }
130
+
131
+ /**
132
+ * Finds the problem matcher from the registry by its name.
133
+ *
134
+ * @param name the name of the problem matcher
135
+ * @return the problem matcher. If the task definition is not found, `undefined` is returned.
136
+ */
137
+ get = (name: string): NamedProblemMatcher | undefined => {
138
+ if (name.startsWith('$')) {
139
+ return this.matchers.get(name.slice(1));
140
+ }
141
+ return this.matchers.get(name);
142
+ };
143
+
144
+ /**
145
+ * Returns all registered problem matchers in the registry.
146
+ */
147
+ getAll(): NamedProblemMatcher[] {
148
+ const all: NamedProblemMatcher[] = [];
149
+ for (const matcherName of this.matchers.keys()) {
150
+ all.push(this.get(matcherName)!);
151
+ }
152
+ all.sort((one, other) => one.name.localeCompare(other.name));
153
+ return all;
154
+ }
155
+
156
+ /**
157
+ * Add a problem matcher to the registry.
158
+ *
159
+ * @param definition the problem matcher to be added.
160
+ */
161
+ register(matcher: ProblemMatcherContribution): IDisposable {
162
+ if (!matcher.name) {
163
+ // eslint-disable-next-line no-console
164
+ console.error('Only named Problem Matchers can be registered.');
165
+ return Disposable.NULL;
166
+ }
167
+ const toDispose = new DisposableCollection(
168
+ Disposable.create(() => {
169
+ /* mark as not disposed */
170
+ this.onDidChangeProblemMatcherEmitter.fire(undefined);
171
+ }),
172
+ );
173
+ this.doRegister(matcher, toDispose).then(() => this.onDidChangeProblemMatcherEmitter.fire(undefined));
174
+ return toDispose;
175
+ }
176
+
177
+ protected async doRegister(matcher: ProblemMatcherContribution, toDispose: DisposableCollection): Promise<void> {
178
+ const problemMatcher = await this.getProblemMatcherFromContribution(matcher);
179
+ if (toDispose.disposed) {
180
+ return;
181
+ }
182
+ toDispose.push(this.add(problemMatcher as NamedProblemMatcher));
183
+ }
184
+
185
+ private add(matcher: NamedProblemMatcher): IDisposable {
186
+ this.matchers.set(matcher.name, matcher);
187
+ return Disposable.create(() => this.matchers.delete(matcher.name));
188
+ }
189
+
190
+ /**
191
+ * Transforms the `ProblemMatcherContribution` to a `ProblemMatcher`
192
+ *
193
+ * @return the problem matcher
194
+ */
195
+ async getProblemMatcherFromContribution(matcher: ProblemMatcherContribution): Promise<ProblemMatcher> {
196
+ let baseMatcher: NamedProblemMatcher | undefined;
197
+ if (matcher.base) {
198
+ baseMatcher = this.get(matcher.base);
199
+ }
200
+
201
+ let fileLocation: FileLocationKind | undefined;
202
+ let filePrefix: string | undefined;
203
+ if (matcher.fileLocation === undefined) {
204
+ fileLocation = baseMatcher ? (baseMatcher.fileLocation as FileLocationKind) : FileLocationKind.Relative;
205
+ filePrefix = baseMatcher ? baseMatcher.filePrefix : '${workspaceFolder}';
206
+ } else {
207
+ const locationAndPrefix = this.getFileLocationKindAndPrefix(matcher);
208
+ fileLocation = locationAndPrefix.fileLocation;
209
+ filePrefix = locationAndPrefix.filePrefix;
210
+ }
211
+
212
+ const patterns: ProblemPattern[] = [];
213
+ if (matcher.pattern) {
214
+ if (typeof matcher.pattern === 'string') {
215
+ await this.problemPattern.onReady();
216
+ const registeredPattern = this.problemPattern.get(matcher.pattern);
217
+ if (Array.isArray(registeredPattern)) {
218
+ patterns.push(...registeredPattern);
219
+ } else if (registeredPattern) {
220
+ patterns.push(registeredPattern);
221
+ }
222
+ } else if (Array.isArray(matcher.pattern)) {
223
+ patterns.push(...matcher.pattern.map((p) => ProblemPattern.fromProblemPatternContribution(p)));
224
+ } else {
225
+ patterns.push(ProblemPattern.fromProblemPatternContribution(matcher.pattern));
226
+ }
227
+ } else if (baseMatcher) {
228
+ patterns.push(...(baseMatcher.pattern as ProblemPattern[]));
229
+ }
230
+
231
+ let deprecated: boolean | undefined = matcher.deprecated;
232
+ if (deprecated === undefined && baseMatcher) {
233
+ deprecated = baseMatcher.deprecated;
234
+ }
235
+
236
+ let applyTo: ApplyToKind | undefined;
237
+ if (matcher.applyTo === undefined) {
238
+ applyTo = baseMatcher ? (baseMatcher.applyTo as ApplyToKind) : (ApplyToKind.allDocuments as ApplyToKind);
239
+ } else {
240
+ applyTo = ApplyToKind.fromString(matcher.applyTo) || ApplyToKind.allDocuments;
241
+ }
242
+
243
+ let severity: Severity = Severity.fromValue(matcher.severity);
244
+ if (matcher.severity === undefined && baseMatcher && baseMatcher.severity !== undefined) {
245
+ severity = baseMatcher.severity as Severity;
246
+ }
247
+ let watching: WatchingMatcher | undefined = WatchingMatcher.fromWatchingMatcherContribution(
248
+ matcher.background || matcher.watching,
249
+ );
250
+ if (watching === undefined && baseMatcher) {
251
+ watching = baseMatcher.watching;
252
+ }
253
+ const problemMatcher = {
254
+ name: matcher.name || (baseMatcher ? baseMatcher.name : undefined),
255
+ label: matcher.label || (baseMatcher ? baseMatcher.label : undefined),
256
+ deprecated,
257
+ owner: matcher.owner || (baseMatcher ? baseMatcher.owner : ''),
258
+ source: matcher.source || (baseMatcher ? baseMatcher.source : undefined),
259
+ applyTo,
260
+ fileLocation,
261
+ filePrefix,
262
+ pattern: patterns,
263
+ severity,
264
+ watching,
265
+ };
266
+ return problemMatcher;
267
+ }
268
+
269
+ private getFileLocationKindAndPrefix(matcher: ProblemMatcherContribution): {
270
+ fileLocation: FileLocationKind;
271
+ filePrefix: string;
272
+ } {
273
+ let fileLocation = FileLocationKind.Relative;
274
+ let filePrefix = '${workspaceFolder}';
275
+ if (matcher.fileLocation !== undefined) {
276
+ if (Array.isArray(matcher.fileLocation)) {
277
+ if (matcher.fileLocation.length > 0) {
278
+ const locationKind = FileLocationKind.fromString(matcher.fileLocation[0]);
279
+ if (matcher.fileLocation.length === 1 && locationKind === FileLocationKind.Absolute) {
280
+ fileLocation = locationKind;
281
+ } else if (
282
+ matcher.fileLocation.length === 2 &&
283
+ locationKind === FileLocationKind.Relative &&
284
+ matcher.fileLocation[1]
285
+ ) {
286
+ fileLocation = locationKind;
287
+ filePrefix = matcher.fileLocation[1];
288
+ }
289
+ }
290
+ } else {
291
+ const locationKind = FileLocationKind.fromString(matcher.fileLocation);
292
+ if (locationKind) {
293
+ fileLocation = locationKind;
294
+ if (locationKind === FileLocationKind.Relative) {
295
+ filePrefix = '${workspaceFolder}';
296
+ }
297
+ }
298
+ }
299
+ }
300
+ return { fileLocation, filePrefix };
301
+ }
302
+
303
+ // copied from https://github.com/Microsoft/vscode/blob/1.33.1/src/vs/workbench/contrib/tasks/common/problemMatcher.ts
304
+ private fillDefaults(): void {
305
+ this.add({
306
+ name: 'msCompile',
307
+ label: 'Microsoft compiler problems',
308
+ owner: 'msCompile',
309
+ applyTo: ApplyToKind.allDocuments,
310
+ fileLocation: FileLocationKind.Absolute,
311
+ pattern: this.problemPattern.get('msCompile')!,
312
+ });
313
+
314
+ this.add({
315
+ name: 'lessCompile',
316
+ label: 'Less problems',
317
+ deprecated: true,
318
+ owner: 'lessCompile',
319
+ source: 'less',
320
+ applyTo: ApplyToKind.allDocuments,
321
+ fileLocation: FileLocationKind.Absolute,
322
+ pattern: this.problemPattern.get('lessCompile')!,
323
+ severity: Severity.Error,
324
+ });
325
+
326
+ this.add({
327
+ name: 'gulp-tsc',
328
+ label: 'Gulp TSC Problems',
329
+ owner: 'typescript',
330
+ source: 'ts',
331
+ applyTo: ApplyToKind.closedDocuments,
332
+ fileLocation: FileLocationKind.Relative,
333
+ filePrefix: '${workspaceFolder}',
334
+ pattern: this.problemPattern.get('gulp-tsc')!,
335
+ });
336
+
337
+ this.add({
338
+ name: 'jshint',
339
+ label: 'JSHint problems',
340
+ owner: 'jshint',
341
+ source: 'jshint',
342
+ applyTo: ApplyToKind.allDocuments,
343
+ fileLocation: FileLocationKind.Absolute,
344
+ pattern: this.problemPattern.get('jshint')!,
345
+ });
346
+
347
+ this.add({
348
+ name: 'jshint-stylish',
349
+ label: 'JSHint stylish problems',
350
+ owner: 'jshint',
351
+ source: 'jshint',
352
+ applyTo: ApplyToKind.allDocuments,
353
+ fileLocation: FileLocationKind.Absolute,
354
+ pattern: this.problemPattern.get('jshint-stylish')!,
355
+ });
356
+
357
+ this.add({
358
+ name: 'eslint-compact',
359
+ label: 'ESLint compact problems',
360
+ owner: 'eslint',
361
+ source: 'eslint',
362
+ applyTo: ApplyToKind.allDocuments,
363
+ fileLocation: FileLocationKind.Absolute,
364
+ filePrefix: '${workspaceFolder}',
365
+ pattern: this.problemPattern.get('eslint-compact')!,
366
+ });
367
+
368
+ this.add({
369
+ name: 'eslint-stylish',
370
+ label: 'ESLint stylish problems',
371
+ owner: 'eslint',
372
+ source: 'eslint',
373
+ applyTo: ApplyToKind.allDocuments,
374
+ fileLocation: FileLocationKind.Absolute,
375
+ pattern: this.problemPattern.get('eslint-stylish')!,
376
+ });
377
+
378
+ this.add({
379
+ name: 'go',
380
+ label: 'Go problems',
381
+ owner: 'go',
382
+ source: 'go',
383
+ applyTo: ApplyToKind.allDocuments,
384
+ fileLocation: FileLocationKind.Relative,
385
+ filePrefix: '${workspaceFolder}',
386
+ pattern: this.problemPattern.get('go')!,
387
+ });
388
+ }
389
+ }