From 8da55b3c92e0a21bbc4b2524e13b09818f47a56f Mon Sep 17 00:00:00 2001 From: Danil Ovchinnikov Date: Sat, 15 Nov 2025 03:16:58 +0300 Subject: [PATCH 1/4] feat(indexing): check that stdlib can be read --- server/src/indexing/indexing.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/src/indexing/indexing.ts b/server/src/indexing/indexing.ts index 89461763..ff6679d5 100644 --- a/server/src/indexing/indexing.ts +++ b/server/src/indexing/indexing.ts @@ -2,6 +2,8 @@ import {fileURLToPath} from "node:url" import * as path from "node:path" +import * as fs from "node:fs" + import {glob} from "glob" import {filePathToUri} from "@server/files" @@ -40,6 +42,10 @@ export abstract class IndexingRoot { ignore: ignore, }) if (files.length === 0) { + if (!this.checkReadAccess(this.root)) { + console.warn(`Can't access ${this.root}`) + } + console.warn(`No file to index in ${this.root}`) } for (const filePath of files) { @@ -50,5 +56,14 @@ export abstract class IndexingRoot { } } + private checkReadAccess(path: string): boolean { + try { + fs.accessSync(path, fs.constants.R_OK) + return true + } catch { + return false + } + } + protected abstract onFile(uri: string): Promise } From 9cfcbdc67f8e9c7c402c41f0bae47342a1d01798 Mon Sep 17 00:00:00 2001 From: Danil Ovchinnikov Date: Fri, 28 Nov 2025 01:05:23 +0300 Subject: [PATCH 2/4] notify --- server/src/indexing/indexing.ts | 6 +++++- server/src/server.ts | 9 ++------- server/src/utils/notify.ts | 10 ++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 server/src/utils/notify.ts diff --git a/server/src/indexing/indexing.ts b/server/src/indexing/indexing.ts index ff6679d5..915003eb 100644 --- a/server/src/indexing/indexing.ts +++ b/server/src/indexing/indexing.ts @@ -7,6 +7,7 @@ import * as fs from "node:fs" import {glob} from "glob" import {filePathToUri} from "@server/files" +import {showErrorMessage} from "@server/utils/notify" export enum IndexingRootKind { Stdlib = "stdlib", @@ -43,7 +44,10 @@ export abstract class IndexingRoot { }) if (files.length === 0) { if (!this.checkReadAccess(this.root)) { - console.warn(`Can't access ${this.root}`) + const message = `Can't access ${this.root}` + + showErrorMessage(message) + console.error(message) } console.warn(`No file to index in ${this.root}`) diff --git a/server/src/server.ts b/server/src/server.ts index 5f9735ef..eb145303 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -135,6 +135,8 @@ import {collectFuncCodeLenses} from "@server/languages/func/lens" import {collectFiftCodeLenses} from "@server/languages/fift/lens" import {contractAbi} from "@server/languages/tolk/lang/abi/compute" +import {showErrorMessage} from "@server/utils/notify" + import {initParser} from "./parser" import {DocumentStore} from "./document-store" import {connection} from "./connection" @@ -230,13 +232,6 @@ async function handleFileOpen( } } -const showErrorMessage = (msg: string): void => { - void connection.sendNotification(lsp.ShowMessageNotification.type, { - type: lsp.MessageType.Error, - message: msg, - }) -} - async function findTolkStdlib(settings: ServerSettings, rootDir: string): Promise { if (settings.tolk.stdlib.path !== null && settings.tolk.stdlib.path.length > 0) { return settings.tolk.stdlib.path diff --git a/server/src/utils/notify.ts b/server/src/utils/notify.ts new file mode 100644 index 00000000..2bcd7c68 --- /dev/null +++ b/server/src/utils/notify.ts @@ -0,0 +1,10 @@ +import * as lsp from "vscode-languageserver" + +import {connection} from "@server/connection" + +export const showErrorMessage = (msg: string): void => { + void connection.sendNotification(lsp.ShowMessageNotification.type, { + type: lsp.MessageType.Error, + message: msg, + }) +} From 9211f942997ffb17d4f6e2eb2ab30b36d0a86682 Mon Sep 17 00:00:00 2001 From: Danil Ovchinnikov Date: Fri, 28 Nov 2025 01:23:09 +0300 Subject: [PATCH 3/4] docs --- docs/manual/troubleshooting.md | 4 ++++ server/src/indexing/indexing.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/manual/troubleshooting.md b/docs/manual/troubleshooting.md index eea1ac87..f7b578f3 100644 --- a/docs/manual/troubleshooting.md +++ b/docs/manual/troubleshooting.md @@ -72,6 +72,10 @@ Also, you can view extension logs directly in VS Code: These logs are helpful when reporting issues on GitHub. +### Can't access the Tolk standard library folder + +TODO + ## Reporting Issues If you encounter an issue not covered here: diff --git a/server/src/indexing/indexing.ts b/server/src/indexing/indexing.ts index 915003eb..b9838507 100644 --- a/server/src/indexing/indexing.ts +++ b/server/src/indexing/indexing.ts @@ -44,7 +44,7 @@ export abstract class IndexingRoot { }) if (files.length === 0) { if (!this.checkReadAccess(this.root)) { - const message = `Can't access ${this.root}` + const message = `Can't access the '${this.root}' folder in the Tolk standard library.\n` showErrorMessage(message) console.error(message) From 97e9ec99b13e370941cbdec6acf5769d7285af8b Mon Sep 17 00:00:00 2001 From: Danil Ovchinnikov Date: Fri, 28 Nov 2025 01:29:57 +0300 Subject: [PATCH 4/4] link --- server/src/indexing/indexing.ts | 5 +++-- server/src/utils/notify.ts | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server/src/indexing/indexing.ts b/server/src/indexing/indexing.ts index b9838507..7be55208 100644 --- a/server/src/indexing/indexing.ts +++ b/server/src/indexing/indexing.ts @@ -7,7 +7,7 @@ import * as fs from "node:fs" import {glob} from "glob" import {filePathToUri} from "@server/files" -import {showErrorMessage} from "@server/utils/notify" +import {showErrorMessage, troubleshootingLink} from "@server/utils/notify" export enum IndexingRootKind { Stdlib = "stdlib", @@ -44,7 +44,8 @@ export abstract class IndexingRoot { }) if (files.length === 0) { if (!this.checkReadAccess(this.root)) { - const message = `Can't access the '${this.root}' folder in the Tolk standard library.\n` + const see = troubleshootingLink("cant-access-the-tolk-standard-library-folder") + const message = `Can't access the '${this.root}' folder in the Tolk standard library.\nSee: ${see}` showErrorMessage(message) console.error(message) diff --git a/server/src/utils/notify.ts b/server/src/utils/notify.ts index 2bcd7c68..e9311c42 100644 --- a/server/src/utils/notify.ts +++ b/server/src/utils/notify.ts @@ -8,3 +8,14 @@ export const showErrorMessage = (msg: string): void => { message: msg, }) } + +export const troubleshootingLink = (section?: string): string => { + const troubleshootingDocsLink = + "https://github.com/ton-blockchain/ton-language-server/blob/main/docs/manual/troubleshooting.md" + + if (section == undefined) { + return `${troubleshootingDocsLink}#${section}` + } + + return troubleshootingDocsLink +}