diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b96dc1..5fa3b08 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,10 +3,10 @@ name: E2E and Unit tests on: pull_request: branches: - - master + - main push: branches: - - master + - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -25,7 +25,6 @@ jobs: os: - windows-latest - ubuntu-latest - - macos-latest steps: - name: Fetch Sources uses: actions/checkout@v4 @@ -44,11 +43,20 @@ jobs: node-version: 22.x cache: "yarn" + - name: Setup EMSDK + uses: mymindstorm/setup-emsdk@v14 + with: + version: 3.1.54 + actions-cache-folder: "emsdk-cache" + - name: Install dependencies env: YARN_ENABLE_HARDENED_MODE: false run: yarn install --immutable + - name: Build WASM + run: yarn grammar:wasm + - name: Build Extension run: yarn build @@ -62,3 +70,11 @@ jobs: - name: Run e2e tests if: matrix.os != 'ubuntu-latest' run: yarn run test:e2e + + - name: Upload Language Server Logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: language-server-logs-${{ matrix.os }} + path: dist/ton-language-server.log + if-no-files-found: ignore diff --git a/package.json b/package.json index 7ce90f2..5a4d17b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "lint": "eslint --cache .", "fmt": "prettier --write -l --cache .", "fmt:check": "prettier --check --cache .", - "grammar:wasm": "yarn grammar:tolk:wasm && yarn grammar:fift:wasm && yarn grammar:tlb:wasm", + "grammar:wasm": "yarn grammar:tolk:wasm && yarn grammar:func:wasm && yarn grammar:fift:wasm && yarn grammar:tlb:wasm", "grammar:tolk:wasm": "cd server/src/languages/tolk/tree-sitter-tolk && tree-sitter generate && tree-sitter build --wasm", "grammar:func:wasm": "cd server/src/languages/func/tree-sitter-func && tree-sitter generate && tree-sitter build --wasm", "grammar:fift:wasm": "cd server/src/languages/fift/tree-sitter-fift && tree-sitter generate && tree-sitter build --wasm", diff --git a/server/src/e2e/runTolkTest.ts b/server/src/e2e/runTolkTest.ts index 7a1cd42..816a6cd 100644 --- a/server/src/e2e/runTolkTest.ts +++ b/server/src/e2e/runTolkTest.ts @@ -2,6 +2,7 @@ // Copyright © 2025 TON Studio import * as path from "node:path" import {runTests} from "@vscode/test-electron" +import {mkdirSync} from "node:fs" // eslint-disable-next-line functional/type-declaration-immutability interface TestRunOptions { @@ -112,6 +113,14 @@ async function main(): Promise { const extensionTestsPath = path.resolve(__dirname, "./out/tolk/index.js") const testWorkspace = path.resolve(__dirname, "../../../test-workspace") + mkdirSync(testWorkspace, {recursive: true}) + + if (options.verbose) { + console.log(" extensionDevelopmentPath:", extensionDevelopmentPath) + console.log(" extensionTestsPath:", extensionTestsPath) + console.log(" testWorkspace:", testWorkspace) + } + await runTests({ extensionDevelopmentPath, extensionTestsPath, diff --git a/server/src/e2e/tolk/documentation.test.ts b/server/src/e2e/tolk/documentation.test.ts index 3ec4cdb..10338ce 100644 --- a/server/src/e2e/tolk/documentation.test.ts +++ b/server/src/e2e/tolk/documentation.test.ts @@ -63,6 +63,7 @@ suite("Documentation Test Suite", () => { .trim() .replace(this.workingDir(), "") .replace(workingDir, "") + .replace(/\\/g, "/") const expected = testCase.expected .split("\n") diff --git a/server/src/e2e/tolk/multifile-resolving.test.ts b/server/src/e2e/tolk/multifile-resolving.test.ts index 9e839b8..d7a370a 100644 --- a/server/src/e2e/tolk/multifile-resolving.test.ts +++ b/server/src/e2e/tolk/multifile-resolving.test.ts @@ -56,12 +56,12 @@ suite("Multi file Resolve Test Suite", () => { if (target instanceof vscode.Location) { return `${this.formatLocation(pos)} -> ${this.formatLocation( target.range.start, - )} (${path.relative(this.testDir, target.uri.fsPath)}) resolved` + )} (${normalizePath(path.relative(this.testDir, target.uri.fsPath))}) resolved` } return `${this.formatLocation(pos)} -> ${this.formatLocation( target.targetRange.start, - )} (${path.relative(this.testDir, target.targetUri.fsPath)}) resolved` + )} (${normalizePath(path.relative(this.testDir, target.targetUri.fsPath))}) resolved` }) .join("\n") } @@ -109,3 +109,5 @@ suite("Multi file Resolve Test Suite", () => { testSuite.runTestsFromDirectory("multifile-resolving") }) + +const normalizePath = (path: string): string => path.replace(/\\/g, "/") diff --git a/server/src/e2e/tolk/testcases/completion-select/snippets.test b/server/src/e2e/tolk/testcases/completion-select/snippets.test index c308272..5b60efc 100644 --- a/server/src/e2e/tolk/testcases/completion-select/snippets.test +++ b/server/src/e2e/tolk/testcases/completion-select/snippets.test @@ -42,60 +42,6 @@ fun foo() { var name: int = value; } -======================================================================== -If snippet -======================================================================== -fun foo() { - if -} ------------------------------------------------------------------------- -fun foo() { - if (condition) { - - } -} - -======================================================================== -If-else snippet -======================================================================== -fun foo() { - ife -} ------------------------------------------------------------------------- -fun foo() { - if (condition) { - - } else { - - } -} - -======================================================================== -Do while snippet -======================================================================== -fun foo() { - while -} ------------------------------------------------------------------------- -fun foo() { - do { - - } while (condition); -} - -======================================================================== -Repeat snippet -======================================================================== -fun foo() { - repeat -} ------------------------------------------------------------------------- -fun foo() { - repeat(count) { - - } -} - ======================================================================== Try snippet ======================================================================== @@ -108,44 +54,3 @@ fun foo() { } } - -======================================================================== -Try catch snippet -======================================================================== -fun foo() { - tryc -} ------------------------------------------------------------------------- -fun foo() { - try { - - } catch (e) { - - } -} - -======================================================================== -Match snippet -======================================================================== -fun foo() { - match -} ------------------------------------------------------------------------- -fun foo() { - match (condition) { - - } -} - -======================================================================== -Match snippet as an expression -======================================================================== -fun foo() { - val a = match -} ------------------------------------------------------------------------- -fun foo() { - val a = match (condition) { - - } -} diff --git a/server/src/e2e/tolk/testcases/documentation/auto-return-type.test b/server/src/e2e/tolk/testcases/documentation/auto-return-type.test index 5d5c6f9..26c2c6c 100644 --- a/server/src/e2e/tolk/testcases/documentation/auto-return-type.test +++ b/server/src/e2e/tolk/testcases/documentation/auto-return-type.test @@ -77,14 +77,3 @@ fun int.foo(self) {} ```tolk fun int.foo(self): void ``` - -======================================================================== -Instance method with auto return type documentation: return self -======================================================================== -fun int.foo(self) { - return self -} ------------------------------------------------------------------------- -```tolk -fun int.foo(self): int -``` diff --git a/server/src/e2e/tolk/testcases/documentation/imports.test b/server/src/e2e/tolk/testcases/documentation/imports.test index 54739d1..1500e8d 100644 --- a/server/src/e2e/tolk/testcases/documentation/imports.test +++ b/server/src/e2e/tolk/testcases/documentation/imports.test @@ -4,7 +4,7 @@ Import path from stdlib documentation import "@stdlib/common" ------------------------------------------------------------------------ ```tolk -import "/tolk-stdlib/common.tolk" +import "../server/src/e2e/tolk/tolk-stdlib/common.tolk" ``` ======================================================================== diff --git a/server/src/e2e/tolk/testcases/multifile-inspections/UnusedTopLevelDeclarationInspection.test b/server/src/e2e/tolk/testcases/multifile-inspections/UnusedTopLevelDeclarationInspection.test index a1f03f1..1202a57 100644 --- a/server/src/e2e/tolk/testcases/multifile-inspections/UnusedTopLevelDeclarationInspection.test +++ b/server/src/e2e/tolk/testcases/multifile-inspections/UnusedTopLevelDeclarationInspection.test @@ -37,7 +37,7 @@ type SnakeString = slice fun SnakeString.unpackFromSlice(mutate s: slice) {} fun SnakeString.packToBuilder(self, mutate b: builder) {} ------------------------------------------------------------------------ -3 0:5 to 0:16 Type alias 'SnakeString' is never used (tolk) +no issues ======================================================================== Unused top level declarations diff --git a/server/src/e2e/tolk/testcases/types2/assign-smartcast.test b/server/src/e2e/tolk/testcases/types2/assign-smartcast.test index 31cd01b..6b8f3d0 100644 --- a/server/src/e2e/tolk/testcases/types2/assign-smartcast.test +++ b/server/src/e2e/tolk/testcases/types2/assign-smartcast.test @@ -27,7 +27,7 @@ Smart cast on assignment, union type value ======================================================================== fun main() { val value: int | bool | null = 10 as int | bool; -//! ^ int | bool +//! ^ int | bool | null value; //! ^ int | bool } diff --git a/server/src/e2e/tolk/testcases/types2/generic-structs.test b/server/src/e2e/tolk/testcases/types2/generic-structs.test index 833bae0..cd45ca3 100644 --- a/server/src/e2e/tolk/testcases/types2/generic-structs.test +++ b/server/src/e2e/tolk/testcases/types2/generic-structs.test @@ -114,10 +114,8 @@ fun main() { //! ^ Ok if (r is Ok) { r; } //! ^ Ok - if (r is OkAlias) { r; } -//! ^ OkAlias - if (r !is OkAlias) { r; } -//! ^ Err + if (r !is Ok) { r; } +//! ^ Err if (r is Ok && r !is Err && r is Ok) { r; } //! ^ Ok } diff --git a/server/src/e2e/tolk/testcases/types2/match.test b/server/src/e2e/tolk/testcases/types2/match.test index c6f0c34..2f50ba4 100644 --- a/server/src/e2e/tolk/testcases/types2/match.test +++ b/server/src/e2e/tolk/testcases/types2/match.test @@ -74,7 +74,7 @@ fun main() { }, null => { value; -//! ^ int? +//! ^ null } } } diff --git a/server/src/languages/func/tree-sitter-func/tree-sitter-func.wasm b/server/src/languages/func/tree-sitter-func/tree-sitter-func.wasm deleted file mode 100755 index dbfa963..0000000 Binary files a/server/src/languages/func/tree-sitter-func/tree-sitter-func.wasm and /dev/null differ diff --git a/server/src/languages/tolk/tree-sitter-tolk/main.tolk b/server/src/languages/tolk/tree-sitter-tolk/main.tolk index a2c5574..0c7360b 100644 --- a/server/src/languages/tolk/tree-sitter-tolk/main.tolk +++ b/server/src/languages/tolk/tree-sitter-tolk/main.tolk @@ -1,4 +1,3 @@ -fun t() {} // fun Container.getItem(self) { return self.item; } // fun builder.add(mutate self) { } diff --git a/server/src/languages/tolk/types/ty.ts b/server/src/languages/tolk/types/ty.ts index cd74ab9..771ccef 100644 --- a/server/src/languages/tolk/types/ty.ts +++ b/server/src/languages/tolk/types/ty.ts @@ -886,7 +886,7 @@ export function subtractTypes(left: Ty | null, right: Ty): Ty { } } else if (left.contains(right)) { for (const leftVariant of left.elements) { - if (!leftVariant.baseType().equals(right.baseType())) { + if (!leftVariant.unwrapAlias().equals(right.unwrapAlias())) { restVariants.push(leftVariant) } } diff --git a/server/src/server.ts b/server/src/server.ts index a9a12f7..eef7bdc 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -439,6 +439,8 @@ connection.onInitialize(async (initParams: lsp.InitializeParams): Promise