-
Notifications
You must be signed in to change notification settings - Fork 101
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
Null checks & Issue with resolution of "Unknown.hx" #936
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,9 +125,23 @@ public HaxeFileModel getFileModel(String fileName) { | |
protected HaxeFile getFile(String fileName) { | ||
PsiDirectory directory = root.access(path); | ||
if (directory != null && directory.isValid()) { | ||
PsiFile file = directory.findFile(fileName + ".hx"); | ||
if (file != null && file.isValid() && file instanceof HaxeFile) { | ||
return (HaxeFile)file; | ||
PsiFile file; | ||
try { | ||
String fName = fileName + ".hx"; | ||
//TODO @ Eric. What could be the source of a request for "Unknown.hx" ? | ||
if(fName.equals("Unknown.hx")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, there is nothing in the language that says you can't have a class called Perhaps we should rename our internal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree...I didnt expect my little hack to be permanent.. Shall I try to find that magic type and rename it as you recommended? |
||
return null; | ||
} | ||
//file = directory.findFile(fileName + ".hx"); | ||
file = directory.findFile(fName); | ||
if (file != null && file.isValid() && file instanceof HaxeFile) { | ||
return (HaxeFile)file; | ||
} | ||
} catch(Exception e){ | ||
//System.out.println("-----------------------------------"); | ||
//System.out.println(fileName + ".hx"); | ||
//System.out.println("-----------------------------------"); | ||
System.out.println(Arrays.toString(e.getStackTrace())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always use the HaxeDebugLogger instead of any of the System io dumps (out, err); the System calls can create write dead-locks when multiple JetBrains products are used simultaneously or when called on background threads (for example, see #724). They are also not captured in user logs where they could be useful for debugging.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool..thanks for that tip. |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a magic type of "unknown" in the language that is assigned to variables before type inference is able to set the type. (It's the same in the compiler -- just
trace(some_uninitialized_var);
to see it pop out.) If the resolver gets a variable in this condition, it's going to try and find the class by upper-casing the name and looking for an implementation file. Were we throwing an exception out of this function? What was the bug that made you look here?(BTW, ProcessCanceledExceptions are expected and should cancel the current task. That's the way that IntelliJ deals with blocked/blocking tasks.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah whenever it tried to load "Unknown.hx" it was throwing. The Intellij stack trace got me there eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I just noticed your BTW. That may be true but when it threw here it stopped parsing code. This is evident if you can repro from my instructions in the commit notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been unable to repro the exception being thrown and parsing stopping. If I set a breakpoint in
getFile()
, I can definitely see the code trying to find the file -- every time an unknown class reference is created. Issue #938 is for that.