From b0a1963e9f7dfed703cc877c3ffb144799a55607 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 25 Jan 2013 16:13:14 +0400 Subject: [PATCH 01/36] IDEA-99783 Git log: for performance reasons, do not show stashed commits in git log (additional place - to do not load --all) --- plugins/git4idea/src/git4idea/history/GitHistoryUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 8238cbeaf916..4e2ce663ceb9 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -204,7 +204,7 @@ public class GitHistoryUtils { final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG); h.setNoSSH(true); h.setSilent(true); - h.addParameters("--all", "--pretty=format:%H%x20%ct%x0A", "--date-order", "--reverse", "--encoding=UTF-8", "--full-history", + h.addParameters("--branches", "--remotes", "--tags", "--pretty=format:%H%x20%ct%x0A", "--date-order", "--reverse", "--encoding=UTF-8", "--full-history", "--sparse"); h.endOptions(); From 4a8c9b38612a35d26613409a30363b1430997d16 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 16:13:34 +0400 Subject: [PATCH 02/36] [hg] IDEA-75801 already disposed --- .../zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java index d38fbbf03112..120fde117469 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java @@ -70,6 +70,9 @@ public class HgCurrentBranchStatusUpdater implements HgUpdater { handleUpdate(project, null, Collections.emptyList()); } else { + if (project.isDisposed()) { + return; + } Document document = textEditor.get().getDocument(); VirtualFile file = FileDocumentManager.getInstance().getFile(document); From a0e0761cd5f33dfe5f39481d71435333230c318b Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 25 Jan 2013 16:14:40 +0400 Subject: [PATCH 03/36] added FileUtilRt.getExtension method which doesn't convert to lower case to ensure correct behavior on case-sensitive FS (inspired by Jeka) --- .../impl/ui/actions/PackageFileWorker.java | 4 +++- .../importSources/JavaSourceRootDetector.java | 7 ++++--- .../artifacts/ArtifactEditorImpl.java | 3 ++- .../classpath/ChangeLibraryLevelActionBase.java | 7 +++++-- .../templates/TemplateModuleBuilder.java | 4 ++-- .../src/com/intellij/internal/BuildIcons.java | 13 +++++++------ .../fileTypes/impl/FileTypeAssocTable.java | 17 +++-------------- .../jps/model/serialization/JpsLoaderBase.java | 3 ++- .../com/intellij/core/CoreFileTypeRegistry.java | 7 ++++--- .../FilePathCompletionContributor.java | 4 ++-- .../library/impl/LibraryVersionsFetcher.java | 3 ++- .../intellij/ide/actions/CreateFileAction.java | 4 ++-- .../internal/psiView/PsiViewerDialog.java | 4 ++-- .../platform/ModuleAttachProcessor.java | 3 ++- .../psi/impl/file/impl/PsiVFSListener.java | 4 ++-- .../impl/DownloadableFileServiceImpl.java | 3 ++- .../impl/stores/ProjectStoreImpl.java | 3 ++- .../impl/stores/StateStorageManagerImpl.java | 4 ++-- .../openapi/util/text/TrigramBuilderTest.java | 8 +++++--- .../fixtures/CodeInsightTestUtil.java | 3 ++- .../intellij/openapi/util/io/FileUtilRt.java | 12 +++++++++++- .../com/intellij/openapi/util/io/FileUtil.java | 7 ++++++- .../util/src/com/intellij/util/ImageLoader.java | 3 ++- .../intellij/openapi/vcs/VcsConfiguration.java | 8 ++++---- .../actions/ChangeDiffRequestPresentable.java | 3 ++- .../shelf/CompoundShelfFileProcessor.java | 3 ++- .../vcs/changes/shelf/ShelveChangesManager.java | 3 ++- .../MoveClassToNewFileIntention.java | 4 ++-- .../RenameFileWithClassIntention.java | 4 ++-- .../template/XslTextContextType.java | 4 ++-- 30 files changed, 92 insertions(+), 67 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java index 6be07f023bb7..66f0be6d61e6 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java @@ -30,6 +30,7 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Trinity; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -159,7 +160,8 @@ public class PackageFileWorker { try { final JBZipEntry entry = zipFile.getOrCreateEntry(nextPathInArchive); LOG.debug(" extracting to temp file: " + nextPathInArchive + " from " + archivePath); - final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive), FileUtil.getExtension(PathUtil.getFileName(nextPathInArchive))); + final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive), + FileUtilRt.getExtension(PathUtil.getFileName(nextPathInArchive))); if (entry.getSize() != -1) { FileUtil.writeToFile(tempFile, entry.getData()); } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/JavaSourceRootDetector.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/JavaSourceRootDetector.java index 9b077fefd04f..460d7f50b1ad 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/JavaSourceRootDetector.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/JavaSourceRootDetector.java @@ -18,6 +18,7 @@ package com.intellij.ide.util.projectWizard.importSources; import com.intellij.ide.util.projectWizard.importSources.util.CommonSourceRootDetectionUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.NullableFunction; import org.jetbrains.annotations.NotNull; @@ -35,10 +36,10 @@ public abstract class JavaSourceRootDetector extends ProjectStructureDetector { final String fileExtension = getFileExtension(); for (File child : children) { if (child.isFile()) { - String extension = FileUtil.getExtension(child.getName()); - if (extension.equals(fileExtension)) { + if (FileUtilRt.extensionEquals(child.getName(), fileExtension)) { Pair root = CommonSourceRootDetectionUtil.IO_FILE.suggestRootForFileWithPackageStatement(child, base, - getPackageNameFetcher(), true); + getPackageNameFetcher(), + true); if (root != null) { result.add(new JavaModuleSourceRoot(root.getFirst(), root.getSecond(), getLanguageName())); return DirectoryProcessingResult.skipChildrenAndParentsUpTo(root.getFirst()); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java index b2ea31a2ec9d..cf7b201c0a70 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactEditorImpl.java @@ -39,6 +39,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.artifacts.Artifact; @@ -447,7 +448,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx { String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName); final String name = ((ArchivePackagingElement)root).getArchiveFileName(); final String fileName = FileUtil.getNameWithoutExtension(name); - final String extension = FileUtil.getExtension(name); + final String extension = FileUtilRt.getExtension(name); if (fileName.equals(oldFileName) && extension.length() > 0) { myLayoutTreeComponent.editLayout(new Runnable() { @Override diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java index c8f8b9719f69..e52cbd419d80 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ChangeLibraryLevelActionBase.java @@ -37,8 +37,11 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChangeLibraryLe import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -125,7 +128,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction { for (final File from : filesToProcess) { indicator.checkCanceled(); final File to = FileUtil.findSequentNonexistentFile(targetDir, FileUtil.getNameWithoutExtension(from), - FileUtil.getExtension(from.getName())); + FileUtilRt.getExtension(from.getName())); try { if (from.isDirectory()) { if (myCopy) { diff --git a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java index 2106e1e5b706..525aa27e1a77 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java +++ b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java @@ -38,7 +38,7 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.NullableComputable; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -157,7 +157,7 @@ public class TemplateModuleBuilder extends ModuleBuilder { ZipUtil.unzip(ProgressManager.getInstance().getProgressIndicator(), dir, zipInputStream, moduleMode ? PATH_CONVERTOR : null, new ZipUtil.ContentProcessor() { @Override public byte[] processContent(byte[] content, String fileName) throws IOException { - FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FileUtil.getExtension(fileName)); + FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FileUtilRt.getExtension(fileName)); return fileType.isBinary() ? content : processTemplates(new String(content)); } }); diff --git a/java/java-impl/src/com/intellij/internal/BuildIcons.java b/java/java-impl/src/com/intellij/internal/BuildIcons.java index 5eaeacab738d..13eacd15bc03 100644 --- a/java/java-impl/src/com/intellij/internal/BuildIcons.java +++ b/java/java-impl/src/com/intellij/internal/BuildIcons.java @@ -21,15 +21,14 @@ package com.intellij.internal; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import java.awt.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; +import java.util.*; public class BuildIcons { public static void main(String[] args) throws Exception { @@ -66,6 +65,9 @@ public class BuildIcons { System.out.println("Total icons: " + total); } + private static final Set IMAGE_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, + "png", "gif", "jpg", "jpeg"); + private static void walk(File root, MultiMap, String> dimToPath, File file) throws IOException { if (file.isDirectory()) { for (File child : file.listFiles()) { @@ -73,8 +75,7 @@ public class BuildIcons { } } else { - String extension = FileUtil.getExtension(file.getName()); - if ("png".equals(extension) || "gif".equals(extension) || "jpg".equals(extension) || "jpeg".equals(extension)) { + if (IMAGE_EXTENSIONS.contains(FileUtilRt.getExtension(file.getName()))) { String relativePath = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1); Image image = loadImage(file); File target; diff --git a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java index 820d66f069fe..8f6e14b55471 100644 --- a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java +++ b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java @@ -21,10 +21,9 @@ import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; import com.intellij.openapi.fileTypes.FileNameMatcher; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; +import com.intellij.util.text.CaseInsensitiveStringHashingStrategy; import gnu.trove.THashMap; -import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,17 +43,7 @@ public class FileTypeAssocTable { private FileTypeAssocTable(Map extensionMappings, Map exactFileNameMappings, Map exactFileNameAnyCaseMappings, List> matchingMappings) { myExtensionMappings = new THashMap(extensionMappings); myExactFileNameMappings = new THashMap(exactFileNameMappings); - myExactFileNameAnyCaseMappings = new THashMap(exactFileNameAnyCaseMappings, new TObjectHashingStrategy() { - @Override - public int computeHashCode(String object) { - return StringUtil.stringHashCodeInsensitive(object); - } - - @Override - public boolean equals(String o1, String o2) { - return o1.equalsIgnoreCase(o2); - } - }) { + myExactFileNameAnyCaseMappings = new THashMap(exactFileNameAnyCaseMappings, CaseInsensitiveStringHashingStrategy.INSTANCE) { @Override public T remove(Object key) { T removed = super.remove(key); @@ -188,7 +177,7 @@ public class FileTypeAssocTable { if (mapping.getFirst().accept(fileName)) return mapping.getSecond(); } - return myExtensionMappings.get(FileUtilRt.getExtension(fileName)); + return myExtensionMappings.get(FileUtilRt.getExtension(fileName).toLowerCase()); } @Nullable diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLoaderBase.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLoaderBase.java index bda75b69ac7a..a19e607f9161 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLoaderBase.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsLoaderBase.java @@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.jps.model.JpsElement; @@ -78,6 +79,6 @@ public abstract class JpsLoaderBase { } protected static boolean isXmlFile(File file) { - return file.isFile() && FileUtil.getExtension(file.getName()).equalsIgnoreCase("xml"); + return file.isFile() && FileUtilRt.extensionEquals(file.getName(), "xml"); } } diff --git a/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java b/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java index 8b487f326989..7efc8cca3b09 100644 --- a/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java +++ b/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java @@ -19,12 +19,13 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeRegistry; import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vfs.VirtualFile; +import gnu.trove.THashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,7 +33,7 @@ import java.util.Map; * @author yole */ public class CoreFileTypeRegistry extends FileTypeRegistry { - private final Map myExtensionsMap = new HashMap(); + private final Map myExtensionsMap = new THashMap(FileUtil.PATH_HASHING_STRATEGY); private final List myAllFileTypes = new ArrayList(); public CoreFileTypeRegistry() { @@ -58,7 +59,7 @@ public class CoreFileTypeRegistry extends FileTypeRegistry { @NotNull @Override public FileType getFileTypeByFileName(@NotNull @NonNls String fileName) { - final String extension = FileUtil.getExtension(fileName); + final String extension = FileUtilRt.getExtension(fileName); final FileType result = myExtensionsMap.get(extension); return result == null ? UnknownFileType.INSTANCE : result; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java index c491bec4d4a0..bd337c54e46f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java @@ -33,7 +33,7 @@ import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -171,7 +171,7 @@ public class FilePathCompletionContributor extends CompletionContributor { if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true; if (prefixMatched) { - final String extension = FileUtil.getExtension(fileName); + final String extension = FileUtilRt.getExtension(fileName); if (extension.length() == 0) return false; for (final FileType fileType : suitableFileTypes) { diff --git a/platform/lang-impl/src/com/intellij/framework/library/impl/LibraryVersionsFetcher.java b/platform/lang-impl/src/com/intellij/framework/library/impl/LibraryVersionsFetcher.java index f9d58c5f4f55..b97887be63f3 100644 --- a/platform/lang-impl/src/com/intellij/framework/library/impl/LibraryVersionsFetcher.java +++ b/platform/lang-impl/src/com/intellij/framework/library/impl/LibraryVersionsFetcher.java @@ -21,6 +21,7 @@ import com.intellij.framework.library.DownloadableLibraryDescription; import com.intellij.framework.library.DownloadableLibraryFileDescription; import com.intellij.framework.library.FrameworkLibraryVersion; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.download.impl.FileSetVersionsFetcherBase; import org.jetbrains.annotations.NotNull; @@ -51,6 +52,6 @@ public class LibraryVersionsFetcher extends FileSetVersionsFetcherBase 0) { + if (getDefaultExtension() == null || FileUtilRt.getExtension(newName).length() > 0) { return newName; } return newName + "." + getDefaultExtension(); diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index cba6aabbd551..4731f8faf215 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java @@ -55,7 +55,7 @@ import com.intellij.openapi.util.DimensionService; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -643,7 +643,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp myExtensionComboBox.setModel(model); myExtensionComboBox.setVisible(true); myExtensionLabel.setVisible(true); - String fileExt = myCurrentFile != null ? FileUtil.getExtension(myCurrentFile.getName()) : ""; + String fileExt = myCurrentFile != null ? FileUtilRt.getExtension(myCurrentFile.getName()) : ""; if (fileExt.length() > 0 && extensions.contains(fileExt)) { myExtensionComboBox.setSelectedItem(fileExt); return; diff --git a/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java b/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java index e320de2e4f6a..a5507687795e 100644 --- a/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java +++ b/platform/lang-impl/src/com/intellij/platform/ModuleAttachProcessor.java @@ -32,6 +32,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsDirectoryMapping; @@ -75,7 +76,7 @@ public class ModuleAttachProcessor extends ProjectAttachProcessor { final String[] files = projectDir.list(); if (files != null) { for (String file : files) { - if (FileUtil.getExtension(file).equals("iml")) { + if (FileUtilRt.extensionEquals(file, "iml")) { VirtualFile imlFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(projectDir, file)); if (imlFile != null) { attachModule(project, imlFile, callback); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java index 72180223fded..68079c75381f 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java @@ -29,7 +29,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.*; import com.intellij.openapi.startup.StartupManager; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter; import com.intellij.psi.*; @@ -560,7 +560,7 @@ public class PsiVFSListener extends VirtualFileAdapter { // When file is renamed so that extension changes then language dialect might change and thus psiFile should be invalidated private static boolean languageDialectChanged(final PsiFile newPsiFile, String oldFileName) { - return newPsiFile != null && !FileUtil.getExtension(newPsiFile.getName()).equals(FileUtil.getExtension(oldFileName)); + return newPsiFile != null && !FileUtilRt.extensionEquals(oldFileName, FileUtilRt.getExtension(newPsiFile.getName())); } private class MyModuleRootListener implements ModuleRootListener { diff --git a/platform/lang-impl/src/com/intellij/util/download/impl/DownloadableFileServiceImpl.java b/platform/lang-impl/src/com/intellij/util/download/impl/DownloadableFileServiceImpl.java index 5866399506dd..cb16ab069ae6 100644 --- a/platform/lang-impl/src/com/intellij/util/download/impl/DownloadableFileServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/util/download/impl/DownloadableFileServiceImpl.java @@ -19,6 +19,7 @@ import com.intellij.facet.frameworks.beans.Artifact; import com.intellij.facet.frameworks.beans.ArtifactItem; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.download.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ public class DownloadableFileServiceImpl extends DownloadableFileService { @NotNull @Override public DownloadableFileDescription createFileDescription(@NotNull String downloadUrl, @NotNull String fileName) { - return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtil.getExtension(fileName)); + return new DownloadableFileDescriptionImpl(downloadUrl, FileUtil.getNameWithoutExtension(fileName), FileUtilRt.getExtension(fileName)); } @NotNull diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 5b8237d3f76c..5a2530d8f79b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -35,6 +35,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.util.containers.OrderedSet; @@ -198,7 +199,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject } private static boolean isIprPath(final File file) { - return ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(file.getName())); + return FileUtilRt.extensionEquals(file.getName(), ProjectFileType.DEFAULT_EXTENSION); } private static String composeWsPath(String filePath) { diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java index cc864c55ff2d..51410ec06d2b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java @@ -24,7 +24,7 @@ import com.intellij.openapi.options.StreamProvider; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; @@ -225,7 +225,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di return null; } - String extension = FileUtil.getExtension(new File(expandedFile).getName()); + String extension = FileUtilRt.getExtension(new File(expandedFile).getName()); if (!ourHeadlessEnvironment && extension.length() == 0) { throw new IllegalArgumentException("Extension is missing for storage file: " + expandedFile); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/util/text/TrigramBuilderTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/util/text/TrigramBuilderTest.java index 022c16611ab6..5e5b72d7aaac 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/util/text/TrigramBuilderTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/util/text/TrigramBuilderTest.java @@ -16,6 +16,8 @@ package com.intellij.openapi.util.text; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; +import gnu.trove.THashSet; import gnu.trove.TIntHashSet; import gnu.trove.TIntObjectHashMap; import gnu.trove.TIntObjectProcedure; @@ -74,7 +76,7 @@ public class TrigramBuilderTest { } } else { - String ext = FileUtil.getExtension(name); + String ext = FileUtilRt.getExtension(name); if (!allowedExtension.contains(ext)) return; if (root.length() > 100 * 1024) return; @@ -111,10 +113,10 @@ public class TrigramBuilderTest { } } - private static final Set allowedExtension = new HashSet( + private static final Set allowedExtension = new THashSet( Arrays.asList("iml", "xml", "java", "html", "bat", "policy", "properties", "sh", "dtd", "ipr", "txt", "plist", "form", "xsl", "css", "jsp", "jspx", "xhtml", "tld", "htm", "tag", "jspf", "js", "ft", "xsd", "xls", "rb", "php", "ftl", "c", "y", "erb", "rjs", - "rhtml", "sql", "cfml", "groovy", "text", "gsp", "h", "cc", "cpp", "wsdl")); + "rhtml", "sql", "cfml", "groovy", "text", "gsp", "h", "cc", "cpp", "wsdl"), FileUtil.PATH_HASHING_STRATEGY); private static Collection lookup(TIntObjectHashMap> trigramsDatabase, String query) { final Set result = new HashSet(); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestUtil.java index fe345424dd15..6bb69e1ca395 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestUtil.java @@ -38,6 +38,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.psi.PsiElement; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.refactoring.rename.inplace.InplaceRefactoring; @@ -199,7 +200,7 @@ public class CodeInsightTestUtil { } public static void doActionTest(AnAction action, String file, CodeInsightTestFixture fixture) { - String extension = FileUtil.getExtension(file); + String extension = FileUtilRt.getExtension(file); String name = FileUtil.getNameWithoutExtension(file); fixture.configureByFile(file); fixture.testAction(action); diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java index a1edbca35b43..3de14377519c 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java +++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java @@ -68,7 +68,17 @@ public class FileUtilRt { public static String getExtension(@NotNull String fileName) { int index = fileName.lastIndexOf('.'); if (index < 0) return ""; - return fileName.substring(index + 1).toLowerCase(); + return fileName.substring(index + 1); + } + + public static boolean extensionEquals(@NotNull String fileName, @NotNull String extension) { + int extLen = extension.length(); + if (extLen == 0) { + return fileName.indexOf('.') == -1; + } + int extStart = fileName.length() - extLen; + return extStart >= 1 && fileName.charAt(extStart-1) == '.' + && fileName.regionMatches(!SystemInfoRt.isFileSystemCaseSensitive, extStart, extension, 0, extLen); } @NotNull diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index d0645b8fa730..69e102701ff1 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -827,9 +827,14 @@ public class FileUtil extends FileUtilRt { return StringUtil.isEmpty(path) || path == null ? 0 : PATH_HASHING_STRATEGY.computeHashCode(toCanonicalPath(path)); } + /** + * @deprecated this method returns extension converted to lower case, this may not be correct for case-sensitive FS. + * Use {@link FileUtilRt#getExtension(String)} instead to get the unchanged extension. + * If you need to check whether a file has a specified extension use {@link FileUtilRt#extensionEquals(String, String)} + */ @NotNull public static String getExtension(@NotNull String fileName) { - return FileUtilRt.getExtension(fileName); + return FileUtilRt.getExtension(fileName).toLowerCase(); } @NotNull diff --git a/platform/util/src/com/intellij/util/ImageLoader.java b/platform/util/src/com/intellij/util/ImageLoader.java index f7c72e873419..26eb3e2936f0 100644 --- a/platform/util/src/com/intellij/util/ImageLoader.java +++ b/platform/util/src/com/intellij/util/ImageLoader.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.io.URLUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; @@ -101,7 +102,7 @@ public class ImageLoader implements Serializable { List> answer = new ArrayList>(4); final String name = FileUtil.getNameWithoutExtension(file); - final String ext = FileUtil.getExtension(file); + final String ext = FileUtilRt.getExtension(file); if (dark && retina) { answer.add(Pair.create(name + "@2x_dark." + ext, 2)); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index 27a8d40b6833..a9ea4b0d481e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -25,7 +25,7 @@ import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.PlatformUtils; import org.jdom.Element; @@ -345,10 +345,10 @@ public final class VcsConfiguration implements PersistentStateComponent public void acceptLastCreatedPatchName(final String string) { if (StringUtil.isEmptyOrSpaces(string)) return; - final String extension = FileUtil.getExtension(string); - if (DIFF.equalsIgnoreCase(extension)) { + if (FileUtilRt.extensionEquals(string, DIFF)) { DEFAULT_PATCH_EXTENSION = DIFF; - } else if (PATCH.equalsIgnoreCase(extension)) { + } + else if (FileUtilRt.extensionEquals(string, PATCH)) { DEFAULT_PATCH_EXTENSION = PATCH; } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeDiffRequestPresentable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeDiffRequestPresentable.java index 760b6d37ee9b..b6e38e1b7472 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeDiffRequestPresentable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeDiffRequestPresentable.java @@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsException; @@ -246,7 +247,7 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable { } public static boolean checkAssociate(final Project project, final FilePath file, DiffChainContext context) { - final String pattern = FileUtil.getExtension(file.getName()); + final String pattern = FileUtilRt.getExtension(file.getName()).toLowerCase(); if (context.contains(pattern)) return false; int rc = Messages.showOkCancelDialog(project, VcsBundle.message("diff.unknown.file.type.prompt", file.getName()), diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/CompoundShelfFileProcessor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/CompoundShelfFileProcessor.java index 8c8a8655c514..46f65201482e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/CompoundShelfFileProcessor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/CompoundShelfFileProcessor.java @@ -22,6 +22,7 @@ import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.StreamProvider; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vcs.changes.CommitContext; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.containers.ContainerUtil; @@ -192,7 +193,7 @@ public class CompoundShelfFileProcessor { private String getNewFileName(final String serverFileName, final List serverFileNames, final List localFileNames) { String name = FileUtil.getNameWithoutExtension(serverFileName); - String ext = FileUtil.getExtension(serverFileName); + String ext = FileUtilRt.getExtension(serverFileName); for (int i = 1; ;i++) { String suggestedName = name + i + "." + ext; if (!serverFileNames.contains(suggestedName) && !localFileNames.contains(suggestedName)) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java index 64d1e04e2898..ee7bcd051add 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java @@ -37,6 +37,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.*; import com.intellij.openapi.vcs.changes.patch.ApplyPatchDefaultExecutor; @@ -299,7 +300,7 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl String shelvedPath = null; if (afterFile != null) { String shelvedName = FileUtil.getNameWithoutExtension(afterFile.getName()); - String shelvedExt = FileUtil.getExtension(afterFile.getName()); + String shelvedExt = FileUtilRt.getExtension(afterFile.getName()); File shelvedFile = FileUtil.findSequentNonexistentFile(myFileProcessor.getBaseIODir(), shelvedName, shelvedExt); myFileProcessor.saveFile(afterRevision.getFile().getIOFile(), shelvedFile); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java index 20522f719be4..9c0ec2ab165e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java @@ -18,7 +18,7 @@ package org.jetbrains.plugins.groovy.intentions.conversions; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -46,7 +46,7 @@ public class MoveClassToNewFileIntention extends Intention { final String name = psiClass.getName(); final PsiFile file = psiClass.getContainingFile(); - final String fileExtension = FileUtil.getExtension(file.getName()); + final String fileExtension = FileUtilRt.getExtension(file.getName()); final String newFileName = name + "." + fileExtension; final PsiDirectory dir = file.getParent(); if (dir != null) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java index 5bbde8e10496..8a3f5eeacd82 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java @@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.intentions.conversions; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.refactoring.openapi.impl.RenameRefactoringImpl; @@ -38,7 +38,7 @@ public class RenameFileWithClassIntention extends Intention { final String name = psiClass.getName(); final PsiFile file = psiClass.getContainingFile(); - final String newFileName = name + "." + FileUtil.getExtension(file.getName()); + final String newFileName = name + "." + FileUtilRt.getExtension(file.getName()); new RenameRefactoringImpl(project, file, newFileName, true, true).run(); } diff --git a/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java b/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java index 7f22c59b2101..85171d5197af 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java +++ b/xml/impl/src/com/intellij/codeInsight/template/XslTextContextType.java @@ -14,7 +14,7 @@ package com.intellij.codeInsight.template; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; @@ -29,7 +29,7 @@ public class XslTextContextType extends TemplateContextType { @Override public boolean isInContext(@NotNull PsiFile file, int offset) { - if (file.getFileType() == StdFileTypes.XML && FileUtil.getExtension(file.getName()).equals("xsl")) { + if (file.getFileType() == StdFileTypes.XML && FileUtilRt.extensionEquals(file.getName(), "xsl")) { PsiElement element = file.findElementAt(offset); return element == null || HtmlTextContextType.isInContext(element); } From bdbd3be84f784f04a069b93de6668377c4f24ef3 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Fri, 25 Jan 2013 13:21:21 +0100 Subject: [PATCH 04/36] Remote file browsers for remote external tools. --- .../com/intellij/tools/ToolEditorDialog.java | 99 +++++++++++-------- .../src/com/intellij/util/AsyncProducer.java | 23 +++++ 2 files changed, 81 insertions(+), 41 deletions(-) create mode 100644 platform/util-rt/src/com/intellij/util/AsyncProducer.java diff --git a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java index 6900bb2b2154..7026b45073eb 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolEditorDialog.java @@ -206,30 +206,9 @@ public class ToolEditorDialog extends DialogWrapper { pane.add(new JLabel(ToolsBundle.message("tools.program.label")), constr); FixedSizeButton browseCommandButton = new FixedSizeButton(myTfCommand); - browseCommandButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor(); - PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); - chooser.choose(null, new Consumer>() { - @Override - public void consume(List files) { - VirtualFile file = files.size() > 0 ? files.get(0) : null; - if (file != null) { - myTfCommand.setText(file.getPresentableUrl()); - String workingDirectory = myTfCommandWorkingDirectory.getText(); - if (workingDirectory == null || workingDirectory.length() == 0) { - VirtualFile parent = file.getParent(); - if (parent != null && parent.isDirectory()) { - myTfCommandWorkingDirectory.setText(parent.getPresentableUrl()); - } - } - } - } - }); - } - } - ); + + addCommandBrowseAction(pane, browseCommandButton, myTfCommand); + JPanel _pane0 = new JPanel(new BorderLayout()); _pane0.add(myTfCommand, BorderLayout.CENTER); _pane0.add(browseCommandButton, BorderLayout.EAST); @@ -291,24 +270,8 @@ public class ToolEditorDialog extends DialogWrapper { FixedSizeButton browseDirectoryButton = new FixedSizeButton(myTfCommandWorkingDirectory); TextFieldWithBrowseButton.MyDoClickAction.addTo(browseDirectoryButton, myTfCommandWorkingDirectory); - browseDirectoryButton.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); - PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); + addWorkingDirectoryBrowseAction(pane, browseDirectoryButton, myTfCommandWorkingDirectory); - chooser.choose(null, new Consumer>() { - @Override - public void consume(List files) { - VirtualFile file = files.size() > 0 ? files.get(0) : null; - if (file != null) { - myTfCommandWorkingDirectory.setText(file.getPresentableUrl()); - } - } - }); - } - } - ); JPanel _pane1 = new JPanel(new BorderLayout()); _pane1.add(myTfCommandWorkingDirectory, BorderLayout.CENTER); _pane1.add(browseDirectoryButton, BorderLayout.EAST); @@ -342,6 +305,56 @@ public class ToolEditorDialog extends DialogWrapper { return pane; } + protected void addWorkingDirectoryBrowseAction(final JPanel pane, + FixedSizeButton browseDirectoryButton, + JTextField tfCommandWorkingDirectory) { + browseDirectoryButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); + PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); + + chooser.choose(null, new Consumer>() { + @Override + public void consume(List files) { + VirtualFile file = files.size() > 0 ? files.get(0) : null; + if (file != null) { + myTfCommandWorkingDirectory.setText(file.getPresentableUrl()); + } + } + }); + } + } + ); + } + + protected void addCommandBrowseAction(final JPanel pane, FixedSizeButton browseCommandButton, JTextField tfCommand) { + browseCommandButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor(); + PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane); + chooser.choose(null, new Consumer>() { + @Override + public void consume(List files) { + VirtualFile file = files.size() > 0 ? files.get(0) : null; + if (file != null) { + myTfCommand.setText(file.getPresentableUrl()); + String workingDirectory = myTfCommandWorkingDirectory.getText(); + if (workingDirectory == null || workingDirectory.length() == 0) { + VirtualFile parent = file.getParent(); + if (parent != null && parent.isDirectory()) { + myTfCommandWorkingDirectory.setText(parent.getPresentableUrl()); + } + } + } + } + }); + } + } + ); + } + private class InsertMacroActionListener implements ActionListener { private final JTextField myTextField; @@ -507,4 +520,8 @@ public class ToolEditorDialog extends DialogWrapper { if (s.length() == 0) return null; return s.replace('/', File.separatorChar); } + + public Project getProject() { + return myProject; + } } diff --git a/platform/util-rt/src/com/intellij/util/AsyncProducer.java b/platform/util-rt/src/com/intellij/util/AsyncProducer.java new file mode 100644 index 000000000000..09d34e86e470 --- /dev/null +++ b/platform/util-rt/src/com/intellij/util/AsyncProducer.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2013 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. + */ +package com.intellij.util; + +/** + * @author traff + */ +public interface AsyncProducer { + void produce(Consumer consumer); +} From 012b7774336e8aa01eb354e0b881b1bfe3f9f5f3 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 16:56:43 +0400 Subject: [PATCH 05/36] [hg] Remove the traces of mq command draft The functionality is not implemented, and this draft is not very valuable. --- plugins/hg4idea/src/META-INF/plugin.xml | 1 - .../zmlx/hg4idea/action/HgMqRebaseAction.java | 85 ------------------- .../org/zmlx/hg4idea/command/HgMQCommand.java | 34 -------- .../provider/update/HgUpdateEnvironment.java | 4 +- .../provider/update/HgUpdaterFactory.java | 39 --------- 5 files changed, 1 insertion(+), 162 deletions(-) delete mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMqRebaseAction.java delete mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMQCommand.java delete mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdaterFactory.java diff --git a/plugins/hg4idea/src/META-INF/plugin.xml b/plugins/hg4idea/src/META-INF/plugin.xml index ea85d1e3bedd..e2e096153b80 100644 --- a/plugins/hg4idea/src/META-INF/plugin.xml +++ b/plugins/hg4idea/src/META-INF/plugin.xml @@ -52,7 +52,6 @@ - diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMqRebaseAction.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMqRebaseAction.java deleted file mode 100644 index cd298aa58298..000000000000 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgMqRebaseAction.java +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2008-2010 Victor Iacoban -// -// 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. -package org.zmlx.hg4idea.action; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.zmlx.hg4idea.command.HgMQCommand; -import org.zmlx.hg4idea.command.HgPullCommand; -import org.zmlx.hg4idea.ui.HgPullDialog; - -import java.util.Collection; - -// TODO unsued code. Keeping until MQ extension will be supported -public class HgMqRebaseAction extends HgAbstractGlobalAction { - - protected HgGlobalCommandBuilder getHgGlobalCommandBuilder(final Project project) { - return new HgGlobalCommandBuilder() { - public HgGlobalCommand build(Collection repos) { - HgPullDialog dialog = new HgPullDialog(project); - dialog.setRoots(repos); - dialog.show(); - if (dialog.isOK()) { - return buildCommand(dialog, project); - } - return null; - } - }; - } - - private HgGlobalCommand buildCommand(final HgPullDialog dialog, final Project project) { - final VirtualFile repository = dialog.getRepository(); - return new HgGlobalCommand() { - public VirtualFile getRepo() { - return repository; - } - - public void execute() { - HgMQCommand mqCommand = new HgMQCommand(project); - boolean notFoundAppliedPatches = mqCommand.qapplied(repository).isEmpty(); - if (notFoundAppliedPatches) { - return; - } - - HgPullCommand pullCommand = new HgPullCommand(project, repository); - pullCommand.setSource(dialog.getSource()); - pullCommand.setRebase(true); - pullCommand.setUpdate(false); - - //pullCommand.execute(new HgCommandResultHandler() { - // @Override - // public void process(@Nullable HgCommandResult result) { - // new HgCommandResultNotifier(project).process(result, null, null); - // - // String currentBranch = new HgTagBranchCommand(project, repository).getCurrentBranch(); - // if (StringUtil.isEmptyOrSpaces(currentBranch)) { - // return; - // } - // - // new HgConflictResolver(project).resolve(repository); - // - // HgResolveCommand resolveCommand = new HgResolveCommand(project); - // Map status = resolveCommand.getListSynchronously(repository); - // - // if (status.containsValue(HgResolveStatusEnum.UNRESOLVED)) { - // return; - // } - // - // new HgRebaseCommand(project, repository).continueRebase(); - // } - //}); - } - }; - } - -} diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMQCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMQCommand.java deleted file mode 100644 index e871b18c3edd..000000000000 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgMQCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008-2010 Victor Iacoban -// -// 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. -package org.zmlx.hg4idea.command; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.zmlx.hg4idea.execution.HgCommandExecutor; - -import java.util.List; - -public class HgMQCommand { - - private final Project project; - - public HgMQCommand(Project project) { - this.project = project; - } - - public List qapplied(@NotNull VirtualFile repo) { - return new HgCommandExecutor(project).executeInCurrentThread(repo, "qapplied", null).getOutputLines(); - } - -} diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java index 39a29eed9c60..cbb35eae761f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java @@ -34,12 +34,10 @@ import java.util.List; public class HgUpdateEnvironment implements UpdateEnvironment { private final Project project; - private final HgUpdaterFactory hgUpdaterFactory; private final HgUpdater.UpdateConfiguration updateConfiguration = new HgUpdater.UpdateConfiguration(); public HgUpdateEnvironment(Project project) { this.project = project; - hgUpdaterFactory = new HgUpdaterFactory(project); } public void fillGroups(UpdatedFiles updatedFiles) { @@ -64,7 +62,7 @@ public class HgUpdateEnvironment implements UpdateEnvironment { continue; } try { - HgUpdater updater = hgUpdaterFactory.buildUpdater(repository, updateConfiguration); + HgUpdater updater = new HgRegularUpdater(project, repository, updateConfiguration); result &= updater.update(updatedFiles, indicator, exceptions); } catch (VcsException e) { //TODO include module name where exception occurred diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdaterFactory.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdaterFactory.java deleted file mode 100644 index 6d351a7155ed..000000000000 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdaterFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2008-2010 Victor Iacoban -// -// 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. -package org.zmlx.hg4idea.provider.update; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.zmlx.hg4idea.command.HgMQCommand; - -class HgUpdaterFactory { - - private final Project project; - - public HgUpdaterFactory(Project project) { - this.project = project; - } - - HgUpdater buildUpdater(@NotNull VirtualFile repository, @NotNull HgUpdater.UpdateConfiguration configuration) throws VcsException { - HgMQCommand mqCommand = new HgMQCommand(project); - boolean foundAppliedPatches = !mqCommand.qapplied(repository).isEmpty(); - if (foundAppliedPatches) { - throw new VcsException("Cannot update with applied MQ patches, please use rebase"); - } else { - return new HgRegularUpdater(project, repository, configuration); - } - } - -} From 49ac28cb4e134ed9e5e2f3790d9dbbae390eb8e5 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 16:58:00 +0400 Subject: [PATCH 06/36] [hg] nullables, code style --- .../hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java index 55e042980670..80acef513f14 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java @@ -22,7 +22,7 @@ public final class HgErrorUtil { private HgErrorUtil() { } - public static boolean isAbort(HgCommandResult result) { + public static boolean isAbort(@Nullable HgCommandResult result) { if (result == null) { return true; } @@ -35,14 +35,12 @@ public final class HgErrorUtil { return false; } String line = getLastErrorLine(result); - return !StringUtil.isEmptyOrSpaces(line) && ( - line.contains("authorization required") - || line.contains("authorization failed") + return !StringUtil.isEmptyOrSpaces(line) && (line.contains("authorization required") || line.contains("authorization failed") ); } @Nullable - private static String getLastErrorLine(HgCommandResult result) { + private static String getLastErrorLine(@Nullable HgCommandResult result) { if (result == null) { return null; } @@ -53,7 +51,7 @@ public final class HgErrorUtil { return errorLines.get(errorLines.size() - 1); } - public static boolean hasErrorsInCommandExecution(HgCommandResult result) { + public static boolean hasErrorsInCommandExecution(@Nullable HgCommandResult result) { return isAbort(result) || result.getExitValue() != 0; } From 0ace63cd8d1433be3941933f07bfe7e7c9111df1 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 16:59:49 +0400 Subject: [PATCH 07/36] [hg] fix NPE, add Nullables --- .../org/zmlx/hg4idea/command/HgTagBranchCommand.java | 10 +++++++--- .../org/zmlx/hg4idea/execution/HgCommandExecutor.java | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgTagBranchCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgTagBranchCommand.java index 6837df7599b5..202428d6adeb 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgTagBranchCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgTagBranchCommand.java @@ -61,7 +61,9 @@ public class HgTagBranchCommand { new HgCommandExecutor(project).execute(repo, "branches", null, new HgCommandResultHandler() { @Override public void process(@Nullable HgCommandResult result) { - branchListConsumer.consume(tokenize(result)); + if (result != null) { + branchListConsumer.consume(tokenize(result)); + } } }); } @@ -70,12 +72,14 @@ public class HgTagBranchCommand { new HgCommandExecutor(project).execute(repo, "tags", null, new HgCommandResultHandler() { @Override public void process(@Nullable HgCommandResult result) { - tagListConsumer.consume(tokenize(result)); + if (result != null) { + tagListConsumer.consume(tokenize(result)); + } } }); } - private List tokenize(HgCommandResult result) { + private static List tokenize(HgCommandResult result) { List branches = new LinkedList(); for (final String line : result.getOutputLines()) { Matcher matcher = BRANCH_LINE.matcher(line); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java index c67a6bf332a7..a5046bc91332 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java @@ -91,9 +91,7 @@ public final class HgCommandExecutor { myShowOutput = showOutput; } - public void execute(@Nullable final VirtualFile repo, - final String operation, - final List arguments, + public void execute(@Nullable final VirtualFile repo, @NotNull final String operation, @Nullable final List arguments, @Nullable final HgCommandResultHandler handler) { HgUtil.executeOnPooledThreadIfNeeded(new Runnable() { @Override From 82626c8e2bc2dc8639c827439c5ac792aba329f8 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 17:10:07 +0400 Subject: [PATCH 08/36] [hg] remove obsolete comment --- .../src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java index 4e684e340f35..ca44688c674a 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java @@ -71,8 +71,6 @@ class HgCommandAuthenticator { public boolean promptForAuthentication(Project project, String proposedLogin, String uri, String path) { GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization); - // Don't use Application#invokeAndWait here, as IntelliJ - // may already be showing a dialog (such as the clone dialog) ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.defaultModalityState()); myRunnable = runnable; return runnable.isOk(); From 5d845f939b634c2630a7bb536d89254fc1161a3a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 25 Jan 2013 17:10:36 +0400 Subject: [PATCH 09/36] [hg] fix NPE --- plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java index 4311665bb1c1..871c8cd05221 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java @@ -36,6 +36,7 @@ import org.zmlx.hg4idea.ui.HgPushDialog; import org.zmlx.hg4idea.util.HgErrorUtil; import org.zmlx.hg4idea.util.HgUtil; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; @@ -91,15 +92,16 @@ public class HgPusher { return configCommand.getDefaultPushPath(repo); } + @NotNull public static List getBranches(@NotNull Project project, @NotNull VirtualFile root) { - final AtomicReference> branchesRef = new AtomicReference>(); + final List branches = new ArrayList(); new HgTagBranchCommand(project, root).listBranches(new Consumer>() { @Override public void consume(final List branches) { - branchesRef.set(branches); + branches.addAll(branches); } }); - return branchesRef.get(); + return branches; } private static void push(final Project project, HgPushCommand command) { From 95e16a18ccf3336fc4dbe93703fc6ed86d838794 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 25 Jan 2013 17:16:29 +0400 Subject: [PATCH 10/36] - proxy test: not a test, actually. was created for experiments --- .../svn4idea/testSource/org/jetbrains/idea/svn/ProxyTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ProxyTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ProxyTest.java index 1757619d0793..3b39563d3b09 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ProxyTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ProxyTest.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.svn; -import org.junit.Test; +//import org.junit.Test; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.internal.util.SVNSocketFactory; @@ -147,4 +147,6 @@ public class ProxyTest { } }); } + + private @interface Test {} } From ce5df913193d5c5d0eae2be8b8eb65ef71d034b5 Mon Sep 17 00:00:00 2001 From: "andrey.zaytsev" Date: Thu, 24 Jan 2013 19:37:58 +0400 Subject: [PATCH 11/36] remove-breakpoint action is enabled if at least one of selected items is allowed to be removed --- .../ui/tree/BreakpointMasterDetailPopupBuilder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java index a2bf37ce7301..5cdd805fe9a6 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java @@ -332,7 +332,14 @@ public class BreakpointMasterDetailPopupBuilder { actions.add(new AnAction("Remove Breakpoint", null, PlatformIcons.DELETE_ICON) { @Override public void update(AnActionEvent e) { - e.getPresentation().setEnabled(MasterDetailPopupBuilder.allowedToRemoveItems(myPopupBuilder.getSelectedItems())); + boolean enabled = false; + final ItemWrapper[] items = myPopupBuilder.getSelectedItems(); + for (ItemWrapper item : items) { + if (item.allowedToRemove()) { + enabled = true; + } + } + e.getPresentation().setEnabled(enabled); } @Override From ba6fb6610ea1dfded221ab1fdcce7e896e5731a0 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Fri, 25 Jan 2013 17:36:21 +0400 Subject: [PATCH 12/36] WEB-3628 Provide a way to use external JSLint/JSHint installations for easier updates --- .../com/intellij/platform/templates/github/DownloadUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java index 0239824fe3ab..7e7f4a833d8d 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java @@ -33,7 +33,7 @@ public class DownloadUtil { * @param indicator progress indicator * @param url url to download * @param outputFile output file - * @param tempFile temporary file to download to + * @param tempFile temporary file to download to. This file will be removed on method exit. */ public static void downloadAtomically(@Nullable ProgressIndicator indicator, @NotNull String url, @@ -42,7 +42,7 @@ public class DownloadUtil { { try { downloadContentToFile(indicator, url, tempFile); - FileUtil.copy(tempFile, outputFile); + FileUtil.rename(tempFile, outputFile); } finally { FileUtil.delete(tempFile); } From f6c02c3cf6eb0fa685b3cda82ecf67db7310ac77 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 25 Jan 2013 15:00:40 +0100 Subject: [PATCH 13/36] tip of the day updated (PY-8475) --- platform/platform-resources-en/src/tips/FileStructurePopup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/tips/FileStructurePopup.html b/platform/platform-resources-en/src/tips/FileStructurePopup.html index 9d40131bad12..f0f94c6a3e18 100644 --- a/platform/platform-resources-en/src/tips/FileStructurePopup.html +++ b/platform/platform-resources-en/src/tips/FileStructurePopup.html @@ -6,7 +6,7 @@

You can quickly navigate in the currently edited file with &shortcut:FileStructurePopup; - (View | File Structure).

+ (Navigate | File Structure).

It shows the list of members of the current class. Select an element you want to navigate to and press the Enter key or the &shortcut:EditSource; key.

To easily locate an item in the list, just start typing its name.

From 703a24e659b88feada207183454f6bf95d7617c6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 25 Jan 2013 15:44:02 +0100 Subject: [PATCH 14/36] always trim line comment start prefix when checking whether a line is commented (needed for PY-3153) --- .../generation/CommentByLineCommentHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java index 9f5b70960a90..2a4d8578e7a9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/CommentByLineCommentHandler.java @@ -343,8 +343,7 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { String prefix = commenter.getLineCommentPrefix(); if (prefix != null) { - commented = CharArrayUtil.regionMatches(chars, lineStart, prefix) || - prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, lineStart, prefix.trim() + "\n"); + commented = CharArrayUtil.regionMatches(chars, lineStart, StringUtil.trimTrailing(prefix)); } else { prefix = commenter.getBlockCommentPrefix(); @@ -513,12 +512,12 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler { } } - boolean skipNewLine = false; + boolean matchesTrimmed = false; boolean commented = CharArrayUtil.regionMatches(chars, startOffset, prefix) || - (skipNewLine = prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, startOffset, prefix.trim() + "\n")); + (matchesTrimmed = prefix.endsWith(" ") && CharArrayUtil.regionMatches(chars, startOffset, prefix.trim())); assert commented; - int charsToDelete = skipNewLine ? prefix.trim().length() : prefix.length(); + int charsToDelete = matchesTrimmed ? prefix.trim().length() : prefix.length(); int theEnd = endOffset > 0 ? endOffset : chars.length(); // if there's exactly one space after line comment prefix and before the text that follows in the same line, delete the space too if (startOffset + charsToDelete < theEnd - 1 && chars.charAt(startOffset + charsToDelete) == ' ') { From b1e29e17a6b1f6ae83daf9319325a854fdc53165 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 25 Jan 2013 16:05:11 +0100 Subject: [PATCH 15/36] I was wrong. rollback --- .../intellij/ui/ColoredTreeCellRenderer.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java index f5b66bed641f..8399877b4ef6 100644 --- a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -39,6 +39,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp * Defines whether the tree has focus or not */ private boolean myFocused; + private boolean myFocusedCalculated; protected JTree myTree; @@ -57,7 +58,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp clear(); mySelected = selected; - myFocused = hasFocus; + myFocusedCalculated = false; // We paint background if and only if tree path is selected and tree has focus. // If path is selected and tree is not focused then we just paint focused border. @@ -73,7 +74,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp else { if (selected) { setPaintFocusBorder(true); - if (hasFocus) { + if (isFocused()) { setBackground(UIUtil.getTreeSelectionBackground()); } else { @@ -107,7 +108,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp super.setIconOpaque(false); } else { - super.setOpaque(myOpaque || selected && hasFocus); // draw selection background even for non-opaque tree + super.setOpaque(myOpaque || selected && hasFocus || selected && isFocused()); // draw selection background even for non-opaque tree } if (tree.getUI() instanceof WideSelectionTreeUI && UIUtil.isUnderAquaBasedLookAndFeel()) { @@ -128,6 +129,18 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp return myTree; } + protected final boolean isFocused() { + if (!myFocusedCalculated) { + myFocused = calcFocusedState(); + myFocusedCalculated = true; + } + return myFocused; + } + + protected boolean calcFocusedState() { + return myTree.hasFocus(); + } + public void setOpaque(boolean isOpaque) { myOpaque = isOpaque; super.setOpaque(isOpaque); @@ -138,7 +151,7 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp * It guaranties readability of selected text in any LAF. */ public void append(@NotNull @Nls String fragment, @NotNull SimpleTextAttributes attributes, boolean isMainText) { - if (mySelected && myFocused) { + if (mySelected && isFocused()) { super.append(fragment, new SimpleTextAttributes(attributes.getStyle(), UIUtil.getTreeSelectionForeground()), isMainText); } else if (mySelected && UIUtil.isUnderAquaBasedLookAndFeel()) { From ea718874e7e2af083b9510432a643683f374234c Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 25 Jan 2013 16:07:57 +0100 Subject: [PATCH 16/36] libraries moved --- platform/icons/src/nodes/ppLib.png | Bin 298 -> 295 bytes platform/icons/src/nodes/ppLib@2x.png | Bin 388 -> 385 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/platform/icons/src/nodes/ppLib.png b/platform/icons/src/nodes/ppLib.png index 2d31e4af69d1f67272a659e2ab94a4cafa17d110..048bcf6dfa8390b4d7ef611cf0e9e7cefd017268 100644 GIT binary patch delta 230 zcmV zm^*ha!@Ya=Fbv6*5h3UTCMf-1NlEEHjE1q%6`!&3!Z3gZpXqGkl5jS+s1TU$Kk|s- z%yF=H7?zes!CinA{CfEuj=#Qs$M8wr73?w-OB=Wg!7dOJ6JG;s`1$iE3L8kG7%0ih z4rhxeVYS=jqd@4D9Uea5e*4AU^+$F!0T@HzSD7fU?Q%At+_2;ieQO5!z z=FXkVaPQtd3_~(yLB%IAHDg>tck33>H za~$j)hNY!Za2H?&zg|9v>Y1-s0|(gyBAunWY*#A3i2e*XN4!UmEk21@d> z!`UKIA_yt3;_p-iHZH^=H>}mtTJwKL7j!7B{i90n^VOKVo?Hfs2iqfd`0DC3qQr{Sz64xd52I8NPn~3dS%#2+PXKVijkQ5W;Kl zo3FnakkbGRJUV;xnc>Z|H={-IXh}E>LV!?7IP^kbv?LrY2}i607)N~X7$Cp^si(m% Tv1PXw00000NkvXXu0mjf9ea{k delta 324 zcmV-K0lWTz1B3&RNq;6uL_t(|+G70w|3AY(0w#t51}ref+_`f}(&#J5{r~URFARUb zd`1!f_Vf|McOX7v70000 Date: Fri, 25 Jan 2013 19:21:01 +0400 Subject: [PATCH 17/36] effectively unqualified check --- .../sillyAssignment/SillyAssignmentInspection.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java b/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java index 9adcfae79d2f..6fd1d33a37f5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/sillyAssignment/SillyAssignmentInspection.java @@ -21,6 +21,7 @@ import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.util.Comparing; import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -150,7 +151,14 @@ public class SillyAssignmentInspection extends BaseJavaLocalInspectionTool { private static PsiJavaCodeReferenceElement getQualifier(PsiElement qualifier) { if (qualifier instanceof PsiThisExpression) { - return ((PsiThisExpression)qualifier).getQualifier(); + final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)qualifier).getQualifier(); + if (thisQualifier != null) { + final PsiClass innerMostClass = PsiTreeUtil.getParentOfType(thisQualifier, PsiClass.class); + if (innerMostClass == thisQualifier.resolve()) { + return null; + } + } + return thisQualifier; } else if (qualifier != null) { return ((PsiSuperExpression)qualifier).getQualifier(); } From 3df8cf6a77d3cf8c5980c56eb1d52d60f2ef1e59 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 25 Jan 2013 16:30:04 +0100 Subject: [PATCH 18/36] code simplification, avoid creating lots of Runnable objects when scheduling automake tasks --- .../compiler/server/BuildManager.java | 159 ++++++++++-------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index b12f6457b734..16749a944ad4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -151,10 +151,45 @@ public class BuildManager implements ApplicationComponent{ private final SequentialTaskExecutor myRequestsProcessor = new SequentialTaskExecutor(myPooledThreadExecutor); private final Map myProjectDataMap = Collections.synchronizedMap(new HashMap()); - private final Alarm myMakeScheduleAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); - private final AtomicBoolean myAutoMakeInProgress = new AtomicBoolean(false); - private final Alarm myProjectsSaveAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); - private final AtomicBoolean myProjectsSaveInProgress = new AtomicBoolean(false); + private final BuildManagerPeriodicTask myAutoMakeTask = new BuildManagerPeriodicTask() { + @Override + protected void runTask() { + runAutoMake(); + } + }; + + private final BuildManagerPeriodicTask myDocumentSaveTask = new BuildManagerPeriodicTask() { + private final Semaphore mySemaphore = new Semaphore(); + private final Runnable mySaveDocsRunnable = new Runnable() { + @Override + public void run() { + try { + FileDocumentManager.getInstance().saveAllDocuments(); + } + finally { + mySemaphore.up(); + } + } + }; + + @Override + public void runTask() { + if (shouldSaveDocuments()) { + mySemaphore.down(); + ApplicationManager.getApplication().invokeLater(mySaveDocsRunnable, ModalityState.NON_MODAL); + mySemaphore.waitFor(); + } + } + + private boolean shouldSaveDocuments() { + for (final Project project : getActiveProjects()) { + if (canStartAutoMake(project)) { + return true; + } + } + return false; + } + }; private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("build-manager"); private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher(); @@ -361,84 +396,16 @@ public class BuildManager implements ApplicationComponent{ public void scheduleAutoMake() { if (!IS_UNIT_TEST_MODE && !PowerSaveMode.isEnabled()) { - scheduleTask(myMakeScheduleAlarm, myAutoMakeInProgress, new Runnable() { - @Override - public void run() { - runAutoMake(); - } - }); + myAutoMakeTask.schedule(); } } private void scheduleProjectSave() { if (!IS_UNIT_TEST_MODE && !PowerSaveMode.isEnabled()) { - scheduleTask(myProjectsSaveAlarm, myProjectsSaveInProgress, new Runnable() { - @Override - public void run() { - boolean shouldSave = false; - for (final Project project : getActiveProjects()) { - if (canStartAutoMake(project)) { - shouldSave = true; - break; - } - } - if (shouldSave) { - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - ApplicationManager.getApplication().invokeLater(new Runnable() { - @Override - public void run() { - try { - FileDocumentManager.getInstance().saveAllDocuments(); - } - finally { - semaphore.up(); - } - } - }, ModalityState.NON_MODAL); - semaphore.waitFor(); - } - } - }); + myDocumentSaveTask.schedule(); } } - private static void scheduleTask(final Alarm alarm, final AtomicBoolean taskLatch, final Runnable task) { - alarm.cancelAllRequests(); - final int delay = Math.max(50, Registry.intValue("compiler.automake.trigger.delay", MAKE_TRIGGER_DELAY)); - alarm.addRequest(new Runnable() { - @Override - public void run() { - if (!HeavyProcessLatch.INSTANCE.isRunning() && !taskLatch.getAndSet(true)) { - try { - ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { - @Override - public void run() { - try { - task.run(); - } - finally { - taskLatch.set(false); - } - } - }); - } - catch (RejectedExecutionException ignored) { - // we were shut down - taskLatch.set(false); - } - catch (Throwable e) { - taskLatch.set(false); - throw new RuntimeException(e); - } - } - else { - scheduleTask(alarm, taskLatch, task); - } - } - }, delay); - } - private void runAutoMake() { final List futures = new ArrayList(); for (final Project project : getActiveProjects()) { @@ -1066,6 +1033,50 @@ public class BuildManager implements ApplicationComponent{ } } + private static abstract class BuildManagerPeriodicTask implements Runnable { + private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); + private final AtomicBoolean myInProgress = new AtomicBoolean(false); + private final Runnable myTaskRunnable = new Runnable() { + @Override + public void run() { + try { + runTask(); + } + finally { + myInProgress.set(false); + } + } + }; + + public final void schedule() { + myAlarm.cancelAllRequests(); + final int delay = Math.max(50, Registry.intValue("compiler.automake.trigger.delay", MAKE_TRIGGER_DELAY)); + myAlarm.addRequest(this, delay); + } + + protected abstract void runTask(); + + @Override + public final void run() { + if (!HeavyProcessLatch.INSTANCE.isRunning() && !myInProgress.getAndSet(true)) { + try { + ApplicationManager.getApplication().executeOnPooledThread(myTaskRunnable); + } + catch (RejectedExecutionException ignored) { + // we were shut down + myInProgress.set(false); + } + catch (Throwable e) { + myInProgress.set(false); + throw new RuntimeException(e); + } + } + else { + schedule(); + } + } + } + private class ProjectWatcher extends ProjectManagerAdapter { private final Map myConnections = new HashMap(); From 70b562fb27c0acca19c8dba6cbe5da7ef72c4532 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 25 Jan 2013 16:47:02 +0100 Subject: [PATCH 19/36] remove incorrect @NotNull annotation (PY-8597) --- .../src/com/intellij/platform/DirectoryProjectGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/platform/DirectoryProjectGenerator.java b/platform/platform-impl/src/com/intellij/platform/DirectoryProjectGenerator.java index 43a57a42d050..c99bf6afe372 100644 --- a/platform/platform-impl/src/com/intellij/platform/DirectoryProjectGenerator.java +++ b/platform/platform-impl/src/com/intellij/platform/DirectoryProjectGenerator.java @@ -39,7 +39,7 @@ public interface DirectoryProjectGenerator { T showGenerationSettings(final VirtualFile baseDir) throws ProcessCanceledException; void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir, - @NotNull final T settings, @NotNull final Module module); + @Nullable final T settings, @NotNull final Module module); @NotNull ValidationResult validate(@NotNull String baseDirPath); From 6e964bf0073a74b83f6ad0ad6df71351e1fb37f1 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 25 Jan 2013 19:52:12 +0400 Subject: [PATCH 20/36] eclipse: read language level for jps (IDEA-99463) --- .../jps/eclipse/model/JpsIdeaSpecificSettings.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsIdeaSpecificSettings.java b/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsIdeaSpecificSettings.java index e1e1b8506a70..9d722746650e 100644 --- a/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsIdeaSpecificSettings.java +++ b/plugins/eclipse/jps-plugin/src/org/jetbrains/jps/eclipse/model/JpsIdeaSpecificSettings.java @@ -118,7 +118,13 @@ class JpsIdeaSpecificSettings extends AbstractIdeaSpecificSettings Date: Fri, 25 Jan 2013 19:51:52 +0400 Subject: [PATCH 21/36] github themes added minor improvements for indent guides --- .../src/colorSchemes/all_hallows_eve.xml | 3 +- colorSchemes/src/colorSchemes/blackboard.xml | 3 +- colorSchemes/src/colorSchemes/cobalt.xml | 3 +- colorSchemes/src/colorSchemes/github.xml | 2215 +++++++++++++++++ colorSchemes/src/colorSchemes/monokai.xml | 3 +- colorSchemes/src/colorSchemes/rails_casts.xml | 3 +- colorSchemes/src/colorSchemes/twilight.xml | 3 +- 7 files changed, 2227 insertions(+), 6 deletions(-) create mode 100644 colorSchemes/src/colorSchemes/github.xml diff --git a/colorSchemes/src/colorSchemes/all_hallows_eve.xml b/colorSchemes/src/colorSchemes/all_hallows_eve.xml index 8e4586cb256d..2f7320d99113 100644 --- a/colorSchemes/src/colorSchemes/all_hallows_eve.xml +++ b/colorSchemes/src/colorSchemes/all_hallows_eve.xml @@ -3,13 +3,14 @@