@theia/plugin-ext 1.29.0-next.2 → 1.29.0-next.23

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 (112) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +7 -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 +15 -9
  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/common/rpc-protocol.d.ts +1 -1
  8. package/lib/common/rpc-protocol.d.ts.map +1 -1
  9. package/lib/common/rpc-protocol.js +3 -3
  10. package/lib/common/rpc-protocol.js.map +1 -1
  11. package/lib/main/browser/comments/comment-thread-widget.d.ts +2 -0
  12. package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
  13. package/lib/main/browser/comments/comment-thread-widget.js +4 -3
  14. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  15. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  16. package/lib/main/browser/debug/debug-main.js +20 -10
  17. package/lib/main/browser/debug/debug-main.js.map +1 -1
  18. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +4 -4
  19. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
  20. package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
  21. package/lib/main/browser/languages-main.d.ts +6 -1
  22. package/lib/main/browser/languages-main.d.ts.map +1 -1
  23. package/lib/main/browser/languages-main.js +15 -1
  24. package/lib/main/browser/languages-main.js.map +1 -1
  25. package/lib/main/browser/plugin-ext-frontend-module.d.ts +1 -0
  26. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  27. package/lib/main/browser/plugin-ext-frontend-module.js +1 -0
  28. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  29. package/lib/main/browser/preference-registry-main.d.ts +4 -3
  30. package/lib/main/browser/preference-registry-main.d.ts.map +1 -1
  31. package/lib/main/browser/preference-registry-main.js +26 -14
  32. package/lib/main/browser/preference-registry-main.js.map +1 -1
  33. package/lib/main/browser/theme-icon-override.d.ts +2 -0
  34. package/lib/main/browser/theme-icon-override.d.ts.map +1 -0
  35. package/lib/main/browser/theme-icon-override.js +217 -0
  36. package/lib/main/browser/theme-icon-override.js.map +1 -0
  37. package/lib/main/browser/view/tree-view-decorator-service.d.ts +1 -1
  38. package/lib/main/browser/view/tree-view-decorator-service.d.ts.map +1 -1
  39. package/lib/main/browser/view/tree-view-decorator-service.js +1 -1
  40. package/lib/main/browser/view/tree-view-decorator-service.js.map +1 -1
  41. package/lib/plugin/languages/code-action.d.ts.map +1 -1
  42. package/lib/plugin/languages/code-action.js +8 -9
  43. package/lib/plugin/languages/code-action.js.map +1 -1
  44. package/lib/plugin/languages/document-highlight.d.ts.map +1 -1
  45. package/lib/plugin/languages/document-highlight.js +0 -1
  46. package/lib/plugin/languages/document-highlight.js.map +1 -1
  47. package/lib/plugin/languages/evaluatable-expression.d.ts +12 -0
  48. package/lib/plugin/languages/evaluatable-expression.d.ts.map +1 -0
  49. package/lib/plugin/languages/evaluatable-expression.js +41 -0
  50. package/lib/plugin/languages/evaluatable-expression.js.map +1 -0
  51. package/lib/plugin/languages/util.d.ts +2 -2
  52. package/lib/plugin/languages/util.d.ts.map +1 -1
  53. package/lib/plugin/languages/util.js +0 -2
  54. package/lib/plugin/languages/util.js.map +1 -1
  55. package/lib/plugin/languages.d.ts +3 -1
  56. package/lib/plugin/languages.d.ts.map +1 -1
  57. package/lib/plugin/languages.js +11 -0
  58. package/lib/plugin/languages.js.map +1 -1
  59. package/lib/plugin/plugin-context.d.ts.map +1 -1
  60. package/lib/plugin/plugin-context.js +4 -0
  61. package/lib/plugin/plugin-context.js.map +1 -1
  62. package/lib/plugin/plugin-storage.d.ts +1 -0
  63. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  64. package/lib/plugin/plugin-storage.js +3 -0
  65. package/lib/plugin/plugin-storage.js.map +1 -1
  66. package/lib/plugin/preference-registry.d.ts +15 -2
  67. package/lib/plugin/preference-registry.d.ts.map +1 -1
  68. package/lib/plugin/preference-registry.js +105 -62
  69. package/lib/plugin/preference-registry.js.map +1 -1
  70. package/lib/plugin/preference-registry.spec.js +207 -35
  71. package/lib/plugin/preference-registry.spec.js.map +1 -1
  72. package/lib/plugin/type-converters.d.ts +7 -6
  73. package/lib/plugin/type-converters.d.ts.map +1 -1
  74. package/lib/plugin/type-converters.js +54 -55
  75. package/lib/plugin/type-converters.js.map +1 -1
  76. package/lib/plugin/types-impl.d.ts +8 -3
  77. package/lib/plugin/types-impl.d.ts.map +1 -1
  78. package/lib/plugin/types-impl.js +22 -10
  79. package/lib/plugin/types-impl.js.map +1 -1
  80. package/package.json +24 -24
  81. package/src/common/plugin-api-rpc-model.ts +10 -0
  82. package/src/common/plugin-api-rpc.ts +18 -9
  83. package/src/common/rpc-protocol.ts +5 -5
  84. package/src/main/browser/comments/comment-thread-widget.tsx +5 -3
  85. package/src/main/browser/debug/debug-main.ts +19 -11
  86. package/src/main/browser/debug/plugin-debug-session-factory.ts +3 -3
  87. package/src/main/browser/languages-main.ts +23 -1
  88. package/src/main/browser/plugin-ext-frontend-module.ts +1 -0
  89. package/src/main/browser/preference-registry-main.ts +23 -14
  90. package/src/main/browser/theme-icon-override.ts +221 -0
  91. package/src/main/browser/view/tree-view-decorator-service.ts +2 -2
  92. package/src/plugin/languages/code-action.ts +9 -12
  93. package/src/plugin/languages/document-highlight.ts +1 -2
  94. package/src/plugin/languages/evaluatable-expression.ts +47 -0
  95. package/src/plugin/languages/util.ts +2 -4
  96. package/src/plugin/languages.ts +15 -0
  97. package/src/plugin/plugin-context.ts +6 -1
  98. package/src/plugin/plugin-storage.ts +4 -0
  99. package/src/plugin/preference-registry.spec.ts +247 -39
  100. package/src/plugin/preference-registry.ts +107 -71
  101. package/src/plugin/type-converters.ts +58 -59
  102. package/src/plugin/types-impl.ts +30 -14
  103. package/lib/plugin/preferences/configuration.d.ts +0 -35
  104. package/lib/plugin/preferences/configuration.d.ts.map +0 -1
  105. package/lib/plugin/preferences/configuration.js +0 -137
  106. package/lib/plugin/preferences/configuration.js.map +0 -1
  107. package/lib/plugin/preferences/configuration.spec.d.ts +0 -2
  108. package/lib/plugin/preferences/configuration.spec.d.ts.map +0 -1
  109. package/lib/plugin/preferences/configuration.spec.js +0 -178
  110. package/lib/plugin/preferences/configuration.spec.js.map +0 -1
  111. package/src/plugin/preferences/configuration.spec.ts +0 -292
  112. package/src/plugin/preferences/configuration.ts +0 -167
