Tests for additional lazy resolve (local classes/objects in class initializers)
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.resolve;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetClassInitializer;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveDescriptorRendererTest;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.jet.plugin.project.ResolveElementCache;
|
||||
|
||||
public abstract class AbstractAdditionalLazyResolveDescriptorRendererTest extends AbstractLazyResolveDescriptorRendererTest {
|
||||
@Override
|
||||
protected DeclarationDescriptor getDescriptor(JetDeclaration declaration, ResolveSession resolveSession) {
|
||||
if (declaration instanceof JetClassInitializer || JetPsiUtil.isLocal(declaration)) {
|
||||
ResolveElementCache resolveElementCache = new ResolveElementCache(resolveSession, getProject());
|
||||
return resolveElementCache.resolveToElement(declaration).get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||
}
|
||||
return resolveSession.resolveToDescriptor(declaration);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.resolve;
|
||||
|
||||
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.resolve.AbstractAdditionalLazyResolveDescriptorRendererTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/resolve/additionalLazyResolve")
|
||||
public class AdditionalLazyResolveDescriptorRendererTestGenerated extends AbstractAdditionalLazyResolveDescriptorRendererTest {
|
||||
public void testAllFilesPresentInAdditionalLazyResolve() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/resolve/additionalLazyResolve"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectInClassInitializer.kt")
|
||||
public void testAnonymousObjectInClassInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/anonymousObjectInClassInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectInClassParameterInitializer.kt")
|
||||
public void testAnonymousObjectInClassParameterInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/anonymousObjectInClassParameterInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localClassInClassInitializer.kt")
|
||||
public void testLocalClassInClassInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/localClassInClassInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localClassInClosureInClassParameterInitializer.kt")
|
||||
public void testLocalClassInClosureInClassParameterInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/localClassInClosureInClassParameterInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localObjectInClassInitializer.kt")
|
||||
public void testLocalObjectInClassInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/localObjectInClassInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localObjectInClosureInClassParameterInitializer.kt")
|
||||
public void testLocalObjectInClosureInClassParameterInitializer() throws Exception {
|
||||
doTest("idea/testData/resolve/additionalLazyResolve/localObjectInClosureInClassParameterInitializer.kt");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user