Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
skulidropek opened this issue Nov 12, 2024 · 3 comments

Comments

@skulidropek
Copy link
Contributor

skulidropek commented Nov 12, 2024

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
Copy link
Member

logvik commented Nov 12, 2024

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
Copy link
Contributor Author

skulidropek commented Nov 12, 2024

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
Copy link
Contributor Author

skulidropek commented Nov 12, 2024

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);
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants