mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
convert some groovy tests to java to reduce the number of chunks with expensive groovy compiler
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
<orderEntry type="library" name="ASM" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.compiler.instrumentationUtil" />
|
||||
<orderEntry type="module" module-name="intellij.java.ui" />
|
||||
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.spellchecker" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.model.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testExtensions" scope="TEST" />
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.intellij.compiler
|
||||
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.ContentEntry
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
class ResourcePatternsTest extends LightCodeInsightFixtureTestCase {
|
||||
String[] oldPatterns
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
contentEntry.sourceFolders.each { contentEntry.removeSourceFolder(it) }
|
||||
contentEntry.addSourceFolder(contentEntry.getFile().createChildDirectory(this, "aaa").createChildDirectory(this, "bbb"), false)
|
||||
super.configureModule(module, model, contentEntry)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
super.setUp()
|
||||
oldPatterns = conf.resourceFilePatterns
|
||||
conf.removeResourceFilePatterns()
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
conf.removeResourceFilePatterns()
|
||||
oldPatterns.each { conf.addResourceFilePattern(it) }
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
void testFilePattern() {
|
||||
conf.addResourceFilePattern('*.ttt')
|
||||
|
||||
assert conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
assert !conf.isResourceFile(createFile('foo/bar.xxx'))
|
||||
}
|
||||
|
||||
void testWildcards() {
|
||||
conf.addResourceFilePattern('*.t?t')
|
||||
assert conf.isResourceFile(createFile('foo/bar.txt'))
|
||||
assert conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
assert conf.isResourceFile(createFile('foo/bar.tyt'))
|
||||
assert !conf.isResourceFile(createFile('foo/bar.xml'))
|
||||
}
|
||||
|
||||
void testDirectory() {
|
||||
conf.addResourceFilePattern('*/foo/*')
|
||||
assert conf.isResourceFile(createFile('goo/foo/bar.ttt'))
|
||||
assert !conf.isResourceFile(createFile('goo/foo.zzz'))
|
||||
assert !conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
}
|
||||
|
||||
void testRootDirectory() {
|
||||
conf.addResourceFilePattern('foo/*')
|
||||
assert !conf.isResourceFile(createFile('goo/foo/bar.ttt'))
|
||||
assert !conf.isResourceFile(createFile('goo/foo.zzz'))
|
||||
assert !conf.isResourceFile(createFile('goo/foo/zzz'))
|
||||
assert conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
}
|
||||
|
||||
void testDoubleAsterisk() {
|
||||
conf.addResourceFilePattern('**/foo/*')
|
||||
assert conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
assert conf.isResourceFile(createFile('goo/foo/bar.ttt'))
|
||||
assert !conf.isResourceFile(createFile('goo/foo.zzz'))
|
||||
assert conf.isResourceFile(createFile('goo/foo/zzz'))
|
||||
}
|
||||
|
||||
void testResourceRoot() {
|
||||
conf.addResourceFilePattern('bbb:*.ttt')
|
||||
|
||||
assert conf.isResourceFile(createFile('foo/bar.ttt'))
|
||||
assert !conf.isResourceFile(createFile('foo/bar.xxx'))
|
||||
assert !conf.isResourceFile(myFixture.addFileToProject("aaa/ccc/xxx.ttt", '').virtualFile)
|
||||
}
|
||||
|
||||
private VirtualFile createFile(String path) {
|
||||
return myFixture.addFileToProject("aaa/bbb/" + path, '').virtualFile
|
||||
}
|
||||
|
||||
private CompilerConfigurationImpl getConf() {
|
||||
return CompilerConfiguration.getInstance(project)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.intellij.compiler;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class ResourcePatternsTest extends LightCodeInsightFixtureTestCase {
|
||||
private String[] oldPatterns;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
try {
|
||||
contentEntry.clearSourceFolders();
|
||||
VirtualFile aaaBbb = contentEntry.getFile()
|
||||
.createChildDirectory(this, "aaa")
|
||||
.createChildDirectory(this, "bbb");
|
||||
contentEntry.addSourceFolder(aaaBbb, false);
|
||||
super.configureModule(module, model, contentEntry);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
oldPatterns = getConf().getResourceFilePatterns();
|
||||
getConf().removeResourceFilePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
getConf().removeResourceFilePatterns();
|
||||
for (String pattern : oldPatterns) {
|
||||
getConf().addResourceFilePattern(pattern);
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
addSuppressedException(e);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void testFilePattern() {
|
||||
getConf().addResourceFilePattern("*.ttt");
|
||||
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("foo/bar.xxx")));
|
||||
}
|
||||
|
||||
public void testWildcards() {
|
||||
getConf().addResourceFilePattern("*.t?t");
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.txt")));
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.tyt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("foo/bar.xml")));
|
||||
}
|
||||
|
||||
public void testDirectory() {
|
||||
getConf().addResourceFilePattern("*/foo/*");
|
||||
assertTrue(getConf().isResourceFile(createFile("goo/foo/bar.ttt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("goo/foo.zzz")));
|
||||
assertFalse(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
}
|
||||
|
||||
public void testRootDirectory() {
|
||||
getConf().addResourceFilePattern("foo/*");
|
||||
assertFalse(getConf().isResourceFile(createFile("goo/foo/bar.ttt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("goo/foo.zzz")));
|
||||
assertFalse(getConf().isResourceFile(createFile("goo/foo/zzz")));
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
}
|
||||
|
||||
public void testDoubleAsterisk() {
|
||||
getConf().addResourceFilePattern("**/foo/*");
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
assertTrue(getConf().isResourceFile(createFile("goo/foo/bar.ttt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("goo/foo.zzz")));
|
||||
assertTrue(getConf().isResourceFile(createFile("goo/foo/zzz")));
|
||||
}
|
||||
|
||||
public void testResourceRoot() {
|
||||
getConf().addResourceFilePattern("bbb:*.ttt");
|
||||
|
||||
assertTrue(getConf().isResourceFile(createFile("foo/bar.ttt")));
|
||||
assertFalse(getConf().isResourceFile(createFile("foo/bar.xxx")));
|
||||
assertFalse(getConf().isResourceFile(myFixture.addFileToProject("aaa/ccc/xxx.ttt", "").getVirtualFile()));
|
||||
}
|
||||
|
||||
private VirtualFile createFile(String path) {
|
||||
return myFixture.addFileToProject("aaa/bbb/" + path, "").getVirtualFile();
|
||||
}
|
||||
|
||||
private CompilerConfigurationImpl getConf() {
|
||||
return ((CompilerConfigurationImpl)(CompilerConfiguration.getInstance(getProject())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
<orderEntry type="module" module-name="intellij.java.compiler.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.impl" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.java.execution.impl" exported="" scope="RUNTIME" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.relaxng" exported="" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.ui" exported="" />
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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 com.intellij.codeInsight
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
|
||||
import com.intellij.codeInsight.template.impl.TemplateState
|
||||
import com.intellij.refactoring.typeMigration.intentions.ChangeClassParametersIntention
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
/**
|
||||
* User: anna
|
||||
*/
|
||||
class ChangeClassParametersTest extends LightCodeInsightFixtureTestCase {
|
||||
void "test nested type elements"() {
|
||||
def text = """\
|
||||
interface Fun<A, B> {}
|
||||
class Test {
|
||||
{
|
||||
new Fun<java.util.List<Int<caret>eger>, String> () {};
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
doTest(text)
|
||||
}
|
||||
|
||||
private doTest(String text) {
|
||||
myFixture.configureByText("a.java", text)
|
||||
try {
|
||||
myFixture.doHighlighting()
|
||||
myFixture.launchAction(new ChangeClassParametersIntention())
|
||||
}
|
||||
finally {
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(editor)
|
||||
assertNull(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.refactoring.typeMigration.intentions.ChangeClassParametersIntention;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
*/
|
||||
public class ChangeClassParametersTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testNestedTypeElements() {
|
||||
String text = "interface Fun<A, B> {}\n" +
|
||||
"class Test {\n" +
|
||||
" {\n" +
|
||||
" new Fun<java.util.List<Int<caret>eger>, String> () {};\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
myFixture.configureByText("a.java", text);
|
||||
myFixture.doHighlighting();
|
||||
myFixture.launchAction(new ChangeClassParametersIntention());
|
||||
assertNull(TemplateManagerImpl.getTemplateState(getEditor()));
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@
|
||||
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.xml.dom.impl" scope="RUNTIME" />
|
||||
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
|
||||
<orderEntry type="library" name="NanoXML" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.intellij.lang.xpath
|
||||
|
||||
class XPath2CompletionTest extends TestBase {
|
||||
|
||||
void testCastInsert() throws Throwable {
|
||||
TestNamespaceContext.install(myFixture.getTestRootDisposable())
|
||||
configure()
|
||||
assert myFixture.lookupElementStrings.containsAll("xs:anyAtomicType", "xs:untypedAtomic", "xs:anyURI")
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
final String name = getTestFileName()
|
||||
myFixture.configureByFile(name + ".xpath2")
|
||||
myFixture.completeBasic()
|
||||
}
|
||||
|
||||
void testTreatInsert() throws Throwable {
|
||||
configure()
|
||||
myFixture.type('\n')
|
||||
myFixture.checkResultByFile(getTestFileName() + "_after.xpath2")
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubPath() {
|
||||
return "xpath2/completion"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.intellij.lang.xpath;
|
||||
|
||||
public class XPath2CompletionTest extends TestBase {
|
||||
public void testCastInsert() {
|
||||
TestNamespaceContext.install(myFixture.getTestRootDisposable());
|
||||
configure();
|
||||
assertContainsElements(myFixture.getLookupElementStrings(), "xs:anyAtomicType", "xs:untypedAtomic", "xs:anyURI");
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
myFixture.configureByFile(getTestFileName() + ".xpath2");
|
||||
myFixture.completeBasic();
|
||||
}
|
||||
|
||||
public void testTreatInsert() {
|
||||
configure();
|
||||
myFixture.type("\n");
|
||||
myFixture.checkResultByFile(getTestFileName() + "_after.xpath2");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubPath() {
|
||||
return "xpath2/completion";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user