Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Fixes for code complete
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Jan 23, 2022
1 parent 08fdb15 commit 2bb3daf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.0.14

Fixes for code completion.

## 0.0.13

Nile integration.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Cairo and StarkNet language support for VS Code",
"author": "Eric Lau",
"license": "EPL-2.0",
"version": "0.0.13",
"version": "0.0.14",
"preview": true,
"icon": "images/logo.png",
"repository": {
Expand Down
11 changes: 6 additions & 5 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,14 @@ async function getAllCairoFilesStartingWith(uri: string, prefix: string) : Promi
const withoutFileExtension = fileFullPath.substring(0, fileFullPath.lastIndexOf(".cairo"));
const relativePathWithoutExt = relativize(withoutFileExtension, searchPath);

// if (isPartOfAnotherSearchPath(fileFullPath, searchPath, packageSearchPathsArray)) {
// connection.console.log(`Skipping path since it is part of another search path: ${relativePathWithoutExt}`);
// else
if (relativePathWithoutExt.includes('.')) {
if (isPartOfAnotherSearchPath(fileFullPath, searchPath, packageSearchPathsArray)) {
connection.console.log(`Skipping path since it is part of another search path: ${relativePathWithoutExt}`);
} else if (relativePathWithoutExt.includes('.')) {
// filter out paths that have "." since those are not proper cairo paths
// e.g. "cairo-contracts/env/lib/python3.9/site-packages/starkware/cairo/common/bitwise" is part of a venv, not really a contract path in the current search path
connection.console.log(`Skipping path since it's not a valid cairo path: ${relativePathWithoutExt}`);
} else if (fileFullPath.includes('site-packages/nile/base_project')) {
connection.console.log(`Skipping nile base project: ${relativePathWithoutExt}`);
} else {
connection.console.log(`Adding package path for cairo file: ${relativePathWithoutExt}`);
result.push(convertPathToImport(relativePathWithoutExt));
Expand All @@ -1002,7 +1003,7 @@ async function getAllCairoFilesStartingWith(uri: string, prefix: string) : Promi

function isPartOfAnotherSearchPath(filePath: string, searchPath: string, packageSearchPaths: string[]) {
for (let otherSearchPath of packageSearchPaths) {
if (otherSearchPath !== searchPath && filePath.startsWith(otherSearchPath)) {
if (otherSearchPath !== searchPath && otherSearchPath.startsWith(searchPath) && filePath.startsWith(otherSearchPath)) {
return true;
}
}
Expand Down

0 comments on commit 2bb3daf

Please sign in to comment.