@theia/plugin-ext 1.26.0-next.23 → 1.26.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 (75) hide show
  1. package/lib/common/paths-util.js +1 -1
  2. package/lib/common/paths-util.js.map +1 -1
  3. package/lib/common/plugin-api-rpc-model.d.ts +7 -12
  4. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  5. package/lib/common/plugin-api-rpc-model.js +3 -1
  6. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  7. package/lib/common/plugin-api-rpc.d.ts +18 -2
  8. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  9. package/lib/common/plugin-api-rpc.js.map +1 -1
  10. package/lib/main/browser/documents-main.d.ts.map +1 -1
  11. package/lib/main/browser/documents-main.js +2 -0
  12. package/lib/main/browser/documents-main.js.map +1 -1
  13. package/lib/main/browser/languages-main.d.ts +6 -2
  14. package/lib/main/browser/languages-main.d.ts.map +1 -1
  15. package/lib/main/browser/languages-main.js +15 -0
  16. package/lib/main/browser/languages-main.js.map +1 -1
  17. package/lib/main/browser/status-bar-message-registry-main.d.ts +2 -1
  18. package/lib/main/browser/status-bar-message-registry-main.d.ts.map +1 -1
  19. package/lib/main/browser/status-bar-message-registry-main.js.map +1 -1
  20. package/lib/main/browser/view/tree-view-widget.js +2 -2
  21. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  22. package/lib/plugin/documents.d.ts.map +1 -1
  23. package/lib/plugin/documents.js +3 -1
  24. package/lib/plugin/documents.js.map +1 -1
  25. package/lib/plugin/file-system-event-service-ext-impl.d.ts +1 -1
  26. package/lib/plugin/file-system-event-service-ext-impl.d.ts.map +1 -1
  27. package/lib/plugin/file-system-event-service-ext-impl.js +1 -1
  28. package/lib/plugin/file-system-event-service-ext-impl.js.map +1 -1
  29. package/lib/plugin/languages.d.ts +4 -1
  30. package/lib/plugin/languages.d.ts.map +1 -1
  31. package/lib/plugin/languages.js +117 -0
  32. package/lib/plugin/languages.js.map +1 -1
  33. package/lib/plugin/markdown-string.d.ts +23 -9
  34. package/lib/plugin/markdown-string.d.ts.map +1 -1
  35. package/lib/plugin/markdown-string.js +97 -26
  36. package/lib/plugin/markdown-string.js.map +1 -1
  37. package/lib/plugin/plugin-context.d.ts.map +1 -1
  38. package/lib/plugin/plugin-context.js +6 -1
  39. package/lib/plugin/plugin-context.js.map +1 -1
  40. package/lib/plugin/scm.js +1 -1
  41. package/lib/plugin/scm.js.map +1 -1
  42. package/lib/plugin/status-bar/status-bar-item.d.ts +2 -2
  43. package/lib/plugin/status-bar/status-bar-item.d.ts.map +1 -1
  44. package/lib/plugin/status-bar/status-bar-item.js.map +1 -1
  45. package/lib/plugin/type-converters.d.ts +6 -5
  46. package/lib/plugin/type-converters.d.ts.map +1 -1
  47. package/lib/plugin/type-converters.js +12 -6
  48. package/lib/plugin/type-converters.js.map +1 -1
  49. package/lib/plugin/type-converters.spec.js +16 -15
  50. package/lib/plugin/type-converters.spec.js.map +1 -1
  51. package/lib/plugin/types-impl.d.ts +16 -8
  52. package/lib/plugin/types-impl.d.ts.map +1 -1
  53. package/lib/plugin/types-impl.js +14 -7
  54. package/lib/plugin/types-impl.js.map +1 -1
  55. package/lib/plugin/workspace.js +1 -1
  56. package/lib/plugin/workspace.js.map +1 -1
  57. package/package.json +23 -23
  58. package/src/common/paths-util.ts +1 -1
  59. package/src/common/plugin-api-rpc-model.ts +7 -12
  60. package/src/common/plugin-api-rpc.ts +21 -2
  61. package/src/main/browser/documents-main.ts +2 -0
  62. package/src/main/browser/languages-main.ts +17 -2
  63. package/src/main/browser/status-bar-message-registry-main.ts +2 -1
  64. package/src/main/browser/view/tree-view-widget.tsx +2 -2
  65. package/src/plugin/documents.ts +9 -8
  66. package/src/plugin/file-system-event-service-ext-impl.ts +1 -1
  67. package/src/plugin/languages.ts +124 -3
  68. package/src/plugin/markdown-string.ts +83 -26
  69. package/src/plugin/plugin-context.ts +9 -2
  70. package/src/plugin/scm.ts +1 -1
  71. package/src/plugin/status-bar/status-bar-item.ts +3 -3
  72. package/src/plugin/type-converters.spec.ts +20 -17
  73. package/src/plugin/type-converters.ts +17 -12
  74. package/src/plugin/types-impl.ts +19 -11
  75. package/src/plugin/workspace.ts +1 -1
