tact-lang / tact-vscode

Tact VS Code plugin
Apache License 2.0
23 stars 9 forks source link

Formatter does note recognitsa @stdlib imports for syntax highlighting #51

Open skulidropek opened 1 day ago

skulidropek commented 1 day ago

The formatter does not recognize libraries imported using the @stdlib syntax, resulting in missing syntax highlighting and potentially affecting other IDE features.

For instance, the following snippet:

tact

import "@stdlib/deploy";
import "@stdlib/ownable";

is not recognized by the formatter and syntax highlighter, while the workaround below works as expected: tact

import "../node_modules/@tact-lang/compiler/stdlib/libs/deploy.tact";
import "../node_modules/@tact-lang/compiler/stdlib/libs/ownable.tact";

Logs:

foundImport @stdlib/deploy fs.existsSync(foundImport) false
foundImport @stdlib/ownable fs.existsSync(foundImport) false
foundImport c:/Users/legov/OneDrive/Documents/GitHub/tact-template/node_modules/@tact-lang/compiler/stdlib/libs/ownable.tact fs.existsSync(foundImport) true
logvik commented 1 day ago

I didn't expect any issue with this code

import "@stdlib/deploy";
import "@stdlib/ownable";
import "@stdlib/stoppable";

May you share information about your environment? I see that you use Windows, as and I, but maybe not the latest version for the extension? Also, may this issue be related to different tact compiler version?

skulidropek commented 1 day ago

It does not give errors, but when pressing ctrl + click the functionality does not work for libraries taken from stdlib. It simply does not load them from the folder

I am using the latest version of the compiler

image

image

skulidropek commented 1 day ago

there is another problem that I found it does not load the default libraries that Tact uses

import "./std/primitives";
import "./std/cells";
import "./std/crypto";
import "./std/text";
import "./std/math";
import "./std/contract";
import "./std/debug";
import "./std/context";
import "./std/reserve";
import "./std/send";
import "./std/config";
import "./std/base";

I'm writing code now to make it load them because it doesn't see them for autocomplete or for ctrl+click.

 const stdlibPath = path.resolve(path.dirname(this.absolutePath), "../node_modules/@tact-lang/compiler/stdlib/std");
        const standardImports = [
            "primitives", "cells", "crypto", "text", "math", "contract",
            "debug", "context", "reserve", "send", "config", "base"
        ];

        const contractFileName = path.basename(contractPath);

        for (const lib of standardImports) {
            const fullPath = path.join(stdlibPath, `${lib}.tact`);
            const fullPathFileName = path.basename(fullPath);

            if (fs.existsSync(fullPath) && fullPathFileName !== contractFileName && !this.imports.includes(fullPath)) {
                this.imports.push(fullPath);
            }
        }