3030import com .intellij .java .language .psi .JavaPsiFacade ;
3131import com .intellij .java .language .psi .PsiJavaPackage ;
3232import consulo .application .Application ;
33- import consulo .component .extension .Extensions ;
3433import consulo .component .macro .PathMacroUtil ;
3534import consulo .content .bundle .Sdk ;
3635import consulo .disposer .Disposer ;
@@ -162,14 +161,14 @@ protected GeneralCommandLine createCommandLine() throws ExecutionException {
162161 @ Nonnull
163162 @ Override
164163 public ExecutionResult execute (@ Nonnull Executor executor , @ Nonnull ProgramRunner runner ) throws ExecutionException {
165- final RunnerSettings runnerSettings = getRunnerSettings ();
164+ RunnerSettings runnerSettings = getRunnerSettings ();
166165
167- final SMTRunnerConsoleProperties testConsoleProperties = getConfiguration ().createTestConsoleProperties (executor );
166+ SMTRunnerConsoleProperties testConsoleProperties = getConfiguration ().createTestConsoleProperties (executor );
168167 testConsoleProperties .setIdBasedTestTree (isIdBasedTestTree ());
169168 testConsoleProperties .setIfUndefined (TestConsoleProperties .HIDE_PASSED_TESTS , false );
170169
171- final BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil .createConsole (getFrameworkName (), testConsoleProperties );
172- final SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView )consoleView ).getResultsViewer ();
170+ BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil .createConsole (getFrameworkName (), testConsoleProperties );
171+ SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView )consoleView ).getResultsViewer ();
173172 Disposer .register (getConfiguration ().getProject (), consoleView );
174173
175174 final ProcessHandler handler = createHandler (executor );
@@ -187,7 +186,7 @@ public ExecutionResult execute(@Nonnull Executor executor, @Nonnull ProgramRunne
187186 @ Override
188187 public void startNotified (@ Nonnull ProcessEvent event ) {
189188 if (getConfiguration ().isSaveOutputToFile ()) {
190- final File file = OutputFileUtil .getOutputFile (getConfiguration ());
189+ File file = OutputFileUtil .getOutputFile (getConfiguration ());
191190 root .setOutputFilePath (file != null ? file .getAbsolutePath () : null );
192191 }
193192 }
@@ -209,7 +208,7 @@ public void processTerminated(@Nonnull ProcessEvent event) {
209208 LOG .assertTrue (rerunFailedTestsAction != null );
210209 rerunFailedTestsAction .setModelProvider (() -> viewer );
211210
212- final DefaultExecutionResult result = new DefaultExecutionResult (consoleView , handler );
211+ DefaultExecutionResult result = new DefaultExecutionResult (consoleView , handler );
213212 result .setRestartActions (rerunFailedTestsAction , new ToggleAutoTestAction () {
214213 @ Override
215214 public boolean isDelayApplicable () {
@@ -230,14 +229,14 @@ public AbstractAutoTestManager getAutoTestManager(Project project) {
230229
231230 @ Override
232231 protected OwnJavaParameters createJavaParameters () throws ExecutionException {
233- final OwnJavaParameters javaParameters = new OwnJavaParameters ();
232+ OwnJavaParameters javaParameters = new OwnJavaParameters ();
234233 Project project = getConfiguration ().getProject ();
235- final Module module = getConfiguration ().getConfigurationModule ().getModule ();
234+ Module module = getConfiguration ().getConfigurationModule ().getModule ();
236235
237236 Sdk jdk = module == null ? null : ModuleUtilCore .getSdk (module , JavaModuleExtension .class );
238237 javaParameters .setJdk (jdk );
239238
240- final String parameters = getConfiguration ().getProgramParameters ();
239+ String parameters = getConfiguration ().getProgramParameters ();
241240 getConfiguration ().setProgramParameters (null );
242241 try {
243242 JavaParametersUtil .configureConfiguration (javaParameters , getConfiguration ());
@@ -248,7 +247,7 @@ protected OwnJavaParameters createJavaParameters() throws ExecutionException {
248247 javaParameters .getClassPath ().addFirst (JavaSdkUtil .getJavaRtJarPath ());
249248 configureClasspath (javaParameters );
250249
251- final JavaTestPatcher [] patchers = JavaTestPatcher .EP_NAME .getExtensions ();
250+ JavaTestPatcher [] patchers = JavaTestPatcher .EP_NAME .getExtensions ();
252251 for (JavaTestPatcher patcher : patchers ) {
253252 patcher .patchJavaParameters (module , javaParameters );
254253 }
@@ -291,37 +290,41 @@ public ServerSocket getForkSocket() {
291290 }
292291
293292 private boolean isExecutorDisabledInForkedMode () {
294- final RunnerSettings settings = getRunnerSettings ();
293+ RunnerSettings settings = getRunnerSettings ();
295294 return settings != null && !(settings instanceof GenericDebuggerRunnerSettings );
296295 }
297296
298297 protected void appendForkInfo (Executor executor ) throws ExecutionException {
299- final String forkMode = getForkMode ();
298+ String forkMode = getForkMode ();
300299 if (Comparing .strEqual (forkMode , "none" )) {
301300 if (forkPerModule ()) {
302301 if (isExecutorDisabledInForkedMode ()) {
303- final String actionName = executor .getStartActionText ().map (Presentation .NO_MNEMONIC ).get ();
304- throw new CantRunException ("'" + actionName + "' is disabled when per-module working directory is configured.<br/>" + "Please specify single working directory, or change test " +
305- "scope to single module." );
302+ String actionName = executor .getStartActionText ().map (Presentation .NO_MNEMONIC ).get ();
303+ throw new CantRunException (
304+ "'" + actionName + "' is disabled when per-module working directory is configured.<br/>" +
305+ "Please specify single working directory, or change test scope to single module."
306+ );
306307 }
307308 }
308309 else {
309310 return ;
310311 }
311312 }
312313 else if (isExecutorDisabledInForkedMode ()) {
313- final String actionName = executor .getStartActionText ().toLowerCase ().map (Presentation .NO_MNEMONIC ).get ();
314- throw new CantRunException (actionName + " is disabled in fork mode.<br/>Please change fork mode to <none> to " + actionName + "." );
314+ String actionName = executor .getStartActionText ().toLowerCase ().map (Presentation .NO_MNEMONIC ).get ();
315+ throw new CantRunException (
316+ actionName + " is disabled in fork mode.<br/>Please change fork mode to <none> to " + actionName + "."
317+ );
315318 }
316319
317- final OwnJavaParameters javaParameters = getJavaParameters ();
318- final Sdk jdk = javaParameters .getJdk ();
320+ OwnJavaParameters javaParameters = getJavaParameters ();
321+ Sdk jdk = javaParameters .getJdk ();
319322 if (jdk == null ) {
320323 throw new ExecutionException (ExecutionLocalize .runConfigurationErrorNoJdkSpecified ().get ());
321324 }
322325
323326 try {
324- final File tempFile = FileUtil .createTempFile ("command.line" , "" , true );
327+ File tempFile = FileUtil .createTempFile ("command.line" , "" , true );
325328 try (PrintWriter writer = new PrintWriter (tempFile , CharsetToolkit .UTF8 )) {
326329 if (forkPerModule ()) {
327330 writer .println ("use classpath jar" );
@@ -354,11 +357,11 @@ else if (isExecutorDisabledInForkedMode()) {
354357 protected abstract void passForkMode (String forkMode , File tempFile , OwnJavaParameters parameters ) throws ExecutionException ;
355358
356359 protected void collectListeners (OwnJavaParameters javaParameters , StringBuilder buf , Class epName , String delimiter ) {
357- final T configuration = getConfiguration ();
358- final Object [] listeners = Application .get ().getExtensionPoint (epName ).getExtensions ();
359- for (final Object listener : listeners ) {
360+ T configuration = getConfiguration ();
361+ Object [] listeners = Application .get ().getExtensionPoint (epName ).getExtensions ();
362+ for (Object listener : listeners ) {
360363 boolean enabled = true ;
361- for (RunConfigurationExtension ext : Extensions . getExtensions ( RunConfigurationExtension .EP_NAME )) {
364+ for (RunConfigurationExtension ext : RunConfigurationExtension .EP_NAME . getExtensions ( )) {
362365 if (ext .isListenerDisabled (configuration , listener , getRunnerSettings ())) {
363366 enabled = false ;
364367 break ;
@@ -368,19 +371,19 @@ protected void collectListeners(OwnJavaParameters javaParameters, StringBuilder
368371 if (buf .length () > 0 ) {
369372 buf .append (delimiter );
370373 }
371- final Class classListener = listener .getClass ();
374+ Class classListener = listener .getClass ();
372375 buf .append (classListener .getName ());
373376 javaParameters .getClassPath ().add (ClassPathUtil .getJarPathForClass (classListener ));
374377 }
375378 }
376379 }
377380
378- protected void configureClasspath (final OwnJavaParameters javaParameters ) throws CantRunException {
381+ protected void configureClasspath (OwnJavaParameters javaParameters ) throws CantRunException {
379382 configureRTClasspath (javaParameters );
380383 RunConfigurationModule module = getConfiguration ().getConfigurationModule ();
381- final String alternativeJreName =
384+ String alternativeJreName =
382385 getConfiguration ().isAlternativeJrePathEnabled () ? getConfiguration ().getAlternativeJrePath () : null ;
383- final int pathType = OwnJavaParameters .JDK_AND_CLASSES_AND_TESTS ;
386+ int pathType = OwnJavaParameters .JDK_AND_CLASSES_AND_TESTS ;
384387 if (configureByModule (module .getModule ())) {
385388 JavaParametersUtil .configureModule (module , javaParameters , pathType , alternativeJreName );
386389 }
@@ -399,18 +402,18 @@ protected void createServerSocket(OwnJavaParameters javaParameters) {
399402 }
400403 }
401404
402- protected boolean spansMultipleModules (final String qualifiedName ) {
405+ protected boolean spansMultipleModules (String qualifiedName ) {
403406 if (qualifiedName != null ) {
404- final Project project = getConfiguration ().getProject ();
405- final PsiJavaPackage aPackage = JavaPsiFacade .getInstance (project ).findPackage (qualifiedName );
407+ Project project = getConfiguration ().getProject ();
408+ PsiJavaPackage aPackage = JavaPsiFacade .getInstance (project ).findPackage (qualifiedName );
406409 if (aPackage != null ) {
407- final TestSearchScope scope = getScope ();
410+ TestSearchScope scope = getScope ();
408411 if (scope != null ) {
409- final SourceScope sourceScope = scope .getSourceScope (getConfiguration ());
412+ SourceScope sourceScope = scope .getSourceScope (getConfiguration ());
410413 if (sourceScope != null ) {
411- final GlobalSearchScope configurationSearchScope =
414+ GlobalSearchScope configurationSearchScope =
412415 GlobalSearchScopesCore .projectTestScope (project ).intersectWith (sourceScope .getGlobalSearchScope ());
413- final PsiDirectory [] directories = aPackage .getDirectories (configurationSearchScope );
416+ PsiDirectory [] directories = aPackage .getDirectories (configurationSearchScope );
414417 return Arrays .stream (directories )
415418 .map (dir -> ModuleUtilCore .findModuleForFile (dir .getVirtualFile (), project ))
416419 .filter (Objects ::nonNull )
@@ -427,9 +430,10 @@ protected boolean spansMultipleModules(final String qualifiedName) {
427430 * Configuration based on package which spans multiple modules
428431 */
429432 protected boolean forkPerModule () {
430- final String workingDirectory = getConfiguration ().getWorkingDirectory ();
431- return getScope () != TestSearchScope .SINGLE_MODULE && ("$" + PathMacroUtil .MODULE_DIR_MACRO_NAME + "$" ).equals (workingDirectory ) && spansMultipleModules (
432- getConfiguration ().getPackage ());
433+ String workingDirectory = getConfiguration ().getWorkingDirectory ();
434+ return getScope () != TestSearchScope .SINGLE_MODULE
435+ && ("$" + PathMacroUtil .MODULE_DIR_MACRO_NAME + "$" ).equals (workingDirectory )
436+ && spansMultipleModules (getConfiguration ().getPackage ());
433437 }
434438
435439 protected void createTempFiles (OwnJavaParameters javaParameters ) {
@@ -445,13 +449,10 @@ protected void createTempFiles(OwnJavaParameters javaParameters) {
445449 }
446450 }
447451
448- protected void writeClassesPerModule (
449- String packageName ,
450- OwnJavaParameters javaParameters ,
451- Map <Module , List <String >> perModule
452- ) throws FileNotFoundException , UnsupportedEncodingException , CantRunException {
452+ protected void writeClassesPerModule (String packageName , OwnJavaParameters javaParameters , Map <Module , List <String >> perModule )
453+ throws FileNotFoundException , UnsupportedEncodingException , CantRunException {
453454 if (perModule != null ) {
454- final String classpath = getScope () == TestSearchScope .WHOLE_PROJECT ? null : javaParameters .getClassPath ().getPathsString ();
455+ String classpath = getScope () == TestSearchScope .WHOLE_PROJECT ? null : javaParameters .getClassPath ().getPathsString ();
455456
456457 try (PrintWriter wWriter = new PrintWriter (myWorkingDirsFile , CharsetToolkit .UTF8 )) {
457458 wWriter .println (packageName );
@@ -460,7 +461,7 @@ protected void writeClassesPerModule(
460461 wWriter .println (module .getName ());
461462
462463 if (classpath == null ) {
463- final OwnJavaParameters parameters = new OwnJavaParameters ();
464+ OwnJavaParameters parameters = new OwnJavaParameters ();
464465 parameters .getClassPath ().add (JavaSdkUtil .getJavaRtJarPath ());
465466 configureRTClasspath (parameters );
466467 JavaParametersUtil .configureModule (
@@ -476,7 +477,7 @@ protected void writeClassesPerModule(
476477 wWriter .println (classpath );
477478 }
478479
479- final List <String > classNames = perModule .get (module );
480+ List <String > classNames = perModule .get (module );
480481 wWriter .println (classNames .size ());
481482 for (String className : classNames ) {
482483 wWriter .println (className );
0 commit comments