@theia/plugin-ext 1.73.0-next.20 → 1.73.0-next.26

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 (57) hide show
  1. package/lib/hosted/node/hosted-plugin-localization-service.d.ts +2 -1
  2. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
  3. package/lib/hosted/node/hosted-plugin-localization-service.js +6 -1
  4. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  5. package/lib/hosted/node/plugin-deployer-handler-impl.js +4 -3
  6. package/lib/hosted/node/plugin-deployer-handler-impl.js.map +1 -1
  7. package/lib/hosted/node/scanners/scanner-theia.d.ts +2 -0
  8. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  9. package/lib/hosted/node/scanners/scanner-theia.js +55 -49
  10. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  11. package/lib/main/browser/debug/debug-main.d.ts +1 -11
  12. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  13. package/lib/main/browser/debug/debug-main.js +3 -24
  14. package/lib/main/browser/debug/debug-main.js.map +1 -1
  15. package/lib/main/browser/debug/plugin-debug-service.d.ts +2 -1
  16. package/lib/main/browser/debug/plugin-debug-service.d.ts.map +1 -1
  17. package/lib/main/browser/debug/plugin-debug-service.js +8 -3
  18. package/lib/main/browser/debug/plugin-debug-service.js.map +1 -1
  19. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +7 -44
  20. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
  21. package/lib/main/browser/debug/plugin-debug-session-factory.js +29 -35
  22. package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
  23. package/lib/main/browser/languages-main.d.ts +2 -0
  24. package/lib/main/browser/languages-main.d.ts.map +1 -1
  25. package/lib/main/browser/languages-main.js +7 -1
  26. package/lib/main/browser/languages-main.js.map +1 -1
  27. package/lib/main/browser/plugin-contribution-handler.d.ts +2 -0
  28. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  29. package/lib/main/browser/plugin-contribution-handler.js +10 -4
  30. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  31. package/lib/main/browser/webview/webview-resource-cache.d.ts +2 -0
  32. package/lib/main/browser/webview/webview-resource-cache.d.ts.map +1 -1
  33. package/lib/main/browser/webview/webview-resource-cache.js +7 -1
  34. package/lib/main/browser/webview/webview-resource-cache.js.map +1 -1
  35. package/lib/main/browser/webview/webview.d.ts +2 -1
  36. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  37. package/lib/main/browser/webview/webview.js +7 -1
  38. package/lib/main/browser/webview/webview.js.map +1 -1
  39. package/lib/main/node/plugin-deployer-impl.js +2 -1
  40. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  41. package/lib/plugin/languages/diagnostics.d.ts +4 -1
  42. package/lib/plugin/languages/diagnostics.d.ts.map +1 -1
  43. package/lib/plugin/languages/diagnostics.js +22 -9
  44. package/lib/plugin/languages/diagnostics.js.map +1 -1
  45. package/package.json +29 -29
  46. package/src/hosted/node/hosted-plugin-localization-service.ts +6 -3
  47. package/src/hosted/node/plugin-deployer-handler-impl.ts +5 -5
  48. package/src/hosted/node/scanners/scanner-theia.ts +54 -50
  49. package/src/main/browser/debug/debug-main.ts +3 -45
  50. package/src/main/browser/debug/plugin-debug-service.ts +7 -5
  51. package/src/main/browser/debug/plugin-debug-session-factory.ts +25 -71
  52. package/src/main/browser/languages-main.ts +6 -2
  53. package/src/main/browser/plugin-contribution-handler.ts +8 -4
  54. package/src/main/browser/webview/webview-resource-cache.ts +6 -2
  55. package/src/main/browser/webview/webview.ts +6 -3
  56. package/src/main/node/plugin-deployer-impl.ts +2 -2
  57. package/src/plugin/languages/diagnostics.ts +28 -10
@@ -26,8 +26,6 @@ import {
26
26
  } from '../../../common/plugin-api-rpc';
27
27
  import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
28
28
  import { Breakpoint, DebugStackFrameDTO, DebugThreadDTO, WorkspaceFolder } from '../../../common/plugin-api-rpc-model';
29
- import { LabelProvider } from '@theia/core/lib/browser';
30
- import { EditorManager } from '@theia/editor/lib/browser';
31
29
  import { BreakpointManager, BreakpointsChangeEvent } from '@theia/debug/lib/browser/breakpoint/breakpoint-manager';
