GuessManagerImpl: box values on fast-path; disable DFA on primitive types at all

Fixes IDEA-189340 Does not show Number methods during auto completion
This commit is contained in:
Tagir Valeev
2018-04-05 11:46:42 +07:00
parent c2e61e860c
commit 5fe4a9b691
4 changed files with 19 additions and 0 deletions
@@ -340,6 +340,9 @@ public class GuessManagerImpl extends GuessManager {
@NotNull
@Override
public List<PsiType> getControlFlowExpressionTypeConjuncts(@NotNull PsiExpression expr) {
if (expr.getType() instanceof PsiPrimitiveType) {
return Collections.emptyList();
}
List<PsiType> result = null;
PsiExpression place = PsiUtil.skipParenthesizedExprDown(expr);
if (place == null) return Collections.emptyList();
@@ -413,6 +416,9 @@ public class GuessManagerImpl extends GuessManager {
private void handleAssignment(@Nullable PsiExpression expression) {
if (expression == null) return;
PsiType type = expression.getType();
if (type instanceof PsiPrimitiveType) {
type = ((PsiPrimitiveType)type).getBoxedType(expression);
}
PsiType rawType = type instanceof PsiClassType ? ((PsiClassType)type).rawType() : type;
if (rawType == null || rawType.equals(PsiType.NULL)) return;
if (mySpecificType == null) {
@@ -0,0 +1,6 @@
class Foo {
void test() {
Number x = 10;
return x.lon<caret>
}
}
@@ -0,0 +1,6 @@
class Foo {
void test() {
Number x = 10;
return x.longValue()
}
}
@@ -47,6 +47,7 @@ class NormalCompletionDfaTest extends NormalCompletionTestCase {
void testAssignmentTwicePreciseTypeDfa() { doTest() }
void testAssignmentParameterDfa() { doTest() }
void testAssignmentNoPreciseTypeDfa() { doTest() }
void testAssignmentPrimitiveLiteral() { doTest() }
void testDeclarationPreciseTypeDfa() { doTest() }
void testInstanceOfAssignmentDfa() { doTest() }
void testStreamDfa() { doTest() }