Don't create stubs for properties in delegate expression
This commit is contained in:
+11
-4
@@ -23,10 +23,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
|
||||
import org.jetbrains.jet.lang.psi.JetWithExpressionInitializer;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
public abstract class JetStubElementType<StubT extends StubElement, PsiT extends PsiElement> extends IStubElementType<StubT, PsiT> {
|
||||
@@ -67,6 +64,16 @@ public abstract class JetStubElementType<StubT extends StubElement, PsiT extends
|
||||
}
|
||||
}
|
||||
|
||||
// Don't create stubs if declaration is inside property delegate
|
||||
@SuppressWarnings("unchecked") JetPropertyDelegate delegate =
|
||||
PsiTreeUtil.getParentOfType(psi, JetPropertyDelegate.class, true, JetBlockExpression.class);
|
||||
if (delegate != null) {
|
||||
JetExpression delegateExpression = delegate.getExpression();
|
||||
if (PsiTreeUtil.isAncestor(delegateExpression, psi, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.shouldCreateStub(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,12 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
public void testNotStorePropertyFromDelegate() {
|
||||
doBuildTest("val a by kotlin.\n val b = 1",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top topFQName=a name=a typeText=null bodyText=null]\n");
|
||||
}
|
||||
|
||||
public void testNotStorePropertiesFrom() {
|
||||
doBuildTest("class Test() {\n" +
|
||||
" val test = 12;\n" +
|
||||
|
||||
Reference in New Issue
Block a user