@theia/plugin-ext 1.25.0-next.7 → 1.25.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 (133) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +3 -15
  2. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  4. package/lib/common/plugin-api-rpc.d.ts +15 -22
  5. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  6. package/lib/common/plugin-api-rpc.js +2 -0
  7. package/lib/common/plugin-api-rpc.js.map +1 -1
  8. package/lib/common/uri-components.d.ts +2 -9
  9. package/lib/common/uri-components.d.ts.map +1 -1
  10. package/lib/common/uri-components.js +1 -7
  11. package/lib/common/uri-components.js.map +1 -1
  12. package/lib/hosted/node/hosted-plugin-localization-service.js +17 -2
  13. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  14. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.d.ts +9 -9
  15. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.d.ts.map +1 -1
  16. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.js +70 -89
  17. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.js.map +1 -1
  18. package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
  19. package/lib/main/browser/comments/comment-thread-widget.js +8 -2
  20. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  21. package/lib/main/browser/comments/comments-main.d.ts +5 -0
  22. package/lib/main/browser/comments/comments-main.d.ts.map +1 -1
  23. package/lib/main/browser/comments/comments-main.js +14 -0
  24. package/lib/main/browser/comments/comments-main.js.map +1 -1
  25. package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts +0 -12
  26. package/lib/main/browser/debug/plugin-debug-adapter-contribution.d.ts.map +1 -1
  27. package/lib/main/browser/debug/plugin-debug-adapter-contribution.js +0 -18
  28. package/lib/main/browser/debug/plugin-debug-adapter-contribution.js.map +1 -1
  29. package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts +2 -2
  30. package/lib/main/browser/debug/plugin-debug-configuration-provider.d.ts.map +1 -1
  31. package/lib/main/browser/debug/plugin-debug-configuration-provider.js.map +1 -1
  32. package/lib/main/browser/debug/plugin-debug-service.d.ts +3 -2
  33. package/lib/main/browser/debug/plugin-debug-service.d.ts.map +1 -1
  34. package/lib/main/browser/debug/plugin-debug-service.js +28 -29
  35. package/lib/main/browser/debug/plugin-debug-service.js.map +1 -1
  36. package/lib/main/browser/languages-main.d.ts.map +1 -1
  37. package/lib/main/browser/languages-main.js +7 -1
  38. package/lib/main/browser/languages-main.js.map +1 -1
  39. package/lib/main/browser/main-context.d.ts.map +1 -1
  40. package/lib/main/browser/main-context.js +3 -0
  41. package/lib/main/browser/main-context.js.map +1 -1
  42. package/lib/main/browser/notification-main.d.ts +2 -1
  43. package/lib/main/browser/notification-main.d.ts.map +1 -1
  44. package/lib/main/browser/notification-main.js +12 -4
  45. package/lib/main/browser/notification-main.js.map +1 -1
  46. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  47. package/lib/main/browser/plugin-ext-frontend-module.js +3 -0
  48. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  49. package/lib/main/browser/status-bar-message-registry-main.d.ts +1 -1
  50. package/lib/main/browser/status-bar-message-registry-main.d.ts.map +1 -1
  51. package/lib/main/browser/status-bar-message-registry-main.js +4 -1
  52. package/lib/main/browser/status-bar-message-registry-main.js.map +1 -1
  53. package/lib/main/browser/view/tree-view-decorator-service.d.ts +33 -0
  54. package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -0
  55. package/lib/main/browser/view/tree-view-decorator-service.js +70 -0
  56. package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -0
  57. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  58. package/lib/main/browser/view/tree-view-widget.js +5 -1
  59. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  60. package/lib/plugin/comments.d.ts +3 -0
  61. package/lib/plugin/comments.d.ts.map +1 -1
  62. package/lib/plugin/comments.js +12 -0
  63. package/lib/plugin/comments.js.map +1 -1
  64. package/lib/plugin/languages/call-hierarchy.d.ts +8 -7
  65. package/lib/plugin/languages/call-hierarchy.d.ts.map +1 -1
  66. package/lib/plugin/languages/call-hierarchy.js +39 -31
  67. package/lib/plugin/languages/call-hierarchy.js.map +1 -1
  68. package/lib/plugin/languages/lens.js.map +1 -1
  69. package/lib/plugin/languages.d.ts +5 -4
  70. package/lib/plugin/languages.d.ts.map +1 -1
  71. package/lib/plugin/languages.js +3 -0
  72. package/lib/plugin/languages.js.map +1 -1
  73. package/lib/plugin/node/debug/debug.d.ts +2 -5
  74. package/lib/plugin/node/debug/debug.d.ts.map +1 -1
  75. package/lib/plugin/node/debug/debug.js +1 -60
  76. package/lib/plugin/node/debug/debug.js.map +1 -1
  77. package/lib/plugin/notification.d.ts +2 -0
  78. package/lib/plugin/notification.d.ts.map +1 -1
  79. package/lib/plugin/notification.js +14 -2
  80. package/lib/plugin/notification.js.map +1 -1
  81. package/lib/plugin/quick-open.d.ts +0 -1
  82. package/lib/plugin/quick-open.d.ts.map +1 -1
  83. package/lib/plugin/quick-open.js +1 -30
  84. package/lib/plugin/quick-open.js.map +1 -1
  85. package/lib/plugin/status-bar/status-bar-item.d.ts +10 -2
  86. package/lib/plugin/status-bar/status-bar-item.d.ts.map +1 -1
  87. package/lib/plugin/status-bar/status-bar-item.js +31 -1
  88. package/lib/plugin/status-bar/status-bar-item.js.map +1 -1
  89. package/lib/plugin/tree/tree-views.d.ts.map +1 -1
  90. package/lib/plugin/tree/tree-views.js +2 -1
  91. package/lib/plugin/tree/tree-views.js.map +1 -1
  92. package/lib/plugin/type-converters.d.ts +1 -1
  93. package/lib/plugin/type-converters.d.ts.map +1 -1
  94. package/lib/plugin/type-converters.js +10 -6
  95. package/lib/plugin/type-converters.js.map +1 -1
  96. package/lib/plugin/type-converters.spec.js +16 -1
  97. package/lib/plugin/type-converters.spec.js.map +1 -1
  98. package/lib/plugin/types-impl.d.ts +1 -2
  99. package/lib/plugin/types-impl.d.ts.map +1 -1
  100. package/lib/plugin/types-impl.js.map +1 -1
  101. package/lib/plugin/workspace.d.ts +1 -1
  102. package/lib/plugin/workspace.d.ts.map +1 -1
  103. package/package.json +24 -24
  104. package/src/common/plugin-api-rpc-model.ts +3 -17
  105. package/src/common/plugin-api-rpc.ts +32 -26
  106. package/src/common/uri-components.ts +4 -17
  107. package/src/hosted/node/hosted-plugin-localization-service.ts +23 -2
  108. package/src/main/browser/callhierarchy/callhierarchy-type-converters.ts +85 -97
  109. package/src/main/browser/comments/comment-thread-widget.tsx +8 -2
  110. package/src/main/browser/comments/comments-main.ts +15 -0
  111. package/src/main/browser/debug/plugin-debug-adapter-contribution.ts +0 -21
  112. package/src/main/browser/debug/plugin-debug-configuration-provider.ts +8 -2
  113. package/src/main/browser/debug/plugin-debug-service.ts +53 -31
  114. package/src/main/browser/languages-main.ts +8 -4
  115. package/src/main/browser/main-context.ts +4 -0
  116. package/src/main/browser/notification-main.ts +13 -4
  117. package/src/main/browser/plugin-ext-frontend-module.ts +3 -0
  118. package/src/main/browser/status-bar-message-registry-main.ts +5 -0
  119. package/src/main/browser/view/tree-view-decorator-service.ts +52 -0
  120. package/src/main/browser/view/tree-view-widget.tsx +4 -1
  121. package/src/plugin/comments.ts +16 -1
  122. package/src/plugin/languages/call-hierarchy.ts +44 -50
  123. package/src/plugin/languages/lens.ts +1 -1
  124. package/src/plugin/languages.ts +11 -6
  125. package/src/plugin/node/debug/debug.ts +22 -78
  126. package/src/plugin/notification.ts +18 -2
  127. package/src/plugin/quick-open.ts +1 -33
  128. package/src/plugin/status-bar/status-bar-item.ts +46 -5
  129. package/src/plugin/tree/tree-views.ts +2 -1
  130. package/src/plugin/type-converters.spec.ts +20 -1
  131. package/src/plugin/type-converters.ts +13 -7
  132. package/src/plugin/types-impl.ts +1 -2
  133. package/src/plugin/workspace.ts +1 -1