32
30
  import { URI as Uri } from '@theia/core/shared/vscode-uri';
33
31
  import { SourceBreakpoint, FunctionBreakpoint, BaseBreakpoint } from '@theia/debug/lib/browser/breakpoint/breakpoint-marker';
@@ -35,10 +33,6 @@ import { DebugConfiguration, DebugSessionOptions } from '@theia/debug/lib/common
35
33
  import { DebuggerDescription } from '@theia/debug/lib/common/debug-service';
36
34
  import { DebugProtocol } from '@vscode/debugprotocol';
37
35
  import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
38
- import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
39
- import { MessageClient } from '@theia/core/lib/common/message-service-protocol';
40
- import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
41
- import { DebugPreferences } from '@theia/debug/lib/common/debug-preferences';
42
36
  import { PluginDebugAdapterContribution } from './plugin-debug-adapter-contribution';
43
37
  import { PluginDebugConfigurationProvider } from './plugin-debug-configuration-provider';
44
38
  import { PluginDebugSessionContributionRegistrator, PluginDebugSessionContributionRegistry } from './plugin-debug-session-contribution-registry';
@@ -46,17 +40,12 @@ import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposa
46
40
  import { PluginDebugSessionFactory } from './plugin-debug-session-factory';
47
41
  import { PluginDebugService } from './plugin-debug-service';
48
42
  import { HostedPluginSupport } from '../../../hosted/browser/hosted-plugin';
49
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
50
43
  import { ConsoleSessionManager } from '@theia/console/lib/browser/console-session-manager';
51
44
  import { DebugConsoleSession } from '@theia/debug/lib/browser/console/debug-console-session';
52
- import { CommandService, ContributionProvider } from '@theia/core/lib/common';
53
- import { DebugContribution } from '@theia/debug/lib/browser/debug-contribution';
54
45
  import { ConnectionImpl } from '../../../common/connection';
