mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: bf150dad2c2254bada135f7a0d458638de46de63
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c4d2bcc95
commit
945a38826d
@@ -15,34 +15,32 @@
|
||||
*/
|
||||
package com.intellij.java.psi;
|
||||
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public abstract class OptimizeImportsTestCase extends LightJavaCodeInsightFixtureTestCase {
|
||||
protected void doTest(final String extension) {
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
getProject(), () -> WriteCommandAction.runWriteCommandAction(null, () -> {
|
||||
String fileName = getTestName(false) + extension;
|
||||
try {
|
||||
PsiFile file = myFixture.configureByFile(fileName);
|
||||
|
||||
JavaCodeStyleManager.getInstance(getProject()).optimizeImports(file);
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after" + extension);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}), "", "");
|
||||
protected void doTest(@NotNull String extension) {
|
||||
WriteCommandAction.runWriteCommandAction(null, () -> {
|
||||
String fileName = getTestName(false) + extension;
|
||||
try {
|
||||
PsiFile file = myFixture.configureByFile(fileName);
|
||||
|
||||
JavaCodeStyleManager.getInstance(getProject()).optimizeImports(file);
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after" + extension);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -107,7 +107,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
protected AbstractLayoutCodeProcessor(@NotNull Project project,
|
||||
PsiDirectory directory,
|
||||
@NotNull PsiDirectory directory,
|
||||
boolean includeSubdirs,
|
||||
String progressText,
|
||||
String commandName,
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
protected AbstractLayoutCodeProcessor(@NotNull Project project,
|
||||
PsiFile file,
|
||||
@NotNull PsiFile file,
|
||||
String progressText,
|
||||
String commandName,
|
||||
boolean processChangedTextOnly) {
|
||||
@@ -137,7 +137,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
protected AbstractLayoutCodeProcessor(@NotNull Project project,
|
||||
PsiFile[] files,
|
||||
PsiFile @NotNull [] files,
|
||||
String progressText,
|
||||
String commandName,
|
||||
@Nullable Runnable postRunnable,
|
||||
|
||||
+9
-9
@@ -41,23 +41,23 @@ public class OptimizeImportsProcessor extends AbstractLayoutCodeProcessor {
|
||||
super(project, module, getCommandName(), getProgressText(), false);
|
||||
}
|
||||
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiDirectory directory, boolean includeSubdirs) {
|
||||
public OptimizeImportsProcessor(@NotNull Project project, @NotNull PsiDirectory directory, boolean includeSubdirs) {
|
||||
super(project, directory, includeSubdirs, getProgressText(), getCommandName(), false);
|
||||
}
|
||||
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiDirectory directory, boolean includeSubdirs, boolean processOnlyVcsChangedFiles) {
|
||||
public OptimizeImportsProcessor(@NotNull Project project, @NotNull PsiDirectory directory, boolean includeSubdirs, boolean processOnlyVcsChangedFiles) {
|
||||
super(project, directory, includeSubdirs, getProgressText(), getCommandName(), processOnlyVcsChangedFiles);
|
||||
}
|
||||
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiFile file) {
|
||||
public OptimizeImportsProcessor(@NotNull Project project, @NotNull PsiFile file) {
|
||||
super(project, file, getProgressText(), getCommandName(), false);
|
||||
}
|
||||
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiFile[] files, Runnable postRunnable) {
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiFile @NotNull [] files, Runnable postRunnable) {
|
||||
this(project, files, getCommandName(), postRunnable);
|
||||
}
|
||||
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiFile[] files, String commandName, Runnable postRunnable) {
|
||||
public OptimizeImportsProcessor(@NotNull Project project, PsiFile @NotNull [] files, String commandName, Runnable postRunnable) {
|
||||
super(project, files, getProgressText(), commandName, postRunnable, false);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class OptimizeImportsProcessor extends AbstractLayoutCodeProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
Runnable runnable = !runnables.isEmpty() ? () -> {
|
||||
Runnable runnable = runnables.isEmpty() ? EmptyRunnable.getInstance() : () -> {
|
||||
CodeStyleManagerImpl.setSequentialProcessingAllowed(false);
|
||||
try {
|
||||
for (Runnable runnable1 : runnables) {
|
||||
@@ -95,7 +95,7 @@ public class OptimizeImportsProcessor extends AbstractLayoutCodeProcessor {
|
||||
finally {
|
||||
CodeStyleManagerImpl.setSequentialProcessingAllowed(true);
|
||||
}
|
||||
} : EmptyRunnable.getInstance();
|
||||
};
|
||||
|
||||
return new FutureTask<>(runnable, true);
|
||||
}
|
||||
@@ -132,8 +132,8 @@ public class OptimizeImportsProcessor extends AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
static class NotificationInfo {
|
||||
public static final NotificationInfo NOTHING_CHANGED_NOTIFICATION = new NotificationInfo(false, null);
|
||||
public static final NotificationInfo SOMETHING_CHANGED_WITHOUT_MESSAGE_NOTIFICATION = new NotificationInfo(true, null);
|
||||
static final NotificationInfo NOTHING_CHANGED_NOTIFICATION = new NotificationInfo(false, null);
|
||||
static final NotificationInfo SOMETHING_CHANGED_WITHOUT_MESSAGE_NOTIFICATION = new NotificationInfo(true, null);
|
||||
|
||||
private final boolean mySomethingChanged;
|
||||
private final String myMessage;
|
||||
|
||||
+5
-3
@@ -86,7 +86,7 @@ public class GeneralCommandLine implements UserDataHolder {
|
||||
private ParentEnvironmentType myParentEnvironmentType = ParentEnvironmentType.CONSOLE;
|
||||
private final ParametersList myProgramParams = new ParametersList();
|
||||
private Charset myCharset = CharsetToolkit.getDefaultSystemCharset();
|
||||
private boolean myRedirectErrorStream = false;
|
||||
private boolean myRedirectErrorStream;
|
||||
private File myInputFile;
|
||||
private Map<Object, Object> myUserData;
|
||||
|
||||
@@ -391,14 +391,16 @@ public class GeneralCommandLine implements UserDataHolder {
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : myEnvParams.entrySet()) {
|
||||
String name = entry.getKey(), value = entry.getValue();
|
||||
String name = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
if (!EnvironmentUtil.isValidName(name)) throw new IllegalEnvVarException(IdeUtilIoBundle.message("run.configuration.invalid.env.name", name));
|
||||
if (!EnvironmentUtil.isValidValue(value)) throw new IllegalEnvVarException(IdeUtilIoBundle.message("run.configuration.invalid.env.value", name, value));
|
||||
}
|
||||
|
||||
String exePath = myExePath;
|
||||
if (SystemInfo.isMac && myParentEnvironmentType == ParentEnvironmentType.CONSOLE && exePath.indexOf(File.separatorChar) == -1) {
|
||||
String systemPath = System.getenv("PATH"), shellPath = EnvironmentUtil.getValue("PATH");
|
||||
String systemPath = System.getenv("PATH");
|
||||
String shellPath = EnvironmentUtil.getValue("PATH");
|
||||
if (!Objects.equals(systemPath, shellPath)) {
|
||||
File exeFile = PathEnvironmentVariableUtil.findInPath(myExePath, shellPath, null);
|
||||
if (exeFile != null) {
|
||||
|
||||
+1
-2
@@ -28,7 +28,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class ProcessListUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.impl.ProcessListUtil");
|
||||
private static final Logger LOG = Logger.getInstance(ProcessListUtil.class);
|
||||
private static final String WIN_PROCESS_LIST_HELPER_FILENAME = "WinProcessListHelper.exe";
|
||||
|
||||
public static ProcessInfo @NotNull [] getProcessList() {
|
||||
@@ -120,7 +120,6 @@ public final class ProcessListUtil {
|
||||
|
||||
List<String> cmdline;
|
||||
try (FileInputStream stream = new FileInputStream(new File(each, "cmdline"))) {
|
||||
//noinspection SSBasedInspection - no better candidate for system encoding anyways
|
||||
String cmdlineString = new String(FileUtil.loadBytes(stream), StandardCharsets.UTF_8);
|
||||
cmdline = StringUtil.split(cmdlineString, "\0");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user