Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect core src directory #355

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vscode-lean4/src/utils/leanInstaller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { window, TerminalOptions, OutputChannel, Disposable, EventEmitter, ProgressLocation, Uri } from 'vscode'
import { window, TerminalOptions, OutputChannel, EventEmitter, Uri } from 'vscode'
import { toolchainPath, addServerEnvPaths, getPowerShellPath, shouldAutofocusOutput, isRunningTest } from '../config'
import { ExecutionExitCode, ExecutionResult, batchExecute, batchExecuteWithProgress } from './batch'
import { ExecutionExitCode, ExecutionResult, batchExecute } from './batch'
import { readLeanVersion, isCoreLean4Directory } from './projectInfo';
import { join } from 'path';
import { logger } from './logger'
Expand Down
19 changes: 18 additions & 1 deletion vscode-lean4/src/utils/projectInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ export async function isCoreLean4Directory(path: Uri): Promise<boolean> {
const licensePath = Uri.joinPath(path, 'LICENSE').fsPath
const licensesPath = Uri.joinPath(path, 'LICENSES').fsPath
const srcPath = Uri.joinPath(path, 'src').fsPath
return await fileExists(licensePath)

const isCoreLean4RootDirectory =
await fileExists(licensePath)
&& await fileExists(licensesPath)
&& await fileExists(srcPath)
if (isCoreLean4RootDirectory) {
return true
}

const initPath = Uri.joinPath(path, 'Init').fsPath
const leanPath = Uri.joinPath(path, 'Lean').fsPath
const kernelPath = Uri.joinPath(path, 'kernel').fsPath
const runtimePath = Uri.joinPath(path, 'runtime').fsPath

const isCoreLean4SrcDirectory =
await fileExists(initPath)
&& await fileExists(leanPath)
&& await fileExists(kernelPath)
&& await fileExists(runtimePath)
return isCoreLean4SrcDirectory
}

// Find the root of a Lean project and return an optional WorkspaceFolder for it,
Expand Down