Cleanup (inlines unwarranted *Ex class)

GitOrigin-RevId: 2a842221145912d422dfd0b5ee659ce2e6f8e532
This commit is contained in:
Roman Shevchenko
2019-04-28 18:02:52 +03:00
committed by intellij-monorepo-bot
parent a9b41651ed
commit 8bd1811fdd
7 changed files with 56 additions and 119 deletions
@@ -11,7 +11,6 @@ import com.intellij.notification.NotificationListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.deployment.DeploymentUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -473,7 +472,7 @@ public class CompileDriver {
if (_status != ExitStatus.UP_TO_DATE && _status != ExitStatus.CANCELLED) {
// have to refresh in case of errors too, because run configuration may be set to ignore errors
Collection<String> affectedRoots = ContainerUtil.newHashSet(CompilerPathsEx.getOutputPaths(affectedModules));
Collection<String> affectedRoots = ContainerUtil.newHashSet(CompilerPaths.getOutputPaths(affectedModules));
if (!affectedRoots.isEmpty()) {
ProgressIndicator indicator = compileContext.getProgressIndicator();
indicator.setText("Synchronizing output directories...");
@@ -1,24 +1,10 @@
/*
* Copyright 2000-2017 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.
*/
// 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 com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
@@ -65,7 +51,7 @@ public final class OutputPathMacro extends Macro {
if (allModules.length == 0) {
return null;
}
String[] paths = CompilerPathsEx.getOutputPaths(allModules);
String[] paths = CompilerPaths.getOutputPaths(allModules);
final StringBuilder outputPath = new StringBuilder();
for (int idx = 0; idx < paths.length; idx++) {
String path = paths[idx];
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// 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 com.intellij.openapi.compiler;
import com.intellij.compiler.CompilerConfiguration;
@@ -25,15 +11,22 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.roots.CompilerModuleExtension;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderEnumerationHandler;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.OrderedSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
* A set of utility methods for working with paths
@@ -155,4 +148,35 @@ public class CompilerPaths {
return StringUtil.isEmpty(sourceDirName)? path : path + "/" + sourceDirName;
}
}
@NotNull
public static String[] getOutputPaths(@NotNull Module[] modules) {
Set<String> outputPaths = new OrderedSet<>();
for (Module module : modules) {
CompilerModuleExtension compilerModuleExtension = !module.isDisposed()? CompilerModuleExtension.getInstance(module) : null;
if (compilerModuleExtension == null) continue;
String outputPathUrl = compilerModuleExtension.getCompilerOutputUrl();
if (outputPathUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathUrl).replace('/', File.separatorChar));
}
String outputPathForTestsUrl = compilerModuleExtension.getCompilerOutputUrlForTests();
if (outputPathForTestsUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathForTestsUrl).replace('/', File.separatorChar));
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
for (OrderEnumerationHandler.Factory handlerFactory : OrderEnumerationHandler.EP_NAME.getExtensions()) {
if (handlerFactory.isApplicable(module)) {
OrderEnumerationHandler handler = handlerFactory.createHandler(module);
List<String> outputUrls = new SmartList<>();
handler.addCustomModuleRoots(OrderRootType.CLASSES, moduleRootManager, outputUrls, true, true);
for (String outputUrl : outputUrls) {
outputPaths.add(VirtualFileManager.extractPath(outputUrl).replace('/', File.separatorChar));
}
}
}
}
return ArrayUtil.toStringArray(outputPaths);
}
}
@@ -1,52 +1,8 @@
// 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.
// 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 com.intellij.openapi.compiler.ex;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.CompilerModuleExtension;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderEnumerationHandler;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.OrderedSet;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Set;
public class CompilerPathsEx extends CompilerPaths {
@NotNull
public static String[] getOutputPaths(@NotNull Module[] modules) {
Set<String> outputPaths = new OrderedSet<>();
for (Module module : modules) {
CompilerModuleExtension compilerModuleExtension = !module.isDisposed()? CompilerModuleExtension.getInstance(module) : null;
if (compilerModuleExtension == null) continue;
String outputPathUrl = compilerModuleExtension.getCompilerOutputUrl();
if (outputPathUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathUrl).replace('/', File.separatorChar));
}
String outputPathForTestsUrl = compilerModuleExtension.getCompilerOutputUrlForTests();
if (outputPathForTestsUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathForTestsUrl).replace('/', File.separatorChar));
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
for (OrderEnumerationHandler.Factory handlerFactory : OrderEnumerationHandler.EP_NAME.getExtensions()) {
if (handlerFactory.isApplicable(module)) {
OrderEnumerationHandler handler = handlerFactory.createHandler(module);
List<String> outputUrls = new SmartList<>();
handler.addCustomModuleRoots(OrderRootType.CLASSES, moduleRootManager, outputUrls, true, true);
for (String outputUrl : outputUrls) {
outputPaths.add(VirtualFileManager.extractPath(outputUrl).replace('/', File.separatorChar));
}
}
}
}
return ArrayUtil.toStringArray(outputPaths);
}
}
/** @deprecated use {@link CompilerPaths} */
@Deprecated
public class CompilerPathsEx extends CompilerPaths { }
@@ -13,7 +13,7 @@ import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
@@ -310,7 +310,7 @@ public class HotSwapUIImpl extends HotSwapUI {
private MyCompilationStatusListener() {
myOutputRoots = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) {
for (final String path : CompilerPaths.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) {
myOutputRoots.add(new File(path));
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 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.
*/
// 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 com.intellij.openapi.externalSystem.test;
import com.intellij.find.FindManager;
@@ -20,7 +6,7 @@ import com.intellij.find.findUsages.FindUsagesHandler;
import com.intellij.find.findUsages.FindUsagesManager;
import com.intellij.find.findUsages.FindUsagesOptions;
import com.intellij.find.impl.FindManagerImpl;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.externalSystem.importing.ImportSpec;
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder;
@@ -240,7 +226,7 @@ public abstract class ExternalSystemImportingTestCase extends ExternalSystemTest
}
protected void assertModuleOutputs(String moduleName, String... outputs) {
String[] outputPaths = ContainerUtil.map2Array(CompilerPathsEx.getOutputPaths(new Module[]{getModule(moduleName)}), String.class,
String[] outputPaths = ContainerUtil.map2Array(CompilerPaths.getOutputPaths(new Module[]{getModule(moduleName)}), String.class,
s -> getAbsolutePath(s));
assertUnorderedElementsAreEqual(outputPaths, outputs);
}
@@ -1,18 +1,4 @@
/*
* 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.
*/
// 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.gradle.execution.build;
import com.intellij.build.BuildViewManager;
@@ -23,7 +9,7 @@ import com.intellij.execution.configurations.RunConfigurationModule;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.externalSystem.model.DataNode;
import com.intellij.openapi.externalSystem.model.ProjectKeys;
import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings;
@@ -124,7 +110,7 @@ public class GradleProjectTaskRunner extends ProjectTaskRunner {
final List<Module> affectedModules = ContainerUtil.concat(modulesToBuild, modulesOfResourcesToBuild, modulesOfFiles);
// have to refresh in case of errors too, because run configuration may be set to ignore errors
Collection<String> affectedRoots = ContainerUtil.newHashSet(
CompilerPathsEx.getOutputPaths(affectedModules.toArray(Module.EMPTY_ARRAY)));
CompilerPaths.getOutputPaths(affectedModules.toArray(Module.EMPTY_ARRAY)));
if (!affectedRoots.isEmpty()) {
CompilerUtil.refreshOutputRoots(affectedRoots);
}