diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java index 648836ab525..0ab89ffb090 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java @@ -85,15 +85,15 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub { + @Nullable + FqName getTopFQName(); + /** * Is function defined in directly in package. * @return diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java index d28ff9af203..8ba2892bfcc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFileElementType.java @@ -38,7 +38,7 @@ import java.io.IOException; * @author Nikolay Krasko */ public class JetFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = 15; + public static final int STUB_VERSION = 16; public JetFileElementType() { super("jet.FILE", JetLanguage.INSTANCE); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java index d8b8b967d7e..ca435954d05 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java @@ -17,6 +17,7 @@ package org.jetbrains.jet.lang.psi.stubs.elements; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; import com.intellij.psi.stubs.IndexSink; import com.intellij.psi.stubs.StubElement; import com.intellij.psi.stubs.StubInputStream; @@ -28,6 +29,7 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction; import org.jetbrains.jet.lang.psi.stubs.PsiJetFileStub; import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub; import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetFunctionStubImpl; +import org.jetbrains.jet.lang.resolve.name.FqName; import java.io.IOException; @@ -50,30 +52,51 @@ public class JetFunctionElementType extends JetStubElementType implement private final StringRef nameRef; private final boolean isTopLevel; private final boolean isExtension; - - public PsiJetFunctionStubImpl(@NotNull IStubElementType elementType, @NotNull StubElement parent, - @Nullable String name, boolean isTopLevel, boolean isExtension) { - this(elementType, parent, StringRef.fromString(name), isTopLevel, isExtension); + private final FqName topFQName; + + public PsiJetFunctionStubImpl( + @NotNull IStubElementType elementType, + @NotNull StubElement parent, + @Nullable String name, + boolean isTopLevel, + @Nullable FqName topFQName, + boolean isExtension) { + this(elementType, parent, StringRef.fromString(name), isTopLevel, topFQName, isExtension); } - public PsiJetFunctionStubImpl(@NotNull IStubElementType elementType, @NotNull StubElement parent, - @Nullable StringRef nameRef, boolean isTopLevel, boolean isExtension) { + public PsiJetFunctionStubImpl( + @NotNull IStubElementType elementType, + @NotNull StubElement parent, + @Nullable StringRef nameRef, + boolean isTopLevel, + @Nullable FqName topFQName, + boolean isExtension) { super(parent, elementType); + if (isTopLevel && topFQName == null) { + throw new IllegalArgumentException("topFQName shouldn't be null for top level functions"); + } + this.nameRef = nameRef; + this.topFQName = topFQName; this.isTopLevel = isTopLevel; this.isExtension = isExtension; } @@ -54,6 +71,12 @@ public class PsiJetFunctionStubImpl extends StubBase implement return StringRef.toString(nameRef); } + @Nullable + @Override + public FqName getTopFQName() { + return topFQName; + } + @Override public boolean isTopLevel() { return isTopLevel; @@ -77,7 +100,8 @@ public class PsiJetFunctionStubImpl extends StubBase implement builder.append("PsiJetFunctionStubImpl["); if (isTopLevel()) { - builder.append("top "); + assert topFQName != null; + builder.append("top ").append("topFQName=").append(topFQName.toString()).append(" "); } if (isExtension()) { diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java index 81020c7532b..5c06f6dff4a 100644 --- a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java @@ -78,7 +78,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase { public void testFunctionParameters() { doBuildTest("fun some(t: Int, other: String = \"hello\") { }", "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top name=some]\n" + + " FUN:PsiJetFunctionStubImpl[top topFQName=some name=some]\n" + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" + " VALUE_PARAMETER:PsiJetParameterStubImpl[val name=t typeText=Int defaultValue=null]\n" + " VALUE_PARAMETER:PsiJetParameterStubImpl[val name=other typeText=String defaultValue=\"hello\"]\n"); @@ -87,14 +87,14 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase { public void testNotStoreInFunction() { doBuildTest("fun some() { val test = 12;\n fun fake() {}\n class FakeClass\n }", "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top name=some]\n" + + " FUN:PsiJetFunctionStubImpl[top topFQName=some name=some]\n" + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); } public void testNotStorePropertyFromInitializer() { doBuildTest("fun DoubleArray.some() = for (element in this) println(element)", "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top ext name=some]\n" + + " FUN:PsiJetFunctionStubImpl[top topFQName=some ext name=some]\n" + " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); }