55
- import { WorkspaceService } from '@theia/workspace/lib/browser';
56
46
  import { DebugSessionOptions as TheiaDebugSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
57
47
  import { DebugStackFrame } from '@theia/debug/lib/browser/model/debug-stack-frame';
58
48
  import { DebugThread } from '@theia/debug/lib/browser/model/debug-thread';
59
- import { TestService } from '@theia/test/lib/browser/test-service';
60
49
  import { DebugBreakpoint } from '@theia/debug/lib/browser/model/debug-breakpoint';
61
50
 
62
51
  function toOrigin<T extends BaseBreakpoint>(input: DebugBreakpoint<T>): T {
@@ -75,24 +64,14 @@ function eventToOrigins<T extends BaseBreakpoint>({ added, removed, changed, uri
75
64
  export class DebugMainImpl implements DebugMain, Disposable {
76
65
  private readonly debugExt: DebugExt;
77
66
 
67
+ private readonly container: interfaces.Container;
78
68
  private readonly sessionManager: DebugSessionManager;
79
- private readonly labelProvider: LabelProvider;
80
- private readonly editorManager: EditorManager;
81
69
  private readonly breakpointsManager: BreakpointManager;
82
70
  private readonly consoleSessionManager: ConsoleSessionManager;
83
71
  private readonly configurationManager: DebugConfigurationManager;
84
- private readonly terminalService: TerminalService;
85
- private readonly messages: MessageClient;
86
- private readonly outputChannelManager: OutputChannelManager;
87
- private readonly debugPreferences: DebugPreferences;
88
72
  private readonly sessionContributionRegistrator: PluginDebugSessionContributionRegistrator;
89
73
  private readonly pluginDebugService: PluginDebugService;
90
- private readonly fileService: FileService;
91
74
  private readonly pluginService: HostedPluginSupport;
92
- private readonly debugContributionProvider: ContributionProvider<DebugContribution>;
93
- private readonly testService: TestService;
94
- private readonly workspaceService: WorkspaceService;
95
- private readonly commandService: CommandService;
96
75
 
97
76
  private readonly debuggerContributions = new Map<string, DisposableCollection>();
98
77
  private readonly configurationProviders = new Map<number, DisposableCollection>();
@@ -100,24 +79,14 @@ export class DebugMainImpl implements DebugMain, Disposable {
100
79
 
101
80
  constructor(rpc: RPCProtocol, readonly connectionMain: ConnectionImpl, container: interfaces.Container) {
102
81
  this.debugExt = rpc.getProxy(MAIN_RPC_CONTEXT.DEBUG_EXT);
82
+ this.container = container;
103
83
  this.sessionManager = container.get(DebugSessionManager);
104
- this.labelProvider = container.get(LabelProvider);
105
- this.editorManager = container.get(EditorManager);
106
84
  this.breakpointsManager = container.get(BreakpointManager);
107
85
  this.consoleSessionManager = container.get(ConsoleSessionManager);
108
86
  this.configurationManager = container.get(DebugConfigurationManager);
109
- this.terminalService = container.get(TerminalService);
110
- this.messages = container.get(MessageClient);
111
- this.outputChannelManager = container.get(OutputChannelManager);
112
- this.debugPreferences = container.get(DebugPreferences);
113
87
  this.pluginDebugService = container.get(PluginDebugService);
114
88
  this.sessionContributionRegistrator = container.get(PluginDebugSessionContributionRegistry);
115
- this.debugContributionProvider = container.getNamed(ContributionProvider, DebugContribution);
116
- this.fileService = container.get(FileService);
117
89
  this.pluginService = container.get(HostedPluginSupport);
118
- this.testService = container.get(TestService);
119
- this.workspaceService = container.get(WorkspaceService);
120
- this.commandService = container.get(CommandService);
121
90
 
122
91
  const fireDidChangeBreakpoints = ({ added, removed, changed }: BreakpointsChangeEvent<SourceBreakpoint | FunctionBreakpoint>) => {
123
92
  this.debugExt.$breakpointsDidChange(
@@ -168,23 +137,12 @@ export class DebugMainImpl implements DebugMain, Disposable {
168
137
  }
169
138
 
170
139
  const debugSessionFactory = new PluginDebugSessionFactory(
171
- this.terminalService,
172
- this.editorManager,
173
- this.breakpointsManager,
174
- this.labelProvider,
175
- this.messages,
176
- this.outputChannelManager,
177
- this.debugPreferences,
178
140
  async (sessionId: string) => {
179
141
  const connection = await this.connectionMain.ensureConnection(sessionId);
180
142
  return connection;
181
143
  },
182
- this.fileService,
183
144
  terminalOptionsExt,
184
- this.debugContributionProvider,
185
- this.testService,
186
- this.workspaceService,
187
- this.commandService,
145
+ this.container,
188
146
  );
189
147
 
190
148
  const toDispose = new DisposableCollection(
@@ -16,13 +16,13 @@
16
16
 
17
17
  import { DebuggerDescription, DebugPath, DebugService, DynamicDebugConfigurationProvider } from '@theia/debug/lib/common/debug-service';
18
18
  import debounce = require('@theia/core/shared/lodash.debounce');
19
- import { deepClone, Emitter, Event, nls } from '@theia/core';
19
+ import { deepClone, Emitter, Event, nls, ILogger } from '@theia/core';
20
20
  import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
21
21
  import { DebugConfiguration } from '@theia/debug/lib/common/debug-configuration';
22
22
  import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-schema';
23
23
  import { PluginDebugAdapterContribution } from './plugin-debug-adapter-contribution';
24
24
  import { PluginDebugConfigurationProvider } from './plugin-debug-configuration-provider';
25
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
25
+ import { injectable, inject, postConstruct, named } from '@theia/core/shared/inversify';
26
26
  import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
27
27
  import { WorkspaceService } from '@theia/workspace/lib/browser';
28
28
  import { CommandIdVariables } from '@theia/variable-resolver/lib/common/variable-types';
@@ -64,6 +64,8 @@ export class PluginDebugService implements DebugService {
64
64
  protected readonly connectionProvider: WebSocketConnectionProvider;
65
65
  @inject(WorkspaceService)
66
66
  protected readonly workspaceService: WorkspaceService;
67
+ @inject(ILogger) @named('plugin-ext:PluginDebugService')
68
+ protected readonly logger: ILogger;
67
69
 
68
70
  @postConstruct()
69
71
  protected init(): void {
@@ -84,7 +86,7 @@ export class PluginDebugService implements DebugService {
84
86
  const { type } = contrib;
85
87
 
86
88
  if (this.contributors.has(type)) {
87
- console.warn(`Debugger with type '${type}' already registered.`);
89
+ this.logger.warn(`Debugger with type '${type}' already registered.`);
88
90
  return Disposable.NULL;
89
91
  }
90
92
 
@@ -105,7 +107,7 @@ export class PluginDebugService implements DebugService {
105
107
  if (this.configurationProviders.has(provider.handle)) {
106
108
  const configuration = this.configurationProviders.get(provider.handle);
107
109
  if (configuration && configuration.type !== provider.type) {
108
- console.warn(`Different debug configuration provider with type '${configuration.type}' already registered.`);
110
+ this.logger.warn(`Different debug configuration provider with type '${configuration.type}' already registered.`);
109
111
  provider.handle = this.configurationProviders.size;
110
112
  }
111
113
  }
@@ -358,7 +360,7 @@ export class PluginDebugService implements DebugService {
358
360
  }
359
361
  resolved = await resolver(workspaceFolderUri, resolved);
360
362
  } catch (e) {
361
- console.error(e);
363
+ this.logger.error(e);
362
364
  }
363
365
  }
364
366
  return resolved;
@@ -14,53 +14,32 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+ import { injectable, inject, interfaces } from '@theia/core/shared/inversify';
17
18
  import { DefaultDebugSessionFactory } from '@theia/debug/lib/browser/debug-session-contribution';
18
- import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
19
- import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
20
- import { BreakpointManager } from '@theia/debug/lib/browser/breakpoint/breakpoint-manager';
21
- import { LabelProvider } from '@theia/core/lib/browser/label-provider';
22
- import { MessageClient } from '@theia/core/lib/common/message-service-protocol';
23
- import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
24
- import { DebugPreferences } from '@theia/debug/lib/common/debug-preferences';
25
- import { DebugConfigurationSessionOptions, TestRunReference } from '@theia/debug/lib/browser/debug-session-options';
26
- import { DebugSession } from '@theia/debug/lib/browser/debug-session';
19
+ import { DebugConfigurationSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
20
+ import { DebugSession, DebugSessionData } from '@theia/debug/lib/browser/debug-session';
27
21
  import { DebugSessionConnection } from '@theia/debug/lib/browser/debug-session-connection';
28
22
  import { TerminalWidgetOptions, TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
29
23
  import { TerminalOptionsExt } from '../../../common/plugin-api-rpc';
30
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
31
- import { DebugContribution } from '@theia/debug/lib/browser/debug-contribution';
32
- import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
33
- import { WorkspaceService } from '@theia/workspace/lib/browser';
34
24
  import { PluginChannel } from '../../../common/connection';
35
- import { TestService } from '@theia/test/lib/browser/test-service';
36
- import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
37
- import { CommandService } from '@theia/core';
38
25
 
26
+ export const PluginTerminalOptionsExt = Symbol('PluginTerminalOptionsExt');
27
+
28
+ @injectable()
39
29
  export class PluginDebugSession extends DebugSession {
40
- constructor(
41
- override readonly id: string,
42
- override readonly options: DebugConfigurationSessionOptions,
43
- override readonly parentSession: DebugSession | undefined,
44
- testService: TestService,
45
- testRun: TestRunReference | undefined,
46
- sessionManager: DebugSessionManager,
47
- protected override readonly connection: DebugSessionConnection,
48
- protected override readonly terminalServer: TerminalService,
49
- protected override readonly editorManager: EditorManager,
50
- protected override readonly breakpoints: BreakpointManager,
51
- protected override readonly labelProvider: LabelProvider,
52
- protected override readonly messages: MessageClient,
53
- protected override readonly fileService: FileService,
54
- protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
55
- protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
56
- protected override readonly workspaceService: WorkspaceService,
57
- debugPreferences: DebugPreferences,
58
- protected override readonly commandService: CommandService) {
59
- super(id, options, parentSession, testService, testRun, sessionManager, connection, terminalServer, editorManager, breakpoints,
60
- labelProvider, messages, fileService, debugContributionProvider,
61
- workspaceService, debugPreferences, commandService);
30
+
31
+ static override createContainer(
32
+ parent: interfaces.Container, data: DebugSessionData, connection: DebugSessionConnection, terminalOptionsExt?: TerminalOptionsExt
33
+ ): interfaces.Container {
34
+ const child = DebugSession.createContainer(parent, data, connection);
35
+ child.rebind(DebugSession).to(PluginDebugSession);
36
+ child.bind(PluginTerminalOptionsExt).toConstantValue(terminalOptionsExt);
37
+ return child;
62
38
  }
63
39
 
40
+ @inject(PluginTerminalOptionsExt)
41
+ protected readonly terminalOptionsExt: TerminalOptionsExt | undefined;
42
+
64
43
  protected override async doCreateTerminal(terminalWidgetOptions: TerminalWidgetOptions): Promise<TerminalWidget> {
65
44
  terminalWidgetOptions = Object.assign({}, terminalWidgetOptions, this.terminalOptionsExt);
66
45
  return super.doCreateTerminal(terminalWidgetOptions);
@@ -73,49 +52,24 @@ export class PluginDebugSession extends DebugSession {
73
52
  */
74
53
  export class PluginDebugSessionFactory extends DefaultDebugSessionFactory {
75
54
  constructor(
76
- protected override readonly terminalService: TerminalService,
77
- protected override readonly editorManager: EditorManager,
78
- protected override readonly breakpoints: BreakpointManager,
79
- protected override readonly labelProvider: LabelProvider,
80
- protected override readonly messages: MessageClient,
81
- protected override readonly outputChannelManager: OutputChannelManager,
82
- protected override readonly debugPreferences: DebugPreferences,
83
55
  protected readonly connectionFactory: (sessionId: string) => Promise<PluginChannel>,
84
- protected override readonly fileService: FileService,
85
56
  protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
86
- protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
87
- protected override readonly testService: TestService,
88
- protected override readonly workspaceService: WorkspaceService,
89
- protected override readonly commandService: CommandService,
57
+ container: interfaces.Container,
90
58
  ) {
91
- super();
59
+ super(container);
92
60
  }
93
61
 
94
- override get(manager: DebugSessionManager, sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
62
+ override createSession(sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
95
63
  const connection = new DebugSessionConnection(
96
64
  sessionId,
97
65
  this.connectionFactory,
98
66
  this.getTraceOutputChannel());
99
-
100
- return new PluginDebugSession(
101
- sessionId,
67
+ const data: DebugSessionData = {
68
+ id: sessionId,
102
69
  options,
103
70
  parentSession,
104
- this.testService,
105
- options.testRun,
106
- manager,
107
- connection,
108
- this.terminalService,
109
- this.editorManager,
110
- this.breakpoints,
111
- this.labelProvider,
112
- this.messages,
113
- this.fileService,
114
- this.terminalOptionsExt,
115
- this.debugContributionProvider,
116
- this.workspaceService,
117
- this.debugPreferences,
118
- this.commandService
119
- );
71
+ };
72
+ const child = PluginDebugSession.createContainer(this.container, data, connection, this.terminalOptionsExt);
73
+ return child.get(DebugSession);
120
74
  }
121
75
  }
@@ -39,7 +39,7 @@ import {
39
39
  IdentifiableInlineCompletions,
40
40
  HoverWithId
41
41
  } from '../../common/plugin-api-rpc';
42
- import { injectable, inject } from '@theia/core/shared/inversify';
42
+ import { injectable, inject, named } from '@theia/core/shared/inversify';
43
43
  import {
44
44
  SerializedDocumentFilter, MarkerData, Range, RelatedInformation,
45
45
  MarkerSeverity, DocumentLink, WorkspaceSymbolParams, CodeAction, CompletionDto,
@@ -86,6 +86,7 @@ import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model
86
86
  import { CodeActionTriggerKind } from '../../plugin/types-impl';
87
87
  import { IReadonlyVSDataTransfer } from '@theia/monaco-editor-core/esm/vs/base/common/dataTransfer';
88
88
  import { FileUploadService } from '@theia/filesystem/lib/common/upload/file-upload';
89
+ import { ILogger } from '@theia/core';
89
90
 
90
91
  @injectable()
91
92
  export class LanguagesMainImpl implements LanguagesMain, Disposable {
@@ -108,6 +109,9 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
108
109
  @inject(FileUploadService)
109
110
  protected readonly fileUploadService: FileUploadService;
110
111
 
112
+ @inject(ILogger) @named('plugin-ext:LanguagesMainImpl')
113
+ protected readonly logger: ILogger;
114
+
111
115
  private readonly proxy: LanguagesExt;
112
116
  private readonly services = new Map<number, Disposable>();
113
117
  private readonly toDispose = new DisposableCollection();
@@ -958,7 +962,7 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
958
962
  dispose: () => this.proxy.$releaseCodeActions(handle, actions.map(a => a.cacheId))
959
963
  };
960
964
  } catch (e) {
961
- console.error(e);
965
+ this.logger.error(e);
962
966
  return undefined;
963
967
  }
964
968
  }
@@ -52,6 +52,7 @@ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
52
52
  import { LanguageService } from '@theia/core/lib/browser/language-service';
53
53
  import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/base/common/themables';
54
54
  import { JSONObject, JSONValue } from '@theia/core/shared/@lumino/coreutils';
55
+ import { ILogger } from '@theia/core';
55
56
 
56
57
  // The enum export is missing from `vscode-textmate@9.2.0`
57
58
  const enum StandardTokenType {
@@ -147,6 +148,9 @@ export class PluginContributionHandler {
147
148
  @inject(ContextKeyService)
148
149
  protected readonly contextKeyService: ContextKeyService;
149
150
 
151
+ @inject(ILogger) @named('plugin-ext:PluginContributionHandler')
152
+ protected readonly logger: ILogger;
153
+
150
154
  protected readonly commandHandlers = new Map<string, CommandHandler['execute'] | undefined>();
151
155
 
152
156
  protected readonly onDidRegisterCommandHandlerEmitter = new Emitter<string>();
@@ -164,8 +168,8 @@ export class PluginContributionHandler {
164
168
  }
165
169
  const toDispose = new DisposableCollection(Disposable.create(() => { /* mark as not disposed */ }));
166
170
  /* eslint-disable @typescript-eslint/no-explicit-any */
167
- const logError = (message: string, ...args: any[]) => console.error(`[${clientId}][${plugin.metadata.model.id}]: ${message}`, ...args);
168
- const logWarning = (message: string, ...args: any[]) => console.warn(`[${clientId}][${plugin.metadata.model.id}]: ${message}`, ...args);
171
+ const logError = (message: string, ...args: any[]) => this.logger.error(`[${clientId}][${plugin.metadata.model.id}]: ${message}`, ...args);
172
+ const logWarning = (message: string, ...args: any[]) => this.logger.warn(`[${clientId}][${plugin.metadata.model.id}]: ${message}`, ...args);
169
173
  const pushContribution = (id: string, contribute: () => Disposable) => {
170
174
  if (toDispose.disposed) {
171
175
  return;
@@ -517,7 +521,7 @@ export class PluginContributionHandler {
517
521
 
518
522
  registerCommand(command: Command, enablement?: string): Disposable {
519
523
  if (this.hasCommand(command.id)) {
520
- console.warn(`command '${command.id}' already registered`);
524
+ this.logger.warn(`command '${command.id}' already registered`);
521
525
  return Disposable.NULL;
522
526
  }
523
527
 
@@ -565,7 +569,7 @@ export class PluginContributionHandler {
565
569
 
566
570
  registerCommandHandler(id: string, execute: CommandHandler['execute']): Disposable {
567
571
  if (this.hasCommandHandler(id)) {
568
- console.warn(`command handler '${id}' already registered`);
572
+ this.logger.warn(`command handler '${id}' already registered`);
569
573
  return Disposable.NULL;
570
574
  }
571
575
 
@@ -14,9 +14,10 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { injectable } from '@theia/core/shared/inversify';
17
+ import { injectable, inject, named } from '@theia/core/shared/inversify';
18
18
  import { Deferred } from '@theia/core/lib/common/promise-util';
19
19
  import { MaybePromise } from '@theia/core/lib/common/types';
20
+ import { ILogger } from '@theia/core';
20
21
 
21
22
  export interface WebviewResourceResponse {
22
23
  eTag: string | undefined,
@@ -29,6 +30,9 @@ export interface WebviewResourceResponse {
29
30
  @injectable()
30
31
  export class WebviewResourceCache {
31
32
 
33
+ @inject(ILogger) @named('plugin-ext:WebviewResourceCache')
34
+ protected readonly logger: ILogger;
35
+
32
36
  protected readonly cache = new Deferred<Cache | undefined>();
33
37
 
34
38
  constructor() {
@@ -39,7 +43,7 @@ export class WebviewResourceCache {
39
43
  try {
40
44
  this.cache.resolve(await caches.open('webview:v1'));
41
45
  } catch (e) {
42
- console.error('Failed to enable webview caching: ', e);
46
+ this.logger.error('Failed to enable webview caching: ', e);
43
47
  this.cache.resolve(undefined);
44
48
  }
45
49
  }
@@ -22,7 +22,7 @@
22
22
 
23
23
  import * as mime from 'mime';
24
24
  import { JSONExt } from '@theia/core/shared/@lumino/coreutils';
25
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
25
+ import { injectable, inject, postConstruct, named } from '@theia/core/shared/inversify';
26
26
  import { WebviewPanelOptions, WebviewPortMapping } from '@theia/plugin';
27
27
  import { BaseWidget, Message, codicon } from '@theia/core/lib/browser/widgets/widget';
28
28
  import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
@@ -49,7 +49,7 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service';
49
49
  import { FileOperationError, FileOperationResult } from '@theia/filesystem/lib/common/files';
50
50
  import { BinaryBufferReadableStream } from '@theia/core/lib/common/buffer';
51
51
  import { ExtractableWidget } from '@theia/core/lib/browser/widgets/extractable-widget';
52
- import { MenuPath } from '@theia/core';
52
+ import { MenuPath, ILogger } from '@theia/core';
53
53
  import { ContextMenuRenderer } from '@theia/core/lib/browser';
54
54
  import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
55
55
  import { PluginViewWidget } from '../view/plugin-view-widget';
@@ -166,6 +166,9 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget, Extract
166
166
  @inject(ContextKeyService)
167
167
  protected readonly contextKeyService: ContextKeyService;
168
168
 
169
+ @inject(ILogger) @named('plugin-ext:WebviewWidget')
170
+ protected readonly logger: ILogger;
171
+
169
172
  viewState: WebviewPanelViewState = {
170
173
  visible: false,
171
174
  active: false,
@@ -626,7 +629,7 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget, Extract
626
629
  await this.ready.promise;
627
630
  this.postMessage(channel, data);
628
631
  } catch (e) {
629
- console.error(e);
632
+ this.logger.error(e);
630
633
  }
631
634
  }
632
635
 
@@ -42,7 +42,7 @@ export class PluginDeployerImpl implements PluginDeployer {
42
42
  protected readonly onDidDeployEmitter = new Emitter<void>();
43
43
  readonly onDidDeploy = this.onDidDeployEmitter.event;
44
44
 
45
- @inject(ILogger)
45
+ @inject(ILogger) @named('plugin-ext:PluginDeployerImpl')
46
46
  protected readonly logger: ILogger;
47
47
 
48
48
  @inject(PluginDeployerHandler)
@@ -215,7 +215,7 @@ export class PluginDeployerImpl implements PluginDeployer {
215
215
  }
216
216
  }
217
217
  } catch (e) {
218
- console.error(`Failed to resolve plugins from '${entry.id}'`, e);
218
+ this.logger.error(`Failed to resolve plugins from '${entry.id}'`, e);
219
219
  errors.push(e instanceof Error ? e : new Error(String(e)));
220
220
  }
221
221
  }));
@@ -30,6 +30,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
30
30
  ];
31
31
 
32
32
  private collectionName: string;
33
+ private ownerId: string;
33
34
  private diagnosticsLimitPerResource: number;
34
35
  private proxy: LanguagesMain;
35
36
  private onDidChangeDiagnosticsEmitter: Emitter<theia.DiagnosticChangeEvent>;
@@ -38,8 +39,9 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
38
39
  private isDisposed: boolean;
39
40
  private onDisposeCallback: (() => void) | undefined;
40
41
 
41
- constructor(name: string, maxCountPerFile: number, proxy: LanguagesMain, onDidChangeDiagnosticsEmitter: Emitter<theia.DiagnosticChangeEvent>) {
42
+ constructor(name: string, owner: string, maxCountPerFile: number, proxy: LanguagesMain, onDidChangeDiagnosticsEmitter: Emitter<theia.DiagnosticChangeEvent>) {
42
43
  this.collectionName = name;
44
+ this.ownerId = owner;
43
45
  this.diagnosticsLimitPerResource = maxCountPerFile;
44
46
  this.proxy = proxy;
45
47
  this.onDidChangeDiagnosticsEmitter = onDidChangeDiagnosticsEmitter;
@@ -53,6 +55,10 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
53
55
  return this.collectionName;
54
56
  }
55
57
 
58
+ get owner(): string {
59
+ return this.ownerId;
60
+ }
61
+
56
62
  set(uri: theia.Uri, diagnostics: theia.Diagnostic[] | undefined): void;
57
63
  set(entries: [theia.Uri, theia.Diagnostic[] | undefined][]): void;
58
64
  set(arg: theia.Uri | [theia.Uri, theia.Diagnostic[] | undefined][], diagnostics?: theia.Diagnostic[] | undefined): void {
@@ -115,7 +121,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
115
121
  if (this.has(uri)) {
116
122
  this.fireDiagnosticChangeEvent(uri);
117
123
  this.diagnostics.delete(uri.toString());
118
- this.proxy.$changeDiagnostics(this.name, [[uri.toString(), []]]);
124
+ this.proxy.$changeDiagnostics(this.ownerId, [[uri.toString(), []]]);
119
125
  }
120
126
  }
121
127
 
@@ -123,7 +129,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
123
129
  this.ensureNotDisposed();
124
130
  this.fireDiagnosticChangeEvent(this.getAllResourcesUris());
125
131
  this.diagnostics.clear();
126
- this.proxy.$clearDiagnostics(this.name);
132
+ this.proxy.$clearDiagnostics(this.ownerId);
127
133
  }
128
134
 
129
135
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -247,7 +253,7 @@ export class DiagnosticCollection implements theia.DiagnosticCollection {
247
253
  }
248
254
  }
249
255
 
250
- this.proxy.$changeDiagnostics(this.name, markers);
256
+ this.proxy.$changeDiagnostics(this.ownerId, markers);
251
257
  }
252
258
  }
253
259
 
@@ -256,7 +262,12 @@ export class Diagnostics {
256
262
  private static GENERATED_DIAGNOSTIC_COLLECTION_NAME_PREFIX = '_generated_diagnostic_collection_name_#';
257
263
 
258
264
  private proxy: LanguagesMain;
259
- private diagnosticCollections: Map<string, DiagnosticCollection>; // id -> diagnostic collection
265
+ // Collections are keyed by their unique `owner` id (which is the same as `name` for the first
266
+ // collection with that name, but is suffixed when a duplicate name is requested). This matches
267
+ // VS Code's behavior and prevents collisions on the main side's marker owner namespace as well
268
+ // as a latent bug where disposing the first collection would evict the second from the map.
269
+ private diagnosticCollections: Map<string, DiagnosticCollection>;
270
+ private nextOwnerSuffix = 1;
260
271
 
261
272
  private diagnosticsChangedEmitter = new Emitter<theia.DiagnosticChangeEvent>();
262
273
  public readonly onDidChangeDiagnostics: Event<theia.DiagnosticChangeEvent> = this.diagnosticsChangedEmitter.event;
@@ -278,19 +289,26 @@ export class Diagnostics {
278
289
  }
279
290
 
280
291
  createDiagnosticCollection(name?: string): theia.DiagnosticCollection {
292
+ let owner: string;
281
293
  if (!name) {
282
294
  do {
283
295
  name = Diagnostics.GENERATED_DIAGNOSTIC_COLLECTION_NAME_PREFIX + this.getNextId();
284
296
  } while (this.diagnosticCollections.has(name));
285
- } else if (this.diagnosticCollections.has(name)) {
286
- console.warn(`Diagnostic collection with name '${name}' already exist.`);
297
+ owner = name;
298
+ } else if (!this.diagnosticCollections.has(name)) {
299
+ owner = name;
300
+ } else {
301
+ console.warn(`Diagnostic collection with name '${name}' already exists.`);
302
+ do {
303
+ owner = name + this.nextOwnerSuffix++;
304
+ } while (this.diagnosticCollections.has(owner));
287
305
  }
288
306
 
289
- const diagnosticCollection = new DiagnosticCollection(name, Diagnostics.MAX_DIAGNOSTICS_PER_FILE, this.proxy, this.diagnosticsChangedEmitter);
307
+ const diagnosticCollection = new DiagnosticCollection(name, owner, Diagnostics.MAX_DIAGNOSTICS_PER_FILE, this.proxy, this.diagnosticsChangedEmitter);
290
308
  diagnosticCollection.setOnDisposeCallback(() => {
291
- this.diagnosticCollections.delete(name!);
309
+ this.diagnosticCollections.delete(owner);
292
310
  });
293
- this.diagnosticCollections.set(name, diagnosticCollection);
311
+ this.diagnosticCollections.set(owner, diagnosticCollection);
294
312
  return diagnosticCollection;
295
313
  }
296
314