Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
44,300
String () { return "Pet{" + "name='" + name + '\'' + ", birthDay=" + birthDay + ", owner=" + owner + '}'; }
toString
44,301
void (Owner owner) { this.owner = owner; }
setOwner
44,302
String () { return "DummySortTestBean{" + "age=" + age + ", year=" + year + ", name='" + name + '\'' + ", email='" + email + '\'' + ", _member=" + _member + ", bean=" + bean + '}'; }
toString
44,303
void () { doTest(""" class X { private int <warning descr="Field 'i' is not used in 'toString()' method">i</warning> = 0; public String toString() { return null; } }"""); }
testBasic
44,304
String () { return null; }
toString
44,305
void () { doTest(""" class ToStringTest3 { int number; public int getNumber() { return number; } @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("ToStringTest3"); sb.append("{number=").append(getNumber()); sb.append('}'); return sb.toString(); } }"""); }
testGetterUsed
44,306
int () { return number; }
getNumber
44,307
String () { final StringBuilder sb = new StringBuilder(); sb.append("ToStringTest3"); sb.append("{number=").append(getNumber()); sb.append('}'); return sb.toString(); }
toString
44,308
void () { myFixture.addClass(""" package java.util; public class Objects { public static String toString(Object object) { return null; } }"""); doTest(""" import java.util.Objects; class X { private int i = 0; public String toString() { return Objects.toString(this); } }"""); }
testReflectionUsed
44,309
String (Object object) { return null; }
toString
44,310
String () { return Objects.toString(this); }
toString
44,311
void (@NonNls String text) { myFixture.configureByText("X.java", text); myFixture.enableInspections(new FieldNotUsedInToStringInspection()); myFixture.testHighlighting(true, false, false); }
doTest
44,312
void () { doTest("class <warning descr=\"Class 'X' does not override 'toString()' method\">X</warning> {" + " private int i = 0;" + "}"); }
testBasic
44,313
void () { doTest("class X {" + " class Inner {" + " private int i = 0;" + " }" + "}"); }
testDoNotWarnOnInnerClass
44,314
void () { doTest("record R(int x, int y) {}"); }
testDoNotWarnOnRecord
44,315
void (@NonNls String text) { myFixture.configureByText("X.java", text); final ClassHasNoToStringMethodInspection inspection = new ClassHasNoToStringMethodInspection(); inspection.excludeInnerClasses = true; myFixture.enableInspections(inspection); myFixture.testHighlighting(true, false, false); }
doTest
44,316
void () { doTest(""" public class Foobar { private int foo; private int bar; @Override <caret> public String toString() { return "Foobar{" + "foo=" + foo + ", bar=" + bar + '}'; } public static class Nested { } } """, """ public class Foobar { private int foo; private int bar; @Override public String <caret>toString() ...
testDuplicateToStringAnInnerClass
44,317
String () { return "Foobar{" + "foo=" + foo + ", bar=" + bar + '}'; }
toString
44,318
void () { doTest(""" class Foobar extends Foo { private int bar; <caret>\s } class Foo { protected int foo; } """, """ class Foobar extends Foo { private int bar; @Override public String toString() { return "Foobar{" + "foo=" + foo + ", bar=" + bar + '}'; } } class Foo { protected int foo; } """, ReplacePolicy.getInsta...
testProtectedFieldInSuper
44,319
String () { return "Foobar{" + "foo=" + foo + ", bar=" + bar + '}'; }
toString
44,320
void () { Config config = GenerateToStringContext.getConfig(); config.setEnableMethods(true); try { doTest(""" class Foobar extends Foo { private int bar; <caret>\s } class Foo { private int foo; public int getFoo() { return foo; } } """, """ class Foobar extends Foo { private int bar; @Override public String toString(...
testPrivateFieldWithGetterInSuper
44,321
int () { return foo; }
getFoo
44,322
String () { return "Foobar{" + "foo=" + getFoo() + ", bar=" + bar + '}'; }
toString
44,323
int () { return foo; }
getFoo
44,324
void () { Config config = GenerateToStringContext.getConfig(); config.setEnableMethods(true); config.setSortElements(3); try { doTest(""" class Foobar extends Foo { private int bar; <caret>\s } class Foo { private int foo; public int getFoo() { return foo; } } """, """ class Foobar extends Foo { private int bar; @Overr...
testPrivateFieldWithGetterInSuperSortSuperFirst
44,325
int () { return foo; }
getFoo
44,326
String () { return "Foobar{" + "foo=" + getFoo() + ", bar=" + bar + '}'; }
toString
44,327
int () { return foo; }
getFoo
44,328
void () { doTest(""" class FooImpl extends Foo { <caret> } abstract class Foo { public abstract toString(); } """, """ class FooImpl extends Foo { @Override public String toString() { return "FooImpl{}"; } } abstract class Foo { public abstract toString(); } """, ReplacePolicy.getInstance(), findTemplate("String concat...
testAbstractSuperToString
44,329
String () { return "FooImpl{}"; }
toString
44,330
void (@NotNull String before, @NotNull String after, @NotNull ConflictResolutionPolicy policy, @NotNull TemplateResource template) { myFixture.configureByText("a.java", before); PsiClass clazz = findClass(); Collection<PsiMember> members = collectMembers(clazz); GenerateToStringWorker worker = buildWorker(clazz, policy...
doTest
44,331
void (@NotNull String before, @NotNull String after, @NotNull ConflictResolutionPolicy policy) { doTest(before, after, policy, ToStringGeneratingTest.findDefaultTemplate()); }
doTest
44,332
GenerateToStringWorker (@NotNull final PsiClass clazz, @NotNull final ConflictResolutionPolicy policy) { return new GenerateToStringWorker(clazz, myFixture.getEditor(), true) { @Override protected ConflictResolutionPolicy exitsMethodDialog(TemplateResource template) { return policy; } }; }
buildWorker
44,333
ConflictResolutionPolicy (TemplateResource template) { return policy; }
exitsMethodDialog
44,334
TemplateResource () { return findTemplate("String concat (+)"); }
findDefaultTemplate
44,335
TemplateResource (final String templateName) { Collection<TemplateResource> templates = ToStringTemplatesManager.getInstance().getAllTemplates(); TemplateResource template = ContainerUtil.find(templates, x -> x.getFileName().equals(templateName)); assertNotNull(template); return template; }
findTemplate
44,336
Collection<PsiMember> (@NotNull PsiClass clazz) { PsiElementClassMember<?>[] memberElements = GenerateToStringActionHandlerImpl.buildMembersToShow(clazz); return Arrays.stream(memberElements) .<PsiMember>map(x -> x.getElement()) .sorted((o1, o2) -> compareMembers(o1, o2)) .toList(); }
collectMembers
44,337
int (PsiMember o1, PsiMember o2) { PsiClass c1 = o1.getContainingClass(); PsiClass c2 = o2.getContainingClass(); return c1.equals(c2) ? o2.getName().compareTo(o1.getName()) : c1.isInheritor(c2, true) ? 1 : -1; }
compareMembers
44,338
PsiClass () { PsiFile file = myFixture.getFile(); assertInstanceOf(file, PsiJavaFile.class); PsiClass[] classes = ((PsiJavaFile)file).getClasses(); assertTrue(classes.length > 0); return classes[0]; }
findClass
44,339
Status () { switch (myRealEvent.result.getStatus()) { case PASSED: return Status.PASSED; case PENDING: return Status.PENDING; case SKIPPED: return Status.SKIPPED; default: return Status.FAILED; } }
getResult
44,340
Long () { return myRealEvent.result.getDuration() != null ? myRealEvent.result.getDuration() / 1000000: 0; }
getDuration
44,341
String () { return myRealEvent.result.getErrorMessage(); }
getErrorMessage
44,342
boolean () { PickleEvent pickleEvent = getPickleEvent(myRealTestCase); return pickleEvent != null && pickleEvent.pickle.getLocations().size() > 1; }
isScenarioOutline
44,343
String () { return myRealTestCase.getUri(); }
getUri
44,344
int () { PickleEvent pickleEvent = getPickleEvent(myRealTestCase); if (pickleEvent != null) { return pickleEvent.pickle.getLocations().get(pickleEvent.pickle.getLocations().size() - 1).getLine(); } return 0; }
getScenarioOutlineLine
44,345
int () { return myRealTestCase.getLine(); }
getLine
44,346
String () { return myRealTestCase.getName(); }
getScenarioName
44,347
String () { if (myRealStep.isHook()) { try { Field definitionMatchField = myRealStep.getClass().getSuperclass().getDeclaredField("definitionMatch"); definitionMatchField.setAccessible(true); Object definitionMatchFieldValue = definitionMatchField.get(myRealStep); Field hookDefinitionField = definitionMatchFieldValue.ge...
getLocation
44,348
String () { String stepName; if (myRealStep.isHook()) { stepName = "Hook: " + myRealStep.getHookType().toString(); } else { stepName = getStepKeyword() + " " + myRealStep.getStepText(); } return stepName; }
getStepName
44,349
String () { try { String filePath = myRealStep.getStepLocation().substring(0, myRealStep.getStepLocation().indexOf(':')); String line = CucumberJvmSMFormatterUtil.getStepKeyword(filePath, myRealStep.getStepLine()); if (line != null) { return line; } } catch (Throwable ignored) { } return "Given"; }
getStepKeyword
44,350
PickleEvent (TestCase testCase) { try { Field pickleEventField = testCase.getClass().getDeclaredField("pickleEvent"); pickleEventField.setAccessible(true); return (PickleEvent)pickleEventField.get(testCase); } catch (Exception ignored) { } return null; }
getPickleEvent
44,351
String () { return myUri; }
getUri
44,352
String () { return mySource; }
getSource
44,353
void (CucumberJvmTestCase testCase) { String uri = testCase.getUri(); if (currentFilePath == null) { outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri, getFeatureFileDescription(uri)); } else if (!uri.equals(currentFilePath)) { closeCurrentScenarioOutline(); outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurre...
handleTestCaseStarted
44,354
void (CucumberJvmTestCase testCase) { outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getScenarioName(testCase)); outCommand(TEMPLATE_SCENARIO_FINISHED, getCurrentTime()); }
handleTestCaseFinished
44,355
void () { closeCurrentScenarioOutline(); outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getFeatureFileDescription(currentFilePath)); }
handleTestRunFinished
44,356
void (CucumberJvmWriteEvent event) { myOut.println(event.getText()); }
handleWriteEvent
44,357
void (CucumberJvmTestStep testStep) { outCommand(TEMPLATE_TEST_STARTED, getCurrentTime(), testStep.getLocation(), testStep.getStepName()); }
handleTestStepStarted
44,358
void (CucumberJvmTestStepFinishedEvent event) { if (event.getResult() == CucumberJvmTestStepFinishedEvent.Status.PASSED) { // write nothing } else if (event.getResult() == CucumberJvmTestStepFinishedEvent.Status.SKIPPED || event.getResult() == CucumberJvmTestStepFinishedEvent.Status.PENDING) { outCommand(TEMPLATE_TEST_...
handleTestStepFinished
44,359
void (CucumberJvmTestSourceReadEvent event) { closeCurrentScenarioOutline(); pathToDescription.put(event.getUri(), getFeatureName(event.getSource())); }
handleTestSourceRead
44,360
String (String uri) { if (pathToDescription.containsKey(uri)) { return pathToDescription.get(uri); } return uri; }
getFeatureFileDescription
44,361
void () { if (currentScenarioOutlineLine > 0) { outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), EXAMPLES_CAPTION); outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), currentScenarioOutlineName); currentScenarioOutlineLine = 0; currentScenarioOutlineName = null; } }
closeCurrentScenarioOutline
44,362
String[] (String errorReport) { if (errorReport == null) { errorReport = ""; } String[] messageAndDetails = errorReport.split("\n", 2); String message = null; if (messageAndDetails.length > 0) { message = messageAndDetails[0]; } if (message == null) { message = ""; } String details = null; if (messageAndDetails.length ...
getMessageAndDetails
44,363
void (String command, String... parameters) { myOut.println(escapeCommand(command, parameters)); }
outCommand
44,364
String (CucumberJvmTestCase testCase) { if (testCase.isScenarioOutline()) { return SCENARIO_OUTLINE_CAPTION + testCase.getLine(); } return "Scenario: " + testCase.getScenarioName(); }
getScenarioName
44,365
String () { if (myCurrentTimeValue != null) { return myCurrentTimeValue; } return CucumberJvmSMFormatterUtil.getCurrentTime(); }
getCurrentTime
44,366
String (String fqName, boolean splitBySlash) { return fqName; }
getNodeName
44,367
String (Description description, String className, String methodName) { try { Field descriptionField = Description.class.getDeclaredField("fUniqueId"); descriptionField.setAccessible(true); String elementUrl = descriptionField.get(description).toString(); String elementSMUrl = elementUrl; if (elementUrl.startsWith(CLAS...
getTestLocation
44,368
String () { return myText; }
getText
44,369
String () { return DATE_FORMAT.format(new Date()); }
getCurrentTime
44,370
String (String source) { if (source == null) { return ""; } return source.replace("|", "||").replace("\n", "|n").replace("\r", "|r").replace("'", "|'").replace("]", "|]"); }
escape
44,371
String (String command, String... parameters) { String[] escapedParameters = new String[parameters.length]; for (int i = 0; i < escapedParameters.length; i++) { escapedParameters[i] = escape(parameters[i]); } return String.format(command, (Object[])escapedParameters); }
escapeCommand
44,372
String (String featureHeader) { String[] lines = featureHeader.split("\n"); for (String line : lines) { line = line.trim(); if (line.length() == 0 || line.charAt(0) == '#' || line.charAt(0) == '@') { continue; } int i = featureHeader.indexOf(":"); if (i < 0) { continue; } return line; } return featureHeader; }
getFeatureName
44,373
void (TestCaseStarted event) { CucumberJvm2SMFormatter.this.handleTestCaseStarted(new CucumberJvm2Adapter.CucumberJvmTestCase(event.testCase)); }
receive
44,374
void (TestCaseFinished event) { handleTestCaseFinished(new CucumberJvm2Adapter.CucumberJvmTestCase(event.testCase)); }
receive
44,375
void (TestRunFinished event) { CucumberJvm2SMFormatter.this.handleTestRunFinished(); }
receive
44,376
void (WriteEvent event) { CucumberJvm2SMFormatter.this.handleWriteEvent(new CucumberJvmWriteEvent(event.text)); }
receive
44,377
void (TestStepStarted event) { handleTestStepStarted(new CucumberJvm2Adapter.CucumberJvmTestStep(event.testStep)); }
receive
44,378
void (TestStepFinished event) { handleTestStepFinished(new CucumberJvm2Adapter.CucumberJvmTestStepFinishedEvent(event)); }
receive
44,379
void (TestSourceRead event) { CucumberJvm2SMFormatter.this.handleTestSourceRead(new CucumberJvmTestSourceReadEvent(event.uri, event.source)); }
receive
44,380
void (EventPublisher publisher) { publisher.registerHandlerFor(TestCaseStarted.class, this.testCaseStartedHandler); publisher.registerHandlerFor(TestCaseFinished.class, this.testCaseFinishedHandler); publisher.registerHandlerFor(TestStepStarted.class, this.testStepStartedHandler); publisher.registerHandlerFor(TestStepF...
setEventPublisher
44,381
void (Feature feature) { if (currentFeatureName != null) { done(); } currentFeatureName = "Feature: " + getName(feature); outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ":" + feature.getLine(), currentFeatureName); }
feature
44,382
boolean (final Scenario scenario) { return scenario.getKeyword().equals("Scenario"); }
isRealScenario
44,383
void (Scenario scenario) { closeScenario(); outCommand(TEMPLATE_SCENARIO_STARTED, getCurrentTime()); if (isRealScenario(scenario)) { scenarioCount++; closeScenarioOutline(); currentSteps.clear(); } currentScenario = scenario; beforeExampleSection = false; outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ...
scenario
44,384
void (ScenarioOutline outline) { scenarioCount++; queue.clear(); currentSteps.clear(); closePreviousScenarios(); currentScenarioOutline = outline; currentScenario = null; beforeExampleSection = true; outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ":" + outline.getLine(), getName(currentScenarioOutline)...
scenarioOutline
44,385
void (Examples examples) { beforeExampleSection = false; outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ":" + examples.getLine(), "Examples:"); }
examples
44,386
void (Scenario scenario) { }
startOfScenarioLifeCycle
44,387
void (Step step) { if (beforeExampleSection) { return; } currentSteps.add(step); }
step
44,388
void (Scenario scenario) { }
endOfScenarioLifeCycle
44,389
void (Result result) { stepCount++; Step currentStep = currentSteps.poll(); outCommand(TEMPLATE_TEST_STARTED, true, getCurrentTime(), uri + ":" + currentStep.getLine(), getName(currentStep)); String stepFullName = getName(currentStep); if (result.getStatus().equals(Result.FAILED)) { failedStepCount++; scenarioPassed = ...
result
44,390
void () { if (currentScenario != null) { if (isRealScenario(currentScenario)) { if (scenarioPassed) { passedScenarioCount++; } } if (!scenarioPassed) { outCommand(TEMPLATE_SCENARIO_FAILED, true, getCurrentTime()); } outCommand(TEMPLATE_SCENARIO_FINISHED, true, getCurrentTime()); outCommand(TEMPLATE_TEST_SUITE_FINISHED,...
closeScenario
44,391
void () { if (currentScenarioOutline != null) { if (scenarioPassed) { passedScenarioCount++; } if (!beforeExampleSection) { outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), "Examples:"); } outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getName(currentScenarioOutline)); } currentScenarioOutline = n...
closeScenarioOutline
44,392
void () { closeScenario(); closeScenarioOutline(); }
closePreviousScenarios
44,393
void (Background background) { closeScenario(); currentScenario = null; }
background
44,394
void () { closePreviousScenarios(); outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), currentFeatureName); }
done
44,395
void (String s) { String currentDir = System.getProperty("org.jetbrains.run.directory"); if (currentDir != null) { uri = FILE_RESOURCE_PREFIX + currentDir + File.separator + s; } else { uri = FILE_RESOURCE_PREFIX + s; } }
uri
44,396
void () { }
eof
44,397
void (String s, String s1, List<String> strings, String s2, Integer integer) { outCommand("Syntax error\n"); }
syntaxError
44,398
void (Match match, Result result) { }
after
44,399
void (Match match) { }
match