lean4monaco 1.0.46 → 1.1.0
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/README.md +75 -0
- package/dist/JuliaMono-Regular.ttf +0 -0
- package/dist/css/custom.css +7 -1
- package/dist/infowebview.d.ts +3 -4
- package/dist/infowebview.js +4 -4
- package/dist/lean4-infoview/codicon.ttf +0 -0
- package/dist/lean4-infoview/esm-shims/react-dom.d.ts +5 -0
- package/dist/lean4-infoview/esm-shims/react-jsx-runtime.d.ts +5 -0
- package/dist/lean4-infoview/esm-shims/react.d.ts +5 -0
- package/dist/lean4-infoview/index.css +4161 -0
- package/dist/lean4-infoview/index.d.ts +16 -0
- package/dist/lean4-infoview/index.development.js +37312 -0
- package/dist/lean4-infoview/index.production.min.js +1528 -0
- package/dist/lean4-infoview/infoview/collapsing.d.ts +12 -0
- package/dist/lean4-infoview/infoview/contexts.d.ts +10 -0
- package/dist/lean4-infoview/infoview/editorConnection.d.ts +22 -0
- package/dist/lean4-infoview/infoview/errors.d.ts +14 -0
- package/dist/lean4-infoview/infoview/event.d.ts +33 -0
- package/dist/lean4-infoview/infoview/goalLocation.d.ts +61 -0
- package/dist/lean4-infoview/infoview/goals.d.ts +46 -0
- package/dist/lean4-infoview/infoview/info.d.ts +18 -0
- package/dist/lean4-infoview/infoview/infos.d.ts +2 -0
- package/dist/lean4-infoview/infoview/interactiveCode.d.ts +19 -0
- package/dist/lean4-infoview/infoview/main.d.ts +13 -0
- package/dist/lean4-infoview/infoview/messages.d.ts +19 -0
- package/dist/lean4-infoview/infoview/rpcSessions.d.ts +11 -0
- package/dist/lean4-infoview/infoview/serverVersion.d.ts +10 -0
- package/dist/lean4-infoview/infoview/tooltips.d.ts +32 -0
- package/dist/lean4-infoview/infoview/traceExplorer.d.ts +11 -0
- package/dist/lean4-infoview/infoview/userWidget.d.ts +39 -0
- package/dist/lean4-infoview/infoview/util.d.ts +144 -0
- package/dist/lean4-infoview/loader.d.ts +20 -0
- package/dist/lean4-infoview/loader.development.js +1006 -0
- package/dist/lean4-infoview/loader.production.min.js +1 -0
- package/dist/lean4-infoview/react-dom.development.js +30537 -0
- package/dist/lean4-infoview/react-dom.production.min.js +21 -0
- package/dist/lean4-infoview/react-jsx-runtime.development.js +1362 -0
- package/dist/lean4-infoview/react-jsx-runtime.production.min.js +1 -0
- package/dist/lean4-infoview/react.development.js +2823 -0
- package/dist/lean4-infoview/react.production.min.js +1 -0
- package/dist/leanmonaco.js +5 -4
- package/dist/monaco-lean4/vscode-lean4/package.json +944 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +9 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +20 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.d.ts +12 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.js +40 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +20 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +79 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.d.ts +13 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.js +29 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +28 -0
- package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +124 -0
- package/dist/monaco-lean4/vscode-lean4/src/config.d.ts +33 -0
- package/dist/monaco-lean4/vscode-lean4/src/config.js +119 -0
- package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +27 -0
- package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +133 -0
- package/dist/monaco-lean4/vscode-lean4/src/infoview.d.ts +69 -0
- package/dist/monaco-lean4/vscode-lean4/src/infoview.js +711 -0
- package/dist/monaco-lean4/vscode-lean4/src/leanclient.d.ts +67 -0
- package/dist/monaco-lean4/vscode-lean4/src/leanclient.js +443 -0
- package/dist/monaco-lean4/vscode-lean4/src/rpc.d.ts +16 -0
- package/dist/monaco-lean4/vscode-lean4/src/rpc.js +102 -0
- package/dist/monaco-lean4/vscode-lean4/src/taskgutter.d.ts +11 -0
- package/dist/monaco-lean4/vscode-lean4/src/taskgutter.js +130 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/batch.d.ts +37 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/batch.js +203 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.d.ts +41 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.js +205 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/converters.d.ts +16 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/converters.js +129 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/elan.d.ts +3 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/elan.js +4 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.d.ts +21 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.js +53 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.d.ts +35 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.js +136 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.d.ts +17 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.js +36 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +37 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.js +210 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/logger.d.ts +7 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/logger.js +20 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.d.ts +24 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.js +110 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.d.ts +9 -0
- package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.js +125 -0
- package/dist/monacoleanclient.d.ts +1 -2
- package/dist/monacoleanclient.js +3 -3
- package/dist/vscode-lean4/lean4-infoview/package.json +25 -23
- package/dist/vscode-lean4/lean4-infoview/src/infoview/highlightjs.css +210 -0
- package/dist/vscode-lean4/lean4-infoview/tsconfig.json +6 -2
- package/dist/vscode-lean4/lean4-infoview-api/package.json +1 -1
- package/dist/vscode-lean4/lean4-unicode-input/package.json +1 -1
- package/dist/vscode-lean4/lean4-unicode-input/src/abbreviations.json +12 -12
- package/dist/vscode-lean4/lean4-unicode-input-component/package.json +2 -2
- package/dist/vscode-lean4/package-lock.json +6129 -3245
- package/dist/vscode-lean4/vscode-lean4/language-configuration.json +1 -1
- package/dist/vscode-lean4/vscode-lean4/loogleview/static/index.css +19 -16
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-dark.svg +91 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-dark.svg +114 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-light.svg +114 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-passthrough-dark.svg +109 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-passthrough-light.svg +109 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-init-dark.svg +100 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-init-light.svg +100 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-dark.svg +123 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-light.svg +123 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-passthrough-dark.svg +109 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-passthrough-light.svg +109 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-light.svg +91 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-dark.svg +123 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-light.svg +123 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-passthrough-dark.svg +118 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-passthrough-light.svg +118 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-dark.svg +138 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-i-passthrough-dark.svg +160 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-i-passthrough-light.svg +160 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-l-passthrough-dark.svg +158 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-l-passthrough-light.svg +158 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-light.svg +138 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-t-passthrough-dark.svg +169 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-t-passthrough-light.svg +169 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-dark.svg +147 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-i-passthrough-dark.svg +170 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-i-passthrough-light.svg +170 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-l-passthrough-dark.svg +167 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-l-passthrough-light.svg +167 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-light.svg +147 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-t-passthrough-dark.svg +179 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-t-passthrough-light.svg +179 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-dark.svg +165 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-i-passthrough-dark.svg +187 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-i-passthrough-light.svg +187 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-l-passthrough-dark.svg +185 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-l-passthrough-light.svg +185 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-light.svg +165 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-t-passthrough-dark.svg +196 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-t-passthrough-light.svg +196 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-dark.svg +184 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-i-passthrough-dark.svg +206 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-i-passthrough-light.svg +206 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-l-passthrough-dark.svg +204 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-l-passthrough-light.svg +204 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-light.svg +184 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-t-passthrough-dark.svg +215 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-t-passthrough-light.svg +215 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-dark.svg +132 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-i-passthrough-dark.svg +154 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-i-passthrough-light.svg +154 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-l-passthrough-dark.svg +152 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-l-passthrough-light.svg +152 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-light.svg +132 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-t-passthrough-dark.svg +163 -0
- package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-t-passthrough-light.svg +163 -0
- package/dist/vscode-lean4/vscode-lean4/moogleview/static/index.css +198 -0
- package/dist/vscode-lean4/vscode-lean4/moogleview/tsconfig.json +10 -0
- package/dist/vscode-lean4/vscode-lean4/package.json +638 -18
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +2 -2
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +2 -2
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +2 -3
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +3 -5
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +1 -2
- package/dist/vscode-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +4 -8
- package/dist/vscode-lean4/vscode-lean4/src/config.d.ts +14 -1
- package/dist/vscode-lean4/vscode-lean4/src/config.js +56 -5
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnoser.d.ts +36 -5
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnoser.js +59 -23
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnostics.d.ts +22 -17
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnostics.js +182 -119
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +33 -20
- package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +235 -89
- package/dist/vscode-lean4/vscode-lean4/src/infoview.d.ts +7 -18
- package/dist/vscode-lean4/vscode-lean4/src/infoview.js +217 -102
- package/dist/vscode-lean4/vscode-lean4/src/leanclient.d.ts +12 -7
- package/dist/vscode-lean4/vscode-lean4/src/leanclient.js +187 -64
- package/dist/vscode-lean4/vscode-lean4/src/taskgutter.d.ts +35 -3
- package/dist/vscode-lean4/vscode-lean4/src/taskgutter.js +533 -93
- package/dist/vscode-lean4/vscode-lean4/src/utils/batch.d.ts +12 -4
- package/dist/vscode-lean4/vscode-lean4/src/utils/batch.js +78 -72
- package/dist/vscode-lean4/vscode-lean4/src/utils/clientProvider.d.ts +9 -9
- package/dist/vscode-lean4/vscode-lean4/src/utils/clientProvider.js +121 -77
- package/dist/vscode-lean4/vscode-lean4/src/utils/converters.d.ts +15 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/converters.js +9 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/elan.d.ts +179 -1
- package/dist/vscode-lean4/vscode-lean4/src/utils/elan.js +422 -3
- package/dist/vscode-lean4/vscode-lean4/src/utils/exturi.d.ts +3 -1
- package/dist/vscode-lean4/vscode-lean4/src/utils/exturi.js +11 -11
- package/dist/vscode-lean4/vscode-lean4/src/utils/groupBy.d.ts +2 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/groupBy.js +17 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/internalErrors.d.ts +2 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/internalErrors.js +35 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanCmdRunner.d.ts +34 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanCmdRunner.js +249 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanEditorProvider.d.ts +83 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanEditorProvider.js +323 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +41 -12
- package/dist/vscode-lean4/vscode-lean4/src/utils/leanInstaller.js +245 -128
- package/dist/vscode-lean4/vscode-lean4/src/utils/notifs.d.ts +27 -22
- package/dist/vscode-lean4/vscode-lean4/src/utils/notifs.js +177 -82
- package/dist/vscode-lean4/vscode-lean4/src/utils/projectInfo.d.ts +11 -4
- package/dist/vscode-lean4/vscode-lean4/src/utils/projectInfo.js +18 -16
- package/dist/vscode-lean4/vscode-lean4/src/utils/semverRegex.d.ts +1 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/semverRegex.js +2 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/viewColumn.d.ts +3 -0
- package/dist/vscode-lean4/vscode-lean4/src/utils/viewColumn.js +22 -0
- package/dist/vscode-lean4/vscode-lean4/tsconfig.json +2 -1
- package/dist/vscode-lean4/vscode-lean4/webview/tsconfig.json +3 -1
- package/dist/vscode.css +7 -0
- package/package.json +7 -5
|
@@ -1,3 +1,181 @@
|
|
|
1
|
+
import { SemVer } from 'semver';
|
|
1
2
|
import { OutputChannel } from 'vscode';
|
|
2
3
|
import { ExecutionResult } from './batch';
|
|
3
|
-
|
|
4
|
+
import { FileUri } from './exturi';
|
|
5
|
+
export declare const elanStableChannel = "leanprover/lean4:stable";
|
|
6
|
+
export declare const elanNightlyChannel = "leanprover/lean4:nightly";
|
|
7
|
+
export declare const elanEagerResolutionMajorVersion = 4;
|
|
8
|
+
export declare function isElanEagerResolutionVersion(version: SemVer): boolean;
|
|
9
|
+
export type ElanVersionResult = {
|
|
10
|
+
kind: 'Success';
|
|
11
|
+
version: SemVer;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'ElanNotInstalled';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'ExecutionError';
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function elanVersion(): Promise<ElanVersionResult>;
|
|
19
|
+
export declare function elanSelfUpdate(channel: OutputChannel | undefined, context: string | undefined): Promise<ExecutionResult>;
|
|
20
|
+
export type ElanOption<T> = T | undefined;
|
|
21
|
+
export type ElanResult<T> = {
|
|
22
|
+
kind: 'Ok';
|
|
23
|
+
value: T;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'Error';
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
export type ElanVersion = {
|
|
29
|
+
current: SemVer;
|
|
30
|
+
newest: ElanResult<SemVer>;
|
|
31
|
+
};
|
|
32
|
+
export type ElanInstalledToolchain = {
|
|
33
|
+
resolvedName: string;
|
|
34
|
+
path: FileUri;
|
|
35
|
+
};
|
|
36
|
+
export type ElanLocalUnresolvedToolchain = {
|
|
37
|
+
kind: 'Local';
|
|
38
|
+
toolchain: string;
|
|
39
|
+
};
|
|
40
|
+
export type ElanRemoteUnresolvedToolchain = {
|
|
41
|
+
kind: 'Remote';
|
|
42
|
+
githubRepoOrigin: string;
|
|
43
|
+
release: string;
|
|
44
|
+
fromChannel: ElanOption<string>;
|
|
45
|
+
};
|
|
46
|
+
export type ElanUnresolvedToolchain = ElanLocalUnresolvedToolchain | ElanRemoteUnresolvedToolchain;
|
|
47
|
+
export declare namespace ElanUnresolvedToolchain {
|
|
48
|
+
function toolchainName(unresolved: ElanUnresolvedToolchain): string;
|
|
49
|
+
}
|
|
50
|
+
export type ElanToolchainResolution = {
|
|
51
|
+
resolvedToolchain: ElanResult<string>;
|
|
52
|
+
cachedToolchain: ElanOption<string>;
|
|
53
|
+
};
|
|
54
|
+
export type ElanDefaultToolchain = {
|
|
55
|
+
unresolved: ElanUnresolvedToolchain;
|
|
56
|
+
resolved: ElanToolchainResolution;
|
|
57
|
+
};
|
|
58
|
+
export type ElanOverrideReason = {
|
|
59
|
+
kind: 'Environment';
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'Manual';
|
|
62
|
+
directoryPath: FileUri;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'ToolchainFile';
|
|
65
|
+
toolchainPath: FileUri;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'LeanpkgFile';
|
|
68
|
+
leanpkgPath: FileUri;
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'ToolchainDirectory';
|
|
71
|
+
directoryPath: FileUri;
|
|
72
|
+
};
|
|
73
|
+
export type ElanOverride = {
|
|
74
|
+
unresolved: ElanUnresolvedToolchain;
|
|
75
|
+
reason: ElanOverrideReason;
|
|
76
|
+
};
|
|
77
|
+
export type ElanToolchains = {
|
|
78
|
+
installed: Map<string, ElanInstalledToolchain>;
|
|
79
|
+
default: ElanOption<ElanDefaultToolchain>;
|
|
80
|
+
activeOverride: ElanOption<ElanOverride>;
|
|
81
|
+
resolvedActive: ElanOption<ElanToolchainResolution>;
|
|
82
|
+
};
|
|
83
|
+
export declare namespace ElanToolchains {
|
|
84
|
+
function unresolvedToolchain(toolchains: ElanToolchains): ElanOption<ElanUnresolvedToolchain>;
|
|
85
|
+
function unresolvedToolchainName(toolchains: ElanToolchains): ElanOption<string>;
|
|
86
|
+
}
|
|
87
|
+
export type ElanStateDump = {
|
|
88
|
+
elanVersion: ElanVersion;
|
|
89
|
+
toolchains: ElanToolchains;
|
|
90
|
+
};
|
|
91
|
+
export type ElanDumpStateWithoutNetResult = {
|
|
92
|
+
kind: 'Success';
|
|
93
|
+
state: ElanStateDump;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'ElanNotFound';
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'ExecutionError';
|
|
98
|
+
message: string;
|
|
99
|
+
};
|
|
100
|
+
export type ElanDumpStateWithNetResult = ElanDumpStateWithoutNetResult | {
|
|
101
|
+
kind: 'Cancelled';
|
|
102
|
+
};
|
|
103
|
+
export declare function elanDumpStateWithoutNet(cwdUri: FileUri | undefined, toolchain?: string | undefined): Promise<ElanDumpStateWithoutNetResult>;
|
|
104
|
+
export declare function elanDumpStateWithNet(cwdUri: FileUri | undefined, context: string | undefined, toolchain?: string | undefined): Promise<ElanDumpStateWithNetResult>;
|
|
105
|
+
export type ElanInstalledToolchainsResult = {
|
|
106
|
+
kind: 'Success';
|
|
107
|
+
toolchains: string[];
|
|
108
|
+
defaultToolchain: string | undefined;
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'ElanNotFound';
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'ExecutionError';
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
export declare function elanInstalledToolchains(): Promise<ElanInstalledToolchainsResult>;
|
|
116
|
+
export type ActiveToolchainInfo = {
|
|
117
|
+
unresolvedToolchain: string;
|
|
118
|
+
cachedToolchain: string | undefined;
|
|
119
|
+
resolvedToolchain: string;
|
|
120
|
+
origin: ElanOverrideReason | {
|
|
121
|
+
kind: 'Default';
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
export type ElanActiveToolchainResult = {
|
|
125
|
+
kind: 'ElanNotFound';
|
|
126
|
+
} | {
|
|
127
|
+
kind: 'ExecutionError';
|
|
128
|
+
message: string;
|
|
129
|
+
} | {
|
|
130
|
+
kind: 'Cancelled';
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'NoActiveToolchain';
|
|
133
|
+
} | {
|
|
134
|
+
kind: 'Success';
|
|
135
|
+
info: ActiveToolchainInfo;
|
|
136
|
+
};
|
|
137
|
+
export declare function elanActiveToolchain(cwdUri: FileUri | undefined, context: string | undefined, toolchain?: string | undefined): Promise<ElanActiveToolchainResult>;
|
|
138
|
+
export declare function toolchainVersion(toolchain: string): string;
|
|
139
|
+
export type ElanInstallToolchainResult = {
|
|
140
|
+
kind: 'Success';
|
|
141
|
+
} | {
|
|
142
|
+
kind: 'ElanNotFound';
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'ToolchainAlreadyInstalled';
|
|
145
|
+
} | {
|
|
146
|
+
kind: 'Error';
|
|
147
|
+
message: string;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'Cancelled';
|
|
150
|
+
};
|
|
151
|
+
export declare function elanInstallToolchain(channel: OutputChannel | undefined, context: string | undefined, toolchain: string): Promise<ElanInstallToolchainResult>;
|
|
152
|
+
export declare function elanUninstallToolchains(channel: OutputChannel | undefined, context: string | undefined, toolchains: string[]): Promise<ExecutionResult>;
|
|
153
|
+
export declare function elanSelfUninstall(channel: OutputChannel | undefined, context: string | undefined): Promise<ExecutionResult>;
|
|
154
|
+
export type ElanSetDefaultToolchainResult = {
|
|
155
|
+
kind: 'Success';
|
|
156
|
+
} | {
|
|
157
|
+
kind: 'ElanNotFound';
|
|
158
|
+
} | {
|
|
159
|
+
kind: 'Error';
|
|
160
|
+
message: string;
|
|
161
|
+
};
|
|
162
|
+
export declare function elanSetDefaultToolchain(channel: OutputChannel | undefined, toolchain: string): Promise<ElanSetDefaultToolchainResult>;
|
|
163
|
+
export type ElanUsedToolchain = {
|
|
164
|
+
user: string;
|
|
165
|
+
toolchain: string;
|
|
166
|
+
};
|
|
167
|
+
export type ElanGcInfo = {
|
|
168
|
+
unusedToolchains: string[];
|
|
169
|
+
usedToolchains: ElanUsedToolchain[];
|
|
170
|
+
};
|
|
171
|
+
export type ElanQueryGcResult = {
|
|
172
|
+
kind: 'Success';
|
|
173
|
+
info: ElanGcInfo;
|
|
174
|
+
} | {
|
|
175
|
+
kind: 'ElanNotFound';
|
|
176
|
+
} | {
|
|
177
|
+
kind: 'ExecutionError';
|
|
178
|
+
message: string;
|
|
179
|
+
};
|
|
180
|
+
export declare function elanQueryGc(): Promise<ElanQueryGcResult>;
|
|
181
|
+
export declare function elanGC(channel: OutputChannel | undefined, context: string | undefined): Promise<ExecutionResult>;
|
|
@@ -1,4 +1,423 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SemVer } from 'semver';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { batchExecute, batchExecuteWithProgress, ExecutionExitCode } from './batch';
|
|
4
|
+
import { FileUri } from './exturi';
|
|
5
|
+
import { groupByUniqueKey } from './groupBy';
|
|
6
|
+
import { semVerRegex } from './semverRegex';
|
|
7
|
+
export const elanStableChannel = 'leanprover/lean4:stable';
|
|
8
|
+
export const elanNightlyChannel = 'leanprover/lean4:nightly';
|
|
9
|
+
export const elanEagerResolutionMajorVersion = 4;
|
|
10
|
+
export function isElanEagerResolutionVersion(version) {
|
|
11
|
+
return version.major >= elanEagerResolutionMajorVersion;
|
|
12
|
+
}
|
|
13
|
+
const elanVersionRegex = /^elan ((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)/;
|
|
14
|
+
export async function elanVersion() {
|
|
15
|
+
const r = await batchExecute('elan', ['--version']);
|
|
16
|
+
switch (r.exitCode) {
|
|
17
|
+
case ExecutionExitCode.Success:
|
|
18
|
+
const match = elanVersionRegex.exec(r.stdout);
|
|
19
|
+
if (match === null) {
|
|
20
|
+
return { kind: 'ExecutionError', message: 'Cannot parse output of `elan --version`: ' + r.stdout };
|
|
21
|
+
}
|
|
22
|
+
return { kind: 'Success', version: new SemVer(match[1]) };
|
|
23
|
+
case ExecutionExitCode.CannotLaunch:
|
|
24
|
+
return { kind: 'ElanNotInstalled' };
|
|
25
|
+
case ExecutionExitCode.ExecutionError:
|
|
26
|
+
return { kind: 'ExecutionError', message: r.combined };
|
|
27
|
+
case ExecutionExitCode.Cancelled:
|
|
28
|
+
throw new Error('Unexpected cancellation of `elan --version`');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function elanSelfUpdate(channel, context) {
|
|
32
|
+
return await batchExecuteWithProgress('elan', ['self', 'update'], context, 'Updating Elan', { channel });
|
|
33
|
+
}
|
|
34
|
+
export var ElanUnresolvedToolchain;
|
|
35
|
+
(function (ElanUnresolvedToolchain) {
|
|
36
|
+
function toolchainName(unresolved) {
|
|
37
|
+
switch (unresolved.kind) {
|
|
38
|
+
case 'Local':
|
|
39
|
+
return unresolved.toolchain;
|
|
40
|
+
case 'Remote':
|
|
41
|
+
return unresolved.githubRepoOrigin + ':' + unresolved.release;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ElanUnresolvedToolchain.toolchainName = toolchainName;
|
|
45
|
+
})(ElanUnresolvedToolchain || (ElanUnresolvedToolchain = {}));
|
|
46
|
+
export var ElanToolchains;
|
|
47
|
+
(function (ElanToolchains) {
|
|
48
|
+
function unresolvedToolchain(toolchains) {
|
|
49
|
+
return toolchains.activeOverride?.unresolved ?? toolchains.default?.unresolved;
|
|
50
|
+
}
|
|
51
|
+
ElanToolchains.unresolvedToolchain = unresolvedToolchain;
|
|
52
|
+
function unresolvedToolchainName(toolchains) {
|
|
53
|
+
const unresolvedToolchain = ElanToolchains.unresolvedToolchain(toolchains);
|
|
54
|
+
if (unresolvedToolchain === undefined) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return ElanUnresolvedToolchain.toolchainName(unresolvedToolchain);
|
|
58
|
+
}
|
|
59
|
+
ElanToolchains.unresolvedToolchainName = unresolvedToolchainName;
|
|
60
|
+
})(ElanToolchains || (ElanToolchains = {}));
|
|
61
|
+
function zodElanResult(zodValue) {
|
|
62
|
+
return z.union([
|
|
63
|
+
z.object({
|
|
64
|
+
Ok: zodValue,
|
|
65
|
+
}),
|
|
66
|
+
z.object({
|
|
67
|
+
Err: z.string(),
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
function zodElanUnresolvedToolchain() {
|
|
72
|
+
return z.union([
|
|
73
|
+
z.object({
|
|
74
|
+
Local: z.object({
|
|
75
|
+
name: z.string(),
|
|
76
|
+
}),
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
Remote: z.object({
|
|
80
|
+
origin: z.string(),
|
|
81
|
+
release: z.string(),
|
|
82
|
+
from_channel: z.nullable(z.string()),
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
function zodElanToolchainResolution() {
|
|
88
|
+
return z.object({
|
|
89
|
+
live: zodElanResult(z.string()),
|
|
90
|
+
cached: z.nullable(z.string()),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function convertElanResult(zodResult, f) {
|
|
94
|
+
if ('Ok' in zodResult) {
|
|
95
|
+
return { kind: 'Ok', value: f(zodResult.Ok) };
|
|
96
|
+
}
|
|
97
|
+
zodResult;
|
|
98
|
+
return { kind: 'Error', message: zodResult.Err };
|
|
99
|
+
}
|
|
100
|
+
function convertElanOption(zodNullable, f) {
|
|
101
|
+
if (zodNullable === null) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return f(zodNullable);
|
|
105
|
+
}
|
|
106
|
+
function convertElanUnresolvedToolchain(zodElanUnresolvedToolchain) {
|
|
107
|
+
if ('Local' in zodElanUnresolvedToolchain) {
|
|
108
|
+
return { kind: 'Local', toolchain: zodElanUnresolvedToolchain.Local.name };
|
|
109
|
+
}
|
|
110
|
+
zodElanUnresolvedToolchain;
|
|
111
|
+
return {
|
|
112
|
+
kind: 'Remote',
|
|
113
|
+
githubRepoOrigin: zodElanUnresolvedToolchain.Remote.origin,
|
|
114
|
+
release: zodElanUnresolvedToolchain.Remote.release,
|
|
115
|
+
fromChannel: convertElanOption(zodElanUnresolvedToolchain.Remote.from_channel, c => c),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function covertElanToolchainResolution(installed, zodElanToolchainResolution) {
|
|
119
|
+
let cachedToolchain = convertElanOption(zodElanToolchainResolution.cached, t => t);
|
|
120
|
+
if (cachedToolchain !== undefined && !installed.has(cachedToolchain)) {
|
|
121
|
+
cachedToolchain = undefined;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
resolvedToolchain: convertElanResult(zodElanToolchainResolution.live, t => t),
|
|
125
|
+
cachedToolchain,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function convertElanOverrideReason(zodElanOverrideReason) {
|
|
129
|
+
if (zodElanOverrideReason === 'Environment') {
|
|
130
|
+
return { kind: 'Environment' };
|
|
131
|
+
}
|
|
132
|
+
if ('OverrideDB' in zodElanOverrideReason) {
|
|
133
|
+
return { kind: 'Manual', directoryPath: new FileUri(zodElanOverrideReason.OverrideDB) };
|
|
134
|
+
}
|
|
135
|
+
if ('ToolchainFile' in zodElanOverrideReason) {
|
|
136
|
+
return { kind: 'ToolchainFile', toolchainPath: new FileUri(zodElanOverrideReason.ToolchainFile) };
|
|
137
|
+
}
|
|
138
|
+
if ('LeanpkgFile' in zodElanOverrideReason) {
|
|
139
|
+
return { kind: 'LeanpkgFile', leanpkgPath: new FileUri(zodElanOverrideReason.LeanpkgFile) };
|
|
140
|
+
}
|
|
141
|
+
zodElanOverrideReason;
|
|
142
|
+
return { kind: 'ToolchainDirectory', directoryPath: new FileUri(zodElanOverrideReason.InToolchainDirectory) };
|
|
143
|
+
}
|
|
144
|
+
function parseElanStateDump(elanDumpStateOutput) {
|
|
145
|
+
let parsedJson;
|
|
146
|
+
try {
|
|
147
|
+
parsedJson = JSON.parse(elanDumpStateOutput);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
const stateDumpSchema = z.object({
|
|
153
|
+
elan_version: z.object({
|
|
154
|
+
current: z.string().regex(semVerRegex),
|
|
155
|
+
newest: zodElanResult(z.string().regex(semVerRegex)),
|
|
156
|
+
}),
|
|
157
|
+
toolchains: z.object({
|
|
158
|
+
installed: z.array(z.object({
|
|
159
|
+
resolved_name: z.string(),
|
|
160
|
+
path: z.string(),
|
|
161
|
+
})),
|
|
162
|
+
default: z.nullable(z.object({
|
|
163
|
+
unresolved: zodElanUnresolvedToolchain(),
|
|
164
|
+
resolved: zodElanToolchainResolution(),
|
|
165
|
+
})),
|
|
166
|
+
active_override: z.nullable(z.object({
|
|
167
|
+
unresolved: zodElanUnresolvedToolchain(),
|
|
168
|
+
reason: z.union([
|
|
169
|
+
z.literal('Environment'),
|
|
170
|
+
z.object({ OverrideDB: z.string() }),
|
|
171
|
+
z.object({ ToolchainFile: z.string() }),
|
|
172
|
+
z.object({ LeanpkgFile: z.string() }),
|
|
173
|
+
z.object({ InToolchainDirectory: z.string() }),
|
|
174
|
+
]),
|
|
175
|
+
})),
|
|
176
|
+
resolved_active: z.nullable(zodElanToolchainResolution()),
|
|
177
|
+
}),
|
|
178
|
+
});
|
|
179
|
+
const stateDumpResult = stateDumpSchema.safeParse(parsedJson);
|
|
180
|
+
if (!stateDumpResult.success) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const s = stateDumpResult.data;
|
|
184
|
+
const installed = groupByUniqueKey(s.toolchains.installed.map(i => ({ resolvedName: i.resolved_name, path: new FileUri(i.path) })), i => i.resolvedName);
|
|
185
|
+
const stateDump = {
|
|
186
|
+
elanVersion: {
|
|
187
|
+
current: new SemVer(s.elan_version.current),
|
|
188
|
+
newest: convertElanResult(s.elan_version.newest, version => new SemVer(version)),
|
|
189
|
+
},
|
|
190
|
+
toolchains: {
|
|
191
|
+
installed,
|
|
192
|
+
default: convertElanOption(s.toolchains.default, d => ({
|
|
193
|
+
unresolved: convertElanUnresolvedToolchain(d.unresolved),
|
|
194
|
+
resolved: covertElanToolchainResolution(installed, d.resolved),
|
|
195
|
+
})),
|
|
196
|
+
activeOverride: convertElanOption(s.toolchains.active_override, r => ({
|
|
197
|
+
reason: convertElanOverrideReason(r.reason),
|
|
198
|
+
unresolved: convertElanUnresolvedToolchain(r.unresolved),
|
|
199
|
+
})),
|
|
200
|
+
resolvedActive: convertElanOption(s.toolchains.resolved_active, r => covertElanToolchainResolution(installed, r)),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
return stateDump;
|
|
204
|
+
}
|
|
205
|
+
function toolchainEnvExtensions(toolchain) {
|
|
206
|
+
if (toolchain === undefined) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
ELAN_TOOLCHAIN: toolchain,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export async function elanDumpStateWithoutNet(cwdUri, toolchain) {
|
|
214
|
+
const r = await batchExecute('elan', ['dump-state', '--no-net'], cwdUri?.fsPath, undefined, toolchainEnvExtensions(toolchain));
|
|
215
|
+
switch (r.exitCode) {
|
|
216
|
+
case ExecutionExitCode.Success:
|
|
217
|
+
const state = parseElanStateDump(r.stdout);
|
|
218
|
+
if (state === undefined) {
|
|
219
|
+
return { kind: 'ExecutionError', message: 'Cannot parse output of `elan dump-state --no-net`.' };
|
|
220
|
+
}
|
|
221
|
+
return { kind: 'Success', state };
|
|
222
|
+
case ExecutionExitCode.CannotLaunch:
|
|
223
|
+
return { kind: 'ElanNotFound' };
|
|
224
|
+
case ExecutionExitCode.ExecutionError:
|
|
225
|
+
return { kind: 'ExecutionError', message: r.combined };
|
|
226
|
+
case ExecutionExitCode.Cancelled:
|
|
227
|
+
throw new Error('Unexpected cancellation of `elan dump-state --no-net`');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export async function elanDumpStateWithNet(cwdUri, context, toolchain) {
|
|
231
|
+
const r = await batchExecuteWithProgress('elan', ['dump-state'], context, 'Fetching Lean version information', {
|
|
232
|
+
cwd: cwdUri?.fsPath,
|
|
233
|
+
allowCancellation: true,
|
|
234
|
+
envExtensions: toolchainEnvExtensions(toolchain),
|
|
235
|
+
});
|
|
236
|
+
switch (r.exitCode) {
|
|
237
|
+
case ExecutionExitCode.Success:
|
|
238
|
+
const state = parseElanStateDump(r.stdout);
|
|
239
|
+
if (state === undefined) {
|
|
240
|
+
return { kind: 'ExecutionError', message: 'Cannot parse output of `elan dump-state`.' };
|
|
241
|
+
}
|
|
242
|
+
return { kind: 'Success', state };
|
|
243
|
+
case ExecutionExitCode.CannotLaunch:
|
|
244
|
+
return { kind: 'ElanNotFound' };
|
|
245
|
+
case ExecutionExitCode.ExecutionError:
|
|
246
|
+
return { kind: 'ExecutionError', message: r.combined };
|
|
247
|
+
case ExecutionExitCode.Cancelled:
|
|
248
|
+
return { kind: 'Cancelled' };
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export async function elanInstalledToolchains() {
|
|
252
|
+
const stateDumpResult = await elanDumpStateWithoutNet(undefined);
|
|
253
|
+
if (stateDumpResult.kind === 'ExecutionError') {
|
|
254
|
+
// User is probably on a pre-eager toolchain resolution elan version which did not yet support
|
|
255
|
+
// `elan dump-state`. Fall back to parsing the toolchain with `elan toolchain list`.
|
|
256
|
+
const r = await batchExecute('elan', ['toolchain', 'list']);
|
|
257
|
+
switch (r.exitCode) {
|
|
258
|
+
case ExecutionExitCode.Success:
|
|
259
|
+
const lines = r.stdout
|
|
260
|
+
.split(/\r?\n/)
|
|
261
|
+
.map(line => line.trim())
|
|
262
|
+
.filter(line => line.length > 0);
|
|
263
|
+
const toolchainInfo = lines.map(line => [
|
|
264
|
+
line.replace(/\(default\)$/, '').trim(),
|
|
265
|
+
line.endsWith('(default)'),
|
|
266
|
+
]);
|
|
267
|
+
const toolchains = toolchainInfo.map(([toolchain, _]) => toolchain);
|
|
268
|
+
const defaultToolchain = toolchainInfo.find(([_, isDefault]) => isDefault)?.[0];
|
|
269
|
+
return { kind: 'Success', toolchains, defaultToolchain };
|
|
270
|
+
case ExecutionExitCode.CannotLaunch:
|
|
271
|
+
return { kind: 'ElanNotFound' };
|
|
272
|
+
case ExecutionExitCode.ExecutionError:
|
|
273
|
+
return { kind: 'ExecutionError', message: r.combined };
|
|
274
|
+
case ExecutionExitCode.Cancelled:
|
|
275
|
+
throw new Error('Unexpected cancellation of `elan toolchain list`');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (stateDumpResult.kind === 'ElanNotFound') {
|
|
279
|
+
return stateDumpResult;
|
|
280
|
+
}
|
|
281
|
+
stateDumpResult.kind;
|
|
282
|
+
const installedToolchains = [...stateDumpResult.state.toolchains.installed.values()].map(t => t.resolvedName);
|
|
283
|
+
const defaultToolchain = stateDumpResult.state.toolchains.default;
|
|
284
|
+
if (defaultToolchain === undefined) {
|
|
285
|
+
return { kind: 'Success', toolchains: installedToolchains, defaultToolchain: undefined };
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
kind: 'Success',
|
|
289
|
+
toolchains: installedToolchains,
|
|
290
|
+
defaultToolchain: ElanUnresolvedToolchain.toolchainName(defaultToolchain.unresolved),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
export async function elanActiveToolchain(cwdUri, context, toolchain) {
|
|
294
|
+
const stateDumpResult = await elanDumpStateWithNet(cwdUri, context, toolchain);
|
|
295
|
+
if (stateDumpResult.kind !== 'Success') {
|
|
296
|
+
return stateDumpResult;
|
|
297
|
+
}
|
|
298
|
+
const unresolvedToolchain = ElanToolchains.unresolvedToolchainName(stateDumpResult.state.toolchains);
|
|
299
|
+
if (unresolvedToolchain === undefined) {
|
|
300
|
+
return { kind: 'NoActiveToolchain' };
|
|
301
|
+
}
|
|
302
|
+
const toolchainResolution = stateDumpResult.state.toolchains.resolvedActive;
|
|
303
|
+
if (toolchainResolution === undefined) {
|
|
304
|
+
return { kind: 'NoActiveToolchain' };
|
|
305
|
+
}
|
|
306
|
+
const cachedToolchain = toolchainResolution.cachedToolchain;
|
|
307
|
+
const resolvedToolchainResult = toolchainResolution.resolvedToolchain;
|
|
308
|
+
if (resolvedToolchainResult.kind === 'Error') {
|
|
309
|
+
return { kind: 'ExecutionError', message: resolvedToolchainResult.message };
|
|
310
|
+
}
|
|
311
|
+
const resolvedToolchain = resolvedToolchainResult.value;
|
|
312
|
+
const overrideReason = stateDumpResult.state.toolchains.activeOverride?.reason;
|
|
313
|
+
const origin = overrideReason !== undefined ? overrideReason : { kind: 'Default' };
|
|
314
|
+
return { kind: 'Success', info: { unresolvedToolchain, cachedToolchain, resolvedToolchain, origin } };
|
|
315
|
+
}
|
|
316
|
+
export function toolchainVersion(toolchain) {
|
|
317
|
+
const toolchainRegex = /(.+)\/(.+):(.+)/;
|
|
318
|
+
const match = toolchainRegex.exec(toolchain);
|
|
319
|
+
if (match === null) {
|
|
320
|
+
return toolchain;
|
|
321
|
+
}
|
|
322
|
+
return match[3];
|
|
323
|
+
}
|
|
324
|
+
export async function elanInstallToolchain(channel, context, toolchain) {
|
|
325
|
+
const r = await batchExecuteWithProgress('elan', ['toolchain', 'install', toolchain], context, `Installing ${toolchain}`, {
|
|
326
|
+
channel,
|
|
327
|
+
allowCancellation: true,
|
|
328
|
+
});
|
|
329
|
+
switch (r.exitCode) {
|
|
330
|
+
case ExecutionExitCode.Success:
|
|
331
|
+
return { kind: 'Success' };
|
|
332
|
+
case ExecutionExitCode.CannotLaunch:
|
|
333
|
+
return { kind: 'ElanNotFound' };
|
|
334
|
+
case ExecutionExitCode.ExecutionError:
|
|
335
|
+
if (r.stderr.match(/error: '.*' is already installed/) !== null) {
|
|
336
|
+
return { kind: 'ToolchainAlreadyInstalled' };
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return { kind: 'Error', message: r.combined };
|
|
340
|
+
}
|
|
341
|
+
case ExecutionExitCode.Cancelled:
|
|
342
|
+
return { kind: 'Cancelled' };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
export async function elanUninstallToolchains(channel, context, toolchains) {
|
|
346
|
+
if (toolchains.length === 0) {
|
|
347
|
+
throw new Error('Cannot uninstall zero toolchains.');
|
|
348
|
+
}
|
|
349
|
+
const waitingPrompt = toolchains.length === 1
|
|
350
|
+
? `Uninstalling '${toolchains[0]}'`
|
|
351
|
+
: `Uninstalling Lean versions ${toolchains.map(t => `'${t}'`).join(', ')}`;
|
|
352
|
+
return await batchExecuteWithProgress('elan', ['toolchain', 'uninstall', ...toolchains], context, waitingPrompt, {
|
|
353
|
+
channel,
|
|
354
|
+
allowCancellation: true,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
export async function elanSelfUninstall(channel, context) {
|
|
358
|
+
return await batchExecuteWithProgress('elan', ['self', 'uninstall', '-y'], context, 'Uninstalling Elan', {
|
|
359
|
+
channel,
|
|
360
|
+
allowCancellation: true,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
export async function elanSetDefaultToolchain(channel, toolchain) {
|
|
364
|
+
const r = await batchExecute('elan', ['default', toolchain], undefined, { combined: channel });
|
|
365
|
+
switch (r.exitCode) {
|
|
366
|
+
case ExecutionExitCode.Success:
|
|
367
|
+
return { kind: 'Success' };
|
|
368
|
+
case ExecutionExitCode.CannotLaunch:
|
|
369
|
+
return { kind: 'ElanNotFound' };
|
|
370
|
+
case ExecutionExitCode.ExecutionError:
|
|
371
|
+
return { kind: 'Error', message: r.combined };
|
|
372
|
+
case ExecutionExitCode.Cancelled:
|
|
373
|
+
throw new Error('Unexpected cancellation of `elan default <toolchain>`');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function parseElanGcJson(jsonOutput) {
|
|
377
|
+
let parsedJson;
|
|
378
|
+
try {
|
|
379
|
+
parsedJson = JSON.parse(jsonOutput);
|
|
380
|
+
}
|
|
381
|
+
catch (e) {
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
const elanGcJsonSchema = z.object({
|
|
385
|
+
unused_toolchains: z.array(z.string()),
|
|
386
|
+
used_toolchains: z.array(z.object({
|
|
387
|
+
user: z.string(),
|
|
388
|
+
toolchain: z.string(),
|
|
389
|
+
})),
|
|
390
|
+
});
|
|
391
|
+
const elanGcJsonResult = elanGcJsonSchema.safeParse(parsedJson);
|
|
392
|
+
if (!elanGcJsonResult.success) {
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
const elanGcJson = elanGcJsonResult.data;
|
|
396
|
+
return {
|
|
397
|
+
unusedToolchains: elanGcJson.unused_toolchains,
|
|
398
|
+
usedToolchains: elanGcJson.used_toolchains,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
export async function elanQueryGc() {
|
|
402
|
+
const r = await batchExecute('elan', ['toolchain', 'gc', '--json']);
|
|
403
|
+
switch (r.exitCode) {
|
|
404
|
+
case ExecutionExitCode.Success:
|
|
405
|
+
const info = parseElanGcJson(r.stdout);
|
|
406
|
+
if (info === undefined) {
|
|
407
|
+
return { kind: 'ExecutionError', message: 'Cannot parse output of `elan toolchain gc --json`' };
|
|
408
|
+
}
|
|
409
|
+
return { kind: 'Success', info };
|
|
410
|
+
case ExecutionExitCode.CannotLaunch:
|
|
411
|
+
return { kind: 'ElanNotFound' };
|
|
412
|
+
case ExecutionExitCode.ExecutionError:
|
|
413
|
+
return { kind: 'ExecutionError', message: r.combined };
|
|
414
|
+
case ExecutionExitCode.Cancelled:
|
|
415
|
+
throw new Error('Unexpected cancellation of `elan toolchain gc --json`.');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
export async function elanGC(channel, context) {
|
|
419
|
+
return await batchExecuteWithProgress('elan', ['toolchain', 'gc', '--delete'], context, 'Removing unused Lean versions', {
|
|
420
|
+
channel,
|
|
421
|
+
allowCancellation: true,
|
|
422
|
+
});
|
|
4
423
|
}
|
|
@@ -9,11 +9,13 @@ export declare class FileUri {
|
|
|
9
9
|
equals(other: FileUri): boolean;
|
|
10
10
|
equalsUri(other: Uri): boolean;
|
|
11
11
|
toString(): string;
|
|
12
|
+
baseName(): string;
|
|
12
13
|
join(...pathSegments: string[]): FileUri;
|
|
13
14
|
isInFolder(folderUri: FileUri): boolean;
|
|
14
15
|
relativeTo(folderUri: FileUri): FileUri | undefined;
|
|
15
16
|
}
|
|
16
|
-
export declare function
|
|
17
|
+
export declare function isInWorkspaceFolder(uri: FileUri): boolean;
|
|
18
|
+
export declare function isWorkspaceFolder(uri: FileUri): boolean;
|
|
17
19
|
export declare class UntitledUri {
|
|
18
20
|
scheme: 'untitled';
|
|
19
21
|
path: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import { Uri, workspace } from 'vscode';
|
|
2
3
|
import { isFileInFolder, relativeFilePathInFolder } from './fsHelper';
|
|
3
4
|
function unsupportedSchemeError(uri) {
|
|
@@ -7,8 +8,6 @@ export class FileUri {
|
|
|
7
8
|
scheme;
|
|
8
9
|
fsPath;
|
|
9
10
|
constructor(fsPath) {
|
|
10
|
-
// TODO: Is this robust on Windows???
|
|
11
|
-
fsPath = fsPath.replaceAll('\\', '/');
|
|
12
11
|
this.scheme = 'file';
|
|
13
12
|
this.fsPath = fsPath;
|
|
14
13
|
}
|
|
@@ -41,6 +40,9 @@ export class FileUri {
|
|
|
41
40
|
toString() {
|
|
42
41
|
return this.asUri().toString();
|
|
43
42
|
}
|
|
43
|
+
baseName() {
|
|
44
|
+
return path.basename(this.fsPath);
|
|
45
|
+
}
|
|
44
46
|
join(...pathSegments) {
|
|
45
47
|
return FileUri.fromUriOrError(Uri.joinPath(this.asUri(), ...pathSegments));
|
|
46
48
|
}
|
|
@@ -55,16 +57,14 @@ export class FileUri {
|
|
|
55
57
|
return new FileUri(relativePath);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
export function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (folderUri === undefined) {
|
|
65
|
-
return undefined;
|
|
60
|
+
export function isInWorkspaceFolder(uri) {
|
|
61
|
+
return workspace.getWorkspaceFolder(uri.asUri()) !== undefined;
|
|
62
|
+
}
|
|
63
|
+
export function isWorkspaceFolder(uri) {
|
|
64
|
+
if (workspace.workspaceFolders === undefined) {
|
|
65
|
+
return false;
|
|
66
66
|
}
|
|
67
|
-
return
|
|
67
|
+
return workspace.workspaceFolders.some(folder => uri.equalsUri(folder.uri));
|
|
68
68
|
}
|
|
69
69
|
export class UntitledUri {
|
|
70
70
|
scheme;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function groupByKey(values, key) {
|
|
2
|
+
const r = new Map();
|
|
3
|
+
for (const v of values) {
|
|
4
|
+
const k = key(v);
|
|
5
|
+
const group = r.get(k) ?? [];
|
|
6
|
+
group.push(v);
|
|
7
|
+
r.set(k, group);
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
export function groupByUniqueKey(values, key) {
|
|
12
|
+
const r = new Map();
|
|
13
|
+
for (const v of values) {
|
|
14
|
+
r.set(key(v), v);
|
|
15
|
+
}
|
|
16
|
+
return r;
|
|
17
|
+
}
|