void () { final String pathSpec; Set<Class<?>> importedClasses = StreamEx.of(myTools.stream().<Class<?>>map(wrapper -> wrapper.getTool().getClass())) .append(LightJavaCodeInsightFixtureTestCase.class, LightProjectDescriptor.class, NotNull.class) .toSet(); if (myBaseDir.startsWith(myBasePath)) { Path relativePath = myBasePath.relativize(myBaseDir); importedClasses.add(JavaTestUtil.class); pathSpec = "JavaTestUtil.getRelativeJavaTestDataPath() + \"/" + StringUtil.escapeStringCharacters(relativePath.toString().replace('\\', '/')) + '"'; } else { Path basePath = Paths.get(PathManagerEx.getCommunityHomePath()); if (myBaseDir.startsWith(basePath)) { Path relativePath = basePath.relativize(myBaseDir); String pathText = '/' + relativePath.toString().replace('\\', '/'); if (pathText.startsWith(LightJavaInspectionTestCase.INSPECTION_GADGETS_TEST_DATA_PATH)) { importedClasses.add(LightJavaInspectionTestCase.class); pathSpec = "LightJavaInspectionTestCase.INSPECTION_GADGETS_TEST_DATA_PATH + \"" + StringUtil.escapeStringCharacters( pathText.substring(LightJavaInspectionTestCase.INSPECTION_GADGETS_TEST_DATA_PATH.length())) + '"'; } else { pathSpec = '"' + StringUtil.escapeStringCharacters(pathText) + '"'; } } else { pathSpec = "\"!!! Unable to convert path!!! " + StringUtil.escapeStringCharacters(myBaseDir.toString()) + '"'; } } String imports = generateImports(importedClasses); String testMethods = myTestNames.stream().map(name -> " public void test"+name+"() {\n doTest();\n }\n\n").collect(Collectors.joining()); String inspections = myTools.stream().map(InspectionToolWrapper::getTool).map(InspectionProfileEntry::getClass).map(Class::getSimpleName) .map(name -> "new " + name + "()").collect(Collectors.joining(", ")); String year = Year.now().toString(); String classTemplate = MessageFormat.format( """ // Copyright 2000-{6} 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 {0}; {1} public class {2} extends LightCodeInsightFixtureTestCase '{' @Override protected String getBasePath() '{' return {3}; '}' private void doTest() '{' myFixture.enableInspections({4}); myFixture.testHighlighting(getTestName(false) + ".java"); '}' {5}'}' """, myTestClass.getPackage().getName(), imports, myTestClass.getSimpleName(), pathSpec, inspections, testMethods, year); System.out.println("Class template: (" + myTestClass.getSimpleName() + ".java)"); System.out.println("=============================="); System.out.println(classTemplate); System.out.println("=============================="); }