@theia/plugin-ext 1.23.0-next.52 → 1.23.0-next.56

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 (37) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +8 -0
  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 +3 -3
  5. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/main/browser/custom-editors/custom-editors-main.js +1 -1
  8. package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
  9. package/lib/main/browser/languages-main.d.ts +2 -2
  10. package/lib/main/browser/languages-main.d.ts.map +1 -1
  11. package/lib/main/browser/languages-main.js +5 -3
  12. package/lib/main/browser/languages-main.js.map +1 -1
  13. package/lib/main/browser/menus/menus-contribution-handler.js +4 -4
  14. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  15. package/lib/plugin/custom-editors.d.ts +1 -1
  16. package/lib/plugin/custom-editors.d.ts.map +1 -1
  17. package/lib/plugin/custom-editors.js +2 -2
  18. package/lib/plugin/custom-editors.js.map +1 -1
  19. package/lib/plugin/languages/code-action.d.ts.map +1 -1
  20. package/lib/plugin/languages/code-action.js +3 -1
  21. package/lib/plugin/languages/code-action.js.map +1 -1
  22. package/lib/plugin/languages.d.ts.map +1 -1
  23. package/lib/plugin/languages.js +14 -3
  24. package/lib/plugin/languages.js.map +1 -1
  25. package/lib/plugin/types-impl.d.ts +4 -0
  26. package/lib/plugin/types-impl.d.ts.map +1 -1
  27. package/lib/plugin/types-impl.js.map +1 -1
  28. package/package.json +23 -23
  29. package/src/common/plugin-api-rpc-model.ts +4 -0
  30. package/src/common/plugin-api-rpc.ts +4 -3
  31. package/src/main/browser/custom-editors/custom-editors-main.ts +1 -1
  32. package/src/main/browser/languages-main.ts +7 -3
  33. package/src/main/browser/menus/menus-contribution-handler.ts +6 -6
  34. package/src/plugin/custom-editors.ts +2 -2
  35. package/src/plugin/languages/code-action.ts +3 -1
  36. package/src/plugin/languages.ts +19 -3
  37. package/src/plugin/types-impl.ts +4 -0
@@ -69,7 +69,8 @@ import {
69
69
  CommentOptions,
70
70
  CommentThreadCollapsibleState,
71
71
  CommentThread,
72
- CommentThreadChangedEvent
72
+ CommentThreadChangedEvent,
73
+ CodeActionProviderDocumentation
73
74
  } from './plugin-api-rpc-model';
74
75
  import { ExtPluginApi } from './plugin-ext-api-contribution';
75
76
  import { KeysToAnyValues, KeysToKeysToAnyValue } from './types';
@@ -1493,7 +1494,7 @@ export interface LanguagesMain {
1493
1494
  $registerSignatureHelpProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], metadata: theia.SignatureHelpProviderMetadata): void;
1494
1495
  $registerHoverProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
1495
1496
  $registerDocumentHighlightProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
1496
- $registerQuickFixProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void;
1497
+ $registerQuickFixProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], codeActionKinds?: string[], documentation?: CodeActionProviderDocumentation): void;
1497
1498
  $clearDiagnostics(id: string): void;
1498
1499
  $changeDiagnostics(id: string, delta: [string, MarkerData[]][]): void;
1499
1500
  $registerDocumentFormattingSupport(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
@@ -1586,7 +1587,7 @@ export interface CustomEditorsExt {
1586
1587
  widgetOpenerOptions: WidgetOpenerOptions | undefined,
1587
1588
  options: theia.WebviewPanelOptions,
1588
1589
  cancellation: CancellationToken): Promise<void>;
1589
- $createCustomDocument(resource: UriComponents, viewType: string, backupId: string | undefined, cancellation: CancellationToken): Promise<{ editable: boolean }>;
1590
+ $createCustomDocument(resource: UriComponents, viewType: string, openContext: theia.CustomDocumentOpenContext, cancellation: CancellationToken): Promise<{ editable: boolean }>;
1590
1591
  $disposeCustomDocument(resource: UriComponents, viewType: string): Promise<void>;
1591
1592
  $undo(resource: UriComponents, viewType: string, editId: number, isDirty: boolean): Promise<void>;
1592
1593
  $redo(resource: UriComponents, viewType: string, editId: number, isDirty: boolean): Promise<void>;
@@ -308,7 +308,7 @@ export class MainCustomEditorModel implements CustomEditorModel {
308
308
  editorPreferences: EditorPreferences,
309
309
  cancellation: CancellationToken,
310
310
  ): Promise<MainCustomEditorModel> {
311
- const { editable } = await proxy.$createCustomDocument(URI.file(resource.path.toString()), viewType, undefined, cancellation);
311
+ const { editable } = await proxy.$createCustomDocument(URI.file(resource.path.toString()), viewType, {}, cancellation);
312
312
  return new MainCustomEditorModel(proxy, viewType, resource, editable, undoRedoService, fileService, editorPreferences);
313
313
  }
314
314
 
@@ -37,7 +37,7 @@ import {
37
37
  import { injectable, inject } from '@theia/core/shared/inversify';
38
38
  import {
39
39
  SerializedDocumentFilter, MarkerData, Range, RelatedInformation,
40
- MarkerSeverity, DocumentLink, WorkspaceSymbolParams, CodeAction, CompletionDto
40
+ MarkerSeverity, DocumentLink, WorkspaceSymbolParams, CodeAction, CompletionDto, CodeActionProviderDocumentation
41
41
  } from '../../common/plugin-api-rpc-model';
42
42
  import { RPCProtocol } from '../../common/rpc-protocol';
43
43
  import { MonacoLanguages, WorkspaceSymbolProvider } from '@theia/monaco/lib/browser/monaco-languages';
@@ -710,7 +710,9 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
710
710
  }, token);
