@opensumi/ide-core-common 2.17.9 → 2.18.1

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 (296) hide show
  1. package/lib/application-error.d.ts.map +1 -1
  2. package/lib/application-error.js +6 -0
  3. package/lib/application-error.js.map +1 -1
  4. package/lib/command.d.ts +1 -2
  5. package/lib/command.d.ts.map +1 -1
  6. package/lib/command.js +4 -4
  7. package/lib/command.js.map +1 -1
  8. package/lib/{utils/comparers.d.ts → comparers.d.ts} +1 -1
  9. package/lib/comparers.d.ts.map +1 -0
  10. package/lib/{utils/comparers.js → comparers.js} +5 -5
  11. package/lib/comparers.js.map +1 -0
  12. package/lib/const/application.d.ts +1 -0
  13. package/lib/const/application.d.ts.map +1 -1
  14. package/lib/const/application.js +3 -1
  15. package/lib/const/application.js.map +1 -1
  16. package/lib/const/index.d.ts +1 -1
  17. package/lib/const/index.d.ts.map +1 -1
  18. package/lib/const/index.js +1 -1
  19. package/lib/const/index.js.map +1 -1
  20. package/lib/crypto.d.ts +7 -0
  21. package/lib/{cryptr.d.ts.map → crypto.d.ts.map} +1 -1
  22. package/lib/crypto.js +6 -0
  23. package/lib/crypto.js.map +1 -0
  24. package/lib/electron.d.ts +2 -2
  25. package/lib/electron.d.ts.map +1 -1
  26. package/lib/electron.js.map +1 -1
  27. package/lib/event-bus/event-bus-types.d.ts +3 -4
  28. package/lib/event-bus/event-bus-types.d.ts.map +1 -1
  29. package/lib/event-bus/event-bus.d.ts +3 -3
  30. package/lib/event-bus/event-bus.d.ts.map +1 -1
  31. package/lib/event-bus/event-bus.js +3 -3
  32. package/lib/event-bus/event-bus.js.map +1 -1
  33. package/lib/event-bus/event-decorator.d.ts +1 -1
  34. package/lib/event-bus/event-decorator.d.ts.map +1 -1
  35. package/lib/event-bus/event-decorator.js +2 -2
  36. package/lib/event-bus/event-decorator.js.map +1 -1
  37. package/lib/hash-calculate/hash-calculate.d.ts.map +1 -1
  38. package/lib/hash-calculate/hash-calculate.js +2 -2
  39. package/lib/hash-calculate/hash-calculate.js.map +1 -1
  40. package/lib/index.d.ts +4 -18
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/index.js +4 -18
  43. package/lib/index.js.map +1 -1
  44. package/lib/keyboard/keyboard-layout-provider.d.ts +1 -1
  45. package/lib/keyboard/keyboard-layout-provider.d.ts.map +1 -1
  46. package/lib/keyboard/keymap.js +4 -4
  47. package/lib/keyboard/keymap.js.map +1 -1
  48. package/lib/localize.d.ts.map +1 -1
  49. package/lib/localize.js +7 -7
  50. package/lib/localize.js.map +1 -1
  51. package/lib/log.d.ts +1 -1
  52. package/lib/log.d.ts.map +1 -1
  53. package/lib/{utils/markdown.d.ts → markdown.d.ts} +1 -1
  54. package/lib/markdown.d.ts.map +1 -0
  55. package/lib/{utils/markdown.js → markdown.js} +0 -0
  56. package/lib/markdown.js.map +1 -0
  57. package/lib/menu.d.ts +1 -1
  58. package/lib/menu.d.ts.map +1 -1
  59. package/lib/menu.js.map +1 -1
  60. package/lib/network.d.ts +2 -1
  61. package/lib/network.d.ts.map +1 -1
  62. package/lib/network.js +19 -18
  63. package/lib/network.js.map +1 -1
  64. package/lib/problem-matcher.d.ts +1 -3
  65. package/lib/problem-matcher.d.ts.map +1 -1
  66. package/lib/problem-matcher.js +5 -6
  67. package/lib/problem-matcher.js.map +1 -1
  68. package/lib/problem-pattern.d.ts +1 -2
  69. package/lib/problem-pattern.d.ts.map +1 -1
  70. package/lib/problem-pattern.js +9 -10
  71. package/lib/problem-pattern.js.map +1 -1
  72. package/lib/reference.d.ts +1 -3
  73. package/lib/reference.d.ts.map +1 -1
  74. package/lib/reference.js +4 -5
  75. package/lib/reference.js.map +1 -1
  76. package/lib/reporter.d.ts +1 -1
  77. package/lib/reporter.d.ts.map +1 -1
  78. package/lib/storage.d.ts +1 -4
  79. package/lib/storage.d.ts.map +1 -1
  80. package/lib/storage.js +11 -11
  81. package/lib/storage.js.map +1 -1
  82. package/lib/task-definition.d.ts +1 -1
  83. package/lib/task-definition.d.ts.map +1 -1
  84. package/lib/task-definition.js +6 -6
  85. package/lib/task-definition.js.map +1 -1
  86. package/lib/types/application.d.ts +4 -4
  87. package/lib/types/application.d.ts.map +1 -1
  88. package/lib/types/authentication.d.ts +1 -2
  89. package/lib/types/authentication.d.ts.map +1 -1
  90. package/lib/types/authentication.js.map +1 -1
  91. package/lib/types/common.d.ts +2 -2
  92. package/lib/types/common.d.ts.map +1 -1
  93. package/lib/types/extension.d.ts +1 -1
  94. package/lib/types/extension.d.ts.map +1 -1
  95. package/lib/types/extension.js.map +1 -1
  96. package/lib/types/file-watch.d.ts +1 -1
  97. package/lib/types/file-watch.d.ts.map +1 -1
  98. package/lib/types/file-watch.js +2 -2
  99. package/lib/types/file-watch.js.map +1 -1
  100. package/lib/types/file.d.ts +1 -1
  101. package/lib/types/file.d.ts.map +1 -1
  102. package/lib/types/index.d.ts +1 -0
  103. package/lib/types/index.d.ts.map +1 -1
  104. package/lib/types/index.js +1 -0
  105. package/lib/types/index.js.map +1 -1
  106. package/lib/types/markdown.d.ts +2 -1
  107. package/lib/types/markdown.d.ts.map +1 -1
  108. package/lib/types/markers/markers-manager.d.ts +2 -2
  109. package/lib/types/markers/markers-manager.d.ts.map +1 -1
  110. package/lib/types/markers/markers-manager.js +25 -23
  111. package/lib/types/markers/markers-manager.js.map +1 -1
  112. package/lib/types/markers/markers.js +2 -2
  113. package/lib/types/markers/markers.js.map +1 -1
  114. package/lib/utils/ipc.d.ts.map +1 -1
  115. package/lib/utils/ipc.js +7 -8
  116. package/lib/utils/ipc.js.map +1 -1
  117. package/package.json +4 -7
  118. package/lib/arrays.d.ts +0 -134
  119. package/lib/arrays.d.ts.map +0 -1
  120. package/lib/arrays.js +0 -545
  121. package/lib/arrays.js.map +0 -1
  122. package/lib/async.d.ts +0 -185
  123. package/lib/async.d.ts.map +0 -1
  124. package/lib/async.js +0 -469
  125. package/lib/async.js.map +0 -1
  126. package/lib/cache.d.ts +0 -12
  127. package/lib/cache.d.ts.map +0 -1
  128. package/lib/cache.js +0 -37
  129. package/lib/cache.js.map +0 -1
  130. package/lib/cancellation.d.ts +0 -23
  131. package/lib/cancellation.d.ts.map +0 -1
  132. package/lib/cancellation.js +0 -120
  133. package/lib/cancellation.js.map +0 -1
  134. package/lib/charCode.d.ts +0 -406
  135. package/lib/charCode.d.ts.map +0 -1
  136. package/lib/charCode.js +0 -8
  137. package/lib/charCode.js.map +0 -1
  138. package/lib/character-classifier.d.ts +0 -25
  139. package/lib/character-classifier.d.ts.map +0 -1
  140. package/lib/character-classifier.js +0 -59
  141. package/lib/character-classifier.js.map +0 -1
  142. package/lib/const/encodings.d.ts +0 -10
  143. package/lib/const/encodings.d.ts.map +0 -1
  144. package/lib/const/encodings.js +0 -244
  145. package/lib/const/encodings.js.map +0 -1
  146. package/lib/cryptr.d.ts +0 -7
  147. package/lib/cryptr.js +0 -6
  148. package/lib/cryptr.js.map +0 -1
  149. package/lib/date.d.ts +0 -2
  150. package/lib/date.d.ts.map +0 -1
  151. package/lib/date.js +0 -22
  152. package/lib/date.js.map +0 -1
  153. package/lib/disposable.d.ts +0 -88
  154. package/lib/disposable.d.ts.map +0 -1
  155. package/lib/disposable.js +0 -316
  156. package/lib/disposable.js.map +0 -1
  157. package/lib/encoding/index.d.ts +0 -34
  158. package/lib/encoding/index.d.ts.map +0 -1
  159. package/lib/encoding/index.js +0 -219
  160. package/lib/encoding/index.js.map +0 -1
  161. package/lib/errors.d.ts +0 -56
  162. package/lib/errors.d.ts.map +0 -1
  163. package/lib/errors.js +0 -148
  164. package/lib/errors.js.map +0 -1
  165. package/lib/event.d.ts +0 -268
  166. package/lib/event.d.ts.map +0 -1
  167. package/lib/event.js +0 -816
  168. package/lib/event.js.map +0 -1
  169. package/lib/filters.d.ts +0 -47
  170. package/lib/filters.d.ts.map +0 -1
  171. package/lib/filters.js +0 -699
  172. package/lib/filters.js.map +0 -1
  173. package/lib/functional.d.ts +0 -4
  174. package/lib/functional.d.ts.map +0 -1
  175. package/lib/functional.js +0 -45
  176. package/lib/functional.js.map +0 -1
  177. package/lib/iterator.d.ts +0 -17
  178. package/lib/iterator.d.ts.map +0 -1
  179. package/lib/iterator.js +0 -24
  180. package/lib/iterator.js.map +0 -1
  181. package/lib/lifecycle.d.ts +0 -17
  182. package/lib/lifecycle.d.ts.map +0 -1
  183. package/lib/lifecycle.js +0 -39
  184. package/lib/lifecycle.js.map +0 -1
  185. package/lib/linked-list.d.ts +0 -18
  186. package/lib/linked-list.d.ts.map +0 -1
  187. package/lib/linked-list.js +0 -138
  188. package/lib/linked-list.js.map +0 -1
  189. package/lib/linkedText.d.ts +0 -13
  190. package/lib/linkedText.d.ts.map +0 -1
  191. package/lib/linkedText.js +0 -50
  192. package/lib/linkedText.js.map +0 -1
  193. package/lib/map.d.ts +0 -124
  194. package/lib/map.d.ts.map +0 -1
  195. package/lib/map.js +0 -819
  196. package/lib/map.js.map +0 -1
  197. package/lib/path.d.ts +0 -92
  198. package/lib/path.d.ts.map +0 -1
  199. package/lib/path.js +0 -1695
  200. package/lib/path.js.map +0 -1
  201. package/lib/platform.d.ts +0 -48
  202. package/lib/platform.d.ts.map +0 -1
  203. package/lib/platform.js +0 -153
  204. package/lib/platform.js.map +0 -1
  205. package/lib/process.d.ts +0 -5
  206. package/lib/process.d.ts.map +0 -1
  207. package/lib/process.js +0 -23
  208. package/lib/process.js.map +0 -1
  209. package/lib/progress.d.ts +0 -56
  210. package/lib/progress.d.ts.map +0 -1
  211. package/lib/progress.js +0 -27
  212. package/lib/progress.js.map +0 -1
  213. package/lib/sequence.d.ts +0 -20
  214. package/lib/sequence.d.ts.map +0 -1
  215. package/lib/sequence.js +0 -17
  216. package/lib/sequence.js.map +0 -1
  217. package/lib/uint.d.ts +0 -32
  218. package/lib/uint.d.ts.map +0 -1
  219. package/lib/uint.js +0 -28
  220. package/lib/uint.js.map +0 -1
  221. package/lib/uri.d.ts +0 -94
  222. package/lib/uri.d.ts.map +0 -1
  223. package/lib/uri.js +0 -231
  224. package/lib/uri.js.map +0 -1
  225. package/lib/utils/ansi.d.ts +0 -5
  226. package/lib/utils/ansi.d.ts.map +0 -1
  227. package/lib/utils/ansi.js +0 -14
  228. package/lib/utils/ansi.js.map +0 -1
  229. package/lib/utils/arrays.d.ts +0 -66
  230. package/lib/utils/arrays.d.ts.map +0 -1
  231. package/lib/utils/arrays.js +0 -260
  232. package/lib/utils/arrays.js.map +0 -1
  233. package/lib/utils/buffer.d.ts +0 -35
  234. package/lib/utils/buffer.d.ts.map +0 -1
  235. package/lib/utils/buffer.js +0 -174
  236. package/lib/utils/buffer.js.map +0 -1
  237. package/lib/utils/comparers.d.ts.map +0 -1
  238. package/lib/utils/comparers.js.map +0 -1
  239. package/lib/utils/decorators.d.ts +0 -11
  240. package/lib/utils/decorators.d.ts.map +0 -1
  241. package/lib/utils/decorators.js +0 -151
  242. package/lib/utils/decorators.js.map +0 -1
  243. package/lib/utils/file-uri.d.ts +0 -15
  244. package/lib/utils/file-uri.d.ts.map +0 -1
  245. package/lib/utils/file-uri.js +0 -46
  246. package/lib/utils/file-uri.js.map +0 -1
  247. package/lib/utils/glob.d.ts +0 -46
  248. package/lib/utils/glob.d.ts.map +0 -1
  249. package/lib/utils/glob.js +0 -556
  250. package/lib/utils/glob.js.map +0 -1
  251. package/lib/utils/hash.d.ts +0 -38
  252. package/lib/utils/hash.d.ts.map +0 -1
  253. package/lib/utils/hash.js +0 -294
  254. package/lib/utils/hash.js.map +0 -1
  255. package/lib/utils/index.d.ts +0 -15
  256. package/lib/utils/index.d.ts.map +0 -1
  257. package/lib/utils/index.js +0 -18
  258. package/lib/utils/index.js.map +0 -1
  259. package/lib/utils/json.d.ts +0 -76
  260. package/lib/utils/json.d.ts.map +0 -1
  261. package/lib/utils/json.js +0 -188
  262. package/lib/utils/json.js.map +0 -1
  263. package/lib/utils/markdown.d.ts.map +0 -1
  264. package/lib/utils/markdown.js.map +0 -1
  265. package/lib/utils/marshalling.d.ts +0 -7
  266. package/lib/utils/marshalling.d.ts.map +0 -1
  267. package/lib/utils/marshalling.js +0 -59
  268. package/lib/utils/marshalling.js.map +0 -1
  269. package/lib/utils/objects.d.ts +0 -6
  270. package/lib/utils/objects.d.ts.map +0 -1
  271. package/lib/utils/objects.js +0 -103
  272. package/lib/utils/objects.js.map +0 -1
  273. package/lib/utils/os.d.ts +0 -49
  274. package/lib/utils/os.d.ts.map +0 -1
  275. package/lib/utils/os.js +0 -98
  276. package/lib/utils/os.js.map +0 -1
  277. package/lib/utils/paths.d.ts +0 -35
  278. package/lib/utils/paths.d.ts.map +0 -1
  279. package/lib/utils/paths.js +0 -313
  280. package/lib/utils/paths.js.map +0 -1
  281. package/lib/utils/promise-util.d.ts +0 -10
  282. package/lib/utils/promise-util.d.ts.map +0 -1
  283. package/lib/utils/promise-util.js +0 -17
  284. package/lib/utils/promise-util.js.map +0 -1
  285. package/lib/utils/strings.d.ts +0 -181
  286. package/lib/utils/strings.d.ts.map +0 -1
  287. package/lib/utils/strings.js +0 -858
  288. package/lib/utils/strings.js.map +0 -1
  289. package/lib/utils/types.d.ts +0 -69
  290. package/lib/utils/types.d.ts.map +0 -1
  291. package/lib/utils/types.js +0 -201
  292. package/lib/utils/types.js.map +0 -1
  293. package/lib/uuid.d.ts +0 -2
  294. package/lib/uuid.d.ts.map +0 -1
  295. package/lib/uuid.js +0 -10
  296. package/lib/uuid.js.map +0 -1