@@ -19,6 +19,7 @@ import * as types from '../../plugin/types-impl';
19
19
  import { StatusBarMessageRegistryMain } from '../../common/plugin-api-rpc';
20
20
  import { StatusBar, StatusBarAlignment, StatusBarEntry } from '@theia/core/lib/browser/status-bar/status-bar';
21
21
  import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
22
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
22
23
 
23
24
  export class StatusBarMessageRegistryMainImpl implements StatusBarMessageRegistryMain, Disposable {
24
25
  private readonly delegate: StatusBar;
@@ -45,7 +46,7 @@ export class StatusBarMessageRegistryMainImpl implements StatusBarMessageRegistr
45
46
  alignment: number,
46
47
  color: string | undefined,
47
48
  backgroundColor: string | undefined,
48
- tooltip: string | undefined,
49
+ tooltip: string | MarkdownString | undefined,
49
50
  command: string | undefined,
50
51
  accessibilityInformation: types.AccessibilityInformation,
51
52
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -43,7 +43,7 @@ import { View } from '../../../common/plugin-protocol';
43
43
  import CoreURI from '@theia/core/lib/common/uri';
44
44
  import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
45
45
  import * as markdownit from '@theia/core/shared/markdown-it';
46
- import { isMarkdownString } from '../../../plugin/markdown-string';
46
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
47
47
  import { LabelParser } from '@theia/core/lib/browser/label-parser';
48
48
  import { AccessibilityInformation } from '@theia/plugin';
49
49
 
@@ -312,7 +312,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
312
312
  };
313
313
  }
314
314
 
