Skip to content

Commit 6e144e8

Browse files
committed
Improve imports getting out of date
Fixes elm-tooling/elm-language-client-vscode#93
1 parent 46a4886 commit 6e144e8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/providers/astProvider.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ export class ASTProvider {
5353
}
5454
if (tree) {
5555
forest.setTree(document.uri, true, true, tree);
56+
57+
// Figure out if we have files importing our changed file - update them
58+
const urisToRefresh = [];
59+
for (const uri in imports.imports) {
60+
if (imports.imports.hasOwnProperty(uri)) {
61+
const fileImports = imports.imports[uri];
62+
63+
if (fileImports.some((a) => a.fromUri === document.uri)) {
64+
urisToRefresh.push(uri);
65+
}
66+
}
67+
}
68+
urisToRefresh.forEach((a) => {
69+
imports.updateImports(a, forest.getTree(a)!, forest);
70+
});
71+
72+
// Refresh imports of the calling file
5673
imports.updateImports(document.uri, tree, forest);
5774
}
5875
};

0 commit comments

Comments
 (0)