This keeps behaviour consistent in rare cases when JavaClass can be found but not resolved
As of now this can happen in IDE if we take PsiClass from index but file structure is wrong so we can't resolve the class
Add test which documents this case
Get rid of Kind in JavaPackageFragmentDescriptor and create subclass which exposes additional function
Add method in JavaClassDescriptor to get correponding package fragment
Remove JavaDescriptorResolver from context
The previous commit made JetThisExpression not implement
JetStatementExpression. This had the side effect that
smartSelectExpression over a label-qualified this expression
(e.g 'this@outerClass') would now also list a plain 'this'
as a potential expression. Restore the old behaviour by adding an
explicit check for JetThisExpression.
Operator priority calculation for 'this' expressions was incorrect in
JetPsiUtil.getPriority(): it would return a very low value for
a JetThisExpression, causing the IDE to report that parenthesis
are necessary in an expression like '(this)[1]'.
Fix this by making JetThisExpression not implement
JetStatementExpression by removing the implements clause from
JetLabelQualifiedInstanceExpression and adding it to all other
subclasses of JetLabelQualifiedInstanceExpression.
Fixes KT-4513.
Add test suite for smart expression selector (the small expression list
popup in e.g. Extract Variable.)
The test file format is similar to that in JetNameSuggesterTest: a .kt
file with the usual <caret> marker specifying the place where the smart
selector will be run. Then, the last comment in the file should contain
the expected outcome.
Previously smartSelectExpression did both the determination of suitable
expressions and displaying the GUI. Separate the actual logic into a new
method, getSmartSelectSuggestions so that smart selection can be tested
in the future.
JetNameSuggesterTest contains useful code for getting the last comment
of a file. Extract it to JetTestUtils.getLastCommentInFile() so other
tests can use it as well.
These tests check that that complex references (var p by delegate, for in collection, array[index]) are resolved correctly when target descriptors have type parameters
See 41f9dcba91
#KT-4505 Fixed
Jet*Reference#getTargetDescriptors() no longer returns nullable value (convention is dropped)
Use ResolvedCall#getCandidateDescriptor() instead of ResolvedCall#getResultingDescriptor() because unsubstituted descriptors are expected
Add JetReference#resolveMap() function
Correct behaviour for unary, binary expressions and type references
Add instanceof checks in TipsManager so it's clear it only takes care of certain types of JetSimpleNameExpression