Refactor: use generated approach for stubs test
Remove meaningless assertion Add comment to NotStorePropertyFromDelegate test
This commit is contained in:
@@ -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<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
@@ -529,6 +530,10 @@ fun main(args: Array<String>) {
|
||||
testClass(javaClass<AbstractSmartStepIntoTest>()) {
|
||||
model("debugger/smartStepInto")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractStubBuilderTest>()) {
|
||||
model("stubs", extension = "kt")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("j2k/tests/test", "j2k/tests/testData") {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
CLASS:PsiJetClassStubImpl[isAnnotation name=Test fqn=Test superNames=[]]
|
||||
@@ -0,0 +1 @@
|
||||
annotation class Test
|
||||
@@ -0,0 +1,4 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]
|
||||
ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]
|
||||
CLASS_BODY:PsiJetClassBodyStubImpl
|
||||
@@ -0,0 +1,2 @@
|
||||
Deprecated class Test {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]
|
||||
ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]
|
||||
VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl
|
||||
@@ -0,0 +1,2 @@
|
||||
Deprecated fun foo() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]
|
||||
VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
[Deprecated] fun innerFoo() {
|
||||
}
|
||||
}
|
||||
@@ -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]]
|
||||
@@ -0,0 +1,3 @@
|
||||
class A
|
||||
trait T
|
||||
val obj = object : A(), T
|
||||
@@ -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
|
||||
@@ -0,0 +1,5 @@
|
||||
class C { class object {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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]
|
||||
@@ -0,0 +1,3 @@
|
||||
class More {
|
||||
private val test: Int = 11
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
class C<T> {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
PsiJetFileStubImpl[package=some.test]
|
||||
@@ -0,0 +1 @@
|
||||
package some.test
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
object {
|
||||
fun testing() = 12
|
||||
}
|
||||
@@ -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"]
|
||||
@@ -0,0 +1,2 @@
|
||||
fun some(t: Int, other: String = "hello") {
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
class A { inner class B {
|
||||
}
|
||||
}
|
||||
@@ -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]]
|
||||
@@ -0,0 +1,5 @@
|
||||
class A
|
||||
trait T
|
||||
fun foo() {
|
||||
class Test : A(), T
|
||||
}
|
||||
@@ -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]]
|
||||
@@ -0,0 +1,7 @@
|
||||
class A
|
||||
trait T
|
||||
fun foo() {
|
||||
fun bar() {
|
||||
class Test : A(), T
|
||||
}
|
||||
}
|
||||
@@ -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]]
|
||||
@@ -0,0 +1,5 @@
|
||||
class A
|
||||
trait T
|
||||
fun foo() {
|
||||
object O: A(), T
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
[Deprecated Override] fun foo() {
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
class A
|
||||
trait T
|
||||
object Test: A(), T {
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test() {
|
||||
val test = 12;
|
||||
{
|
||||
for (i in 0..12) {
|
||||
}
|
||||
}
|
||||
fun more() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
PROPERTY:PsiJetPropertyStubImpl[val top fqName=a name=a typeText=null bodyText=null]
|
||||
@@ -0,0 +1,2 @@
|
||||
val a by kotlin. //intentional parser error
|
||||
val b = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
FUN:PsiJetFunctionStubImpl[top fqName=some ext name=some]
|
||||
VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl
|
||||
@@ -0,0 +1 @@
|
||||
fun DoubleArray.some() = for (element in this) println(element)
|
||||
@@ -0,0 +1,2 @@
|
||||
PsiJetFileStubImpl[package=test.testing]
|
||||
PROPERTY:PsiJetPropertyStubImpl[val top fqName=test.testing.some name=some typeText=null bodyText=12]
|
||||
@@ -0,0 +1,3 @@
|
||||
package test.testing
|
||||
|
||||
val some = 12
|
||||
@@ -0,0 +1,4 @@
|
||||
PsiJetFileStubImpl[package=]
|
||||
FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]
|
||||
ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]
|
||||
VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl
|
||||
@@ -0,0 +1,2 @@
|
||||
java.lang.Deprecated fun foo() {
|
||||
}
|
||||
@@ -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=[]]
|
||||
@@ -0,0 +1,4 @@
|
||||
enum class Test {
|
||||
First
|
||||
Second
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<T> { }",
|
||||
"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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user