@theia/plugin-ext 1.26.0-next.21 → 1.26.0-next.22

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 (38) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +5 -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 -1
  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/languages-main.d.ts +2 -0
  8. package/lib/main/browser/languages-main.d.ts.map +1 -1
  9. package/lib/main/browser/languages-main.js +21 -0
  10. package/lib/main/browser/languages-main.js.map +1 -1
  11. package/lib/plugin/languages/linked-editing-range.d.ts +12 -0
  12. package/lib/plugin/languages/linked-editing-range.d.ts.map +1 -0
  13. package/lib/plugin/languages/linked-editing-range.js +41 -0
  14. package/lib/plugin/languages/linked-editing-range.js.map +1 -0
  15. package/lib/plugin/languages-utils.d.ts +6 -0
  16. package/lib/plugin/languages-utils.d.ts.map +1 -0
  17. package/lib/plugin/languages-utils.js +52 -0
  18. package/lib/plugin/languages-utils.js.map +1 -0
  19. package/lib/plugin/languages.d.ts +3 -1
  20. package/lib/plugin/languages.d.ts.map +1 -1
  21. package/lib/plugin/languages.js +15 -33
  22. package/lib/plugin/languages.js.map +1 -1
  23. package/lib/plugin/plugin-context.d.ts.map +1 -1
  24. package/lib/plugin/plugin-context.js +5 -1
  25. package/lib/plugin/plugin-context.js.map +1 -1
  26. package/lib/plugin/types-impl.d.ts +5 -0
  27. package/lib/plugin/types-impl.d.ts.map +1 -1
  28. package/lib/plugin/types-impl.js +12 -1
  29. package/lib/plugin/types-impl.js.map +1 -1
  30. package/package.json +23 -23
  31. package/src/common/plugin-api-rpc-model.ts +6 -0
  32. package/src/common/plugin-api-rpc.ts +4 -1
  33. package/src/main/browser/languages-main.ts +26 -0
  34. package/src/plugin/languages/linked-editing-range.ts +48 -0
  35. package/src/plugin/languages-utils.ts +55 -0
  36. package/src/plugin/languages.ts +19 -41
  37. package/src/plugin/plugin-context.ts +7 -2
  38. package/src/plugin/types-impl.ts +12 -0
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext",
3
- "version": "1.26.0-next.21+7d1f7241fa3",
3
+ "version": "1.26.0-next.22+1265154246d",
4
4
  "description": "Theia - Plugin Extension",
5
5
  "main": "lib/common/index.js",
6
6
  "typings": "lib/common/index.d.ts",