711
711
  }
712
712
 
713
- $registerQuickFixProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], providedCodeActionKinds?: string[]): void {
713
+ $registerQuickFixProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], providedCodeActionKinds?: string[],
714
+ documentation?: CodeActionProviderDocumentation): void {
715
+
714
716
  const languageSelector = this.toLanguageSelector(selector);
715
717
  const quickFixProvider = {
716
718
  provideCodeActions: (model: monaco.editor.ITextModel, range: monaco.Range,
@@ -720,7 +722,8 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
720
722
  },
721
723
  resolveCodeAction: (codeAction: monaco.languages.CodeAction, token: monaco.CancellationToken): Promise<monaco.languages.CodeAction> =>
722
724
  this.resolveCodeAction(handle, codeAction, token),
723
- providedCodeActionKinds
725
+ providedCodeActionKinds,
726
+ documentation
724
727
  };
725
728
  this.register(handle, monaco.modes.CodeActionProviderRegistry.register(languageSelector, quickFixProvider));
726
729
  }
@@ -1022,6 +1025,7 @@ function toMonacoAction(action: CodeAction): monaco.languages.CodeAction {
1022
1025
  return {
1023
1026
  ...action,
1024
1027
  diagnostics: action.diagnostics ? action.diagnostics.map(m => toMonacoMarkerData(m)) : undefined,
1028
+ disabled: action.disabled?.reason,
1025
1029
  edit: action.edit ? toMonacoWorkspaceEdit(action.edit) : undefined
1026
1030
  };
1027
1031
  }
@@ -21,7 +21,7 @@ import { injectable, inject, optional } from '@theia/core/shared/inversify';
21
21
  import { MenuPath, ILogger, CommandRegistry, Command, Mutable, MenuAction, SelectionService, CommandHandler, Disposable, DisposableCollection } from '@theia/core';
22
22
  import { EDITOR_CONTEXT_MENU, EditorWidget } from '@theia/editor/lib/browser';
23
23
  import { MenuModelRegistry } from '@theia/core/lib/common';
24
- import { Emitter } from '@theia/core/lib/common/event';
24
+ import { Emitter, Event } from '@theia/core/lib/common/event';
25
25
  import { TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
26
26
  import { NAVIGATOR_CONTEXT_MENU } from '@theia/navigator/lib/browser/navigator-contribution';
27
27
  import { VIEW_ITEM_CONTEXT_MENU, TreeViewWidget, VIEW_ITEM_INLINE_MENU } from '../view/tree-view-widget';
@@ -359,20 +359,20 @@ export class MenusContributionPointHandler {
359
359
 
360
360
  const { when } = action;
361
361
  const whenKeys = when && this.contextKeyService.parseKeys(when);
362
- let onDidChange;
362
+ let onDidChange: Event<void> | undefined;
363
363
  if (whenKeys && whenKeys.size) {
364
364
  const onDidChangeEmitter = new Emitter<void>();
365
365
  toDispose.push(onDidChangeEmitter);
366
366
  onDidChange = onDidChangeEmitter.event;
367
- this.contextKeyService.onDidChange.maxListeners = this.contextKeyService.onDidChange.maxListeners + 1;
367
+ Event.addMaxListeners(this.contextKeyService.onDidChange, 1);
368
+ toDispose.push(Disposable.create(() => {
369
+ Event.addMaxListeners(this.contextKeyService.onDidChange, -1);
370
+ }));
368
371
  toDispose.push(this.contextKeyService.onDidChange(event => {
369
372
  if (event.affects(whenKeys)) {
370
373
  onDidChangeEmitter.fire(undefined);
371
374
  }
372
375
  }));
373
- toDispose.push(Disposable.create(() => {
374
- this.contextKeyService.onDidChange.maxListeners = this.contextKeyService.onDidChange.maxListeners - 1;
375
- }));
376
376
  }
377
377
 
378
378
  // handle group and priority
@@ -81,7 +81,7 @@ export class CustomEditorsExtImpl implements CustomEditorsExt {
81
81
  );
82
82
  }
83
83
 
84
- async $createCustomDocument(resource: UriComponents, viewType: string, backupId: string | undefined, cancellation: CancellationToken): Promise<{
84
+ async $createCustomDocument(resource: UriComponents, viewType: string, openContext: theia.CustomDocumentOpenContext, cancellation: CancellationToken): Promise<{
85
85
  editable: boolean;
86
86
  }> {
87
87
  const entry = this.editorProviders.get(viewType);
@@ -94,7 +94,7 @@ export class CustomEditorsExtImpl implements CustomEditorsExt {
94
94
  }
95
95
 
96
96
  const revivedResource = URI.revive(resource);
97
- const document = await entry.provider.openCustomDocument(revivedResource, { backupId }, cancellation);
97
+ const document = await entry.provider.openCustomDocument(revivedResource, openContext, cancellation);
98
98
  this.documents.add(viewType, document);
99
99
 
100
100
  return { editable: this.supportEditing(entry.provider) };
@@ -104,7 +104,9 @@ export class CodeActionAdapter {
104
104
  command: this.commands.converter.toSafeCommand(candidate.command, toDispose),
105
105
  diagnostics: candidate.diagnostics && candidate.diagnostics.map(Converter.convertDiagnosticToMarkerData),
106
106
  edit: candidate.edit && Converter.fromWorkspaceEdit(candidate.edit),
107
- kind: candidate.kind && candidate.kind.value
107
+ kind: candidate.kind && candidate.kind.value,
108
+ disabled: candidate.disabled,
109
+ isPreferred: candidate.isPreferred
108
110
  });
109
111
  }
110
112
  }