@@ -137,9 +137,8 @@ export function toPosition(position: Position): types.Position {
137
137
  return new types.Position(position.lineNumber - 1, position.column - 1);
138
138
  }
139
139
 
140
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
- function isDecorationOptions(something: any): something is theia.DecorationOptions {
142
- return (typeof something.range !== 'undefined');
140
+ function isDecorationOptions(arg: unknown): arg is theia.DecorationOptions {
141
+ return !!arg && typeof arg === 'object' && typeof (arg as theia.DecorationOptions).range !== 'undefined';
143
142
  }
144
143
 
145
144
  export function isDecorationOptionsArr(something: theia.Range[] | theia.DecorationOptions[]): something is theia.DecorationOptions[] {
@@ -182,11 +181,10 @@ interface Codeblock {
182
181
  value: string;
183
182
  }
184
183
 
185
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
- function isCodeblock(thing: any): thing is Codeblock {
187
- return thing && typeof thing === 'object'
188
- && typeof (<Codeblock>thing).language === 'string'
189
- && typeof (<Codeblock>thing).value === 'string';
184
+ function isCodeblock(arg: unknown): arg is Codeblock {
185
+ return !!arg && typeof arg === 'object'
186
+ && typeof (arg as Codeblock).language === 'string'
187
+ && typeof (arg as Codeblock).value === 'string';
190
188
  }
191
189
 
192
190
  export function fromMarkdown(markup: theia.MarkdownString | theia.MarkedString): MarkdownStringDTO {
@@ -396,6 +394,13 @@ export function fromHover(hover: theia.Hover): model.Hover {
396
394
  };
397
395
  }
398
396
 
397
+ export function fromEvaluatableExpression(evaluatableExpression: theia.EvaluatableExpression): model.EvaluatableExpression {
398
+ return <model.EvaluatableExpression>{
399
+ range: fromRange(evaluatableExpression.range),
400
+ expression: evaluatableExpression.expression
401
+ };
402
+ }
403
+
399
404
  export function fromLocation(location: theia.Location): model.Location {
400
405
  return <model.Location>{
401
406
  uri: location.uri,
@@ -618,64 +623,58 @@ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
618
623
  }
619
624
  }
620
625
 
621
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
622
- export function isModelLocation(thing: any): thing is model.Location {
623
- if (!thing) {
624
- return false;
625
- }
626
- return isModelRange((<model.Location>thing).range) &&
627
- isUriComponents((<model.Location>thing).uri);
628
- }
629
-
630
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
631
- export function isModelRange(thing: any): thing is model.Range {
632
- if (!thing) {
633
- return false;
634
- }
635
- return (('startLineNumber' in thing) && typeof thing.startLineNumber === 'number') &&
636
- (('startColumn' in thing) && typeof thing.startColumn === 'number') &&
637
- (('endLineNumber' in thing) && typeof thing.endLineNumber === 'number') &&
638
- (('endColumn' in thing) && typeof thing.endColumn === 'number');
639
- }
640
-
641
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
642
- export function isUriComponents(thing: any): thing is UriComponents {
643
- if (!thing) {
626
+ export function isModelLocation(arg: unknown): arg is model.Location {
627
+ if (!arg) {
644
628
  return false;
645
629
  }
646
- return (('scheme' in thing) && typeof thing.scheme === 'string') &&
647
- (('path' in thing) && typeof thing.path === 'string') &&
648
- (('query' in thing) && typeof thing.query === 'string') &&
649
- (('fragment' in thing) && typeof thing.fragment === 'string');
630
+ return !!arg &&
631
+ typeof arg === 'object' &&
632
+ isModelRange((arg as model.Location).range) &&
633
+ isUriComponents((arg as model.Location).uri);
650
634
  }
651
635
 
652
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
653
- export function isModelCallHierarchyItem(thing: any): thing is model.CallHierarchyItem {
654
- if (!thing) {
655
- return false;
656
- }
657
- return isModelRange(thing.range)
658
- && isModelRange(thing.selectionRange)
659
- && isUriComponents(thing.uri)
660
- && !!thing.name;
636
+ export function isModelRange(arg: unknown): arg is model.Range {
637
+ const range = arg as model.Range;
638
+ return !!arg && typeof arg === 'object' &&
639
+ typeof range.startLineNumber === 'number' &&
640
+ typeof range.startColumn === 'number' &&
641
+ typeof range.endLineNumber === 'number' &&
642
+ typeof range.endColumn === 'number';
661
643
  }
662
644
 
663
645
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
664
- export function isModelCallHierarchyIncomingCall(thing: any): thing is model.CallHierarchyIncomingCall {
665
- if (!thing) {
666
- return false;
667
- }
668
- const maybeIncomingCall = thing as model.CallHierarchyIncomingCall;
669
- return 'from' in maybeIncomingCall && 'fromRanges' in maybeIncomingCall && isModelCallHierarchyItem(maybeIncomingCall.from);
670
- }
671
-
672
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
673
- export function isModelCallHierarchyOutgoingCall(thing: any): thing is model.CallHierarchyOutgoingCall {
674
- if (!thing) {
675
- return false;
676
- }
677
- const maybeOutgoingCall = thing as model.CallHierarchyOutgoingCall;
678
- return 'to' in maybeOutgoingCall && 'fromRanges' in maybeOutgoingCall && isModelCallHierarchyItem(maybeOutgoingCall.to);
646
+ export function isUriComponents(arg: unknown): arg is UriComponents {
647
+ const uriComponents = arg as UriComponents;
648
+ return !!arg && typeof arg === 'object' &&
649
+ typeof uriComponents.scheme === 'string' &&
650
+ typeof uriComponents.path === 'string' &&
651
+ typeof uriComponents.query === 'string' &&
652
+ typeof uriComponents.fragment === 'string';
653
+ }
654
+
655
+ export function isModelCallHierarchyItem(arg: unknown): arg is model.CallHierarchyItem {
656
+ const item = arg as model.CallHierarchyItem;
657
+ return !!item && typeof item === 'object'
658
+ && isModelRange(item.range)
659
+ && isModelRange(item.selectionRange)
660
+ && isUriComponents(item.uri)
661
+ && !!item.name;
662
+ }
663
+
664
+ export function isModelCallHierarchyIncomingCall(arg: unknown): arg is model.CallHierarchyIncomingCall {
665
+ const maybeIncomingCall = arg as model.CallHierarchyIncomingCall;
666
+ return !!arg && typeof arg === 'object' &&
667
+ 'from' in maybeIncomingCall &&
668
+ 'fromRanges' in maybeIncomingCall &&
669
+ isModelCallHierarchyItem(maybeIncomingCall.from);
670
+ }
671
+
672
+ export function isModelCallHierarchyOutgoingCall(arg: unknown): arg is model.CallHierarchyOutgoingCall {
673
+ const maybeOutgoingCall = arg as model.CallHierarchyOutgoingCall;
674
+ return !!arg && typeof arg === 'object' &&
675
+ 'to' in maybeOutgoingCall &&
676
+ 'fromRanges' in maybeOutgoingCall &&
677
+ isModelCallHierarchyItem(maybeOutgoingCall.to);
679
678
  }
680
679
 
681
680
  export function toLocation(value: model.Location): types.Location {
@@ -20,7 +20,6 @@
20
20
  *--------------------------------------------------------------------------------------------*/
21
21
 
22
22
  /* eslint-disable no-null/no-null */
23
- /* eslint-disable @typescript-eslint/no-explicit-any */
24
23
 
25
24
  import { UUID } from '@theia/core/shared/@phosphor/coreutils';
26
25
  import { illegalArgument } from '../common/errors';
@@ -38,6 +37,7 @@ import { es5ClassCompat } from '../common/types';
38
37
  * A reviver that takes URI's transferred via JSON.stringify() and makes
39
38
  * instances of our local plugin API URI class (below)
40
39
  */
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
41
  export function reviver(key: string | undefined, value: any): any {
42
42
  const revived = ObjectsTransferrer.reviver(key, value);
43
43
  if (CodeURI.isUri(revived)) {
@@ -423,7 +423,7 @@ export class Position {
423
423
  return false;
424
424
  }
425
425
 
426
- toJSON(): any {
426
+ toJSON(): unknown {
427
427
  return { line: this.line, character: this.character };
428
428
  }
429
429
  }
@@ -546,19 +546,17 @@ export class Range {
546
546
  return new Range(start, end);
547
547
  }
548
548
 
549
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
550
- static isRange(thing: any): thing is theia.Range {
549
+ static isRange(thing: unknown): thing is theia.Range {
551
550
  if (thing instanceof Range) {
552
551
  return true;
553
552
  }
554
- if (!thing) {
555
- return false;
556
- }
557
- return Position.isPosition((<Range>thing).start)
558
- && Position.isPosition((<Range>thing).end);
553
+ const range = thing as theia.Range;
554
+ return !!thing && typeof thing === 'object'
555
+ && Position.isPosition(range.start)
556
+ && Position.isPosition(range.end);
559
557
  }
560
558
 
561
- toJSON(): any {
559
+ toJSON(): unknown {
562
560
  return [this.start, this.end];
563
561
  }
564
562
  }
@@ -1119,6 +1117,24 @@ export class Hover {
1119
1117
  }
1120
1118
  }
1121
1119
 
1120
+ @es5ClassCompat
1121
+ export class EvaluatableExpression {
1122
+
1123
+ public range: Range;
1124
+ public expression?: string;
1125
+
1126
+ constructor(
1127
+ range: Range,
1128
+ expression?: string
1129
+ ) {
1130
+ if (!range) {
1131
+ illegalArgument('range must be defined');
1132
+ }
1133
+ this.range = range;
1134
+ this.expression = expression;
1135
+ }
1136
+ }
1137
+
1122
1138
  export enum DocumentHighlightKind {
1123
1139
  Text = 0,
1124
1140
  Read = 1,
@@ -1618,8 +1634,8 @@ export class FileSystemError extends Error {
1618
1634
 
1619
1635
  // workaround when extending builtin objects and when compiling to ES5, see:
1620
1636
  // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
1621
- if (typeof (<any>Object).setPrototypeOf === 'function') {
1622
- (<any>Object).setPrototypeOf(this, FileSystemError.prototype);
1637
+ if (typeof Object.setPrototypeOf === 'function') {
1638
+ Object.setPrototypeOf(this, FileSystemError.prototype);
1623
1639
  }
1624
1640
 
1625
1641
  if (typeof Error.captureStackTrace === 'function' && typeof terminator === 'function') {
@@ -2537,7 +2553,7 @@ export class SemanticTokensLegend {
2537
2553
  }
2538
2554
  }
2539
2555
 
2540
- function isStrArrayOrUndefined(arg: any): arg is string[] | undefined {
2556
+ function isStrArrayOrUndefined(arg: unknown): arg is string[] | undefined {
2541
2557
  return ((typeof arg === 'undefined') || (Array.isArray(arg) && arg.every(e => typeof e === 'string')));
2542
2558
  }
2543
2559
 
@@ -2575,7 +2591,7 @@ export class SemanticTokensBuilder {
2575
2591
 
2576
2592
  public push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
2577
2593
  public push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
2578
- public push(arg0: any, arg1: any, arg2: any, arg3?: any, arg4?: any): void {
2594
+ public push(arg0: number | Range, arg1: number | string, arg2?: number | string[], arg3?: number, arg4?: number): void {
2579
2595
  if (typeof arg0 === 'number' && typeof arg1 === 'number' && typeof arg2 === 'number' && typeof arg3 === 'number' &&
2580
2596
  (typeof arg4 === 'number' || typeof arg4 === 'undefined')) {
2581
2597
  if (typeof arg4 === 'undefined') {
@@ -1,35 +0,0 @@
1
- import { WorkspaceExtImpl } from '../workspace';
2
- import { URI } from '@theia/core/shared/vscode-uri';
3
- export declare class Configuration {
4
- private defaultConfiguration;
5
- private userConfiguration;
6
- private workspaceConfiguration;
7
- private folderConfigurations;
8
- private combinedConfig;
9
- private folderCombinedConfigs;
10
- constructor(defaultConfiguration: ConfigurationModel, userConfiguration: ConfigurationModel, workspaceConfiguration?: ConfigurationModel, folderConfigurations?: {
11
- [resource: string]: ConfigurationModel;
12
- });
13
- getValue(section: string | undefined, workspace: WorkspaceExtImpl, resource?: URI): any;
14
- inspect<C>(key: string, workspace: WorkspaceExtImpl, resource?: URI): {
15
- default: C;
16
- user: C;
17
- workspace: C | undefined;
18
- workspaceFolder: C | undefined;
19
- value: C;
20
- };
21
- private getCombinedResourceConfig;
22
- private getCombinedConfig;
23
- private getFolderCombinedConfig;
24
- private getFolderResourceConfig;
25
- }
26
- export declare class ConfigurationModel {
27
- private contents;
28
- private keys;
29
- constructor(contents?: any, keys?: string[]);
30
- getValue(section?: string): any;
31
- merge(...others: ConfigurationModel[]): ConfigurationModel;
32
- private mergeContents;
33
- private mergeKeys;
34
- }
35
- //# sourceMappingURL=configuration.d.ts.map
@@ -1 +0,0 @@
1
- {"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,EAAE,MAAM,GAAG,GAAG;IAgB/B,KAAK,CAAC,GAAG,MAAM,EAAE,kBAAkB,EAAE,GAAG,kBAAkB;IAW1D,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,SAAS;CAQpB"}
@@ -1,137 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2019 Red Hat, Inc. and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ConfigurationModel = exports.Configuration = void 0;
19
- const types_1 = require("../../common/types");
20
- const cloneDeep = require("lodash.clonedeep");
21
- /* eslint-disable @typescript-eslint/no-explicit-any */
22
- class Configuration {
23
- constructor(defaultConfiguration, userConfiguration, workspaceConfiguration = new ConfigurationModel(), folderConfigurations = {}) {
24
- this.defaultConfiguration = defaultConfiguration;
25
- this.userConfiguration = userConfiguration;
26
- this.workspaceConfiguration = workspaceConfiguration;
27
- this.folderConfigurations = folderConfigurations;
28
- this.folderCombinedConfigs = {};
29
- }
30
- getValue(section, workspace, resource) {
31
- return this.getCombinedResourceConfig(workspace, resource).getValue(section);
32
- }
33
- inspect(key, workspace, resource) {
34
- const combinedConfiguration = this.getCombinedResourceConfig(workspace, resource);
35
- const folderConfiguration = this.getFolderResourceConfig(workspace, resource);
36
- return {
37
- default: this.defaultConfiguration.getValue(key),
38
- user: this.userConfiguration.getValue(key),
39
- workspace: workspace ? this.workspaceConfiguration.getValue(key) : undefined,
40
- workspaceFolder: folderConfiguration ? folderConfiguration.getValue(key) : undefined,
41
- value: combinedConfiguration.getValue(key)
42
- };
43
- }
44
- getCombinedResourceConfig(workspace, resource) {
45
- const combinedConfig = this.getCombinedConfig();
46
- if (!workspace || !resource) {
47
- return combinedConfig;
48
- }
49
- const workspaceFolder = workspace.getWorkspaceFolder(resource);
50
- if (!workspaceFolder) {
51
- return combinedConfig;
52
- }
53
- return this.getFolderCombinedConfig(workspaceFolder.uri.toString()) || combinedConfig;
54
- }
55
- getCombinedConfig() {
56
- if (!this.combinedConfig) {
57
- this.combinedConfig = this.defaultConfiguration.merge(this.userConfiguration, this.workspaceConfiguration);
58
- }
59
- return this.combinedConfig;
60
- }
61
- getFolderCombinedConfig(folder) {
62
- if (this.folderCombinedConfigs[folder]) {
63
- return this.folderCombinedConfigs[folder];
64
- }
65
- const combinedConfig = this.getCombinedConfig();
66
- const folderConfig = this.folderConfigurations[folder];
67
- if (!folderConfig) {
68
- return combinedConfig;
69
- }
70
- const folderCombinedConfig = combinedConfig.merge(folderConfig);
71
- this.folderCombinedConfigs[folder] = folderCombinedConfig;
72
- return folderCombinedConfig;
73
- }
74
- getFolderResourceConfig(workspace, resource) {
75
- if (!workspace || !resource) {
76
- return;
77
- }
78
- const workspaceFolder = workspace.getWorkspaceFolder(resource);
79
- if (!workspaceFolder) {
80
- return;
81
- }
82
- return this.folderConfigurations[workspaceFolder.uri.toString()];
83
- }
84
- }
85
- exports.Configuration = Configuration;
86
- class ConfigurationModel {
87
- constructor(contents = Object.create(null), keys = []) {
88
- this.contents = contents;
89
- this.keys = keys;
90
- }
91
- getValue(section) {
92
- if (!section) {
93
- return this.contents;
94
- }
95
- const path = section.split('.');
96
- let current = this.contents;
97
- for (let i = 0; i < path.length; i++) {
98
- if (typeof current !== 'object' || current === null) {
99
- return undefined;
100
- }
101
- current = current[path[i]];
102
- }
103
- return current;
104
- }
105
- merge(...others) {
106
- const contents = cloneDeep(this.contents);
107
- const allKeys = [...this.keys];
108
- for (const other of others) {
109
- this.mergeContents(contents, other.contents);
110
- this.mergeKeys(allKeys, other.keys);
111
- }
112
- return new ConfigurationModel(contents, allKeys);
113
- }
114
- mergeContents(source, target) {
115
- for (const key of Object.keys(target)) {
116
- if (key === '__proto__') {
117
- continue;
118
- }
119
- if (key in source) {
120
- if ((0, types_1.isObject)(source[key]) && (0, types_1.isObject)(target[key])) {
121
- this.mergeContents(source[key], target[key]);
122
- continue;
123
- }
124
- }
125
- source[key] = cloneDeep(target[key]);
126
- }
127
- }
128
- mergeKeys(source, target) {
129
- for (const key of target) {
130
- if (source.indexOf(key) === -1) {
131
- source.push(key);
132
- }
133
- }
134
- }
135
- }
136
- exports.ConfigurationModel = ConfigurationModel;
137
- //# sourceMappingURL=configuration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;AAGhF,8CAA8C;AAC9C,8CAA+C;AAG/C,uDAAuD;AAEvD,MAAa,aAAa;IAKtB,YACY,oBAAwC,EACxC,iBAAqC,EACrC,yBAA6C,IAAI,kBAAkB,EAAE,EACrE,uBAAmE,EAAE;QAHrE,yBAAoB,GAApB,oBAAoB,CAAoB;QACxC,sBAAiB,GAAjB,iBAAiB,CAAoB;QACrC,2BAAsB,GAAtB,sBAAsB,CAA+C;QACrE,yBAAoB,GAApB,oBAAoB,CAAiD;QANzE,0BAAqB,GAA+C,EAAE,CAAC;IAO3E,CAAC;IAEL,QAAQ,CAAC,OAA2B,EAAE,SAA2B,EAAE,QAAc;QAC7E,OAAO,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAA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I,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC7C,SAAS;iBACZ;aACJ;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SACxC;IACL,CAAC;IAEO,SAAS,CAAC,MAAgB,EAAE,MAAgB;QAChD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;YACtB,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;SACJ;IACL,CAAC;CAEJ;AAzDD,gDAyDC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=configuration.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.spec.d.ts","sourceRoot":"","sources":["../../../src/plugin/preferences/configuration.spec.ts"],"names":[],"mappings":""}
@@ -1,178 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2019 Red Hat, Inc. and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- /* eslint-disable @typescript-eslint/no-explicit-any */
19
- const chai = require("chai");
20
- const configuration_1 = require("./configuration");
21
- const preference_scope_1 = require("@theia/core/lib/common/preferences/preference-scope");
22
- const vscode_uri_1 = require("@theia/core/shared/vscode-uri");
23
- const expect = chai.expect;
24
- let inspect;
25
- const projects = ['/projects/workspace/project1', '/projects/workspace/project2'];
26
- const propertyName = 'tabSize';
27
- const preferences = {
28
- [preference_scope_1.PreferenceScope.Default]: {
29
- [propertyName]: 6,
30
- },
31
- [preference_scope_1.PreferenceScope.User]: {
32
- [propertyName]: 5
33
- },
34
- [preference_scope_1.PreferenceScope.Workspace]: {
35
- [propertyName]: 4
36
- },
37
- [preference_scope_1.PreferenceScope.Folder]: {
38
- [projects[0]]: {
39
- [propertyName]: 3
40
- },
41
- [projects[1]]: {
42
- [propertyName]: 2
43
- }
44
- }
45
- };
46
- const workspace = {};
47
- let configuration;
48
- let defaultConfiguration;
49
- let userConfiguration;
50
- let workspaceConfiguration;
51
- let folderConfigurations;
52
- before(() => {
53
- workspace.getWorkspaceFolder = (uri => {
54
- const name = uri.toString().replace(/[^\/]+$/, '$1');
55
- const index = projects.indexOf(uri.toString());
56
- return { uri, name, index };
57
- });
58
- defaultConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Default], Object.keys(preferences[preference_scope_1.PreferenceScope.Default]));
59
- userConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.User], Object.keys(preferences[preference_scope_1.PreferenceScope.User]));
60
- workspaceConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Workspace], Object.keys(preferences[preference_scope_1.PreferenceScope.Workspace]));
61
- folderConfigurations = projects.reduce((configurations, project) => {
62
- const folderPrefs = preferences[preference_scope_1.PreferenceScope.Folder][project];
63
- configurations[project] = new configuration_1.ConfigurationModel(folderPrefs, Object.keys(folderPrefs));
64
- return configurations;
65
- }, {});
66
- });
67
- describe('Configuration:', () => {
68
- describe('Default scope preferences:', () => {
69
- beforeEach(() => {
70
- configuration = new configuration_1.Configuration(defaultConfiguration, new configuration_1.ConfigurationModel({}, []), undefined, undefined);
71
- inspect = configuration.inspect(propertyName, workspace, undefined);
72
- });
73
- it('should have correct value of \'default\' property', () => {
74
- expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
75
- expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
76
- });
77
- it('should have correct value of \'value\' property', () => {
78
- expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
79
- expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
80
- });
81
- });
82
- describe('User scope preferences:', () => {
83
- beforeEach(() => {
84
- configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, undefined, undefined);
85
- inspect = configuration.inspect(propertyName, workspace, undefined);
86
- });
87
- it('should have correct value of \'default\' property', () => {
88
- expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
89
- expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
90
- });
91
- it('should have correct value of \'user\' property', () => {
92
- expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
93
- expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
94
- });
95
- it('should have correct value of \'value\' property', () => {
96
- expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
97
- expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
98
- });
99
- });
100
- describe('Workspace scope preferences:', () => {
101
- beforeEach(() => {
102
- configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, workspaceConfiguration, undefined);
103
- inspect = configuration.inspect(propertyName, workspace, undefined);
104
- });
105
- it('should have correct value of \'default\' property', () => {
106
- expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
107
- expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
108
- });
109
- it('should have correct value of \'user\' property', () => {
110
- expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
111
- expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
112
- });
113
- it('should have correct value of \'workspace\' property', () => {
114
- expect(inspect).to.have.property('workspace', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
115
- expect(inspect.workspace).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
116
- });
117
- it('should have correct value of \'value\' property', () => {
118
- expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
119
- expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
120
- });
121
- });
122
- describe('Folder scope preferences:', () => {
123
- const project = projects[0];
124
- beforeEach(() => {
125
- configuration = new configuration_1.Configuration(defaultConfiguration, userConfiguration, workspaceConfiguration, folderConfigurations);
126
- const resource = vscode_uri_1.URI.revive({ path: project, scheme: '', authority: '', query: '', fragment: '' });
127
- inspect = configuration.inspect(propertyName, workspace, resource);
128
- });
129
- it('should have correct value of \'default\' property', () => {
130
- expect(inspect).to.have.property('default', preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
131
- expect(inspect.default).to.equal(preferences[preference_scope_1.PreferenceScope.Default][propertyName]);
132
- });
133
- it('should have correct value of \'user\' property', () => {
134
- expect(inspect).to.have.property('user', preferences[preference_scope_1.PreferenceScope.User][propertyName]);
135
- expect(inspect.user).to.equal(preferences[preference_scope_1.PreferenceScope.User][propertyName]);
136
- });
137
- it('should have correct value of \'workspace\' property', () => {
138
- expect(inspect).to.have.property('workspace', preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
139
- expect(inspect.workspace).to.equal(preferences[preference_scope_1.PreferenceScope.Workspace][propertyName]);
140
- });
141
- it('should have correct value of \'workspaceFolder\' property', () => {
142
- expect(inspect).to.have.property('workspaceFolder', preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
143
- expect(inspect.workspaceFolder).to.equal(preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
144
- });
145
- it('should have correct value of \'value\' property', () => {
146
- expect(inspect).to.have.property('value', preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
147
- expect(inspect.value).to.equal(preferences[preference_scope_1.PreferenceScope.Folder][project][propertyName]);
148
- });
149
- });
150
- describe('ConfigurationModel', () => {
151
- it('check merge', () => {
152
- defaultConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Default], Object.keys(preferences[preference_scope_1.PreferenceScope.Default]));
153
- userConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.User], Object.keys(preferences[preference_scope_1.PreferenceScope.User]));
154
- workspaceConfiguration = new configuration_1.ConfigurationModel(preferences[preference_scope_1.PreferenceScope.Workspace], Object.keys(preferences[preference_scope_1.PreferenceScope.Workspace]));
155
- const mergedConfiguration = new configuration_1.ConfigurationModel().merge(defaultConfiguration, userConfiguration, workspaceConfiguration);
156
- expect(mergedConfiguration.getValue('tabSize')).to.equal(4);
157
- });
158
- it('Prototype pollution check', () => {
159
- const payload = JSON.parse('{"__proto__":{"injectedConfigurationPrototype": true}}');
160
- const configurationModel = new configuration_1.ConfigurationModel();
161
- configurationModel.merge(new configuration_1.ConfigurationModel(payload));
162
- const prototypeObject = Object.prototype;
163
- expect(prototypeObject.injectedConfigurationPrototype).to.be.an('undefined');
164
- const rawObject = {};
165
- expect(rawObject.injectedConfigurationPrototype).to.be.an('undefined');
166
- });
167
- it('Prototype constructor pollution check', () => {
168
- const payload = JSON.parse('{"constructor": {"prototype": {"injectedConfigurationConstructorPrototype": true}}}');
169
- const configurationModel = new configuration_1.ConfigurationModel();
170
- configurationModel.merge(new configuration_1.ConfigurationModel(payload));
171
- const prototypeObject = Object.prototype;
172
- expect(prototypeObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
173
- const rawObject = {};
174
- expect(rawObject.injectedConfigurationConstructorPrototype).to.be.an('undefined');
175
- });
176
- });
177
- });
178
- //# sourceMappingURL=configuration.spec.js.map