7
7
  "dependencies": {
8
- "@theia/bulk-edit": "1.26.0-next.21+7d1f7241fa3",
9
- "@theia/callhierarchy": "1.26.0-next.21+7d1f7241fa3",
10
- "@theia/console": "1.26.0-next.21+7d1f7241fa3",
11
- "@theia/core": "1.26.0-next.21+7d1f7241fa3",
12
- "@theia/debug": "1.26.0-next.21+7d1f7241fa3",
13
- "@theia/editor": "1.26.0-next.21+7d1f7241fa3",
14
- "@theia/file-search": "1.26.0-next.21+7d1f7241fa3",
15
- "@theia/filesystem": "1.26.0-next.21+7d1f7241fa3",
16
- "@theia/markers": "1.26.0-next.21+7d1f7241fa3",
17
- "@theia/messages": "1.26.0-next.21+7d1f7241fa3",
18
- "@theia/monaco": "1.26.0-next.21+7d1f7241fa3",
8
+ "@theia/bulk-edit": "1.26.0-next.22+1265154246d",
9
+ "@theia/callhierarchy": "1.26.0-next.22+1265154246d",
10
+ "@theia/console": "1.26.0-next.22+1265154246d",
11
+ "@theia/core": "1.26.0-next.22+1265154246d",
12
+ "@theia/debug": "1.26.0-next.22+1265154246d",
13
+ "@theia/editor": "1.26.0-next.22+1265154246d",
14
+ "@theia/file-search": "1.26.0-next.22+1265154246d",
15
+ "@theia/filesystem": "1.26.0-next.22+1265154246d",
16
+ "@theia/markers": "1.26.0-next.22+1265154246d",
17
+ "@theia/messages": "1.26.0-next.22+1265154246d",
18
+ "@theia/monaco": "1.26.0-next.22+1265154246d",
19
19
  "@theia/monaco-editor-core": "1.65.2",
20
- "@theia/navigator": "1.26.0-next.21+7d1f7241fa3",
21
- "@theia/output": "1.26.0-next.21+7d1f7241fa3",
22
- "@theia/plugin": "1.26.0-next.21+7d1f7241fa3",
23
- "@theia/preferences": "1.26.0-next.21+7d1f7241fa3",
24
- "@theia/scm": "1.26.0-next.21+7d1f7241fa3",
25
- "@theia/search-in-workspace": "1.26.0-next.21+7d1f7241fa3",
26
- "@theia/task": "1.26.0-next.21+7d1f7241fa3",
27
- "@theia/terminal": "1.26.0-next.21+7d1f7241fa3",
28
- "@theia/timeline": "1.26.0-next.21+7d1f7241fa3",
29
- "@theia/workspace": "1.26.0-next.21+7d1f7241fa3",
20
+ "@theia/navigator": "1.26.0-next.22+1265154246d",
21
+ "@theia/output": "1.26.0-next.22+1265154246d",
22
+ "@theia/plugin": "1.26.0-next.22+1265154246d",
23
+ "@theia/preferences": "1.26.0-next.22+1265154246d",
24
+ "@theia/scm": "1.26.0-next.22+1265154246d",
25
+ "@theia/search-in-workspace": "1.26.0-next.22+1265154246d",
26
+ "@theia/task": "1.26.0-next.22+1265154246d",
27
+ "@theia/terminal": "1.26.0-next.22+1265154246d",
28
+ "@theia/timeline": "1.26.0-next.22+1265154246d",
29
+ "@theia/workspace": "1.26.0-next.22+1265154246d",
30
30
  "@types/mime": "^2.0.1",
31
31
  "decompress": "^4.2.1",
32
32
  "escape-html": "^1.0.3",
@@ -91,5 +91,5 @@
91
91
  "nyc": {
92
92
  "extends": "../../configs/nyc.json"
93
93
  },
94
- "gitHead": "7d1f7241fa30f033a04e025501719d6dcdf9e549"
94
+ "gitHead": "1265154246d98e44c0e1ee479aa9d42b2615d9d1"
95
95
  }
@@ -20,6 +20,7 @@ import { UriComponents } from './uri-components';
20
20
  import { CompletionItemTag } from '../plugin/types-impl';
21
21
  import { Event as TheiaEvent } from '@theia/core/lib/common/event';
22
22
  import { URI } from '@theia/core/shared/vscode-uri';
23
+ import { SerializedRegExp } from './plugin-api-rpc';
23
24
 
24
25
  // Should contains internal Plugin API types
25
26
 
@@ -541,6 +542,11 @@ export interface CallHierarchyOutgoingCall {
541
542
  fromRanges: Range[];
542
543
  }
543
544
 
545
+ export interface LinkedEditingRanges {
546
+ ranges: Range[];
547
+ wordPattern?: SerializedRegExp;
548
+ }
549
+
544
550
  export interface SearchInWorkspaceResult {
545
551
  root: string;
546
552
  fileUri: string;
@@ -71,7 +71,8 @@ import {
71
71
  CommentThreadCollapsibleState,
72
72
  CommentThread,
73
73
  CommentThreadChangedEvent,
74
- CodeActionProviderDocumentation
74
+ CodeActionProviderDocumentation,
75
+ LinkedEditingRanges
75
76
  } from './plugin-api-rpc-model';
76
77
  import { ExtPluginApi } from './plugin-ext-api-contribution';
77
78
  import { KeysToAnyValues, KeysToKeysToAnyValue } from './types';
@@ -1483,6 +1484,7 @@ export interface LanguagesExt {
1483
1484
  $provideRootDefinition(handle: number, resource: UriComponents, location: Position, token: CancellationToken): Promise<CallHierarchyItem[] | undefined>;
1484
1485
  $provideCallers(handle: number, definition: CallHierarchyItem, token: CancellationToken): Promise<CallHierarchyIncomingCall[] | undefined>;
1485
1486
  $provideCallees(handle: number, definition: CallHierarchyItem, token: CancellationToken): Promise<CallHierarchyOutgoingCall[] | undefined>;
1487
+ $provideLinkedEditingRanges(handle: number, resource: UriComponents, position: Position, token: CancellationToken): Promise<LinkedEditingRanges | undefined>;
1486
1488
  $releaseCallHierarchy(handle: number, session?: string): Promise<boolean>;
1487
1489
  }
1488
1490
 
@@ -1531,6 +1533,7 @@ export interface LanguagesMain {
1531
1533
  $emitDocumentSemanticTokensEvent(eventHandle: number): void;
1532
1534
  $registerDocumentRangeSemanticTokensProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], legend: theia.SemanticTokensLegend): void;
