@codingame/monaco-vscode-extensions-service-override 1.83.8 → 1.83.9
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.
- package/assets/webWorkerExtensionHostIframe.html +123 -0
- package/extensions.d.ts +12 -13
- package/extensions.js +456 -0
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/override/vs/platform/dialogs/common/dialogs.js +8 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +8 -0
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +3 -0
- package/package.json +5 -3
- package/tools/url.js +10 -0
- package/tools.js +5 -0
- package/vscode/src/vs/base/common/console.js +59 -0
- package/vscode/src/vs/base/common/prefixTree.js +131 -0
- package/vscode/src/vs/platform/files/common/watcher.js +71 -0
- package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +27 -0
- package/vscode/src/vs/platform/log/browser/log.js +26 -0
- package/vscode/src/vs/platform/remote/common/managedSocket.js +98 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +31 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +330 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +174 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents.js +52 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatProvider.js +61 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatSlashCommands.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +31 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +107 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +94 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +541 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +80 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +578 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +387 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +102 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +69 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +75 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +249 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +370 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +22 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +41 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +411 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +475 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +227 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +317 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +280 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +283 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +28 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +33 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +27 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +947 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +78 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +35 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +78 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +93 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +118 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +158 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +123 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +188 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +129 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +131 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +341 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +25 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +48 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +76 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.js +38 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +68 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +185 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +30 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +463 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +148 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +70 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +50 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +53 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +72 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +731 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +53 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +412 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +182 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +55 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +313 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +223 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +110 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +61 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +29 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +283 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +100 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +135 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +57 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +273 -0
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHost.api.impl.d.ts +2 -2
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostConfiguration.d.ts +3 -3
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostExtensionService.d.ts +3 -4
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostManagedSockets.d.ts +2 -2
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTerminalService.d.ts +19 -20
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTunnelService.d.ts +7 -8
- package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostWorkspace.d.ts +25 -26
- package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +217 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +57 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +51 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +92 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +648 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +297 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +62 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +109 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +109 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +331 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +380 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +5 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1196 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +19 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +334 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +543 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +178 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +101 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +57 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +145 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +3 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +73 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +83 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +179 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +144 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +482 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +6 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +85 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +56 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +110 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +260 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +616 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +309 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +38 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +167 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +80 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +70 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +108 -0
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +506 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +132 -0
- package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +103 -0
- package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +28 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testCoverage.js +25 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +336 -0
- package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +46 -0
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +283 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +273 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +52 -0
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +1093 -0
- package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +41 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +25 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +643 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +274 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +58 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +80 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +64 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +49 -0
- package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +220 -0
- package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +5 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +79 -0
- package/vscode-proposed.d.ts +0 -3872
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHost.protocol.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostExtensionActivator.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostFileSystemInfo.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostInitDataService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostLocalizationService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostRpcService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostStoragePaths.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostTypes.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/common/extHostUriTransformerService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/api/worker/extHostExtensionService.d.ts +0 -0
- /package/{dist/main/vscode → vscode}/src/vs/workbench/services/search/common/queryBuilder.d.ts +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { compareBy, numberComparator } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
2
|
+
import { BugIndicatingError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
3
|
+
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
4
|
+
|
|
5
|
+
class LineRange {
|
|
6
|
+
static { this.compareByStart = compareBy(l => l.startLineNumber, numberComparator); }
|
|
7
|
+
static join(ranges) {
|
|
8
|
+
if (ranges.length === 0) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
let startLineNumber = Number.MAX_SAFE_INTEGER;
|
|
12
|
+
let endLineNumber = 0;
|
|
13
|
+
for (const range of ranges) {
|
|
14
|
+
startLineNumber = Math.min(startLineNumber, range.startLineNumber);
|
|
15
|
+
endLineNumber = Math.max(endLineNumber, range.startLineNumber + range.lineCount);
|
|
16
|
+
}
|
|
17
|
+
return ( new LineRange(startLineNumber, endLineNumber - startLineNumber));
|
|
18
|
+
}
|
|
19
|
+
static fromLineNumbers(startLineNumber, endExclusiveLineNumber) {
|
|
20
|
+
return ( new LineRange(startLineNumber, endExclusiveLineNumber - startLineNumber));
|
|
21
|
+
}
|
|
22
|
+
constructor(startLineNumber, lineCount) {
|
|
23
|
+
this.startLineNumber = startLineNumber;
|
|
24
|
+
this.lineCount = lineCount;
|
|
25
|
+
if (lineCount < 0) {
|
|
26
|
+
throw new BugIndicatingError();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
join(other) {
|
|
30
|
+
return ( new LineRange(
|
|
31
|
+
Math.min(this.startLineNumber, other.startLineNumber),
|
|
32
|
+
Math.max(this.endLineNumberExclusive, other.endLineNumberExclusive) - this.startLineNumber
|
|
33
|
+
));
|
|
34
|
+
}
|
|
35
|
+
get endLineNumberExclusive() {
|
|
36
|
+
return this.startLineNumber + this.lineCount;
|
|
37
|
+
}
|
|
38
|
+
get isEmpty() {
|
|
39
|
+
return this.lineCount === 0;
|
|
40
|
+
}
|
|
41
|
+
touches(other) {
|
|
42
|
+
return (this.endLineNumberExclusive >= other.startLineNumber &&
|
|
43
|
+
other.endLineNumberExclusive >= this.startLineNumber);
|
|
44
|
+
}
|
|
45
|
+
isAfter(range) {
|
|
46
|
+
return this.startLineNumber >= range.endLineNumberExclusive;
|
|
47
|
+
}
|
|
48
|
+
isBefore(range) {
|
|
49
|
+
return range.startLineNumber >= this.endLineNumberExclusive;
|
|
50
|
+
}
|
|
51
|
+
delta(lineDelta) {
|
|
52
|
+
return ( new LineRange(this.startLineNumber + lineDelta, this.lineCount));
|
|
53
|
+
}
|
|
54
|
+
toString() {
|
|
55
|
+
return `[${this.startLineNumber},${this.endLineNumberExclusive})`;
|
|
56
|
+
}
|
|
57
|
+
equals(originalRange) {
|
|
58
|
+
return this.startLineNumber === originalRange.startLineNumber && this.lineCount === originalRange.lineCount;
|
|
59
|
+
}
|
|
60
|
+
contains(lineNumber) {
|
|
61
|
+
return this.startLineNumber <= lineNumber && lineNumber < this.endLineNumberExclusive;
|
|
62
|
+
}
|
|
63
|
+
deltaEnd(delta) {
|
|
64
|
+
return ( new LineRange(this.startLineNumber, this.lineCount + delta));
|
|
65
|
+
}
|
|
66
|
+
deltaStart(lineDelta) {
|
|
67
|
+
return ( new LineRange(this.startLineNumber + lineDelta, this.lineCount - lineDelta));
|
|
68
|
+
}
|
|
69
|
+
getLines(model) {
|
|
70
|
+
const result = ( new Array(this.lineCount));
|
|
71
|
+
for (let i = 0; i < this.lineCount; i++) {
|
|
72
|
+
result[i] = model.getLineContent(this.startLineNumber + i);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
containsRange(range) {
|
|
77
|
+
return this.startLineNumber <= range.startLineNumber && range.endLineNumberExclusive <= this.endLineNumberExclusive;
|
|
78
|
+
}
|
|
79
|
+
toRange() {
|
|
80
|
+
return ( new Range(this.startLineNumber, 1, this.endLineNumberExclusive, 1));
|
|
81
|
+
}
|
|
82
|
+
toInclusiveRange() {
|
|
83
|
+
if (this.isEmpty) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return ( new Range(
|
|
87
|
+
this.startLineNumber,
|
|
88
|
+
1,
|
|
89
|
+
this.endLineNumberExclusive - 1,
|
|
90
|
+
1073741824
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
toInclusiveRangeOrEmpty() {
|
|
94
|
+
if (this.isEmpty) {
|
|
95
|
+
return ( new Range(this.startLineNumber, 1, this.startLineNumber, 1));
|
|
96
|
+
}
|
|
97
|
+
return ( new Range(
|
|
98
|
+
this.startLineNumber,
|
|
99
|
+
1,
|
|
100
|
+
this.endLineNumberExclusive - 1,
|
|
101
|
+
1073741824
|
|
102
|
+
));
|
|
103
|
+
}
|
|
104
|
+
intersects(lineRange) {
|
|
105
|
+
return this.startLineNumber <= lineRange.endLineNumberExclusive
|
|
106
|
+
&& lineRange.startLineNumber <= this.endLineNumberExclusive;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { LineRange };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { lastOrDefault, compareBy, numberComparator } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
2
|
+
import { findLast } from 'monaco-editor/esm/vs/base/common/arraysFind.js';
|
|
3
|
+
import { assertFn, checkAdjacentItems } from 'monaco-editor/esm/vs/base/common/assert.js';
|
|
4
|
+
import { BugIndicatingError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
5
|
+
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
6
|
+
import { concatArrays } from '../utils.js';
|
|
7
|
+
import { LineRangeEdit } from './editing.js';
|
|
8
|
+
import { LineRange } from './lineRange.js';
|
|
9
|
+
import { rangeIsBeforeOrTouching, rangeContainsPosition, lengthBetweenPositions, addLength } from './rangeUtils.js';
|
|
10
|
+
|
|
11
|
+
class LineRangeMapping {
|
|
12
|
+
static join(mappings) {
|
|
13
|
+
return mappings.reduce((acc, cur) => acc ? acc.join(cur) : cur, undefined);
|
|
14
|
+
}
|
|
15
|
+
constructor(inputRange, outputRange) {
|
|
16
|
+
this.inputRange = inputRange;
|
|
17
|
+
this.outputRange = outputRange;
|
|
18
|
+
}
|
|
19
|
+
extendInputRange(extendedInputRange) {
|
|
20
|
+
if (!extendedInputRange.containsRange(this.inputRange)) {
|
|
21
|
+
throw new BugIndicatingError();
|
|
22
|
+
}
|
|
23
|
+
const startDelta = extendedInputRange.startLineNumber - this.inputRange.startLineNumber;
|
|
24
|
+
const endDelta = extendedInputRange.endLineNumberExclusive - this.inputRange.endLineNumberExclusive;
|
|
25
|
+
return ( new LineRangeMapping(extendedInputRange, ( new LineRange(
|
|
26
|
+
this.outputRange.startLineNumber + startDelta,
|
|
27
|
+
this.outputRange.lineCount - startDelta + endDelta
|
|
28
|
+
))));
|
|
29
|
+
}
|
|
30
|
+
join(other) {
|
|
31
|
+
return ( new LineRangeMapping(
|
|
32
|
+
this.inputRange.join(other.inputRange),
|
|
33
|
+
this.outputRange.join(other.outputRange)
|
|
34
|
+
));
|
|
35
|
+
}
|
|
36
|
+
get resultingDeltaFromOriginalToModified() {
|
|
37
|
+
return this.outputRange.endLineNumberExclusive - this.inputRange.endLineNumberExclusive;
|
|
38
|
+
}
|
|
39
|
+
toString() {
|
|
40
|
+
return `${( this.inputRange.toString())} -> ${( this.outputRange.toString())}`;
|
|
41
|
+
}
|
|
42
|
+
addOutputLineDelta(delta) {
|
|
43
|
+
return ( new LineRangeMapping(this.inputRange, this.outputRange.delta(delta)));
|
|
44
|
+
}
|
|
45
|
+
addInputLineDelta(delta) {
|
|
46
|
+
return ( new LineRangeMapping(this.inputRange.delta(delta), this.outputRange));
|
|
47
|
+
}
|
|
48
|
+
reverse() {
|
|
49
|
+
return ( new LineRangeMapping(this.outputRange, this.inputRange));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class DocumentLineRangeMap {
|
|
53
|
+
static betweenOutputs(inputToOutput1, inputToOutput2, inputLineCount) {
|
|
54
|
+
const alignments = MappingAlignment.compute(inputToOutput1, inputToOutput2);
|
|
55
|
+
const mappings = ( alignments.map((m) => ( new LineRangeMapping(m.output1Range, m.output2Range))));
|
|
56
|
+
return ( new DocumentLineRangeMap(mappings, inputLineCount));
|
|
57
|
+
}
|
|
58
|
+
constructor(
|
|
59
|
+
lineRangeMappings, inputLineCount) {
|
|
60
|
+
this.lineRangeMappings = lineRangeMappings;
|
|
61
|
+
this.inputLineCount = inputLineCount;
|
|
62
|
+
assertFn(() => {
|
|
63
|
+
return checkAdjacentItems(lineRangeMappings, (m1, m2) => m1.inputRange.isBefore(m2.inputRange) && m1.outputRange.isBefore(m2.outputRange) &&
|
|
64
|
+
m2.inputRange.startLineNumber - m1.inputRange.endLineNumberExclusive === m2.outputRange.startLineNumber - m1.outputRange.endLineNumberExclusive);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
project(lineNumber) {
|
|
68
|
+
const lastBefore = findLast(this.lineRangeMappings, r => r.inputRange.startLineNumber <= lineNumber);
|
|
69
|
+
if (!lastBefore) {
|
|
70
|
+
return ( new LineRangeMapping(( new LineRange(lineNumber, 1)), ( new LineRange(lineNumber, 1))));
|
|
71
|
+
}
|
|
72
|
+
if (lastBefore.inputRange.contains(lineNumber)) {
|
|
73
|
+
return lastBefore;
|
|
74
|
+
}
|
|
75
|
+
const containingRange = ( new LineRange(lineNumber, 1));
|
|
76
|
+
const mappedRange = ( new LineRange(lineNumber +
|
|
77
|
+
lastBefore.outputRange.endLineNumberExclusive -
|
|
78
|
+
lastBefore.inputRange.endLineNumberExclusive, 1));
|
|
79
|
+
return ( new LineRangeMapping(containingRange, mappedRange));
|
|
80
|
+
}
|
|
81
|
+
get outputLineCount() {
|
|
82
|
+
const last = lastOrDefault(this.lineRangeMappings);
|
|
83
|
+
const diff = last ? last.outputRange.endLineNumberExclusive - last.inputRange.endLineNumberExclusive : 0;
|
|
84
|
+
return this.inputLineCount + diff;
|
|
85
|
+
}
|
|
86
|
+
reverse() {
|
|
87
|
+
return ( new DocumentLineRangeMap(( this.lineRangeMappings.map(r => r.reverse())), this.outputLineCount));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class MappingAlignment {
|
|
91
|
+
static compute(fromInputToOutput1, fromInputToOutput2) {
|
|
92
|
+
const compareByStartLineNumber = compareBy((d) => d.inputRange.startLineNumber, numberComparator);
|
|
93
|
+
const combinedDiffs = concatArrays(( fromInputToOutput1.map((diff) => ({ source: 0, diff }))), ( fromInputToOutput2.map((diff) => ({ source: 1, diff })))).sort(compareBy((d) => d.diff, compareByStartLineNumber));
|
|
94
|
+
const currentDiffs = [( new Array()), ( new Array())];
|
|
95
|
+
const deltaFromBaseToInput = [0, 0];
|
|
96
|
+
const alignments = ( new Array());
|
|
97
|
+
function pushAndReset(inputRange) {
|
|
98
|
+
const mapping1 = LineRangeMapping.join(currentDiffs[0]) || ( new LineRangeMapping(inputRange, inputRange.delta(deltaFromBaseToInput[0])));
|
|
99
|
+
const mapping2 = LineRangeMapping.join(currentDiffs[1]) || ( new LineRangeMapping(inputRange, inputRange.delta(deltaFromBaseToInput[1])));
|
|
100
|
+
alignments.push(( new MappingAlignment(
|
|
101
|
+
currentInputRange,
|
|
102
|
+
mapping1.extendInputRange(currentInputRange).outputRange,
|
|
103
|
+
currentDiffs[0],
|
|
104
|
+
mapping2.extendInputRange(currentInputRange).outputRange,
|
|
105
|
+
currentDiffs[1]
|
|
106
|
+
)));
|
|
107
|
+
currentDiffs[0] = [];
|
|
108
|
+
currentDiffs[1] = [];
|
|
109
|
+
}
|
|
110
|
+
let currentInputRange;
|
|
111
|
+
for (const diff of combinedDiffs) {
|
|
112
|
+
const range = diff.diff.inputRange;
|
|
113
|
+
if (currentInputRange && !currentInputRange.touches(range)) {
|
|
114
|
+
pushAndReset(currentInputRange);
|
|
115
|
+
currentInputRange = undefined;
|
|
116
|
+
}
|
|
117
|
+
deltaFromBaseToInput[diff.source] =
|
|
118
|
+
diff.diff.resultingDeltaFromOriginalToModified;
|
|
119
|
+
currentInputRange = currentInputRange ? currentInputRange.join(range) : range;
|
|
120
|
+
currentDiffs[diff.source].push(diff.diff);
|
|
121
|
+
}
|
|
122
|
+
if (currentInputRange) {
|
|
123
|
+
pushAndReset(currentInputRange);
|
|
124
|
+
}
|
|
125
|
+
return alignments;
|
|
126
|
+
}
|
|
127
|
+
constructor(inputRange, output1Range, output1LineMappings, output2Range, output2LineMappings) {
|
|
128
|
+
this.inputRange = inputRange;
|
|
129
|
+
this.output1Range = output1Range;
|
|
130
|
+
this.output1LineMappings = output1LineMappings;
|
|
131
|
+
this.output2Range = output2Range;
|
|
132
|
+
this.output2LineMappings = output2LineMappings;
|
|
133
|
+
}
|
|
134
|
+
toString() {
|
|
135
|
+
return `${this.output1Range} <- ${this.inputRange} -> ${this.output2Range}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class DetailedLineRangeMapping extends LineRangeMapping {
|
|
139
|
+
static join(mappings) {
|
|
140
|
+
return mappings.reduce((acc, cur) => acc ? acc.join(cur) : cur, undefined);
|
|
141
|
+
}
|
|
142
|
+
constructor(inputRange, inputTextModel, outputRange, outputTextModel, rangeMappings) {
|
|
143
|
+
super(inputRange, outputRange);
|
|
144
|
+
this.inputTextModel = inputTextModel;
|
|
145
|
+
this.outputTextModel = outputTextModel;
|
|
146
|
+
this.rangeMappings = rangeMappings || [( new RangeMapping(this.inputRange.toRange(), this.outputRange.toRange()))];
|
|
147
|
+
}
|
|
148
|
+
addOutputLineDelta(delta) {
|
|
149
|
+
return ( new DetailedLineRangeMapping(
|
|
150
|
+
this.inputRange,
|
|
151
|
+
this.inputTextModel,
|
|
152
|
+
this.outputRange.delta(delta),
|
|
153
|
+
this.outputTextModel,
|
|
154
|
+
( this.rangeMappings.map(d => d.addOutputLineDelta(delta)))
|
|
155
|
+
));
|
|
156
|
+
}
|
|
157
|
+
addInputLineDelta(delta) {
|
|
158
|
+
return ( new DetailedLineRangeMapping(
|
|
159
|
+
this.inputRange.delta(delta),
|
|
160
|
+
this.inputTextModel,
|
|
161
|
+
this.outputRange,
|
|
162
|
+
this.outputTextModel,
|
|
163
|
+
( this.rangeMappings.map(d => d.addInputLineDelta(delta)))
|
|
164
|
+
));
|
|
165
|
+
}
|
|
166
|
+
join(other) {
|
|
167
|
+
return ( new DetailedLineRangeMapping(
|
|
168
|
+
this.inputRange.join(other.inputRange),
|
|
169
|
+
this.inputTextModel,
|
|
170
|
+
this.outputRange.join(other.outputRange),
|
|
171
|
+
this.outputTextModel
|
|
172
|
+
));
|
|
173
|
+
}
|
|
174
|
+
getLineEdit() {
|
|
175
|
+
return ( new LineRangeEdit(this.inputRange, this.getOutputLines()));
|
|
176
|
+
}
|
|
177
|
+
getReverseLineEdit() {
|
|
178
|
+
return ( new LineRangeEdit(this.outputRange, this.getInputLines()));
|
|
179
|
+
}
|
|
180
|
+
getOutputLines() {
|
|
181
|
+
return this.outputRange.getLines(this.outputTextModel);
|
|
182
|
+
}
|
|
183
|
+
getInputLines() {
|
|
184
|
+
return this.inputRange.getLines(this.inputTextModel);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
class RangeMapping {
|
|
188
|
+
constructor(inputRange, outputRange) {
|
|
189
|
+
this.inputRange = inputRange;
|
|
190
|
+
this.outputRange = outputRange;
|
|
191
|
+
}
|
|
192
|
+
toString() {
|
|
193
|
+
function rangeToString(range) {
|
|
194
|
+
return `[${range.startLineNumber}:${range.startColumn}, ${range.endLineNumber}:${range.endColumn})`;
|
|
195
|
+
}
|
|
196
|
+
return `${rangeToString(this.inputRange)} -> ${rangeToString(this.outputRange)}`;
|
|
197
|
+
}
|
|
198
|
+
addOutputLineDelta(deltaLines) {
|
|
199
|
+
return ( new RangeMapping(this.inputRange, ( new Range(
|
|
200
|
+
this.outputRange.startLineNumber + deltaLines,
|
|
201
|
+
this.outputRange.startColumn,
|
|
202
|
+
this.outputRange.endLineNumber + deltaLines,
|
|
203
|
+
this.outputRange.endColumn
|
|
204
|
+
))));
|
|
205
|
+
}
|
|
206
|
+
addInputLineDelta(deltaLines) {
|
|
207
|
+
return ( new RangeMapping(( new Range(
|
|
208
|
+
this.inputRange.startLineNumber + deltaLines,
|
|
209
|
+
this.inputRange.startColumn,
|
|
210
|
+
this.inputRange.endLineNumber + deltaLines,
|
|
211
|
+
this.inputRange.endColumn
|
|
212
|
+
)), this.outputRange));
|
|
213
|
+
}
|
|
214
|
+
reverse() {
|
|
215
|
+
return ( new RangeMapping(this.outputRange, this.inputRange));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
class DocumentRangeMap {
|
|
219
|
+
constructor(
|
|
220
|
+
rangeMappings, inputLineCount) {
|
|
221
|
+
this.rangeMappings = rangeMappings;
|
|
222
|
+
this.inputLineCount = inputLineCount;
|
|
223
|
+
assertFn(() => checkAdjacentItems(rangeMappings, (m1, m2) => rangeIsBeforeOrTouching(m1.inputRange, m2.inputRange) &&
|
|
224
|
+
rangeIsBeforeOrTouching(m1.outputRange, m2.outputRange)
|
|
225
|
+
));
|
|
226
|
+
}
|
|
227
|
+
project(position) {
|
|
228
|
+
const lastBefore = findLast(this.rangeMappings, r => r.inputRange.getStartPosition().isBeforeOrEqual(position));
|
|
229
|
+
if (!lastBefore) {
|
|
230
|
+
return ( new RangeMapping(
|
|
231
|
+
Range.fromPositions(position, position),
|
|
232
|
+
Range.fromPositions(position, position)
|
|
233
|
+
));
|
|
234
|
+
}
|
|
235
|
+
if (rangeContainsPosition(lastBefore.inputRange, position)) {
|
|
236
|
+
return lastBefore;
|
|
237
|
+
}
|
|
238
|
+
const dist = lengthBetweenPositions(lastBefore.inputRange.getEndPosition(), position);
|
|
239
|
+
const outputPos = addLength(lastBefore.outputRange.getEndPosition(), dist);
|
|
240
|
+
return ( new RangeMapping(Range.fromPositions(position), Range.fromPositions(outputPos)));
|
|
241
|
+
}
|
|
242
|
+
projectRange(range) {
|
|
243
|
+
const start = this.project(range.getStartPosition());
|
|
244
|
+
const end = this.project(range.getEndPosition());
|
|
245
|
+
return ( new RangeMapping(
|
|
246
|
+
start.inputRange.plusRange(end.inputRange),
|
|
247
|
+
start.outputRange.plusRange(end.outputRange)
|
|
248
|
+
));
|
|
249
|
+
}
|
|
250
|
+
get outputLineCount() {
|
|
251
|
+
const last = lastOrDefault(this.rangeMappings);
|
|
252
|
+
const diff = last ? last.outputRange.endLineNumber - last.inputRange.endLineNumber : 0;
|
|
253
|
+
return this.inputLineCount + diff;
|
|
254
|
+
}
|
|
255
|
+
reverse() {
|
|
256
|
+
return ( new DocumentRangeMap(( this.rangeMappings.map(m => m.reverse())), this.outputLineCount));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { DetailedLineRangeMapping, DocumentLineRangeMap, DocumentRangeMap, LineRangeMapping, MappingAlignment, RangeMapping };
|