@@ -0,0 +1,52 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 1C-Soft LLC 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
+
17
+ import { inject, injectable, interfaces, named } from '@theia/core/shared/inversify';
18
+ import { AbstractTreeDecoratorService, TreeDecorator } from '@theia/core/lib/browser/tree/tree-decorator';
19
+ import { bindContributionProvider, ContributionProvider } from '@theia/core';
20
+ import { TreeNode } from '@theia/core/lib/browser';
21
+ import { TreeItem, Uri } from '@theia/plugin';
22
+ import URI from '@theia/core/lib/common/uri';
23
+ import { FileTreeDecoratorAdapter } from '@theia/filesystem/lib/browser';
24
+
25
+ export const TreeViewDecorator = Symbol('TreeViewDecorator');
26
+
27
+ @injectable()
28
+ export class TreeViewDecoratorAdapter extends FileTreeDecoratorAdapter {
29
+ protected override getUriForNode(node: TreeNode | TreeItem): string | undefined {
30
+ if (this.isTreeItem(node)) {
31
+ return new URI(node.resourceUri).toString();
32
+ }
33
+ }
34
+
35
+ protected isTreeItem(node: object | undefined): node is TreeItem & { resourceUri: Uri } {
36
+ const candidate = node as TreeItem;
37
+ return !!candidate && 'resourceUri' in candidate && !!candidate.resourceUri;
38
+ }
39
+ }
40
+
41
+ @injectable()
42
+ export class TreeViewDecoratorService extends AbstractTreeDecoratorService {
43
+ constructor(@inject(ContributionProvider) @named(TreeViewDecorator) contributions: ContributionProvider<TreeDecorator>) {
44
+ super(contributions.getContributions());
45
+ }
46
+ }
47
+
48
+ export function bindTreeViewDecoratorUtilities(bind: interfaces.Bind): void {
49
+ bind(TreeViewDecoratorAdapter).toSelf().inSingletonScope();
50
+ bindContributionProvider(bind, TreeViewDecorator);
51
+ bind(TreeViewDecorator).toService(TreeViewDecoratorAdapter);
52
+ }
@@ -355,8 +355,11 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
355
355
  return this.contextKeys.with({ view: this.id, viewItem: node.contextValue }, () => {
356
356
  const menu = this.menus.getMenu(VIEW_ITEM_INLINE_MENU);
357
357
  const arg = this.toTreeViewSelection(node);
358
+ const inlineCommands = menu.children.filter((item): item is ActionMenuNode => item instanceof ActionMenuNode);
359
+ const tailDecorations = super.renderTailDecorations(node, props);
358
360
  return <React.Fragment>
359
- {menu.children.map((item, index) => item instanceof ActionMenuNode && this.renderInlineCommand(item, index, arg))}
361
+ {inlineCommands.length > 0 && <div className={TREE_NODE_SEGMENT_CLASS}>{inlineCommands.map((item, index) => this.renderInlineCommand(item, index, arg))}</div>}
362
+ {tailDecorations !== undefined && <div className={TREE_NODE_SEGMENT_CLASS}>{super.renderTailDecorations(node, props)}</div>}
360
363
  </React.Fragment>;
361
364
  });
