Skip to content

Commit

Permalink
refactor: Move check to shared file
Browse files Browse the repository at this point in the history
  • Loading branch information
famoser committed Feb 9, 2024
1 parent af3f440 commit b7cbe63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/cached_task_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Connection} from "vscode-languageserver/node";
import {fileURLToPath, pathToFileURL} from 'url';
import {dirname, sep} from 'path';
import {readdir} from 'fs/promises';
import {readFile} from "./utils/files";
import {isProverifFile, readFile} from "./utils/files";

type DocumentCache = {
settings?: ProVerifSettings,
Expand Down Expand Up @@ -210,7 +210,7 @@ export class CachedTaskExecutor {
console.log("Discovering " + entries.length + " files in " + currentFolder);
const fileUrls = entries
.filter(entry => entry.isFile())
.filter(entry => entry.name.endsWith(".pv") || entry.name.endsWith(".pvl") || entry.name.endsWith(".pvc"))
.filter(entry => isProverifFile(entry.name))
.map(file => pathToFileURL(currentFolder + sep + file.name));
await Promise.all(fileUrls.map(fileUrl => this.parseLibraryDependencies({ uri: fileUrl.toString()})));

Expand Down
3 changes: 3 additions & 0 deletions server/src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const asTempFile = async <T>(path: string, content: string, appendFileEnd
}
};

export const isProverifFile = (path: string) => {
return path.endsWith(".pv") || path.endsWith(".pvl") || path.endsWith(".pvc");
};
export const readFile = async <T>(path: string) => {
const buffer = await fsPromises.readFile(path);
return buffer.toString();
Expand Down

0 comments on commit b7cbe63

Please sign in to comment.