find file paths in use and import tokens (#105)

This commit is contained in:
Dima 2024-05-29 14:10:16 +07:00 committed by GitHub
parent 6edf408617
commit a31e1c78b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 64 deletions

View File

@ -28,22 +28,6 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
}, },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -55,18 +39,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/semver": { "node_modules/semver": {
"version": "7.5.4", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
@ -153,22 +125,6 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
}, },
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"lru-cache": { "lru-cache": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -177,15 +133,6 @@
"yallist": "^4.0.0" "yallist": "^4.0.0"
} }
}, },
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"semver": { "semver": {
"version": "7.5.4", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",

View File

@ -8,7 +8,7 @@
"name": "aqua-ls-server", "name": "aqua-ls-server",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@fluencelabs/aqua-language-server-api": "0.14.7", "@fluencelabs/aqua-language-server-api": "0.14.8",
"global-dirs": "^4.0.0", "global-dirs": "^4.0.0",
"vscode-languageserver": "^9.0.0", "vscode-languageserver": "^9.0.0",
"vscode-languageserver-textdocument": "^1.0.4", "vscode-languageserver-textdocument": "^1.0.4",
@ -35,9 +35,9 @@
"license": "Apache-2.0" "license": "Apache-2.0"
}, },
"node_modules/@fluencelabs/aqua-language-server-api": { "node_modules/@fluencelabs/aqua-language-server-api": {
"version": "0.14.7", "version": "0.14.8",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-language-server-api/-/aqua-language-server-api-0.14.7.tgz", "resolved": "https://registry.npmjs.org/@fluencelabs/aqua-language-server-api/-/aqua-language-server-api-0.14.8.tgz",
"integrity": "sha512-B+dEpbTf/vjsfqKf0+vONYCy/xYCJJbNcQggcirrFzB3E2EiV9BIZUkWNuxZE0zcFwNktbd7N/GfhFTRNXsraQ==" "integrity": "sha512-cvpo4p0XbzXFtrvM5jeHVsq4oxxl7jU+DsEcqfq/iCYr8n29Dmf3JYDPfA46NdtDTIVzUh+kKHbhA6jes3+shA=="
}, },
"node_modules/@types/json5": { "node_modules/@types/json5": {
"version": "0.0.29", "version": "0.0.29",
@ -1290,9 +1290,9 @@
}, },
"dependencies": { "dependencies": {
"@fluencelabs/aqua-language-server-api": { "@fluencelabs/aqua-language-server-api": {
"version": "0.14.7", "version": "0.14.8",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-language-server-api/-/aqua-language-server-api-0.14.7.tgz", "resolved": "https://registry.npmjs.org/@fluencelabs/aqua-language-server-api/-/aqua-language-server-api-0.14.8.tgz",
"integrity": "sha512-B+dEpbTf/vjsfqKf0+vONYCy/xYCJJbNcQggcirrFzB3E2EiV9BIZUkWNuxZE0zcFwNktbd7N/GfhFTRNXsraQ==" "integrity": "sha512-cvpo4p0XbzXFtrvM5jeHVsq4oxxl7jU+DsEcqfq/iCYr8n29Dmf3JYDPfA46NdtDTIVzUh+kKHbhA6jes3+shA=="
}, },
"@types/json5": { "@types/json5": {
"version": "0.0.29", "version": "0.0.29",

View File

@ -11,7 +11,7 @@
"url": "https://github.com/fluencelabs/aqua" "url": "https://github.com/fluencelabs/aqua"
}, },
"dependencies": { "dependencies": {
"@fluencelabs/aqua-language-server-api": "0.14.7", "@fluencelabs/aqua-language-server-api": "0.14.8",
"global-dirs": "^4.0.0", "global-dirs": "^4.0.0",
"vscode-languageserver": "^9.0.0", "vscode-languageserver": "^9.0.0",
"vscode-languageserver-textdocument": "^1.0.4", "vscode-languageserver-textdocument": "^1.0.4",

View File

@ -53,11 +53,20 @@ export async function compileAqua(
const docPath = Path.parse(path); const docPath = Path.parse(path);
const linksSearch = [docPath.dir]; // empty string for already resolved paths in 'importLocations'
const linksSearch = ['', docPath.dir];
// TODO: fix import locations search
result.importLocations.map(function (ti) { result.importLocations.map(function (ti) {
const path = linksSearch.map((i) => Path.join(i, ti.path)).find(fs.existsSync); // add extension for imports without extension
let importPath: string;
if (ti.path.endsWith('.aqua')) {
importPath = ti.path;
} else {
importPath = ti.path + '.aqua';
}
const path = linksSearch.map((i) => Path.join(i, importPath)).find(fs.existsSync);
if (path) { if (path) {
links.push({ links.push({
@ -70,6 +79,8 @@ export async function compileAqua(
endCol: 0, endCol: 0,
}, },
}); });
} else {
console.log(`Cannot find path for '${ti}'`)
} }
}); });