Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
28,400
void () { doTest(); }
testGRVY1316
28,401
void () { doTest(); }
testGrvy194
28,402
void () { doTest(); }
testGrvy194_1
28,403
void () { doTest(); }
testGRVY223
28,404
void () { doTest(); }
testGrvy487
28,405
void () { doTest(); }
testGrvy491
28,406
void () { doTest(); }
testGrvy76
28,407
void () { doTest(); }
testGrvy959
28,408
void () { doTest(); }
testOnDemand
28,409
void () { doTest(); }
testStaticMethod
28,410
void () { doTest(); }
testThrowVariable
28,411
void () { doTest(); }
testTupleCompl1
28,412
void () { doTest(); }
testTupleLongListAssign
28,413
void () { doTest(); }
testTupleObjCompl
28,414
void () { doTest(); }
testTupleShortListAss
28,415
void () { doTest(); }
testTupleTypedCompl
28,416
void () { doTest(); }
testType
28,417
void () { doTest(); }
testUntyped
28,418
String () { return TestUtils.getTestDataPath() + "groovy/oldCompletion/reference"; }
getBasePath
28,419
void (JavaModuleFixtureBuilder moduleBuilder) { moduleBuilder.addJdk(TestUtils.getMockJdkHome()); }
tuneFixture
28,420
void () { doTest(""); }
doTest
28,421
void (String directory) { CamelHumpMatcher.forceStartMatching(myFixture.getTestRootDisposable()); final List<String> stringList = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test"); if (directory.length()!=0) directory += "/"; final String fileName = directory + getTestName(true) + "." + getExtension(); myFixture.addFileToProject(fileName, stringList.get(0)); myFixture.configureByFile(fileName); CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false; StringBuilder result = new StringBuilder(); try { myFixture.completeBasic(); final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myFixture.getEditor()); if (lookup != null) { List<LookupElement> items = lookup.getItems(); if (!addReferenceVariants()) { items = ContainerUtil.findAll(items, lookupElement -> { final Object o = lookupElement.getObject(); return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage); }); } Collections.sort(items, Comparator.comparing(LookupElement::getLookupString)); result = new StringBuilder(); for (LookupElement item : items) { result.append("\n").append(item.getLookupString()); } result = new StringBuilder(result.toString().trim()); LookupManager.hideActiveLookup(myFixture.getProject()); } } finally { CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true; } assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result.toString()); }
doTest
28,422
String () { return "groovy"; }
getExtension
28,423
boolean () { return true; }
addReferenceVariants
28,424
String () { return TestUtils.getTestDataPath() + "intentions/convertMethodToClosure/"; }
getBasePath
28,425
void () { doMethodToClosureTest(); }
testMethodToClosure
28,426
void () { doMethodToClosureTest(); }
testStaticMethodToClosure
28,427
void () { doClosureToMethodTest(); }
testClosureToMethod
28,428
void () { doClosureToMethodTest(); }
testClosureWithImplicitParameterToMethod
28,429
void () { doClosureToMethodTest(); }
testClosureWithoutModifiersToMethod
28,430
void () { doClosureToMethodTest(); }
testClosureToMethodWithFieldUsages
28,431
void () { doMethodToClosureTest(); }
testMethodToClosureWithMemberPointer
28,432
void () { doMethodToClosureTest(); }
testMethodFromReference
28,433
void () { doMethodToClosureTest(false); }
testConstructorToClosure
28,434
void () {doMethodToClosureTest(false);}
testInvalidMethodName
28,435
void () { doTest(GroovyIntentionsBundle.message("convert.closure.to.method.intention.name"), true); }
doClosureToMethodTest
28,436
void () { doMethodToClosureTest(true); }
doMethodToClosureTest
28,437
void (boolean available) { doTest(GroovyIntentionsBundle.message("convert.method.to.closure.intention.name"), available); }
doMethodToClosureTest
28,438
String () { return TestUtils.getTestDataPath() + "intentions/convertJavaStyleArrayCreation/"; }
getBasePath
28,439
void () { doTest(GroovyIntentionsBundle.message("convert.java.style.array.intention.name"), true); }
testConversion
28,440
void () { myFixture.configureByText("Test.groovy", """ def fn() { def str = "hello " <caret>+ "world"; } """); IntentionAction intention = myFixture.findSingleIntention("Copy string concatenation text to clipboard"); ModCommandAction action = intention.asModCommandAction(); assertNotNull(action); ModCommand command = action.perform(myFixture.getActionContext()); assertEquals(new ModCopyToClipboard("hello world"), command); }
testCopyConcatenation
28,441
void () { myFixture.configureByText("Test.groovy", """ def fn() { def str = "hello <caret>world"; } """); IntentionAction intention = myFixture.findSingleIntention("Copy string literal text to clipboard"); ModCommandAction action = intention.asModCommandAction(); assertNotNull(action); ModCommand command = action.perform(myFixture.getActionContext()); assertEquals(new ModCopyToClipboard("hello world"), command); }
testCopyLiteral
28,442
String () { return TestUtils.getTestDataPath() + "intentions/staticImport/"; }
getBasePath
28,443
void () { doTest("Add static import", true); }
doSingleTest
28,444
void () { doTest("Add import on demand", true); }
doOnDemandTest
28,445
void () {doSingleTest();}
testSingleImport1
28,446
void () {doSingleTest();}
testSingleImport2
28,447
void () {doSingleTest();}
testSingleImport3
28,448
void () {doOnDemandTest();}
testOnDemand1
28,449
void () {doOnDemandTest();}
testOnDemand2
28,450
void () {doOnDemandTest();}
testOnDemand3
28,451
void () { doTextTest("def m(String a<caret>, int b, boolean c) {}", "def m(int b<caret>, String a, boolean c) {}"); doTextTest("def m(String a,<caret> int b, boolean c) {}", "def m(int b, String a, boolean c) {}"); }
testFlipFirstAndMiddleParameters
28,452
void () { doTextTest("def m(String a, int b<caret>, boolean c) {}", "def m(String a, boolean c<caret>, int b) {}"); doTextTest("def m(String a, int b,<caret> boolean c) {}", "def m(String a, boolean c, int b) {}"); }
testFlipMiddleAndLastParameters
28,453
void () { doTextTest("[1<caret>, 2, 3]", "[2<caret>, 1, 3]"); doTextTest("[1,<caret> 2, 3]", "[2, 1, 3]"); }
testFlipFirstAndMiddleListElements
28,454
void () { doTextTest("[1, 2<caret>, 3]", "[1, 3<caret>, 2]"); doTextTest("[1, 2,<caret> 3]", "[1, 3, 2]"); }
testFlipMiddleAndLastListElements
28,455
void () { doTextTest("[1<caret>,\n 2]", "[2<caret>,\n 1]"); }
testFlipAfterNewline
28,456
String () { return TestUtils.getTestDataPath() + "intentions/convertMapToClass/"; }
getBasePath
28,457
void () { doTest(); }
testSimple
28,458
void () { doTest(); }
testVariableTypeReplace
28,459
void () { doTest(false); }
testBadCase
28,460
void () { doTest(); }
testChangeReturnType
28,461
void () { doTest(); }
testChangeMethodParameter
28,462
void () { doTest(); }
_testNotChangeReturnType
28,463
void () { doTest(true); }
doTest
28,464
void (boolean exists) { myFixture.configureByFile(getTestName(true) + "/Test.groovy"); String hint = GroovyIntentionsBundle.message("convert.map.to.class.intention.name"); final List<IntentionAction> list = myFixture.filterAvailableIntentions(hint); if (!exists) { assertEmpty(list); return; } assertOneElement(list); final PsiElement element = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset()); final GrListOrMap map = PsiTreeUtil.getParentOfType(element, GrListOrMap.class); assertNotNull(map); final GrTypeDefinition foo = ConvertMapToClassIntention.createClass(getProject(), map.getNamedArguments(), "", "Foo"); myFixture.addFileToProject(getTestName(true) + "/Foo.groovy", foo.getContainingFile().getText()); final PsiClass psiClass = myFixture.findClass("Foo"); WriteCommandAction.runWriteCommandAction(getProject(), () -> ConvertMapToClassIntention .replaceMapWithClass(getProject(), map, psiClass, ConvertMapToClassIntention.checkForReturnFromMethod(map), ConvertMapToClassIntention.checkForVariableDeclaration(map), ConvertMapToClassIntention.checkForMethodParameter(map))); myFixture.checkResultByFile(getTestName(true) + "/Foo.groovy", getTestName(true) + "/Expected.groovy", true); myFixture.checkResultByFile(getTestName(true) + "/Test_after.groovy", true); }
doTest
28,465
String () { return TestUtils.getTestDataPath() + "intentions/removeUnnecessaryBraces/"; }
getBasePath
28,466
void () { doTest("Remove unnecessary braces in GString", true); }
testIntention
28,467
void () { doTest("Remove unnecessary braces in GString", true); }
testRefWithQualifier
28,468
void () { doTest("Remove unnecessary braces in GString", false); }
testNoIntention
28,469
String () { return TestUtils.getTestDataPath() + "paramToMap/" + getTestName(true) + "/"; }
getBasePath
28,470
LightProjectDescriptor () { return GroovyProjectDescriptors.GROOVY_1_7; }
getProjectDescriptor
28,471
CodeStyleSettings () { return CodeStyleSettingsManager.getSettings(getProject()); }
getCurrentCodeStyleSettings
28,472
void () { doTestImpl("A.groovy"); }
testParam1
28,473
void () { doTestImpl("A.groovy"); }
testFormatter
28,474
void () { doTestImpl("A.groovy"); }
testClosureAtEnd
28,475
void () { doTestImpl("A.groovy"); }
testClosure1
28,476
void () { doTestImpl("A.groovy"); }
testNewMap
28,477
void () { doTestImpl("A.groovy"); }
testTestError
28,478
void () { doTestImpl("A.groovy"); }
testSecondClosure
28,479
void () { doTestImpl("A.groovy"); }
testVarArgs
28,480
void () { doTestImpl("A.groovy"); }
testCallMethod
28,481
void () { doTestImpl("A.groovy"); }
testGettersAndCallMethod
28,482
void (String filePath) { myFixture.configureByFile(filePath); int offset = myFixture.getEditor().getCaretModel().getOffset(); final PsiFile file = myFixture.getFile(); final ConvertParameterToMapEntryIntention intention = new ConvertParameterToMapEntryIntention(); PsiElement element = file.findElementAt(offset); while (element != null && !(element instanceof GrReferenceExpression || element instanceof GrParameter)) { element = element.getParent(); } Assert.assertNotNull(element); final PsiElementPredicate condition = intention.getElementPredicate(); Assert.assertTrue(condition.satisfiedBy(element)); // Launch it! intention.processIntention(element, myFixture.getProject(), myFixture.getEditor()); PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); final String result = file.getText(); //System.out.println(result); myFixture.checkResultByFile(filePath.replace(".groovy", ".test"), true); // String expected = getExpectedResult(filePath); // Assert.assertEquals(expected, result); }
doTestImpl
28,483
String (final String filePath) { Assert.assertTrue(filePath.endsWith(".groovy")); String testFilePath = StringUtil.trimEnd(filePath, "groovy") + "test"; final File file = new File(getTestDataPath() + testFilePath); assertTrue(file.exists()); String expected = ""; try { BufferedReader reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); while (line != null) { expected += line; line = reader.readLine(); if (line != null) expected += "\n"; } reader.close(); } catch (IOException e) { e.printStackTrace(); } return expected; }
getExpectedResult
28,484
void () { myFixture.enableInspections(GroovyAssignabilityCheckInspection.class, GrUnresolvedAccessInspection.class); myFixture.configureByText("A.groovy", """ new groovy.xml.MarkupBuilder().root { a() b {} c(2) {} d(a: 1) {} e(b: 2, {}) f(c: 3, d: 4) g(e: 5, [1, 2, 3], f: 6) h([g: 7, h: 8], new Object()) i(new Object(), i: 9, j: 10) {} j([k: 11, l: 12], new Object(), {}) k(new Object()) l(new Object(), [m: 13]) m(new Object(), [n: 14]) {} n(new Object(), [o: 15], {}) foo<warning>("a", "b")</warning> } """); myFixture.testHighlighting(true, false, true); }
testHighlighting
28,485
void () { myFixture.configureByText("A.groovy", "\nclass A {\n void foo() {}\n\n void testSomething() {\n def xml = new groovy.xml.MarkupBuilder()\n xml.records() {\n foo<caret>()\n }\n }\n}\n"); PsiElement method = myFixture.getElementAtCaret(); assert method instanceof GrMethodImpl; assert method.isPhysical(); assert ((GrMethodImpl)method).getContainingClass().getName().equals("A"); }
testResolveToMethod1
28,486
void () { myFixture.configureByText("A.groovy", """ class A { void testSomething() { def xml = new groovy.xml.MarkupBuilder() xml.records() { getDoubleQuotes<caret>() } } } """); PsiElement method = myFixture.getElementAtCaret(); assert method instanceof ClsMethodImpl; assert method.isPhysical(); assert ((ClsMethodImpl)method).getContainingClass().getName().equals("MarkupBuilder"); }
testResolveToMethod2
28,487
void () { myFixture.configureByText("A.groovy", """ def xml = new groovy.xml.MarkupBuilder() xml.records() { foo<caret>() } """); PsiElement method = myFixture.getElementAtCaret(); assert method instanceof GrLightMethodBuilder; assert ((GrLightMethodBuilder)method).getReturnType().getCanonicalText().equals("java.lang.String"); }
testResolveToDynamicMethod
28,488
void () { myFixture.configureByText("a.groovy", """ def builder = new groovy.json.StreamingJsonBuilder(null) builder.people { person { string "fdsasdf" mapCall( city: 'A', country: 'B', zip: 12345, ) boolCall true varArgs '1111', 22222 empty() cc { foobar() hellYeah(1,2,3) } <warning>someProperty</warning> } <warning>someProperty</warning> } builder.<warning>root</warning> builder.root<warning>(new Object())</warning> builder.root<warning>(new Object[0])</warning> builder.root<warning>([new Object(), new Object()])</warning> builder.root<warning>([], new Object(), {})</warning> """); getFixture().enableInspections(GroovyAssignabilityCheckInspection.class, GrUnresolvedAccessInspection.class); getFixture().checkHighlighting(true, false, true); }
testHighlighting
28,489
void () { for (String text : List.of("builder.root()", "builder.root {}", "builder.root(a: 1, b: 2)", "builder.root(a: 1, b: 2) {}", "builder.root([1, 2, 3, 4]) {}", "builder.root([] as Integer[], {})")) { GroovyFile file = (GroovyFile)getFixture().configureByText("a.groovy", "def builder = new groovy.json.StreamingJsonBuilder(null);" + text); GrTopStatement[] statements = file.getTopStatements(); GrCallExpression call = (GrCallExpression)statements[statements.length - 1]; assert call.resolveMethod() != null; assert call.getType().getCanonicalText().equals("groovy.json.StreamingJsonBuilder"); } }
testBuilderCallsResolveReturnType
28,490
void () { for (String callText : List.of("noArg()", "singleArg(1)", "singleArg(new Object())", "singleArg {}", "singleArg([:])", "doubleArg([:]) {}", "doubleArg(1, 2)", "doubleArg([], {})", "doubleArg(new Object[0]) {}", "doubleArg(new Object[0], {})", "varArg(1, 2, 3)", "varArg(1, 2d, '')", "varArg(new Object(), [], {}, a: 1, 2d, [:], '')")) { for (String text : List.of("builder.root {<caret>" + callText + "}", "builder.root(a: 1, b: 2) {<caret>" + callText + "}", "builder.root([1, 2, 3, 4]) {<caret>" + callText + "}", "builder.root([] as Integer[], {<caret>" + callText + "})")) { doTest(text); } } }
testBuilderInnerCallsResolveReturnType
28,491
void () { for (String innerCallText : List.of("noArg()", "singleArg(1)", "singleArg(new Object())", "singleArg {}", "singleArg([:])", "doubleArg([:]) {}", "doubleArg(1, 2)", "doubleArg([], {})", "doubleArg(new Object[0]) {}", "doubleArg(new Object[0], {})", "varArg(1, 2, 3)", "varArg(1, 2d, '')", "varArg(new Object(), [], {}, a: 1, 2d, [:], '')")) { for (String callText : List.of("singleArg {<caret>" + innerCallText + "}", "doubleArg([:]) {<caret>" + innerCallText + "}", "doubleArg([], {<caret>" + innerCallText + "})", "doubleArg(new Object[0], {<caret>" + innerCallText + "})", "varArg(new Object(), [], {<caret>" + innerCallText + "}, a: 1, 2d, [:], '')")) { for (String s : List.of("builder.root {" + callText + "}", "builder.root(a: 1, b: 2) {" + callText + "}", "builder.root([1, 2, 3, 4]) {" + callText + "}", "builder.root([] as Integer[], {" + callText + "})")) { doTest(s); } } } }
test_builder_delegate_inner_calls_resolve___return_type
28,492
void () { myFixture.configureByText("a.groovy", """ def foo(String s) {} new groovy.json.StreamingJsonBuilder().root { fo<caret>o "" } """); PsiElement resolved = myFixture.getFile().findReferenceAt(myFixture.getCaretOffset()).resolve(); assert resolved instanceof GrMethod; assert !(resolved instanceof LightElement); assert resolved.isPhysical(); }
testOwnerFirst
28,493
void (String text) { getFixture().configureByText("a.groovy", "def builder = new groovy.json.StreamingJsonBuilder(); " + DefaultGroovyMethods.invokeMethod(String.class, "valueOf", new Object[]{text})); GrReferenceExpression reference = (GrReferenceExpression)getFixture().getReferenceAtCaretPosition(); assert reference.resolve() instanceof PsiMethod && reference.getType().getCanonicalText().equals("java.lang.Object") : text; }
doTest
28,494
void () { GroovyFile file = (GroovyFile) myFixture.configureByText("a.groovy", """ new groovy.json.StreamingJsonBuilder().cal<caret>l {} """); GrTopStatement[] statements = file.getTopStatements(); GrCallExpression call = (GrCallExpression) statements[statements.length - 1]; Object method = call.resolveMethod(); assert method != null; assert method instanceof ClsMethodImpl; }
testDoNotOverrideExistingMethods
28,495
LightProjectDescriptor () { return projectDescriptor; }
getProjectDescriptor
28,496
LightProjectDescriptor () { return GroovyProjectDescriptors.GROOVY_LATEST; }
getProjectDescriptor
28,497
void () { getFixture().configureByText("a.groovy", """ def builder = new groovy.json.JsonBuilder() builder.people { person { string "fdsasdf" mapCall( city: 'A', country: 'B', zip: 12345, ) boolCall true varArgs '1111', 22222 empty() <warning>someProperty</warning> } <warning>someProperty</warning> } builder.<warning>root</warning> builder.root<warning>(new Object())</warning> builder.root<warning>(new Object[0])</warning> builder.root<warning>([new Object(), new Object()])</warning> builder.root<warning>([], new Object(), {})</warning> """); getFixture().enableInspections(GroovyAssignabilityCheckInspection.class, GrUnresolvedAccessInspection.class); getFixture().checkHighlighting(true, false, true); }
testHighlighting
28,498
void () { for (Map.Entry<String, String> entry : Map.of( "builder.root()", "java.util.Map", "builder.root {}", "java.util.Map", "builder.root(a:1)", "java.util.Map", "builder.root([a:1])", "java.util.Map", "builder.root([a:1]) {}", "java.util.Map", "builder.root(a:1) {}", "java.util.Map", "builder.root(a:1, {})", "java.util.Map", "builder.root({}, a:1)", "java.util.Map", "builder.root([1,\"\",new Object()], {})", "java.util.Map", "builder.root([1,\"\",new Object()] as Object[], {})", "java.util.Map" ).entrySet()) { String text = entry.getKey(); String returnType = entry.getValue(); var file = (GroovyFile)getFixture().configureByText("a.groovy", "def builder = new groovy.json.JsonBuilder(); " + text); GrTopStatement[] statements = file.getTopStatements(); var call = (GrCallExpression)statements[statements.length - 1]; assert call.resolveMethod() != null; assert call.getType().getCanonicalText().equals(returnType); } }
testBuilderCallsResolveAndReturnType
28,499
void () { for (Map.Entry<String, String> entry : Map.of( "noArg()", "java.util.List", "singleArg(1)", "java.lang.Integer", "singleArg(\"\")", "java.lang.String", "singleArg(new Object())", "java.lang.Object", "doubleArgs([1,2,3], {})", "java.util.List<java.lang.Integer>", "doubleArgs([] as Number[], {})", "java.util.List<java.lang.Number>", "varArgs(1,2,3)", "java.util.List<java.lang.Integer>", "varArgs(1,2l,3d)", "java.util.List<java.lang.Number>", "varArgs(1,2l,3d, new Object())", "java.util.List<java.lang.Object>" ).entrySet()) { String callText = entry.getKey(); String returnType = entry.getValue(); for (String text : List.of( "builder.root {<caret>" + callText + "}", "builder.root([a:1]) {<caret>" + callText + "}", "builder.root({<caret>" + callText + "}, a:1)" )) { getFixture().configureByText("a.groovy", "def builder = new groovy.json.JsonBuilder(); " + text); var reference = (GrReferenceExpression)getFixture().getReferenceAtCaretPosition(); assert reference.resolve() instanceof PsiMethod; assert reference.getType().getCanonicalText().equals(returnType); } } }
testBuilderInnerCallsResolveAndReturnType