315
- if (node.tooltip && isMarkdownString(node.tooltip)) {
315
+ if (node.tooltip && MarkdownString.is(node.tooltip)) {
316
316
  // Render markdown in custom tooltip
317
317
  const tooltip = this.markdownIt.render(node.tooltip.value);
318
318
 
@@ -163,7 +163,8 @@ export class DocumentsExtImpl implements DocumentsExt {
163
163
  data.acceptIsDirty(isDirty);
164
164
  this._onDidChangeDocument.fire({
165
165
  document: data.document,
166
- contentChanges: []
166
+ contentChanges: [],
167
+ reason: undefined,
167
168
  });
168
169
  }
169
170
  $acceptModelChanged(strUrl: UriComponents, e: ModelChangedEvent, isDirty: boolean): void {
@@ -177,13 +178,13 @@ export class DocumentsExtImpl implements DocumentsExt {
177
178
  data.onEvents(e);
178
179
  this._onDidChangeDocument.fire({
179
180
  document: data.document,
180
- contentChanges: e.changes.map(change =>
181
- ({
182
- range: Converter.toRange(change.range),
183
- rangeOffset: change.rangeOffset,
184
- rangeLength: change.rangeLength,
185
- text: change.text
186
- }))
181
+ reason: e.reason,
182
+ contentChanges: e.changes.map(change => ({
183
+ range: Converter.toRange(change.range),
184
+ rangeOffset: change.rangeOffset,
185
+ rangeLength: change.rangeLength,
186
+ text: change.text
187
+ }))
187
188
  });
188
189
  }
189
190
  getAllDocumentData(): DocumentDataExt[] {
@@ -29,7 +29,7 @@
29
29
  /* eslint-disable @typescript-eslint/tslint/config */
30
30
 
31
31
  import { Emitter, WaitUntilEvent, AsyncEmitter } from '@theia/core/lib/common/event';
32
- import { IRelativePattern, parse } from '@theia/callhierarchy/lib/common/glob';
32
+ import { IRelativePattern, parse } from '@theia/core/lib/common/glob';
33
33
  import { UriComponents } from '@theia/core/shared/vscode-uri';
34
34
  import { Disposable, URI, WorkspaceEdit } from './types-impl';
35
35
  import { EditorsAndDocumentsExtImpl as ExtHostDocumentsAndEditors } from './editors-and-documents';
@@ -23,13 +23,14 @@ import {
23
23
  Selection,
24
24
  RawColorInfo,
25
25
  WorkspaceEditDto,
26
- PluginInfo
26
+ PluginInfo,
27
+ Plugin,
27
28
  } from '../common/plugin-api-rpc';
28
29
  import { RPCProtocol } from '../common/rpc-protocol';
29
30
  import * as theia from '@theia/plugin';
30
31
  import { DocumentsExtImpl } from './documents';
31
32
  import { PluginModel } from '../common/plugin-protocol';
32
- import { Disposable, URI } from './types-impl';
33
+ import { Disposable, URI, LanguageStatusSeverity } from './types-impl';
33
34
  import { UriComponents } from '../common/uri-components';
34
35
  import {
35
36
  CodeActionProviderDocumentation,
@@ -91,7 +92,8 @@ 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';
94
- import { DisposableCollection } from '@theia/core/lib/common/disposable';
95
+ import { DisposableCollection, disposableTimeout, Disposable as TheiaDisposable } from '@theia/core/lib/common/disposable';
96
+ import { Severity } from '@theia/core/lib/common/severity';
95
97
  import { LinkedEditingRangeAdapter } from './languages/linked-editing-range';
96
98
  import { serializeEnterRules, serializeIndentation, serializeRegExp } from './languages-utils';
97
99
 
@@ -682,6 +684,125 @@ export class LanguagesExtImpl implements LanguagesExt {
682
684
  return this.withAdapter(handle, DocumentRangeSemanticTokensAdapter, adapter => adapter.provideDocumentRangeSemanticTokens(URI.revive(resource), range, token), null);
683
685
  }
684
686
 
687
+ // Copied from https://github.com/microsoft/vscode/blob/7d9b1c37f8e5ae3772782ba3b09d827eb3fdd833/src/vs/workbench/api/common/extHostLanguages.ts
688
+ protected statusItemHandlePool = 0;
689
+ protected readonly statusItemIds = new Set<string>();
690
+ createLanguageStatusItem(extension: Plugin, id: string, selector: theia.DocumentSelector): theia.LanguageStatusItem {
691
+
692
+ const handle = this.statusItemHandlePool++;
693
+ const proxy = this.proxy;
694
+ const ids = this.statusItemIds;
695
+
696
+ // enforce extension unique identifier
697
+ const fullyQualifiedId = `${extension.model.id}/${id}`;
698
+ if (ids.has(fullyQualifiedId)) {
699
+ throw new Error(`LanguageStatusItem with id '${id}' ALREADY exists`);
700
+ }
701
+ ids.add(fullyQualifiedId);
702
+
703
+ const data: Omit<theia.LanguageStatusItem, 'dispose'> = {
704
+ selector,
705
+ id,
706
+ name: extension.model.displayName ?? extension.model.name,
707
+ severity: LanguageStatusSeverity.Information,
708
+ command: undefined,
709
+ text: '',
710
+ detail: '',
711
+ busy: false
712
+ };
713
+
714
+ let soonHandle: TheiaDisposable | undefined;
715
+ const commandDisposables = new DisposableCollection();
716
+ const updateAsync = () => {
717
+ soonHandle?.dispose();
718
+ soonHandle = disposableTimeout(() => {
719
+ commandDisposables.dispose();
720
+ commandDisposables.push({ dispose: () => { } }); // Mark disposable as undisposed.
721
+ this.proxy.$setLanguageStatus(handle, {
722
+ id: fullyQualifiedId,
723
+ name: data.name ?? extension.model.displayName ?? extension.model.name,
724
+ source: extension.model.displayName ?? extension.model.name,
725
+ selector: this.transformDocumentSelector(data.selector),
726
+ label: data.text,
727
+ detail: data.detail ?? '',
728
+ severity: data.severity === LanguageStatusSeverity.Error ? Severity.Error : data.severity === LanguageStatusSeverity.Warning ? Severity.Warning : Severity.Info,
729
+ command: data.command && this.commands.converter.toSafeCommand(data.command, commandDisposables),
730
+ accessibilityInfo: data.accessibilityInformation,
731
+ busy: data.busy
732
+ });
733
+ }, 0);
734
+ };
735
+
736
+ const result: theia.LanguageStatusItem = {
737
+ dispose(): void {
738
+ commandDisposables.dispose();
739
+ soonHandle?.dispose();
740
+ proxy.$removeLanguageStatus(handle);
741
+ ids.delete(fullyQualifiedId);
742
+ },
743
+ get id(): string {
744
+ return data.id;
745
+ },
746
+ get name(): string | undefined {
747
+ return data.name;
748
+ },
749
+ set name(value) {
750
+ data.name = value;
751
+ updateAsync();
752
+ },
753
+ get selector(): theia.DocumentSelector {
754
+ return data.selector;
755
+ },
756
+ set selector(value) {
757
+ data.selector = value;
758
+ updateAsync();
759
+ },
760
+ get text(): string {
761
+ return data.text;
762
+ },
763
+ set text(value) {
764
+ data.text = value;
765
+ updateAsync();
766
+ },
767
+ get detail(): string | undefined {
768
+ return data.detail;
769
+ },
770
+ set detail(value) {
771
+ data.detail = value;
772
+ updateAsync();
773
+ },
774
+ get severity(): theia.LanguageStatusSeverity {
775
+ return data.severity;
776
+ },
777
+ set severity(value) {
778
+ data.severity = value;
779
+ updateAsync();
780
+ },
781
+ get accessibilityInformation(): theia.AccessibilityInformation | undefined {
782
+ return data.accessibilityInformation;
783
+ },
784
+ set accessibilityInformation(value) {
785
+ data.accessibilityInformation = value;
786
+ updateAsync();
787
+ },
788
+ get command(): theia.Command | undefined {
789
+ return data.command;
790
+ },
791
+ set command(value) {
792
+ data.command = value;
793
+ updateAsync();
794
+ },
795
+ get busy(): boolean {
796
+ return data.busy;
797
+ },
798
+ set busy(value: boolean) {
799
+ data.busy = value;
800
+ updateAsync();
801
+ }
802
+ };
803
+ updateAsync();
804
+ return result;
805
+ }
685
806
  // #endregion
686
807
  }
687
808
 
@@ -14,45 +14,102 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { MarkdownString as IMarkdownString } from '../common/plugin-api-rpc-model';
17
+ import { Mutable } from '@theia/core';
18
+ import { MarkdownStringImpl as BaseMarkdownString, MarkdownString as MarkdownStringInterface } from '@theia/core/lib/common/markdown-rendering';
19
+ import * as pluginAPI from '@theia/plugin';
20
+ import { es5ClassCompat } from '../common/types';
21
+ import { URI } from './types-impl';
18
22
 
19
- export class MarkdownString {
23
+ // Copied from https://github.com/microsoft/vscode/blob/7d9b1c37f8e5ae3772782ba3b09d827eb3fdd833/src/vs/workbench/api/common/extHostTypes.ts
20
24
 
21
- value: string;
22
- isTrusted?: boolean;
25
+ @es5ClassCompat
26
+ export class MarkdownString implements pluginAPI.MarkdownString {
23
27
 
24
- constructor(value?: string) {
25
- this.value = value || '';
28
+ readonly #delegate: BaseMarkdownString;
29
+
30
+ /**
31
+ * @returns whether the thing is a markdown string implementation with helper methods.
32
+ */
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ static isMarkdownString(thing: any): thing is pluginAPI.MarkdownString {
35
+ if (thing instanceof MarkdownString) {
36
+ return true;
37
+ }
38
+ return thing && thing.appendCodeblock && thing.appendMarkdown && thing.appendText && (thing.value !== undefined);
39
+ }
40
+
41
+ constructor(value?: string, supportThemeIcons: boolean = false) {
42
+ this.#delegate = new BaseMarkdownString(value, { supportThemeIcons });
43
+ }
44
+
45
+ get value(): string {
46
+ return this.#delegate.value;
47
+ }
48
+ set value(value: string) {
49
+ this.#delegate.value = value;
50
+ }
51
+
52
+ get isTrusted(): boolean | undefined {
53
+ return this.#delegate.isTrusted;
54
+ }
55
+
56
+ set isTrusted(value: boolean | undefined) {
57
+ this.#delegate.isTrusted = value;
58
+ }
59
+
60
+ get supportThemeIcons(): boolean | undefined {
61
+ return this.#delegate.supportThemeIcons;
26
62
  }
27
63
 
28
- appendText(value: string): MarkdownString {
29
- // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
30
- this.value += value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&');
64
+ set supportThemeIcons(value: boolean | undefined) {
65
+ this.#delegate.supportThemeIcons = value;
66
+ }
67
+
68
+ get supportHtml(): boolean | undefined {
69
+ return this.#delegate.supportHtml;
70
+ }
71
+
72
+ set supportHtml(value: boolean | undefined) {
73
+ this.#delegate.supportHtml = value;
74
+ }
75
+
76
+ get baseUri(): pluginAPI.Uri | undefined {
77
+ return URI.revive(this.#delegate.baseUri);
78
+ }
79
+
80
+ set baseUri(value: pluginAPI.Uri | undefined) {
81
+ this.#delegate.baseUri = value;
82
+ }
83
+
84
+ appendText(value: string): pluginAPI.MarkdownString {
85
+ this.#delegate.appendText(value);
31
86
  return this;
32
87
  }
33
88
 
34
- appendMarkdown(value: string): MarkdownString {
35
- this.value += value;
89
+ appendMarkdown(value: string): pluginAPI.MarkdownString {
90
+ this.#delegate.appendMarkdown(value);
36
91
  return this;
37
92
  }
38
93
 
39
- appendCodeblock(code: string, language: string = ''): MarkdownString {
40
- this.value += '\n```';
41
- this.value += language;
42
- this.value += '\n';
43
- this.value += code;
44
- this.value += '\n```\n';
94
+ appendCodeblock(value: string, language?: string): pluginAPI.MarkdownString {
95
+ this.#delegate.appendCodeblock(language ?? '', value);
45
96
  return this;
46
97
  }
47
- }
48
98
 
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- export function isMarkdownString(thing: any): thing is IMarkdownString {
51
- if (thing instanceof MarkdownString) {
52
- return true;
53
- } else if (thing && typeof thing === 'object') {
54
- return typeof (<MarkdownString>thing).value === 'string'
55
- && (typeof (<MarkdownString>thing).isTrusted === 'boolean' || (<MarkdownString>thing).isTrusted === undefined);
99
+ toJSON(): MarkdownStringInterface {
100
+ const plainObject: Mutable<MarkdownStringInterface> = { value: this.value };
101
+ if (this.isTrusted !== undefined) {
102
+ plainObject.isTrusted = this.isTrusted;
103
+ }
104
+ if (this.supportThemeIcons !== undefined) {
105
+ plainObject.supportThemeIcons = this.supportThemeIcons;
106
+ }
107
+ if (this.supportHtml !== undefined) {
108
+ plainObject.supportHtml = this.supportHtml;
109
+ }
110
+ if (this.baseUri !== undefined) {
111
+ plainObject.baseUri = this.baseUri.toJSON();
112
+ }
113
+ return plainObject;
56
114
  }
57
- return false;
58
115
  }
@@ -141,7 +141,9 @@ import {
141
141
  URI,
142
142
  FileDecoration,
143
143
  ExtensionMode,
144
- LinkedEditingRanges
144
+ LinkedEditingRanges,
145
+ LanguageStatusSeverity,
146
+ TextDocumentChangeReason
145
147
  } from './types-impl';
146
148
  import { AuthenticationExtImpl } from './authentication-ext';
147
149
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -156,7 +158,7 @@ import { LanguagesExtImpl } from './languages';
156
158
  import { fromDocumentSelector, pluginToPluginInfo, fromGlobPattern } from './type-converters';
157
159
  import { DialogsExtImpl } from './dialogs';
158
160
  import { NotificationExtImpl } from './notification';
159
- import { score } from '@theia/callhierarchy/lib/common/language-selector';
161
+ import { score } from '@theia/editor/lib/common/language-selector';
160
162
  import { MarkdownString } from './markdown-string';
161
163
  import { TreeViewsExtImpl } from './tree/tree-views';
162
164
  import { ConnectionImpl } from '../common/connection';
@@ -783,6 +785,9 @@ export function createAPIFactory(
783
785
  },
784
786
  registerLinkedEditingRangeProvider(selector: theia.DocumentSelector, provider: theia.LinkedEditingRangeProvider): theia.Disposable {
785
787
  return languagesExt.registerLinkedEditingRangeProvider(selector, provider);
788
+ },
789
+ createLanguageStatusItem(id: string, selector: theia.DocumentSelector): theia.LanguageStatusItem {
790
+ return languagesExt.createLanguageStatusItem(plugin, id, selector);
786
791
  }
787
792
  };
788
793
 
@@ -959,6 +964,7 @@ export function createAPIFactory(
959
964
  DebugConsoleMode,
960
965
  DiagnosticSeverity,
961
966
  DiagnosticRelatedInformation,
967
+ LanguageStatusSeverity,
962
968
  Location,
963
969
  LogLevel,
964
970
  DiagnosticTag,
@@ -1035,6 +1041,7 @@ export function createAPIFactory(
1035
1041
  SemanticTokens,
1036
1042
  SemanticTokensEdits,
1037
1043
  SemanticTokensEdit,
1044
+ TextDocumentChangeReason,
1038
1045
  ColorThemeKind,
1039
1046
  SourceControlInputBoxValidationType,
1040
1047
  FileDecoration,
package/src/plugin/scm.ts CHANGED
@@ -37,7 +37,7 @@ import { Command } from '../common/plugin-api-rpc-model';
37
37
  import { RPCProtocol } from '../common/rpc-protocol';
38
38
  import { URI } from './types-impl';
39
39
  import { ScmCommandArg } from '../common/plugin-api-rpc';
40
- import { sep } from '@theia/callhierarchy/lib/common/paths';
40
+ import { sep } from '@theia/core/lib/common/paths';
41
41
  type ProviderHandle = number;
42
42
  type GroupHandle = number;
43
43
  type ResourceStateHandle = number;
@@ -33,7 +33,7 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
33
33
 
34
34
  private _name: string | undefined;
35
35
  private _text: string;
36
- private _tooltip: string;
36
+ private _tooltip: string | theia.MarkdownString | undefined;
37
37
  private _color: string | ThemeColor | undefined;
38
38
  private _backgroundColor: ThemeColor | undefined;
39
39
  private _command: string | theia.Command;
@@ -74,7 +74,7 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
74
74
  return this._text;
75
75
  }
76
76
 
77
- public get tooltip(): string {
77
+ public get tooltip(): string | theia.MarkdownString | undefined {
78
78
  return this._tooltip;
79
79
  }
80
80
 
@@ -104,7 +104,7 @@ export class StatusBarItemImpl implements theia.StatusBarItem {
104
104
  this.update();
105
105
  }
106
106
 
107
- public set tooltip(tooltip: string) {
107
+ public set tooltip(tooltip: string | theia.MarkdownString | undefined) {
108
108
  this._tooltip = tooltip;
109
109
  this.update();
110
110
  }
@@ -19,7 +19,8 @@ import * as Converter from './type-converters';
19
19
  import * as theia from '@theia/plugin';
20
20
  import * as types from './types-impl';
21
21
  import * as model from '../common/plugin-api-rpc-model';
22
- import { MarkdownString, isMarkdownString } from './markdown-string';
22
+ import { MarkdownString } from './markdown-string';
23
+ import { MarkdownString as MarkdownStringInterface } from '@theia/core/lib/common/markdown-rendering';
23
24
  import { TaskDto } from '../common/plugin-api-rpc';
24
25
  import { TaskGroup } from './types-impl';
25
26
 
@@ -63,7 +64,7 @@ describe('Type converters:', () => {
63
64
  const markdownString = new MarkdownString('**test**');
64
65
 
65
66
  // when
66
- const result = isMarkdownString(markdownString);
67
+ const result = MarkdownStringInterface.is(markdownString);
67
68
 
68
69
  // then
69
70
  assert.deepStrictEqual(result !== false, true);
@@ -74,7 +75,7 @@ describe('Type converters:', () => {
74
75
  const markdownObject = { value: '*test*' };
75
76
 
76
77
  // when
77
- const result = isMarkdownString(markdownObject);
78
+ const result = MarkdownStringInterface.is(markdownObject);
78
79
 
79
80
  // then
80
81
  assert.deepStrictEqual(result !== false, true);
@@ -85,7 +86,7 @@ describe('Type converters:', () => {
85
86
  const markdownObject = { field1: 5, value: '*test*', field2: 'test' };
86
87
 
87
88
  // when
88
- const result = isMarkdownString(markdownObject);
89
+ const result = MarkdownStringInterface.is(markdownObject);
89
90
 
90
91
  // then
91
92
  assert.deepStrictEqual(result !== false, true);
@@ -96,7 +97,7 @@ describe('Type converters:', () => {
96
97
  const nonMarkdownObject = { field1: 5, field2: 'test' };
97
98
 
98
99
  // when
99
- const result = isMarkdownString(nonMarkdownObject);
100
+ const result = MarkdownStringInterface.is(nonMarkdownObject);
100
101
 
101
102
  // then
102
103
  assert.deepStrictEqual(result === false, true);
@@ -107,7 +108,7 @@ describe('Type converters:', () => {
107
108
  const nonMarkdownObject = { isTrusted: true, field1: 5, field2: 'test' };
108
109
 
109
110
  // when
110
- const result = isMarkdownString(nonMarkdownObject);
111
+ const result = MarkdownStringInterface.is(nonMarkdownObject);
111
112
 
112
113
  // then
113
114
  assert.deepStrictEqual(result === false, true);
@@ -125,10 +126,11 @@ describe('Type converters:', () => {
125
126
 
126
127
  it('should convert plugin markdown to model markdown', () => {
127
128
  // when
128
- const result = { ...Converter.fromMarkdown(pluginMarkdown) };
129
+ const result = Converter.fromMarkdown(pluginMarkdown);
129
130
 
130
131
  // then
131
- assert.deepStrictEqual(result, modelMarkdown);
132
+ assert.deepStrictEqual(result, { ...modelMarkdown, supportThemeIcons: false, supportHtml: false },
133
+ 'The implementation includes an explicit default `false` for `supportThemeIcons` and `supportHtml`');
132
134
  });
133
135
 
134
136
  it('should convert string to model markdown', () => {
@@ -153,20 +155,21 @@ describe('Type converters:', () => {
153
155
  const markups: (theia.MarkdownString | theia.MarkedString)[] = [
154
156
  pluginMarkdown,
155
157
  aStringWithMarkdown,
156
- codeblock
158
+ codeblock,
159
+ new MarkdownString('hello', true),
157
160
  ];
158
161
 
159
162
  // when
160
- const result: model.MarkdownString[] = Converter.fromManyMarkdown(markups)
161
- // convert to vanilla JS Object for deepStrictEqual comparison:
162
- .map(md => ({ ...md }));
163
-
163
+ const result: model.MarkdownString[] = Converter.fromManyMarkdown(markups);
164
164
  // then
165
165
  assert.deepStrictEqual(Array.isArray(result), true);
166
- assert.deepStrictEqual(result.length, 3);
167
- assert.deepStrictEqual(result[0], modelMarkdown);
168
- assert.deepStrictEqual(result[1], modelMarkdown);
169
- assert.deepStrictEqual(result[2], modelMarkdownWithCode);
166
+ assert.deepStrictEqual(result.length, 4);
167
+ assert.deepStrictEqual(result[0], { ...modelMarkdown, supportThemeIcons: false, supportHtml: false, },
168
+ 'MarkdownString implementation includes default value for `supportThemeIcons` and `supportHtml`');
169
+ assert.deepStrictEqual(result[1], modelMarkdown, 'Strings should be converted to Markdown.');
170
+ assert.deepStrictEqual(result[2], modelMarkdownWithCode, 'Objects matching the interface should be unchanged');
171
+ assert.deepStrictEqual(result[3], { value: 'hello', supportThemeIcons: true, supportHtml: false },
172
+ 'The constructor argument to MarkdownString for theme icons is respected.');
170
173
  });
171
174
  });
172
175
 
@@ -22,11 +22,12 @@ import {
22
22
  DecorationOptions, EditorPosition, Plugin, Position, WorkspaceTextEditDto, WorkspaceFileEditDto, Selection, TaskDto, WorkspaceEditDto
23
23
  } from '../common/plugin-api-rpc';
24
24
  import * as model from '../common/plugin-api-rpc-model';
25
- import { LanguageFilter, LanguageSelector, RelativePattern } from '@theia/callhierarchy/lib/common/language-selector';
26
- import { isMarkdownString, MarkdownString } from './markdown-string';
25
+ import { LanguageFilter, LanguageSelector, RelativePattern } from '@theia/editor/lib/common/language-selector';
26
+ import { MarkdownString as PluginMarkdownStringImpl } from './markdown-string';
27
27
  import * as types from './types-impl';
28
28
  import { UriComponents } from '../common/uri-components';
29
29
  import { isReadonlyArray } from '../common/arrays';
30
+ import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/markdown-rendering';
30
31
 
31
32
  const SIDE_GROUP = -2;
32
33
  const ACTIVE_GROUP = -1;
@@ -172,7 +173,7 @@ export function fromRangeOrRangeWithMessage(ranges: theia.Range[] | theia.Decora
172
173
  }
173
174
  }
174
175
 
175
- export function fromManyMarkdown(markup: (theia.MarkdownString | theia.MarkedString)[]): model.MarkdownString[] {
176
+ export function fromManyMarkdown(markup: (theia.MarkdownString | theia.MarkedString)[]): MarkdownStringDTO[] {
176
177
  return markup.map(fromMarkdown);
177
178
  }
178
179
 
@@ -188,23 +189,27 @@ function isCodeblock(thing: any): thing is Codeblock {
188
189
  && typeof (<Codeblock>thing).value === 'string';
189
190
  }
190
191
 
191
- export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): model.MarkdownString {
192
+ export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
192
193
  if (isCodeblock(markup)) {
193
194
  const { language, value } = markup;
194
195
  return { value: '```' + language + '\n' + value + '\n```\n' };
195
- } else if (isMarkdownString(markup)) {
196
+ } else if (markup instanceof PluginMarkdownStringImpl) {
197
+ return markup.toJSON();
198
+ } else if (MarkdownStringDTO.is(markup)) {
196
199
  return markup;
197
200
  } else if (typeof markup === 'string') {
198
- return { value: <string>markup };
201
+ return { value: markup };
199
202
  } else {
200
203
  return { value: '' };
201
204
  }
202
205
  }
203
206
 
204
- export function toMarkdown(value: model.MarkdownString): MarkdownString {
205
- const ret = new MarkdownString(value.value);
206
- ret.isTrusted = value.isTrusted;
207
- return ret;
207
+ export function toMarkdown(value: MarkdownStringDTO): PluginMarkdownStringImpl {
208
+ const implemented = new PluginMarkdownStringImpl(value.value, value.supportThemeIcons);
209
+ implemented.isTrusted = value.isTrusted;
210
+ implemented.supportHtml = value.supportHtml;
211
+ implemented.baseUri = value.baseUri && URI.revive(implemented.baseUri);
212
+ return implemented;
208
213
  }
209
214
 
210
215
  export function fromDocumentSelector(selector: theia.DocumentSelector | undefined): LanguageSelector | undefined {
@@ -466,7 +471,7 @@ export namespace ParameterInformation {
466
471
  export function to(info: model.ParameterInformation): types.ParameterInformation {
467
472
  return {
468
473
  label: info.label,
469
- documentation: isMarkdownString(info.documentation) ? toMarkdown(info.documentation) : info.documentation
474
+ documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation
470
475
  };
471
476
  }
472
477
  }
@@ -484,7 +489,7 @@ export namespace SignatureInformation {
484
489
  export function to(info: model.SignatureInformation): types.SignatureInformation {
485
490
  return {
486
491
  label: info.label,
487
- documentation: isMarkdownString(info.documentation) ? toMarkdown(info.documentation) : info.documentation,
492
+ documentation: MarkdownStringDTO.is(info.documentation) ? toMarkdown(info.documentation) : info.documentation,
488
493
  parameters: info.parameters && info.parameters.map(ParameterInformation.to)
489
494
  };
490
495
  }