1533
1535
  $registerCallHierarchyProvider(handle: number, selector: SerializedDocumentFilter[]): void;
1536
+ $registerLinkedEditingRangeProvider(handle: number, selector: SerializedDocumentFilter[]): void;
1534
1537
  }
1535
1538
 
1536
1539
  export interface WebviewInitData {
@@ -948,6 +948,32 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
948
948
  });
949
949
  }
950
950
 
951
+ // --- linked editing range
952
+
953
+ $registerLinkedEditingRangeProvider(handle: number, selector: SerializedDocumentFilter[]): void {
954
+ const languageSelector = this.toLanguageSelector(selector);
955
+ const linkedEditingRangeProvider = this.createLinkedEditingRangeProvider(handle);
956
+ this.register(handle,
957
+ (monaco.languages.registerLinkedEditingRangeProvider as RegistrationFunction<monaco.languages.LinkedEditingRangeProvider>)(languageSelector, linkedEditingRangeProvider)
958
+ );
959
+ }
960
+
961
+ protected createLinkedEditingRangeProvider(handle: number): monaco.languages.LinkedEditingRangeProvider {
962
+ return {
963
+ provideLinkedEditingRanges: async (model: monaco.editor.ITextModel, position: monaco.Position, token: CancellationToken):
964
+ Promise<monaco.languages.LinkedEditingRanges | undefined> => {
965
+ const res = await this.proxy.$provideLinkedEditingRanges(handle, model.uri, position, token);
966
+ if (res) {
967
+ return {
968
+ ranges: res.ranges,
969
+ wordPattern: reviveRegExp(res.wordPattern)
970
+ };
971
+ }
972
+ return undefined;
973
+ }
974
+ };
975
+ };
976
+
951
977
  }
952
978
 
