-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix NPE with commented import in kotlin scripts #999
Conversation
### What's done: * Changed logic * Added tests
Codecov Report
@@ Coverage Diff @@
## master #999 +/- ##
============================================
- Coverage 83.80% 83.79% -0.02%
- Complexity 2422 2423 +1
============================================
Files 102 102
Lines 6108 6108
Branches 1809 1810 +1
============================================
- Hits 5119 5118 -1
Misses 269 269
- Partials 720 721 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
// In case when comment is inside of a function or class | ||
if (node.treePrev.isWhiteSpace()) { | ||
node.treePrev.treePrev.elementType == LBRACE | ||
// in some cases (e.g. kts files) BLOCK doesn't have a leading brace | ||
node.treePrev?.treePrev?.elementType == LBRACE |
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.
treePrev
, treeParent
are nullable types, however, they don't marked as such in source code, so IDEA don't advise to make such calls 'save' automatically, and so we use them is some dangerous way
May be we need to change such calls in whole project to appropriate !!
or ?.
in aim to avoid some problems in future?
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.
The problem here is that we won't get any compiler checks, unless source of ASTNode is annotated with proper annotations. For sure, adding safe access to all such unvokations may save us from some NPEs, but I don't see a good way to enforce this style.
What's done:
This pull request closes #994