package/lib/map.js DELETED
@@ -1,819 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CaseInsensitiveMap = exports.SetMap = exports.LRUCache = exports.LinkedMap = exports.ResourceMap = exports.TernarySearchTree = exports.PathIterator = exports.StringIterator = exports.serializableToMap = exports.mapToSerializable = exports.setToString = exports.mapToString = exports.getOrSet = exports.keys = exports.values = void 0;
4
- const vscode_uri_1 = require("vscode-uri");
5
- const iterator_1 = require("./iterator");
6
- function values(forEachable) {
7
- const result = [];
8
- forEachable.forEach((value) => result.push(value));
9
- return result;
10
- }
11
- exports.values = values;
12
- function keys(map) {
13
- const result = [];
14
- map.forEach((value, key) => result.push(key));
15
- return result;
16
- }
17
- exports.keys = keys;
18
- function getOrSet(map, key, value) {
19
- let result = map.get(key);
20
- if (result === undefined) {
21
- result = value;
22
- map.set(key, result);
23
- }
24
- return result;
25
- }
26
- exports.getOrSet = getOrSet;
27
- function mapToString(map) {
28
- const entries = [];
29
- map.forEach((value, key) => {
30
- entries.push(`${key} => ${value}`);
31
- });
32
- return `Map(${map.size}) {${entries.join(', ')}}`;
33
- }
34
- exports.mapToString = mapToString;
35
- function setToString(set) {
36
- const entries = [];
37
- set.forEach((value) => {
38
- entries.push(value);
39
- });
40
- return `Set(${set.size}) {${entries.join(', ')}}`;
41
- }
42
- exports.setToString = setToString;
43
- function mapToSerializable(map) {
44
- const serializable = [];
45
- map.forEach((value, key) => {
46
- serializable.push([key, value]);
47
- });
48
- return serializable;
49
- }
50
- exports.mapToSerializable = mapToSerializable;
51
- function serializableToMap(serializable) {
52
- const items = new Map();
53
- for (const [key, value] of serializable) {
54
- items.set(key, value);
55
- }
56
- return items;
57
- }
58
- exports.serializableToMap = serializableToMap;
59
- class StringIterator {
60
- constructor() {
61
- this._value = '';
62
- this._pos = 0;
63
- }
64
- reset(key) {
65
- this._value = key;
66
- this._pos = 0;
67
- return this;
68
- }
69
- next() {
70
- this._pos += 1;
71
- return this;
72
- }
73
- hasNext() {
74
- return this._pos < this._value.length - 1;
75
- }
76
- cmp(a) {
77
- const aCode = a.charCodeAt(0);
78
- const thisCode = this._value.charCodeAt(this._pos);
79
- return aCode - thisCode;
80
- }
81
- value() {
82
- return this._value[this._pos];
83
- }
84
- }
85
- exports.StringIterator = StringIterator;
86
- class PathIterator {
87
- reset(key) {
88
- this._value = key.replace(/\\$|\/$/, '');
89
- this._from = 0;
90
- this._to = 0;
91
- return this.next();
92
- }
93
- hasNext() {
94
- return this._to < this._value.length;
95
- }
96
- next() {
97
- // this._data = key.split(/[\\/]/).filter(s => !!s);
98
- this._from = this._to;
99
- let justSeps = true;
100
- for (; this._to < this._value.length; this._to++) {
101
- const ch = this._value.charCodeAt(this._to);
102
- if (ch === 47 /* Slash */ || ch === 92 /* Backslash */) {
103
- if (justSeps) {
104
- this._from++;
105
- }
106
- else {
107
- break;
108
- }
109
- }
110
- else {
111
- justSeps = false;
112
- }
113
- }
114
- return this;
115
- }
116
- cmp(a) {
117
- let aPos = 0;
118
- const aLen = a.length;
119
- let thisPos = this._from;
120
- while (aPos < aLen && thisPos < this._to) {
121
- const cmp = a.charCodeAt(aPos) - this._value.charCodeAt(thisPos);
122
- if (cmp !== 0) {
123
- return cmp;
124
- }
125
- aPos += 1;
126
- thisPos += 1;
127
- }
128
- if (aLen === this._to - this._from) {
129
- return 0;
130
- }
131
- else if (aPos < aLen) {
132
- return -1;
133
- }
134
- else {
135
- return 1;
136
- }
137
- }
138
- value() {
139
- return this._value.substring(this._from, this._to);
140
- }
141
- }
142
- exports.PathIterator = PathIterator;
143
- class TernarySearchTreeNode {
144
- isEmpty() {
145
- return !this.left && !this.mid && !this.right && !this.value;
146
- }
147
- }
148
- class TernarySearchTree {
149
- constructor(segments) {
150
- this._iter = segments;
151
- }
152
- static forPaths() {
153
- return new TernarySearchTree(new PathIterator());
154
- }
155
- static forStrings() {
156
- return new TernarySearchTree(new StringIterator());
157
- }
158
- clear() {
159
- this._root = undefined;
160
- }
161
- set(key, element) {
162
- const iter = this._iter.reset(key);
163
- let node;
164
- if (!this._root) {
165
- this._root = new TernarySearchTreeNode();
166
- this._root.segment = iter.value();
167
- }
168
- node = this._root;
169
- while (true) {
170
- const val = iter.cmp(node.segment);
171
- if (val > 0) {
172
- // left
173
- if (!node.left) {
174
- node.left = new TernarySearchTreeNode();
175
- node.left.segment = iter.value();
176
- }
177
- node = node.left;
178
- }
179
- else if (val < 0) {
180
- // right
181
- if (!node.right) {
182
- node.right = new TernarySearchTreeNode();
183
- node.right.segment = iter.value();
184
- }
185
- node = node.right;
186
- }
187
- else if (iter.hasNext()) {
188
- // mid
189
- iter.next();
190
- if (!node.mid) {
191
- node.mid = new TernarySearchTreeNode();
192
- node.mid.segment = iter.value();
193
- }
194
- node = node.mid;
195
- }
196
- else {
197
- break;
198
- }
199
- }
200
- const oldElement = node.value;
201
- node.value = element;
202
- node.key = key;
203
- return oldElement;
204
- }
205
- get(key) {
206
- const iter = this._iter.reset(key);
207
- let node = this._root;
208
- while (node) {
209
- const val = iter.cmp(node.segment);
210
- if (val > 0) {
211
- // left
212
- node = node.left;
213
- }
214
- else if (val < 0) {
215
- // right
216
- node = node.right;
217
- }
218
- else if (iter.hasNext()) {
219
- // mid
220
- iter.next();
221
- node = node.mid;
222
- }
223
- else {
224
- break;
225
- }
226
- }
227
- return node ? node.value : undefined;
228
- }
229
- delete(key) {
230
- const iter = this._iter.reset(key);
231
- const stack = [];
232
- let node = this._root;
233
- // find and unset node
234
- while (node) {
235
- const val = iter.cmp(node.segment);
236
- if (val > 0) {
237
- // left
238
- stack.push([1, node]);
239
- node = node.left;
240
- }
241
- else if (val < 0) {
242
- // right
243
- stack.push([-1, node]);
244
- node = node.right;
245
- }
246
- else if (iter.hasNext()) {
247
- // mid
248
- iter.next();
249
- stack.push([0, node]);
250
- node = node.mid;
251
- }
252
- else {
253
- // remove element
254
- node.value = undefined;
255
- // clean up empty nodes
256
- while (stack.length > 0 && node.isEmpty()) {
257
- const [dir, parent] = stack.pop();
258
- switch (dir) {
259
- case 1:
260
- parent.left = undefined;
261
- break;
262
- case 0:
263
- parent.mid = undefined;
264
- break;
265
- case -1:
266
- parent.right = undefined;
267
- break;
268
- }
269
- node = parent;
270
- }
271
- break;
272
- }
273
- }
274
- }
275
- findSubstr(key) {
276
- const iter = this._iter.reset(key);
277
- let node = this._root;
278
- let candidate;
279
- while (node) {
280
- const val = iter.cmp(node.segment);
281
- if (val > 0) {
282
- // left
283
- node = node.left;
284
- }
285
- else if (val < 0) {
286
- // right
287
- node = node.right;
288
- }
289
- else if (iter.hasNext()) {
290
- // mid
291
- iter.next();
292
- candidate = node.value || candidate;
293
- node = node.mid;
294
- }
295
- else {
296
- break;
297
- }
298
- }
299
- return (node && node.value) || candidate;
300
- }
301
- findSuperstr(key) {
302
- const iter = this._iter.reset(key);
303
- let node = this._root;
304
- while (node) {
305
- const val = iter.cmp(node.segment);
306
- if (val > 0) {
307
- // left
308
- node = node.left;
309
- }
310
- else if (val < 0) {
311
- // right
312
- node = node.right;
313
- }
314
- else if (iter.hasNext()) {
315
- // mid
316
- iter.next();
317
- node = node.mid;
318
- }
319
- else {
320
- // collect
321
- if (!node.mid) {
322
- return undefined;
323
- }
324
- else {
325
- return this._nodeIterator(node.mid);
326
- }
327
- }
328
- }
329
- return undefined;
330
- }
331
- _nodeIterator(node) {
332
- let res;
333
- let idx;
334
- let data;
335
- const next = () => {
336
- if (!data) {
337
- // lazy till first invocation
338
- data = [];
339
- idx = 0;
340
- this._forEach(node, (value) => data.push(value));
341
- }
342
- if (idx >= data.length) {
343
- return iterator_1.FIN;
344
- }
345
- if (!res) {
346
- res = { done: false, value: data[idx++] };
347
- }
348
- else {
349
- res.value = data[idx++];
350
- }
351
- return res;
352
- };
353
- return { next };
354
- }
355
- forEach(callback) {
356
- this._forEach(this._root, callback);
357
- }
358
- _forEach(node, callback) {
359
- if (node) {
360
- // left
361
- this._forEach(node.left, callback);
362
- // node
363
- if (node.value) {
364
- // callback(node.value, this._iter.join(parts));
365
- callback(node.value, node.key);
366
- }
367
- // mid
368
- this._forEach(node.mid, callback);
369
- // right
370
- this._forEach(node.right, callback);
371
- }
372
- }
373
- }
374
- exports.TernarySearchTree = TernarySearchTree;
375
- class ResourceMap {
376
- constructor() {
377
- this.map = new Map();
378
- this.ignoreCase = false; // in the future this should be an uri-comparator
379
- }
380
- set(resource, value) {
381
- this.map.set(this.toKey(resource), value);
382
- }
383
- get(resource) {
384
- return this.map.get(this.toKey(resource));
385
- }
386
- has(resource) {
387
- return this.map.has(this.toKey(resource));
388
- }
389
- get size() {
390
- return this.map.size;
391
- }
392
- clear() {
393
- this.map.clear();
394
- }
395
- delete(resource) {
396
- return this.map.delete(this.toKey(resource));
397
- }
398
- forEach(clb) {
399
- this.map.forEach(clb);
400
- }
401
- values() {
402
- return values(this.map);
403
- }
404
- toKey(resource) {
405
- let key = resource.toString();
406
- if (this.ignoreCase) {
407
- key = key.toLowerCase();
408
- }
409
- return key;
410
- }
411
- keys() {
412
- return keys(this.map).map((k) => vscode_uri_1.URI.parse(k));
413
- }
414
- clone() {
415
- const resourceMap = new ResourceMap();
416
- this.map.forEach((value, key) => resourceMap.map.set(key, value));
417
- return resourceMap;
418
- }
419
- }
420
- exports.ResourceMap = ResourceMap;
421
- class LinkedMap {
422
- constructor() {
423
- this._map = new Map();
424
- this._head = undefined;
425
- this._tail = undefined;
426
- this._size = 0;
427
- }
428
- clear() {
429
- this._map.clear();
430
- this._head = undefined;
431
- this._tail = undefined;
432
- this._size = 0;
433
- }
434
- isEmpty() {
435
- return !this._head && !this._tail;
436
- }
437
- get size() {
438
- return this._size;
439
- }
440
- has(key) {
441
- return this._map.has(key);
442
- }
443
- get(key, touch = 0 /* None */) {
444
- const item = this._map.get(key);
445
- if (!item) {
446
- return undefined;
447
- }
448
- if (touch !== 0 /* None */) {
449
- this.touch(item, touch);
450
- }
451
- return item.value;
452
- }
453
- set(key, value, touch = 0 /* None */) {
454
- let item = this._map.get(key);
455
- if (item) {
456
- item.value = value;
457
- if (touch !== 0 /* None */) {
458
- this.touch(item, touch);
459
- }
460
- }
461
- else {
462
- item = { key, value, next: undefined, previous: undefined };
463
- switch (touch) {
464
- case 0 /* None */:
465
- this.addItemLast(item);
466
- break;
467
- case 1 /* AsOld */:
468
- this.addItemFirst(item);
469
- break;
470
- case 2 /* AsNew */:
471
- this.addItemLast(item);
472
- break;
473
- default:
474
- this.addItemLast(item);
475
- break;
476
- }
477
- this._map.set(key, item);
478
- this._size++;
479
- }
480
- }
481
- delete(key) {
482
- return !!this.remove(key);
483
- }
484
- remove(key) {
485
- const item = this._map.get(key);
486
- if (!item) {
487
- return undefined;
488
- }
489
- this._map.delete(key);
490
- this.removeItem(item);
491
- this._size--;
492
- return item.value;
493
- }
494
- shift() {
495
- if (!this._head && !this._tail) {
496
- return undefined;
497
- }
498
- if (!this._head || !this._tail) {
499
- throw new Error('Invalid list');
500
- }
501
- const item = this._head;
502
- this._map.delete(item.key);
503
- this.removeItem(item);
504
- this._size--;
505
- return item.value;
506
- }
507
- forEach(callbackfn, thisArg) {
508
- let current = this._head;
509
- while (current) {
510
- if (thisArg) {
511
- callbackfn.bind(thisArg)(current.value, current.key, this);
512
- }
513
- else {
514
- callbackfn(current.value, current.key, this);
515
- }
516
- current = current.next;
517
- }
518
- }
519
- values() {
520
- const result = [];
521
- let current = this._head;
522
- while (current) {
523
- result.push(current.value);
524
- current = current.next;
525
- }
526
- return result;
527
- }
528
- keys() {
529
- const result = [];
530
- let current = this._head;
531
- while (current) {
532
- result.push(current.key);
533
- current = current.next;
534
- }
535
- return result;
536
- }
537
- /* VS Code / Monaco editor runs on es5 which has no Symbol.iterator
538
- keys(): IterableIterator<K> {
539
- const current = this._head;
540
- const iterator: IterableIterator<K> = {
541
- [Symbol.iterator]() {
542
- return iterator;
543
- },
544
- next():IteratorResult<K> {
545
- if (current) {
546
- const result = { value: current.key, done: false };
547
- current = current.next;
548
- return result;
549
- } else {
550
- return { value: undefined, done: true };
551
- }
552
- }
553
- };
554
- return iterator;
555
- }
556
-
557
- values(): IterableIterator<V> {
558
- const current = this._head;
559
- const iterator: IterableIterator<V> = {
560
- [Symbol.iterator]() {
561
- return iterator;
562
- },
563
- next():IteratorResult<V> {
564
- if (current) {
565
- const result = { value: current.value, done: false };
566
- current = current.next;
567
- return result;
568
- } else {
569
- return { value: undefined, done: true };
570
- }
571
- }
572
- };
573
- return iterator;
574
- }
575
- */
576
- trimOld(newSize) {
577
- if (newSize >= this.size) {
578
- return;
579
- }
580
- if (newSize === 0) {
581
- this.clear();
582
- return;
583
- }
584
- let current = this._head;
585
- let currentSize = this.size;
586
- while (current && currentSize > newSize) {
587
- this._map.delete(current.key);
588
- current = current.next;
589
- currentSize--;
590
- }
591
- this._head = current;
592
- this._size = currentSize;
593
- if (current) {
594
- current.previous = undefined;
595
- }
596
- }
597
- addItemFirst(item) {
598
- // First time Insert
599
- if (!this._head && !this._tail) {
600
- this._tail = item;
601
- }
602
- else if (!this._head) {
603
- throw new Error('Invalid list');
604
- }
605
- else {
606
- item.next = this._head;
607
- this._head.previous = item;
608
- }
609
- this._head = item;
610
- }
611
- addItemLast(item) {
612
- // First time Insert
613
- if (!this._head && !this._tail) {
614
- this._head = item;
615
- }
616
- else if (!this._tail) {
617
- throw new Error('Invalid list');
618
- }
619
- else {
620
- item.previous = this._tail;
621
- this._tail.next = item;
622
- }
623
- this._tail = item;
624
- }
625
- removeItem(item) {
626
- if (item === this._head && item === this._tail) {
627
- this._head = undefined;
628
- this._tail = undefined;
629
- }
630
- else if (item === this._head) {
631
- // This can only happend if size === 1 which is handle
632
- // by the case above.
633
- if (!item.next) {
634
- throw new Error('Invalid list');
635
- }
636
- item.next.previous = undefined;
637
- this._head = item.next;
638
- }
639
- else if (item === this._tail) {
640
- // This can only happend if size === 1 which is handle
641
- // by the case above.
642
- if (!item.previous) {
643
- throw new Error('Invalid list');
644
- }
645
- item.previous.next = undefined;
646
- this._tail = item.previous;
647
- }
648
- else {
649
- const next = item.next;
650
- const previous = item.previous;
651
- if (!next || !previous) {
652
- throw new Error('Invalid list');
653
- }
654
- next.previous = previous;
655
- previous.next = next;
656
- }
657
- item.next = undefined;
658
- item.previous = undefined;
659
- }
660
- touch(item, touch) {
661
- if (!this._head || !this._tail) {
662
- throw new Error('Invalid list');
663
- }
664
- if (touch !== 1 /* AsOld */ && touch !== 2 /* AsNew */) {
665
- return;
666
- }
667
- if (touch === 1 /* AsOld */) {
668
- if (item === this._head) {
669
- return;
670
- }
671
- const next = item.next;
672
- const previous = item.previous;
673
- // Unlink the item
674
- if (item === this._tail) {
675
- // previous must be defined since item was not head but is tail
676
- // So there are more than on item in the map
677
- previous.next = undefined;
678
- this._tail = previous;
679
- }
680
- else {
681
- // Both next and previous are not undefined since item was neither head nor tail.
682
- next.previous = previous;
683
- previous.next = next;
684
- }
685
- // Insert the node at head
686
- item.previous = undefined;
687
- item.next = this._head;
688
- this._head.previous = item;
689
- this._head = item;
690
- }
691
- else if (touch === 2 /* AsNew */) {
692
- if (item === this._tail) {
693
- return;
694
- }
695
- const next = item.next;
696
- const previous = item.previous;
697
- // Unlink the item.
698
- if (item === this._head) {
699
- // next must be defined since item was not tail but is head
700
- // So there are more than on item in the map
701
- next.previous = undefined;
702
- this._head = next;
703
- }
704
- else {
705
- // Both next and previous are not undefined since item was neither head nor tail.
706
- next.previous = previous;
707
- previous.next = next;
708
- }
709
- item.next = undefined;
710
- item.previous = this._tail;
711
- this._tail.next = item;
712
- this._tail = item;
713
- }
714
- }
715
- toJSON() {
716
- const data = [];
717
- this.forEach((value, key) => {
718
- data.push([key, value]);
719
- });
720
- return data;
721
- }
722
- fromJSON(data) {
723
- this.clear();
724
- for (const [key, value] of data) {
725
- this.set(key, value);
726
- }
727
- }
728
- }
729
- exports.LinkedMap = LinkedMap;
730
- class LRUCache extends LinkedMap {
731
- constructor(limit, ratio = 1) {
732
- super();
733
- this._limit = limit;
734
- this._ratio = Math.min(Math.max(0, ratio), 1);
735
- }
736
- get limit() {
737
- return this._limit;
738
- }
739
- set limit(limit) {
740
- this._limit = limit;
741
- this.checkTrim();
742
- }
743
- get ratio() {
744
- return this._ratio;
745
- }
746
- set ratio(ratio) {
747
- this._ratio = Math.min(Math.max(0, ratio), 1);
748
- this.checkTrim();
749
- }
750
- get(key) {
751
- return super.get(key, 2 /* AsNew */);
752
- }
753
- peek(key) {
754
- return super.get(key, 0 /* None */);
755
- }
756
- set(key, value) {
757
- super.set(key, value, 2 /* AsNew */);
758
- this.checkTrim();
759
- }
760
- checkTrim() {
761
- if (this.size > this._limit) {
762
- this.trimOld(Math.round(this._limit * this._ratio));
763
- }
764
- }
765
- }
766
- exports.LRUCache = LRUCache;
767
- class SetMap {
768
- constructor() {
769
- this.map = new Map();
770
- }
771
- add(key, value) {
772
- let values = this.map.get(key);
773
- if (!values) {
774
- values = new Set();
775
- this.map.set(key, values);
776
- }
777
- values.add(value);
778
- }
779
- delete(key, value) {
780
- const values = this.map.get(key);
781
- if (!values) {
782
- return;
783
- }
784
- values.delete(value);
785
- if (values.size === 0) {
786
- this.map.delete(key);
787
- }
788
- }
789
- forEach(key, fn) {
790
- const values = this.map.get(key);
791
- if (!values) {
792
- return;
793
- }
794
- values.forEach(fn);
795
- }
796
- }
797
- exports.SetMap = SetMap;
798
- class CaseInsensitiveMap extends Map {
799
- set(key, value) {
800
- if (typeof key === 'string') {
801
- key = key.toLowerCase();
802
- }
803
- return super.set(key, value);
804
- }
805
- get(key) {
806
- if (typeof key === 'string') {
807
- key = key.toLowerCase();
808
- }
809
- return super.get(key);
810
- }
811
- has(key) {
812
- if (typeof key === 'string') {
813
- key = key.toLowerCase();
814
- }
815
- return super.has(key);
816
- }
817
- }
818
- exports.CaseInsensitiveMap = CaseInsensitiveMap;
819
- //# sourceMappingURL=map.js.map