Skip to content
Open
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: 4 additions & 0 deletions docs/manual/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions server/src/indexing/indexing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ 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"
import {showErrorMessage, troubleshootingLink} from "@server/utils/notify"

export enum IndexingRootKind {
Stdlib = "stdlib",
Expand Down Expand Up @@ -40,6 +43,14 @@ export abstract class IndexingRoot {
ignore: ignore,
})
if (files.length === 0) {
if (!this.checkReadAccess(this.root)) {
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)
}

console.warn(`No file to index in ${this.root}`)
}
for (const filePath of files) {
Expand All @@ -50,5 +61,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<void>
}
9 changes: 2 additions & 7 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<string | null> {
if (settings.tolk.stdlib.path !== null && settings.tolk.stdlib.path.length > 0) {
return settings.tolk.stdlib.path
Expand Down
21 changes: 21 additions & 0 deletions server/src/utils/notify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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,
})
}

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
}