More aggressive block cache invalidation for declarations with type inference

This commit is contained in:
Nikolay Krasko
2012-06-08 22:53:17 +04:00
parent b5d5e42e5b
commit b104d70196
3 changed files with 35 additions and 3 deletions
@@ -35,18 +35,18 @@ public final class JetModifiableBlockHelper {
if (declaration instanceof JetNamedFunction) {
JetNamedFunction function = (JetNamedFunction) declaration;
if (function.hasDeclaredReturnType() || function.hasBlockBody()) {
return false;
return takePartInDeclarationTypeInference(function);
}
return shouldChangeModificationCount(function);
}
else if (declaration instanceof JetPropertyAccessor) {
return false;
return takePartInDeclarationTypeInference(declaration);
}
else if (declaration instanceof JetProperty) {
JetProperty property = (JetProperty) declaration;
if (property.getPropertyTypeRef() != null) {
return false;
return takePartInDeclarationTypeInference(property);
}
return shouldChangeModificationCount(property);
@@ -59,4 +59,26 @@ public final class JetModifiableBlockHelper {
return true;
}
private static boolean takePartInDeclarationTypeInference(PsiElement place) {
JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclaration.class, true);
if (declaration != null) {
if (declaration instanceof JetNamedFunction) {
JetNamedFunction function = (JetNamedFunction) declaration;
if (!function.hasDeclaredReturnType()) {
return true;
}
}
else if (declaration instanceof JetProperty) {
JetProperty property = (JetProperty) declaration;
if (property.getPropertyTypeRef() == null) {
return true;
}
}
return takePartInDeclarationTypeInference(declaration);
}
return false;
}
}
@@ -0,0 +1,6 @@
// TRUE
val o = object {
fun test() {
<caret>
}
}
@@ -54,6 +54,10 @@ public class OutOfBlockModificationTest extends LightCodeInsightFixtureTestCase
doTest();
}
public void testInAntonymsObjectDeclaration() {
doTest();
}
public void testInPropertyWithFunctionLiteral() {
doTest();
}