From 64581b2d53e81159919b35ead584d0d76f312114 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 16:06:27 +0400 Subject: [PATCH 01/10] anonymous class can't have constructor (IDEA-91071) --- .../daemon/impl/analysis/HighlightMethodUtil.java | 6 ++++-- .../advHighlighting/InvalidExpressions.java | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 9bda079a5260..8c1c539d010b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -806,10 +806,12 @@ public class HighlightMethodUtil { if (aClass != null) { String className = aClass instanceof PsiAnonymousClass ? null : aClass.getName(); - if (className != null && !Comparing.strEqual(methodName, className)) { + if (className == null || !Comparing.strEqual(methodName, className)) { errorResult = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, method.getNameIdentifier(), JavaErrorMessages.message("missing.return.type")); - QuickFixAction.registerQuickFixAction(errorResult, new RenameElementFix(method, className)); + if (className != null) { + QuickFixAction.registerQuickFixAction(errorResult, new RenameElementFix(method, className)); + } } } return errorResult; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java index 91315f1707f3..79ab2bdd2748 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java @@ -99,6 +99,12 @@ public class a12 { public foo() { } + { + new Object() { + Object() {} + }; + } + // do not warn about illegal type in incomplete declarations (http://www.intellij.net/tracker/idea/viewSCR?publicId=9586) void foo } From 61f80166a6a3864754cd5b16aecfb2b92ac0cd2a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 17:43:08 +0400 Subject: [PATCH 02/10] EA-39070 - assert: RenameProcessor. --- .../src/com/intellij/refactoring/rename/RenameProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java index a6dbc002cb77..6f2e687b8a76 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java @@ -199,7 +199,7 @@ public class RenameProcessor extends BaseRefactoringProcessor { } protected static void assertNonCompileElement(PsiElement element) { - LOG.assertTrue(!(element instanceof PsiCompiledElement)); + LOG.assertTrue(!(element instanceof PsiCompiledElement), element); } private boolean findRenamedVariables(final List variableUsages) { From b2d6e4266f3288edef794f1c37b41f74f5f8780a Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 17:56:43 +0400 Subject: [PATCH 03/10] EA-38866 - AIOOBE: ParameterCanBeLocalInspection$ConvertParameterToLocalQuickFix.applyChanges --- .../ParameterCanBeLocalInspection.java | 9 ++++++--- .../afterUpdateCallers1.java | 12 ++++++++++++ .../beforeUpdateCallers1.java | 12 ++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/afterUpdateCallers1.java create mode 100644 java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/beforeUpdateCallers1.java diff --git a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java index 43a95af1c708..e933ff89de25 100644 --- a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java @@ -159,13 +159,16 @@ public class ParameterCanBeLocalInspection extends BaseJavaLocalInspectionTool { final PsiMethod method = (PsiMethod)scope; final PsiParameter[] parameters = method.getParameterList().getParameters(); - final ParameterInfoImpl[] info = new ParameterInfoImpl[parameters.length - 1]; + final List info = new ArrayList(); for (int i = 0; i < parameters.length; i++) { PsiParameter psiParameter = parameters[i]; if (psiParameter == parameter) continue; - info[i] = new ParameterInfoImpl(i, psiParameter.getName(), psiParameter.getType()); + info.add(new ParameterInfoImpl(i, psiParameter.getName(), psiParameter.getType())); } - final ChangeSignatureProcessor cp = new ChangeSignatureProcessor(project, method, false, VisibilityUtil.getVisibilityModifier(method.getModifierList()), method.getName(), method.getReturnType(), info){ + final ParameterInfoImpl[] newParams = info.toArray(new ParameterInfoImpl[info.size()]); + final String visibilityModifier = VisibilityUtil.getVisibilityModifier(method.getModifierList()); + final ChangeSignatureProcessor cp = new ChangeSignatureProcessor(project, method, false, visibilityModifier, + method.getName(), method.getReturnType(), newParams) { @Override protected void performRefactoring(UsageInfo[] usages) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); diff --git a/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/afterUpdateCallers1.java b/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/afterUpdateCallers1.java new file mode 100644 index 000000000000..b9c031872b39 --- /dev/null +++ b/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/afterUpdateCallers1.java @@ -0,0 +1,12 @@ +// "Convert to local variable" "true" +class Temp { + + void foo(int k) { + int x = 5; + System.out.println(x); + } + + void bar() { + foo(42); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/beforeUpdateCallers1.java b/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/beforeUpdateCallers1.java new file mode 100644 index 000000000000..e84b3737f8ca --- /dev/null +++ b/java/java-tests/testData/inspection/quickFix/ConvertParameterToLocalVariable/beforeUpdateCallers1.java @@ -0,0 +1,12 @@ +// "Convert to local variable" "true" +class Temp { + + void foo(int x, int k) { + x = 5; + System.out.println(x); + } + + void bar() { + foo(2, 42); + } +} \ No newline at end of file From 3be42e32b9456aa2cc1085cea5d53ad6317865fa Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 18:09:15 +0400 Subject: [PATCH 04/10] EA-38845 - CCE: AnonymousToInnerHandler.createClass forbid to convert to inner enum constants --- .../anonymousToInner/AnonymousToInnerHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java index 5ae7c8613e07..71a0c9508a8d 100644 --- a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java @@ -76,6 +76,11 @@ public class AnonymousToInnerHandler implements RefactoringActionHandler { showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.anonymous"))); return; } + final PsiElement parent = anonymousClass.getParent(); + if (parent instanceof PsiEnumConstant) { + showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage("Enum constant can't be converted to inner class")); + return; + } invoke(project, editor, anonymousClass); } From 18794d8e3e31494d2415ff2d78ca3ff2ab38f86e Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 18:32:44 +0400 Subject: [PATCH 05/10] NPE in command line apps --- .../com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java index 86b979f949fd..8497a49f7eba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java @@ -142,10 +142,9 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo @Override public void setNoCopyJarForPath(String pathInJar) { - if (myNoCopyJarPaths == null) { + if (myNoCopyJarPaths == null || pathInJar == null) { return; } - int index = pathInJar.indexOf(JAR_SEPARATOR); if (index < 0) return; String path = pathInJar.substring(0, index); From 2140c64851bce0abf6d54eec08c75152ae2372e8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 10 Sep 2012 18:43:51 +0400 Subject: [PATCH 06/10] junit: notify when tests were interrupted with toolwindow close (IDEA-91113) --- .../execution/testframework/TestsUIUtil.java | 17 +++++++++++++---- .../intellij/execution/junit/TestObject.java | 12 +++++++++--- .../intellij/execution/junit/TestPackage.java | 4 ++-- .../configuration/TestNGRunnableState.java | 11 ++++++++++- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java index 4cd26f4f73d4..92a779cda874 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java @@ -96,7 +96,10 @@ public class TestsUIUtil { return null; } - public static void notifyByBalloon(@NotNull final Project project, final AbstractTestProxy root, final TestConsoleProperties properties) { + public static void notifyByBalloon(@NotNull final Project project, + boolean started, + final AbstractTestProxy root, + final TestConsoleProperties properties) { if (project.isDisposed()) return; if (properties == null) return; @@ -107,7 +110,7 @@ public class TestsUIUtil { String text; String balloonText; MessageType type; - TestResultPresentation testResultPresentation = new TestResultPresentation(root).getPresentation(); + TestResultPresentation testResultPresentation = new TestResultPresentation(root, started).getPresentation(); type = testResultPresentation.getType(); balloonText = testResultPresentation.getBalloonText(); title = testResultPresentation.getTitle(); @@ -157,13 +160,19 @@ public class TestsUIUtil { private static class TestResultPresentation { private AbstractTestProxy myRoot; + private boolean myStarted; private String myTitle; private String myText; private String myBalloonText; private MessageType myType; - public TestResultPresentation(AbstractTestProxy root) { + public TestResultPresentation(AbstractTestProxy root, boolean started) { myRoot = root; + myStarted = started; + } + + public TestResultPresentation(AbstractTestProxy root) { + this(root, true); } public String getTitle() { @@ -184,7 +193,7 @@ public class TestsUIUtil { public TestResultPresentation getPresentation() { if (myRoot == null) { - myBalloonText = myTitle = ExecutionBundle.message("test.not.started.progress.text"); + myBalloonText = myTitle = myStarted ? "Tests were interrupted" : ExecutionBundle.message("test.not.started.progress.text"); myText = ""; myType = MessageType.WARNING; } else{ diff --git a/plugins/junit/src/com/intellij/execution/junit/TestObject.java b/plugins/junit/src/com/intellij/execution/junit/TestObject.java index c3a1058f0df6..e59369b8b5e3 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestObject.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestObject.java @@ -288,6 +288,12 @@ public abstract class TestObject implements JavaCommandLine { handler.getErr().setPacketDispatcher(packetsReceiver, queue); handler.addProcessListener(new ProcessAdapter() { + private boolean myStarted = false; + @Override + public void startNotified(ProcessEvent event) { + myStarted = true; + } + @Override public void processTerminated(ProcessEvent event) { handler.removeProcessListener(this); @@ -304,7 +310,7 @@ public abstract class TestObject implements JavaCommandLine { unboundOutputRoot.flush(); packetsReceiver.checkTerminated(); final JUnitRunningModel model = packetsReceiver.getModel(); - notifyByBalloon(model, consoleProperties); + notifyByBalloon(model, myStarted, consoleProperties); } finally { if (ApplicationManager.getApplication().isUnitTestMode()) { @@ -355,8 +361,8 @@ public abstract class TestObject implements JavaCommandLine { return result; } - protected void notifyByBalloon(JUnitRunningModel model, JUnitConsoleProperties consoleProperties) { - TestsUIUtil.notifyByBalloon(myProject, model != null ? model.getRoot() : null, consoleProperties); + protected void notifyByBalloon(JUnitRunningModel model, boolean started, JUnitConsoleProperties consoleProperties) { + TestsUIUtil.notifyByBalloon(myProject, started, model != null ? model.getRoot() : null, consoleProperties); } protected JUnitProcessHandler createHandler(Executor executor) throws ExecutionException { diff --git a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java index 12adb15c78da..dbd83ba50b60 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java @@ -272,9 +272,9 @@ public class TestPackage extends TestObject { } @Override - protected void notifyByBalloon(JUnitRunningModel model, final JUnitConsoleProperties consoleProperties) { + protected void notifyByBalloon(JUnitRunningModel model, boolean started, final JUnitConsoleProperties consoleProperties) { if (myFoundTests) { - super.notifyByBalloon(model, consoleProperties); + super.notifyByBalloon(model, started, consoleProperties); } else { final String packageName = myConfiguration.getPackage(); diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java index e941dc21f7ad..c35b3c3ff0ea 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java @@ -133,6 +133,8 @@ public class TestNGRunnableState extends JavaCommandLineState { JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(config, processHandler, runnerSettings); final SearchingForTestsTask task = createSearchingForTestsTask(myServerSocket, config, myTempFile); processHandler.addProcessListener(new ProcessAdapter() { + private boolean myStarted = false; + @Override public void processTerminated(final ProcessEvent event) { unboundOutputRoot.flush(); @@ -157,7 +159,13 @@ public class TestNGRunnableState extends JavaCommandLineState { : (resultsView.getStatus() == MessageHelper.FAILED_TEST ? MessageType.ERROR : MessageType.INFO); - final String message = resultsView == null ? "Tests were not started" : resultsView.getStatusLine(); + final String message; + if (resultsView == null) { + message = myStarted ? "Tests were interrupted" : "Tests were not started"; + } + else { + message = resultsView.getStatusLine(); + } toolWindowManager.notifyByBalloon(testRunDebugId, type, message, null, null); TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project); } @@ -173,6 +181,7 @@ public class TestNGRunnableState extends JavaCommandLineState { unboundOutputRoot.setOutputFilePath(config.getOutputFilePath()); } client.prepareListening(listener, port); + myStarted = true; mySearchForTestIndicator = new BackgroundableProcessIndicator(task); ProgressManagerImpl.runProcessWithProgressAsynchronously(task, mySearchForTestIndicator); } From 99f4c595ebffd4d97f8de83affc3e9b2373b3992 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 10 Sep 2012 16:49:47 +0200 Subject: [PATCH 07/10] use FileUtil.fileEquals for file comparison --- .../impl/packagingCompiler/FileCopyInstructionImpl.java | 3 ++- .../com/intellij/openapi/deployment/DeploymentUtilImpl.java | 3 +-- .../instructions/ArtifactInstructionsBuilderImpl.java | 2 +- .../instructions/FileBasedArtifactRootDescriptor.java | 2 +- .../org/jetbrains/jps/incremental/java/CopyResourcesUtil.java | 4 ++-- .../src/com/intellij/platform/ModuleAttachProcessor.java | 2 +- .../src/org/jetbrains/jps/android/AndroidJpsUtil.java | 2 +- .../jetbrains/jps/android/AndroidSourceGeneratingBuilder.java | 2 +- .../org/jetbrains/android/compiler/AndroidCompileUtil.java | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java index 9dc9aa2f60de..64b58555f151 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java @@ -17,6 +17,7 @@ package com.intellij.compiler.impl.packagingCompiler; import com.intellij.openapi.compiler.make.BuildInstructionVisitor; import com.intellij.openapi.compiler.make.FileCopyInstruction; +import com.intellij.openapi.util.io.FileUtil; import java.io.File; @@ -43,7 +44,7 @@ public class FileCopyInstructionImpl extends BuildInstructionBase implements Fil final FileCopyInstruction item = (FileCopyInstruction) o; - if (getFile() != null ? !getFile().equals(item.getFile()) : item.getFile() != null) return false; + if (getFile() != null ? !FileUtil.filesEqual(getFile(), item.getFile()) : item.getFile() != null) return false; if (getOutputRelativePath() != null) { if (!getOutputRelativePath().equals( item.getOutputRelativePath() )) return false; diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java index d57d0f3c8d5b..d36d28f10058 100644 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java +++ b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java @@ -70,8 +70,7 @@ public class DeploymentUtilImpl extends DeploymentUtil { CompilerBundle.message("message.text.destination.is.directory", createCopyErrorMessage(fromFile, toFile)), null, -1, -1); return; } - if (fromFile.equals(toFile) - || writtenPaths != null && !writtenPaths.add(toFile.getPath())) { + if (FileUtil.filesEqual(fromFile, toFile) || writtenPaths != null && !writtenPaths.add(toFile.getPath())) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping " + fromFile.getAbsolutePath() + ": " + toFile.getAbsolutePath() + " is already written"); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactInstructionsBuilderImpl.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactInstructionsBuilderImpl.java index 6577b2c8201b..14500e7d6979 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactInstructionsBuilderImpl.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactInstructionsBuilderImpl.java @@ -38,7 +38,7 @@ public class ArtifactInstructionsBuilderImpl implements ArtifactInstructionsBuil public boolean addDestination(@NotNull ArtifactRootDescriptor descriptor, @NotNull DestinationInfo destinationInfo) { if (destinationInfo instanceof ExplodedDestinationInfo && descriptor instanceof FileBasedArtifactRootDescriptor - && descriptor.getRootFile().equals(new File(FileUtil.toSystemDependentName(destinationInfo.getOutputFilePath())))) { + && FileUtil.filesEqual(descriptor.getRootFile(), new File(FileUtil.toSystemDependentName(destinationInfo.getOutputFilePath())))) { return false; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/FileBasedArtifactRootDescriptor.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/FileBasedArtifactRootDescriptor.java index c8293b1266c3..a0fc86b28ff9 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/FileBasedArtifactRootDescriptor.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/FileBasedArtifactRootDescriptor.java @@ -35,7 +35,7 @@ public class FileBasedArtifactRootDescriptor extends ArtifactRootDescriptor { final File file = new File(FileUtil.toSystemDependentName(filePath)); if (!file.exists()) return; String targetPath; - if (!file.equals(getRootFile())) { + if (!FileUtil.filesEqual(file, getRootFile())) { final String relativePath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(getRootFile().getPath()), filePath, '/'); targetPath = JpsPathUtil.appendToPath(outputPath, relativePath); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/CopyResourcesUtil.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/CopyResourcesUtil.java index 77ac5210ff7f..dd799fa43b3d 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/CopyResourcesUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/CopyResourcesUtil.java @@ -34,7 +34,7 @@ public final class CopyResourcesUtil { final File file = new File(targetDir, className + ".class"); FileUtil.createParentDirs(file); if (deleteOnExit) { - for (File f = file; f != null && !f.equals(targetDir); f = f.getParentFile()) { + for (File f = file; f != null && !FileUtil.filesEqual(f, targetDir); f = FileUtil.getParentFile(f)) { f.deleteOnExit(); } } @@ -66,7 +66,7 @@ public final class CopyResourcesUtil { final File targetDir = new File(targetPath).getAbsoluteFile(); final File file = new File(targetDir, fileName); FileUtil.createParentDirs(file); - for (File f = file; f != null && !f.equals(targetDir); f = f.getParentFile()) { + for (File f = file; f != null && !FileUtil.filesEqual(f, targetDir); f = FileUtil.getParentFile(f)) { f.deleteOnExit(); } final String resourceName = "/" + fileName; diff --git a/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java b/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java index 94da68fb6c47..e320de2e4f6a 100644 --- a/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java +++ b/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java @@ -130,7 +130,7 @@ public class ModuleAttachProcessor extends ProjectAttachProcessor { if (mappings.size() == 1) { final VirtualFile[] contentRoots = ModuleRootManager.getInstance(primaryModule).getContentRoots(); // if we had one mapping for the root of the primary module and the added module uses the same VCS, change mapping to - if (contentRoots.length == 1 && new File(contentRoots[0].getPath()).equals(new File(mappings.get(0).getDirectory()))) { + if (contentRoots.length == 1 && FileUtil.filesEqual(new File(contentRoots[0].getPath()), new File(mappings.get(0).getDirectory()))) { final AbstractVcs vcs = vcsManager.findVersioningVcs(addedModuleContentRoot); if (vcs != null && vcs.getName().equals(mappings.get(0).getVcs())) { vcsManager.setDirectoryMappings(Arrays.asList(new VcsDirectoryMapping("", vcs.getName()))); diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java index 4fb5d94ac8f3..35f526e530c0 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidJpsUtil.java @@ -533,7 +533,7 @@ class AndroidJpsUtil { if ((JavaSourceRootType.SOURCE.equals(root.getRootType()) || JavaSourceRootType.TEST_SOURCE.equals(root.getRootType()) && extension != null && extension.isPackTestCode()) - && !rootDir.equals(resDir) && !rootDir.equals(resDirForCompilation)) { + && !FileUtil.filesEqual(rootDir, resDir) && !rootDir.equals(resDirForCompilation)) { result.add(rootDir); } } diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java index e7a8fbcb8ca2..bccbd1cc911f 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java @@ -910,7 +910,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { return null; } - if (parent.equals(sourceRoot)) { + if (FileUtil.filesEqual(parent, sourceRoot)) { return genFolder.getPath(); } final String relativePath = FileUtil.getRelativePath(sourceRoot, parent); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java index f11134d4e9a0..b144d899e86b 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java @@ -485,7 +485,7 @@ public class AndroidCompileUtil { try { f = f.getCanonicalFile(); classFile = classFile != null ? classFile.getCanonicalFile() : null; - if (f != null && !f.equals(classFile) && f.exists()) { + if (f != null && !FileUtil.filesEqual(f, classFile) && f.exists()) { if (f.delete()) { virtualFile.refresh(true, false); } From 396e234568840f6c705718754c124b73b10380a1 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 10 Sep 2012 16:53:21 +0200 Subject: [PATCH 08/10] temporary rollback: do not store file paths in lowercased form for case-insensitive file systems --- .../jps/builders/java/dependencyView/DependencyContext.java | 5 ++--- .../testSrc/org/jetbrains/ether/ClassRenameTest.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/DependencyContext.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/DependencyContext.java index 27ac0e972ef9..75b842cbb7de 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/DependencyContext.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/DependencyContext.java @@ -1,6 +1,5 @@ package org.jetbrains.jps.builders.java.dependencyView; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.io.PersistentStringEnumerator; @@ -9,7 +8,6 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; import java.util.HashMap; -import java.util.Locale; import java.util.Map; /** @@ -92,7 +90,8 @@ class DependencyContext { return myEmptyName; } final String _path = FileUtil.toSystemIndependentName(path); - return myEnumerator.enumerate(SystemInfo.isFileSystemCaseSensitive ? _path : _path.toLowerCase(Locale.US)); + //return myEnumerator.enumerate(SystemInfo.isFileSystemCaseSensitive ? _path : _path.toLowerCase(Locale.US)); + return myEnumerator.enumerate(_path); } catch (IOException e) { throw new RuntimeException(e); diff --git a/jps/jps-builders/testSrc/org/jetbrains/ether/ClassRenameTest.java b/jps/jps-builders/testSrc/org/jetbrains/ether/ClassRenameTest.java index b9b29422f803..a24513a30a9f 100644 --- a/jps/jps-builders/testSrc/org/jetbrains/ether/ClassRenameTest.java +++ b/jps/jps-builders/testSrc/org/jetbrains/ether/ClassRenameTest.java @@ -16,7 +16,7 @@ public class ClassRenameTest extends IncrementalTestCase { doTest().assertSuccessful(); } - public void testChangeCaseOfName() { + public void _testChangeCaseOfName() { doTest().assertSuccessful(); } } From eb72629b57bb3772b579ecf8c399a8765a81028d Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 10 Sep 2012 16:02:53 +0200 Subject: [PATCH 09/10] ok, not @NotNull (EA-36166) --- platform/util/src/com/intellij/openapi/util/text/StringUtil.java | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 7287600249de..55ef2708b922 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -134,7 +134,6 @@ public class StringUtil extends StringUtilRt { return newBuffer == null ? buffer : newBuffer.toString(); } - @NotNull public static String replace(@NotNull final String text, @NotNull final String oldS, @Nullable final String newS, boolean ignoreCase) { if (text.length() < oldS.length()) return text; From 2d5457e37c1bbae66faff05b842441ccaf9d423d Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 10 Sep 2012 17:31:10 +0200 Subject: [PATCH 10/10] use file hashing strategy for set of files --- .../jps/incremental/ModuleLevelBuilder.java | 18 +++++---- .../jps/incremental/ModuleRootsIndex.java | 5 ++- .../jps/incremental/java/JavaBuilder.java | 40 ++++++++++++++----- .../jps/incremental/java/OutputFilesSink.java | 6 ++- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java index 818692023eac..c3a8d86884b4 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleLevelBuilder.java @@ -3,10 +3,12 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; -import org.jetbrains.jps.builders.java.dependencyView.Callbacks; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; +import com.intellij.openapi.util.io.FileUtil; +import gnu.trove.THashSet; import org.jetbrains.jps.ModuleChunk; import org.jetbrains.jps.ProjectPaths; +import org.jetbrains.jps.builders.java.dependencyView.Callbacks; +import org.jetbrains.jps.builders.java.dependencyView.Mappings; import org.jetbrains.jps.incremental.fs.RootDescriptor; import org.jetbrains.jps.incremental.messages.ProgressMessage; import org.jetbrains.jps.incremental.storage.SourceToOutputMapping; @@ -87,7 +89,8 @@ public abstract class ModuleLevelBuilder extends Builder { // unmark as affected all successfully compiled allAffectedFiles.removeAll(successfullyCompiled); - final HashSet affectedBeforeDif = new HashSet(allAffectedFiles); + final Set affectedBeforeDif = new THashSet(FileUtil.FILE_HASHING_STRATEGY); + affectedBeforeDif.addAll(allAffectedFiles); final ModulesBasedFileFilter moduleBasedFilter = new ModulesBasedFileFilter(context, chunk); final boolean incremental = globalMappings.differentiateOnIncrementalMake( @@ -110,8 +113,7 @@ public abstract class ModuleLevelBuilder extends Builder { if (incremental) { final Set newlyAffectedFiles = new HashSet(allAffectedFiles); newlyAffectedFiles.removeAll(affectedBeforeDif); - newlyAffectedFiles - .removeAll(allCompiledFiles); // the diff operation may have affected the class already compiled in thic compilation round + newlyAffectedFiles.removeAll(allCompiledFiles); // the diff operation may have affected the class already compiled in thic compilation round final String infoMessage = "Dependency analysis found " + newlyAffectedFiles.size() + " affected files"; LOG.info(infoMessage); @@ -211,7 +213,7 @@ public abstract class ModuleLevelBuilder extends Builder { private static Set getAllAffectedFilesContainer(CompileContext context) { Set allAffectedFiles = ALL_AFFECTED_FILES_KEY.get(context); if (allAffectedFiles == null) { - allAffectedFiles = new HashSet(); + allAffectedFiles = new THashSet(FileUtil.FILE_HASHING_STRATEGY); ALL_AFFECTED_FILES_KEY.set(context, allAffectedFiles); } return allAffectedFiles; @@ -220,7 +222,7 @@ public abstract class ModuleLevelBuilder extends Builder { private static Set getAllCompiledFilesContainer(CompileContext context) { Set allCompiledFiles = ALL_COMPILED_FILES_KEY.get(context); if (allCompiledFiles == null) { - allCompiledFiles = new HashSet(); + allCompiledFiles = new THashSet(FileUtil.FILE_HASHING_STRATEGY); ALL_COMPILED_FILES_KEY.set(context, allCompiledFiles); } return allCompiledFiles; @@ -231,7 +233,7 @@ public abstract class ModuleLevelBuilder extends Builder { if (map == null) { return Collections.emptySet(); } - final Set removed = new HashSet(); + final Set removed = new THashSet(FileUtil.PATH_HASHING_STRATEGY); for (ModuleBuildTarget target : chunk.getTargets()) { final Collection modulePaths = map.get(target); if (modulePaths != null) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleRootsIndex.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleRootsIndex.java index 22d43940e607..703b78befd91 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleRootsIndex.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleRootsIndex.java @@ -2,6 +2,7 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.JpsPathUtil; @@ -23,7 +24,7 @@ import java.util.*; * Date: 1/11/12 */ public class ModuleRootsIndex { - private final Map myRootToDescriptorMap = new HashMap(); + private final THashMap myRootToDescriptorMap = new THashMap(FileUtil.FILE_HASHING_STRATEGY); private final Map> myModuleToRootsMap = new HashMap>(); private final Map myNameToModuleMap = new HashMap(); private final int myTotalModuleCount; @@ -167,7 +168,7 @@ public class ModuleRootsIndex { public RootDescriptor associateRoot(@NotNull CompileContext context, File root, JpsModule module, boolean isTestRoot) { Map rootToDescriptorMap = ROOT_DESCRIPTOR_MAP.get(context); if (rootToDescriptorMap == null) { - rootToDescriptorMap = new HashMap(); + rootToDescriptorMap = new THashMap(FileUtil.FILE_HASHING_STRATEGY); ROOT_DESCRIPTOR_MAP.set(context, rootToDescriptorMap); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index bac5d4762266..43acf52556d3 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -8,6 +8,7 @@ import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.uiDesigner.compiler.AlienFormFileException; @@ -19,6 +20,7 @@ import com.intellij.uiDesigner.lw.CompiledClassPropertiesProvider; import com.intellij.uiDesigner.lw.LwRootContainer; import com.intellij.util.SystemProperties; import com.intellij.util.concurrency.SequentialTaskExecutor; +import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.asm4.ClassReader; @@ -82,16 +84,32 @@ public class JavaBuilder extends ModuleLevelBuilder { "-g", "-deprecation", "-nowarn", "-verbose" )); - private static final FileFilter JAVA_SOURCES_FILTER = new FileFilter() { - public boolean accept(File file) { - return file.getPath().endsWith(JAVA_EXTENSION); + private static final FileFilter JAVA_SOURCES_FILTER = + SystemInfo.isFileSystemCaseSensitive? + new FileFilter() { + public boolean accept(File file) { + return file.getPath().endsWith(JAVA_EXTENSION); + } + } : + new FileFilter() { + public boolean accept(File file) { + return StringUtil.endsWithIgnoreCase(file.getPath(), JAVA_EXTENSION); + } + }; + + private static final FileFilter FORM_SOURCES_FILTER = + SystemInfo.isFileSystemCaseSensitive? + new FileFilter() { + public boolean accept(File file) { + return file.getPath().endsWith(FORM_EXTENSION); + } + } : + new FileFilter() { + public boolean accept(File file) { + return StringUtil.endsWithIgnoreCase(file.getPath(), FORM_EXTENSION); + } } - }; - private static final FileFilter FORM_SOURCES_FILTER = new FileFilter() { - public boolean accept(File file) { - return file.getPath().endsWith(FORM_EXTENSION); - } - }; + ; private static final Key DELTA_MAPPINGS_CALLBACK_KEY = Key.create("_dependency_data_"); private final Executor myTaskRunner; @@ -153,8 +171,8 @@ public class JavaBuilder extends ModuleLevelBuilder { public ExitCode build(final CompileContext context, final ModuleChunk chunk) throws ProjectBuildException { try { - final Set filesToCompile = new HashSet(); - final Set formsToCompile = new HashSet(); + final Set filesToCompile = new THashSet(FileUtil.FILE_HASHING_STRATEGY); + final Set formsToCompile = new THashSet(FileUtil.FILE_HASHING_STRATEGY); FSOperations.processFilesToRecompile(context, chunk, new FileProcessor() { public boolean apply(ModuleBuildTarget target, File file, String sourceRoot) throws IOException { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFilesSink.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFilesSink.java index b0b0eec07afb..d99454548c92 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFilesSink.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/OutputFilesSink.java @@ -1,5 +1,7 @@ package org.jetbrains.jps.incremental.java; +import com.intellij.openapi.util.io.FileUtil; +import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.incremental.CompileContext; @@ -19,8 +21,8 @@ import java.util.*; */ class OutputFilesSink implements OutputFileConsumer { private final CompileContext myContextI; - private final Set mySuccessfullyCompiled = new LinkedHashSet(); - private final Set myProblematic = new HashSet(); + private final Set mySuccessfullyCompiled = new THashSet(FileUtil.FILE_HASHING_STRATEGY); + private final Set myProblematic = new THashSet(FileUtil.FILE_HASHING_STRATEGY); private final List myFileObjects = new ArrayList(); private final Map myCompiledClasses = new HashMap();