mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
groovy: convert some tests in groovy support from groovy to java
GitOrigin-RevId: 1917a89ecec151695ef693f8a58a4ab812e6b9e8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3d1ffc142d
commit
8acc6bd313
@@ -0,0 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite;
|
||||
import org.jetbrains.plugins.groovy.util.SlowPolicy;
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy", policy = SlowPolicy.ALL)
|
||||
public class AllGroovyTestSuite {
|
||||
}
|
||||
@@ -1,25 +1,21 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CompileStatic
|
||||
final class CompoundTestLibrary implements TestLibrary {
|
||||
|
||||
private final TestLibrary[] myLibraries
|
||||
|
||||
CompoundTestLibrary(TestLibrary... libraries) {
|
||||
assert libraries.length > 0
|
||||
myLibraries = libraries
|
||||
public final class CompoundTestLibrary implements TestLibrary {
|
||||
public CompoundTestLibrary(TestLibrary... libraries) {
|
||||
assert libraries.length > 0;
|
||||
myLibraries = libraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
void addTo(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
||||
for (library in myLibraries) {
|
||||
library.addTo(module, model)
|
||||
public void addTo(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
||||
for (TestLibrary library : myLibraries) {
|
||||
library.addTo(module, model);
|
||||
}
|
||||
}
|
||||
|
||||
private final TestLibrary[] myLibraries;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite;
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage("org.jetbrains.plugins.groovy")
|
||||
public class FastGroovyTestSuite {
|
||||
}
|
||||
@@ -1,121 +1,119 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction
|
||||
import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.plugins.groovy.lang.formatter.GroovyFormatterTestCase
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction;
|
||||
import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.formatter.GroovyFormatterTestCase;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
class GrCommentTest extends GroovyFormatterTestCase {
|
||||
public class GrCommentTest extends GroovyFormatterTestCase {
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
TestUtils.testDataPath + 'grComment/'
|
||||
return TestUtils.getTestDataPath() + "grComment/";
|
||||
}
|
||||
|
||||
void testUncommentLine() {
|
||||
lineTest('''\
|
||||
public void testUncommentLine() {
|
||||
lineTest("""
|
||||
//<caret>print 2
|
||||
''', '''\
|
||||
""", """
|
||||
print 2
|
||||
<caret>''')
|
||||
<caret>""");
|
||||
}
|
||||
|
||||
|
||||
void testBlock0() {
|
||||
blockTest('''\
|
||||
public void testBlock0() {
|
||||
blockTest("""
|
||||
<selection>print 2</selection>
|
||||
''', '''\
|
||||
""", """
|
||||
<selection>/*print 2*/</selection>
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void testUncommentBlock0() {
|
||||
blockTest('''\
|
||||
public void testUncommentBlock0() {
|
||||
blockTest("""
|
||||
<selection>/*print 2*/</selection>
|
||||
''', '''\
|
||||
""", """
|
||||
<selection>print 2</selection>
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void testBlock1() {
|
||||
blockTest('''\
|
||||
public void testBlock1() {
|
||||
blockTest("""
|
||||
<selection>print 2
|
||||
</selection>
|
||||
''', '''\
|
||||
""", """
|
||||
<selection>/*
|
||||
print 2
|
||||
*/
|
||||
</selection>
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void testUncommentBlock1() {
|
||||
blockTest('''\
|
||||
public void testUncommentBlock1() {
|
||||
blockTest("""
|
||||
<selection>/*
|
||||
print 2
|
||||
*/
|
||||
</selection>
|
||||
''', '''\
|
||||
""", """
|
||||
<selection>print 2
|
||||
</selection>
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void 'test line comment no indent'() {
|
||||
lineTest '''\
|
||||
public void test_line_comment_no_indent() {
|
||||
lineTest("""
|
||||
def foo() {
|
||||
<caret>print 2
|
||||
}
|
||||
''', '''\
|
||||
""", """
|
||||
def foo() {
|
||||
// print 2
|
||||
}<caret>
|
||||
'''
|
||||
""");
|
||||
}
|
||||
|
||||
void 'test line comment indent'() {
|
||||
groovySettings.LINE_COMMENT_AT_FIRST_COLUMN = false
|
||||
lineTest '''\
|
||||
public void test_line_comment_indent() {
|
||||
getGroovySettings().LINE_COMMENT_AT_FIRST_COLUMN = false;
|
||||
lineTest("""
|
||||
def foo() {
|
||||
println 42<caret>
|
||||
}
|
||||
''', '''\
|
||||
""", """
|
||||
def foo() {
|
||||
//println 42
|
||||
}<caret>
|
||||
'''
|
||||
""");
|
||||
}
|
||||
|
||||
void 'test line comment indent and space'() {
|
||||
groovySettings.LINE_COMMENT_AT_FIRST_COLUMN = false
|
||||
groovySettings.LINE_COMMENT_ADD_SPACE = true
|
||||
lineTest '''\
|
||||
public void test_line_comment_indent_and_space() {
|
||||
getGroovySettings().LINE_COMMENT_AT_FIRST_COLUMN = false;
|
||||
getGroovySettings().LINE_COMMENT_ADD_SPACE = true;
|
||||
lineTest("""
|
||||
def foo() {
|
||||
println 42<caret>
|
||||
}
|
||||
''', '''\
|
||||
""", """
|
||||
def foo() {
|
||||
// println 42
|
||||
}<caret>
|
||||
'''
|
||||
""");
|
||||
}
|
||||
|
||||
void lineTest(String before, String after) {
|
||||
doTest(before, after, new CommentByLineCommentAction())
|
||||
public void lineTest(String before, String after) {
|
||||
doTest(before, after, new CommentByLineCommentAction());
|
||||
}
|
||||
|
||||
void blockTest(String before, String after) {
|
||||
doTest(before, after, new CommentByBlockCommentAction())
|
||||
public void blockTest(String before, String after) {
|
||||
doTest(before, after, new CommentByBlockCommentAction());
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String before, @NotNull String after, final AnAction action) {
|
||||
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before)
|
||||
myFixture.testAction(action)
|
||||
myFixture.checkResult(after)
|
||||
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before);
|
||||
myFixture.testAction(action);
|
||||
myFixture.checkResult(after);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +1,110 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
class GroovyActionsTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
|
||||
final String basePath = TestUtils.testDataPath + 'groovy/actions/'
|
||||
|
||||
void testSelectWordBeforeMethod() {
|
||||
doTestForSelectWord 1
|
||||
public class GroovyActionsTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
public void testSelectWordBeforeMethod() {
|
||||
doTestForSelectWord(1);
|
||||
}
|
||||
|
||||
void testSWInGString() { doTestSelectWordUpTo 5 }
|
||||
public void testSWInGString() { doTestSelectWordUpTo(5); }
|
||||
|
||||
void 'test select word in GString select line before injection'() {
|
||||
doTestForSelectWord 2, '''\
|
||||
print """
|
||||
public void test_select_word_in_GString_select_line_before_injection() {
|
||||
doTestForSelectWord(2, """
|
||||
print ""\"
|
||||
asddf
|
||||
as<caret>df $b sfsasdf
|
||||
fdsas
|
||||
"""
|
||||
''', '''\
|
||||
print """
|
||||
""\"
|
||||
""", """
|
||||
print ""\"
|
||||
asddf
|
||||
<selection>as<caret>df $b sfsasdf</selection>
|
||||
fdsas
|
||||
"""
|
||||
'''
|
||||
""\"
|
||||
""");
|
||||
}
|
||||
|
||||
void 'test select word in GString select line after injection'() {
|
||||
doTestForSelectWord 2, '''\
|
||||
print """
|
||||
public void test_select_word_in_GString_select_line_after_injection() {
|
||||
doTestForSelectWord(2, """
|
||||
print ""\"
|
||||
asddf
|
||||
asdf $b sfs<caret>asdf
|
||||
fdsas
|
||||
"""
|
||||
''', '''\
|
||||
print """
|
||||
""\"
|
||||
""", """
|
||||
print ""\"
|
||||
asddf
|
||||
<selection>asdf $b sfs<caret>asdf</selection>
|
||||
fdsas
|
||||
"""
|
||||
'''
|
||||
""\"
|
||||
""");
|
||||
}
|
||||
|
||||
void 'test select word in GString select line before end'() {
|
||||
doTestForSelectWord 2, '''\
|
||||
print """
|
||||
public void test_select_word_in_GString_select_line_before_end() {
|
||||
doTestForSelectWord(2, """
|
||||
print ""\"
|
||||
asddf
|
||||
asdf $b sfsasdf
|
||||
fd<caret>sas fsss"""
|
||||
''', '''\
|
||||
print """
|
||||
fd<caret>sas fsss""\"
|
||||
""", """
|
||||
print ""\"
|
||||
asddf
|
||||
asdf $b sfsasdf
|
||||
<selection>fd<caret>sas fsss</selection>"""
|
||||
'''
|
||||
<selection>fd<caret>sas fsss</selection>""\"
|
||||
""");
|
||||
}
|
||||
|
||||
void testSWInGStringMultiline() { doTestSelectWordUpTo 4 }
|
||||
public void testSWInGStringMultiline() { doTestSelectWordUpTo(4); }
|
||||
|
||||
void testSWInGStringBegin() { doTestSelectWordUpTo 2 }
|
||||
public void testSWInGStringBegin() { doTestSelectWordUpTo(2); }
|
||||
|
||||
void testSWInGStringEnd() { doTestSelectWordUpTo 2 }
|
||||
public void testSWInGStringEnd() { doTestSelectWordUpTo(2); }
|
||||
|
||||
void testSWInParameterList() { doTestForSelectWord(3) }
|
||||
public void testSWInParameterList() { doTestForSelectWord(3); }
|
||||
|
||||
void testSWInArgLabel1() { doTestForSelectWord(2) }
|
||||
public void testSWInArgLabel1() { doTestForSelectWord(2); }
|
||||
|
||||
void testSWInArgLabel2() { doTestForSelectWord(2) }
|
||||
public void testSWInArgLabel2() { doTestForSelectWord(2); }
|
||||
|
||||
void testSWInArgLabel3() { doTestForSelectWord(2) }
|
||||
public void testSWInArgLabel3() { doTestForSelectWord(2); }
|
||||
|
||||
void testSWEscapesInString() {
|
||||
doTestForSelectWord 1,
|
||||
"String s = \"abc\\nd<caret>ef\"",
|
||||
"String s = \"abc\\n<selection>d<caret>ef</selection>\""
|
||||
public void testSWEscapesInString() {
|
||||
doTestForSelectWord(1, "String s = \"abc\\nd<caret>ef\"", "String s = \"abc\\n<selection>d<caret>ef</selection>\"");
|
||||
}
|
||||
|
||||
void testSWListLiteralArgument() {
|
||||
doTestForSelectWord 2,
|
||||
"foo([a<caret>], b)",
|
||||
"foo(<selection>[a<caret>]</selection>, b)"
|
||||
public void testSWListLiteralArgument() {
|
||||
doTestForSelectWord(2, "foo([a<caret>], b)", "foo(<selection>[a<caret>]</selection>, b)");
|
||||
}
|
||||
|
||||
void testSWMethodParametersBeforeQualifier() {
|
||||
doTestForSelectWord 2,
|
||||
"a.fo<caret>o(b)",
|
||||
"a.<selection>foo(b)</selection>"
|
||||
public void testSWMethodParametersBeforeQualifier() {
|
||||
doTestForSelectWord(2, "a.fo<caret>o(b)", "a.<selection>foo(b)</selection>");
|
||||
}
|
||||
|
||||
void testSWInCodeBlock() { doTestForSelectWord 5 }
|
||||
public void testSWInCodeBlock() { doTestForSelectWord(5); }
|
||||
|
||||
void testElseBranch() {
|
||||
doTestForSelectWord (3, '''\
|
||||
public void testElseBranch() {
|
||||
doTestForSelectWord(3, """
|
||||
def foo() {
|
||||
if (a){
|
||||
}
|
||||
else <caret>{
|
||||
}
|
||||
}
|
||||
''', '''\
|
||||
""", """
|
||||
def foo() {
|
||||
if (a){
|
||||
}
|
||||
<selection> else <caret>{
|
||||
}
|
||||
</selection>}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void testBlocksOfCode() {
|
||||
doTestForSelectWord(8, '''\
|
||||
public void testBlocksOfCode() {
|
||||
doTestForSelectWord(8, """
|
||||
this.allOptions = [:];
|
||||
confTag.option.each{ opt ->
|
||||
def value = opt.'@value';
|
||||
@@ -132,7 +122,7 @@ this.allOptions = [:];
|
||||
}
|
||||
|
||||
this.macroExpander = macroExpander;
|
||||
''', '''\
|
||||
""", """
|
||||
this.allOptions = [:];
|
||||
confTag.option.each{ opt ->
|
||||
def value = opt.'@value';
|
||||
@@ -150,45 +140,45 @@ this.allOptions = [:];
|
||||
}
|
||||
</selection>
|
||||
this.macroExpander = macroExpander;
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void "test hippie completion in groovydoc"() {
|
||||
def text = '''
|
||||
class A {
|
||||
public void test_hippie_completion_in_groovydoc() {
|
||||
String text = """
|
||||
class A {
|
||||
|
||||
/** long<caret>
|
||||
*/
|
||||
void longName() {}
|
||||
void example() {}
|
||||
}
|
||||
'''
|
||||
myFixture.configureByText 'a.groovy', text
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
assert myFixture.editor.document.text.contains('** longName\n')
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
myFixture.checkResult(text)
|
||||
/** long<caret>
|
||||
*/
|
||||
void longName() {}
|
||||
void example() {}
|
||||
}
|
||||
""";
|
||||
myFixture.configureByText("a.groovy", text);
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION);
|
||||
assert myFixture.getEditor().getDocument().getText().contains("** longName\n");
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION);
|
||||
myFixture.checkResult(text);
|
||||
}
|
||||
|
||||
void "test hippie completion with hyphenated match"() {
|
||||
myFixture.configureByText 'a.groovy', '''
|
||||
foo = [ helloWorld: 1, "hello-world": {
|
||||
hw<caret>
|
||||
f
|
||||
}
|
||||
]'''
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
assert myFixture.editor.document.text.contains(' hello-world\n')
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
assert myFixture.editor.document.text.contains(' helloWorld\n')
|
||||
public void test_hippie_completion_with_hyphenated_match() {
|
||||
myFixture.configureByText("a.groovy", """
|
||||
foo = [ helloWorld: 1, "hello-world": {
|
||||
hw<caret>
|
||||
f
|
||||
}
|
||||
]""");
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION);
|
||||
assert myFixture.getEditor().getDocument().getText().contains(" hello-world\n");
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION);
|
||||
assert myFixture.getEditor().getDocument().getText().contains(" helloWorld\n");
|
||||
|
||||
myFixture.editor.caretModel.moveToOffset(myFixture.editor.document.text.indexOf(' f') + 2)
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
assert myFixture.editor.document.text.contains(' foo\n')
|
||||
myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getText().indexOf(" f") + 2);
|
||||
performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION);
|
||||
assert myFixture.getEditor().getDocument().getText().contains(" foo\n");
|
||||
}
|
||||
|
||||
void testSWforMemberWithDoc() {
|
||||
doTestForSelectWord(4, '''\
|
||||
public void testSWforMemberWithDoc() {
|
||||
doTestForSelectWord(4, """
|
||||
class A {
|
||||
/**
|
||||
* abc
|
||||
@@ -197,7 +187,7 @@ class A {
|
||||
|
||||
def bar(){}
|
||||
}
|
||||
''', '''\
|
||||
""", """
|
||||
class A {
|
||||
<selection> /**
|
||||
* abc
|
||||
@@ -206,67 +196,72 @@ class A {
|
||||
</selection>
|
||||
def bar(){}
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
void testMultiLineStingSelection() {
|
||||
public void testMultiLineStingSelection() {
|
||||
doTestForSelectWord(2, """
|
||||
print '''
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
'''
|
||||
""", """
|
||||
print '''
|
||||
<selection> abc cde
|
||||
xyz <caret>ahc
|
||||
</selection> '''
|
||||
""")
|
||||
print '''
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
'''
|
||||
""", """
|
||||
print '''
|
||||
<selection> abc cde
|
||||
xyz <caret>ahc
|
||||
</selection> '''
|
||||
""");
|
||||
|
||||
doTestForSelectWord(3, """
|
||||
print '''
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
'''
|
||||
""", """
|
||||
print '''<selection>
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
</selection>'''
|
||||
""")
|
||||
|
||||
print '''
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
'''
|
||||
""", """
|
||||
print '''<selection>
|
||||
abc cde
|
||||
xyz <caret>ahc
|
||||
</selection>'''
|
||||
""");
|
||||
}
|
||||
|
||||
private void doTestForSelectWord(int count, String input, String expected) {
|
||||
myFixture.configureByText("a.groovy", input)
|
||||
selectWord(count)
|
||||
myFixture.checkResult(expected)
|
||||
myFixture.configureByText("a.groovy", input);
|
||||
selectWord(count);
|
||||
myFixture.checkResult(expected);
|
||||
}
|
||||
|
||||
private void doTestForSelectWord(int count) {
|
||||
myFixture.configureByFile(getTestName(false) + ".groovy")
|
||||
selectWord(count)
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.groovy")
|
||||
myFixture.configureByFile(getTestName(false) + ".groovy");
|
||||
selectWord(count);
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
|
||||
}
|
||||
|
||||
private void doTestSelectWordUpTo(int count) {
|
||||
def testName = getTestName(false)
|
||||
myFixture.configureByFile "${testName}_0.groovy"
|
||||
myFixture.editor.settings.camelWords = true
|
||||
count.times {
|
||||
performEditorAction IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET
|
||||
myFixture.checkResultByFile "${testName}_${it + 1}.groovy"
|
||||
final String testName = getTestName(false);
|
||||
myFixture.configureByFile(testName + "_0.groovy");
|
||||
myFixture.getEditor().getSettings().setCamelWords(true);
|
||||
for (int i = 0; i < count; i++) {
|
||||
performEditorAction(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
|
||||
myFixture.checkResultByFile(testName + "_" + (i + 1) + ".groovy");
|
||||
}
|
||||
}
|
||||
|
||||
private def selectWord(int count) {
|
||||
myFixture.editor.settings.camelWords = true
|
||||
private void selectWord(int count) {
|
||||
myFixture.getEditor().getSettings().setCamelWords(true);
|
||||
for (int i = 0; i < count; i++) {
|
||||
performEditorAction(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET)
|
||||
performEditorAction(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
|
||||
}
|
||||
}
|
||||
|
||||
private void performEditorAction(final String actionId) {
|
||||
myFixture.performEditorAction(actionId)
|
||||
myFixture.performEditorAction(actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
private final String basePath = TestUtils.getTestDataPath() + "groovy/actions/";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite;
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy.ext.ginq")
|
||||
public class GroovyGinqTestSuite {
|
||||
}
|
||||
@@ -1,29 +1,35 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
|
||||
@CompileStatic
|
||||
class GroovyGotoDeclarationTest extends LightGroovyTestCase {
|
||||
|
||||
final String basePath = TestUtils.testDataPath + "gotoDeclaration/"
|
||||
|
||||
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
public class GroovyGotoDeclarationTest extends LightGroovyTestCase {
|
||||
private void doTest() {
|
||||
def name = getTestName()
|
||||
fixture.configureByFile "${name}.groovy"
|
||||
fixture.performEditorAction "GotoDeclaration"
|
||||
fixture.checkResultByFile("${name}_after.groovy")
|
||||
final String name = getTestName();
|
||||
getFixture().configureByFile(name + ".groovy");
|
||||
getFixture().performEditorAction("GotoDeclaration");
|
||||
getFixture().checkResultByFile(name + "_after.groovy");
|
||||
}
|
||||
|
||||
void 'test default constructor'() {
|
||||
doTest()
|
||||
public void testDefaultConstructor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
void 'test qualifier in new'() {
|
||||
doTest()
|
||||
public void testQualifierInNew() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return projectDescriptor;
|
||||
}
|
||||
|
||||
private final String basePath = TestUtils.getTestDataPath() + "gotoDeclaration/";
|
||||
private final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite;
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy.lang.parser")
|
||||
public class GroovyParserTestSuite {
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.openapi.paths.WebReference
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.InjectionTestFixtureKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.testFramework.fixtures.InjectionTestFixtureKt.assertInjectedReference
|
||||
|
||||
@CompileStatic
|
||||
class GroovyWebReferenceTest extends LightGroovyTestCase {
|
||||
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
|
||||
|
||||
void 'test web reference in strings'() {
|
||||
public class GroovyWebReferenceTest extends LightGroovyTestCase {
|
||||
public void test_web_reference_in_strings() {
|
||||
myFixture.configureByText("Demo.groovy", """
|
||||
class Demo {
|
||||
static void main(String[] args) {
|
||||
def doubleQuotes = "http://double:8080/app"
|
||||
def singleQuotes = 'http://single:8080/app'
|
||||
|
||||
def multilineSingle = '''
|
||||
https://multiline-single:8080/app
|
||||
'''
|
||||
|
||||
def multilineDouble = \"\"\"
|
||||
http://multiline-double:8080/app
|
||||
\"\"\"
|
||||
}
|
||||
}
|
||||
""")
|
||||
class Demo {
|
||||
static void main(String[] args) {
|
||||
def doubleQuotes = "http://double:8080/app"
|
||||
def singleQuotes = 'http://single:8080/app'
|
||||
|
||||
def multilineSingle = '''
|
||||
https://multiline-single:8080/app
|
||||
'''
|
||||
|
||||
def multilineDouble = ""\"
|
||||
http://multiline-double:8080/app
|
||||
""\"
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
assertInjectedReference(myFixture, WebReference.class, "http://double:8080/app")
|
||||
assertInjectedReference(myFixture, WebReference.class, "http://single:8080/app")
|
||||
assertInjectedReference(myFixture, WebReference.class, "https://multiline-single:8080/app")
|
||||
assertInjectedReference(myFixture, WebReference.class, "http://multiline-double:8080/app")
|
||||
InjectionTestFixtureKt.assertInjectedReference(myFixture, WebReference.class, "http://double:8080/app");
|
||||
InjectionTestFixtureKt.assertInjectedReference(myFixture, WebReference.class, "http://single:8080/app");
|
||||
InjectionTestFixtureKt.assertInjectedReference(myFixture, WebReference.class, "https://multiline-single:8080/app");
|
||||
InjectionTestFixtureKt.assertInjectedReference(myFixture, WebReference.class, "http://multiline-double:8080/app");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return GroovyProjectDescriptors.GROOVY_LATEST;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-18
@@ -1,25 +1,21 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.ContentEntry
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CompileStatic
|
||||
class LibraryLightProjectDescriptor extends DefaultLightProjectDescriptor {
|
||||
|
||||
private final TestLibrary myLibrary
|
||||
|
||||
LibraryLightProjectDescriptor(TestLibrary library) {
|
||||
myLibrary = library
|
||||
public class LibraryLightProjectDescriptor extends DefaultLightProjectDescriptor {
|
||||
public LibraryLightProjectDescriptor(TestLibrary library) {
|
||||
myLibrary = library;
|
||||
}
|
||||
|
||||
@Override
|
||||
void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry)
|
||||
myLibrary.addTo(module, model)
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
myLibrary.addTo(module, model);
|
||||
}
|
||||
|
||||
private final TestLibrary myLibrary;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,62 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerBase;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.psi.PsiIntersectionType;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||
import org.codehaus.groovy.runtime.StringGroovyMethods;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerBase
|
||||
import com.intellij.psi.PsiIntersectionType
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
abstract class LightGroovyTestCase extends LightJavaCodeInsightFixtureTestCase {
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class LightGroovyTestCase extends LightJavaCodeInsightFixtureTestCase {
|
||||
@NotNull
|
||||
JavaCodeInsightTestFixture getFixture() {
|
||||
myFixture
|
||||
public JavaCodeInsightTestFixture getFixture() {
|
||||
return myFixture;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setUp() throws Exception {
|
||||
super.setUp()
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// avoid PSI/document/model changes are not allowed during highlighting
|
||||
EntryPointsManagerBase.DEAD_CODE_EP_NAME.getExtensionList()
|
||||
EntryPointsManagerBase.DEAD_CODE_EP_NAME.getExtensionList();
|
||||
}
|
||||
|
||||
@Override
|
||||
void tearDown() throws Exception {
|
||||
super.tearDown()
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return GroovyProjectDescriptors.GROOVY_2_1
|
||||
return GroovyProjectDescriptors.GROOVY_2_1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return relative path to the test data. Path is relative to the
|
||||
* {@link com.intellij.openapi.application.PathManager#getHomePath()}
|
||||
* {@link PathManager#getHomePath()}
|
||||
*
|
||||
* @return relative path to the test data.
|
||||
*/
|
||||
@Override
|
||||
@NonNls
|
||||
protected String getBasePath() { null }
|
||||
|
||||
protected String getBasePath() { return null; }
|
||||
|
||||
protected void addGroovyTransformField() {
|
||||
myFixture.addClass('''package groovy.transform; public @interface Field{}''')
|
||||
myFixture.addClass("package groovy.transform; public @interface Field{}");
|
||||
}
|
||||
|
||||
protected void addGroovyObject() throws IOException {
|
||||
myFixture.addClass('''\
|
||||
protected void addGroovyObject() {
|
||||
myFixture.addClass("""
|
||||
package groovy.lang;
|
||||
public interface GroovyObject {
|
||||
java.lang.Object invokeMethod(java.lang.String s, java.lang.Object o);
|
||||
@@ -62,50 +65,48 @@ public interface GroovyObject {
|
||||
groovy.lang.MetaClass getMetaClass();
|
||||
void setMetaClass(groovy.lang.MetaClass metaClass);
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
|
||||
public static final String IMPORT_COMPILE_STATIC = 'import groovy.transform.CompileStatic'
|
||||
void addCompileStatic() {
|
||||
myFixture.addClass('''\
|
||||
public void addCompileStatic() {
|
||||
myFixture.addClass("""
|
||||
package groovy.transform;
|
||||
public @interface CompileStatic{
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
protected void addBigDecimal() {
|
||||
myFixture.addClass('''\
|
||||
myFixture.addClass("""
|
||||
package java.math;
|
||||
|
||||
public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
protected void addBigInteger() {
|
||||
myFixture.addClass('''\
|
||||
myFixture.addClass("""
|
||||
package java.math;
|
||||
|
||||
public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
protected void addHashSet() {
|
||||
myFixture.addClass('''\
|
||||
myFixture.addClass("""
|
||||
package java.util;
|
||||
|
||||
public class HashSet<E>
|
||||
extends AbstractSet<E>
|
||||
implements Set<E>, Cloneable, java.io.Serializable
|
||||
{}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
protected final void addAnnotationCollector() {
|
||||
myFixture.addClass '''\
|
||||
myFixture.addClass("""
|
||||
package groovy.transform;
|
||||
|
||||
@java.lang.annotation.Documented
|
||||
@@ -115,7 +116,7 @@ public @interface AnnotationCollector {
|
||||
String processor() default "org.codehaus.groovy.transform.AnnotationCollectorTransform";
|
||||
Class[] value() default {};
|
||||
}
|
||||
'''
|
||||
""");
|
||||
}
|
||||
|
||||
/*void addHashMap() {
|
||||
@@ -132,15 +133,14 @@ public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneabl
|
||||
}*/
|
||||
|
||||
protected final void addTestCase() {
|
||||
myFixture.addClass('''\
|
||||
|
||||
myFixture.addClass("""
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package junit.framework;
|
||||
package junit.framework;
|
||||
|
||||
@SuppressWarnings({"Contract", "MethodOverridesStaticMethodOfSuperclass", "RedundantThrows"})
|
||||
public abstract class TestCase extends junit.framework.Assert implements junit.framework.Test {
|
||||
@SuppressWarnings({"Contract", "MethodOverridesStaticMethodOfSuperclass", "RedundantThrows"})
|
||||
public abstract class TestCase extends junit.framework.Assert implements junit.framework.Test {
|
||||
private java.lang.String fName;
|
||||
|
||||
public TestCase() { /* compiled code */ }
|
||||
@@ -245,39 +245,44 @@ public abstract class TestCase extends junit.framework.Assert implements junit.f
|
||||
|
||||
public void setName(java.lang.String name) { /* compiled code */ }
|
||||
}
|
||||
''')
|
||||
""");
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
static void assertType(@Nullable String expected, @Nullable PsiType actual) {
|
||||
if (expected == null) {
|
||||
assert actual == null
|
||||
return
|
||||
public static void assertType(@Nullable String expected, @Nullable PsiType actual) {
|
||||
if (expected == null){
|
||||
assertNull(actual);
|
||||
return;
|
||||
}
|
||||
|
||||
assert actual != null
|
||||
if (actual instanceof PsiIntersectionType) {
|
||||
assertEquals(expected, genIntersectionTypeText(actual))
|
||||
assertNotNull(actual);
|
||||
if (actual instanceof PsiIntersectionType){
|
||||
TestCase.assertEquals(expected, genIntersectionTypeText((PsiIntersectionType)actual));
|
||||
}
|
||||
else {
|
||||
assertEquals(expected, actual.canonicalText)
|
||||
TestCase.assertEquals(expected, actual.getCanonicalText());
|
||||
}
|
||||
}
|
||||
|
||||
private static String genIntersectionTypeText(PsiIntersectionType t) {
|
||||
StringBuilder b = new StringBuilder('[')
|
||||
for (PsiType c : t.conjuncts) {
|
||||
b << c.canonicalText << ','
|
||||
StringBuilder b = new StringBuilder("[");
|
||||
for(PsiType c : t.getConjuncts()){
|
||||
StringGroovyMethods.leftShift(StringGroovyMethods.leftShift(b, c.getCanonicalText()), ",");
|
||||
}
|
||||
if (t.conjuncts) {
|
||||
b.replace(b.length() - 1, b.length(), ']')
|
||||
|
||||
if (DefaultGroovyMethods.asBoolean(t.getConjuncts())){
|
||||
b.replace(b.length() - 1, b.length(), "]");
|
||||
}
|
||||
return b
|
||||
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
@CompileStatic
|
||||
String getTestName() {
|
||||
return (getTestName(true) - 'test').split(' ')*.capitalize().join('').uncapitalize()
|
||||
public String getTestName() {
|
||||
String[] split = getTestName(true)
|
||||
.replaceFirst("test", "")
|
||||
.split(" ");
|
||||
String joined = Arrays.stream(split)
|
||||
.map(s -> StringGroovyMethods.capitalize(s))
|
||||
.collect(Collectors.joining());
|
||||
return StringGroovyMethods.uncapitalize(joined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,103 +1,110 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ControlFlowBuilder
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.GrAllVarsInitializedPolicy
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.GroovyControlFlow
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.FragmentVariableInfos
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.ReachingDefinitionsCollector
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ControlFlowBuilder;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.GrAllVarsInitializedPolicy;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.GroovyControlFlow;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.FragmentVariableInfos;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.ReachingDefinitionsCollector;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @auther ven
|
||||
*/
|
||||
class ReachingDefsTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
import java.util.List;
|
||||
|
||||
String basePath = TestUtils.testDataPath + 'groovy/reachingDefs/'
|
||||
public class ReachingDefsTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
public void testAssign() { doTest(); }
|
||||
|
||||
void testAssign() { doTest() }
|
||||
public void testClosure() { doTest(); }
|
||||
|
||||
void testClosure() { doTest() }
|
||||
public void testClosure1() { doTest(); }
|
||||
|
||||
void testClosure1() { doTest() }
|
||||
public void testEm1() { doTest(); }
|
||||
|
||||
void testEm1() { doTest() }
|
||||
public void testEm2() { doTest(); }
|
||||
|
||||
void testEm2() { doTest() }
|
||||
public void testEm3() { doTest(); }
|
||||
|
||||
void testEm3() { doTest() }
|
||||
public void testIf1() { doTest(); }
|
||||
|
||||
void testIf1() { doTest() }
|
||||
public void testInner() { doTest(); }
|
||||
|
||||
void testInner() { doTest() }
|
||||
public void testLocal1() { doTest(); }
|
||||
|
||||
void testLocal1() { doTest() }
|
||||
public void testLocal2() { doTest(); }
|
||||
|
||||
void testLocal2() { doTest() }
|
||||
public void testSimpl1() { doTest(); }
|
||||
|
||||
void testSimpl1() { doTest() }
|
||||
public void testSimpl2() { doTest(); }
|
||||
|
||||
void testSimpl2() { doTest() }
|
||||
public void testSimpl3() { doTest(); }
|
||||
|
||||
void testSimpl3() { doTest() }
|
||||
public void testWhile1() { doTest(); }
|
||||
|
||||
void testWhile1() { doTest() }
|
||||
public void doTest() {
|
||||
final List<String> data = TestUtils.readInput(getTestDataPath() + getTestName(true) + ".test");
|
||||
String text = data.get(0);
|
||||
|
||||
void doTest() {
|
||||
final List<String> data = TestUtils.readInput(testDataPath + getTestName(true) + ".test")
|
||||
String text = data.get(0)
|
||||
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, text);
|
||||
|
||||
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, text)
|
||||
int selStart = myFixture.getEditor().getSelectionModel().getSelectionStart();
|
||||
int selEnd = myFixture.getEditor().getSelectionModel().getSelectionEnd();
|
||||
|
||||
int selStart = myFixture.editor.selectionModel.selectionStart
|
||||
int selEnd = myFixture.editor.selectionModel.selectionEnd
|
||||
final GroovyFile file = (GroovyFile)myFixture.getFile();
|
||||
final PsiElement start = file.findElementAt(selStart);
|
||||
final PsiElement end = file.findElementAt(selEnd - 1);
|
||||
final GrControlFlowOwner owner = PsiTreeUtil.getParentOfType(PsiTreeUtil.findCommonParent(start, end), GrControlFlowOwner.class, false);
|
||||
assert owner != null;
|
||||
GrStatement firstStatement = getStatement(start, owner);
|
||||
GrStatement lastStatement = getStatement(end, owner);
|
||||
|
||||
final GroovyFile file = (GroovyFile)myFixture.file
|
||||
final PsiElement start = file.findElementAt(selStart)
|
||||
final PsiElement end = file.findElementAt(selEnd - 1)
|
||||
final GrControlFlowOwner owner = PsiTreeUtil.getParentOfType(PsiTreeUtil.findCommonParent(start, end), GrControlFlowOwner, false)
|
||||
assert owner != null
|
||||
GrStatement firstStatement = getStatement(start, owner)
|
||||
GrStatement lastStatement = getStatement(end, owner)
|
||||
final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(firstStatement);
|
||||
final GroovyControlFlow flow = ControlFlowBuilder.buildControlFlow(flowOwner, GrAllVarsInitializedPolicy.getInstance());
|
||||
final FragmentVariableInfos fragmentVariableInfos =
|
||||
ReachingDefinitionsCollector.obtainVariableFlowInformation(firstStatement, lastStatement, flowOwner, flow);
|
||||
|
||||
final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(firstStatement)
|
||||
final GroovyControlFlow flow = ControlFlowBuilder.buildControlFlow(flowOwner, GrAllVarsInitializedPolicy.getInstance())
|
||||
final FragmentVariableInfos fragmentVariableInfos = ReachingDefinitionsCollector.obtainVariableFlowInformation(firstStatement, lastStatement, flowOwner, flow)
|
||||
|
||||
assertEquals(data.get(1), dumpInfo(fragmentVariableInfos).trim())
|
||||
TestCase.assertEquals(data.get(1), dumpInfo(fragmentVariableInfos).trim());
|
||||
}
|
||||
|
||||
private static String dumpInfo(FragmentVariableInfos fragmentVariableInfos) {
|
||||
StringBuilder builder = new StringBuilder()
|
||||
builder.append("input:\n")
|
||||
for (VariableInfo info : fragmentVariableInfos.inputVariableNames) {
|
||||
builder.append(info.name).append("\n")
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("input:\n");
|
||||
for (VariableInfo info : fragmentVariableInfos.getInputVariableNames()) {
|
||||
builder.append(info.getName()).append("\n");
|
||||
}
|
||||
|
||||
builder.append("output:\n")
|
||||
for (VariableInfo info : fragmentVariableInfos.outputVariableNames) {
|
||||
builder.append(info.name).append("\n")
|
||||
builder.append("output:\n");
|
||||
for (VariableInfo info : fragmentVariableInfos.getOutputVariableNames()) {
|
||||
builder.append(info.getName()).append("\n");
|
||||
}
|
||||
|
||||
return builder.toString()
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static GrStatement getStatement(@NotNull PsiElement element, PsiElement context) {
|
||||
while (element.parent != context) {
|
||||
element = element.parent
|
||||
assert element != null
|
||||
while (!element.getParent().equals(context)) {
|
||||
element = element.getParent();
|
||||
assertNotNull(element);
|
||||
}
|
||||
|
||||
return (GrStatement) element
|
||||
return (GrStatement)element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public void setBasePath(String basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
private String basePath = TestUtils.getTestDataPath() + "groovy/reachingDefs/";
|
||||
}
|
||||
|
||||
@@ -1,70 +1,72 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.jarRepository.JarRepositoryManager
|
||||
import com.intellij.jarRepository.RemoteRepositoryDescription
|
||||
import com.intellij.openapi.application.WriteAction
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.DependencyScope
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.openapi.roots.libraries.ui.OrderRoot
|
||||
import com.intellij.project.IntelliJProjectConfiguration
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties
|
||||
import com.intellij.jarRepository.JarRepositoryManager;
|
||||
import com.intellij.jarRepository.RemoteRepositoryDescription;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.DependencyScope;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.ui.OrderRoot;
|
||||
import com.intellij.project.IntelliJProjectConfiguration;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties;
|
||||
|
||||
@CompileStatic
|
||||
final class RepositoryTestLibrary implements TestLibrary {
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
private final String[] myCoordinates
|
||||
private final DependencyScope myDependencyScope
|
||||
|
||||
RepositoryTestLibrary(String... coordinates) {
|
||||
this(DependencyScope.COMPILE, coordinates)
|
||||
public final class RepositoryTestLibrary implements TestLibrary {
|
||||
public RepositoryTestLibrary(String... coordinates) {
|
||||
this(DependencyScope.COMPILE, coordinates);
|
||||
}
|
||||
|
||||
RepositoryTestLibrary(String coordinates, DependencyScope dependencyScope) {
|
||||
this(dependencyScope, coordinates)
|
||||
public RepositoryTestLibrary(String coordinates, DependencyScope dependencyScope) {
|
||||
this(dependencyScope, coordinates);
|
||||
}
|
||||
|
||||
private RepositoryTestLibrary(DependencyScope dependencyScope, String... coordinates) {
|
||||
assert coordinates.length > 0
|
||||
myCoordinates = coordinates
|
||||
myDependencyScope = dependencyScope
|
||||
assert coordinates.length > 0;
|
||||
myCoordinates = coordinates;
|
||||
myDependencyScope = dependencyScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
void addTo(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
||||
def tableModel = model.moduleLibraryTable.modifiableModel
|
||||
def library = tableModel.createLibrary(myCoordinates[0])
|
||||
def libraryModel = library.modifiableModel
|
||||
public void addTo(@NotNull Module module, @NotNull ModifiableRootModel model) {
|
||||
final LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel();
|
||||
Library library = tableModel.createLibrary(myCoordinates[0]);
|
||||
final Library.ModifiableModel libraryModel = library.getModifiableModel();
|
||||
|
||||
for (coordinates in myCoordinates) {
|
||||
def roots = loadRoots(module.project, coordinates)
|
||||
for (root in roots) {
|
||||
libraryModel.addRoot(root.file, root.type)
|
||||
for (String coordinates : myCoordinates) {
|
||||
Collection<OrderRoot> roots = loadRoots(module.getProject(), coordinates);
|
||||
for (OrderRoot root : roots) {
|
||||
libraryModel.addRoot(root.getFile(), root.getType());
|
||||
}
|
||||
}
|
||||
|
||||
WriteAction.runAndWait({
|
||||
libraryModel.commit()
|
||||
tableModel.commit()
|
||||
})
|
||||
WriteAction.runAndWait(() -> {
|
||||
libraryModel.commit();
|
||||
tableModel.commit();
|
||||
});
|
||||
|
||||
model.findLibraryOrderEntry(library).scope = myDependencyScope
|
||||
model.findLibraryOrderEntry(library).setScope(myDependencyScope);
|
||||
}
|
||||
|
||||
static Collection<OrderRoot> loadRoots(Project project, String coordinates) {
|
||||
def libraryProperties = new RepositoryLibraryProperties(coordinates, true)
|
||||
def roots = JarRepositoryManager.loadDependenciesModal(project, libraryProperties, false, false, null, remoteRepositoryDescriptions)
|
||||
assert !roots.isEmpty()
|
||||
return roots
|
||||
public static Collection<OrderRoot> loadRoots(Project project, String coordinates) {
|
||||
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(coordinates, true);
|
||||
Collection<OrderRoot> roots = JarRepositoryManager.loadDependenciesModal(project, libraryProperties, false, false, null, getRemoteRepositoryDescriptions());
|
||||
assert !roots.isEmpty();
|
||||
return roots;
|
||||
}
|
||||
|
||||
private static List<RemoteRepositoryDescription> getRemoteRepositoryDescriptions() {
|
||||
IntelliJProjectConfiguration.remoteRepositoryDescriptions.collect { repository ->
|
||||
new RemoteRepositoryDescription(repository.id, repository.name, repository.url)
|
||||
}
|
||||
return ContainerUtil.map(IntelliJProjectConfiguration.getRemoteRepositoryDescriptions(), repository -> {
|
||||
return new RemoteRepositoryDescription(repository.getId(), repository.getName(), repository.getUrl());
|
||||
});
|
||||
}
|
||||
|
||||
private final String[] myCoordinates;
|
||||
private final DependencyScope myDependencyScope;
|
||||
}
|
||||
|
||||
@@ -1,37 +1,45 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import com.intellij.testFramework.EdtTestUtil
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
import com.intellij.testFramework.EdtTestUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.GroovyProjectDescriptors.GROOVY_LATEST_REAL_JDK
|
||||
|
||||
@CompileStatic
|
||||
class SetupRule implements TestRule {
|
||||
|
||||
final LightGroovyTestCase testCase = new LightGroovyTestCase() {
|
||||
LightProjectDescriptor projectDescriptor = GROOVY_LATEST_REAL_JDK
|
||||
}
|
||||
import static org.jetbrains.plugins.groovy.GroovyProjectDescriptors.GROOVY_LATEST_REAL_JDK;
|
||||
|
||||
public class SetupRule implements TestRule {
|
||||
@Override
|
||||
Statement apply(Statement base, Description description) {
|
||||
new Statement() {
|
||||
public Statement apply(final Statement base, Description description) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
void evaluate() throws Throwable {
|
||||
testCase.setUp()
|
||||
public void evaluate() throws Throwable {
|
||||
getTestCase().setUp();
|
||||
try {
|
||||
EdtTestUtil.runInEdtAndWait {
|
||||
base.evaluate()
|
||||
}
|
||||
EdtTestUtil.runInEdtAndWait(() -> base.evaluate());
|
||||
}
|
||||
finally {
|
||||
testCase.tearDown()
|
||||
getTestCase().tearDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public final LightGroovyTestCase getTestCase() {
|
||||
return testCase;
|
||||
}
|
||||
|
||||
private final LightGroovyTestCase testCase = new LightGroovyTestCase() {
|
||||
@Override
|
||||
public @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return projectDescriptor;
|
||||
}
|
||||
|
||||
public void setProjectDescriptor(LightProjectDescriptor projectDescriptor) {
|
||||
this.projectDescriptor = projectDescriptor;
|
||||
}
|
||||
|
||||
private LightProjectDescriptor projectDescriptor = GROOVY_LATEST_REAL_JDK;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.groovy;
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite;
|
||||
import org.jetbrains.plugins.groovy.util.SlowPolicy;
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy", policy = SlowPolicy.SLOW_ONLY)
|
||||
public class SlowGroovyTestSuite {
|
||||
}
|
||||
@@ -1,106 +1,80 @@
|
||||
/*
|
||||
* 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.jetbrains.plugins.groovy.lang
|
||||
package org.jetbrains.plugins.groovy.lang;
|
||||
|
||||
import com.intellij.codeInsight.unwrap.UnwrapHandler
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
|
||||
class GroovyUnwrapTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
import com.intellij.codeInsight.unwrap.UnwrapHandler;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
|
||||
public class GroovyUnwrapTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
private void assertUnwrapped(String codeBefore, String expectedCodeAfter) {
|
||||
myFixture.configureByText("A.groovy", codeBefore)
|
||||
new UnwrapHandler().invoke(project, myFixture.editor, myFixture.file)
|
||||
myFixture.checkResult(expectedCodeAfter)
|
||||
myFixture.configureByText("A.groovy", codeBefore);
|
||||
new UnwrapHandler().invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
|
||||
myFixture.checkResult(expectedCodeAfter);
|
||||
}
|
||||
|
||||
|
||||
void testUnwrapIf() {
|
||||
public void testUnwrapIf() {
|
||||
assertUnwrapped("""
|
||||
if (true) {
|
||||
a=1;
|
||||
c = 3
|
||||
b=1;<caret>
|
||||
}
|
||||
""",
|
||||
"""a=1;
|
||||
if (true) {
|
||||
a=1;
|
||||
c = 3
|
||||
b=1;<caret>
|
||||
}
|
||||
""", """
|
||||
a=1;
|
||||
c = 3
|
||||
b=1;""")
|
||||
b=1;""");
|
||||
}
|
||||
|
||||
void testUnwrapFor1() {
|
||||
public void testUnwrapFor1() {
|
||||
assertUnwrapped("""
|
||||
for(int i = 0; i < 10; i++) {
|
||||
Sys<caret>tem.gc();
|
||||
}
|
||||
""", "Sys<caret>tem.gc();")
|
||||
for(int i = 0; i < 10; i++) {
|
||||
Sys<caret>tem.gc();
|
||||
}
|
||||
""", "Sys<caret>tem.gc();");
|
||||
}
|
||||
|
||||
void testBraces() throws Exception {
|
||||
assertUnwrapped("""\
|
||||
public void testBraces() throws Exception {
|
||||
assertUnwrapped("""
|
||||
<caret>{
|
||||
def x = 1
|
||||
}
|
||||
""", "def x = 1")
|
||||
""", "def x = 1");
|
||||
}
|
||||
|
||||
void testUnwrapParameterUnderArgumentList() throws Exception {
|
||||
assertUnwrapped("xxx(1, yyy(<caret>1), 2)",
|
||||
"xxx(1, <caret>1, 2)")
|
||||
public void testUnwrapParameterUnderArgumentList() {
|
||||
assertUnwrapped("xxx(1, yyy(<caret>1), 2)", "xxx(1, <caret>1, 2)");
|
||||
}
|
||||
|
||||
void testTryWithCatches() throws Exception {
|
||||
assertUnwrapped("try {\n" +
|
||||
" int i;<caret>\n" +
|
||||
"} catch(RuntimeException e) {\n" +
|
||||
" int j;\n" +
|
||||
"} catch(Exception e) {\n" +
|
||||
" int k;\n" +
|
||||
"}",
|
||||
|
||||
"int i;")
|
||||
public void testTryWithCatches() {
|
||||
assertUnwrapped("""
|
||||
try {
|
||||
int i;<caret>
|
||||
} catch(RuntimeException e) {
|
||||
int j;
|
||||
} catch(Exception e) {
|
||||
int k;
|
||||
}""", "int i;");
|
||||
}
|
||||
|
||||
void testConditionalThat() throws Exception {
|
||||
assertUnwrapped("xxx(f ? <caret>'1' : '2');\n",
|
||||
"xxx('1');\n")
|
||||
public void testConditionalThat() {
|
||||
assertUnwrapped("xxx(f ? <caret>'1' : '2');\n", "xxx('1');\n");
|
||||
}
|
||||
|
||||
void testConditionalElse() throws Exception {
|
||||
assertUnwrapped("xxx(f ? '1' : '2' +<caret> 3);\n",
|
||||
"xxx('2' +<caret> 3);\n")
|
||||
public void testConditionalElse() {
|
||||
assertUnwrapped("xxx(f ? '1' : '2' +<caret> 3);\n", "xxx('2' +<caret> 3);\n");
|
||||
}
|
||||
|
||||
void testConditionalFromParameterList2() throws Exception {
|
||||
assertUnwrapped("xxx(11, f ? '1' : '2' +<caret> 3, 12);\n",
|
||||
"xxx(11, '2' +<caret> 3, 12);\n")
|
||||
public void testConditionalFromParameterList2() {
|
||||
assertUnwrapped("xxx(11, f ? '1' : '2' +<caret> 3, 12);\n", "xxx(11, '2' +<caret> 3, 12);\n");
|
||||
}
|
||||
|
||||
void testConditionalCond1() throws Exception {
|
||||
assertUnwrapped("f <caret>? \"1\" : \"2\" + 3",
|
||||
"\"1\"")
|
||||
public void testConditionalCond1() {
|
||||
assertUnwrapped("f <caret>? \"1\" : \"2\" + 3", "\"1\"");
|
||||
}
|
||||
|
||||
void testConditionalCond2() throws Exception {
|
||||
assertUnwrapped("<caret>f ? \"1\" : \"2\" + 3",
|
||||
"\"1\"")
|
||||
public void testConditionalCond2() {
|
||||
assertUnwrapped("<caret>f ? \"1\" : \"2\" + 3", "\"1\"");
|
||||
}
|
||||
|
||||
void testConditionalUnwrapUnderAssigmentExpression() throws Exception {
|
||||
assertUnwrapped("String s = f ? \"1<caret>\" : \"2\";\n",
|
||||
"String s = \"1\";\n")
|
||||
public void testConditionalUnwrapUnderAssigmentExpression() {
|
||||
assertUnwrapped("String s = f ? \"1<caret>\" : \"2\";\n", "String s = \"1\";\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+29
-27
@@ -1,47 +1,44 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.highlighting
|
||||
package org.jetbrains.plugins.groovy.lang.highlighting;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyUncheckedAssignmentOfMemberOfRawTypeInspection
|
||||
import org.jetbrains.plugins.groovy.util.GroovyLatestTest
|
||||
import org.jetbrains.plugins.groovy.util.HighlightingTest
|
||||
import org.junit.Test
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import org.codehaus.groovy.runtime.StringGroovyMethods;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyUncheckedAssignmentOfMemberOfRawTypeInspection;
|
||||
import org.jetbrains.plugins.groovy.util.GroovyLatestTest;
|
||||
import org.jetbrains.plugins.groovy.util.HighlightingTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.util.Collections.singletonList
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CompileStatic
|
||||
class GrUncheckedAssignmentOfRawTypeTest extends GroovyLatestTest implements HighlightingTest {
|
||||
|
||||
GrUncheckedAssignmentOfRawTypeTest() {
|
||||
super('highlighting')
|
||||
public class GrUncheckedAssignmentOfRawTypeTest extends GroovyLatestTest implements HighlightingTest {
|
||||
public GrUncheckedAssignmentOfRawTypeTest() {
|
||||
super("highlighting");
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTestName() {
|
||||
return super.getTestName().capitalize()
|
||||
public String getTestName() {
|
||||
return StringGroovyMethods.capitalize(super.getTestName());
|
||||
}
|
||||
|
||||
final Collection<Class<? extends LocalInspectionTool>> inspections = singletonList(GroovyUncheckedAssignmentOfMemberOfRawTypeInspection)
|
||||
@Test
|
||||
public void rawMethodAccess() { fileHighlightingTest(); }
|
||||
|
||||
@Test
|
||||
void rawMethodAccess() { fileHighlightingTest() }
|
||||
public void rawFieldAccess() { fileHighlightingTest(); }
|
||||
|
||||
@Test
|
||||
void rawFieldAccess() { fileHighlightingTest() }
|
||||
public void rawArrayStyleAccess() { fileHighlightingTest(); }
|
||||
|
||||
@Test
|
||||
void rawArrayStyleAccess() { fileHighlightingTest() }
|
||||
public void rawArrayStyleAccessToMap() { fileHighlightingTest(); }
|
||||
|
||||
@Test
|
||||
void rawArrayStyleAccessToMap() { fileHighlightingTest() }
|
||||
public void rawArrayStyleAccessToList() { fileHighlightingTest(); }
|
||||
|
||||
@Test
|
||||
void rawArrayStyleAccessToList() { fileHighlightingTest() }
|
||||
|
||||
@Test
|
||||
void rawClosureReturnType() {
|
||||
highlightingTest '''\
|
||||
public void rawClosureReturnType() {
|
||||
highlightingTest("""
|
||||
class A<T> {
|
||||
A(T t) {this.t = t}
|
||||
|
||||
@@ -54,6 +51,11 @@ class A<T> {
|
||||
|
||||
def a = new A(new Date())
|
||||
Date d = <warning descr="Cannot assign 'Object' to 'Date'">a.cl()</warning>
|
||||
'''
|
||||
""");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @NotNull List<Class<? extends LocalInspectionTool>> getInspections() {
|
||||
return Collections.singletonList(GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
//file:noinspection NewGroovyClassNamingConvention
|
||||
package org.jetbrains.plugins.groovy
|
||||
|
||||
import org.jetbrains.plugins.groovy.util.AllTestsSuite
|
||||
import org.jetbrains.plugins.groovy.util.SlowPolicy
|
||||
import org.jetbrains.plugins.groovy.util.TestPackage
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage("org.jetbrains.plugins.groovy")
|
||||
class FastGroovyTestSuite {}
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy", policy = SlowPolicy.SLOW_ONLY)
|
||||
class SlowGroovyTestSuite {}
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy", policy = SlowPolicy.ALL)
|
||||
class AllGroovyTestSuite {}
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy.lang.parser")
|
||||
class GroovyParserTestSuite {}
|
||||
|
||||
@RunWith(AllTestsSuite.class)
|
||||
@TestPackage(value = "org.jetbrains.plugins.groovy.ext.ginq")
|
||||
class GroovyGinqTestSuite {}
|
||||
@@ -1,15 +1,11 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.util
|
||||
package org.jetbrains.plugins.groovy.util;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
|
||||
|
||||
@CompileStatic
|
||||
abstract class Groovy25Test extends LightProjectTest {
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
|
||||
public abstract class Groovy25Test extends LightProjectTest {
|
||||
@Override
|
||||
final LightProjectDescriptor getProjectDescriptor() {
|
||||
GroovyProjectDescriptors.GROOVY_2_5
|
||||
public final LightProjectDescriptor getProjectDescriptor() {
|
||||
return GroovyProjectDescriptors.GROOVY_2_5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.util
|
||||
package org.jetbrains.plugins.groovy.util;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
|
||||
|
||||
@CompileStatic
|
||||
abstract class Groovy30Test extends LightProjectTest {
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
|
||||
public abstract class Groovy30Test extends LightProjectTest {
|
||||
@Override
|
||||
final LightProjectDescriptor getProjectDescriptor() {
|
||||
GroovyProjectDescriptors.GROOVY_3_0
|
||||
public final LightProjectDescriptor getProjectDescriptor() {
|
||||
return GroovyProjectDescriptors.GROOVY_3_0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.util
|
||||
package org.jetbrains.plugins.groovy.util;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.InheritConstructors
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
|
||||
|
||||
@CompileStatic
|
||||
@InheritConstructors
|
||||
abstract class GroovyLatestTest extends LightProjectTest {
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
|
||||
|
||||
public abstract class GroovyLatestTest extends LightProjectTest {
|
||||
@Override
|
||||
final LightProjectDescriptor getProjectDescriptor() {
|
||||
GroovyProjectDescriptors.GROOVY_2_5
|
||||
public final LightProjectDescriptor getProjectDescriptor() {
|
||||
return GroovyProjectDescriptors.GROOVY_2_5;
|
||||
}
|
||||
|
||||
public GroovyLatestTest(String testDataPath) {
|
||||
super(testDataPath);
|
||||
}
|
||||
|
||||
public GroovyLatestTest() { }
|
||||
}
|
||||
|
||||
@@ -1,36 +1,37 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.util
|
||||
package org.jetbrains.plugins.groovy.util;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.rules.TestName
|
||||
import org.junit.rules.TestRule
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
@CompileStatic
|
||||
abstract class LightProjectTest {
|
||||
|
||||
private final TestName myTestName
|
||||
private final FixtureRule myFixtureRule
|
||||
public final @Rule TestRule myRules
|
||||
|
||||
LightProjectTest(String testDataPath = '') {
|
||||
myTestName = new TestName()
|
||||
myFixtureRule = new FixtureRule(projectDescriptor, testDataPath)
|
||||
myRules = RuleChain.outerRule(myTestName).around(myFixtureRule).around(new EdtRule())
|
||||
public abstract class LightProjectTest {
|
||||
public LightProjectTest(String testDataPath) {
|
||||
myTestName = new TestName();
|
||||
myFixtureRule = new FixtureRule(getProjectDescriptor(), testDataPath);
|
||||
myRules = RuleChain.outerRule(myTestName).around(myFixtureRule).around(new EdtRule());
|
||||
}
|
||||
|
||||
abstract LightProjectDescriptor getProjectDescriptor()
|
||||
public LightProjectTest() {
|
||||
this("");
|
||||
}
|
||||
|
||||
String getTestName() {
|
||||
return myTestName.methodName
|
||||
public abstract LightProjectDescriptor getProjectDescriptor();
|
||||
|
||||
public String getTestName() {
|
||||
return myTestName.getMethodName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
final JavaCodeInsightTestFixture getFixture() {
|
||||
myFixtureRule.fixture
|
||||
public final JavaCodeInsightTestFixture getFixture() {
|
||||
return myFixtureRule.getFixture();
|
||||
}
|
||||
|
||||
private final TestName myTestName;
|
||||
private final FixtureRule myFixtureRule;
|
||||
|
||||
@Rule public final TestRule myRules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user