diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index b4bd920e8a5..f64c6af4ceb 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -100,6 +100,7 @@ import org.jetbrains.jet.cfg.AbstractDataFlowTest import org.jetbrains.jet.plugin.libraries.AbstractDecompiledTextTest import org.jetbrains.jet.plugin.imports.AbstractOptimizeImportsTest import org.jetbrains.jet.plugin.debugger.AbstractSmartStepIntoTest +import org.jetbrains.jet.plugin.stubs.AbstractStubBuilderTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -529,6 +530,10 @@ fun main(args: Array) { testClass(javaClass()) { model("debugger/smartStepInto") } + + testClass(javaClass()) { + model("stubs", extension = "kt") + } } testGroup("j2k/tests/test", "j2k/tests/testData") { diff --git a/idea/testData/stubs/AnnotationClass.expected b/idea/testData/stubs/AnnotationClass.expected new file mode 100644 index 00000000000..c75aedb372c --- /dev/null +++ b/idea/testData/stubs/AnnotationClass.expected @@ -0,0 +1,2 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[isAnnotation name=Test fqn=Test superNames=[]] diff --git a/idea/testData/stubs/AnnotationClass.kt b/idea/testData/stubs/AnnotationClass.kt new file mode 100644 index 00000000000..3e5244b860b --- /dev/null +++ b/idea/testData/stubs/AnnotationClass.kt @@ -0,0 +1 @@ +annotation class Test \ No newline at end of file diff --git a/idea/testData/stubs/AnnotationOnClass.expected b/idea/testData/stubs/AnnotationOnClass.expected new file mode 100644 index 00000000000..b102e187568 --- /dev/null +++ b/idea/testData/stubs/AnnotationOnClass.expected @@ -0,0 +1,4 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]] + ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated] + CLASS_BODY:PsiJetClassBodyStubImpl diff --git a/idea/testData/stubs/AnnotationOnClass.kt b/idea/testData/stubs/AnnotationOnClass.kt new file mode 100644 index 00000000000..df38f557cc0 --- /dev/null +++ b/idea/testData/stubs/AnnotationOnClass.kt @@ -0,0 +1,2 @@ +Deprecated class Test { +} \ No newline at end of file diff --git a/idea/testData/stubs/AnnotationOnFunction.expected b/idea/testData/stubs/AnnotationOnFunction.expected new file mode 100644 index 00000000000..fa932fa9ef1 --- /dev/null +++ b/idea/testData/stubs/AnnotationOnFunction.expected @@ -0,0 +1,4 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/AnnotationOnFunction.kt b/idea/testData/stubs/AnnotationOnFunction.kt new file mode 100644 index 00000000000..1e429e42bb6 --- /dev/null +++ b/idea/testData/stubs/AnnotationOnFunction.kt @@ -0,0 +1,2 @@ +Deprecated fun foo() { +} \ No newline at end of file diff --git a/idea/testData/stubs/AnnotationOnLocalFunction.expected b/idea/testData/stubs/AnnotationOnLocalFunction.expected new file mode 100644 index 00000000000..8f04c639699 --- /dev/null +++ b/idea/testData/stubs/AnnotationOnLocalFunction.expected @@ -0,0 +1,3 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/AnnotationOnLocalFunction.kt b/idea/testData/stubs/AnnotationOnLocalFunction.kt new file mode 100644 index 00000000000..76d03a6c38a --- /dev/null +++ b/idea/testData/stubs/AnnotationOnLocalFunction.kt @@ -0,0 +1,4 @@ +fun foo() { + [Deprecated] fun innerFoo() { + } +} \ No newline at end of file diff --git a/idea/testData/stubs/AnonymousObject.expected b/idea/testData/stubs/AnonymousObject.expected new file mode 100644 index 00000000000..cbb2982c9e2 --- /dev/null +++ b/idea/testData/stubs/AnonymousObject.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]] + PROPERTY:PsiJetPropertyStubImpl[val top fqName=obj name=obj typeText=null bodyText=object : A(), T] + OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=null fqName=null superNames=[AT]] diff --git a/idea/testData/stubs/AnonymousObject.kt b/idea/testData/stubs/AnonymousObject.kt new file mode 100644 index 00000000000..c2984e24a31 --- /dev/null +++ b/idea/testData/stubs/AnonymousObject.kt @@ -0,0 +1,3 @@ +class A +trait T +val obj = object : A(), T \ No newline at end of file diff --git a/idea/testData/stubs/ClassObject.expected b/idea/testData/stubs/ClassObject.expected new file mode 100644 index 00000000000..831ac7c6c84 --- /dev/null +++ b/idea/testData/stubs/ClassObject.expected @@ -0,0 +1,7 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + FUN:PsiJetFunctionStubImpl[name=foo] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/ClassObject.kt b/idea/testData/stubs/ClassObject.kt new file mode 100644 index 00000000000..eb2dd4b3b11 --- /dev/null +++ b/idea/testData/stubs/ClassObject.kt @@ -0,0 +1,5 @@ +class C { class object { + fun foo() { + } +} +} \ No newline at end of file diff --git a/idea/testData/stubs/ClassProperty.expected b/idea/testData/stubs/ClassProperty.expected new file mode 100644 index 00000000000..0e67e76cfdd --- /dev/null +++ b/idea/testData/stubs/ClassProperty.expected @@ -0,0 +1,4 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=More fqn=More superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=Int bodyText=11] diff --git a/idea/testData/stubs/ClassProperty.kt b/idea/testData/stubs/ClassProperty.kt new file mode 100644 index 00000000000..707dc6d02be --- /dev/null +++ b/idea/testData/stubs/ClassProperty.kt @@ -0,0 +1,3 @@ +class More { + private val test: Int = 11 +} \ No newline at end of file diff --git a/idea/testData/stubs/ClassTypeParameters.expected b/idea/testData/stubs/ClassTypeParameters.expected new file mode 100644 index 00000000000..dfc9f4e0c79 --- /dev/null +++ b/idea/testData/stubs/ClassTypeParameters.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]] + TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl + TYPE_PARAMETER:PsiJetTypeParameterStubImpl[name=T extendText=null] + CLASS_BODY:PsiJetClassBodyStubImpl diff --git a/idea/testData/stubs/ClassTypeParameters.kt b/idea/testData/stubs/ClassTypeParameters.kt new file mode 100644 index 00000000000..c5dd46faa10 --- /dev/null +++ b/idea/testData/stubs/ClassTypeParameters.kt @@ -0,0 +1,2 @@ +class C { +} \ No newline at end of file diff --git a/idea/testData/stubs/FilePackage.expected b/idea/testData/stubs/FilePackage.expected new file mode 100644 index 00000000000..521cfeefc45 --- /dev/null +++ b/idea/testData/stubs/FilePackage.expected @@ -0,0 +1 @@ +PsiJetFileStubImpl[package=some.test] diff --git a/idea/testData/stubs/FilePackage.kt b/idea/testData/stubs/FilePackage.kt new file mode 100644 index 00000000000..dbfdc4dabdb --- /dev/null +++ b/idea/testData/stubs/FilePackage.kt @@ -0,0 +1 @@ +package some.test \ No newline at end of file diff --git a/idea/testData/stubs/FunctionInNotNamedObject.expected b/idea/testData/stubs/FunctionInNotNamedObject.expected new file mode 100644 index 00000000000..9cc46f04032 --- /dev/null +++ b/idea/testData/stubs/FunctionInNotNamedObject.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=null fqName=null superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + FUN:PsiJetFunctionStubImpl[name=testing] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/FunctionInNotNamedObject.kt b/idea/testData/stubs/FunctionInNotNamedObject.kt new file mode 100644 index 00000000000..43dfa955505 --- /dev/null +++ b/idea/testData/stubs/FunctionInNotNamedObject.kt @@ -0,0 +1,3 @@ +object { + fun testing() = 12 +} \ No newline at end of file diff --git a/idea/testData/stubs/FunctionParameters.expected b/idea/testData/stubs/FunctionParameters.expected new file mode 100644 index 00000000000..9bbb06da036 --- /dev/null +++ b/idea/testData/stubs/FunctionParameters.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=some name=some] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl + VALUE_PARAMETER:PsiJetParameterStubImpl[val name=t typeText=Int defaultValue=null] + VALUE_PARAMETER:PsiJetParameterStubImpl[val name=other typeText=String defaultValue="hello"] diff --git a/idea/testData/stubs/FunctionParameters.kt b/idea/testData/stubs/FunctionParameters.kt new file mode 100644 index 00000000000..e4f5c415c88 --- /dev/null +++ b/idea/testData/stubs/FunctionParameters.kt @@ -0,0 +1,2 @@ +fun some(t: Int, other: String = "hello") { +} \ No newline at end of file diff --git a/idea/testData/stubs/InnerClass.expected b/idea/testData/stubs/InnerClass.expected new file mode 100644 index 00000000000..62164c068b5 --- /dev/null +++ b/idea/testData/stubs/InnerClass.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + CLASS:PsiJetClassStubImpl[inner name=B fqn=A.B superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl diff --git a/idea/testData/stubs/InnerClass.kt b/idea/testData/stubs/InnerClass.kt new file mode 100644 index 00000000000..08edaabd4ff --- /dev/null +++ b/idea/testData/stubs/InnerClass.kt @@ -0,0 +1,3 @@ +class A { inner class B { +} +} \ No newline at end of file diff --git a/idea/testData/stubs/LocalClass.expected b/idea/testData/stubs/LocalClass.expected new file mode 100644 index 00000000000..8db9d5f72de --- /dev/null +++ b/idea/testData/stubs/LocalClass.expected @@ -0,0 +1,6 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl + CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]] diff --git a/idea/testData/stubs/LocalClass.kt b/idea/testData/stubs/LocalClass.kt new file mode 100644 index 00000000000..9f03c5411fc --- /dev/null +++ b/idea/testData/stubs/LocalClass.kt @@ -0,0 +1,5 @@ +class A +trait T +fun foo() { + class Test : A(), T +} \ No newline at end of file diff --git a/idea/testData/stubs/LocalClassInLocalFunction.expected b/idea/testData/stubs/LocalClassInLocalFunction.expected new file mode 100644 index 00000000000..8db9d5f72de --- /dev/null +++ b/idea/testData/stubs/LocalClassInLocalFunction.expected @@ -0,0 +1,6 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl + CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]] diff --git a/idea/testData/stubs/LocalClassInLocalFunction.kt b/idea/testData/stubs/LocalClassInLocalFunction.kt new file mode 100644 index 00000000000..ccccbd6c6e7 --- /dev/null +++ b/idea/testData/stubs/LocalClassInLocalFunction.kt @@ -0,0 +1,7 @@ +class A +trait T +fun foo() { + fun bar() { + class Test : A(), T + } +} \ No newline at end of file diff --git a/idea/testData/stubs/LocalNamedObject.expected b/idea/testData/stubs/LocalNamedObject.expected new file mode 100644 index 00000000000..57fa824514d --- /dev/null +++ b/idea/testData/stubs/LocalNamedObject.expected @@ -0,0 +1,6 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl + OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=O fqName=null superNames=[AT]] diff --git a/idea/testData/stubs/LocalNamedObject.kt b/idea/testData/stubs/LocalNamedObject.kt new file mode 100644 index 00000000000..1c517b16917 --- /dev/null +++ b/idea/testData/stubs/LocalNamedObject.kt @@ -0,0 +1,5 @@ +class A +trait T +fun foo() { + object O: A(), T +} \ No newline at end of file diff --git a/idea/testData/stubs/ManyAnnotationsOnFunction.expected b/idea/testData/stubs/ManyAnnotationsOnFunction.expected new file mode 100644 index 00000000000..cae0adc9306 --- /dev/null +++ b/idea/testData/stubs/ManyAnnotationsOnFunction.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated] + ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Override] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/ManyAnnotationsOnFunction.kt b/idea/testData/stubs/ManyAnnotationsOnFunction.kt new file mode 100644 index 00000000000..4ed010ec40e --- /dev/null +++ b/idea/testData/stubs/ManyAnnotationsOnFunction.kt @@ -0,0 +1,2 @@ +[Deprecated Override] fun foo() { +} \ No newline at end of file diff --git a/idea/testData/stubs/NamedObject.expected b/idea/testData/stubs/NamedObject.expected new file mode 100644 index 00000000000..d8d2c3acade --- /dev/null +++ b/idea/testData/stubs/NamedObject.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]] + CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]] + OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=Test fqName=Test superNames=[AT]] + CLASS_BODY:PsiJetClassBodyStubImpl diff --git a/idea/testData/stubs/NamedObject.kt b/idea/testData/stubs/NamedObject.kt new file mode 100644 index 00000000000..0f328838ce5 --- /dev/null +++ b/idea/testData/stubs/NamedObject.kt @@ -0,0 +1,4 @@ +class A +trait T +object Test: A(), T { +} \ No newline at end of file diff --git a/idea/testData/stubs/NotStorePropertiesFrom.expected b/idea/testData/stubs/NotStorePropertiesFrom.expected new file mode 100644 index 00000000000..1402f800356 --- /dev/null +++ b/idea/testData/stubs/NotStorePropertiesFrom.expected @@ -0,0 +1,7 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl + CLASS_BODY:PsiJetClassBodyStubImpl + PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12] + FUN:PsiJetFunctionStubImpl[name=more] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/NotStorePropertiesFrom.kt b/idea/testData/stubs/NotStorePropertiesFrom.kt new file mode 100644 index 00000000000..16f855b3625 --- /dev/null +++ b/idea/testData/stubs/NotStorePropertiesFrom.kt @@ -0,0 +1,9 @@ +class Test() { + val test = 12; + { + for (i in 0..12) { + } + } + fun more() { + } +} diff --git a/idea/testData/stubs/NotStorePropertyFromDelegate.expected b/idea/testData/stubs/NotStorePropertyFromDelegate.expected new file mode 100644 index 00000000000..ccc75a5af15 --- /dev/null +++ b/idea/testData/stubs/NotStorePropertyFromDelegate.expected @@ -0,0 +1,2 @@ +PsiJetFileStubImpl[package=] + PROPERTY:PsiJetPropertyStubImpl[val top fqName=a name=a typeText=null bodyText=null] diff --git a/idea/testData/stubs/NotStorePropertyFromDelegate.kt b/idea/testData/stubs/NotStorePropertyFromDelegate.kt new file mode 100644 index 00000000000..7b10f41971b --- /dev/null +++ b/idea/testData/stubs/NotStorePropertyFromDelegate.kt @@ -0,0 +1,2 @@ +val a by kotlin. //intentional parser error +val b = 1 \ No newline at end of file diff --git a/idea/testData/stubs/NotStorePropertyFromInitializer.expected b/idea/testData/stubs/NotStorePropertyFromInitializer.expected new file mode 100644 index 00000000000..9399f90088b --- /dev/null +++ b/idea/testData/stubs/NotStorePropertyFromInitializer.expected @@ -0,0 +1,3 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=some ext name=some] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/NotStorePropertyFromInitializer.kt b/idea/testData/stubs/NotStorePropertyFromInitializer.kt new file mode 100644 index 00000000000..a0dff2255c2 --- /dev/null +++ b/idea/testData/stubs/NotStorePropertyFromInitializer.kt @@ -0,0 +1 @@ +fun DoubleArray.some() = for (element in this) println(element) \ No newline at end of file diff --git a/idea/testData/stubs/PackageProperty.expected b/idea/testData/stubs/PackageProperty.expected new file mode 100644 index 00000000000..941db7a6b0f --- /dev/null +++ b/idea/testData/stubs/PackageProperty.expected @@ -0,0 +1,2 @@ +PsiJetFileStubImpl[package=test.testing] + PROPERTY:PsiJetPropertyStubImpl[val top fqName=test.testing.some name=some typeText=null bodyText=12] diff --git a/idea/testData/stubs/PackageProperty.kt b/idea/testData/stubs/PackageProperty.kt new file mode 100644 index 00000000000..aa3169cdf3a --- /dev/null +++ b/idea/testData/stubs/PackageProperty.kt @@ -0,0 +1,3 @@ +package test.testing + +val some = 12 \ No newline at end of file diff --git a/idea/testData/stubs/QualifiedAnnotationOnFunction.expected b/idea/testData/stubs/QualifiedAnnotationOnFunction.expected new file mode 100644 index 00000000000..fa932fa9ef1 --- /dev/null +++ b/idea/testData/stubs/QualifiedAnnotationOnFunction.expected @@ -0,0 +1,4 @@ +PsiJetFileStubImpl[package=] + FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo] + ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated] + VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl diff --git a/idea/testData/stubs/QualifiedAnnotationOnFunction.kt b/idea/testData/stubs/QualifiedAnnotationOnFunction.kt new file mode 100644 index 00000000000..4f6d6e65478 --- /dev/null +++ b/idea/testData/stubs/QualifiedAnnotationOnFunction.kt @@ -0,0 +1,2 @@ +java.lang.Deprecated fun foo() { +} \ No newline at end of file diff --git a/idea/testData/stubs/SimpleEnumBuild.expected b/idea/testData/stubs/SimpleEnumBuild.expected new file mode 100644 index 00000000000..c126e12d911 --- /dev/null +++ b/idea/testData/stubs/SimpleEnumBuild.expected @@ -0,0 +1,5 @@ +PsiJetFileStubImpl[package=] + CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]] + CLASS_BODY:PsiJetClassBodyStubImpl + ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]] + ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]] diff --git a/idea/testData/stubs/SimpleEnumBuild.kt b/idea/testData/stubs/SimpleEnumBuild.kt new file mode 100644 index 00000000000..8e7dfdde280 --- /dev/null +++ b/idea/testData/stubs/SimpleEnumBuild.kt @@ -0,0 +1,4 @@ +enum class Test { + First + Second +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/AbstractStubBuilderTest.java b/idea/tests/org/jetbrains/jet/plugin/stubs/AbstractStubBuilderTest.java new file mode 100644 index 00000000000..a54426d871c --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/AbstractStubBuilderTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.stubs; + +import com.intellij.lang.FileASTNode; +import com.intellij.psi.impl.DebugUtil; +import com.intellij.psi.stubs.StubElement; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.psi.stubs.elements.JetFileStubBuilder; + +import java.io.File; + +public abstract class AbstractStubBuilderTest extends LightCodeInsightFixtureTestCase { + protected void doTest(@NotNull String sourcePath) { + JetFile file = (JetFile) myFixture.configureByFile(sourcePath); + JetFileStubBuilder jetStubBuilder = new JetFileStubBuilder(); + StubElement lighterTree = jetStubBuilder.buildStubTree(file); + String stubTree = DebugUtil.stubTreeToString(lighterTree); + String expectedFile = sourcePath.replace(".kt", ".expected"); + JetTestUtils.assertEqualsToFile(new File(expectedFile), stubTree); + } +} diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java index 86ad031b279..99c348929d2 100644 --- a/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/JetStubsTest.java @@ -16,21 +16,15 @@ package org.jetbrains.jet.plugin.stubs; -import com.intellij.lang.FileASTNode; import com.intellij.psi.PsiFile; -import com.intellij.psi.impl.DebugUtil; -import com.intellij.psi.stubs.StubElement; import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetClass; import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.stubs.PsiJetClassStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetFileStubBuilder; import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.JetLightProjectDescriptor; import java.util.List; @@ -58,224 +52,4 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase { PsiJetClassStub stub = JetStubElementTypes.CLASS.createStub(jetClass, null); assertEquals(true, stub.isTrait()); } - - public void testFilePackage() { - doBuildTest("package some.test", - "PsiJetFileStubImpl[package=some.test]\n"); - } - - public void testClassTypeParameters() { - doBuildTest("class C { }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" + - " TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl\n" + - " TYPE_PARAMETER:PsiJetTypeParameterStubImpl[name=T extendText=null]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n"); - } - - public void testClassObject() { - doBuildTest("class C { class object { fun foo() {} }}", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " FUN:PsiJetFunctionStubImpl[name=foo]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testFunctionInNotNamedObject() { - doBuildTest("object { fun testing() = 12 }", - "PsiJetFileStubImpl[package=]\n" + - " OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=null fqName=null superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " FUN:PsiJetFunctionStubImpl[name=testing]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testFunctionParameters() { - doBuildTest("fun some(t: Int, other: String = \"hello\") { }", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=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"); - } - - public void testPackageProperty() { - doBuildTest("package test.testing\n" + - "val some = 12", - "PsiJetFileStubImpl[package=test.testing]\n" + - " PROPERTY:PsiJetPropertyStubImpl[val top fqName=test.testing.some name=some typeText=null bodyText=12]\n"); - } - - public void testClassProperty() { - doBuildTest("class More { \n" + - " private val test : Int = 11\n" + - "}", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=More fqn=More superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=Int bodyText=11]\n"); - } - - public void testNotStorePropertyFromInitializer() { - doBuildTest("fun DoubleArray.some() = for (element in this) println(element)", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=some ext name=some]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testNotStorePropertyFromDelegate() { - doBuildTest("val a by kotlin.\n val b = 1", - "PsiJetFileStubImpl[package=]\n" + - " PROPERTY:PsiJetPropertyStubImpl[val top fqName=a name=a typeText=null bodyText=null]\n"); - } - - public void testNotStorePropertiesFrom() { - doBuildTest("class Test() {\n" + - " val test = 12;\n" + - " {\n" + - " for (i in 0..12) {\n" + - " }\n" + - " }\n" + - " fun more() {\n" + - " }\n" + - "}\n", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12]\n" + - " FUN:PsiJetFunctionStubImpl[name=more]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testSimpleEnumBuild() { - doBuildTest("enum class Test { First\n Second\n }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]]\n" + - " ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]]\n"); - } - - public void testAnnotationClass() { - doBuildTest("annotation class Test", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[isAnnotation name=Test fqn=Test superNames=[]]\n"); - } - - public void testInnerClass() { - doBuildTest("class A { inner class B { } }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n" + - " CLASS:PsiJetClassStubImpl[inner name=B fqn=A.B superNames=[]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n"); - } - - public void testLocalClass() { - doBuildTest("class A\ntrait T\nfun foo() { class Test: A(), T }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" + - " CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]]\n"); - } - - public void testLocalClassInLocalFunction() { - doBuildTest("class A\ntrait T\nfun foo() { fun bar() { class Test: A(), T } }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" + - " CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]]\n"); - } - - public void testNamedObject() { - doBuildTest("class A\ntrait T\nobject Test: A(), T {}", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" + - " OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=Test fqName=Test superNames=[AT]]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n"); - } - - public void testLocalNamedObject() { - doBuildTest("class A\ntrait T\nfun foo() { object O: A(), T }", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" + - " OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=O fqName=null superNames=[AT]]\n"); - } - - public void testAnonymousObject() { - doBuildTest("class A\ntrait T\nval obj = object : A(), T", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" + - " CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" + - " PROPERTY:PsiJetPropertyStubImpl[val top fqName=obj name=obj typeText=null bodyText=object : A(), T]\n" + - " OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=null fqName=null superNames=[AT]]\n"); - } - - public void testAnnotationOnClass() { - doBuildTest("Deprecated class Test {}", - "PsiJetFileStubImpl[package=]\n" + - " CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + - " CLASS_BODY:PsiJetClassBodyStubImpl\n"); - } - - public void testAnnotationOnFunction() { - doBuildTest("Deprecated fun foo() {}", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testQualifiedAnnotationOnFunction() { - doBuildTest("java.lang.Deprecated fun foo() {}", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testManyAnnotationsOnFunction() { - doBuildTest("[Deprecated Override] fun foo() {}", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" + - " ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Override]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - public void testAnnotationOnLocalFunction() { - doBuildTest("fun foo() { [Deprecated] fun innerFoo() {} }", - "PsiJetFileStubImpl[package=]\n" + - " FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" + - " VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n"); - } - - private void doBuildTest(@NonNls String source, @NonNls @NotNull String tree) { - JetFile file = (JetFile) createLightFile(JetFileType.INSTANCE, source); - FileASTNode fileNode = file.getNode(); - assertNotNull(fileNode); - // assertFalse(fileNode.isParsed()); // TODO - - JetFileStubBuilder jetStubBuilder = new JetFileStubBuilder(); - - StubElement lighterTree = jetStubBuilder.buildStubTree(file); - // assertFalse(fileNode.isParsed()); // TODO - - String lightStr = DebugUtil.stubTreeToString(lighterTree); - - assertEquals("light tree differs", tree, lightStr); - } } diff --git a/idea/tests/org/jetbrains/jet/plugin/stubs/StubBuilderTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/stubs/StubBuilderTestGenerated.java new file mode 100644 index 00000000000..fda6280078b --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/stubs/StubBuilderTestGenerated.java @@ -0,0 +1,154 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.stubs; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.plugin.stubs.AbstractStubBuilderTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/stubs") +public class StubBuilderTestGenerated extends AbstractStubBuilderTest { + public void testAllFilesPresentInStubs() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/stubs"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("AnnotationClass.kt") + public void testAnnotationClass() throws Exception { + doTest("idea/testData/stubs/AnnotationClass.kt"); + } + + @TestMetadata("AnnotationOnClass.kt") + public void testAnnotationOnClass() throws Exception { + doTest("idea/testData/stubs/AnnotationOnClass.kt"); + } + + @TestMetadata("AnnotationOnFunction.kt") + public void testAnnotationOnFunction() throws Exception { + doTest("idea/testData/stubs/AnnotationOnFunction.kt"); + } + + @TestMetadata("AnnotationOnLocalFunction.kt") + public void testAnnotationOnLocalFunction() throws Exception { + doTest("idea/testData/stubs/AnnotationOnLocalFunction.kt"); + } + + @TestMetadata("AnonymousObject.kt") + public void testAnonymousObject() throws Exception { + doTest("idea/testData/stubs/AnonymousObject.kt"); + } + + @TestMetadata("ClassObject.kt") + public void testClassObject() throws Exception { + doTest("idea/testData/stubs/ClassObject.kt"); + } + + @TestMetadata("ClassProperty.kt") + public void testClassProperty() throws Exception { + doTest("idea/testData/stubs/ClassProperty.kt"); + } + + @TestMetadata("ClassTypeParameters.kt") + public void testClassTypeParameters() throws Exception { + doTest("idea/testData/stubs/ClassTypeParameters.kt"); + } + + @TestMetadata("FilePackage.kt") + public void testFilePackage() throws Exception { + doTest("idea/testData/stubs/FilePackage.kt"); + } + + @TestMetadata("FunctionInNotNamedObject.kt") + public void testFunctionInNotNamedObject() throws Exception { + doTest("idea/testData/stubs/FunctionInNotNamedObject.kt"); + } + + @TestMetadata("FunctionParameters.kt") + public void testFunctionParameters() throws Exception { + doTest("idea/testData/stubs/FunctionParameters.kt"); + } + + @TestMetadata("InnerClass.kt") + public void testInnerClass() throws Exception { + doTest("idea/testData/stubs/InnerClass.kt"); + } + + @TestMetadata("LocalClass.kt") + public void testLocalClass() throws Exception { + doTest("idea/testData/stubs/LocalClass.kt"); + } + + @TestMetadata("LocalClassInLocalFunction.kt") + public void testLocalClassInLocalFunction() throws Exception { + doTest("idea/testData/stubs/LocalClassInLocalFunction.kt"); + } + + @TestMetadata("LocalNamedObject.kt") + public void testLocalNamedObject() throws Exception { + doTest("idea/testData/stubs/LocalNamedObject.kt"); + } + + @TestMetadata("ManyAnnotationsOnFunction.kt") + public void testManyAnnotationsOnFunction() throws Exception { + doTest("idea/testData/stubs/ManyAnnotationsOnFunction.kt"); + } + + @TestMetadata("NamedObject.kt") + public void testNamedObject() throws Exception { + doTest("idea/testData/stubs/NamedObject.kt"); + } + + @TestMetadata("NotStorePropertiesFrom.kt") + public void testNotStorePropertiesFrom() throws Exception { + doTest("idea/testData/stubs/NotStorePropertiesFrom.kt"); + } + + @TestMetadata("NotStorePropertyFromDelegate.kt") + public void testNotStorePropertyFromDelegate() throws Exception { + doTest("idea/testData/stubs/NotStorePropertyFromDelegate.kt"); + } + + @TestMetadata("NotStorePropertyFromInitializer.kt") + public void testNotStorePropertyFromInitializer() throws Exception { + doTest("idea/testData/stubs/NotStorePropertyFromInitializer.kt"); + } + + @TestMetadata("PackageProperty.kt") + public void testPackageProperty() throws Exception { + doTest("idea/testData/stubs/PackageProperty.kt"); + } + + @TestMetadata("QualifiedAnnotationOnFunction.kt") + public void testQualifiedAnnotationOnFunction() throws Exception { + doTest("idea/testData/stubs/QualifiedAnnotationOnFunction.kt"); + } + + @TestMetadata("SimpleEnumBuild.kt") + public void testSimpleEnumBuild() throws Exception { + doTest("idea/testData/stubs/SimpleEnumBuild.kt"); + } + +}