@@ -35,6 +35,7 @@ import { PluginModel } from '../common/plugin-protocol';
35
35
  import { Disposable, URI } from './types-impl';
36
36
  import { UriComponents } from '../common/uri-components';
37
37
  import {
38
+ CodeActionProviderDocumentation,
38
39
  CompletionContext,
39
40
  CompletionResultDto,
40
41
  Completion,
@@ -91,6 +92,7 @@ import { CallHierarchyAdapter } from './languages/call-hierarchy';
91
92
  import { BinaryBuffer } from '@theia/core/lib/common/buffer';
92
93
  import { DocumentSemanticTokensAdapter, DocumentRangeSemanticTokensAdapter } from './languages/semantic-highlighting';
93
94
  import { isReadonlyArray } from '../common/arrays';
95
+ import { DisposableCollection } from '@theia/core/lib/common/disposable';
94
96
 
95
97
  type Adapter = CompletionAdapter |
96
98
  SignatureHelpAdapter |
@@ -179,10 +181,11 @@ export class LanguagesExtImpl implements LanguagesExt {
179
181
  return this.callId++;
180
182
  }
181
183
 
182
- private createDisposable(callId: number): theia.Disposable {
184
+ private createDisposable(callId: number, onDispose?: () => void): theia.Disposable {
183
185
  return new Disposable(() => {
184
186
  this.adaptersMap.delete(callId);
185
187
  this.proxy.$unregister(callId);
188
+ onDispose?.();
186
189
  });
187
190
  }
188
191
 
@@ -446,13 +449,26 @@ export class LanguagesExtImpl implements LanguagesExt {
446
449
  metadata?: theia.CodeActionProviderMetadata
447
450
  ): theia.Disposable {
448
451
  const callId = this.addNewAdapter(new CodeActionAdapter(provider, this.documents, this.diagnostics, pluginModel ? pluginModel.id : '', this.commands));
452
+
453
+ let documentation: CodeActionProviderDocumentation | undefined;
454
+ let disposables: DisposableCollection | undefined;
455
+ if (metadata && metadata.documentation) {
456
+ disposables = new DisposableCollection();
457
+ documentation = metadata.documentation.map(doc => ({
458
+ kind: doc.kind.value,
459
+ command: this.commands.converter.toSafeCommand(doc.command, disposables!)
460
+ }));
461
+ }
462
+
449
463
  this.proxy.$registerQuickFixProvider(
450
464
  callId,
451
465
  pluginInfo,
452
466
  this.transformDocumentSelector(selector),
453
- metadata && metadata.providedCodeActionKinds ? metadata.providedCodeActionKinds.map(kind => kind.value!) : undefined
467
+ metadata && metadata.providedCodeActionKinds ? metadata.providedCodeActionKinds.map(kind => kind.value) : undefined,
468
+ documentation
454
469
  );
455
- return this.createDisposable(callId);
470
+
471
+ return this.createDisposable(callId, disposables?.dispose);
456
472
  }
457
473
 
458
474
  $provideCodeActions(handle: number,
@@ -1238,6 +1238,10 @@ export class CodeAction {
1238
1238
 
1239
1239
  kind?: CodeActionKind;
1240
1240
 
1241
+ disabled?: { reason: string };
1242
+
1243
+ isPreferred?: boolean;
1244
+
1241
1245
  constructor(title: string, kind?: CodeActionKind) {
1242
1246
  this.title = title;
1243
1247
  this.kind = kind;