953
979
  function reviveMarker(marker: MarkerData): vst.Diagnostic {
@@ -0,0 +1,48 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson 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 * as theia from '@theia/plugin';
18
+ import * as rpc from '../../common/plugin-api-rpc';
19
+ import { DocumentsExtImpl } from '../documents';
20
+ import { LinkedEditingRanges } from '../../common/plugin-api-rpc-model';
21
+ import { URI } from '@theia/core/shared/vscode-uri';
22
+ import { coalesce } from '../../common/arrays';
23
+ import { fromRange, toPosition } from '../type-converters';
24
+ import { serializeRegExp } from '../languages-utils';
25
+
26
+ export class LinkedEditingRangeAdapter {
27
+
28
+ constructor(
29
+ private readonly documents: DocumentsExtImpl,
30
+ private readonly provider: theia.LinkedEditingRangeProvider
31
+ ) { }
32
+
33
+ async provideRanges(resource: URI, position: rpc.Position, token: theia.CancellationToken): Promise<LinkedEditingRanges | undefined> {
34
+
35
+ const doc = this.documents.getDocument(resource);
36
+ const pos = toPosition(position);
37
+
38
+ const value = await this.provider.provideLinkedEditingRanges(doc, pos, token);
39
+ if (value && Array.isArray(value.ranges)) {
40
+ return {
41
+ ranges: coalesce(value.ranges.map(r => fromRange(r))),
42
+ wordPattern: serializeRegExp(value.wordPattern)
43
+ };
44
+ }
45
+ return undefined;
46
+ }
47
+
48
+ }
@@ -0,0 +1,55 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 Ericsson 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 * as theia from '@theia/plugin';
18
+ import { SerializedIndentationRule, SerializedOnEnterRule, SerializedRegExp } from '../common';
19
+
20
+ export function serializeEnterRules(rules?: theia.OnEnterRule[]): SerializedOnEnterRule[] | undefined {
21
+ if (typeof rules === 'undefined' || rules === null) {
22
+ return undefined;
23
+ }
24
+
25
+ return rules.map(r =>
26
+ ({
27
+ action: r.action,
28
+ beforeText: serializeRegExp(r.beforeText),
29
+ afterText: serializeRegExp(r.afterText)
30
+ } as SerializedOnEnterRule));
31
+ }
32
+
33
+ export function serializeRegExp(regexp?: RegExp): SerializedRegExp | undefined {
34
+ if (typeof regexp === 'undefined' || regexp === null) {
35
+ return undefined;
36
+ }
37
+
38
+ return {
39
+ pattern: regexp.source,
40
+ flags: (regexp.global ? 'g' : '') + (regexp.ignoreCase ? 'i' : '') + (regexp.multiline ? 'm' : '')
41
+ };
42
+ }
43
+
44
+ export function serializeIndentation(indentationRules?: theia.IndentationRule): SerializedIndentationRule | undefined {
45
+ if (typeof indentationRules === 'undefined' || indentationRules === null) {
46
+ return undefined;
47
+ }
48
+
49
+ return {
50
+ increaseIndentPattern: serializeRegExp(indentationRules.increaseIndentPattern),
51
+ decreaseIndentPattern: serializeRegExp(indentationRules.decreaseIndentPattern),
52
+ indentNextLinePattern: serializeRegExp(indentationRules.indentNextLinePattern),
53
+ unIndentedLinePattern: serializeRegExp(indentationRules.unIndentedLinePattern)
54
+ };
55
+ }
@@ -19,9 +19,6 @@ import {
19
19
  PLUGIN_RPC_CONTEXT,
20
20
  LanguagesMain,
21
21
  SerializedLanguageConfiguration,
22
- SerializedRegExp,
23
- SerializedOnEnterRule,
24
- SerializedIndentationRule,
25
22
  Position,
26
23
  Selection,
27
24
  RawColorInfo,
@@ -63,6 +60,7 @@ import {
63
60
  CallHierarchyItem,
64
61
  CallHierarchyIncomingCall,
65
62
  CallHierarchyOutgoingCall,
63
+ LinkedEditingRanges,
66
64
  } from '../common/plugin-api-rpc-model';
67
65
  import { CompletionAdapter } from './languages/completion';
68
66
  import { Diagnostics } from './languages/diagnostics';
@@ -94,6 +92,8 @@ import { BinaryBuffer } from '@theia/core/lib/common/buffer';
94
92
  import { DocumentSemanticTokensAdapter, DocumentRangeSemanticTokensAdapter } from './languages/semantic-highlighting';
95
93
  import { isReadonlyArray } from '../common/arrays';
96
94
  import { DisposableCollection } from '@theia/core/lib/common/disposable';
95
+ import { LinkedEditingRangeAdapter } from './languages/linked-editing-range';
96
+ import { serializeEnterRules, serializeIndentation, serializeRegExp } from './languages-utils';
97
97
 
98
98
  type Adapter = CompletionAdapter |
99
99
  SignatureHelpAdapter |
@@ -118,7 +118,8 @@ type Adapter = CompletionAdapter |
118
118
  RenameAdapter |
119
119
  CallHierarchyAdapter |
120
120
  DocumentRangeSemanticTokensAdapter |
121
- DocumentSemanticTokensAdapter;
121
+ DocumentSemanticTokensAdapter |
122
+ LinkedEditingRangeAdapter;
122
123
 
123
124
  export class LanguagesExtImpl implements LanguagesExt {
124
125
 
@@ -630,6 +631,19 @@ export class LanguagesExtImpl implements LanguagesExt {
630
631
  }
631
632
  // ### Call Hierarchy Provider end
632
633
 
634
+ // ### Linked Editing Range Provider begin
635
+ registerLinkedEditingRangeProvider(selector: theia.DocumentSelector, provider: theia.LinkedEditingRangeProvider): theia.Disposable {
636
+ const handle = this.addNewAdapter(new LinkedEditingRangeAdapter(this.documents, provider));
637
+ this.proxy.$registerLinkedEditingRangeProvider(handle, this.transformDocumentSelector(selector));
638
+ return this.createDisposable(handle);
639
+ }
640
+
641
+ $provideLinkedEditingRanges(handle: number, resource: UriComponents, position: Position, token: theia.CancellationToken): Promise<LinkedEditingRanges | undefined> {
642
+ return this.withAdapter(handle, LinkedEditingRangeAdapter, async adapter => adapter.provideRanges(URI.revive(resource), position, token), undefined);
643
+ }
644
+
645
+ // ### Linked Editing Range Provider end
646
+
633
647
  // #region semantic coloring
634
648
 
635
649
  registerDocumentSemanticTokensProvider(selector: theia.DocumentSelector, provider: theia.DocumentSemanticTokensProvider, legend: theia.SemanticTokensLegend,
@@ -671,43 +685,7 @@ export class LanguagesExtImpl implements LanguagesExt {
671
685
  // #endregion
672
686
  }
673
687
 
674
- function serializeEnterRules(rules?: theia.OnEnterRule[]): SerializedOnEnterRule[] | undefined {
675
- if (typeof rules === 'undefined' || rules === null) {
676
- return undefined;
677
- }
678
-
679
- return rules.map(r =>
680
- ({
681
- action: r.action,
682
- beforeText: serializeRegExp(r.beforeText),
683
- afterText: serializeRegExp(r.afterText)
684
- } as SerializedOnEnterRule));
685
- }
686
-
687
- function serializeRegExp(regexp?: RegExp): SerializedRegExp | undefined {
688
- if (typeof regexp === 'undefined' || regexp === null) {
689
- return undefined;
690
- }
691
-
692
- return {
693
- pattern: regexp.source,
694
- flags: (regexp.global ? 'g' : '') + (regexp.ignoreCase ? 'i' : '') + (regexp.multiline ? 'm' : '')
695
- };
696
- }
697
-
698
- function serializeIndentation(indentationRules?: theia.IndentationRule): SerializedIndentationRule | undefined {
699
- if (typeof indentationRules === 'undefined' || indentationRules === null) {
700
- return undefined;
701
- }
702
-
703
- return {
704
- increaseIndentPattern: serializeRegExp(indentationRules.increaseIndentPattern),
705
- decreaseIndentPattern: serializeRegExp(indentationRules.decreaseIndentPattern),
706
- indentNextLinePattern: serializeRegExp(indentationRules.indentNextLinePattern),
707
- unIndentedLinePattern: serializeRegExp(indentationRules.unIndentedLinePattern)
708
- };
709
- }
710
-
711
688
  function getPluginLabel(pluginInfo: PluginInfo): string {
712
689
  return pluginInfo.displayName || pluginInfo.name;
713
690
  }
691
+
@@ -140,7 +140,8 @@ import {
140
140
  SourceControlInputBoxValidationType,
141
141
  URI,
142
142
  FileDecoration,
143
- ExtensionMode
143
+ ExtensionMode,
144
+ LinkedEditingRanges
144
145
  } from './types-impl';
145
146
  import { AuthenticationExtImpl } from './authentication-ext';
146
147
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -779,6 +780,9 @@ export function createAPIFactory(
779
780
  },
780
781
  registerCallHierarchyProvider(selector: theia.DocumentSelector, provider: theia.CallHierarchyProvider): theia.Disposable {
781
782
  return languagesExt.registerCallHierarchyProvider(selector, provider);
783
+ },
784
+ registerLinkedEditingRangeProvider(selector: theia.DocumentSelector, provider: theia.LinkedEditingRangeProvider): theia.Disposable {
785
+ return languagesExt.registerLinkedEditingRangeProvider(selector, provider);
782
786
  }
783
787
  };
784
788
 
@@ -1035,7 +1039,8 @@ export function createAPIFactory(
1035
1039
  SourceControlInputBoxValidationType,
1036
1040
  FileDecoration,
1037
1041
  CancellationError,
1038
- ExtensionMode
1042
+ ExtensionMode,
1043
+ LinkedEditingRanges
1039
1044
  };
1040
1045
  };
1041
1046
  }
@@ -2486,6 +2486,18 @@ export class CallHierarchyOutgoingCall {
2486
2486
  }
2487
2487
  }
2488
2488
 
2489
+ @es5ClassCompat
2490
+ export class LinkedEditingRanges {
2491
+
2492
+ ranges: theia.Range[];
2493
+ wordPattern?: RegExp;
2494
+
2495
+ constructor(ranges: Range[], wordPattern?: RegExp) {
2496
+ this.ranges = ranges;
2497
+ this.wordPattern = wordPattern;
2498
+ }
2499
+ }
2500
+
2489
2501
  @es5ClassCompat
2490
2502
  export class TimelineItem {
2491
2503
  timestamp: number;