Skip to content

Commit 33f951a

Browse files
committed
Fix completion not working for imports.hx (#1230)
Details: Completion references are in tmp in-memory files and does not provide us with any directory/filesystem information so we are unable to find the `import.hx`when resolving. the solution is to get the original file if available.
1 parent 7f23d49 commit 33f951a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/intellij/plugins/haxe/util/HaxeResolveUtil.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,16 +1158,24 @@ private static List<PsiElement> searchInDirectoryImports(HaxeFileModel file, Str
11581158
*/
11591159
public static boolean walkDirectoryImports(HaxeFileModel file, @NotNull java.util.function.Function<HaxeFileModel, Boolean> processor) {
11601160
if (null == file) return true;
1161+
HaxeFile haxeFile = file.getFile();
1162+
1163+
// Attempt to get physical file if possible, necessary if we are to walk directories
1164+
if(!file.getFile().isPhysical()) {
1165+
if(file.getFile().getOriginalFile() instanceof HaxeFile realFile) {
1166+
haxeFile = realFile;
1167+
}
1168+
}
11611169

1162-
final VirtualFile vfile = file.getFile().getVirtualFile();
1170+
final VirtualFile vfile = haxeFile.getVirtualFile();
11631171
if (null == vfile) return true; // In memory files
11641172

11651173
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(file.getBasePsi().getProject()).getFileIndex();
11661174
final VirtualFile sourceRoot = fileIndex.getSourceRootForFile(vfile);
11671175
if (null == sourceRoot) return true;
11681176

11691177
boolean keepRunning = true;
1170-
HaxeFile haxeFile = file.getFile();
1178+
11711179
PsiDirectory parentDirectory = haxeFile.getContainingDirectory();
11721180
final VirtualFile stopDir = sourceRoot.getParent(); // SrcRoot is a valid place to pick up an import.hx file.
11731181
while (keepRunning && null != parentDirectory && !parentDirectory.getVirtualFile().equals(stopDir)) {

0 commit comments

Comments
 (0)