362
365
  }
@@ -171,7 +171,7 @@ export class CommentsExtImpl implements CommentsExt {
171
171
 
172
172
  const documentData = this._documents.getDocumentData(URI.revive(uriComponents));
173
173
  if (documentData) {
174
- const ranges: theia.Range[] | undefined = await commentController.commentingRangeProvider!.provideCommentingRanges(documentData.document, token);
174
+ const ranges: theia.Range[] | undefined | null = await commentController.commentingRangeProvider!.provideCommentingRanges(documentData.document, token);
175
175
  if (ranges) {
176
176
  return ranges.map(x => fromRange(x));
177
177
  }
@@ -185,6 +185,7 @@ type CommentThreadModification = Partial<{
185
185
  contextValue: string | undefined,
186
186
  comments: theia.Comment[],
187
187
  collapsibleState: theia.CommentThreadCollapsibleState
188
+ canReply: boolean;
188
189
  }>;
189
190
 
190
191
  export class ExtHostCommentThread implements theia.CommentThread, theia.Disposable {
@@ -283,6 +284,17 @@ export class ExtHostCommentThread implements theia.CommentThread, theia.Disposab
283
284
  return this._isDisposed;
284
285
  }
285
286
 
287
+ private _canReply: boolean = true;
288
+ get canReply(): boolean {
289
+ return this._canReply;
290
+ }
291
+
292
+ set canReply(canReply: boolean) {
293
+ this._canReply = canReply;
294
+ this.modifications.canReply = canReply;
295
+ this._onDidUpdateCommentThread.fire();
296
+ }
297
+
286
298
  private commentsMap: Map<theia.Comment, number> = new Map<theia.Comment, number>();
287
299
 
288
300
  private acceptInputDisposables = new DisposableCollection();
@@ -345,6 +357,9 @@ export class ExtHostCommentThread implements theia.CommentThread, theia.Disposab
345
357
  if (modified('collapsibleState')) {
346
358
  formattedModifications.collapseState = convertToCollapsibleState(this.collapseState);
347
359
  }
360
+ if (modified('canReply')) {
361
+ formattedModifications.canReply = this.canReply;
362
+ }
348
363
  this.modifications = {};
349
364
 
350
365
  this.proxy.$updateCommentThread(
@@ -16,11 +16,11 @@
16
16
 
17
17
  import { URI } from '@theia/core/shared/vscode-uri';
18
18
  import * as theia from '@theia/plugin';
19
- import * as Converter from '../type-converters';
20
19
  import { DocumentsExtImpl } from '../documents';
21
- import * as model from '../../common/plugin-api-rpc-model';
20
+ import * as dto from '../../common/plugin-api-rpc-model';
22
21
  import * as rpc from '../../common/plugin-api-rpc';
23
22
  import * as types from '../types-impl';
23
+ import { fromRange } from '../type-converters';
24
24
 
25
25
  export class CallHierarchyAdapter {
26
26
 
@@ -29,9 +29,12 @@ export class CallHierarchyAdapter {
29
29
  private readonly documents: DocumentsExtImpl
30
30
  ) { }
31
31
 
32
+ protected sessionIds = 0;
33
+ protected readonly cache = new Map<string, Map<string, theia.CallHierarchyItem>>();
34
+
32
35
  async provideRootDefinition(
33
36
  resource: URI, position: rpc.Position, token: theia.CancellationToken
34
- ): Promise<model.CallHierarchyDefinition | model.CallHierarchyDefinition[] | undefined> {
37
+ ): Promise<dto.CallHierarchyItem[] | undefined> {
35
38
  const documentData = this.documents.getDocumentData(resource);
36
39
  if (!documentData) {
37
40
  return Promise.reject(new Error(`There is no document for ${resource}`));
@@ -48,83 +51,74 @@ export class CallHierarchyAdapter {
48
51
  if (!definition) {
49
52
  return undefined;
50
53
  }
51
-
52
- return Array.isArray(definition) ? definition.map(item => this.fromCallHierarchyItem(item)) : this.fromCallHierarchyItem(definition);
54
+ const sessionId = (this.sessionIds++).toString(36);
55
+ this.cache.set(sessionId, new Map());
56
+ return Array.isArray(definition) ? definition.map(item => this.fromCallHierarchyItem(item, sessionId)) : [this.fromCallHierarchyItem(definition, sessionId)];
53
57
  }
54
58
 
55
- async provideCallers(definition: model.CallHierarchyDefinition, token: theia.CancellationToken): Promise<model.CallHierarchyReference[] | undefined> {
59
+ async provideCallers(definition: dto.CallHierarchyItem, token: theia.CancellationToken): Promise<dto.CallHierarchyIncomingCall[] | undefined> {
56
60
  const callers = await this.provider.provideCallHierarchyIncomingCalls(this.toCallHierarchyItem(definition), token);
57
61
  if (!callers) {
58
62
  return undefined;
59
63
  }
60
64
 
61
- return callers.map(item => this.fromCallHierarchyIncomingCall(item));
65
+ return callers.map(item => this.fromCallHierarchyIncomingCall(item, definition._sessionId!));
62
66
  }
63
67
 
64
- async provideCallees(definition: model.CallHierarchyDefinition, token: theia.CancellationToken): Promise<model.CallHierarchyReference[] | undefined> {
68
+ async provideCallees(definition: dto.CallHierarchyItem, token: theia.CancellationToken): Promise<dto.CallHierarchyOutgoingCall[] | undefined> {
65
69
  const callees = await this.provider.provideCallHierarchyOutgoingCalls(this.toCallHierarchyItem(definition), token);
66
70
  if (!callees) {
67
71
  return undefined;
68
72
  }
69
73
 
70
- return callees.map(item => this.fromCallHierarchyOutgoingCall(item));
74
+ return callees.map(item => this.fromCallHierarchyOutgoingCall(item, definition._sessionId!));
71
75
  }
72
76
 
73
- private fromCallHierarchyItem(item: theia.CallHierarchyItem): model.CallHierarchyDefinition {
74
- return {
77
+ private fromCallHierarchyItem(item: theia.CallHierarchyItem, sessionId: string): dto.CallHierarchyItem {
78
+ const sessionCache = this.cache.get(sessionId)!;
79
+ const itemId = sessionCache.size.toString(36);
80
+ const definition: dto.CallHierarchyItem = {
75
81
  uri: item.uri,
76
- range: this.fromRange(item.range),
77
- selectionRange: this.fromRange(item.selectionRange),
82
+ range: fromRange(item.range),
83
+ selectionRange: fromRange(item.selectionRange),
78
84
  name: item.name,
79
85
  kind: item.kind,
80
86
  tags: item.tags,
81
- data: item.data,
82
- };
83
- }
84
-
85
- private fromRange(range: theia.Range): model.Range {
86
- return {
87
- startLineNumber: range.start.line + 1,
88
- startColumn: range.start.character + 1,
89
- endLineNumber: range.end.line + 1,
90
- endColumn: range.end.character + 1,
87
+ _itemId: itemId,
88
+ _sessionId: sessionId,
91
89
  };
90
+ sessionCache.set(itemId, item);
91
+ return definition;
92
92
  }
93
93
 
94
- private toRange(range: model.Range): types.Range {
95
- return new types.Range(
96
- range.startLineNumber - 1,
97
- range.startColumn - 1,
98
- range.endLineNumber - 1,
99
- range.endColumn - 1,
100
- );
101
- }
102
-
103
- private toCallHierarchyItem(definition: model.CallHierarchyDefinition): theia.CallHierarchyItem {
104
- const item = new types.CallHierarchyItem(
105
- Converter.SymbolKind.toSymbolKind(definition.kind),
106
- definition.name,
107
- definition.detail ? definition.detail : '',
108
- URI.revive(definition.uri),
109
- this.toRange(definition.range),
110
- this.toRange(definition.selectionRange),
111
- );
112
- item.tags = definition.tags;
113
- item.data = definition.data;
114
- return item;
94
+ private toCallHierarchyItem(definition: dto.CallHierarchyItem): theia.CallHierarchyItem {
95
+ const cached = this.cache.get(definition._sessionId!)?.get(definition._itemId!);
96
+ if (!cached) {
97
+ throw new Error(`Found no cached item corresponding to ${definition.name} in ${definition.uri.path} with ID ${definition.data}.`);
98
+ }
99
+ return cached;
115
100
  }
116
101
 
117
- private fromCallHierarchyIncomingCall(caller: theia.CallHierarchyIncomingCall): model.CallHierarchyReference {
102
+ private fromCallHierarchyIncomingCall(caller: theia.CallHierarchyIncomingCall, sessionId: string): dto.CallHierarchyIncomingCall {
118
103
  return {
119
- callerDefinition: this.fromCallHierarchyItem(caller.from),
120
- references: caller.fromRanges.map(l => this.fromRange(l))
104
+ from: this.fromCallHierarchyItem(caller.from, sessionId),
105
+ fromRanges: caller.fromRanges.map(r => fromRange(r))
121
106
  };
122
107
  }
123
108
 
124
- protected fromCallHierarchyOutgoingCall(caller: theia.CallHierarchyOutgoingCall): model.CallHierarchyReference {
109
+ protected fromCallHierarchyOutgoingCall(caller: theia.CallHierarchyOutgoingCall, sessionId: string): dto.CallHierarchyOutgoingCall {
125
110
  return {
126
- callerDefinition: this.fromCallHierarchyItem(caller.to),
127
- references: caller.fromRanges.map(this.fromRange.bind(this)),
111
+ to: this.fromCallHierarchyItem(caller.to, sessionId),
112
+ fromRanges: caller.fromRanges.map(r => fromRange(r)),
128
113
  };
129
114
  }
115
+
116
+ releaseSession(session?: string): Promise<boolean> {
117
+ if (session !== undefined) {
118
+ return Promise.resolve(this.cache.delete(session));
119
+ } else {
120
+ this.cache.clear();
121
+ return Promise.resolve(true);
122
+ }
123
+ }
130
124
  }
@@ -71,7 +71,7 @@ export class CodeLensAdapter {
71
71
  return undefined;
72
72
  }
73
73
 
74
- let newLens: theia.CodeLens | undefined;
74
+ let newLens: theia.CodeLens | undefined | null;
75
75
  if (typeof this.provider.resolveCodeLens === 'function' && !lens.isResolved) {
76
76
  newLens = await this.provider.resolveCodeLens(lens, token);
77
77
  if (token.isCancellationRequested) {
@@ -59,9 +59,10 @@ import {
59
59
  CodeAction,
60
60
  FoldingRange,
61
61
  SelectionRange,
62
- CallHierarchyDefinition,
63
- CallHierarchyReference,
64
- ChainedCacheId
62
+ ChainedCacheId,
63
+ CallHierarchyItem,
64
+ CallHierarchyIncomingCall,
65
+ CallHierarchyOutgoingCall,
65
66
  } from '../common/plugin-api-rpc-model';
66
67
  import { CompletionAdapter } from './languages/completion';
67
68
  import { Diagnostics } from './languages/diagnostics';
@@ -612,17 +613,21 @@ export class LanguagesExtImpl implements LanguagesExt {
612
613
 
613
614
  $provideRootDefinition(
614
615
  handle: number, resource: UriComponents, location: Position, token: theia.CancellationToken
615
- ): Promise<CallHierarchyDefinition | CallHierarchyDefinition[] | undefined> {
616
+ ): Promise<CallHierarchyItem[] | undefined> {
616
617
  return this.withAdapter(handle, CallHierarchyAdapter, adapter => adapter.provideRootDefinition(URI.revive(resource), location, token), undefined);
617
618
  }
618
619
 
619
- $provideCallers(handle: number, definition: CallHierarchyDefinition, token: theia.CancellationToken): Promise<CallHierarchyReference[] | undefined> {
620
+ $provideCallers(handle: number, definition: CallHierarchyItem, token: theia.CancellationToken): Promise<CallHierarchyIncomingCall[] | undefined> {
620
621
  return this.withAdapter(handle, CallHierarchyAdapter, adapter => adapter.provideCallers(definition, token), undefined);
621
622
  }
622
623
 
623
- $provideCallees(handle: number, definition: CallHierarchyDefinition, token: theia.CancellationToken): Promise<CallHierarchyReference[] | undefined> {
624
+ $provideCallees(handle: number, definition: CallHierarchyItem, token: theia.CancellationToken): Promise<CallHierarchyOutgoingCall[] | undefined> {
624
625
  return this.withAdapter(handle, CallHierarchyAdapter, adapter => adapter.provideCallees(definition, token), undefined);
625
626
  }
627
+
628
+ $releaseCallHierarchy(handle: number, session?: string): Promise<boolean> {
629
+ return this.withAdapter(handle, CallHierarchyAdapter, adapter => adapter.releaseSession(session), false);
630
+ }
626
631
  // ### Call Hierarchy Provider end
627
632
 
628
633
  // #region semantic coloring
@@ -233,6 +233,7 @@ export class DebugExtImpl implements DebugExt {
233
233
  const session = this.sessions.get(sessionId);
234
234
  if (session) {
235
235
  this.onDidTerminateDebugSessionEmitter.fire(session);
236
+ this.sessions.delete(sessionId);
236
237
  }
237
238
  }
238
239
 
@@ -322,7 +323,6 @@ export class DebugExtImpl implements DebugExt {
322
323
  const debugAdapterSession = this.sessions.get(sessionId);
323
324
  if (debugAdapterSession) {
324
325
  await debugAdapterSession.stop();
325
- this.sessions.delete(sessionId);
326
326
  }
327
327
  }
328
328
 
@@ -346,12 +346,20 @@ export class DebugExtImpl implements DebugExt {
346
346
  return { provider, type };
347
347
  }
348
348
 
349
- async $provideDebugConfigurationsByHandle(handle: number, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration[]> {
349
+ async $provideDebugConfigurationsByHandle(
350
+ handle: number,
351
+ workspaceFolderUri: string | undefined
352
+ ): Promise<theia.DebugConfiguration[]> {
350
353
  const { provider, type } = this.getConfigurationProviderRecord(handle);
351
354
 
352
- const configurations = await provider.provideDebugConfigurations?.(this.toWorkspaceFolder(workspaceFolderUri));
355
+ const configurations = await provider.provideDebugConfigurations?.(
356
+ this.toWorkspaceFolder(workspaceFolderUri)
357
+ );
358
+
353
359
  if (!configurations) {
354
- throw new Error('nothing returned from DebugConfigurationProvider.provideDebugConfigurations, type: ' + type);
360
+ throw new Error(
361
+ 'nothing returned from DebugConfigurationProvider.provideDebugConfigurations, type: ' + type
362
+ );
355
363
  }
356
364
 
357
365
  return configurations;
@@ -361,88 +369,24 @@ export class DebugExtImpl implements DebugExt {
361
369
  handle: number,
362
370
  workspaceFolderUri: string | undefined,
363
371
  debugConfiguration: theia.DebugConfiguration
364
- ): Promise<theia.DebugConfiguration | undefined> {
365
-
372
+ ): Promise<theia.DebugConfiguration | undefined | null> {
366
373
  const { provider } = this.getConfigurationProviderRecord(handle);
367
- return provider.resolveDebugConfiguration?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
374
+ return provider.resolveDebugConfiguration?.(
375
+ this.toWorkspaceFolder(workspaceFolderUri),
376
+ debugConfiguration
377
+ );
368
378
  }
369
379
 
370
380
  async $resolveDebugConfigurationWithSubstitutedVariablesByHandle(
371
381
  handle: number,
372
382
  workspaceFolderUri: string | undefined,
373
383
  debugConfiguration: theia.DebugConfiguration
374
- ): Promise<theia.DebugConfiguration | undefined> {
375
-
384
+ ): Promise<theia.DebugConfiguration | undefined | null> {
376
385
  const { provider } = this.getConfigurationProviderRecord(handle);
377
- return provider.resolveDebugConfigurationWithSubstitutedVariables?.(this.toWorkspaceFolder(workspaceFolderUri), debugConfiguration);
378
- }
379
-
380
- async $provideDebugConfigurations(debugType: string, workspaceFolderUri: string | undefined, dynamic: boolean = false): Promise<theia.DebugConfiguration[]> {
381
- let result: theia.DebugConfiguration[] = [];
382
-
383
- const trigger = dynamic ? DebugConfigurationProviderTriggerKind.Dynamic : DebugConfigurationProviderTriggerKind.Initial;
384
- const providers = this.configurationProviders
385
- .filter(p => p.type === debugType && p.trigger === trigger)
386
- .map(p => p.provider);
387
-
388
- for (const provider of providers) {
389
- if (provider.provideDebugConfigurations) {
390
- result = result.concat(await provider.provideDebugConfigurations(this.toWorkspaceFolder(workspaceFolderUri)) || []);
391
- }
392
- }
393
-
394
- return result;
395
- }
396
-
397
- async $resolveDebugConfigurations(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise<theia.DebugConfiguration | undefined> {
398
- let current = debugConfiguration;
399
-
400
- const providers = this.configurationProviders
401
- .filter(p => p.type === debugConfiguration.type || p.type === '*')
402
- .map(p => p.provider);
403
-
404
- for (const provider of providers) {
405
- if (provider.resolveDebugConfiguration) {
406
- try {
407
- const next = await provider.resolveDebugConfiguration(this.toWorkspaceFolder(workspaceFolderUri), current);
408
- if (next) {
409
- current = next;
410
- } else {
411
- return current;
412
- }
413
- } catch (e) {
414
- console.error(e);
415
- }
416
- }
417
- }
418
-
419
- return current;
420
- }
421
-
422
- async $resolveDebugConfigurationWithSubstitutedVariables(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined):
423
- Promise<theia.DebugConfiguration | undefined> {
424
- let current = debugConfiguration;
425
-
426
- const providers = this.configurationProviders
427
- .filter(p => p.type === debugConfiguration.type || p.type === '*')
428
- .map(p => p.provider);
429
-
430
- for (const provider of providers) {
431
- if (provider.resolveDebugConfigurationWithSubstitutedVariables) {
432
- try {
433
- const next = await provider.resolveDebugConfigurationWithSubstitutedVariables(this.toWorkspaceFolder(workspaceFolderUri), current);
434
- if (next) {
435
- current = next;
436
- } else {
437
- return current;
438
- }
439
- } catch (e) {
440
- console.error(e);
441
- }
442
- }
443
- }
444
-
445
- return current;
386
+ return provider.resolveDebugConfigurationWithSubstitutedVariables?.(
387
+ this.toWorkspaceFolder(workspaceFolderUri),
388
+ debugConfiguration
389
+ );
446
390
  }
447
391
 
448
392
  protected async createDebugAdapterTracker(session: theia.DebugSession): Promise<theia.DebugAdapterTracker> {
@@ -23,6 +23,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
23
23
 
24
24
  export class NotificationExtImpl implements NotificationExt {
25
25
  private readonly proxy: NotificationMain;
26
+ private mapProgressIdToCancellationSource: Map<string, CancellationTokenSource> = new Map();
26
27
 
27
28
  constructor(rpc: RPCProtocol) {
28
29
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTIFICATION_MAIN);
@@ -32,13 +33,20 @@ export class NotificationExtImpl implements NotificationExt {
32
33
  options: ProgressOptions,
33
34
  task: (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => PromiseLike<R>
34
35
  ): Promise<R> {
36
+ const source = new CancellationTokenSource();
35
37
  const id = new Deferred<string>();
36
- const tokenSource = new CancellationTokenSource();
37
- const progress = task({ report: async item => this.proxy.$updateProgress(await id.promise, item)}, tokenSource.token);
38
+ const progress = task({ report: async item => this.proxy.$updateProgress(await id.promise, item)}, source.token);
38
39
  const title = options.title ? options.title : '';
39
40
  const location = this.mapLocation(options.location);
40
41
  const cancellable = options.cancellable;
42
+
41
43
  id.resolve(await this.proxy.$startProgress({ title, location, cancellable }));
44
+
45
+ if (cancellable) {
46
+ const progressId = await id.promise;
47
+ this.mapProgressIdToCancellationSource.set(progressId, source);
48
+ }
49
+
42
50
  const stop = async () => this.proxy.$stopProgress(await id.promise);
43
51
  const promise = Promise.all([
44
52
  progress,
@@ -48,6 +56,14 @@ export class NotificationExtImpl implements NotificationExt {
48
56
  return progress;
49
57
  }
50
58
 
59
+ public $acceptProgressCanceled(id: string): void {
60
+ const source = this.mapProgressIdToCancellationSource.get(id);
61
+ if (source) {
62
+ source.cancel();
63
+ this.mapProgressIdToCancellationSource.delete(id);
64
+ }
65
+ }
66
+
51
67
  protected mapLocation(location: ProgressLocation | { viewId: string }): string | undefined {
52
68
  if (typeof location === 'object') {
53
69
  return location.viewId;
@@ -451,6 +451,7 @@ export class QuickInputExt implements QuickInput {
451
451
  }
452
452
 
453
453
  _fireChangedValue(changedValue: string): void {
454
+ this._value = changedValue;
454
455
  this._onDidChangeValueEmitter.fire(changedValue);
455
456
  }
456
457
 
@@ -533,39 +534,6 @@ export class InputBoxExt extends QuickInputExt implements InputBox {
533
534
  this.update({ validationMessage });
534
535
  }
535
536
  }
536
-
537
- override async show(): Promise<void> {
538
- super.show();
539
-
540
- const update = (value: string) => {
541
- this.value = value;
542
- if (this.validationMessage && this.validationMessage.length > 0) {
543
- return this.validationMessage;
544
- }
545
- };
546
-
547
- this.quickOpen.showInputBox({
548
- id: this._id,
549
- busy: this.busy,
550
- buttons: this.buttons,
551
- enabled: this.enabled,
552
- ignoreFocusOut: this.ignoreFocusOut,
553
- password: this.password,
554
- placeholder: this.placeholder,
555
- prompt: this.prompt,
556
- step: this.step,
557
- title: this.title,
558
- totalSteps: this.totalSteps,
559
- validationMessage: this.validationMessage,
560
- value: this.value,
561
- visible: this.visible,
562
- validateInput(value: string): string | undefined {
563
- if (value.length > 0) {
564
- return update(value);
565
- }
566
- }
567
- });
568
- }
569
537
  }
570
538
 
571
539
  /**
@@ -20,14 +20,22 @@ import { UUID } from '@theia/core/shared/@phosphor/coreutils';
20
20
 
21
21
  export class StatusBarItemImpl implements theia.StatusBarItem {
22
22
 
23
+ /** Map from allowed background colors to corresponding foreground colors. */
24
+ private static BACKGROUND_COLORS = new Map<string, string>([
25
+ ['statusBarItem.errorBackground', 'statusBarItem.errorForeground'],
26
+ ['statusBarItem.warningBackground', 'statusBarItem.warningForeground']
27
+ ]);
28
+
23
29
  private _id: string;
24
30
 
25
31
  private _alignment: StatusBarAlignment;
26
32
  private _priority: number;
27
33
 
34
+ private _name: string | undefined;
28
35
  private _text: string;
29
36
  private _tooltip: string;
30
- private _color: string | ThemeColor;
37
+ private _color: string | ThemeColor | undefined;
38
+ private _backgroundColor: ThemeColor | undefined;
31
39
  private _command: string | theia.Command;
32
40
  private _accessibilityInformation: theia.AccessibilityInformation;
33
41
 
@@ -58,6 +66,10 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
58
66
  return this._priority;
59
67
  }
60
68
 
69
+ public get name(): string | undefined {
70
+ return this._name;
71
+ }
72
+
61
73
  public get text(): string {
62
74
  return this._text;
63
75
  }
@@ -66,10 +78,14 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
66
78
  return this._tooltip;
67
79
  }
68
80
 
69
- public get color(): string | ThemeColor {
81
+ public get color(): string | ThemeColor | undefined {
70
82
  return this._color;
71
83
  }
72
84
 
85
+ public get backgroundColor(): ThemeColor | undefined {
86
+ return this._backgroundColor;
87
+ }
88
+
73
89
  public get command(): string | theia.Command {
74
90
  return this._command;
75
91
  }
@@ -78,6 +94,11 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
78
94
  return this._accessibilityInformation;
79
95
  }
80
96
 
97
+ public set name(name: string | undefined) {
98
+ this._name = name;
99
+ this.update();
100
+ }
101
+
81
102
  public set text(text: string) {
82
103
  this._text = text;
83
104
  this.update();
@@ -88,11 +109,20 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
88
109
  this.update();
89
110
  }
90
111
 
91
- public set color(color: string | ThemeColor) {
112
+ public set color(color: string | ThemeColor | undefined) {
92
113
  this._color = color;
93
114
  this.update();
94
115
  }
95
116
 
117
+ public set backgroundColor(backgroundColor: ThemeColor | undefined) {
118
+ if (backgroundColor && StatusBarItemImpl.BACKGROUND_COLORS.has(backgroundColor.id)) {
119
+ this._backgroundColor = backgroundColor;
120
+ } else {
121
+ this._backgroundColor = undefined;
122
+ }
123
+ this.update();
124
+ }
125
+
96
126
  public set command(command: string | theia.Command) {
97
127
  this._command = command;
98
128
  this.update();
@@ -129,11 +159,22 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
129
159
 
130
160
  const commandId = typeof this.command === 'object' ? this.command.command : this.command;
131
161
  const args = typeof this.command === 'object' ? this.command.arguments : undefined;
162
+
163
+ let color = this.color;
164
+ if (this.backgroundColor) {
165
+ // If an error or warning background color is set, set the corresponding foreground color
166
+ color = StatusBarItemImpl.BACKGROUND_COLORS.get(this.backgroundColor.id);
167
+ }
168
+
132
169
  // Set to status bar
133
- this._proxy.$setMessage(this.id, this.text,
170
+ this._proxy.$setMessage(
171
+ this.id,
172
+ this.name,
173
+ this.text,
134
174
  this.priority,
135
175
  this.alignment,
136
- typeof this.color === 'string' ? this.color : this.color && this.color.id,
176
+ typeof color === 'string' ? color : color?.id,
177
+ this.backgroundColor?.id,
137
178
  this.tooltip,
138
179
  commandId,
139
180
  this.accessibilityInformation,
@@ -262,7 +262,8 @@ class TreeViewExtImpl<T> implements Disposable {
262
262
  // root
263
263
  return [];
264
264
  }
265
- const parent = this.treeDataProvider.getParent && await this.treeDataProvider.getParent(element);
265
+ const result = this.treeDataProvider.getParent && await this.treeDataProvider.getParent(element);
266
+ const parent = result ? result : undefined;
266
267
  const chain = await this.calculateRevealParentChain(parent);
267
268
  if (!chain) {
268
269
  // parents are inconsistent