From 2ce633a943be51e11228bba56159b86988ec3657 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 12:56:29 +0400 Subject: [PATCH 01/74] read access --- .../uiDesigner/binding/FormReferencesSearcher.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java index 4025ec791fc9..9025926aa340 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java @@ -3,7 +3,9 @@ package com.intellij.uiDesigner.binding; import com.intellij.lang.properties.IProperty; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.lang.properties.psi.Property; +import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressManager; @@ -151,7 +153,14 @@ public class FormReferencesSearcher implements QueryExecutor Date: Wed, 17 Aug 2011 11:45:04 +0400 Subject: [PATCH 02/74] GitUpdateLikeProcess renamed to GitComplexProcess --- .../src/git4idea/checkin/GitPushActiveBranchesDialog.java | 4 ++-- .../src/git4idea/checkout/branches/GitCheckoutProcess.java | 7 ++----- .../{GitUpdateLikeProcess.java => GitComplexProcess.java} | 4 ++-- plugins/git4idea/src/git4idea/update/GitUpdateProcess.java | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) rename plugins/git4idea/src/git4idea/update/{GitUpdateLikeProcess.java => GitComplexProcess.java} (97%) diff --git a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java index 24629773717d..889d1261e7b7 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java @@ -51,6 +51,7 @@ import git4idea.actions.GitShowAllSubmittedFilesAction; import git4idea.commands.*; import git4idea.config.GitVcsSettings; import git4idea.i18n.GitBundle; +import git4idea.update.GitComplexProcess; import git4idea.rebase.GitRebaser; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; @@ -58,7 +59,6 @@ import git4idea.stash.GitChangesSaver; import git4idea.stash.GitShelveChangesSaver; import git4idea.stash.GitStashChangesSaver; import git4idea.ui.GitUIUtil; -import git4idea.update.GitUpdateLikeProcess; import git4idea.update.GitUpdateProcess; import git4idea.update.UpdatePolicyUtils; import org.jetbrains.annotations.NotNull; @@ -501,7 +501,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { final Boolean[] result = new Boolean[1]; result[0] = false; final ProgressIndicator finalProgressIndicator = progressIndicator; - new GitUpdateLikeProcess(myProject) { + new GitComplexProcess(myProject) { @Override protected void runImpl(ContinuationContext context) { try { diff --git a/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java b/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java index 94c9eec363a2..35b623052c05 100644 --- a/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java +++ b/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java @@ -23,18 +23,15 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectManagerEx; -import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.*; import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager; import com.intellij.openapi.vcs.changes.shelf.ShelvedChangeList; -import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.util.Consumer; import com.intellij.util.continuation.Continuation; import com.intellij.util.continuation.GatheringContinuationContext; @@ -47,9 +44,9 @@ import git4idea.checkout.branches.GitBranchConfigurations.BranchChanges; import git4idea.checkout.branches.GitBranchConfigurations.ChangeInfo; import git4idea.checkout.branches.GitBranchConfigurations.ChangeListInfo; import git4idea.commands.*; +import git4idea.update.GitComplexProcess; import git4idea.stash.GitShelveUtils; import git4idea.ui.GitUIUtil; -import git4idea.update.GitUpdateLikeProcess; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -189,7 +186,7 @@ public class GitCheckoutProcess { // waitForChanges(); myProjectManager.blockReloadingProjectOnExternalChanges(); // todo here not tested!! since now is not used in UI - myChangeManager.freeze(new SemaphoreContinuationContext(), GitUpdateLikeProcess.REASON); + myChangeManager.freeze(new SemaphoreContinuationContext(), GitComplexProcess.REASON); try { GitBranchConfiguration oldConfiguration = checkCurrentConfiguration(); if (oldConfiguration == null) { diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateLikeProcess.java b/plugins/git4idea/src/git4idea/update/GitComplexProcess.java similarity index 97% rename from plugins/git4idea/src/git4idea/update/GitUpdateLikeProcess.java rename to plugins/git4idea/src/git4idea/update/GitComplexProcess.java index cb1dd8776794..215147dae891 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateLikeProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitComplexProcess.java @@ -31,7 +31,7 @@ import git4idea.repo.GitRepositoryManager; * Date: 3/31/11 * Time: 2:59 PM */ -public abstract class GitUpdateLikeProcess { +public abstract class GitComplexProcess { public static final String GIT_UPDATING = "Git: updating"; public static final String REASON = "Local changes are not available until Git update is finished."; @@ -40,7 +40,7 @@ public abstract class GitUpdateLikeProcess { private final ProjectManagerEx myProjectManager; private final GitRepositoryManager myRepositoryManager; - public GitUpdateLikeProcess(final Project project) { + public GitComplexProcess(final Project project) { myProject = project; myGeneralSettings = GeneralSettings.getInstance(); myProjectManager = ProjectManagerEx.getInstanceEx(); diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index 10812260e11f..f48df0aa6375 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -108,7 +108,7 @@ public class GitUpdateProcess { return false; } - new GitUpdateLikeProcess(myProject) { + new GitComplexProcess(myProject) { @Override protected void runImpl(ContinuationContext context) { myResult = updateImpl(forceRebase, context); From 55d77354c753ca4173bdaf0e42d87a3aa419ac5a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 17 Aug 2011 12:20:30 +0400 Subject: [PATCH 03/74] GitComplexProcess refactoring 1. Make not abstract, pass an Operation to the constructor instead of extending the class. 2. Pre-create all preparation and completion operations for better readability in run(). --- .../checkin/GitPushActiveBranchesDialog.java | 7 +- .../checkout/branches/GitCheckoutProcess.java | 3 +- .../git4idea/update/GitComplexProcess.java | 174 +++++++++++------- .../src/git4idea/update/GitUpdateProcess.java | 16 +- 4 files changed, 117 insertions(+), 83 deletions(-) diff --git a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java index 889d1261e7b7..b591f0908553 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java @@ -501,9 +501,9 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { final Boolean[] result = new Boolean[1]; result[0] = false; final ProgressIndicator finalProgressIndicator = progressIndicator; - new GitComplexProcess(myProject) { + GitComplexProcess.Operation reorderOperation = new GitComplexProcess.Operation() { @Override - protected void runImpl(ContinuationContext context) { + public void run(ContinuationContext context) { try { final Set rootsToReorder = rebaseInfo.reorderedCommits.keySet(); saver.saveLocalChanges(rootsToReorder); @@ -546,7 +546,8 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { "Update was cancelled.", true, e); } } - }.execute(); + }; + GitComplexProcess.execute(myProject, "reordering commits", reorderOperation); return result[0]; } diff --git a/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java b/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java index 35b623052c05..9ace43ece493 100644 --- a/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java +++ b/plugins/git4idea/src/git4idea/checkout/branches/GitCheckoutProcess.java @@ -44,7 +44,6 @@ import git4idea.checkout.branches.GitBranchConfigurations.BranchChanges; import git4idea.checkout.branches.GitBranchConfigurations.ChangeInfo; import git4idea.checkout.branches.GitBranchConfigurations.ChangeListInfo; import git4idea.commands.*; -import git4idea.update.GitComplexProcess; import git4idea.stash.GitShelveUtils; import git4idea.ui.GitUIUtil; import org.jetbrains.annotations.Nullable; @@ -186,7 +185,7 @@ public class GitCheckoutProcess { // waitForChanges(); myProjectManager.blockReloadingProjectOnExternalChanges(); // todo here not tested!! since now is not used in UI - myChangeManager.freeze(new SemaphoreContinuationContext(), GitComplexProcess.REASON); + myChangeManager.freeze(new SemaphoreContinuationContext(), "Local changes are not available until Git checkout is finished."); try { GitBranchConfiguration oldConfiguration = checkCurrentConfiguration(); if (oldConfiguration == null) { diff --git a/plugins/git4idea/src/git4idea/update/GitComplexProcess.java b/plugins/git4idea/src/git4idea/update/GitComplexProcess.java index 215147dae891..33a43a8dfa20 100644 --- a/plugins/git4idea/src/git4idea/update/GitComplexProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitComplexProcess.java @@ -16,99 +16,139 @@ package git4idea.update; import com.intellij.ide.GeneralSettings; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.util.continuation.*; -import com.intellij.util.ui.UIUtil; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; /** + * This class executes a Git task, surrounding it with a couple of preparation and completion tasks, such as: + *
    + *
  • Prohibit saving and syncing on frame deactivation.
  • + *
  • {@link ChangeListManager#freeze(com.intellij.util.continuation.ContinuationPause, String) Freeze} the {@link ChangeListManager}
  • + *
+ * + *

+ * To use it implement the {@link Operation} interface which runs the needed Git task itself and call + * {@link GitComplexProcess#execute(com.intellij.openapi.project.Project, String, git4idea.update.GitComplexProcess.Operation)} + *

+ * * @author irengrig - * Date: 3/31/11 - * Time: 2:59 PM + * @author Kirill Likhodedov */ -public abstract class GitComplexProcess { - public static final String GIT_UPDATING = "Git: updating"; - public static final String REASON = "Local changes are not available until Git update is finished."; - +public class GitComplexProcess { + + public interface Operation { + void run(ContinuationContext continuationContext); + } + private final Project myProject; + private final String myTitle; + private final Operation myOperation; + + private final String myFreezeReason; private final GeneralSettings myGeneralSettings; private final ProjectManagerEx myProjectManager; private final GitRepositoryManager myRepositoryManager; + private final ChangeListManager myChangeListManager; - public GitComplexProcess(final Project project) { + private final boolean mySaveOnFrameDeactivation; + private final boolean mySyncOnFrameDeactivation; + + private final TaskDescriptor BLOCK = new TaskDescriptor("", Where.AWT) { + @Override public void run(ContinuationContext context) { + myProjectManager.blockReloadingProjectOnExternalChanges(); + FileDocumentManager.getInstance().saveAllDocuments(); + myGeneralSettings.setSaveOnFrameDeactivation(false); + myGeneralSettings.setSyncOnFrameActivation(false); + } + }; + + private final TaskDescriptor FREEZE; + + private final TaskDescriptor RELEASE = new TaskDescriptor("", Where.AWT) { + @Override public void run(ContinuationContext context) { + myChangeListManager.letGo(); + } + + @Override public boolean isHaveMagicCure() { + return true; + } + }; + + private final TaskDescriptor UNBLOCK = new TaskDescriptor("", Where.AWT) { + @Override public void run(ContinuationContext context) { + myProjectManager.unblockReloadingProjectOnExternalChanges(); + myGeneralSettings.setSaveOnFrameDeactivation(mySaveOnFrameDeactivation); + myGeneralSettings.setSyncOnFrameActivation(mySyncOnFrameDeactivation); + } + + @Override public boolean isHaveMagicCure() { + return true; + } + }; + + private final TaskDescriptor UPDATE_REPOSITORIES; + + public static void execute(Project project, String title, Operation operation) { + new GitComplexProcess(project, title, operation).run(); + } + + private GitComplexProcess(Project project, String title, Operation operation) { myProject = project; + myTitle = title; + myOperation = operation; + myFreezeReason = "Local changes are not available until Git " + myTitle + " is finished."; + myGeneralSettings = GeneralSettings.getInstance(); myProjectManager = ProjectManagerEx.getInstanceEx(); myRepositoryManager = GitRepositoryManager.getInstance(project); + myChangeListManager = ChangeListManager.getInstance(myProject); + + mySaveOnFrameDeactivation = myGeneralSettings.isSaveOnFrameDeactivation(); + mySyncOnFrameDeactivation = myGeneralSettings.isSyncOnFrameActivation(); + + // define tasks that need information from constructor + + FREEZE = new TaskDescriptor(myTitle, Where.POOLED) { + @Override public void run(ContinuationContext context) { + myChangeListManager.freeze(context, myFreezeReason); + } + }; + + UPDATE_REPOSITORIES = new TaskDescriptor(myTitle, Where.POOLED) { + @Override public void run(ContinuationContext context) { + for (GitRepository repo : myRepositoryManager.getRepositories()) { + repo.update(GitRepository.TrackedTopic.ALL); + } + } + }; } - public void execute() { - final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); - - final boolean saveOnFrameDeactivation = myGeneralSettings.isSaveOnFrameDeactivation(); - final boolean syncOnFrameDeactivation = myGeneralSettings.isSyncOnFrameActivation(); - myProjectManager.blockReloadingProjectOnExternalChanges(); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - FileDocumentManager.getInstance().saveAllDocuments(); - myGeneralSettings.setSaveOnFrameDeactivation(false); - myGeneralSettings.setSyncOnFrameActivation(false); - } - }); - } - }); - - final Continuation continuation = Continuation.createForCurrentProgress(myProject, true, GIT_UPDATING); - final GatheringContinuationContext initContext = new GatheringContinuationContext(); - final TaskDescriptor returnFlagsBack = new TaskDescriptor("", Where.AWT) { - @Override - public void run(ContinuationContext context) { - myProjectManager.unblockReloadingProjectOnExternalChanges(); - myGeneralSettings.setSaveOnFrameDeactivation(saveOnFrameDeactivation); - myGeneralSettings.setSyncOnFrameActivation(syncOnFrameDeactivation); - changeListManager.letGo(); + private void run() { + Continuation continuation = Continuation.createForCurrentProgress(myProject, true, myTitle); + GatheringContinuationContext initContext = new GatheringContinuationContext(); + String taskTitle = "Git: " + myTitle; + TaskDescriptor operation = new TaskDescriptor(taskTitle, Where.POOLED) { + @Override public void run(final ContinuationContext context) { + myOperation.run(context); } }; - final TaskDescriptor[] next = { - new TaskDescriptor(GIT_UPDATING, Where.POOLED) { - @Override - public void run(ContinuationContext context) { - changeListManager.freeze(context, REASON); - } - }, - new TaskDescriptor(GIT_UPDATING, Where.POOLED) { - @Override - public void run(final ContinuationContext context) { - runImpl(context); - } - }, - new TaskDescriptor(GIT_UPDATING, Where.POOLED) { - @Override - public void run(ContinuationContext context) { - updateRepositories(); - } - }, - returnFlagsBack + + final TaskDescriptor[] tasks = { + BLOCK, + FREEZE, + operation, + UPDATE_REPOSITORIES, + RELEASE, + UNBLOCK }; - returnFlagsBack.setHaveMagicCure(true); - initContext.next(next); + + initContext.next(tasks); continuation.run(initContext.getList()); } - private void updateRepositories() { - for (GitRepository repo: myRepositoryManager.getRepositories()) { - repo.update(GitRepository.TrackedTopic.ALL); - } - } - - protected abstract void runImpl(ContinuationContext context); } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index f48df0aa6375..f8bc8d22084b 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -15,12 +15,10 @@ */ package git4idea.update; -import com.intellij.ide.GeneralSettings; import com.intellij.notification.NotificationType; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.util.Clock; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.update.UpdatedFiles; @@ -52,7 +50,6 @@ public class GitUpdateProcess { private static final Logger LOG = Logger.getInstance(GitUpdateProcess.class); private final Project myProject; - private final ProjectManagerEx myProjectManager; private final Set myRoots; private final UpdatedFiles myUpdatedFiles; private final ProgressIndicator myProgressIndicator; @@ -60,7 +57,6 @@ public class GitUpdateProcess { private final GitChangesSaver mySaver; private final Map myTrackedBranches = new HashMap(); - private GeneralSettings myGeneralSettings; private boolean myResult; private final Map myUpdaters; private final Collection myRootsToSave; @@ -72,11 +68,9 @@ public class GitUpdateProcess { myRoots = roots; myUpdatedFiles = updatedFiles; myProgressIndicator = progressIndicator; - myProjectManager = ProjectManagerEx.getInstanceEx(); myMerger = new GitMerger(myProject); mySaver = GitChangesSaver.getSaver(myProject, myProgressIndicator, "Uncommitted changes before update operation at " + DateFormatUtil.formatDateTime(Clock.getTime())); - myGeneralSettings = GeneralSettings.getInstance(); myUpdaters = new HashMap(); myRootsToSave = new HashSet(1); } @@ -108,12 +102,12 @@ public class GitUpdateProcess { return false; } - new GitComplexProcess(myProject) { - @Override - protected void runImpl(ContinuationContext context) { - myResult = updateImpl(forceRebase, context); + GitComplexProcess.Operation updateOperation = new GitComplexProcess.Operation() { + @Override public void run(ContinuationContext continuationContext) { + myResult = updateImpl(forceRebase, continuationContext); } - }.execute(); + }; + GitComplexProcess.execute(myProject, "update", updateOperation); return myResult; } From d125119148fabb54ea07e07dc8c7aa54b0a05bbd Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 17 Aug 2011 12:31:03 +0400 Subject: [PATCH 04/74] GitUpdateProcess: remove redundant parameter --- .../src/git4idea/checkin/GitPushActiveBranchesDialog.java | 2 +- .../git4idea/src/git4idea/update/GitUpdateEnvironment.java | 6 +----- plugins/git4idea/src/git4idea/update/GitUpdateProcess.java | 7 ++++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java index b591f0908553..12af599a4854 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java @@ -470,7 +470,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { private boolean executeRebase(final List exceptions, RebaseInfo rebaseInfo) { // TODO this is a workaround to attach PushActiveBranched to the new update. // at first we update via rebase - boolean result = new GitUpdateProcess(myProject, new EmptyProgressIndicator(), rebaseInfo.roots, UpdatedFiles.create()).update(true, true); + boolean result = new GitUpdateProcess(myProject, new EmptyProgressIndicator(), rebaseInfo.roots, UpdatedFiles.create()).update(true); // then we reorder commits if (result) { diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java index 886ce1fb35d9..7b27da3f7ca5 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateEnvironment.java @@ -27,10 +27,6 @@ import com.intellij.openapi.vcs.update.UpdateEnvironment; import com.intellij.openapi.vcs.update.UpdateSession; import com.intellij.openapi.vcs.update.UpdatedFiles; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.continuation.Continuation; -import com.intellij.util.continuation.ContinuationContext; -import com.intellij.util.continuation.TaskDescriptor; -import com.intellij.util.continuation.Where; import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.config.GitVcsSettings; @@ -66,7 +62,7 @@ public class GitUpdateEnvironment implements UpdateEnvironment { public UpdateSession updateDirectories(@NotNull FilePath[] filePaths, UpdatedFiles updatedFiles, ProgressIndicator progressIndicator, @NotNull Ref sequentialUpdatesContextRef) throws ProcessCanceledException { Set roots = GitUtil.gitRoots(Arrays.asList(filePaths)); final GitUpdateProcess gitUpdateProcess = new GitUpdateProcess(myProject, progressIndicator, roots, updatedFiles); - boolean result = gitUpdateProcess.update(false, false); + boolean result = gitUpdateProcess.update(false); return new GitUpdateSession(result); } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index f8bc8d22084b..4c98135148e6 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -80,7 +80,7 @@ public class GitUpdateProcess { * In case of error shows notification and returns false. If update completes without errors, returns true. */ public boolean update() { - return update(false, true); + return update(false); } /** @@ -92,10 +92,11 @@ public class GitUpdateProcess { * 4. Updates via 'git pull' or equivalent. * 5. Restores local changes if update completed or failed with error. If update is incomplete, i.e. some unmerged files remain, * local changes are not restored. + * * @param forceRebase * @return */ - public boolean update(final boolean forceRebase, final boolean restoreChangesRightNow) { + public boolean update(final boolean forceRebase) { LOG.info("update started|" + (forceRebase ? " force rebase" : "")); if (!fetchAndNotify()) { @@ -184,7 +185,7 @@ public class GitUpdateProcess { return success; } - public void restoreLocalChanges(ContinuationContext context) { + private void restoreLocalChanges(ContinuationContext context) { context.addExceptionHandler(VcsException.class, new Consumer() { @Override public void consume(VcsException e) { From 3a6a907619515b31d9e050e906b9cce459136b0b Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 17 Aug 2011 13:02:34 +0400 Subject: [PATCH 05/74] additional keymap Ctrl(meta)+E for recent commit messages --- platform/platform-resources/src/idea/Keymap_Default.xml | 1 + platform/platform-resources/src/idea/Keymap_Mac.xml | 1 + platform/platform-resources/src/idea/Keymap_MacClassic.xml | 1 + 3 files changed, 3 insertions(+) diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index 868c9d9f1b87..41215f4027df 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -859,6 +859,7 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_Mac.xml b/platform/platform-resources/src/idea/Keymap_Mac.xml index e1a16bf5dc69..cc862b1e2b6e 100644 --- a/platform/platform-resources/src/idea/Keymap_Mac.xml +++ b/platform/platform-resources/src/idea/Keymap_Mac.xml @@ -431,6 +431,7 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_MacClassic.xml b/platform/platform-resources/src/idea/Keymap_MacClassic.xml index fa5a35d5f9bb..a1a4775e0c44 100644 --- a/platform/platform-resources/src/idea/Keymap_MacClassic.xml +++ b/platform/platform-resources/src/idea/Keymap_MacClassic.xml @@ -324,6 +324,7 @@ + From 52710f404a7bac9161e8bd8a6d6ed34852adcced Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 11:09:58 +0200 Subject: [PATCH 06/74] a more user-friendly doPreventingRecursion --- .../src/com/intellij/openapi/util/RecursionManager.java | 9 +++++++++ .../groovy/lang/psi/impl/TypeInferenceHelper.java | 2 +- .../lang/psi/impl/synthetic/GroovyScriptClass.java | 2 +- .../plugins/groovy/lang/psi/util/GrClassImplUtil.java | 2 +- .../plugins/groovy/spock/SpockVariableDescriptor.java | 5 +---- xml/impl/src/com/intellij/xml/util/XmlUtil.java | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/RecursionManager.java b/platform/util/src/com/intellij/openapi/util/RecursionManager.java index a639194fe217..23453dede993 100644 --- a/platform/util/src/com/intellij/openapi/util/RecursionManager.java +++ b/platform/util/src/com/intellij/openapi/util/RecursionManager.java @@ -56,6 +56,15 @@ public class RecursionManager { } }; + /** + * @see RecursionGuard#doPreventingRecursion(Object, boolean, Computable) + */ + @SuppressWarnings("JavaDoc") + @Nullable + public static T doPreventingRecursion(@NotNull Object key, boolean memoize, Computable computation) { + return createGuard(computation.getClass().getName()).doPreventingRecursion(key, memoize, computation); + } + /** * @param id just some string to separate different recursion prevention policies from each other * @return a helper object which allow you to perform reentrancy-safe computations and check whether caching will be safe. diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java index e053645d7297..6396084c63dc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/TypeInferenceHelper.java @@ -54,7 +54,7 @@ public class TypeInferenceHelper { @Nullable public static PsiType getInferredType(@NotNull final GrReferenceExpression refExpr) { - return RecursionManager.createGuard("refType").doPreventingRecursion(refExpr, true, new Computable() { + return RecursionManager.doPreventingRecursion(refExpr, true, new Computable() { @Override public PsiType compute() { @SuppressWarnings("unchecked") GroovyPsiElement scope = diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GroovyScriptClass.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GroovyScriptClass.java index 6e8a36fec808..872117e2a8ca 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GroovyScriptClass.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GroovyScriptClass.java @@ -352,7 +352,7 @@ public class GroovyScriptClass extends LightElement implements GrMemberOwner, Sy return CachedValuesManager.getManager(getProject()).getCachedValue(this, new CachedValueProvider>() { @Override public Result> compute() { - List result = RecursionManager.createGuard("groovy.scriptFields").doPreventingRecursion(GroovyScriptClass.this, true, new Computable>() { + List result = RecursionManager.doPreventingRecursion(GroovyScriptClass.this, true, new Computable>() { @Override public List compute() { final List result = new ArrayList(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java index c84526702fb4..17506849afde 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java @@ -129,7 +129,7 @@ public class GrClassImplUtil { @Nullable private static List getImplementsFromDelegate(@NotNull final GrTypeDefinition grType, final Set visited) { - return RecursionManager.createGuard("groovyDelegateFields").doPreventingRecursion(grType, true, new Computable>() { + return RecursionManager.doPreventingRecursion(grType, true, new Computable>() { @Override public List compute() { List result = new ArrayList(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockVariableDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockVariableDescriptor.java index c25dd92a07f6..5b03de4c03f9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockVariableDescriptor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockVariableDescriptor.java @@ -1,7 +1,6 @@ package org.jetbrains.plugins.groovy.spock; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.RecursionGuard; import com.intellij.openapi.util.RecursionManager; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; @@ -29,8 +28,6 @@ public class SpockVariableDescriptor { private PsiVariable myVariable; - private static final RecursionGuard guard = RecursionManager.createGuard("SpockVariableDescriptor"); - public SpockVariableDescriptor(PsiElement navigationElement, String name) { myName = name; myNavigationElement = navigationElement; @@ -63,7 +60,7 @@ public class SpockVariableDescriptor { if (myVariable == null) { final PsiManager manager = myNavigationElement.getManager(); - PsiType type = guard.doPreventingRecursion(this, true, new Computable() { + PsiType type = RecursionManager.doPreventingRecursion(this, true, new Computable() { @Override public PsiType compute() { PsiType res = null; diff --git a/xml/impl/src/com/intellij/xml/util/XmlUtil.java b/xml/impl/src/com/intellij/xml/util/XmlUtil.java index 790d6e5c37a4..e37d365698e4 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/XmlUtil.java @@ -668,7 +668,7 @@ public class XmlUtil { final PsiElement[] inclusion = CachedValuesManager.getManager(xincludeTag.getProject()).getCachedValue(xincludeTag, new CachedValueProvider() { public Result compute() { - return RecursionManager.createGuard("xinclude").doPreventingRecursion(xincludeTag, true, new Computable>() { + return RecursionManager.doPreventingRecursion(xincludeTag, true, new Computable>() { @Override public Result compute() { return computeInclusion(xincludeTag); From af061abc0a5e58e386ab0fe40f48a20c8c6d36a9 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 11:22:13 +0200 Subject: [PATCH 07/74] run java tests in their own classpath --- java/testFramework/testFramework-java.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/java/testFramework/testFramework-java.iml b/java/testFramework/testFramework-java.iml index 129c4b2f135a..edbdff617f45 100644 --- a/java/testFramework/testFramework-java.iml +++ b/java/testFramework/testFramework-java.iml @@ -20,6 +20,7 @@ + From d23deff60e2a18bb71cbafa6b9c9522b38e0d230 Mon Sep 17 00:00:00 2001 From: "Rustam.Vishnyakov" Date: Tue, 16 Aug 2011 18:11:56 +0400 Subject: [PATCH 08/74] Java indent options moved to language settings --- .../ide/JavaLanguageCodeStyleSettingsProvider.java | 11 ++++++++++- resources/src/META-INF/IdeaPlugin.xml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java index 31ebb67c8234..c30d115cba82 100644 --- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java @@ -15,6 +15,8 @@ */ package com.intellij.ide; +import com.intellij.application.options.IndentOptionsEditor; +import com.intellij.application.options.JavaIndentOptionsEditor; import com.intellij.lang.Language; import com.intellij.lang.StdLanguages; import com.intellij.lang.java.JavaLanguage; @@ -79,7 +81,9 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett @Override public CommonCodeStyleSettings getDefaultCommonSettings() { - return new CommonCodeStyleSettings(JavaLanguage.INSTANCE); + CommonCodeStyleSettings settings = new CommonCodeStyleSettings(JavaLanguage.INSTANCE); + settings.initIndentOptions(); + return settings; } @Override @@ -87,6 +91,11 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett return false; } + @Override + public IndentOptionsEditor getIndentOptionsEditor() { + return new JavaIndentOptionsEditor(); + } + private static final String GENERAL_CODE_SAMPLE = "public class Foo {\n" + " public int[] X = new int[]{1, 3, 5 7, 9, 11};\n" + diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index f38211bb7bd5..262e1071eafa 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -820,7 +820,7 @@ - + From 409810d960154d25276922b0a2b21707e5ce96d0 Mon Sep 17 00:00:00 2001 From: "Rustam.Vishnyakov" Date: Tue, 16 Aug 2011 19:51:20 +0400 Subject: [PATCH 09/74] Indent options upgrade fix --- .../com/intellij/psi/codeStyle/CodeStyleSettings.java | 10 ++++++++++ .../psi/codeStyle/CommonCodeStyleSettings.java | 11 ++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java index 1a47ad44e4cf..38e61d234517 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java @@ -574,6 +574,16 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea final FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(extension); if (fileType != FileTypes.UNKNOWN && fileType != FileTypes.PLAIN_TEXT && !myAdditionalIndentOptions.containsKey(fileType) && fileType.getDefaultExtension().length() != 0) { registerAdditionalIndentOptions(fileType, options); + // + // Upgrade to version 11 + // + if (fileType instanceof LanguageFileType) { + Language lang = ((LanguageFileType)fileType).getLanguage(); + CommonCodeStyleSettings langSettings = myCommonSettingsManager.getCommonSettings(lang); + if (langSettings != this && langSettings.getIndentOptions() != null) { + langSettings.importOldIndentOptions(this); + } + } } } diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java index 78961aae124e..97c2f1b132a6 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java @@ -53,7 +53,7 @@ public class CommonCodeStyleSettings { } void importOldIndentOptions(@NotNull CodeStyleSettings rootSettings) { - if (myFileType != null && myIndentOptions != null && !myIndentOptions.isFoundForLanguage()) { + if (myFileType != null && myIndentOptions != null) { if (getFileTypeIndentOptionsProvider() == null) { IndentOptions fileTypeIdentOptions = rootSettings.getAdditionalIndentOptions(myFileType); if (fileTypeIdentOptions != null) { @@ -822,9 +822,7 @@ public class CommonCodeStyleSettings { public int LABEL_INDENT_SIZE = 0; public boolean LABEL_INDENT_ABSOLUTE = false; public boolean USE_RELATIVE_INDENTS = false; - - private boolean myFoundForLanguage = false; - + private final static String INDENT_OPTIONS_TAG = "indentOptions"; public void readExternal(Element element) throws InvalidDataException { @@ -851,15 +849,10 @@ public class CommonCodeStyleSettings { public void deserialize(Element element) { Element indentOptionsElement = element.getChild(INDENT_OPTIONS_TAG); if (indentOptionsElement != null) { - myFoundForLanguage = true; XmlSerializer.deserializeInto(this, indentOptionsElement); } } - public boolean isFoundForLanguage() { - return myFoundForLanguage; - } - public Object clone() { try { return super.clone(); From 2f1648434db26bfd4746de92f70d2fd51fc58dbf Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 17 Aug 2011 13:27:42 +0400 Subject: [PATCH 10/74] revert (additional keymap Ctrl(meta)+E for recent commit messages) --- platform/platform-resources/src/idea/Keymap_Default.xml | 1 - platform/platform-resources/src/idea/Keymap_Mac.xml | 1 - platform/platform-resources/src/idea/Keymap_MacClassic.xml | 1 - 3 files changed, 3 deletions(-) diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index 41215f4027df..868c9d9f1b87 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -859,7 +859,6 @@ - diff --git a/platform/platform-resources/src/idea/Keymap_Mac.xml b/platform/platform-resources/src/idea/Keymap_Mac.xml index cc862b1e2b6e..e1a16bf5dc69 100644 --- a/platform/platform-resources/src/idea/Keymap_Mac.xml +++ b/platform/platform-resources/src/idea/Keymap_Mac.xml @@ -431,7 +431,6 @@ - diff --git a/platform/platform-resources/src/idea/Keymap_MacClassic.xml b/platform/platform-resources/src/idea/Keymap_MacClassic.xml index a1a4775e0c44..fa5a35d5f9bb 100644 --- a/platform/platform-resources/src/idea/Keymap_MacClassic.xml +++ b/platform/platform-resources/src/idea/Keymap_MacClassic.xml @@ -324,7 +324,6 @@ - From 21d91e40ae165b4c41d95efbd4822cf77492f58d Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 17 Aug 2011 13:45:35 +0400 Subject: [PATCH 11/74] show facet type nodes in Project Structure dialog only if corresponding facets exist in project --- ...ction.java => AddFacetToModuleAction.java} | 19 +--- .../projectRoot/AddFacetOfTypeAction.java | 65 ++++++------ .../FacetStructureConfigurable.java | 26 ++++- .../projectRoot/FacetTypeConfigurable.java | 4 - .../projectRoot/FacetsTreeCellRenderer.java | 2 +- .../ModuleStructureConfigurable.java | 16 ++- ...onfigurable.java => TextConfigurable.java} | 98 ++++++++++--------- .../com/intellij/facet/FacetTypeRegistry.java | 2 + .../facet/impl/FacetTypeRegistryImpl.java | 23 +++-- 9 files changed, 144 insertions(+), 111 deletions(-) rename java/idea-ui/src/com/intellij/facet/impl/ui/actions/{AddFacetAction.java => AddFacetToModuleAction.java} (87%) rename java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/{ModuleGroupConfigurable.java => TextConfigurable.java} (59%) diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java similarity index 87% rename from java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java rename to java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java index 033ca8078519..754d491060ea 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetAction.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java @@ -26,19 +26,16 @@ import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; -import java.util.Arrays; -import java.util.Comparator; - /** * @author nik */ -public class AddFacetAction extends AnAction implements DumbAware { - private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.actions.AddFacetAction"); +public class AddFacetToModuleAction extends AnAction implements DumbAware { + private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.actions.AddFacetToModuleAction"); private final FacetEditorFacade myEditor; private final Project myProject; private final FacetType myType; - public AddFacetAction(final FacetEditorFacade editor, Project project, final FacetType type) { + private AddFacetToModuleAction(final FacetEditorFacade editor, Project project, final FacetType type) { super(type.getPresentableName(), null, type.getIcon()); myEditor = editor; myProject = project; @@ -95,16 +92,10 @@ public class AddFacetAction extends AnAction implements DumbAware { } public static AnAction[] createAddFacetActions(FacetEditorFacade editor, Project project) { - final FacetType[] types = FacetTypeRegistry.getInstance().getFacetTypes(); - Arrays.sort(types, new Comparator() { - public int compare(final FacetType o1, final FacetType o2) { - return o1.getPresentableName().compareTo(o2.getPresentableName()); - } - }); - + final FacetType[] types = FacetTypeRegistry.getInstance().getSortedFacetTypes(); AnAction[] actions = new AnAction[types.length]; for (int i = 0; i < types.length; i++) { - actions[i] = new AddFacetAction(editor, project, types[i]); + actions[i] = new AddFacetToModuleAction(editor, project, types[i]); } return actions; } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java index 41f397ab005a..82a580cfdf52 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/AddFacetOfTypeAction.java @@ -20,8 +20,8 @@ import com.intellij.facet.FacetType; import com.intellij.facet.FacetTypeId; import com.intellij.facet.FacetTypeRegistry; import com.intellij.facet.impl.ProjectFacetsConfigurator; -import com.intellij.facet.impl.invalid.InvalidFacetType; import com.intellij.ide.util.ChooseElementsDialog; +import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.DumbAwareAction; @@ -29,10 +29,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.NamedConfigurable; -import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.ArrayList; @@ -44,16 +41,18 @@ import java.util.List; * @author nik */ class AddFacetOfTypeAction extends DumbAwareAction { - private final FacetStructureConfigurable myFacetStructureConfigurable; + private final FacetType myFacetType; + private final StructureConfigurableContext myContext; - AddFacetOfTypeAction(FacetStructureConfigurable facetStructureConfigurable) { - super("New Facet", null, PlatformIcons.ADD_ICON); - this.myFacetStructureConfigurable = facetStructureConfigurable; + AddFacetOfTypeAction(final FacetType type, final StructureConfigurableContext context) { + super(type.getPresentableName(), null, type.getIcon()); + myFacetType = type; + myContext = context; } @Override public void actionPerformed(AnActionEvent e) { - final FacetType type = getSelectedType(); + final FacetType type = myFacetType; if (type == null) return; final FacetTypeId underlyingFacetType = type.getUnderlyingFacetType(); @@ -66,10 +65,9 @@ class AddFacetOfTypeAction extends DumbAwareAction { } private void addSubFacet(FacetType type, FacetTypeId underlyingType) { - final StructureConfigurableContext context = myFacetStructureConfigurable.myContext; - final ProjectFacetsConfigurator facetsConfigurator = context.getModulesConfigurator().getFacetsConfigurator(); + final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator(); List suitableParents = new ArrayList(); - for (Module module : context.getModules()) { + for (Module module : myContext.getModules()) { if (type.isSuitableModuleType(module.getModuleType())) { suitableParents.addAll(facetsConfigurator.getFacetsByType(module, underlyingType)); } @@ -83,14 +81,14 @@ class AddFacetOfTypeAction extends DumbAwareAction { } } - final Project project = context.getProject(); + final Project project = myContext.getProject(); if (suitableParents.isEmpty()) { final String parentType = FacetTypeRegistry.getInstance().findFacetType(underlyingType).getPresentableName(); Messages.showErrorDialog(project, "No suitable parent " + parentType + " facets found", "Cannot Create " + type.getPresentableName() + " Facet"); return; } - ChooseParentFacetDialog dialog = new ChooseParentFacetDialog(project, suitableParents, "Select Parent Facet", null); + ChooseParentFacetDialog dialog = new ChooseParentFacetDialog(project, suitableParents); dialog.show(); final List chosen = dialog.getChosenElements(); if (!dialog.isOK() || chosen.size() != 1) return; @@ -101,9 +99,8 @@ class AddFacetOfTypeAction extends DumbAwareAction { } private void addFacetToModule(@NotNull FacetType type) { - final StructureConfigurableContext context = myFacetStructureConfigurable.myContext; - final ProjectFacetsConfigurator facetsConfigurator = context.getModulesConfigurator().getFacetsConfigurator(); - List suitableModules = new ArrayList(Arrays.asList(context.getModules())); + final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator(); + List suitableModules = new ArrayList(Arrays.asList(myContext.getModules())); final Iterator iterator = suitableModules.iterator(); while (iterator.hasNext()) { Module module = iterator.next(); @@ -111,7 +108,7 @@ class AddFacetOfTypeAction extends DumbAwareAction { iterator.remove(); } } - final Project project = context.getProject(); + final Project project = myContext.getProject(); if (suitableModules.isEmpty()) { Messages.showErrorDialog(project, "No suitable modules for " + type.getPresentableName() + " facet found.", "Cannot Create Facet"); return; @@ -129,27 +126,29 @@ class AddFacetOfTypeAction extends DumbAwareAction { ProjectStructureConfigurable.getInstance(project).select(facet, true); } - @Override - public void update(AnActionEvent e) { - final FacetType type = getSelectedType(); - e.getPresentation().setEnabled(myFacetStructureConfigurable.myContext.getModules().length > 0 && type != null && !(type instanceof InvalidFacetType)); + public static AnAction[] createAddFacetActions(FacetStructureConfigurable configurable) { + final List result = new ArrayList(); + final StructureConfigurableContext context = configurable.myContext; + for (FacetType type : FacetTypeRegistry.getInstance().getSortedFacetTypes()) { + if (hasSuitableModules(context, type)) { + result.add(new AddFacetOfTypeAction(type, context)); + } + } + return result.toArray(new AnAction[result.size()]); } - @Nullable - private FacetType getSelectedType() { - final NamedConfigurable configurable = myFacetStructureConfigurable.getSelectedConfugurable(); - if (configurable instanceof FacetTypeConfigurable) { - return ((FacetTypeConfigurable)configurable).getFacetType(); + private static boolean hasSuitableModules(StructureConfigurableContext context, FacetType type) { + for (Module module : context.getModules()) { + if (type.isSuitableModuleType(module.getModuleType())) { + return true; + } } - else if (configurable instanceof FacetConfigurable) { - return ((FacetConfigurable)configurable).getEditableObject().getType(); - } - return null; + return false; } private static class ChooseParentFacetDialog extends ChooseElementsDialog { - private ChooseParentFacetDialog(Project project, List items, String title, String description) { - super(project, items, title, description, true); + private ChooseParentFacetDialog(Project project, List items) { + super(project, items, "Select Parent Facet", null, true); myChooser.setSingleSelectionMode(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java index f8b9ec7d8df7..d39147b99ba8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java @@ -36,6 +36,8 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStr import com.intellij.openapi.ui.DetailsComponent; import com.intellij.openapi.ui.NamedConfigurable; import com.intellij.openapi.util.IconLoader; +import com.intellij.util.ui.tree.TreeUtil; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +54,7 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { private final ModuleManager myModuleManager; private final Map, FacetTypeEditor> myFacetTypeEditors = new HashMap, FacetTypeEditor>(); private MultipleFacetSettingsEditor myCurrentMultipleSettingsEditor; + @NonNls private static final String NO_FRAMEWORKS_NODE = "No facets are configured"; public FacetStructureConfigurable(final Project project, ModuleManager moduleManager) { super(project); @@ -80,15 +83,20 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { protected void loadTree() { myTree.setRootVisible(false); myTree.setShowsRootHandles(false); + boolean hasFacetTypeNodes = false; for (FacetType facetType : FacetTypeRegistry.getInstance().getFacetTypes()) { - final FacetTypeEditor editor = getOrCreateFacetTypeEditor(facetType); - if (editor.isVisible() || ProjectFacetManager.getInstance(myProject).hasFacets(facetType.getId())) { + if (ProjectFacetManager.getInstance(myProject).hasFacets(facetType.getId())) { + hasFacetTypeNodes = true; addFacetTypeNode(facetType); } } if (!InvalidFacetManager.getInstance(myProject).getInvalidFacets().isEmpty()) { + hasFacetTypeNodes = true; addFacetTypeNode(InvalidFacetType.getInstance()); } + if (!hasFacetTypeNodes) { + addNode(new MyNode(new TextConfigurable(NO_FRAMEWORKS_NODE, NO_FRAMEWORKS_NODE, "Facets", "Press '+' button to add a new facet", null, null)), myRoot); + } addNode(new MyNode(new FrameworkDetectionConfigurable(myProject)), myRoot); } @@ -108,6 +116,11 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { } private MyNode addFacetTypeNode(FacetType facetType) { + final MyNode noFrameworksNode = findNodeByObject(myRoot, NO_FRAMEWORKS_NODE); + if (noFrameworksNode != null) { + removePaths(TreeUtil.getPathFromRoot(noFrameworksNode)); + } + FacetTypeConfigurable facetTypeConfigurable = new FacetTypeConfigurable(this, facetType); MyNode facetTypeNode = new MyNode(facetTypeConfigurable); addNode(facetTypeNode, myRoot); @@ -167,6 +180,7 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { public void reset() { super.reset(); myFacetTypeEditors.clear(); + TreeUtil.expandAll(myTree); } @@ -202,7 +216,13 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { @NotNull protected ArrayList createActions(final boolean fromPopup) { ArrayList actions = new ArrayList(); - actions.add(new AddFacetOfTypeAction(this)); + actions.add(new AbstractAddGroup("Add") { + @NotNull + @Override + public AnAction[] getChildren(@Nullable AnActionEvent e) { + return AddFacetOfTypeAction.createAddFacetActions(FacetStructureConfigurable.this); + } + }); if (fromPopup) { actions.add(new MyNavigateAction()); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java index 567290019169..88db4c5dfe01 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetTypeConfigurable.java @@ -58,10 +58,6 @@ public class FacetTypeConfigurable extends NamedConfigurable { return myFacetType.getIcon(); } - public FacetType getFacetType() { - return myFacetType; - } - public String getHelpTopic() { final FacetTypeEditor editor = myFacetStructureConfigurable.getFacetTypeEditor(myFacetType); return editor != null ? editor.getHelpTopic() : null; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetsTreeCellRenderer.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetsTreeCellRenderer.java index 5b89b3904593..deea9427c3b4 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetsTreeCellRenderer.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetsTreeCellRenderer.java @@ -54,7 +54,7 @@ public class FacetsTreeCellRenderer extends GroupedElementsRenderer.Tree impleme final NamedConfigurable configurable = node.getConfigurable(); if (configurable != null) { final Icon icon = configurable.getIcon(expanded); - final boolean showSeparator = icon == null; + final boolean showSeparator = configurable instanceof FrameworkDetectionConfigurable; int width = -1; if (showSeparator) { final int treeWidth = tree.getSize().width; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java index 17a90b1d4328..abc1e910a79d 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java @@ -19,7 +19,7 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot; import com.intellij.CommonBundle; import com.intellij.facet.Facet; import com.intellij.facet.impl.ProjectFacetsConfigurator; -import com.intellij.facet.impl.ui.actions.AddFacetAction; +import com.intellij.facet.impl.ui.actions.AddFacetToModuleAction; import com.intellij.ide.IdeBundle; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.projectView.impl.ModuleGroup; @@ -63,6 +63,7 @@ import com.intellij.openapi.wm.WindowManager; import com.intellij.ui.navigation.Place; import com.intellij.util.Consumer; import com.intellij.util.Function; +import com.intellij.util.PlatformIcons; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NonNls; @@ -234,7 +235,8 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple }, new Function() { public MyNode fun(final ModuleGroup moduleGroup) { - final NamedConfigurable moduleGroupConfigurable = new ModuleGroupConfigurable(moduleGroup); + final NamedConfigurable moduleGroupConfigurable = + createModuleGroupConfigurable(moduleGroup); return new MyNode(moduleGroupConfigurable, true); } }); @@ -281,7 +283,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple } }, new Function() { public MyNode fun(final ModuleGroup moduleGroup) { - final NamedConfigurable moduleGroupConfigurable = new ModuleGroupConfigurable(moduleGroup); + final NamedConfigurable moduleGroupConfigurable = createModuleGroupConfigurable(moduleGroup); return new MyNode(moduleGroupConfigurable, true); } }); @@ -536,6 +538,12 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple return myContext; } + private static TextConfigurable createModuleGroupConfigurable(final ModuleGroup moduleGroup) { + return new TextConfigurable(moduleGroup, moduleGroup.toString(), + ProjectBundle.message("module.group.banner.text", moduleGroup.toString()), + ProjectBundle.message("project.roots.module.groups.text"), + PlatformIcons.OPENED_MODULE_GROUP_ICON, PlatformIcons.CLOSED_MODULE_GROUP_ICON); + } private class MyDataProviderWrapper extends JPanel implements DataProvider { public MyDataProviderWrapper(final JComponent component) { @@ -639,7 +647,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple ArrayList result = new ArrayList(); result.add(module); - final AnAction[] facets = AddFacetAction.createAddFacetActions(myFacetEditorFacade, myProject); + final AnAction[] facets = AddFacetToModuleAction.createAddFacetActions(myFacetEditorFacade, myProject); if (facets.length > 0) { result.add(new Separator(ProjectBundle.message("add.group.facet.separator"))); ContainerUtil.addAll(result, facets); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleGroupConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/TextConfigurable.java similarity index 59% rename from java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleGroupConfigurable.java rename to java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/TextConfigurable.java index a3fe20581f7f..f6c08deb3de2 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleGroupConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/TextConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -13,68 +13,44 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * Created by IntelliJ IDEA. - * User: Anna.Kozlova - * Date: 16-Jul-2006 - * Time: 16:52:27 - */ package com.intellij.openapi.roots.ui.configuration.projectRoot; -import com.intellij.ide.projectView.impl.ModuleGroup; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.ui.NamedConfigurable; import com.intellij.openapi.ui.PanelWithText; -import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; -public class ModuleGroupConfigurable extends NamedConfigurable { - private final ModuleGroup myModuleGroup; +/** + * @author nik + */ +public class TextConfigurable extends NamedConfigurable { + private final T myObject; + private final String myBannerSlogan; + private final String myDisplayName; + private final Icon myOpenedIcon; + private final Icon myClosedIcon; + private final String myDescriptionText; - public ModuleGroupConfigurable(final ModuleGroup moduleGroup) { - myModuleGroup = moduleGroup; + public TextConfigurable(final T object, + final String displayName, + final String bannerSlogan, + final String descriptionText, + final Icon openedIcon, final Icon closedIcon) { + myDisplayName = displayName; + myBannerSlogan = bannerSlogan; + myDescriptionText = descriptionText; + myOpenedIcon = openedIcon; + myClosedIcon = closedIcon; + myObject = object; } public void setDisplayName(final String name) { //do nothing } - public ModuleGroup getEditableObject() { - return myModuleGroup; - } - - public String getBannerSlogan() { - return ProjectBundle.message("module.group.banner.text", myModuleGroup.toString()); - } - - public String getDisplayName() { - return myModuleGroup.toString(); - } - - public Icon getIcon() { - return PlatformIcons.OPENED_MODULE_GROUP_ICON; - } - - public Icon getIcon(final boolean open) { - return open ? PlatformIcons.OPENED_MODULE_GROUP_ICON : PlatformIcons.CLOSED_MODULE_GROUP_ICON; - } - - @Nullable - @NonNls - public String getHelpTopic() { - return null; - } - - - public JComponent createOptionsPanel() { - return new PanelWithText(ProjectBundle.message("project.roots.module.groups.text")); - } - public boolean isModified() { return false; } @@ -90,4 +66,34 @@ public class ModuleGroupConfigurable extends NamedConfigurable { public void disposeUIResources() { //do nothing } + + @Nullable + @NonNls + public String getHelpTopic() { + return null; + } + + public T getEditableObject() { + return myObject; + } + + public String getBannerSlogan() { + return myBannerSlogan; + } + + public String getDisplayName() { + return myDisplayName; + } + + public Icon getIcon() { + return myOpenedIcon; + } + + public Icon getIcon(final boolean open) { + return open ? myOpenedIcon : myClosedIcon; + } + + public JComponent createOptionsPanel() { + return new PanelWithText(myDescriptionText); + } } diff --git a/platform/lang-api/src/com/intellij/facet/FacetTypeRegistry.java b/platform/lang-api/src/com/intellij/facet/FacetTypeRegistry.java index 1b069b998010..7884b7bad32b 100644 --- a/platform/lang-api/src/com/intellij/facet/FacetTypeRegistry.java +++ b/platform/lang-api/src/com/intellij/facet/FacetTypeRegistry.java @@ -42,6 +42,8 @@ public abstract class FacetTypeRegistry { public abstract FacetType[] getFacetTypes(); + public abstract FacetType[] getSortedFacetTypes(); + @Nullable public abstract FacetType findFacetType(String id); diff --git a/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java index b4a1c7ad25ba..47432d54abbf 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java @@ -18,23 +18,25 @@ package com.intellij.facet.impl; import com.intellij.facet.*; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.ExtensionPointListener; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.PluginDescriptor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author nik */ public class FacetTypeRegistryImpl extends FacetTypeRegistry { private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.FacetTypeRegistryImpl"); + private static final Comparator FACET_TYPE_COMPARATOR = new Comparator() { + public int compare(final FacetType o1, final FacetType o2) { + return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()); + } + }; private final Map myTypeIds = new HashMap(); private final Map myFacetTypes = new HashMap(); private boolean myExtensionsLoaded = false; @@ -67,7 +69,16 @@ public class FacetTypeRegistryImpl extends FacetTypeRegistry { public synchronized FacetType[] getFacetTypes() { loadExtensions(); final Collection types = myFacetTypes.values(); - return types.toArray(new FacetType[types.size()]); + final FacetType[] facetTypes = types.toArray(new FacetType[types.size()]); + Arrays.sort(facetTypes, FACET_TYPE_COMPARATOR); + return facetTypes; + } + + @Override + public FacetType[] getSortedFacetTypes() { + final FacetType[] types = getFacetTypes(); + Arrays.sort(types, FACET_TYPE_COMPARATOR); + return types; } @Nullable From df94793c112c1b505c6a7441e903562d62ea1309 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 17 Aug 2011 12:15:57 +0200 Subject: [PATCH 12/74] cleanup --- .../cvsBrowser/AbstractVcsDataProvider.java | 13 +++-- .../cvsSupport2/cvsBrowser/CvsTreeModel.java | 48 ------------------- .../cvsBrowser/ModuleDataProvider.java | 4 +- .../cvsBrowser/RootDataProvider.java | 3 +- 4 files changed, 10 insertions(+), 58 deletions(-) delete mode 100644 plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java index 99baf3b9b5bf..10f86b03bbff 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java @@ -23,7 +23,6 @@ import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler; import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent; -import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetDirectoriesListViaUpdateOperation; import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsListenerWithProgress; import com.intellij.openapi.application.ApplicationManager; @@ -52,12 +51,12 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi } } - public DirectoryContentProvider createDirectoryContentProvider(String path) { + public CvsOperation createDirectoryContentProvider(String path) { return new GetDirectoriesListViaUpdateOperation(myEnvironment, path); } - private static class MyCancellableCvsHandler extends CommandCvsHandler { - private MyCancellableCvsHandler(final String title, final CvsOperation cvsOperation) { + private static class CancellableCvsHandler extends CommandCvsHandler { + private CancellableCvsHandler(final String title, final CvsOperation cvsOperation) { super(title, cvsOperation, true); } @@ -72,12 +71,12 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi } } - private static void executeCommand(final DirectoryContentProvider command, final GetContentCallback callback) { + private static void executeCommand(final CvsOperation command, final GetContentCallback callback) { final CvsOperationExecutor executor = new CvsOperationExecutor(false, callback.getProject(), callback.getModalityState()); executor.setIsQuietOperation(true); - final MyCancellableCvsHandler cvsHandler = - new MyCancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), (CvsOperation) command); + final CancellableCvsHandler cvsHandler = + new CancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), command); callback.useForCancel(cvsHandler.getProgressListener()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java deleted file mode 100644 index 7ee71be7b78b..000000000000 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2009 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.cvsSupport2.cvsBrowser; - -import javax.swing.*; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; - -/** - * author: lesya - */ -public class CvsTreeModel extends DefaultTreeModel{ - private JTree myTree; - private CvsTree myCvsTree; - - public CvsTreeModel(TreeNode root) { - super(root, true); - } - - public CvsTree getCvsTree() { - return myCvsTree; - } - - public void setCvsTree(CvsTree cvsTree) { - myCvsTree = cvsTree; - } - - public void setTree(JTree tree) { - myTree = tree; - } - - public void selectRoot(){ - myTree.addSelectionPath(myTree.getPathForRow(0)); - } -} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java index 533b0841bcf2..e7c5dfbf3c5b 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java @@ -16,7 +16,7 @@ package com.intellij.cvsSupport2.cvsBrowser; import com.intellij.cvsSupport2.connections.CvsEnvironment; -import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider; +import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModuleContentOperation; /** @@ -27,7 +27,7 @@ public class ModuleDataProvider extends AbstractVcsDataProvider{ super(environment); } - public DirectoryContentProvider createDirectoryContentProvider(String path) { + public CvsOperation createDirectoryContentProvider(String path) { return new GetModuleContentOperation(myEnvironment, path); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java index 0822ecac3577..5bdf07a50077 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java @@ -17,6 +17,7 @@ package com.intellij.cvsSupport2.cvsBrowser; import com.intellij.cvsSupport2.connections.CvsEnvironment; import com.intellij.cvsSupport2.cvsoperations.common.CompositeOperation; +import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetDirectoriesListViaUpdateOperation; @@ -55,7 +56,7 @@ public class RootDataProvider extends AbstractVcsDataProvider{ return new FolderDataProvider(myEnvironment); } - public DirectoryContentProvider createDirectoryContentProvider(String path) { + public CvsOperation createDirectoryContentProvider(String path) { return new RootDirectoryContentProvider(myEnvironment); } } From 0432e14673e927507becbe0a3a6c131e93e9846e Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 17 Aug 2011 12:23:36 +0200 Subject: [PATCH 13/74] report test connection problems with modal dialog instead of balloon --- .../connections/login/CvsLoginWorker.java | 5 +- .../config/ui/Cvs2SettingsEditPanel.java | 12 ++--- .../ext/ExtConnectionCvsSettings.java | 11 ++-- .../connections/ext/ExtLoginWorker.java | 17 +++---- .../connections/login/CvsLoginWorkerImpl.java | 41 +++------------ .../pserver/PServerLoginProviderImpl.java | 4 +- .../common/CvsCommandOperation.java | 7 ++- .../cvsoperations/common/LoginPerformer.java | 50 +++++++++++++++---- 8 files changed, 76 insertions(+), 71 deletions(-) diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorker.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorker.java index 4a23a75ecdc2..7b72d17f9e7e 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorker.java +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorker.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -18,6 +18,7 @@ package com.intellij.cvsSupport2.connections.login; import com.intellij.openapi.vcs.CalledInAwt; import com.intellij.openapi.vcs.CalledInBackground; import com.intellij.util.ThreeState; +import org.netbeans.lib.cvsclient.connection.AuthenticationException; // todo rename? public interface CvsLoginWorker { @@ -28,7 +29,7 @@ public interface CvsLoginWorker { boolean promptForPassword(); @CalledInBackground - ThreeState silentLogin(boolean forceCheck); + ThreeState silentLogin(boolean forceCheck) throws AuthenticationException; void goOffline(); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java index 8a9b938a6e8a..1ee32a78c711 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -26,7 +26,6 @@ import com.intellij.cvsSupport2.connections.CvsRootDataBuilder; import com.intellij.cvsSupport2.connections.ext.ui.ExtConnectionDualPanel; import com.intellij.cvsSupport2.connections.local.ui.LocalConnectionSettingsPanel; import com.intellij.cvsSupport2.connections.login.CvsLoginWorker; -import com.intellij.cvsSupport2.connections.pserver.ui.PServerSettingsPanel; import com.intellij.cvsSupport2.connections.ssh.ui.SshConnectionSettingsPanel; import com.intellij.cvsSupport2.connections.ui.ProxySettingsPanel; import com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl; @@ -199,7 +198,6 @@ public class Cvs2SettingsEditPanel implements CvsRootEditor { public static void testConnection(CvsRootConfiguration configuration, Component component, Project project) { try { final ModalityContextImpl executor = new ModalityContextImpl(true); - final CvsLoginWorker loginWorker = configuration.getLoginWorker(executor, project); final ThreeState checkResult = LoginPerformer.checkLoginWorker(loginWorker, executor, project, true); @@ -265,14 +263,14 @@ public class Cvs2SettingsEditPanel implements CvsRootEditor { } } - private String getProxyPanelName(CvsRootData cvsRootData) { + private static String getProxyPanelName(CvsRootData cvsRootData) { if (cvsRootData.METHOD == null) { return EMPTY; } return cvsRootData.METHOD.supportsProxyConnection() ? NON_EMPTY_PROXY_SETTINGS : EMPTY; } - private String getSettingsPanelName(CvsRootData cvsRootData) { + private static String getSettingsPanelName(CvsRootData cvsRootData) { CvsMethod method = cvsRootData.METHOD; if (method == null) { return EMPTY; @@ -282,7 +280,7 @@ public class Cvs2SettingsEditPanel implements CvsRootEditor { } } - private void setEnabled(Component component, boolean enabled) { + private static void setEnabled(Component component, boolean enabled) { component.setEnabled(enabled); if (component instanceof Container) { @@ -302,7 +300,7 @@ public class Cvs2SettingsEditPanel implements CvsRootEditor { clearAllTextFieldsIn(myPanel); } - private void clearAllTextFieldsIn(Component component) { + private static void clearAllTextFieldsIn(Component component) { if (component instanceof JTextField) { ((JTextField)component).setText(""); return; diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java index 2f677889424d..73b1a3367b55 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,6 +15,7 @@ */ package com.intellij.cvsSupport2.connections.ext; +import com.intellij.CvsBundle; import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration; import com.intellij.cvsSupport2.config.CvsRootConfiguration; import com.intellij.cvsSupport2.config.SshSettings; @@ -25,13 +26,13 @@ import com.intellij.cvsSupport2.connections.ssh.SSHPasswordProviderImpl; import com.intellij.cvsSupport2.connections.ssh.SshConnectionUtil; import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.errorHandling.ErrorRegistry; -import com.intellij.CvsBundle; -import com.intellij.util.ThreeState; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ThreeState; import org.jetbrains.annotations.NonNls; import org.netbeans.lib.cvsclient.command.CommandException; import org.netbeans.lib.cvsclient.command.IOCommandException; +import org.netbeans.lib.cvsclient.connection.AuthenticationException; import org.netbeans.lib.cvsclient.connection.IConnection; import java.io.IOException; @@ -84,7 +85,7 @@ public class ExtConnectionCvsSettings extends CvsConnectionSettings { return myWorker.promptForPassword(); } - public ThreeState silentLogin(boolean forceCheck) { + public ThreeState silentLogin(boolean forceCheck) throws AuthenticationException { return myWorker.silentLogin(forceCheck); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtLoginWorker.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtLoginWorker.java index 3437138db661..924199470a06 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtLoginWorker.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtLoginWorker.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,24 +15,23 @@ */ package com.intellij.cvsSupport2.connections.ext; +import com.intellij.cvsSupport2.config.CvsRootConfiguration; +import com.intellij.cvsSupport2.config.ui.CvsConfigurationsListEditor; import com.intellij.cvsSupport2.connections.login.CvsLoginWorkerImpl; -import com.intellij.cvsSupport2.connections.CvsConnectionSettings; import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics; import com.intellij.cvsSupport2.javacvsImpl.io.StreamLogger; -import com.intellij.cvsSupport2.config.CvsRootConfiguration; -import com.intellij.cvsSupport2.config.ui.CvsConfigurationsListEditor; -import com.intellij.openapi.project.Project; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; import org.netbeans.lib.cvsclient.connection.AuthenticationException; import org.netbeans.lib.cvsclient.connection.IConnection; import java.io.IOException; -public class ExtLoginWorker extends CvsLoginWorkerImpl { +public class ExtLoginWorker extends CvsLoginWorkerImpl { private static final Logger LOG = Logger.getInstance("#com.intellij.cvsSupport2.connections.ext.ExtLoginWorker"); - public ExtLoginWorker(final Project project, final CvsConnectionSettings settings, final ModalityContext executor) { + public ExtLoginWorker(final Project project, final ExtConnectionCvsSettings settings, final ModalityContext executor) { super(project, settings, executor); } @@ -41,6 +40,7 @@ public class ExtLoginWorker extends CvsLoginWorkerImpl { IConnection connection = mySettings.createConnection(new ReadWriteStatistics()); try { connection.open(new StreamLogger()); + mySettings.setOffline(false); } finally { try { @@ -65,6 +65,5 @@ public class ExtLoginWorker extends CvsLoginWorkerImpl { } @Override - protected void clearOldCredentials() { - } + protected void clearOldCredentials() {} } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorkerImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorkerImpl.java index 9fd3843b4472..ade01a4bf3be 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorkerImpl.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/login/CvsLoginWorkerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -26,11 +26,6 @@ import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.util.ThreeState; import org.netbeans.lib.cvsclient.connection.AuthenticationException; -import java.net.ConnectException; -import java.net.NoRouteToHostException; -import java.net.SocketTimeoutException; -import java.net.UnknownHostException; - public abstract class CvsLoginWorkerImpl implements CvsLoginWorker { protected final Project myProject; protected final ModalityContext myExecutor; @@ -44,6 +39,7 @@ public abstract class CvsLoginWorkerImpl implem @CalledInBackground protected abstract void silentLoginImpl(boolean forceCheck) throws AuthenticationException; + /** * @return true if login attempt should be repeated after prompting user */ @@ -52,14 +48,18 @@ public abstract class CvsLoginWorkerImpl implem protected abstract void clearOldCredentials(); - public ThreeState silentLogin(boolean forceCheck) { + public ThreeState silentLogin(boolean forceCheck) throws AuthenticationException { if (mySettings.isOffline()) return ThreeState.NO; try { silentLoginImpl(forceCheck); } catch (AuthenticationException e) { - return reportException(e); + if (e.isSolveable()) { + clearOldCredentials(); + return ThreeState.UNSURE; + } + throw e; } return ThreeState.YES; } @@ -69,31 +69,6 @@ public abstract class CvsLoginWorkerImpl implem VcsBalloonProblemNotifier.showOverChangesView(myProject, CvsBundle.message("set.offline.notification.text"), MessageType.WARNING); } - private ThreeState reportException(final AuthenticationException e) { - if (e.isSolveable()) { - clearOldCredentials(); - return ThreeState.UNSURE; - } - - Throwable cause = e.getCause(); - if (cause instanceof SocketTimeoutException) { - showConnectionErrorMessage(myProject, CvsBundle.message("error.message.timeout.error")); - } - else if (cause instanceof UnknownHostException) { - showConnectionErrorMessage(myProject, CvsBundle.message("error.message.unknown.host", mySettings.HOST)); - } - else if (cause instanceof ConnectException || cause instanceof NoRouteToHostException) { - showConnectionErrorMessage(myProject, CvsBundle.message("error.message.connection.error", mySettings.HOST)); - } else { - String localizedMessage = e.getLocalizedMessage(); - localizedMessage = (localizedMessage == null) ? e.getMessage() : localizedMessage; - localizedMessage = (localizedMessage == null) ? CvsBundle.message("error.dialog.title.cannot.connect.to.cvs") : localizedMessage; - showConnectionErrorMessage(myProject, localizedMessage); - } - - return ThreeState.NO; - } - public static void showConnectionErrorMessage(final Project project, final String message) { VcsBalloonProblemNotifier.showOverChangesView(project, message, MessageType.ERROR); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/PServerLoginProviderImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/PServerLoginProviderImpl.java index 5ec75b44d4fd..94e2168cb5d6 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/PServerLoginProviderImpl.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/pserver/PServerLoginProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -91,7 +91,7 @@ public class PServerLoginProviderImpl extends PServerLoginProvider { connection.close(); } catch (IOException e) { - // ignore + LOG.info(e); } } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java index 235fc59d9850..23b69fcadf33 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/CvsCommandOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -195,8 +195,7 @@ public abstract class CvsCommandOperation extends CvsOperation implements IFileI protected void execute(CvsRootProvider root, final CvsExecutionEnvironment executionEnvironment, ReadWriteStatistics statistics, ModalityContext executor) - throws CommandException, - VcsException { + throws CommandException, VcsException { IConnection connection = root.createConnection(statistics); execute(root, executionEnvironment, connection); @@ -294,7 +293,7 @@ public abstract class CvsCommandOperation extends CvsOperation implements IFileI @SuppressWarnings({"HardCodedStringLiteral"}) private static String composeCommandString(CvsRootProvider root, Command command) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(root.getLocalRoot()); result.append(" cvs "); GlobalOptions globalOptions = command.getGlobalOptions(); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/LoginPerformer.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/LoginPerformer.java index e0527cc1096a..b31404997c84 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/LoginPerformer.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/common/LoginPerformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,6 +15,7 @@ */ package com.intellij.cvsSupport2.cvsoperations.common; +import com.intellij.CvsBundle; import com.intellij.cvsSupport2.connections.CvsEnvironment; import com.intellij.cvsSupport2.connections.CvsRootProvider; import com.intellij.cvsSupport2.connections.login.CvsLoginWorker; @@ -22,14 +23,21 @@ import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.errorHandling.CvsException; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectLocator; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.intellij.util.ThreeState; import org.jetbrains.annotations.Nullable; +import org.netbeans.lib.cvsclient.connection.AuthenticationException; +import java.net.ConnectException; +import java.net.NoRouteToHostException; +import java.net.SocketTimeoutException; +import java.net.UnknownHostException; import java.util.Collection; public abstract class LoginPerformer { @@ -57,25 +65,49 @@ public abstract class LoginPerformer { public boolean loginAll(final ModalityContext executor, final boolean goOffline) { for (T root : myRoots) { final Project project = getProject(root); - final CvsLoginWorker worker = root.getLoginWorker(executor, project); - final ThreeState checkResult = checkLoginWorker(worker, executor, project, myForceCheck); - if (! ThreeState.YES.equals(checkResult)) { - if (ThreeState.UNSURE.equals(checkResult)) { - if (goOffline) { - worker.goOffline(); + try { + final ThreeState checkResult = checkLoginWorker(worker, executor, project, myForceCheck); + if (! ThreeState.YES.equals(checkResult)) { + if (ThreeState.UNSURE.equals(checkResult)) { + if (goOffline) { + worker.goOffline(); + } + myExceptionConsumer.consume(new CvsException("Authentication canceled", root.getCvsRootAsString())); } - myExceptionConsumer.consume(new CvsException("Authentication canceled", root.getCvsRootAsString())); + return false; } + } catch (AuthenticationException e) { + reportException(project, e); return false; } } return true; } + private static void reportException(Project project, AuthenticationException e) { + Throwable cause = e.getCause(); + if (cause instanceof SocketTimeoutException) { + VcsBalloonProblemNotifier.showOverChangesView(project, CvsBundle.message("error.message.timeout.error"), MessageType.ERROR); + } + else if (cause instanceof UnknownHostException) { + VcsBalloonProblemNotifier.showOverChangesView(project, CvsBundle.message("error.message.unknown.host", cause.getMessage()), + MessageType.ERROR); + } + else if (cause instanceof ConnectException || cause instanceof NoRouteToHostException) { + VcsBalloonProblemNotifier.showOverChangesView(project, CvsBundle.message("error.message.connection.error", cause.getMessage()), + MessageType.ERROR); + } else { + String localizedMessage = e.getLocalizedMessage(); + localizedMessage = (localizedMessage == null) ? e.getMessage() : localizedMessage; + localizedMessage = (localizedMessage == null) ? CvsBundle.message("error.dialog.title.cannot.connect.to.cvs") : localizedMessage; + VcsBalloonProblemNotifier.showOverChangesView(project, localizedMessage, MessageType.ERROR); + } + } + public static ThreeState checkLoginWorker(final CvsLoginWorker worker, final ModalityContext executor, final Project project, - final boolean forceCheckParam) { + final boolean forceCheckParam) throws AuthenticationException { boolean forceCheck = forceCheckParam; final Ref promptResult = new Ref(); final Runnable prompt = new Runnable() { From 2457d2607a19f9e1011a17400b557bd8a998fdf5 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 17 Aug 2011 14:23:38 +0400 Subject: [PATCH 14/74] PersistentHashMap uses 4 bytes for each mapping --- .../util/io/PersistentBTreeEnumerator.java | 130 ++++++------ .../util/io/PersistentEnumerator.java | 10 +- .../util/io/PersistentEnumeratorBase.java | 75 ++++--- .../util/io/PersistentEnumeratorDelegate.java | 3 +- .../intellij/util/io/PersistentHashMap.java | 189 +++++++++++++----- .../io/PersistentHashMapValueStorage.java | 99 ++++++--- 6 files changed, 334 insertions(+), 172 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java b/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java index 9df00c57dd06..edea7b164946 100644 --- a/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java +++ b/platform/util/src/com/intellij/util/io/PersistentBTreeEnumerator.java @@ -61,7 +61,7 @@ public class PersistentBTreeEnumerator extends PersistentEnumeratorBase extends PersistentEnumeratorBase leafPages = new ArrayList (); - btree.root.setAddress(btree.root.address); - collectLeafPages(btree.root, leafPages); - Collections.sort(leafPages, new Comparator() { - @Override - public int compare(IntToIntBtree.BtreeIndexNodeView o1, IntToIntBtree.BtreeIndexNodeView o2) { - return o1.address - o2.address; - } - }); - out: - for(IntToIntBtree.BtreeIndexNodeView page:leafPages) { - for(int key:page.exportKeys()) { - Integer record = btree.get(key); - p.setCurrentKey(key); - assert record != null; - if (record > 0) { - if (!p.process(record)) break out; - } else { - int rec = - record; - while(rec != 0) { - int id = myStorage.getInt(rec); - if (!p.process(id)) break out; - rec = myStorage.getInt(rec + COLLISION_OFFSET); - } + List leafPages = new ArrayList (); + btree.root.setAddress(btree.root.address); + collectLeafPages(btree.root, leafPages); + Collections.sort(leafPages, new Comparator() { + @Override + public int compare(IntToIntBtree.BtreeIndexNodeView o1, IntToIntBtree.BtreeIndexNodeView o2) { + return o1.address - o2.address; + } + }); + + out: + for(IntToIntBtree.BtreeIndexNodeView page:leafPages) { + for(int key:page.exportKeys()) { + Integer record = btree.get(key); + p.setCurrentKey(key); + assert record != null; + if (record > 0) { + if (!p.process(record)) break out; + } else { + int rec = - record; + while(rec != 0) { + int id = myStorage.getInt(rec); + if (!p.process(id)) break out; + rec = myStorage.getInt(rec + COLLISION_OFFSET); } } } - return true; - } - - int current = myFirstPageStart; - int currentPage = current; - int end = myDataPageStart + myDataPageOffset; - byte[] recordBuffer = getRecordHandler().getRecordBuffer(this); - int last = PAGE_SIZE - 4; - - while(current != end) { - if (current - currentPage >= last) { - currentPage = current = myStorage.getInt(currentPage + last); - } - if (!p.process(current)) break; - current += recordBuffer.length; } return true; } @@ -256,18 +240,27 @@ public class PersistentBTreeEnumerator extends PersistentEnumeratorBase)myDataDescriptor).fromInt(processingKey); + } + return super.getValue(keyId, processingKey); + } + + protected int enumerateImpl(final Data value, final boolean onlyCheckForExisting, boolean saveNewValue) throws IOException { try { if (IntToIntBtree.doDump) System.out.println(value); final int valueHC = myDataDescriptor.getHashCode(value); final Integer keyValue = btree.get(valueHC); - if (keyValue == null && !saveNewValue) { + if (keyValue == null && onlyCheckForExisting) { return NULL_ID; } int indexNodeValueAddress = keyValue != null ? keyValue:0; int collisionAddress = NULL_ID; + Data existingData = null; if (!myInlineKeysNoMapping) { indexNodeValueAddress = keyValue != null ? keyValue:0; @@ -279,7 +272,8 @@ public class PersistentBTreeEnumerator extends PersistentEnumeratorBase extends PersistentEnumeratorBase extends PersistentEnumeratorBase extends PersistentEnumeratorBase 0) { - // organize collision type reference - int duplicatedValueOff = nextDuplicatedValueRecord(); - btree.put(valueHC, -duplicatedValueOff); + if (existingData != null) { + if (indexNodeValueAddress > 0) { + btree.put(valueHC, newValueId); + } else { + myStorage.putInt(collisionAddress, newValueId); + } + } else { + if (indexNodeValueAddress > 0) { + // organize collision type reference + int duplicatedValueOff = nextDuplicatedValueRecord(); + btree.put(valueHC, -duplicatedValueOff); + + myStorage.putInt(duplicatedValueOff, indexNodeValueAddress); // we will set collision offset in next if + collisionAddress = duplicatedValueOff; + ++collisions; + } - myStorage.putInt(duplicatedValueOff, indexNodeValueAddress); // we will set collision offset in next if - collisionAddress = duplicatedValueOff; ++collisions; + int duplicatedValueOff = nextDuplicatedValueRecord(); + myStorage.putInt(collisionAddress + COLLISION_OFFSET, duplicatedValueOff); + myStorage.putInt(duplicatedValueOff, newValueId); + myStorage.putInt(duplicatedValueOff + COLLISION_OFFSET, 0); } - - ++collisions; - int duplicatedValueOff = nextDuplicatedValueRecord(); - myStorage.putInt(collisionAddress + COLLISION_OFFSET, duplicatedValueOff); - myStorage.putInt(duplicatedValueOff, newValueId); - myStorage.putInt(duplicatedValueOff + COLLISION_OFFSET, 0); } else { btree.put(valueHC, newValueId); } @@ -357,6 +364,11 @@ public class PersistentBTreeEnumerator extends PersistentEnumeratorBase extends PersistentEnumeratorBase { protected static final int NULL_ID = 0; private static final int DIRTY_MAGIC = 0xbabe0589; - private static final int VERSION = 5; + private static final int VERSION = 6; private static final int CORRECTLY_CLOSED_MAGIC = 0xebabafac + VERSION; private static final int FIRST_VECTOR_OFFSET = DATA_START; @@ -81,7 +81,7 @@ public class PersistentEnumerator extends PersistentEnumeratorBase { } } - protected int enumerateImpl(final Data value, final boolean saveNewValue) throws IOException { + protected int enumerateImpl(final Data value, final boolean onlyCheckForExisting, boolean saveNewValue) throws IOException { try { int depth = 0; final int valueHC = myDataDescriptor.getHashCode(value); @@ -106,7 +106,7 @@ public class PersistentEnumerator extends PersistentEnumeratorBase { if (vector == 0) { // Empty slot - if (!saveNewValue) { + if (onlyCheckForExisting) { return NULL_ID; } final int newId = writeData(value, valueHC); @@ -133,7 +133,7 @@ public class PersistentEnumerator extends PersistentEnumeratorBase { } while (collision != 0); - if (!saveNewValue) { + if (onlyCheckForExisting) { return NULL_ID; } @@ -236,4 +236,4 @@ public class PersistentEnumerator extends PersistentEnumeratorBase { Bits.putInt(buf, KEY_REF_OFFSET, dataOffset); } } -} \ No newline at end of file +} diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java index 06cfec948e0d..47a2c88a97e0 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.CommonProcessors; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.containers.SLRUMap; import com.intellij.util.containers.ShareableKey; @@ -41,7 +42,7 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { protected static final int NULL_ID = 0; private static final int META_DATA_OFFSET = 4; - protected static final int DATA_START = META_DATA_OFFSET + 4; + protected static final int DATA_START = META_DATA_OFFSET + 16; protected final ISimpleStorage myStorage; private final ResizeableMappedFile myKeyStorage; @@ -156,6 +157,7 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { try { markDirty(true); putMetaData(0); + putMetaData2(0); setupEmptyFile(); } catch (RuntimeException e) { @@ -217,16 +219,26 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { myMarkCleanCallback = markCleanCallback; } + public Data getValue(int keyId, int processingKey) throws IOException { + return valueOf(keyId); + } + protected int tryEnumerate(Data value) throws IOException { - synchronized (ourEnumerationCache) { - final Integer cachedId = ourEnumerationCache.get(sharedKey(value, this)); - if (cachedId != null) return cachedId.intValue(); + return doEnumerate(value, true, false); + } + + private int doEnumerate(Data value, boolean onlyCheckForExisting, boolean saveNewValue) throws IOException { + if (!saveNewValue) { + synchronized (ourEnumerationCache) { + final Integer cachedId = ourEnumerationCache.get(sharedKey(value, this)); + if (cachedId != null) return cachedId.intValue(); + } } final int id; synchronized (this) { synchronized (ourLock) { - id = enumerateImpl(value, false); + id = enumerateImpl(value, onlyCheckForExisting, saveNewValue); } } @@ -240,40 +252,34 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { } public int enumerate(Data value) throws IOException { - synchronized (ourEnumerationCache) { - final Integer cachedId = ourEnumerationCache.get(sharedKey(value, this)); - if (cachedId != null) { - return cachedId.intValue(); - } - } - - final int id; - synchronized (this) { - synchronized (ourLock) { - id = enumerateImpl(value, true); - } - } - - synchronized (ourEnumerationCache) { - ourEnumerationCache.put(new CacheKey(value, this), id); - } - - return id; + return doEnumerate(value, false, false); } public interface DataFilter { boolean accept(int id); } - protected void putMetaData(int data) throws IOException { + protected void putMetaData(long data) throws IOException { synchronized (ourLock) { - myStorage.putInt(META_DATA_OFFSET, data); + myStorage.putLong(META_DATA_OFFSET, data); } } - protected int getMetaData() throws IOException { + protected long getMetaData() throws IOException { synchronized (ourLock) { - return myStorage.getInt(META_DATA_OFFSET); + return myStorage.getLong(META_DATA_OFFSET); + } + } + + protected void putMetaData2(long data) throws IOException { + synchronized (ourLock) { + myStorage.putLong(META_DATA_OFFSET + 8, data); + } + } + + protected long getMetaData2() throws IOException { + synchronized (ourLock) { + return myStorage.getLong(META_DATA_OFFSET + 8); } } @@ -309,7 +315,7 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { public abstract boolean traverseAllRecords(RecordsProcessor p) throws IOException; - protected abstract int enumerateImpl(final Data value, final boolean saveNewValue) throws IOException; + protected abstract int enumerateImpl(final Data value, final boolean onlyCheckForExisting, boolean saveNewValue) throws IOException; protected int writeData(final Data value, int hashCode) { try { @@ -391,6 +397,15 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { } } + int reenumerate(Data key) throws IOException { + if (!canReEnumerate()) throw new IncorrectOperationException(); + return doEnumerate(key, false, true); + } + + boolean canReEnumerate() { + return false; + } + protected abstract int indexToAddr(int idx); private static class MyDataIS extends DataInputStream { @@ -523,4 +538,4 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { return new CacheKey(key, owner); } } -} \ No newline at end of file +} diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java index 4472091ab38d..c7c689eedae5 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorDelegate.java @@ -34,8 +34,7 @@ public class PersistentEnumeratorDelegate implements Closeable, Forceable private boolean useBtree() { String property = System.getProperty("idea.use.btree"); - //if (property == null) property = Boolean.toString(SystemInfo.is32Bit); - return "true".equals(property); + return !"false".equals(property); } @Override diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMap.java b/platform/util/src/com/intellij/util/io/PersistentHashMap.java index 75b109db745a..5a3b28ee823f 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMap.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMap.java @@ -17,6 +17,7 @@ package com.intellij.util.io; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.LowMemoryWatcher; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.ByteSequence; import com.intellij.openapi.util.io.FileUtil; @@ -24,6 +25,9 @@ import com.intellij.util.CommonProcessors; import com.intellij.util.Processor; import com.intellij.util.containers.LimitedPool; import com.intellij.util.containers.SLRUCache; +import gnu.trove.TIntHash; +import gnu.trove.TIntIntHashMap; +import gnu.trove.TIntStack; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -38,6 +42,7 @@ import java.util.List; */ public class PersistentHashMap extends PersistentEnumeratorDelegate{ private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.PersistentHashMap"); + private PersistentHashMapValueStorage myValueStorage; private final DataExternalizer myValueExternalizer; private static final long NULL_ADDR = 0; @@ -49,9 +54,17 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< @NonNls public static final String DATA_FILE_EXTENSION = ".values"; - private int myGarbageSize; + private long myLiveAndGarbageKeysCounter; // first four bytes contain live keys count (updated via LIVE_KEY_MASK), last four bytes - number of dead keys + private static final long LIVE_KEY_MASK = (1L << 32); + private static final long USED_LONG_VALUE_MASK = 1L << 62; + private static final int POSITIVE_VALUE_SHIFT = 1; private final int myParentValueRefOffset; private final byte[] myRecordBuffer; + private final byte[] mySmallRecordBuffer; + private final boolean myCanReEnumerate; + private int myWatermarkId; + private boolean myIntAddressForNewRecord; + private static final boolean doHardConsistencyChecks = false; private static class AppendStream extends DataOutputStream { private AppendStream() { @@ -88,7 +101,7 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< public void cleanup(final AppendStream appendStream) { appendStream.reset(); } - }); + }); private final SLRUCache myAppendCache = new SLRUCache(16 * 1024, 4 * 1024) { @NotNull @@ -98,15 +111,16 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< protected void onDropFromCache(final Key key, final AppendStream value) { try { - final int id = enumerate(key); - HeaderRecord headerRecord = readValueId(id); - final ByteSequence bytes = value.getInternalBuffer(); + final int id = enumerate(key); + HeaderRecord oldHeaderRecord = readValueId(id); - headerRecord.size += bytes.getLength(); - headerRecord.address = myValueStorage.appendBytes(bytes, headerRecord.address); + HeaderRecord headerRecord = new HeaderRecord( + myValueStorage.appendBytes(bytes, oldHeaderRecord.address) + ); - updateValueId(id, headerRecord); + updateValueId(id, headerRecord, oldHeaderRecord, key, 0); + if (oldHeaderRecord == HeaderRecord.EMPTY) myLiveAndGarbageKeysCounter += LIVE_KEY_MASK; myStreamPool.recycle(value); } @@ -116,6 +130,10 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< } }; + private boolean canUseIntAddressForNewRecord(long size) { + return myCanReEnumerate ? size + POSITIVE_VALUE_SHIFT < Integer.MAX_VALUE: false; + } + private final LowMemoryWatcher myAppendCacheFlusher = LowMemoryWatcher.register(new LowMemoryWatcher.ForceableAdapter() { public void force() { //System.out.println("Flushing caches: " + myFile.getPath()); @@ -136,8 +154,9 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< final PersistentEnumeratorBase.RecordBufferHandler recordHandler = myEnumerator.getRecordHandler(); myParentValueRefOffset = recordHandler.getRecordBuffer(myEnumerator).length; - myRecordBuffer = new byte[myParentValueRefOffset + 8 + 4]; - + myRecordBuffer = new byte[myParentValueRefOffset + 8]; + mySmallRecordBuffer = new byte[myParentValueRefOffset + 4]; + myEnumerator.setRecordHandler(new PersistentEnumeratorBase.RecordBufferHandler() { @Override int recordWriteOffset(PersistentEnumeratorBase enumerator, byte[] buf) { @@ -146,13 +165,13 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< @Override byte[] getRecordBuffer(PersistentEnumeratorBase enumerator) { - return myRecordBuffer; + return myIntAddressForNewRecord ? mySmallRecordBuffer : myRecordBuffer; } @Override void setupRecord(PersistentEnumeratorBase enumerator, int hashCode, int dataOffset, byte[] buf) { recordHandler.setupRecord(enumerator, hashCode, dataOffset, buf); - for (int i = myParentValueRefOffset; i < myRecordBuffer.length; i++) { + for (int i = myParentValueRefOffset; i < buf.length; i++) { buf[i] = 0; } } @@ -162,7 +181,8 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< new Flushable() { @Override public void flush() throws IOException { - myEnumerator.putMetaData(myGarbageSize); + myEnumerator.putMetaData(myLiveAndGarbageKeysCounter); + myEnumerator.putMetaData2(myWatermarkId); } } ); @@ -170,7 +190,9 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< try { myValueExternalizer = valueExternalizer; myValueStorage = PersistentHashMapValueStorage.create(getDataFile(file).getPath()); - myGarbageSize = myEnumerator.getMetaData(); + myLiveAndGarbageKeysCounter = myEnumerator.getMetaData(); + myWatermarkId = (int)myEnumerator.getMetaData2(); + myCanReEnumerate = myEnumerator.canReEnumerate(); if (makesSenseToCompact()) { compact(); @@ -186,7 +208,7 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< } public int getGarbageSize() { - return myGarbageSize; + return (int)myLiveAndGarbageKeysCounter; } public File getBaseFile() { @@ -195,7 +217,12 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< private boolean makesSenseToCompact() { final long fileSize = getDataFile(myEnumerator.myFile).length(); - return fileSize > 5 * 1024 * 1024 && myGarbageSize * 2 > fileSize; // file is longer than 5MB and more than 50% of data is garbage + if (fileSize > 5 * 1024 * 1024) { // file is longer than 5MB and more than 50% of keys is garbage + int liveKeys = (int)(myLiveAndGarbageKeysCounter / LIVE_KEY_MASK); + int oldKeys = (int)(myLiveAndGarbageKeysCounter & 0xFFFFFFFF); + return oldKeys > liveKeys; + } + return false; } private static File checkDataFiles(final File file) { @@ -228,21 +255,27 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< myEnumerator.markDirty(true); myAppendCache.remove(key); - final int id = enumerate(key); final AppendStream record = new AppendStream(); myValueExternalizer.save(record, value); final ByteSequence bytes = record.getInternalBuffer(); + final int id = enumerate(key); - HeaderRecord header = readValueId(id); - myGarbageSize += header.size; + HeaderRecord oldheader = readValueId(id); + if (oldheader != HeaderRecord.EMPTY) myLiveAndGarbageKeysCounter++; + myLiveAndGarbageKeysCounter += LIVE_KEY_MASK; - header.size = bytes.getLength(); - header.address = myValueStorage.appendBytes(bytes, 0); + HeaderRecord header = new HeaderRecord(myValueStorage.appendBytes(bytes, 0)); - updateValueId(id, header); + updateValueId(id, header, oldheader, key, 0); } } + @Override + public synchronized int enumerate(Key name) throws IOException { + myIntAddressForNewRecord = canUseIntAddressForNewRecord(myValueStorage.getSize()); + return super.enumerate(name); + } + public interface ValueDataAppender { void append(DataOutput out) throws IOException; } @@ -290,21 +323,20 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< if (id == PersistentEnumerator.NULL_ID) { return null; } - final HeaderRecord header = readValueId(id); - if (header.address == PersistentEnumerator.NULL_ID) { + final HeaderRecord oldHeader = readValueId(id); + if (oldHeader.address == PersistentEnumerator.NULL_ID) { return null; } - - byte[] data = new byte[header.size]; - long newAddress = myValueStorage.readBytes(header.address, data); - if (newAddress != header.address) { + + Pair readResult = myValueStorage.readBytes(oldHeader.address); + if (readResult.first != null && readResult.first != oldHeader.address) { myEnumerator.markDirty(true); - header.address = newAddress; - updateValueId(id, header); - myGarbageSize += header.size; + + updateValueId(id, new HeaderRecord(readResult.first), oldHeader, key, 0); + if (oldHeader != HeaderRecord.EMPTY) myLiveAndGarbageKeysCounter++; } - final DataInputStream input = new DataInputStream(new ByteArrayInputStream(data)); + final DataInputStream input = new DataInputStream(new ByteArrayInputStream(readResult.second)); try { return myValueExternalizer.read(input); } @@ -321,9 +353,8 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< if (id == PersistentEnumerator.NULL_ID) { return false; } - return readValueId(id).address != PersistentEnumerator.NULL_ID; + return readValueId(id).address != NULL_ADDR; } - } public synchronized void remove(Key key) throws IOException { @@ -336,9 +367,9 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< myEnumerator.markDirty(true); final HeaderRecord record = readValueId(id); - myGarbageSize += record.size; + if (record != HeaderRecord.EMPTY) myLiveAndGarbageKeysCounter++; - updateValueId(id, new HeaderRecord()); + updateValueId(id, HeaderRecord.EMPTY, record, key, 0); } } @@ -382,15 +413,16 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< final String newPath = getDataFile(myEnumerator.myFile).getPath() + ".new"; final PersistentHashMapValueStorage newStorage = PersistentHashMapValueStorage.create(newPath); myValueStorage.switchToCompactionMode(); + myLiveAndGarbageKeysCounter = 0; traverseAllRecords(new PersistentEnumerator.RecordsProcessor() { public boolean process(final int keyId) throws IOException { final HeaderRecord record = readValueId(keyId); - if (record.address != NULL_ADDR) { - final byte[] bytes = new byte[record.size]; - myValueStorage.readBytes(record.address, bytes); - record.address = newStorage.appendBytes(new ByteSequence(bytes), 0); - updateValueId(keyId, record); + if (record.address != NULL_ADDR) { + Pair readResult = myValueStorage.readBytes(record.address); + HeaderRecord value = new HeaderRecord(newStorage.appendBytes(new ByteSequence(readResult.second), 0)); + updateValueId(keyId, value, record, null, getCurrentKey()); + myLiveAndGarbageKeysCounter += LIVE_KEY_MASK; } return true; } @@ -403,25 +435,78 @@ public class PersistentHashMap extends PersistentEnumeratorDelegate< myValueStorage = PersistentHashMapValueStorage.create(getDataFile(myEnumerator.myFile).getPath()); LOG.info("Compacted " + myEnumerator.myFile.getPath() + " in " + (System.currentTimeMillis() - now) + "ms."); - myGarbageSize = 0; - myEnumerator.putMetaData(0); + + myEnumerator.putMetaData(myLiveAndGarbageKeysCounter); } } private HeaderRecord readValueId(final int keyId) { - HeaderRecord result = new HeaderRecord(); - result.address = myEnumerator.myStorage.getLong(keyId + myParentValueRefOffset); - result.size = myEnumerator.myStorage.getInt(keyId + myParentValueRefOffset + 8); - return result; + long address = myEnumerator.myStorage.getInt(keyId + myParentValueRefOffset); + if (address == 0 || address == -POSITIVE_VALUE_SHIFT) { + return HeaderRecord.EMPTY; + } + + if (address < 0) { + address = -address - POSITIVE_VALUE_SHIFT; + } else { + int value = myEnumerator.myStorage.getInt(keyId + myParentValueRefOffset + 4); + address = ((address << 32) + value) & ~USED_LONG_VALUE_MASK; + } + + return new HeaderRecord(address); } - private void updateValueId(final int keyId, HeaderRecord value) { - myEnumerator.myStorage.putLong(keyId + myParentValueRefOffset, value.address); - myEnumerator.myStorage.putInt(keyId + myParentValueRefOffset + 8, value.size); + private int smallKeys; + private int largeKeys; + private int transformedKeys; + private int requests; + + private int updateValueId(int keyId, HeaderRecord value, HeaderRecord oldValue, Key key, int processingKey) throws IOException { + final boolean newKey = oldValue == null || oldValue.address == NULL_ADDR; + if (newKey) ++requests; + boolean defaultSizeInfo = true; + + if (myCanReEnumerate) { + if (canUseIntAddressForNewRecord(value.address)) { + defaultSizeInfo = false; + myEnumerator.myStorage.putInt(keyId + myParentValueRefOffset, -(int)(value.address + POSITIVE_VALUE_SHIFT)); + if (newKey) ++smallKeys; + } else { + if (newKey && myWatermarkId == 0) myWatermarkId = keyId; + if (keyId < myWatermarkId && (oldValue == null || canUseIntAddressForNewRecord(oldValue.address))) { + // keyId is result of enumerate, if we do reenumerate then it is no longer accessible unless somebody cached it + myIntAddressForNewRecord = false; + keyId = myEnumerator.reenumerate(key == null ? myEnumerator.getValue(keyId, processingKey) : key); + ++transformedKeys; + } + } + } + + if (defaultSizeInfo) { + myEnumerator.myStorage.putLong(keyId + myParentValueRefOffset, value.address | USED_LONG_VALUE_MASK); + if (newKey) ++largeKeys; + } + + if (newKey && requests % IOStatistics.KEYS_FACTOR == 0 && IOStatistics.DEBUG) { + IOStatistics.dump("small:"+smallKeys + ", large:" + largeKeys + ", transformed:"+transformedKeys + + ",@"+getBaseFile().getPath()); + } + if (doHardConsistencyChecks) { + HeaderRecord checkRecord = readValueId(keyId); + if (checkRecord.address != value.address) { + assert false:value.address; int a = 1; + } + } + return keyId; } private static class HeaderRecord { - long address; - int size; + final long address; + + HeaderRecord(long address) { + this.address = address; + } + + static final HeaderRecord EMPTY = new HeaderRecord(NULL_ADDR); } } diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java index 919adbb1a5c4..8c86b0f2f64b 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java @@ -19,6 +19,7 @@ */ package com.intellij.util.io; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.ByteSequence; import com.intellij.util.containers.SLRUCache; import org.jetbrains.annotations.NotNull; @@ -67,37 +68,66 @@ public class PersistentHashMapValueStorage { } } + private long smallWrites; + private int smallWritesCount; + private long largeWrites; + private int largeWritesCount; + private int requests; + + private static final int POSITIVE_VALUE_SHIFT = 1; + private static final int BYTE_LENGTH_INT_ADDRESS = 1 + 4; + private static final int INT_LENGTH_LONG_ADDRESS = 4 + 8; + public long appendBytes(ByteSequence data, long prevChunkAddress) throws IOException { assert !myCompactionMode; long result = mySize; final CacheValue appender = ourAppendersCache.get(myPath); + int dataLength = data.getLength(); + int serviceFieldsSizeIncrease; + try { - appender.get().writeLong(prevChunkAddress); - appender.get().writeInt(data.getLength()); - appender.get().write(data.getBytes(), data.getOffset(), data.getLength()); + DataOutputStream dataOutputStream = appender.get(); + ++requests; + + if (dataLength + POSITIVE_VALUE_SHIFT < 0x80 && prevChunkAddress < Integer.MAX_VALUE) { + ++smallWritesCount; + smallWrites += dataLength; + dataOutputStream.write(-dataLength - POSITIVE_VALUE_SHIFT); + dataOutputStream.writeInt((int)prevChunkAddress); + serviceFieldsSizeIncrease = BYTE_LENGTH_INT_ADDRESS; + } else { + ++largeWritesCount; + largeWrites += dataLength; + dataOutputStream.writeInt(dataLength); + dataOutputStream.writeLong(prevChunkAddress); + serviceFieldsSizeIncrease = INT_LENGTH_LONG_ADDRESS; + } + dataOutputStream.write(data.getBytes(), data.getOffset(), dataLength); + if (requests % IOStatistics.KEYS_FACTOR == 0 && IOStatistics.DEBUG) { + IOStatistics.dump("Small writes:"+smallWritesCount +", bytes:"+smallWrites + ", largeWrites:"+largeWritesCount + + ", bytes:"+largeWrites+", total:"+requests + "@"+myFile.getPath()); + } } finally { appender.release(); } - mySize += data.getLength() + 8 + 4; + mySize += dataLength + serviceFieldsSizeIncrease; return result; } + private final byte[] myBuffer = new byte[1024]; + /** * Reads bytes pointed by tailChunkAddress into result passed, returns new address if linked list compactification have been performed */ - public long readBytes(long tailChunkAddress, byte[] result) throws IOException { - int size = result.length; - if (size == 0) return tailChunkAddress; - + public Pair readBytes(long tailChunkAddress) throws IOException { force(); - int bytesRead = 0; long chunk = tailChunkAddress; int chunkCount = 0; - byte[] headerBits = new byte[8 + 4]; + byte[] result = null; RAReader reader = myCompactionModeReader; CacheValue readerHandle = null; if (reader == null) { @@ -107,16 +137,37 @@ public class PersistentHashMapValueStorage { try { while (chunk != 0) { - reader.get(chunk, headerBits, 0, 12); - final long prevChunkAddress = Bits.getLong(headerBits, 0); - final int chunkSize = Bits.getInt(headerBits, 8); - final int off = size - bytesRead - chunkSize; + int len = (int)Math.min(myBuffer.length, mySize - chunk); + reader.get(chunk, myBuffer, 0, len); - checkPreconditions(result, chunkSize, off); + final int sizePart = myBuffer[0]; + final long prevChunkAddress; + final int chunkSize; + + if (sizePart < 0) { + chunkSize = -sizePart - POSITIVE_VALUE_SHIFT; + prevChunkAddress = Bits.getInt(myBuffer, 1); + byte[] b = new byte[(result != null ? result.length:0) + chunkSize]; + if (result != null) System.arraycopy(result, 0, b, b.length - result.length, result.length); + result = b; + + checkPreconditions(result, chunkSize, 0); + System.arraycopy(myBuffer, BYTE_LENGTH_INT_ADDRESS, result, 0, chunkSize); + } else { + chunkSize = Bits.getInt(myBuffer, 0); + prevChunkAddress = Bits.getLong(myBuffer, 4); + byte[] b = new byte[(result != null ? result.length:0) + chunkSize]; + if (result != null) System.arraycopy(result, 0, b, b.length - result.length, result.length); + result = b; + + if (chunkSize < myBuffer.length - INT_LENGTH_LONG_ADDRESS) { + System.arraycopy(myBuffer, INT_LENGTH_LONG_ADDRESS, result, 0, chunkSize); + } else { + reader.get(chunk + INT_LENGTH_LONG_ADDRESS, result, 0, chunkSize); + } + } - reader.get(chunk + 12, result, off, chunkSize); chunk = prevChunkAddress; - bytesRead += chunkSize; chunkCount++; } } @@ -126,16 +177,16 @@ public class PersistentHashMapValueStorage { } } - //assert bytesRead == size; - if (bytesRead != size) { - throw new IOException("Read from storage " + bytesRead + " bytes, but requested " + size + " bytes"); - } - if (chunkCount > 1 && !myCompactionMode) { - return appendBytes(new ByteSequence(result), 0); + long l = appendBytes(new ByteSequence(result), 0); + return new Pair(l, result); } - return tailChunkAddress; + return new Pair(tailChunkAddress, result); + } + + public long getSize() { + return mySize; } private static void checkPreconditions(final byte[] result, final int chunkSize, final int off) throws IOException { From 8fdc96e1ed2ba2a656aa9092fd99d13a8da29b20 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 17 Aug 2011 14:26:24 +0400 Subject: [PATCH 15/74] correctly (additional keymap Ctrl(meta)+E for recent commit messages) --- platform/platform-resources/src/idea/Keymap_Default.xml | 1 + platform/platform-resources/src/idea/Keymap_Emacs.xml | 1 + platform/platform-resources/src/idea/Keymap_Mac.xml | 1 + platform/platform-resources/src/idea/Keymap_MacClassic.xml | 1 + platform/platform-resources/src/idea/Keymap_Netbeans.xml | 4 ++++ 5 files changed, 8 insertions(+) diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index 868c9d9f1b87..41215f4027df 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -859,6 +859,7 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_Emacs.xml b/platform/platform-resources/src/idea/Keymap_Emacs.xml index 663a0e1106a9..f72e98739155 100644 --- a/platform/platform-resources/src/idea/Keymap_Emacs.xml +++ b/platform/platform-resources/src/idea/Keymap_Emacs.xml @@ -275,5 +275,6 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_Mac.xml b/platform/platform-resources/src/idea/Keymap_Mac.xml index e1a16bf5dc69..cc862b1e2b6e 100644 --- a/platform/platform-resources/src/idea/Keymap_Mac.xml +++ b/platform/platform-resources/src/idea/Keymap_Mac.xml @@ -431,6 +431,7 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_MacClassic.xml b/platform/platform-resources/src/idea/Keymap_MacClassic.xml index fa5a35d5f9bb..a1a4775e0c44 100644 --- a/platform/platform-resources/src/idea/Keymap_MacClassic.xml +++ b/platform/platform-resources/src/idea/Keymap_MacClassic.xml @@ -324,6 +324,7 @@ + diff --git a/platform/platform-resources/src/idea/Keymap_Netbeans.xml b/platform/platform-resources/src/idea/Keymap_Netbeans.xml index 1cb7af900bea..a7202a2e2ced 100644 --- a/platform/platform-resources/src/idea/Keymap_Netbeans.xml +++ b/platform/platform-resources/src/idea/Keymap_Netbeans.xml @@ -345,5 +345,9 @@ + + + + From 413e2d68e336f939940345922db5c39e171beeb8 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 17 Aug 2011 14:37:47 +0400 Subject: [PATCH 16/74] Revert "cleanup" This reverts commit df94793c112c1b505c6a7441e903562d62ea1309. --- .../cvsBrowser/AbstractVcsDataProvider.java | 13 ++--- .../cvsSupport2/cvsBrowser/CvsTreeModel.java | 48 +++++++++++++++++++ .../cvsBrowser/ModuleDataProvider.java | 4 +- .../cvsBrowser/RootDataProvider.java | 3 +- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java index 10f86b03bbff..99baf3b9b5bf 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java @@ -23,6 +23,7 @@ import com.intellij.cvsSupport2.cvsExecution.ModalityContext; import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler; import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent; +import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetDirectoriesListViaUpdateOperation; import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsListenerWithProgress; import com.intellij.openapi.application.ApplicationManager; @@ -51,12 +52,12 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi } } - public CvsOperation createDirectoryContentProvider(String path) { + public DirectoryContentProvider createDirectoryContentProvider(String path) { return new GetDirectoriesListViaUpdateOperation(myEnvironment, path); } - private static class CancellableCvsHandler extends CommandCvsHandler { - private CancellableCvsHandler(final String title, final CvsOperation cvsOperation) { + private static class MyCancellableCvsHandler extends CommandCvsHandler { + private MyCancellableCvsHandler(final String title, final CvsOperation cvsOperation) { super(title, cvsOperation, true); } @@ -71,12 +72,12 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi } } - private static void executeCommand(final CvsOperation command, final GetContentCallback callback) { + private static void executeCommand(final DirectoryContentProvider command, final GetContentCallback callback) { final CvsOperationExecutor executor = new CvsOperationExecutor(false, callback.getProject(), callback.getModalityState()); executor.setIsQuietOperation(true); - final CancellableCvsHandler cvsHandler = - new CancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), command); + final MyCancellableCvsHandler cvsHandler = + new MyCancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), (CvsOperation) command); callback.useForCancel(cvsHandler.getProgressListener()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java new file mode 100644 index 000000000000..7ee71be7b78b --- /dev/null +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2009 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.cvsSupport2.cvsBrowser; + +import javax.swing.*; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; + +/** + * author: lesya + */ +public class CvsTreeModel extends DefaultTreeModel{ + private JTree myTree; + private CvsTree myCvsTree; + + public CvsTreeModel(TreeNode root) { + super(root, true); + } + + public CvsTree getCvsTree() { + return myCvsTree; + } + + public void setCvsTree(CvsTree cvsTree) { + myCvsTree = cvsTree; + } + + public void setTree(JTree tree) { + myTree = tree; + } + + public void selectRoot(){ + myTree.addSelectionPath(myTree.getPathForRow(0)); + } +} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java index e7c5dfbf3c5b..533b0841bcf2 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/ModuleDataProvider.java @@ -16,7 +16,7 @@ package com.intellij.cvsSupport2.cvsBrowser; import com.intellij.cvsSupport2.connections.CvsEnvironment; -import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; +import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModuleContentOperation; /** @@ -27,7 +27,7 @@ public class ModuleDataProvider extends AbstractVcsDataProvider{ super(environment); } - public CvsOperation createDirectoryContentProvider(String path) { + public DirectoryContentProvider createDirectoryContentProvider(String path) { return new GetModuleContentOperation(myEnvironment, path); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java index 5bdf07a50077..0822ecac3577 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/RootDataProvider.java @@ -17,7 +17,6 @@ package com.intellij.cvsSupport2.cvsBrowser; import com.intellij.cvsSupport2.connections.CvsEnvironment; import com.intellij.cvsSupport2.cvsoperations.common.CompositeOperation; -import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation; import com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetDirectoriesListViaUpdateOperation; @@ -56,7 +55,7 @@ public class RootDataProvider extends AbstractVcsDataProvider{ return new FolderDataProvider(myEnvironment); } - public CvsOperation createDirectoryContentProvider(String path) { + public DirectoryContentProvider createDirectoryContentProvider(String path) { return new RootDirectoryContentProvider(myEnvironment); } } From 64e0309d3de24644dce6ee24fe7a8276bb1f3487 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 17 Aug 2011 14:46:48 +0400 Subject: [PATCH 17/74] add another convenient Attachment constructor --- .../diagnostic/errordialog/Attachment.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/Attachment.java b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/Attachment.java index 50b8d6b16dcc..0aab862efb56 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/Attachment.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/Attachment.java @@ -1,5 +1,12 @@ package com.intellij.diagnostic.errordialog; +import com.intellij.openapi.fileEditor.impl.LoadTextUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.Base64Converter; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + public class Attachment { private final String myPath; private String myContent; @@ -10,6 +17,24 @@ public class Attachment { myContent = content; } + public Attachment(@NotNull VirtualFile file) { + this(file.getPresentableUrl(), loadText(file)); + } + + private static String loadText(VirtualFile file) { + if (file.getFileType().isBinary()) { + try { + return "Binary file, base64 encoded: " + Base64Converter.encode(file.contentsToByteArray()); + } + catch (IOException e) { + return "Cannot load binary file content"; + } + } + else { + return LoadTextUtil.loadText(file).toString(); + } + } + public String getPath() { return myPath; } From e762123ddb5f812f344a67f744c5aae7b6528540 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 14:17:52 +0400 Subject: [PATCH 18/74] decouple DocumentImpl from EditorHighlighter --- .../impl/search/JspIndexPatternBuilder.java | 6 +- .../util/indexing/FileBasedIndex.java | 4 +- .../openapi/editor/impl/DocumentImpl.java | 28 ++------- .../editor/impl/EditorHighlighterCache.java | 57 +++++++++++++++++++ .../openapi/editor/impl/EditorImpl.java | 4 +- 5 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java diff --git a/java/java-impl/src/com/intellij/psi/impl/search/JspIndexPatternBuilder.java b/java/java-impl/src/com/intellij/psi/impl/search/JspIndexPatternBuilder.java index cb88168724b0..025a154c8fb2 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/JspIndexPatternBuilder.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/JspIndexPatternBuilder.java @@ -22,9 +22,10 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; import com.intellij.openapi.editor.impl.DocumentImpl; +import com.intellij.openapi.editor.impl.EditorHighlighterCache; +import com.intellij.psi.JspPsiUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; -import com.intellij.psi.JspPsiUtil; import com.intellij.psi.impl.cache.impl.id.IdTableBuilding; import com.intellij.psi.impl.source.tree.StdTokenSets; import com.intellij.psi.jsp.JspFile; @@ -44,8 +45,7 @@ public class JspIndexPatternBuilder implements IndexPatternBuilder { EditorHighlighter cachedEditorHighlighter; boolean alreadyInitializedHighlighter = false; - if (document instanceof DocumentImpl && - (cachedEditorHighlighter = ((DocumentImpl)document).getEditorHighlighterForCachesBuilding()) != null && + if ((cachedEditorHighlighter = EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document)) != null && IdTableBuilding.checkCanUseCachedEditorHighlighter(file.getText(), cachedEditorHighlighter) ) { highlighter = cachedEditorHighlighter; diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index 904b310d9d26..5dfcd5773bbc 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -30,7 +30,7 @@ import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.highlighter.EditorHighlighter; -import com.intellij.openapi.editor.impl.DocumentImpl; +import com.intellij.openapi.editor.impl.EditorHighlighterCache; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; @@ -1204,7 +1204,7 @@ public class FileBasedIndex implements ApplicationComponent { } if (content instanceof AuthenticContent) { - newFc.putUserData(EDITOR_HIGHLIGHTER, document instanceof DocumentImpl ? ((DocumentImpl)document) .getEditorHighlighterForCachesBuilding() : null); + newFc.putUserData(EDITOR_HIGHLIGHTER, EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document)); } if (getInputFilter(requestedIndexId).acceptInput(vFile)) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 541053eaed13..56a0b723f752 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -30,10 +30,11 @@ import com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHand import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.editor.ex.*; -import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; -import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.impl.event.DocumentEventImpl; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.ShutDownTracker; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.util.LocalTimeCounter; @@ -41,12 +42,10 @@ import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -76,7 +75,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { private boolean myEventsHandling = false; private final boolean myAssertWriteAccess; private volatile boolean myDoingBulkUpdate = false; - private static final Key> ourSomeEditorSyntaxHighlighter = Key.create("some editor highlighter"); private boolean myAcceptSlashR = false; private boolean myChangeInProgress; @@ -721,24 +719,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } } - @Nullable - public EditorHighlighter getEditorHighlighterForCachesBuilding() { - final WeakReference editorHighlighterWeakReference = getUserData(ourSomeEditorSyntaxHighlighter); - final EditorHighlighter someEditorHighlighter = editorHighlighterWeakReference != null ? editorHighlighterWeakReference.get():null; - - if (someEditorHighlighter instanceof LexerEditorHighlighter && - ((LexerEditorHighlighter)someEditorHighlighter).isValid() - ) { - return someEditorHighlighter; - } - putUserData(ourSomeEditorSyntaxHighlighter, null); - return null; - } - - public void rememberEditorHighlighterForCachesOptimization(@NotNull final EditorHighlighter highlighter) { - putUserData(ourSomeEditorSyntaxHighlighter, new WeakReference(highlighter)); - } - private static class DocumentBulkUpdateListenerHolder { private static final DocumentBulkUpdateListener ourBulkChangePublisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(DocumentBulkUpdateListener.TOPIC); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java new file mode 100644 index 000000000000..a90d575f9e3c --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHighlighterCache.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2011 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.openapi.editor.impl; + +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; +import com.intellij.openapi.editor.highlighter.EditorHighlighter; +import com.intellij.openapi.util.Key; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.ref.WeakReference; + +/** + * @author yole + */ +public class EditorHighlighterCache { + private static final Key> ourSomeEditorSyntaxHighlighter = Key.create("some editor highlighter"); + + private EditorHighlighterCache() { + } + + public static void rememberEditorHighlighterForCachesOptimization(Document document, @NotNull final EditorHighlighter highlighter) { + document.putUserData(ourSomeEditorSyntaxHighlighter, new WeakReference(highlighter)); + } + + @Nullable + public static EditorHighlighter getEditorHighlighterForCachesBuilding(Document document) { + if (document == null) { + return null; + } + final WeakReference editorHighlighterWeakReference = document.getUserData(ourSomeEditorSyntaxHighlighter); + final EditorHighlighter someEditorHighlighter = editorHighlighterWeakReference != null ? editorHighlighterWeakReference.get() : null; + + if (someEditorHighlighter instanceof LexerEditorHighlighter && + ((LexerEditorHighlighter)someEditorHighlighter).isValid() + ) { + return someEditorHighlighter; + } + document.putUserData(ourSomeEditorSyntaxHighlighter, null); + return null; + } + +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 469c12bd11f1..b5ac76ebd731 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -865,9 +865,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi highlighter.setEditor(this); highlighter.setText(document.getCharsSequence()); myHighlighter = highlighter; - if (document instanceof DocumentImpl) { - ((DocumentImpl)document).rememberEditorHighlighterForCachesOptimization(highlighter); - } + EditorHighlighterCache.rememberEditorHighlighterForCachesOptimization(document, highlighter); if (myPanel != null) { reinitSettings(); From e07a89e2c95e59745e4833af212acf3bd53bd875 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 14:26:01 +0400 Subject: [PATCH 19/74] remove code that was commented out at least since 2005 --- .../openapi/application/ex/ApplicationEx.java | 2 -- .../openapi/application/impl/ApplicationImpl.java | 14 -------------- .../intellij/openapi/editor/impl/DocumentImpl.java | 10 ---------- .../src/com/intellij/mock/MockApplication.java | 4 ---- 4 files changed, 30 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java index 43785c30f3bb..8c2dcfe3b1ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java @@ -45,8 +45,6 @@ public interface ApplicationEx extends Application { boolean holdsReadLock(); - void assertReadAccessToDocumentsAllowed(); - void doNotSave(); void doNotSave(boolean value); boolean isDoNotSave(); diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 93b8a02e8654..28494addf1d6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -941,20 +941,6 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application isDispatchThread(); } - public void assertReadAccessToDocumentsAllowed() { - /* TODO - Thread currentThread = Thread.currentThread(); - if (ourDispatchThread != currentThread) { - if (myExceptionalThreadWithReadAccess == currentThread) return; - if (myActionsLock.isReadLockAcquired(currentThread)) return; - if (myActionsLock.isWriteLockAcquired(currentThread)) return; - if (isDispatchThread(currentThread)) return; - LOG.error( - "Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())"); - } - */ - } - private static void assertCanRunWriteAction() { assertIsDispatchThread("Write access is allowed from event dispatch thread only"); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 56a0b723f752..ba565fea87c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; @@ -197,12 +196,10 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); return myRangeMarkers.removeInterval(rangeMarker); } public void addRangeMarker(@NotNull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); myRangeMarkers.addInterval(rangeMarker, start, end, greedyToLeft, greedyToRight, layer); } @@ -283,7 +280,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { @NotNull public RangeMarker createRangeMarker(int startOffset, int endOffset, boolean surviveOnExternalChange) { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); if (!(0 <= startOffset && startOffset <= endOffset && endOffset <= getTextLength())) { LOG.error("Incorrect offsets: startOffset=" + startOffset + ", endOffset=" + endOffset + ", text length=" + getTextLength()); } @@ -293,7 +289,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public long getModificationStamp() { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); return myModificationStamp; } @@ -609,7 +604,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { @NotNull public LineIterator createLineIterator() { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); return myLineSet.createIterator(); } @@ -622,7 +616,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public final int getLineEndOffset(int line) { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); if (getTextLength() == 0 && line == 0) return 0; int result = myLineSet.getLineEnd(line) - getLineSeparatorLength(line); assert result >= 0; @@ -630,14 +623,12 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public final int getLineSeparatorLength(int line) { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); int separatorLength = myLineSet.getSeparatorLength(line); assert separatorLength >= 0; return separatorLength; } public final int getLineCount() { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); int lineCount = myLineSet.getLineCount(); assert lineCount >= 0; return lineCount; @@ -656,7 +647,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public void fireReadOnlyModificationAttempt() { - ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); for (EditReadOnlyListener listener : myReadOnlyListeners) { listener.readOnlyModificationAttempt(this); } diff --git a/platform/testFramework/src/com/intellij/mock/MockApplication.java b/platform/testFramework/src/com/intellij/mock/MockApplication.java index bde2887e26df..191290183f5d 100644 --- a/platform/testFramework/src/com/intellij/mock/MockApplication.java +++ b/platform/testFramework/src/com/intellij/mock/MockApplication.java @@ -199,10 +199,6 @@ public class MockApplication extends MockComponentManager implements Application public void exit() { } - @Override - public void assertReadAccessToDocumentsAllowed() { - } - @Override public void doNotSave() { } From ca49a23ebc3113193540b3e316c1236c3df1cb75 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 14:53:53 +0400 Subject: [PATCH 20/74] no need to associate .rng extension with RelaxNG via a separate component (PY-4318) --- xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java | 2 +- .../src/org/intellij/plugins/relaxNG/ApplicationLoader.java | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java b/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java index e08c7aa8401f..12e341c87c0c 100644 --- a/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java +++ b/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java @@ -34,7 +34,7 @@ public class XmlFileTypeFactory extends FileTypeFactory { consumer.consume(XHtmlFileType.INSTANCE, "xhtml"); consumer.consume(DTDFileType.INSTANCE, "dtd;ent;mod"); - consumer.consume(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;hs;jhm;ant;xul;xslt"); + consumer.consume(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;hs;jhm;ant;xul;xslt;rng"); TypedHandler.registerBaseLanguageQuoteHandler(XMLLanguage.class, TypedHandler.getQuoteHandlerForType(XmlFileType.INSTANCE)); } } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java index 1b0911acf692..36f970689d76 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java @@ -22,8 +22,6 @@ import com.intellij.javaee.StandardResourceProvider; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.components.ApplicationComponent; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.psi.PsiElement; import com.intellij.psi.filters.AndFilter; import com.intellij.psi.filters.ClassFilter; @@ -63,9 +61,6 @@ public class ApplicationLoader implements ApplicationComponent, InspectionToolPr public void initComponent() { registerMetaData(); - final FileTypeManager ftm = FileTypeManager.getInstance(); - ftm.associateExtension(StdFileTypes.XML, RNG_EXT); - installValidateXmlAction(); } From e4fc790fb786fd0ef9036dd782f6a498033d663d Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 17 Aug 2011 13:18:49 +0200 Subject: [PATCH 21/74] one more fix for actions visibility --- .../src/com/intellij/ui/AddRemoveUpDownPanel.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/AddRemoveUpDownPanel.java b/platform/platform-api/src/com/intellij/ui/AddRemoveUpDownPanel.java index df976b83c7cd..3c19a4c8209e 100644 --- a/platform/platform-api/src/com/intellij/ui/AddRemoveUpDownPanel.java +++ b/platform/platform-api/src/com/intellij/ui/AddRemoveUpDownPanel.java @@ -136,15 +136,11 @@ class AddRemoveUpDownPanel extends JPanel { final ShortcutSet shortcut = button.getShortcut(); if (shortcut != null) { if (button instanceof MyActionButton - && !((MyActionButton)button).isAddButton() - && !UIUtil.isDialogRootPane(pane)) { - button.registerCustomShortcutSet(shortcut, button.getContextComponent()); + && ((MyActionButton)button).isAddButton() + && UIUtil.isDialogRootPane(pane)) { + button.registerCustomShortcutSet(shortcut, pane); } else { - if (UIUtil.isDialogRootPane(pane)) { - button.registerCustomShortcutSet(shortcut, pane); - } else { - button.registerCustomShortcutSet(shortcut, button.getContextComponent()); - } + button.registerCustomShortcutSet(shortcut, button.getContextComponent()); } } } From 86488ccb3211fe6b64b8caf56f7732416c8b2bac Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 17 Aug 2011 13:19:45 +0200 Subject: [PATCH 22/74] Toolbar Decorator for Excludes --- .../options/ExcludedEntriesConfigurable.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java index a5a060531217..d31b208337e3 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java @@ -25,9 +25,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.PanelWithButtons; -import com.intellij.ui.RightAlignedLabelUI; -import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.*; import com.intellij.ui.table.JBTable; import javax.swing.*; @@ -308,12 +306,24 @@ public class ExcludedEntriesConfigurable implements UnnamedConfigurable { ((DefaultCellEditor)editor).setClickCountToStart(1); } - //ToolbarDecorator.createDecorator(myExcludedTable) - // .disableUpAction() - // .disableDownAction() + return ToolbarDecorator.createDecorator(myExcludedTable) + .disableUpAction() + .disableDownAction() + .setAddAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton anActionButton) { + addPath(myDescriptor); + } + }) + .setRemoveAction(new AnActionButtonRunnable() { + @Override + public void run(AnActionButton anActionButton) { + removePaths(); + } + }).createPanel(); - return ScrollPaneFactory.createScrollPane(myExcludedTable); + //return ScrollPaneFactory.createScrollPane(myExcludedTable); } } From 196f56a659b567484eaef177e5e99a2a7f4d24f7 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 13:02:28 +0200 Subject: [PATCH 23/74] IDEA-73097 Velocity: macros defined in #parse-d template are not resolved --- .../fixtures/impl/CodeInsightTestFixtureImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index d6feb428c226..c6d533e7d8df 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -453,7 +453,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override @Nullable public PsiReference getReferenceAtCaretPosition(final String... filePaths) { - configureByFilesInner(filePaths); + if (filePaths.length > 0) { + configureByFilesInner(filePaths); + } return getFile().findReferenceAt(myEditor.getCaretModel().getOffset()); } From a7c0a4ceb0a22b4e564cd8f0fd78e911da489947 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 17 Aug 2011 13:48:43 +0200 Subject: [PATCH 24/74] cleanup (another attempt, sorry) --- .../cvsBrowser/AbstractVcsDataProvider.java | 8 ++-- .../cvsSupport2/cvsBrowser/CvsTreeModel.java | 48 ------------------- 2 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java index 99baf3b9b5bf..7e119bef8ca5 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/AbstractVcsDataProvider.java @@ -56,8 +56,8 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi return new GetDirectoriesListViaUpdateOperation(myEnvironment, path); } - private static class MyCancellableCvsHandler extends CommandCvsHandler { - private MyCancellableCvsHandler(final String title, final CvsOperation cvsOperation) { + private static class CancellableCvsHandler extends CommandCvsHandler { + private CancellableCvsHandler(final String title, final CvsOperation cvsOperation) { super(title, cvsOperation, true); } @@ -76,8 +76,8 @@ public abstract class AbstractVcsDataProvider implements RemoteResourceDataProvi final CvsOperationExecutor executor = new CvsOperationExecutor(false, callback.getProject(), callback.getModalityState()); executor.setIsQuietOperation(true); - final MyCancellableCvsHandler cvsHandler = - new MyCancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), (CvsOperation) command); + final CancellableCvsHandler cvsHandler = + new CancellableCvsHandler(CvsBundle.message("browse.repository.operation.name"), (CvsOperation)command); callback.useForCancel(cvsHandler.getProgressListener()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java deleted file mode 100644 index 7ee71be7b78b..000000000000 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsBrowser/CvsTreeModel.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2009 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.cvsSupport2.cvsBrowser; - -import javax.swing.*; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; - -/** - * author: lesya - */ -public class CvsTreeModel extends DefaultTreeModel{ - private JTree myTree; - private CvsTree myCvsTree; - - public CvsTreeModel(TreeNode root) { - super(root, true); - } - - public CvsTree getCvsTree() { - return myCvsTree; - } - - public void setCvsTree(CvsTree cvsTree) { - myCvsTree = cvsTree; - } - - public void setTree(JTree tree) { - myTree = tree; - } - - public void selectRoot(){ - myTree.addSelectionPath(myTree.getPathForRow(0)); - } -} From d9b6ea89b8a7254c1454fe50e3284e2ba4fa0559 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 17 Aug 2011 16:00:11 +0400 Subject: [PATCH 25/74] Cache gradient sample and honor clip bounds. --- .../wm/impl/status/MacStatusBarUI.java | 45 +++++++++++++++---- .../util/src/com/intellij/util/ui/UIUtil.java | 18 -------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MacStatusBarUI.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MacStatusBarUI.java index ac7f68b8b7ca..b80c574ef8c6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MacStatusBarUI.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MacStatusBarUI.java @@ -25,6 +25,7 @@ import javax.swing.border.Border; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; /** * User: spLeaner @@ -176,33 +177,61 @@ public class MacStatusBarUI extends StatusBarUI implements Activatable { private static final Color INACTIVE_BORDER2_TOP_COLOR = new Color(251, 251, 251); private static final Insets INSETS = new Insets(0, 0, 0, 0); + + private static BufferedImage ACTIVE_CACHE; + private static BufferedImage INACTIVE_CACHE; public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { - final Graphics2D g2d = (Graphics2D) g.create(); + final Graphics2D g2d = (Graphics2D) g; + final Rectangle clip = g.getClipBounds(); final boolean active = isActive(c); - final Color top = active ? ACTIVE_TOP_COLOR : INACTIVE_TOP_COLOR; - final Color bottom = active ? ACTIVE_BOTTOM_COLOR : INACTIVE_BOTTOM_COLOR; + BufferedImage img = active ? ACTIVE_CACHE : INACTIVE_CACHE; - UIUtil.fillVerticalGradient(g, x, y, width, height, top, bottom); + if (img == null || img.getHeight() != height) { + final Color top = active ? ACTIVE_TOP_COLOR : INACTIVE_TOP_COLOR; + final Color bottom = active ? ACTIVE_BOTTOM_COLOR : INACTIVE_BOTTOM_COLOR; + img = getSample(height, top, bottom); + + if (active) { + ACTIVE_CACHE = img; + } + else { + INACTIVE_CACHE = img; + } + } + + + final Graphics2D g2 = (Graphics2D)g; + for (int i = clip.x; i < clip.x + clip.width; i += 50) { + g2.drawImage(img, null, i, y); + } if (active) { g2d.setColor(ACTIVE_BORDER_TOP_COLOR); - g2d.drawLine(0, 0, width, 0); + g2d.drawLine(clip.x, 0, clip.width, 0); g2d.setColor(ACTIVE_BORDER2_TOP_COLOR); - g2d.drawLine(0, 1, width, 1); + g2d.drawLine(clip.x, 1, clip.width, 1); } else { g2d.setColor(INACTIVE_BORDER_TOP_COLOR); - g2d.drawLine(0, 0, width, 0); + g2d.drawLine(clip.x, 0, clip.width, 0); g2d.setColor(INACTIVE_BORDER2_TOP_COLOR); - g2d.drawLine(0, 1, width, 1); + g2d.drawLine(clip.x, 1, clip.width, 1); } g2d.dispose(); } + private static BufferedImage getSample(int height, Color top, Color bottom) { + BufferedImage img = new BufferedImage(50, height, BufferedImage.TYPE_INT_RGB); + Graphics2D imageGraphics = (Graphics2D)img.getGraphics(); + imageGraphics.setPaint(new GradientPaint(0, 0, top, 0, height, bottom)); + imageGraphics.fillRect(0, 0, 50, height); + return img; + } + public Insets getBorderInsets(Component c) { return INSETS; } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 6db57a1ef32e..c4beb644c2f0 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -158,24 +158,6 @@ public class UIUtil { } } - public static void fillVerticalGradient(final Graphics g, - final int x, - final int y, - final int width, - final int height, - final Color top, - final Color bottom) { - BufferedImage img = new BufferedImage(50, height, BufferedImage.TYPE_INT_RGB); - Graphics2D imageGraphics = (Graphics2D)img.getGraphics(); - imageGraphics.setPaint(new GradientPaint(0, 0, top, 0, height, bottom)); - imageGraphics.fillRect(0, 0, 50, height); - - final Graphics2D g2 = (Graphics2D)g; - for (int i = x; i < x + width; i += 50) { - g2.drawImage(img, null, i, y); - } - } - public static boolean isReallyTypedEvent(KeyEvent e) { char c = e.getKeyChar(); if (!(c >= 0x20 && c != 0x7F)) return false; From 63b8978ba384f2e44d08cca16985556b94a12f1c Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 17 Aug 2011 16:06:54 +0400 Subject: [PATCH 26/74] remove arrows from Previous/Next buttons in wizards --- .../platform-resources-en/src/messages/IdeBundle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index bcbe8824ea86..118267f2eef0 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -8,8 +8,8 @@ title.browser.path.not.found=Browser Path Not Found action.sort.alphabetically=Sort Alphabetically button.finish=&Finish button.ok=&OK -button.wizard.previous=< &Previous -button.wizard.next=&Next > +button.wizard.previous=&Previous +button.wizard.next=&Next title.system.error=System Error title.select.path.to.browser=Select Path to Browser title.general=General From dcb3403329785785a6e6c211f298d67b58d73b83 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 17 Aug 2011 14:29:23 +0200 Subject: [PATCH 27/74] use alarm to start roots scanning to deal with big numbers of rootsChanged events --- .../impl/TranslatingCompilerFilesMonitor.java | 68 ++++++++++++------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java index 021b17efd938..43cc62e86f78 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java @@ -45,6 +45,7 @@ import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.newvfs.persistent.FSRecords; import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS; +import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.SLRUCache; import com.intellij.util.indexing.FileBasedIndex; @@ -121,7 +122,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { } }; private final ProjectManager myProjectManager; - private final TIntHashSet myInitInProgress = new TIntHashSet(); // projectId fior successfully initialized projects + private final TIntIntHashMap myInitInProgress = new TIntIntHashMap(); // projectId fior successfully initialized projects private final Object myAsyncScanLock = new Object(); public TranslatingCompilerFilesMonitor(VirtualFileManager vfsManager, ProjectManager projectManager, Application application) { @@ -967,7 +968,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { public void ensureInitializationCompleted(Project project, ProgressIndicator indicator) { final int id = getProjectId(project); synchronized (myAsyncScanLock) { - while (myInitInProgress.contains(id)) { + while (myInitInProgress.containsKey(id)) { if (!project.isOpen() || project.isDisposed() || (indicator != null && indicator.isCanceled())) { // makes no sense to continue waiting break; @@ -1095,7 +1096,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { catch (ProjectRef.ProjectClosedException swallowed) { } finally { - terminateAsyncScan(projectId); + terminateAsyncScan(projectId, false); } } }.queue(); @@ -1103,17 +1104,28 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { }); } - private void terminateAsyncScan(int projectId) { + private void terminateAsyncScan(int projectId, final boolean clearCounter) { synchronized (myAsyncScanLock) { - if (myInitInProgress.remove(projectId)) { + int counter = myInitInProgress.remove(projectId); + if (clearCounter) { myAsyncScanLock.notifyAll(); } + else { + if (--counter > 0) { + myInitInProgress.put(projectId, counter); + } + else { + myAsyncScanLock.notifyAll(); + } + } } } private void startAsyncScan(final int projectId) { synchronized (myAsyncScanLock) { - myInitInProgress.add(projectId); + int counter = myInitInProgress.get(projectId); + counter = (counter > 0)? counter + 1 : 1; + myInitInProgress.put(projectId, counter); myAsyncScanLock.notifyAll(); } } @@ -1130,6 +1142,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { conn.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { private VirtualFile[] myRootsBefore; + private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, conn); public void beforeRootsChange(final ModuleRootEvent event) { try { @@ -1164,26 +1177,31 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { } } - startAsyncScan(projectId); - new Task.Backgroundable(project, CompilerBundle.message("compiler.initial.scanning.progress.text"), false) { - public void run(@NotNull final ProgressIndicator indicator) { - try { - if (newRoots.size() > 0) { - scanSourceContent(projRef, newRoots, newRoots.size(), true); + myAlarm.cancelAllRequests(); // need alarm to deal with multiple rootsChanged events + myAlarm.addRequest(new Runnable() { + public void run() { + startAsyncScan(projectId); + new Task.Backgroundable(project, CompilerBundle.message("compiler.initial.scanning.progress.text"), false) { + public void run(@NotNull final ProgressIndicator indicator) { + try { + if (newRoots.size() > 0) { + scanSourceContent(projRef, newRoots, newRoots.size(), true); + } + if (oldRoots.size() > 0) { + scanSourceContent(projRef, oldRoots, oldRoots.size(), false); + } + markOldOutputRoots(projRef, buildOutputRootsLayout(projRef)); + } + catch (ProjectRef.ProjectClosedException swallowed) { + // ignored + } + finally { + terminateAsyncScan(projectId, false); + } } - if (oldRoots.size() > 0) { - scanSourceContent(projRef, oldRoots, oldRoots.size(), false); - } - markOldOutputRoots(projRef, buildOutputRootsLayout(projRef)); - } - catch (ProjectRef.ProjectClosedException swallowed) { - // ignored - } - finally { - terminateAsyncScan(projectId); - } + }.queue(); } - }.queue(); + }, 500); } catch (ProjectRef.ProjectClosedException e) { LOG.info(e); @@ -1196,7 +1214,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { public void projectClosed(final Project project) { final int projectId = getProjectId(project); - terminateAsyncScan(projectId); + terminateAsyncScan(projectId, true); myConnections.remove(project).disconnect(); synchronized (myDataLock) { mySourcesToRecompile.remove(projectId); From dfa24f6399f51ed9aa65f307e3fc62931bf37fc6 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 17 Aug 2011 15:20:07 +0400 Subject: [PATCH 28/74] Run continuation, if background task throws exception. Otherwise QueueProcessor's continuation fails to start the next task. --- .../openapi/progress/RunBackgroundable.java | 12 +++++------- .../openapi/progress/impl/ProgressManagerImpl.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/progress/RunBackgroundable.java b/platform/platform-api/src/com/intellij/openapi/progress/RunBackgroundable.java index 5cac438dcb27..2dac114bcd72 100644 --- a/platform/platform-api/src/com/intellij/openapi/progress/RunBackgroundable.java +++ b/platform/platform-api/src/com/intellij/openapi/progress/RunBackgroundable.java @@ -16,10 +16,6 @@ package com.intellij.openapi.progress; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.progress.Task; -import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,13 +36,15 @@ public class RunBackgroundable { boolean canceled = true; try { task.run(pi); - if (pooledContinuation != null) { - pooledContinuation.run(); - } canceled = pi != null && pi.isCanceled(); } catch (ProcessCanceledException e) { // + } finally { + if (pooledContinuation != null) { + pooledContinuation.run(); + } } + final boolean finalCanceled = canceled; ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index a15b94fae472..ee7405fa1581 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -328,7 +328,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ Disposer.register(ApplicationManager.getApplication(), (Disposable)progressIndicator); } - final Runnable process = new TaskRunnable(task, progressIndicator); + final Runnable process = new TaskRunnable(task, progressIndicator, continuation); TaskContainer action = new TaskContainer(task) { public void run() { @@ -336,9 +336,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ final long start = System.currentTimeMillis(); try { ProgressManager.getInstance().runProcess(process, progressIndicator); - if (continuation != null) { - continuation.run(); - } } catch (ProcessCanceledException e) { canceled = true; @@ -415,10 +412,16 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ private static class TaskRunnable extends TaskContainer { private final ProgressIndicator myIndicator; + private final Runnable myContinuation; private TaskRunnable(@NotNull Task task, @NotNull ProgressIndicator indicator) { + this(task, indicator, null); + } + + private TaskRunnable(@NotNull Task task, @NotNull ProgressIndicator indicator, @Nullable Runnable continuation) { super(task); myIndicator = indicator; + myContinuation = continuation; } public void run() { @@ -429,6 +432,9 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ if (myIndicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)myIndicator).finish(getTask()); } + if (myContinuation != null) { + myContinuation.run(); + } } } } From fd1c3c35a5d427c18b5c3cb514cf198f4f27d5c4 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 17 Aug 2011 16:58:52 +0400 Subject: [PATCH 29/74] Run continuation, if background task throws exception - in the finally block, if ProgressIndicator.finish fails. --- .../openapi/progress/impl/ProgressManagerImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index ee7405fa1581..12befda938a1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -429,11 +429,15 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{ getTask().run(myIndicator); } finally { - if (myIndicator instanceof ProgressIndicatorEx) { - ((ProgressIndicatorEx)myIndicator).finish(getTask()); + try { + if (myIndicator instanceof ProgressIndicatorEx) { + ((ProgressIndicatorEx)myIndicator).finish(getTask()); + } } - if (myContinuation != null) { - myContinuation.run(); + finally { + if (myContinuation != null) { + myContinuation.run(); + } } } } From 41f89eff1cf26d1a9534aa0e4a6884cd50f77c9e Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 15:03:31 +0200 Subject: [PATCH 30/74] no more hacky autopopup delay queue --- .../completion/AllClassesGetter.java | 36 ++++--------------- .../completion/CodeCompletionHandlerBase.java | 10 ++---- .../CompletionProgressIndicator.java | 16 +-------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java index e081d4d91286..6bba05fb03dd 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java @@ -16,7 +16,6 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.CodeInsightUtilBase; -import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -27,7 +26,6 @@ import com.intellij.openapi.util.Condition; import com.intellij.psi.*; import com.intellij.psi.impl.source.PostprocessReformattingAspect; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.PsiShortNamesCache; import com.intellij.psi.search.searches.AllClassesSearch; import com.intellij.util.Consumer; import com.intellij.util.IncorrectOperationException; @@ -153,7 +151,11 @@ public class AllClassesGetter { final GlobalSearchScope scope = filterByScope ? context.getContainingFile().getResolveScope() : GlobalSearchScope.allScope(project); final boolean pkgContext = JavaCompletionUtil.inSomePackage(context); - final Processor classProcessor = new Processor() { + AllClassesSearch.search(scope, project, new Condition() { + public boolean value(String s) { + return prefixMatcher.prefixMatches(s); + } + }).forEach(new Processor() { public boolean process(PsiClass psiClass) { assert psiClass != null; if (isSuitable(context, packagePrefix, qnames, psiClass, filterByScope, pkgContext)) { @@ -162,33 +164,7 @@ public class AllClassesGetter { } return true; } - }; - - PsiShortNamesCache shortNamesCache = JavaPsiFacade.getInstance(project).getShortNamesCache(); - - Set words = WordCompletionContributor.getAllWords(context, parameters.getOffset()); - words.add(prefixMatcher.getPrefix()); - for (String s : words) { - if (prefixMatcher.prefixMatches(s)) { - for (PsiClass wordMatch : shortNamesCache.getClassesByName(s, scope)) { - classProcessor.process(wordMatch); - } - } - } - - final CompletionProgressIndicator indicator = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); - if (indicator != null) { - indicator.delayAllowingFocusedLookup(new Runnable() { - @Override - public void run() { - AllClassesSearch.search(scope, project, new Condition() { - public boolean value(String s) { - return prefixMatcher.prefixMatches(s); - } - }).forEach(classProcessor); - } - }); - } + }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index a61932e1f15a..bece8b7e45f6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -332,17 +332,11 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { indicator.duringCompletion(initContext); ProgressManager.checkCanceled(); - final List items = new ArrayList(); - CompletionService.getCompletionService().performCompletion(parameters, new Consumer() { + data.set(CompletionService.getCompletionService().performCompletion(parameters, new Consumer() { public void consume(final CompletionResult result) { indicator.addItem(result); - items.add(result.getLookupElement()); } - }); - - indicator.processDelayQueue(); - - data.set(items.toArray(new LookupElement[items.size()])); + })); } }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index 561828916924..2f6de08bfa27 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -72,7 +72,6 @@ import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; @@ -117,8 +116,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement }; private volatile int myCount; private final ConcurrentHashMap myItemSorters = new ConcurrentHashMap(TObjectHashingStrategy.IDENTITY); - private final LinkedList myDelayQueue = new LinkedList(); - private volatile boolean myProcessingDelayedActions; private final Set myMapsToDispose = new THashSet(); private final PropertyChangeListener myLookupManagerListener; @@ -214,17 +211,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } } - public void delayAllowingFocusedLookup(@NotNull Runnable runnable) { - myDelayQueue.addLast(runnable); - } - - public void processDelayQueue() { - myProcessingDelayedActions = true; - while (!myDelayQueue.isEmpty()) { - myDelayQueue.removeFirst().run(); - } - } - @NotNull CompletionSorterImpl getSorter(LookupElement element) { return myItemSorters.get(element); @@ -368,7 +354,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement private boolean shouldShowLookup() { if (isAutopopupCompletion() && myLookup.isCalculating()) { - return myProcessingDelayedActions; + return false; } return true; } From 93b117081ec6205e84499c3665974be938df3eff Mon Sep 17 00:00:00 2001 From: Nikolay Matveev Date: Wed, 17 Aug 2011 17:05:38 +0400 Subject: [PATCH 31/74] PHP Provide statistics about file types (WI-7202) --- .../fileTypes/FileTypeUsagesCollector.java | 73 +++++++++++++++++++ .../FileTypeUsagesCollectorTest.java | 70 ++++++++++++++++++ .../src/META-INF/LangExtensions.xml | 1 + 3 files changed, 144 insertions(+) create mode 100644 platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java create mode 100644 platform/lang-impl/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java new file mode 100644 index 000000000000..a29639cf9ad2 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2011 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.openapi.fileTypes; + +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.search.FileTypeIndex; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.util.NotNullFunction; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.indexing.FileBasedIndex; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Nikolay Matveev + */ +public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector { + + private static final String GROUP_ID = "file-type"; + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } + + @NotNull + @Override + public Set getProjectUsages(@NotNull Project project) { + final Set usedFileTypes = new HashSet(); + final FileType[] registeredFileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); + for (final FileType fileType : registeredFileTypes) { + FileBasedIndex.getInstance().processValues( + FileTypeIndex.NAME, + fileType, + null, + new FileBasedIndex.ValueProcessor() { + @Override + public boolean process(VirtualFile file, Void value) { + usedFileTypes.add(fileType); + return false; + } + }, GlobalSearchScope.projectScope(project)); + } + usedFileTypes.add(UnknownFileType.INSTANCE); + return ContainerUtil.map2Set(usedFileTypes, new NotNullFunction() { + @NotNull + @Override + public UsageDescriptor fun(FileType fileType) { + return new UsageDescriptor(fileType.getName(), 1); + } + }); + } +} diff --git a/platform/lang-impl/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java b/platform/lang-impl/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java new file mode 100644 index 000000000000..3e5e8534a86f --- /dev/null +++ b/platform/lang-impl/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2011 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.openapi.fileTypes; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.util.NotNullFunction; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + +/** + * @author Nikolay Matveev + */ +public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixtureTestCase { + + private void doTest(@NotNull Collection fileTypes) { + final Set usages = new FileTypeUsagesCollector().getProjectUsages(getProject()); + for (UsageDescriptor usage : usages) { + assertEquals(1, usage.getValue()); + } + assertEquals( + ContainerUtil.map2Set(fileTypes, new NotNullFunction() { + @NotNull + @Override + public String fun(FileType fileType) { + return fileType.getName(); + } + }), + ContainerUtil.map2Set(usages, new NotNullFunction() { + @NotNull + @Override + public String fun(UsageDescriptor usageDescriptor) { + return usageDescriptor.getKey(); + } + }) + ); + } + + public void testEmptyProject() { + doTest(Arrays.asList(UnknownFileType.INSTANCE)); + } + + public void testSingleFileProject() { + myFixture.configureByText("a.txt", ""); + doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE)); + } + + public void testSeveralSameFilesProject() { + myFixture.configureByText("a.txt", ""); + myFixture.configureByText("b.txt", ""); + doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE)); + } +} diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index a374f757c574..1e6a9135d6d1 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -633,6 +633,7 @@ + From 06356af540721f97bac15b2678ebe9a412854b0f Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 16 Aug 2011 16:47:50 +0400 Subject: [PATCH 32/74] read access --- .../psi/impl/search/JavaDirectInheritorsSearcher.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java b/java/java-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java index 73593a3a7184..fbbd5bdaeaf5 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java @@ -67,7 +67,12 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor() { + @Override + public String compute() { + return aClass.getName(); + } + }); if (StringUtil.isEmpty(searchKey)) { return true; } From 39eef106aaf5e3a00fffe60b616a234b2bf01d0a Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 16 Aug 2011 17:18:35 +0400 Subject: [PATCH 33/74] read access --- .../intellij/codeInsight/daemon/impl/MarkerType.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java index b4f141eb648f..1a6bcce36009 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java @@ -26,12 +26,15 @@ import com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask; import com.intellij.ide.util.MethodCellRenderer; import com.intellij.ide.util.PsiClassListCellRenderer; import com.intellij.ide.util.PsiElementListCellRenderer; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.util.Computable; import com.intellij.psi.*; import com.intellij.psi.search.PsiElementProcessor; import com.intellij.psi.search.PsiElementProcessorAdapter; +import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.util.PsiUtil; @@ -235,7 +238,12 @@ public class MarkerType { @Override public void run(@NotNull ProgressIndicator indicator) { super.run(indicator); - ClassInheritorsSearch.search(myClass, myClass.getUseScope(), true).forEach(new CommonProcessors.CollectProcessor() { + ClassInheritorsSearch.search(myClass, ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public SearchScope compute() { + return myClass.getUseScope(); + } + }), true).forEach(new CommonProcessors.CollectProcessor() { @Override public boolean process(final PsiClass o) { updateComponent(o, myRenderer.getComparator()); @@ -266,7 +274,7 @@ public class MarkerType { @Override public void run(@NotNull ProgressIndicator indicator) { super.run(indicator); - OverridingMethodsSearch.search(myMethod, myMethod.getUseScope(), true).forEach( + OverridingMethodsSearch.search(myMethod, true).forEach( new CommonProcessors.CollectProcessor() { @Override public boolean process(PsiMethod psiMethod) { From cd0938b8bf4bdc547f450ec4b6cc20dd624c1ea3 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 15:20:12 +0200 Subject: [PATCH 34/74] IDEA-70827 Auto-wrap doesn't wrap on typing letters --- .../codeInsight/editorActions/AutoHardWrapHandler.java | 4 ++-- .../codeInsight/editorActions/CompletionAutoPopupHandler.java | 3 +++ .../intellij/codeInsight/lookup/impl/LookupTypedHandler.java | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java index cb3c02720fd3..89bdba70f2d2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java @@ -31,7 +31,7 @@ import com.intellij.openapi.util.Key; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.WhiteSpaceFormattingStrategyFactory; import com.intellij.util.containers.WeakHashMap; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -85,7 +85,7 @@ public class AutoHardWrapHandler { * @param dataContext current data context * @param modificationStampBeforeTyping document modification stamp before the current symbols typing */ - public void wrapLineIfNecessary(Editor editor, @Nullable DataContext dataContext, long modificationStampBeforeTyping) { + public void wrapLineIfNecessary(Editor editor, @NotNull DataContext dataContext, long modificationStampBeforeTyping) { Project project = editor.getProject(); Document document = editor.getDocument(); AutoWrapChange change = myAutoWrapChanges.get(document); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java index 62c9f30ec3f6..87a34547ed31 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java @@ -22,6 +22,7 @@ import com.intellij.codeInsight.completion.CompletionType; import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInsight.lookup.impl.LookupImpl; +import com.intellij.ide.DataManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -51,7 +52,9 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { FileType fileType) { CompletionPhase phase = CompletionServiceImpl.getCompletionPhase(); if (phase instanceof CompletionPhase.EmptyAutoPopup) { + long modificationStampBeforeTyping = editor.getDocument().getModificationStamp(); ((CompletionPhase.EmptyAutoPopup)phase).handleTyping(c); + AutoHardWrapHandler.getInstance().wrapLineIfNecessary(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()), modificationStampBeforeTyping); return Result.STOP; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java index 341c57bca4b2..c05a879af148 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java @@ -25,6 +25,7 @@ import com.intellij.codeInsight.lookup.CharFilter; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.featureStatistics.FeatureUsageTracker; +import com.intellij.ide.DataManager; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.CommandProcessor; @@ -80,7 +81,7 @@ public class LookupTypedHandler extends TypedHandlerDelegate { AutoPopupController.getInstance(editor.getProject()).scheduleAutoPopup(editor, null); } - AutoHardWrapHandler.getInstance().wrapLineIfNecessary(editor, null, modificationStamp); + AutoHardWrapHandler.getInstance().wrapLineIfNecessary(editor, DataManager.getInstance().getDataContext(editor.getContentComponent()), modificationStamp); final CompletionProgressIndicator completion = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (completion != null) { From 965c1d663ff249fe99eee9d7fb635734f6619fa6 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 15:31:03 +0200 Subject: [PATCH 35/74] don't suggest non-imported Arrays --- .../completion/JavaCompletionContributor.java | 9 ++------- .../codeInsight/completion/JavaAutoPopupTest.groovy | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index c240ad91b64a..0f70a482fb5a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java @@ -270,16 +270,11 @@ public class JavaCompletionContributor extends CompletionContributor { final boolean isSwitchLabel = SWITCH_LABEL.accepts(position); final PsiFile originalFile = parameters.getOriginalFile(); - Set set = JavaCompletionUtil.processJavaReference(position, + for (LookupElement element : JavaCompletionUtil.processJavaReference(position, (PsiJavaReference)reference, new ElementExtractorFilter(filter), checkAccess, - result.getPrefixMatcher(), parameters); - PsiClass arrays = JavaPsiFacade.getInstance(position.getProject()).findClass(CommonClassNames.JAVA_UTIL_ARRAYS, position.getResolveScope()); - if (arrays != null && filter.isAcceptable(arrays, position) && isClassNamePossible(parameters.getPosition())) { - set.add(JavaClassNameCompletionContributor.createClassLookupItem(arrays, true)); - } - for (LookupElement element : set) { + result.getPrefixMatcher(), parameters)) { if (inheritors.alreadyProcessed(element)) { continue; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index 146070fc692b..c5e754ab78c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -934,8 +934,9 @@ public class Bar { public void testArrays() { myFixture.configureByText "a.java", "class Foo {{ }}" - type 'Arrays' - assert myFixture.lookupElementStrings == ['Arrays', 'ArrayStoreException'] + type 'Arrays.' + myFixture.checkResult "class Foo {{ Arrays. }}" + assert !lookup } From add760e5f433118d5da1936ff1ed18d33ace2443 Mon Sep 17 00:00:00 2001 From: "Rustam.Vishnyakov" Date: Wed, 17 Aug 2011 17:43:35 +0400 Subject: [PATCH 36/74] Fixed code style settings import/tests --- .../src/com/intellij/psi/codeStyle/CodeStyleSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java index 38e61d234517..0623a5835ad5 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java @@ -563,11 +563,11 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea } } + myCommonSettingsManager.readExternal(element); + copyOldIndentOptions("java", JAVA_INDENT_OPTIONS); copyOldIndentOptions("jsp", JSP_INDENT_OPTIONS); copyOldIndentOptions("xml", XML_INDENT_OPTIONS); - - myCommonSettingsManager.readExternal(element); } private void copyOldIndentOptions(@NonNls final String extension, final IndentOptions options) { From 05cc5f76bbd5ab311c29ca9901a98fdc754ad83f Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Aug 2011 15:47:20 +0200 Subject: [PATCH 37/74] read access --- .../codeInsight/navigation/ImplementationSearcher.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java index 3a62c8605b7b..de052c1e16fd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java @@ -45,7 +45,12 @@ public class ImplementationSearcher { return targetElementUtil.findTargetElement(editor, getFlags() & ~TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED, offset) == null; } }); - return searchImplementations(element, offset, onRef && targetElementUtil.includeSelfInGotoImplementation(element), onRef); + return searchImplementations(element, offset, onRef && ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + return targetElementUtil.includeSelfInGotoImplementation(element); + } + }), onRef); } @NotNull From 9b9ba81cfe7fb928033388776d626e4fdb92ea38 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Aug 2011 15:56:06 +0200 Subject: [PATCH 38/74] read access --- .../codeInsight/navigation/GotoTargetHandler.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java index edff272e83a2..21dba52df62e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java @@ -23,6 +23,7 @@ import com.intellij.ide.util.EditSourceUtil; import com.intellij.ide.util.PsiElementListCellRenderer; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.NavigationItem; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.ProgressManager; @@ -277,11 +278,17 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler { return hasDifferentNames; } - public void addTarget(PsiElement element) { + public void addTarget(final PsiElement element) { targets = ArrayUtil.append(targets, element); renderers.put(element, createRenderer(this, element)); if (!hasDifferentNames && element instanceof PsiNamedElement) { - myNames.add(((PsiNamedElement)element).getName()); + final String name = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public String compute() { + return ((PsiNamedElement)element).getName(); + } + }); + myNames.add(name); hasDifferentNames = myNames.size() > 1; } } From 52210c2abdf9c63029b4ffbe4ed40c15a1c6165d Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 17 Aug 2011 16:17:33 +0200 Subject: [PATCH 39/74] generify --- .../cvsIgnore/IgnoreFileFilter.java | 9 ++--- .../cvsIgnore/IgnoredFilesInfoImpl.java | 35 ++++++++----------- .../cvsSupport2/cvsIgnore/UserDirIgnores.java | 20 +++++------ .../cvsclient/util/SimpleStringPattern.java | 15 ++++---- 4 files changed, 33 insertions(+), 46 deletions(-) diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoreFileFilter.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoreFileFilter.java index 12698a5c9fb8..3ae5a422ea0c 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoreFileFilter.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoreFileFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,9 +15,6 @@ */ package com.intellij.cvsSupport2.cvsIgnore; -import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfo; -import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfoImpl; -import com.intellij.cvsSupport2.CvsUtil; import com.intellij.cvsSupport2.CvsUtil; import com.intellij.util.containers.HashMap; import org.netbeans.lib.cvsclient.file.AbstractFileObject; @@ -38,10 +35,8 @@ public class IgnoreFileFilter implements IIgnoreFileFilter{ File file = cvsFileSystem.getLocalFileSystem().getFile(abstractFileObject); File parent = file.getParentFile(); if (!myParentToFilterMap.containsKey(parent)){ - myParentToFilterMap.put(parent, IgnoredFilesInfoImpl.createForFile(new File(parent, - CvsUtil.CVS_IGNORE_FILE))); + myParentToFilterMap.put(parent, IgnoredFilesInfoImpl.createForFile(new File(parent, CvsUtil.CVS_IGNORE_FILE))); } return myParentToFilterMap.get(parent).shouldBeIgnored(file.getName()); - } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java index 3df15f4f3125..d11c2ed41658 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,17 +15,12 @@ */ package com.intellij.cvsSupport2.cvsIgnore; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.cvsSupport2.application.CvsEntriesManager; -import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfo; +import com.intellij.openapi.diagnostic.Logger; import org.netbeans.lib.cvsclient.util.SimpleStringPattern; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; +import java.io.*; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -79,7 +74,7 @@ public class IgnoredFilesInfoImpl implements IgnoredFilesInfo { } }; - private List myPatterns = null; + private List myPatterns = null; public static IgnoredFilesInfo createForFile(File file){ if (!file.isFile()) return EMPTY_FILTER; @@ -88,8 +83,8 @@ public class IgnoredFilesInfoImpl implements IgnoredFilesInfo { private IgnoredFilesInfoImpl() { } - public static ArrayList getPattensFor(File cvsIgnoreFile){ - ArrayList result = new ArrayList(); + public static List getPattensFor(File cvsIgnoreFile){ + ArrayList result = new ArrayList(); if (!cvsIgnoreFile.exists()) return result; @@ -105,16 +100,16 @@ public class IgnoredFilesInfoImpl implements IgnoredFilesInfo { } } catch (Exception ex){ - + LOG.error(ex); } finally{ try { reader.close(); - } catch (java.io.IOException e) { - + } catch (IOException e) { + LOG.error(e); } } - } catch (java.io.FileNotFoundException e) { + } catch (FileNotFoundException e) { LOG.error(e); } @@ -130,17 +125,17 @@ public class IgnoredFilesInfoImpl implements IgnoredFilesInfo { return checkPatterns(myPatterns, fileName); } - protected static boolean checkPatterns(List patterns, String fileName) { - for (Iterator iterator = patterns.iterator(); iterator.hasNext();) { - SimpleStringPattern simpleStringPattern = (SimpleStringPattern) iterator.next(); + protected static boolean checkPatterns(List patterns, String fileName) { + for (int i = 0, patternsSize = patterns.size(); i < patternsSize; i++) { + SimpleStringPattern simpleStringPattern = patterns.get(i); if (simpleStringPattern.doesMatch(fileName)) return true; } return false; } protected static boolean checkPatterns(SimpleStringPattern[] patterns, String fileName) { - for (int i = 0; i < patterns.length; i++) { - if (patterns[i].doesMatch(fileName)) return true; + for (SimpleStringPattern pattern : patterns) { + if (pattern.doesMatch(fileName)) return true; } return false; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/UserDirIgnores.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/UserDirIgnores.java index 2ecaf24340ef..319015d22bf8 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/UserDirIgnores.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/UserDirIgnores.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,32 +15,32 @@ */ package com.intellij.cvsSupport2.cvsIgnore; +import com.intellij.cvsSupport2.CvsUtil; import com.intellij.cvsSupport2.util.CvsVfsUtil; -import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfoImpl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; +import org.jetbrains.annotations.NonNls; +import org.netbeans.lib.cvsclient.util.SimpleStringPattern; import java.io.File; -import java.util.ArrayList; - -import org.jetbrains.annotations.NonNls; +import java.util.List; /** * author: lesya */ public class UserDirIgnores{ - private ArrayList myPatterns; - @NonNls private static final File ourUserHomeCVSIgnoreFile = new File(System.getProperty("user.home") + "/.cvsignore"); + private List myPatterns; + @NonNls private static final File ourUserHomeCVSIgnoreFile = new File(System.getProperty("user.home") + "/" + CvsUtil.CVS_IGNORE_FILE); - public ArrayList getPatterns(){ + public List getPatterns(){ if (myPatterns == null){ myPatterns = createUserDirIgnoredFilesInfo(); } return myPatterns; } - private ArrayList createUserDirIgnoredFilesInfo() { + private List createUserDirIgnoredFilesInfo() { final File file = userHomeCvsIgnoreFile(); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { @@ -57,6 +57,4 @@ public class UserDirIgnores{ public void clearInfo() { myPatterns = null; } - - } diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/util/SimpleStringPattern.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/util/SimpleStringPattern.java index 45a75ba3a14a..dfb6c37c0344 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/util/SimpleStringPattern.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/util/SimpleStringPattern.java @@ -16,8 +16,7 @@ package org.netbeans.lib.cvsclient.util; import org.jetbrains.annotations.NonNls; -import java.util.Iterator; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; /** @@ -29,7 +28,7 @@ public final class SimpleStringPattern private static final char MATCH_EACH = '*'; private static final char MATCH_ONE = '?'; - private final List subPatterns = new LinkedList(); + private final List subPatterns = new ArrayList(); /** * Creates a SimpleStringPattern for the specified definition. @@ -45,8 +44,8 @@ public final class SimpleStringPattern public boolean doesMatch(String string) { int index = 0; SubPattern subPattern = null; - for (Iterator it = subPatterns.iterator(); it.hasNext();) { - subPattern = (SubPattern)it.next(); + for (int i = 0, length = subPatterns.size(); i < length ; i++) { + subPattern = subPatterns.get(i); index = subPattern.doesMatch(string, index); if (index < 0) { return false; @@ -108,9 +107,9 @@ public final class SimpleStringPattern } public String toString() { - final StringBuffer buffer = new StringBuffer(); - for (Iterator it = subPatterns.iterator(); it.hasNext();) { - final SubPattern subPattern = (SubPattern)it.next(); + final StringBuilder buffer = new StringBuilder(); + for (int i = 0, length = subPatterns.size(); i < length; i++) { + final SubPattern subPattern = subPatterns.get(i); buffer.append(subPattern.toString()); } return buffer.toString(); From afa357adbd2b9b1ec648dd6de0bc49ef0632f5a4 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 16:20:54 +0200 Subject: [PATCH 40/74] don't suggest constant names in second basic completion --- .../JavaBasicToClassNameDelegator.java | 58 +++++++++++++++++++ ...java => XmlBasicToClassNameDelegator.java} | 6 +- resources/src/META-INF/IdeaPlugin.xml | 6 +- 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 java/java-impl/src/com/intellij/codeInsight/completion/JavaBasicToClassNameDelegator.java rename java/java-impl/src/com/intellij/codeInsight/completion/{BasicToClassNameDelegator.java => XmlBasicToClassNameDelegator.java} (88%) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaBasicToClassNameDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaBasicToClassNameDelegator.java new file mode 100644 index 000000000000..daf464e94938 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaBasicToClassNameDelegator.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2011 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.codeInsight.completion; + +import com.intellij.codeInsight.lookup.AutoCompletionPolicy; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.openapi.util.Ref; +import com.intellij.util.Consumer; + +/** + * @author peter + */ +public class JavaBasicToClassNameDelegator extends CompletionContributor { + + @Override + public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) { + if (parameters.getCompletionType() != CompletionType.BASIC || + parameters.getInvocationCount() != 1 || + !JavaCompletionContributor.mayStartClassName(result, false) || + !JavaCompletionContributor.isClassNamePossible(parameters.getPosition())) { + return; + } + + final Ref empty = Ref.create(true); + result.runRemainingContributors(parameters, new Consumer() { + public void consume(final CompletionResult lookupElement) { + empty.set(false); + result.passResult(lookupElement); + } + }); + + if (empty.get()) { + JavaClassNameCompletionContributor.addAllClasses(parameters, JavaCompletionSorting.addJavaSorting(parameters, result), new Consumer() { + @Override + public void consume(LookupElement element) { + JavaPsiClassReferenceElement classElement = element.as(JavaPsiClassReferenceElement.CLASS_CONDITION_KEY); + if (classElement != null) { + classElement.setAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE); + } + result.addElement(element); + } + }); + } + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/BasicToClassNameDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java similarity index 88% rename from java/java-impl/src/com/intellij/codeInsight/completion/BasicToClassNameDelegator.java rename to java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java index 11fe1b25cc70..f5a864885480 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/BasicToClassNameDelegator.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/XmlBasicToClassNameDelegator.java @@ -24,16 +24,12 @@ import com.intellij.psi.PsiFile; /** * @author peter */ -public class BasicToClassNameDelegator extends AbstractBasicToClassNameDelegator { +public class XmlBasicToClassNameDelegator extends AbstractBasicToClassNameDelegator { @Override protected boolean isClassNameCompletionSupported(CompletionResultSet result, PsiFile file, PsiElement position) { if (!JavaCompletionContributor.mayStartClassName(result, false)) return false; - if (file.getLanguage() == StdLanguages.JAVA) { - return JavaCompletionContributor.isClassNamePossible(position); - } - return file.getLanguage().isKindOf(StdLanguages.XML); } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 262e1071eafa..f42d2f5e592c 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -193,8 +193,10 @@ - + + Date: Wed, 17 Aug 2011 16:40:26 +0200 Subject: [PATCH 41/74] show where the constants in class name completion come from --- ...GlobalMemberNameCompletionContributor.java | 2 +- .../GlobalMemberNameCompletionTest.groovy | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java index bdfe1f25cd25..2f414eeedd4d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java @@ -102,7 +102,7 @@ public class JavaGlobalMemberNameCompletionContributor extends CompletionContrib @Override public void renderElement(LookupElementPresentation presentation) { super.renderElement(presentation); - myHelper.renderElement(presentation, getAttribute(FORCE_QUALIFY) != null, PsiSubstitutor.EMPTY); + myHelper.renderElement(presentation, getAttribute(FORCE_QUALIFY) != null ? Boolean.TRUE : null, PsiSubstitutor.EMPTY); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy index 2cf4238f1f49..12d209a155c2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy @@ -2,7 +2,8 @@ package com.intellij.codeInsight.completion; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.codeInsight.CodeInsightSettings -import com.intellij.util.ArrayUtil; +import com.intellij.util.ArrayUtil +import com.intellij.codeInsight.lookup.LookupElementPresentation; /** * @author peter @@ -54,6 +55,24 @@ public class Foo { class Bar {{ Foo.abcfield }}""" } + public void testFieldNamePresentation() { + myFixture.addClass(""" +package foo; + +public class Foo { + public static int abcfield = 2 + static final int fieldThatsNotVisible = 3 +} +""") + myFixture.configureByText "a.java", "class Bar {{ abcf }}" + def element = myFixture.complete(CompletionType.CLASS_NAME)[0] + def presentation = new LookupElementPresentation() + element.renderElement(presentation) + assert 'Foo.abcfield' == presentation.itemText + assert ' (foo)' == presentation.tailText + assert 'int' == presentation.typeText + } + public void testQualifiedMethodName() throws Exception { myFixture.addClass(""" package foo; From 719279583ffe98186171af3b89a81b66e6f1a66e Mon Sep 17 00:00:00 2001 From: "Rustam.Vishnyakov" Date: Wed, 17 Aug 2011 18:38:29 +0400 Subject: [PATCH 42/74] Java indent settings import fix/test --- .../psi/codeStyle/CodeStyleSettings.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java index 0623a5835ad5..175cb35474c1 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java @@ -537,7 +537,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea IMPORT_LAYOUT_TABLE.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY); } } - importOldIndentOptions(element); + boolean oldOptionsImported = importOldIndentOptions(element); for (final CustomCodeStyleSettings settings : myCustomSettings.values()) { settings.readExternal(element); } @@ -565,9 +565,11 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea myCommonSettingsManager.readExternal(element); - copyOldIndentOptions("java", JAVA_INDENT_OPTIONS); - copyOldIndentOptions("jsp", JSP_INDENT_OPTIONS); - copyOldIndentOptions("xml", XML_INDENT_OPTIONS); + if (oldOptionsImported) { + copyOldIndentOptions("java", JAVA_INDENT_OPTIONS); + copyOldIndentOptions("jsp", JSP_INDENT_OPTIONS); + copyOldIndentOptions("xml", XML_INDENT_OPTIONS); + } } private void copyOldIndentOptions(@NonNls final String extension, final IndentOptions options) { @@ -587,8 +589,9 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea } } - private void importOldIndentOptions(@NonNls Element element) { + private boolean importOldIndentOptions(@NonNls Element element) { final List options = element.getChildren("option"); + boolean optionsImported = false; for (Object option1 : options) { @NonNls Element option = (Element)option1; @NonNls final String name = option.getAttributeValue("name"); @@ -598,6 +601,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea JSP_INDENT_OPTIONS.TAB_SIZE = value; XML_INDENT_OPTIONS.TAB_SIZE = value; OTHER_INDENT_OPTIONS.TAB_SIZE = value; + optionsImported = true; } else if ("INDENT_SIZE".equals(name)) { final int value = Integer.valueOf(option.getAttributeValue("value")).intValue(); @@ -605,6 +609,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea JSP_INDENT_OPTIONS.INDENT_SIZE = value; XML_INDENT_OPTIONS.INDENT_SIZE = value; OTHER_INDENT_OPTIONS.INDENT_SIZE = value; + optionsImported = true; } else if ("CONTINUATION_INDENT_SIZE".equals(name)) { final int value = Integer.valueOf(option.getAttributeValue("value")).intValue(); @@ -612,6 +617,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea JSP_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value; XML_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value; OTHER_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value; + optionsImported = true; } else if ("USE_TAB_CHARACTER".equals(name)) { final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue(); @@ -619,6 +625,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea JSP_INDENT_OPTIONS.USE_TAB_CHARACTER = value; XML_INDENT_OPTIONS.USE_TAB_CHARACTER = value; OTHER_INDENT_OPTIONS.USE_TAB_CHARACTER = value; + optionsImported = true; } else if ("SMART_TABS".equals(name)) { final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue(); @@ -626,11 +633,14 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea JSP_INDENT_OPTIONS.SMART_TABS = value; XML_INDENT_OPTIONS.SMART_TABS = value; OTHER_INDENT_OPTIONS.SMART_TABS = value; + optionsImported = true; } else if ("SPACE_AFTER_UNARY_OPERATOR".equals(name)) { final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue(); SPACE_AROUND_UNARY_OPERATOR = value; + optionsImported = true; } } + return optionsImported; } public void writeExternal(Element element) throws WriteExternalException { From 7918455f6740b9a737c6aaa4bf3d89b13e4602c3 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 17 Aug 2011 17:00:39 +0200 Subject: [PATCH 43/74] IDEA-73195 Multiline EOL comments autoformatting problem --- .../formatter/processors/GroovySpacingProcessor.java | 10 +++++----- .../plugins/groovy/lang/formatter/FormatterTest.java | 1 + .../groovy/formatter/multilineEolComment.test | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/formatter/multilineEolComment.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java index 57b45924147f..93478130a8da 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java @@ -96,17 +96,17 @@ public class GroovySpacingProcessor extends GroovyElementVisitor { if (prev != null && prev.getElementType() == mNLS) { prev = getPrevElementType(prev); } - if (prev != null && prev.getElementType() == mSL_COMMENT) { - myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE); - return; - } - if (myChild2 != null && mySettings.KEEP_FIRST_COLUMN_COMMENT && COMMENT_SET.contains(myChild2.getElementType())) { if (myChild1.getElementType() != IMPORT_STATEMENT) { myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, 1); } return; } + if (prev != null && prev.getElementType() == mSL_COMMENT) { + myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE); + return; + } + if (myParent instanceof GroovyPsiElement) { ((GroovyPsiElement) myParent).accept(this); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java index f2f961508374..072d276d911c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java @@ -147,6 +147,7 @@ public class FormatterTest extends GroovyFormatterTestCase { public void testFormatDiamonds() throws Throwable { doTest(); } public void testFormatAnonymousDiamonds() throws Throwable { doTest(); } public void testPreserveChainingLineBreaks() throws Throwable { doTest(); } + public void testMultilineEolComment() throws Throwable { doTest(); } public void testAlignChainedCalls() throws Throwable { myTempSettings.ALIGN_MULTILINE_CHAINED_METHODS = true; diff --git a/plugins/groovy/testdata/groovy/formatter/multilineEolComment.test b/plugins/groovy/testdata/groovy/formatter/multilineEolComment.test new file mode 100644 index 000000000000..a68535ff1b8e --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/multilineEolComment.test @@ -0,0 +1,11 @@ +class Foo{ +// Foo copy() { +// another(zo) +// } +} +----- +class Foo { +// Foo copy() { +// another(zo) +// } +} From 4347db8cc2e5c3c6f16fb0958f6f22ed229e5c9e Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 17 Aug 2011 17:39:02 +0200 Subject: [PATCH 44/74] [r=peter] prevent index & vfs flushes while the app is initializing --- .../intellij/openapi/application/impl/ApplicationImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 28494addf1d6..3f7807894a64 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -62,6 +62,7 @@ import com.intellij.util.EventDispatcher; import com.intellij.util.ReflectionCache; import com.intellij.util.concurrency.ReentrantWriterPreferenceReadWriteLock; import com.intellij.util.containers.Stack; +import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -494,13 +495,16 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application loadComponentRoamingTypes(); + HeavyProcessLatch.INSTANCE.processStarted(); try { getStateStore().load(); } catch (StateStorage.StateStorageException e) { throw new IOException(e.getMessage()); } - + finally { + HeavyProcessLatch.INSTANCE.processFinished(); + } } @Override From b8691cbeeb88ea7bf808f621e033492ecb635868 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Aug 2011 16:21:33 +0200 Subject: [PATCH 45/74] new notifications protocol (IDEA-73289) --- .../actions/AnalyzeDependenciesOnSpecifiedTargetHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/actions/AnalyzeDependenciesOnSpecifiedTargetHandler.java b/platform/lang-impl/src/com/intellij/packageDependencies/actions/AnalyzeDependenciesOnSpecifiedTargetHandler.java index 877cd0a8735a..623a2ebc1b69 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/actions/AnalyzeDependenciesOnSpecifiedTargetHandler.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/actions/AnalyzeDependenciesOnSpecifiedTargetHandler.java @@ -17,12 +17,12 @@ package com.intellij.packageDependencies.actions; import com.intellij.analysis.AnalysisScope; import com.intellij.analysis.AnalysisScopeBundle; +import com.intellij.notification.NotificationGroup; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.packageDependencies.DependenciesBuilder; import com.intellij.packageDependencies.ForwardDependenciesBuilder; import com.intellij.psi.PsiFile; @@ -64,7 +64,7 @@ public class AnalyzeDependenciesOnSpecifiedTargetHandler extends DependenciesHan final String source = StringUtil.decapitalize(builders.get(0).getScope().getDisplayName()); final String target = StringUtil.decapitalize(myTargetScope.getDisplayName()); final String message = AnalysisScopeBundle.message("no.dependencies.found.message", source, target); - ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.DEPENDENCIES, MessageType.INFO, message); + NotificationGroup.toolWindowGroup("Dependencies", ToolWindowId.DEPENDENCIES, true).createNotification("message", MessageType.INFO).notify(myProject); return false; } From b66c85fdeea6d96b852e81c5f3393e5c3bcf783d Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Aug 2011 17:09:20 +0200 Subject: [PATCH 46/74] diamonds: forbid diamonds completion with anonymous rollover (IDEA-72527) --- .../codeInsight/completion/JavaInheritorsGetter.java | 2 +- .../DiamondNotCollapsedInCaseOfAnonymousClasses-out.java | 9 +++++++++ .../DiamondNotCollapsedInCaseOfAnonymousClasses.java | 8 ++++++++ .../completion/SmartType17CompletionTest.java | 4 ++++ .../completion/CompletionProgressIndicator.java | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfAnonymousClasses-out.java create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfAnonymousClasses.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java index 89a928ecb034..1a55cee49c3c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java @@ -137,7 +137,7 @@ public class JavaInheritorsGetter extends CompletionProvider d = new MyDD() { + } + } +} + +abstract class MyDD { +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfAnonymousClasses.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfAnonymousClasses.java new file mode 100644 index 000000000000..546c59c4c63f --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfAnonymousClasses.java @@ -0,0 +1,8 @@ +class MyClass { + public void foo() { + MyDD d = new MyD + } +} + +abstract class MyDD { +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java index 272408cedc6e..14436d1336db 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java @@ -41,6 +41,10 @@ public class SmartType17CompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testDiamondNotCollapsedInCaseOfAnonymousClasses() throws Exception { + doTest(); + } + public void testDiamondPresentation() { configureByFile("/" + getTestName(false) + ".java"); LookupElementPresentation presentation = new LookupElementPresentation(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index 2f6de08bfa27..83f633fc46a1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -382,7 +382,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement myLookup.addItem(item.getLookupElement(), item.getPrefixMatcher()); myCount++; - if (myCount == 1) { + if (myCount == 1 && !ApplicationManager.getApplication().isUnitTestMode()) { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { try { From 50c39a05d23fe25eb32b96681260696e4d419804 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Aug 2011 18:12:27 +0200 Subject: [PATCH 47/74] diamonds: forbid diamonds completion with inapplicable inferred types (IDEA-73068) --- .../completion/JavaInheritorsGetter.java | 31 ++++++++++++++----- ...psedInCaseOfInapplicableInference-out.java | 12 +++++++ ...ollapsedInCaseOfInapplicableInference.java | 12 +++++++ .../completion/SmartType17CompletionTest.java | 4 +++ 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference-out.java create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java index 1a55cee49c3c..5cbc97c19593 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java @@ -22,16 +22,14 @@ import com.intellij.openapi.util.Condition; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.filters.getters.ExpectedTypesGetter; +import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.statistics.JavaStatisticsManager; import com.intellij.psi.statistics.StatisticsInfo; import com.intellij.psi.statistics.StatisticsManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.util.Consumer; -import com.intellij.util.ProcessingContext; -import com.intellij.util.Processor; -import com.intellij.util.SmartList; +import com.intellij.util.*; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -137,8 +135,13 @@ public class JavaInheritorsGetter extends CompletionProvider -1) { + final JavaResolveResult resolveResult = methodCallExpression.resolveMethodGenerics(); + return PsiUtil.getApplicabilityLevel((PsiMethod)resolveResult.getElement(), resolveResult.getSubstitutor(), types, PsiUtil.getLanguageLevel(originalPosition)) + != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE; + } + } + return true; + } + + public static void processInheritors(final CompletionParameters parameters, final Collection expectedClassTypes, final PrefixMatcher matcher, final Consumer consumer) { //quick diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference-out.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference-out.java new file mode 100644 index 000000000000..a658060983f6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference-out.java @@ -0,0 +1,12 @@ +import java.util.ArrayList; + +public class CompletionWithPassToMethod { + + public static void main(String[] args) { + foo(new ArrayList()); + } + + + static void foo(ArrayList ll) { + } +} diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference.java new file mode 100644 index 000000000000..4665f7a7612d --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsedInCaseOfInapplicableInference.java @@ -0,0 +1,12 @@ +import java.util.ArrayList; + +public class CompletionWithPassToMethod { + + public static void main(String[] args) { + foo(new ArrayL); + } + + + static void foo(ArrayList ll) { + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java index 14436d1336db..70c1ff827755 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java @@ -45,6 +45,10 @@ public class SmartType17CompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testDiamondNotCollapsedInCaseOfInapplicableInference() throws Exception { + doTest(); + } + public void testDiamondPresentation() { configureByFile("/" + getTestName(false) + ".java"); LookupElementPresentation presentation = new LookupElementPresentation(); From 27f6146bf9ad5da83e9d43fdc521cd63d8194d20 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 17 Aug 2011 18:38:56 +0200 Subject: [PATCH 48/74] aad JBPopup for ComboBox --- .../src/com/intellij/openapi/ui/ComboBox.java | 80 +++++++++++++++---- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java index 792523a4ae06..3216978cbc76 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java @@ -15,10 +15,11 @@ */ package com.intellij.openapi.ui; -import com.intellij.openapi.Disposable; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.SystemInfo; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.components.JBList; import com.intellij.util.ui.MacUIUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; @@ -45,6 +46,8 @@ import java.util.List; */ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener { private int myMinimumAndPreferredWidth; + private boolean mySwingPopup = true; + private JBPopup myJBPopup; public ComboBox() { this(-1); @@ -55,31 +58,65 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener } /** - * @param minimumAndPreferredWidth preferred width of the combobox. Value -1 means undefined. + * @param width preferred width of the combobox. Value -1 means undefined. */ - public ComboBox(final int minimumAndPreferredWidth) { - this(new DefaultComboBoxModel(), minimumAndPreferredWidth); + public ComboBox(final int width) { + this(new DefaultComboBoxModel(), width); UIUtil.installComboBoxCopyAction(this); } - public ComboBox(final ComboBoxModel model, final int minimumAndPreferredWidth) { + public ComboBox(final ComboBoxModel model, final int width) { super(model); - myMinimumAndPreferredWidth = minimumAndPreferredWidth; + myMinimumAndPreferredWidth = width; registerCancelOnEscape(); } @Override - public void setPopupVisible(boolean v) { - if (getModel().getSize() == 0 && v) return; - if (v && JBPopupFactory.getInstance().getChildFocusedPopup(this) != null) return; + public void setPopupVisible(boolean visible) { + if (!isSwingPopup()) { + if (visible && (myJBPopup == null || myJBPopup.isDisposed())) { + final JBList list = new JBList(getModel()); + myJBPopup = JBPopupFactory.getInstance() + .createListPopupBuilder(list) + .setItemChoosenCallback(new Runnable() { + @Override + public void run() { + final Object value = list.getSelectedValue(); + if (value != null) { + configureEditor(getEditor(), value); + } + } + }) + .setMinSize(new Dimension(getWidth(), -1)) + .setMovable(false) + .setResizable(false) + .createPopup(); + list.setBorder(IdeBorderFactory.createEmptyBorder(0)); + myJBPopup.showUnderneathOf(this); + list.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + myJBPopup.cancel(); + } + }); + } + return; + } + + if (getModel().getSize() == 0 && visible) return; + if (visible && JBPopupFactory.getInstance().getChildFocusedPopup(this) != null) return; final boolean wasShown = isPopupVisible(); - super.setPopupVisible(v); - if (!wasShown && v && isEditable() && !wasShown && !UIManager.getBoolean("ComboBox.isEnterSelectablePopup")) { + super.setPopupVisible(visible); + if (!wasShown + && visible + && isEditable() + && !UIManager.getBoolean("ComboBox.isEnterSelectablePopup")) { + final ComboBoxEditor editor = getEditor(); final Object item = editor.getItem(); final Object selectedItem = getSelectedItem(); - if (item == null || item != selectedItem) { + if (isSwingPopup() && (item == null || item != selectedItem)) { configureEditor(editor, selectedItem); } } @@ -106,13 +143,16 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); } - Toolkit.getDefaultToolkit().addAWTEventListener(this, WindowEvent.WINDOW_EVENT_MASK); + Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.WINDOW_EVENT_MASK); } @Override public void removeNotify() { super.removeNotify(); Toolkit.getDefaultToolkit().removeAWTEventListener(this); + if (myJBPopup != null && myJBPopup.isVisible()) { + myJBPopup.cancel(); + } } @@ -127,13 +167,25 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener registerCancelOnEscape(); } + + public boolean isSwingPopup() { + return mySwingPopup; + } + + public void setSwingPopup(boolean swingPopup) { + mySwingPopup = swingPopup; + } + public void setMinimumAndPreferredWidth(final int minimumAndPreferredWidth) { myMinimumAndPreferredWidth = minimumAndPreferredWidth; } + @Nullable private static DialogWrapperDialog getParentDialog(Component c) { do { - if (c == null || c instanceof DialogWrapperDialog) return (DialogWrapperDialog)c; + if (c == null || c instanceof DialogWrapperDialog) { + return (DialogWrapperDialog)c; + } c = c.getParent(); } while (true); From 545053d83b373f0b05187dc89974bafffa8f99d1 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 17 Aug 2011 18:41:05 +0200 Subject: [PATCH 49/74] use JBPopup for Expression evaluator --- .../src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java index cdb4ee4a7e21..c57205e6e981 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java @@ -81,6 +81,7 @@ public class DebuggerExpressionComboBox extends DebuggerEditorImpl { setLayout(new BorderLayout(0, 0)); myComboBox = new ComboBox(new MyComboboxModel(getRecents()), -1); + myComboBox.setSwingPopup(false); // Have to turn this off because when used in DebuggerTreeInplaceEditor, the combobox popup is hidden on every change of selection // See comment to SynthComboBoxUI.FocusHandler.focusLost() From 200c3a4f0529bb43d9109b30aea330e27fc46dd4 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 17 Aug 2011 19:04:16 +0200 Subject: [PATCH 50/74] more efficient isAncestor implementation for a set of roots --- .../compiler/impl/CompileContextImpl.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java index a7611f5e273e..a9d074801562 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -143,10 +143,8 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon if (myGeneratedSources.contains(FileBasedIndex.getFileId(file))) { return true; } - for (final VirtualFile root : myRootToModuleMap.keySet()) { - if (VfsUtil.isAncestor(root, file, false)) { - return true; - } + if (isUnderRoots(myRootToModuleMap.keySet(), file)) { + return true; } final Module module = getModuleByFile(file); if (module != null) { @@ -467,10 +465,8 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon if (myProjectFileIndex.isInTestSourceContent(fileOrDir)) { return true; } - for (final VirtualFile root : myGeneratedTestRoots) { - if (VfsUtil.isAncestor(root, fileOrDir, false)) { - return true; - } + if (isUnderRoots(myGeneratedTestRoots, fileOrDir)) { + return true; } return false; } @@ -479,11 +475,23 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon if (myProjectFileIndex.isInSourceContent(fileOrDir)) { return true; } - for (final VirtualFile root : myRootToModuleMap.keySet()) { - if (VfsUtil.isAncestor(root, fileOrDir, false)) { - return true; - } + if (isUnderRoots(myRootToModuleMap.keySet(), fileOrDir)) { + return true; } return false; } + + public static boolean isUnderRoots(@NotNull Set roots, @NotNull VirtualFile file) { + VirtualFile parent = file; + while (true) { + if (parent == null) { + return false; + } + if (roots.contains(parent)) { + return true; + } + parent = parent.getParent(); + } + } + } From a5aa9a3b9ad7dc53b270978e9de3ca2c1ca656b4 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 17 Aug 2011 19:06:36 +0200 Subject: [PATCH 51/74] use project as a disposable parent for the alarm --- .../intellij/compiler/impl/TranslatingCompilerFilesMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java index 43cc62e86f78..a59f0d010fc3 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java @@ -1142,7 +1142,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent { conn.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { private VirtualFile[] myRootsBefore; - private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, conn); + private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, project); public void beforeRootsChange(final ModuleRootEvent event) { try { From 331e04794898892177b7b94629c9b722726adfc1 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:27:16 +0400 Subject: [PATCH 52/74] decouple DocumentImpl from Editor and action system: move editor-dependent part of trailing spaces stripping to TrailingSpacesStripper --- .../codeInsight/GenerateJavadocTest.java | 4 +- .../java/AbstractJavaFormatterTest.java | 3 +- .../codeInsight/CodeInsightTestCase.java | 5 +- .../injected/editor/DocumentWindowImpl.java | 4 - .../openapi/editor/ex/DocumentEx.java | 4 - .../openapi/editor/impl/DocumentImpl.java | 104 ++++++++++-------- .../impl/TrailingSpacesStripper.java | 52 +++++++-- .../editor/StripTrailingSpacesTest.java | 4 +- .../src/com/intellij/mock/MockDocument.java | 5 - .../LightPlatformCodeInsightTestCase.java | 5 +- .../impl/CodeInsightTestFixtureImpl.java | 4 +- .../updown/GroovyMoveStatementTest.java | 4 +- 12 files changed, 113 insertions(+), 85 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java index 1668696059c3..9df55fdaa25f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java @@ -4,7 +4,7 @@ import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionManager; -import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.testFramework.PlatformTestCase; /** @@ -29,6 +29,6 @@ public class GenerateJavadocTest extends CodeInsightTestCase { EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER); actionHandler.execute(myEditor, DataManager.getInstance().getDataContext()); - ((DocumentEx)myEditor.getDocument()).stripTrailingSpaces(false); + ((DocumentImpl)myEditor.getDocument()).stripTrailingSpaces(); } } diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java index 6a3ec80568de..662b34b00e92 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java @@ -21,7 +21,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.roots.LanguageLevelProjectExtension; @@ -200,7 +199,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - ((DocumentEx)doc).stripTrailingSpaces(false); + ((DocumentImpl)doc).stripTrailingSpaces(); } }); } diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index 0238f601e11b..5f3e20cfa075 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -32,6 +32,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionManager; import com.intellij.openapi.editor.actionSystem.TypedAction; import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; @@ -480,7 +481,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { public void run() { getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); if (stripTrailingSpaces) { - ((DocumentEx)myEditor.getDocument()).stripTrailingSpaces(false); + ((DocumentImpl)myEditor.getDocument()).stripTrailingSpaces(); } PsiDocumentManager.getInstance(myProject).commitAllDocuments(); @@ -522,7 +523,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { String newFileText1 = newFileText; if (stripTrailingSpaces) { Document document1 = EditorFactory.getInstance().createDocument(newFileText); - ((DocumentEx)document1).stripTrailingSpaces(false); + ((DocumentImpl)document1).stripTrailingSpaces(); newFileText1 = document1.getText(); } diff --git a/platform/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java b/platform/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java index a5392a045d51..14230eb50657 100644 --- a/platform/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java +++ b/platform/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java @@ -490,10 +490,6 @@ public class DocumentWindowImpl extends UserDataHolderBase implements Disposable return new RangeMarkerWindow(this, (RangeMarkerEx)hostMarker); } - public boolean stripTrailingSpaces(final boolean inChangedLinesOnly) { - return myDelegate.stripTrailingSpaces(inChangedLinesOnly); - } - public void setStripTrailingSpacesEnabled(final boolean isEnabled) { myDelegate.setStripTrailingSpacesEnabled(isEnabled); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java index dcf483585a12..03b7d51b4229 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java @@ -24,10 +24,6 @@ import org.jetbrains.annotations.NotNull; import java.util.List; public interface DocumentEx extends Document { - /** - * @return true if stripping was completed successfully, false if the document prevented stripping by e.g. caret being in the way - */ - boolean stripTrailingSpaces(boolean inChangedLinesOnly); void setStripTrailingSpacesEnabled(boolean isEnabled); @NotNull LineIterator createLineIterator(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index ba565fea87c3..79e59fba86be 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -15,32 +15,33 @@ */ package com.intellij.openapi.editor.impl; -import com.intellij.ide.DataManager; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.*; +import com.intellij.openapi.editor.DocumentRunnable; +import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.ReadOnlyFragmentModificationException; +import com.intellij.openapi.editor.ReadOnlyModificationException; import com.intellij.openapi.editor.actionSystem.DocCommandGroupId; import com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHandler; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.editor.ex.*; import com.intellij.openapi.editor.impl.event.DocumentEventImpl; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.ShutDownTracker; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.util.LocalTimeCounter; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.beans.PropertyChangeListener; @@ -120,60 +121,67 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { public void setStripTrailingSpacesEnabled(boolean isEnabled) { isStripTrailingSpacesEnabled = isEnabled; } + + @TestOnly + public boolean stripTrailingSpaces() { + return stripTrailingSpaces(null, false, false, -1, -1); + } - public boolean stripTrailingSpaces(boolean inChangedLinesOnly) { + /** + * @return true if stripping was completed successfully, false if the document prevented stripping by e.g. caret being in the way + */ + public boolean stripTrailingSpaces(@Nullable final Project project, + boolean inChangedLinesOnly, + boolean virtualSpaceEnabled, + int caretLine, + int caretOffset) { if (!isStripTrailingSpacesEnabled) { return true; } - DataContext dataContext = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getFocusOwner()); - Editor activeEditor = PlatformDataKeys.EDITOR.getData(dataContext); - - // when virtual space enabled, we can strip whitespace anywhere - boolean isVirtualSpaceEnabled = activeEditor == null || activeEditor.getSettings().isVirtualSpace(); - - VisualPosition visualCaret = activeEditor == null ? null : activeEditor.getCaretModel().getVisualPosition(); - int caretLine = activeEditor == null ? -1 : activeEditor.getCaretModel().getLogicalPosition().line; - boolean markAsNeedsStrippingLater = false; CharSequence text = myText.getCharArray(); - for (int line = 0; line < myLineSet.getLineCount(); line++) { - if (inChangedLinesOnly && !myLineSet.isModified(line)) continue; - int whiteSpaceStart = -1; - final int lineEnd = myLineSet.getLineEnd(line) - myLineSet.getSeparatorLength(line); - int lineStart = myLineSet.getLineStart(line); - for (int offset = lineEnd - 1; offset >= lineStart; offset--) { - char c = text.charAt(offset); - if (c != ' ' && c != '\t') { - break; - } - whiteSpaceStart = offset; - } - if (whiteSpaceStart == -1) continue; - if (!isVirtualSpaceEnabled && caretLine == line && activeEditor != null && whiteSpaceStart < activeEditor.getCaretModel().getOffset()) { - // mark this as a document that needs stripping later - // otherwise the caret would jump madly - markAsNeedsStrippingLater = true; - } - else { - final int finalStart = whiteSpaceStart; - ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(this, activeEditor == null ? null : activeEditor.getProject()) { - public void run() { - CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { - public void run() { - deleteString(finalStart, lineEnd); - } - }); + RangeMarker caretMarker = caretOffset < 0 ? null : createRangeMarker(caretOffset, caretOffset); + try { + for (int line = 0; line < myLineSet.getLineCount(); line++) { + if (inChangedLinesOnly && !myLineSet.isModified(line)) continue; + int whiteSpaceStart = -1; + final int lineEnd = myLineSet.getLineEnd(line) - myLineSet.getSeparatorLength(line); + int lineStart = myLineSet.getLineStart(line); + for (int offset = lineEnd - 1; offset >= lineStart; offset--) { + char c = text.charAt(offset); + if (c != ' ' && c != '\t') { + break; } - }); - text = myText.getCharArray(); + whiteSpaceStart = offset; + } + if (whiteSpaceStart == -1) continue; + if (!virtualSpaceEnabled && caretLine == line && caretMarker != null && + caretMarker.getStartOffset() >= 0 && whiteSpaceStart < caretMarker.getStartOffset()) { + // mark this as a document that needs stripping later + // otherwise the caret would jump madly + markAsNeedsStrippingLater = true; + } + else { + final int finalStart = whiteSpaceStart; + ApplicationManager + .getApplication().runWriteAction(new DocumentRunnable(this, project) { + public void run() { + CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { + public void run() { + deleteString(finalStart, lineEnd); + } + }); + } + }); + text = myText.getCharArray(); + } } } - - if (!ShutDownTracker.isShutdownHookRunning() && activeEditor != null) { - activeEditor.getCaretModel().moveToVisualPosition(visualCaret); + finally { + if (caretMarker != null) caretMarker.dispose(); } - return !markAsNeedsStrippingLater; + return markAsNeedsStrippingLater; } public void setReadOnly(boolean isReadOnly) { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java index d4638958e31c..c56a02ee7b84 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/TrailingSpacesStripper.java @@ -15,28 +15,36 @@ */ package com.intellij.openapi.fileEditor.impl; +import com.intellij.ide.DataManager; +import com.intellij.injected.editor.DocumentWindow; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.DocumentRunnable; -import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.VisualPosition; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.ShutDownTracker; +import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.util.text.CharArrayUtil; import gnu.trove.THashSet; -import org.jetbrains.annotations.TestOnly; import java.util.Set; public final class TrailingSpacesStripper extends FileDocumentManagerAdapter { - private final Set myDocumentsToStripLater = new THashSet(); + private final Set myDocumentsToStripLater = new THashSet(); @Override public void beforeAllDocumentsSaving() { - Set documentsToStrip = new THashSet(myDocumentsToStripLater); + Set documentsToStrip = new THashSet(myDocumentsToStripLater); myDocumentsToStripLater.clear(); - for (DocumentEx documentEx : documentsToStrip) { - strip(documentEx); + for (Document document : documentsToStrip) { + strip(document); } } @@ -57,10 +65,9 @@ public final class TrailingSpacesStripper extends FileDocumentManagerAdapter { if (doStrip) { final boolean inChangedLinesOnly = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE); - DocumentEx ex = (DocumentEx)document; - boolean success = ex.stripTrailingSpaces(inChangedLinesOnly); + boolean success = stripIfNotCurrentLine((DocumentImpl)document, inChangedLinesOnly); if (!success) { - myDocumentsToStripLater.add(ex); + myDocumentsToStripLater.add(document); } } @@ -88,6 +95,33 @@ public final class TrailingSpacesStripper extends FileDocumentManagerAdapter { } } + public static boolean stripIfNotCurrentLine(Document document, boolean inChangedLinesOnly) { + if (document instanceof DocumentWindow) { + document = ((DocumentWindow) document).getDelegate(); + } + if (!(document instanceof DocumentImpl)) { + return true; + } + DataContext dataContext = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getFocusOwner()); + Editor activeEditor = PlatformDataKeys.EDITOR.getData(dataContext); + + // when virtual space enabled, we can strip whitespace anywhere + boolean isVirtualSpaceEnabled = activeEditor == null || activeEditor.getSettings().isVirtualSpace(); + + VisualPosition visualCaret = activeEditor == null ? null : activeEditor.getCaretModel().getVisualPosition(); + int caretLine = activeEditor == null ? -1 : activeEditor.getCaretModel().getLogicalPosition().line; + int caretOffset = activeEditor == null ? -1 : activeEditor.getCaretModel().getOffset(); + + final Project project = activeEditor == null ? null : activeEditor.getProject(); + boolean markAsNeedsStrippingLater = ((DocumentImpl) document).stripTrailingSpaces(project, inChangedLinesOnly, isVirtualSpaceEnabled, + caretLine, caretOffset); + + if (!ShutDownTracker.isShutdownHookRunning() && activeEditor != null) { + activeEditor.getCaretModel().moveToVisualPosition(visualCaret); + } + return !markAsNeedsStrippingLater; + } + @Override public void unsavedDocumentsDropped() { myDocumentsToStripLater.clear(); diff --git a/platform/platform-impl/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java b/platform/platform-impl/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java index 52c63cd251f4..aba277b13774 100644 --- a/platform/platform-impl/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java +++ b/platform/platform-impl/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java @@ -3,7 +3,7 @@ package com.intellij.openapi.editor; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; -import com.intellij.openapi.editor.impl.DocumentImpl; +import com.intellij.openapi.fileEditor.impl.TrailingSpacesStripper; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; import org.jdom.Element; @@ -90,7 +90,7 @@ public class StripTrailingSpacesTest extends LightPlatformCodeInsightTestCase { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - ((DocumentImpl)getEditor().getDocument()).stripTrailingSpaces(true); + TrailingSpacesStripper.stripIfNotCurrentLine(getEditor().getDocument(), true); } }); } diff --git a/platform/testFramework/src/com/intellij/mock/MockDocument.java b/platform/testFramework/src/com/intellij/mock/MockDocument.java index 2ccc4c9a2704..61d9405d3272 100644 --- a/platform/testFramework/src/com/intellij/mock/MockDocument.java +++ b/platform/testFramework/src/com/intellij/mock/MockDocument.java @@ -184,11 +184,6 @@ public class MockDocument implements DocumentEx { myUserData.put(key, value); } - @Override - public boolean stripTrailingSpaces(boolean inChangedLinesOnly) { - return true; - } - @Override public void setStripTrailingSpacesEnabled(boolean isEnabled) { } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 8efbc44eb958..7cc4887342bd 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -27,7 +27,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionManager; -import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.EditorImpl; @@ -267,7 +266,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); if (ignoreTrailingSpaces) { final Editor editor = myEditor; - ((DocumentEx) editor.getDocument()).stripTrailingSpaces(false); + ((DocumentImpl) editor.getDocument()).stripTrailingSpaces(); EditorUtil.fillVirtualSpaceUntilCaret(editor); } @@ -321,7 +320,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest : null; if (ignoreTrailingSpaces) { - ((DocumentEx)document).stripTrailingSpaces(false); + ((DocumentImpl)document).stripTrailingSpaces(); } if (caretMarker != null) { diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index c6d533e7d8df..3399e62fb327 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -62,9 +62,9 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.DocCommandGroupId; import com.intellij.openapi.editor.actionSystem.EditorActionManager; -import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.util.EditorUtil; +import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.editor.markup.RangeHighlighter; @@ -1634,7 +1634,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private static String stripTrailingSpaces(String actualText) { final Document document = EditorFactory.getInstance().createDocument(actualText); - ((DocumentEx)document).stripTrailingSpaces(false); + ((DocumentImpl)document).stripTrailingSpaces(); actualText = document.getText(); return actualText; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java index a5b799e1031b..8edfa884ea4c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/updown/GroovyMoveStatementTest.java @@ -18,7 +18,7 @@ package org.jetbrains.plugins.groovy.lang.actions.updown; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; -import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.util.TestUtils; @@ -119,7 +119,7 @@ public class GroovyMoveStatementTest extends LightCodeInsightFixtureTestCase { new WriteCommandAction(getProject()) { @Override protected void run(Result result) throws Throwable { - ((DocumentEx)myFixture.getEditor().getDocument()).stripTrailingSpaces(false); + ((DocumentImpl)myFixture.getEditor().getDocument()).stripTrailingSpaces(); } }.execute(); } From 947f933986c1494f69082e47711e3f52234630b4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:35:15 +0400 Subject: [PATCH 53/74] move WalkingState to util --- java/java-impl/src/com/intellij/slicer/SliceLeafAnalyzer.java | 2 +- .../src/com/intellij/slicer/SliceNullnessAnalyzer.java | 1 + platform/lang-api/src/com/intellij/psi/PsiWalkingState.java | 1 + .../impl/source/tree/RecursiveTreeElementWalkingVisitor.java | 2 +- .../src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java | 2 +- .../psi => util/src/com/intellij/util}/WalkingState.java | 3 +-- 6 files changed, 6 insertions(+), 5 deletions(-) rename platform/{lang-api/src/com/intellij/psi => util/src/com/intellij/util}/WalkingState.java (98%) diff --git a/java/java-impl/src/com/intellij/slicer/SliceLeafAnalyzer.java b/java/java-impl/src/com/intellij/slicer/SliceLeafAnalyzer.java index 733c249da67d..dc36ddf99c8a 100644 --- a/java/java-impl/src/com/intellij/slicer/SliceLeafAnalyzer.java +++ b/java/java-impl/src/com/intellij/slicer/SliceLeafAnalyzer.java @@ -29,7 +29,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiJavaReference; import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.WalkingState; +import com.intellij.util.WalkingState; import com.intellij.psi.impl.source.tree.SourceUtil; import com.intellij.util.NullableFunction; import com.intellij.util.PairProcessor; diff --git a/java/java-impl/src/com/intellij/slicer/SliceNullnessAnalyzer.java b/java/java-impl/src/com/intellij/slicer/SliceNullnessAnalyzer.java index 70cc0535c9c3..bf3d141a8d2f 100644 --- a/java/java-impl/src/com/intellij/slicer/SliceNullnessAnalyzer.java +++ b/java/java-impl/src/com/intellij/slicer/SliceNullnessAnalyzer.java @@ -30,6 +30,7 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; import com.intellij.util.NullableFunction; import com.intellij.util.PairProcessor; +import com.intellij.util.WalkingState; import com.intellij.util.containers.FactoryMap; import gnu.trove.THashMap; import gnu.trove.THashSet; diff --git a/platform/lang-api/src/com/intellij/psi/PsiWalkingState.java b/platform/lang-api/src/com/intellij/psi/PsiWalkingState.java index cafc4e254c8a..dd8a75a76450 100644 --- a/platform/lang-api/src/com/intellij/psi/PsiWalkingState.java +++ b/platform/lang-api/src/com/intellij/psi/PsiWalkingState.java @@ -17,6 +17,7 @@ package com.intellij.psi; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.util.WalkingState; import org.jetbrains.annotations.NotNull; /** diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/RecursiveTreeElementWalkingVisitor.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/RecursiveTreeElementWalkingVisitor.java index 86af329d5676..9eae91cd6e3e 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/RecursiveTreeElementWalkingVisitor.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/RecursiveTreeElementWalkingVisitor.java @@ -17,7 +17,7 @@ package com.intellij.psi.impl.source.tree; import com.intellij.lang.ASTNode; -import com.intellij.psi.WalkingState; +import com.intellij.util.WalkingState; import org.jetbrains.annotations.NotNull; public abstract class RecursiveTreeElementWalkingVisitor extends TreeElementVisitor { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java index 4791a78f9887..b5ed541862dc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java @@ -17,7 +17,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.Trinity; -import com.intellij.psi.WalkingState; +import com.intellij.util.WalkingState; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.SmartList; diff --git a/platform/lang-api/src/com/intellij/psi/WalkingState.java b/platform/util/src/com/intellij/util/WalkingState.java similarity index 98% rename from platform/lang-api/src/com/intellij/psi/WalkingState.java rename to platform/util/src/com/intellij/util/WalkingState.java index c71fed95b2f9..5904db52b624 100644 --- a/platform/lang-api/src/com/intellij/psi/WalkingState.java +++ b/platform/util/src/com/intellij/util/WalkingState.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.intellij.psi; +package com.intellij.util; -import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; /** From 1dc4ebcdc415e4122c2e3c624f0eb163daef1d77 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:36:32 +0400 Subject: [PATCH 54/74] to decouple RangeMarkerTree from MarkupModel, pull SweepProcessor to upper level --- .../daemon/impl/UpdateHighlightersUtil.java | 5 +++-- .../injected/editor/MarkupModelWindow.java | 1 + .../openapi/editor/ex/MarkupModelEx.java | 5 ----- .../openapi/editor/ex/SweepProcessor.java | 22 +++++++++++++++++++ .../openapi/editor/impl/EmptyMarkupModel.java | 1 + .../openapi/editor/impl/MarkupModelImpl.java | 1 + .../openapi/editor/impl/RangeMarkerTree.java | 6 ++--- 7 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index 815ee1d370fb..06cb28e0759e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -28,6 +28,7 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.ex.SweepProcessor; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.impl.RangeMarkerTree; import com.intellij.openapi.editor.impl.RedBlackTree; @@ -264,7 +265,7 @@ public class UpdateHighlightersUtil { public boolean generate(Processor processor) { return ContainerUtil.process(infos, processor); } - }, new MarkupModelEx.SweepProcessor() { + }, new SweepProcessor() { @Override public boolean process(int offset, HighlightInfo info, boolean atStart, Collection overlappingIntervals) { if (!atStart) return true; @@ -335,7 +336,7 @@ public class UpdateHighlightersUtil { public boolean generate(final Processor processor) { return ContainerUtil.process(highlights, processor); } - }, new MarkupModelEx.SweepProcessor() { + }, new SweepProcessor() { @Override public boolean process(int offset, HighlightInfo info, boolean atStart, Collection overlappingIntervals) { if (!atStart) { diff --git a/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java b/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java index d6c63cc21bc8..d4b6c117b813 100644 --- a/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java +++ b/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java @@ -19,6 +19,7 @@ package com.intellij.injected.editor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.ex.SweepProcessor; import com.intellij.openapi.editor.impl.event.MarkupModelListener; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java index 22737a2bdac5..5f72ea62c055 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java @@ -25,7 +25,6 @@ import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; import java.util.Iterator; /** @@ -61,9 +60,5 @@ public interface MarkupModelEx extends MarkupModel { // runs change attributes action and fires highlighterChanged event if there were changes void changeAttributesInBatch(@NotNull RangeHighlighterEx highlighter, @NotNull Consumer changeAttributesAction); - interface SweepProcessor { - boolean process(int offset, T interval, boolean atStart, Collection overlappingIntervals); - } - boolean sweep(int start, int end, @NotNull final SweepProcessor sweepProcessor); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java new file mode 100644 index 000000000000..8d89b8bab76d --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2011 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.openapi.editor.ex; + +import java.util.Collection; + +public interface SweepProcessor { + boolean process(int offset, T interval, boolean atStart, Collection overlappingIntervals); +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java index 3879ce9e7e26..6cc6b16ed787 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java @@ -3,6 +3,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.ex.SweepProcessor; import com.intellij.openapi.editor.impl.event.MarkupModelListener; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java index e5eea39715e3..dbf24389fc0f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java @@ -29,6 +29,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.ex.SweepProcessor; import com.intellij.openapi.editor.impl.event.MarkupModelListener; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java index 2c0105f496c6..66ff226fcda7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java @@ -20,9 +20,9 @@ import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.PrioritizedDocumentListener; import com.intellij.openapi.editor.ex.RangeMarkerEx; +import com.intellij.openapi.editor.ex.SweepProcessor; import com.intellij.openapi.util.Segment; import com.intellij.util.Processor; import com.intellij.util.SmartList; @@ -297,7 +297,7 @@ public class RangeMarkerTree extends IntervalTreeImpl sweepProcessor) { + public boolean sweep(final int start, final int end, @NotNull final SweepProcessor sweepProcessor) { return sweep(new Generator() { @Override public boolean generate(Processor processor) { @@ -310,7 +310,7 @@ public class RangeMarkerTree extends IntervalTreeImpl processor); } - public static boolean sweep(@NotNull Generator generator, @NotNull final MarkupModelEx.SweepProcessor sweepProcessor) { + public static boolean sweep(@NotNull Generator generator, @NotNull final SweepProcessor sweepProcessor) { final Queue ends = new PriorityQueue(5, new Comparator() { public int compare(T o1, T o2) { return o1.getEndOffset() - o2.getEndOffset(); From af1cd431e0ca32b0998505c72d3f477af3a07835 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:41:08 +0400 Subject: [PATCH 55/74] pull up ApplicationEx.isInternal() --- .../src/com/intellij/openapi/application/Application.java | 2 ++ .../src/com/intellij/openapi/application/ex/ApplicationEx.java | 2 -- .../src/com/intellij/openapi/editor/impl/RangeMarkerTree.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/application/Application.java b/platform/platform-api/src/com/intellij/openapi/application/Application.java index e8ce3a3c5b7c..dfc60e440cc8 100644 --- a/platform/platform-api/src/com/intellij/openapi/application/Application.java +++ b/platform/platform-api/src/com/intellij/openapi/application/Application.java @@ -331,4 +331,6 @@ public interface Application extends ComponentManager { * Returns lock used for write operations, should be closed in finally block */ AccessToken acquireWriteActionLock(@Nullable Class marker); + + boolean isInternal(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java index 8c2dcfe3b1ef..60bf1ec3a48c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java @@ -38,8 +38,6 @@ public interface ApplicationEx extends Application { */ void load(String optionsPath) throws IOException, InvalidDataException; - boolean isInternal(); - @NotNull String getName(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java index 66ff226fcda7..2b27387099d0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java @@ -16,7 +16,6 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.event.DocumentEvent; @@ -36,7 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class RangeMarkerTree extends IntervalTreeImpl { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.RangeMarkerTree"); - private static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication().isUnitTestMode() || ApplicationManagerEx.getApplicationEx().isInternal(); + private static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isInternal(); private final PrioritizedDocumentListener myListener; private final Document myDocument; From 09e7b7f53b64fded6684603139f4ffba8781feee Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:44:08 +0400 Subject: [PATCH 56/74] decouple VirtualFileEvent from FileDocumentManager --- .../fileEditor/FileDocumentManager.java | 3 ++- .../intellij/openapi/vfs/SavingRequestor.java | 24 +++++++++++++++++++ .../openapi/vfs/VirtualFileEvent.java | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileDocumentManager.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileDocumentManager.java index 3e9b78830fe3..c435868096e8 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileDocumentManager.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileDocumentManager.java @@ -18,11 +18,12 @@ package com.intellij.openapi.fileEditor; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.SavingRequestor; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class FileDocumentManager { +public abstract class FileDocumentManager implements SavingRequestor { public static FileDocumentManager getInstance() { return ApplicationManager.getApplication().getComponent(FileDocumentManager.class); } diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java b/platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java new file mode 100644 index 000000000000..4e2c3d0add2d --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2011 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.openapi.vfs; + +/** + * Marker interface for the requestor to label VFS events as coming from a save operation. + * + * @author yole + */ +public interface SavingRequestor { +} diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java b/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java index 32d1e002e1ed..37fd9ca05111 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java @@ -125,6 +125,6 @@ public class VirtualFileEvent extends EventObject { * @return true if the VFS change described by the event is the save of a document, false otherwise. */ public boolean isFromSave() { - return myRequestor instanceof FileDocumentManager; + return myRequestor instanceof SavingRequestor; } } From 3e40f0b9cb2ed1a965ac1a3a62f8b193f84c6b61 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 15:45:39 +0400 Subject: [PATCH 57/74] optimize imports --- .../src/com/intellij/openapi/vfs/VirtualFileEvent.java | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java b/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java index 37fd9ca05111..51923f4d1cb3 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.vfs; -import com.intellij.openapi.fileEditor.FileDocumentManager; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; From 0b99a0f9a140f0d5e049790f984200dca446a493 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 16:53:30 +0400 Subject: [PATCH 58/74] avoid exposing VFS implementation details in API --- .../vfs/newvfs/NewVirtualFileSystem.java | 78 +------------- .../openapi/vfs/ex/temp/TempFileSystem.java | 23 ++++ .../vfs/impl/jar/JarFileSystemImpl.java | 23 +++- .../vfs/impl/local/LocalFileSystemBase.java | 12 ++- .../openapi/vfs/newvfs/VfsImplUtil.java | 100 ++++++++++++++++++ .../intellij/mock/MockLocalFileSystem.java | 5 + 6 files changed, 158 insertions(+), 83 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java index 008c44da4e99..958001c71769 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java @@ -19,7 +19,6 @@ */ package com.intellij.openapi.vfs.newvfs; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileListener; import com.intellij.openapi.vfs.VirtualFileManager; @@ -28,88 +27,17 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; public abstract class NewVirtualFileSystem extends VirtualFileSystem implements FileSystemInterface { - @NonNls private static final String FILE_SEPARATORS = "/" + File.separator; private final Map myListenerWrappers = new HashMap(); public abstract boolean isCaseSensitive(); @Nullable - public VirtualFile findFileByPath(@NotNull @NonNls final String path) { - final String normalizedPath = normalize(path); - if (normalizedPath == null) return null; - final String basePath = extractRootPath(normalizedPath); - NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, this); - if (file == null || !file.exists()) return null; - - if (normalizedPath.length() < basePath.length()) { - return null; - } - for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { - if (pathElement.length() == 0 || ".".equals(pathElement)) continue; - if ("..".equals(pathElement)) { - file = file.getParent(); - } - else { - file = file.findChild(pathElement); - } - - if (file == null) return null; - } - - return file; - } - - @Nullable - public VirtualFile findFileByPathIfCached(@NotNull @NonNls final String path) { - final String normalizedPath = normalize(path); - if (normalizedPath == null) return null; - final String basePath = extractRootPath(normalizedPath); - NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, this); - if (file == null || !file.exists()) return null; - - for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { - if (pathElement.length() == 0 || ".".equals(pathElement)) continue; - if ("..".equals(pathElement)) { - file = file.getParent(); - } - else { - file = file.findChildIfCached(pathElement); - } - - if (file == null) return null; - } - - return file; - } - - @Nullable - public VirtualFile refreshAndFindFileByPath(@NotNull final String path) { - final String normalizedPath = normalize(path); - if (normalizedPath == null) return null; - final String basePath = extractRootPath(normalizedPath); - NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, this); - if (file == null || !file.exists()) return null; - - for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { - if (pathElement.length() == 0 || ".".equals(pathElement)) continue; - if ("..".equals(pathElement)) { - file = file.getParent(); - } - else { - file = file.refreshAndFindChild(pathElement); - } - - if (file == null) return null; - } - - return file; - } + public abstract VirtualFile findFileByPathIfCached(@NotNull @NonNls final String path); @Nullable protected String normalize(final String path) { @@ -120,10 +48,6 @@ public abstract class NewVirtualFileSystem extends VirtualFileSystem implements refresh(asynchronous); } - public void refresh(final boolean asynchronous) { - RefreshQueue.getInstance().refresh(asynchronous, true, null, ManagingFS.getInstance().getRoots(this)); - } - public boolean isReadOnly() { return true; } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java index c59904facf4e..829c28507faa 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java @@ -22,11 +22,15 @@ package com.intellij.openapi.vfs.ex.temp; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; +import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.VfsImplUtil; import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile; import com.intellij.openapi.vfs.newvfs.persistent.FSRecords; import com.intellij.util.ArrayUtil; import com.intellij.util.LocalTimeCounter; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -214,6 +218,25 @@ public class TempFileSystem extends NewVirtualFileSystem { }; } + public void refresh(final boolean asynchronous) { + RefreshQueue.getInstance().refresh(asynchronous, true, null, ManagingFS.getInstance().getRoots(this)); + } + + @Override + public VirtualFile findFileByPath(@NotNull @NonNls String path) { + return VfsImplUtil.findFileByPath(this, path); + } + + @Override + public VirtualFile findFileByPathIfCached(@NotNull @NonNls String path) { + return VfsImplUtil.findFileByPathIfCached(this, path); + } + + @Override + public VirtualFile refreshAndFindFileByPath(@NotNull String path) { + return VfsImplUtil.refreshAndFindFileByPath(this, path); + } + public long getLength(@NotNull final VirtualFile file) { try { return contentsToByteArray(file).length; 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 5546ee197cbd..86b7a1dfd285 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 @@ -23,9 +23,7 @@ import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.*; -import com.intellij.openapi.vfs.newvfs.BulkFileListener; -import com.intellij.openapi.vfs.newvfs.NewVirtualFile; -import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.*; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.util.containers.ConcurrentHashSet; import com.intellij.util.messages.MessageBus; @@ -315,4 +313,23 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo public int getRank() { return 2; } + + public void refresh(final boolean asynchronous) { + RefreshQueue.getInstance().refresh(asynchronous, true, null, ManagingFS.getInstance().getRoots(this)); + } + + @Override + public VirtualFile findFileByPath(@NotNull @NonNls String path) { + return VfsImplUtil.findFileByPath(this, path); + } + + @Override + public VirtualFile findFileByPathIfCached(@NotNull @NonNls String path) { + return VfsImplUtil.findFileByPathIfCached(this, path); + } + + @Override + public VirtualFile refreshAndFindFileByPath(@NotNull String path) { + return VfsImplUtil.refreshAndFindFileByPath(this, path); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java index 6c68ecc026ee..b7dd59c55ed4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java @@ -23,8 +23,10 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.ex.VirtualFileManagerEx; +import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.VfsImplUtil; import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; @@ -51,20 +53,20 @@ public abstract class LocalFileSystemBase extends LocalFileSystem { public VirtualFile findFileByPath(@NotNull String path) { String canonicalPath = getVfsCanonicalPath(path); if (canonicalPath == null) return null; - return super.findFileByPath(canonicalPath); + return VfsImplUtil.findFileByPath(this, path); } public VirtualFile findFileByPathIfCached(@NotNull String path) { String canonicalPath = getVfsCanonicalPath(path); if (canonicalPath == null) return null; - return super.findFileByPathIfCached(canonicalPath); + return VfsImplUtil.findFileByPathIfCached(this, canonicalPath); } @Nullable public VirtualFile refreshAndFindFileByPath(@NotNull String path) { String canonicalPath = getVfsCanonicalPath(path); if (canonicalPath == null) return null; - return super.refreshAndFindFileByPath(canonicalPath); + return VfsImplUtil.refreshAndFindFileByPath(this, canonicalPath); } public VirtualFile findFileByIoFile(File file) { @@ -603,4 +605,8 @@ public abstract class LocalFileSystemBase extends LocalFileSystem { return originalFileName; } } + + public void refresh(final boolean asynchronous) { + RefreshQueue.getInstance().refresh(asynchronous, true, null, ManagingFS.getInstance().getRoots(this)); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java new file mode 100644 index 000000000000..95faccc432d0 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2011 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.openapi.vfs.newvfs; + +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; + +public class VfsImplUtil { + @NonNls private static final String FILE_SEPARATORS = "/" + File.separator; + + @Nullable + public static VirtualFile findFileByPath(NewVirtualFileSystem vfs, @NotNull @NonNls final String path) { + final String normalizedPath = vfs.normalize(path); + if (normalizedPath == null) return null; + final String basePath = vfs.extractRootPath(normalizedPath); + NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, vfs); + if (file == null || !file.exists()) return null; + + if (normalizedPath.length() < basePath.length()) { + return null; + } + for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { + if (pathElement.length() == 0 || ".".equals(pathElement)) continue; + if ("..".equals(pathElement)) { + file = file.getParent(); + } + else { + file = file.findChild(pathElement); + } + + if (file == null) return null; + } + + return file; + } + + @Nullable + public static VirtualFile findFileByPathIfCached(NewVirtualFileSystem vfs, @NotNull @NonNls String path) { + final String normalizedPath = vfs.normalize(path); + if (normalizedPath == null) return null; + final String basePath = vfs.extractRootPath(normalizedPath); + NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, vfs); + if (file == null || !file.exists()) return null; + + for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { + if (pathElement.length() == 0 || ".".equals(pathElement)) continue; + if ("..".equals(pathElement)) { + file = file.getParent(); + } + else { + file = file.findChildIfCached(pathElement); + } + + if (file == null) return null; + } + + return file; + } + + @Nullable + public static VirtualFile refreshAndFindFileByPath(NewVirtualFileSystem vfs, @NotNull final String path) { + final String normalizedPath = vfs.normalize(path); + if (normalizedPath == null) return null; + final String basePath = vfs.extractRootPath(normalizedPath); + NewVirtualFile file = ManagingFS.getInstance().findRoot(basePath, vfs); + if (file == null || !file.exists()) return null; + + for (String pathElement : StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS)) { + if (pathElement.length() == 0 || ".".equals(pathElement)) continue; + if ("..".equals(pathElement)) { + file = file.getParent(); + } + else { + file = file.refreshAndFindChild(pathElement); + } + + if (file == null) return null; + } + + return file; + } +} diff --git a/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java b/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java index ea24cea1c648..e6b062b2937c 100644 --- a/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java +++ b/platform/testFramework/src/com/intellij/mock/MockLocalFileSystem.java @@ -185,6 +185,11 @@ public class MockLocalFileSystem extends LocalFileSystem { return false; } + @Override + public VirtualFile findFileByPathIfCached(@NotNull @NonNls String path) { + return findFileByPath(path); + } + @Override public boolean exists(@NotNull final VirtualFile fileOrDirectory) { return false; From 7c56a9e60238b8b0189e47331016111a50949cd4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 16:57:01 +0400 Subject: [PATCH 59/74] meaningless i18n --- .../src/com/intellij/openapi/fileTypes/UnknownFileType.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java index 107e29a0ebd4..8ded6faed7b1 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.fileTypes; -import com.intellij.ide.IdeBundle; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -35,7 +34,7 @@ public class UnknownFileType implements FileType { @NotNull public String getDescription() { - return IdeBundle.message("filetype.description.unknown"); + return "UNKNOWN"; } @NotNull From aec9476bf8041b69ab4d0e0197f3589f08e6161c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 20:36:07 +0400 Subject: [PATCH 60/74] initially extracted core-api and core-impl modules --- platform/core-api/core-api.iml | 16 ++ .../src/com/intellij/lang/Language.java | 0 .../openapi/application/AccessToken.java | 0 .../openapi/application/Application.java | 0 .../application/ApplicationListener.java | 0 .../application/ApplicationManager.java | 0 .../application/BaseActionRunnable.java | 0 .../application/CachedSingletonsRegistry.java | 0 .../application/ModalityInvokator.java | 0 .../openapi/application/ModalityState.java | 0 .../intellij/openapi/application/Result.java | 0 .../openapi/application/RunResult.java | 0 .../openapi/application/WriteAction.java | 0 .../openapi/command/CommandEvent.java | 0 .../openapi/command/CommandListener.java | 0 .../openapi/command/CommandProcessor.java | 0 .../command/UndoConfirmationPolicy.java | 0 .../openapi/components/BaseComponent.java | 0 .../openapi/components/ComponentManager.java | 0 .../openapi/components/NamedComponent.java | 0 .../openapi/components/ServiceManager.java | 0 .../com/intellij/openapi/editor/Document.java | 0 .../openapi/editor/DocumentRunnable.java | 0 .../intellij/openapi/editor/EditorBundle.java | 0 .../intellij/openapi/editor/RangeMarker.java | 0 ...ReadOnlyFragmentModificationException.java | 0 .../editor/ReadOnlyModificationException.java | 0 .../intellij/openapi/editor/TextChange.java | 0 .../actionSystem/DocCommandGroupId.java | 0 .../ReadonlyFragmentModificationHandler.java | 0 .../openapi/editor/event/DocumentEvent.java | 0 .../editor/event/DocumentListener.java | 0 .../fileTypes/ExactFileNameMatcher.java | 0 .../fileTypes/ExtensionFileNameMatcher.java | 0 .../openapi/fileTypes/FileNameMatcher.java | 0 .../intellij/openapi/fileTypes/FileType.java | 0 .../openapi/fileTypes/FileTypeEvent.java | 0 .../openapi/fileTypes/FileTypeListener.java | 0 .../openapi/fileTypes/FileTypeManager.java | 0 .../intellij/openapi/fileTypes/FileTypes.java | 0 .../openapi/fileTypes/LanguageFileType.java | 0 .../fileTypes/MockFileTypeManager.java | 0 .../fileTypes/MockLanguageFileType.java | 0 .../openapi/fileTypes/UnknownFileType.java | 0 .../fileTypes/WildcardFileNameMatcher.java | 0 .../com/intellij/openapi/options/Scheme.java | 0 .../com/intellij/openapi/project/Project.java | 0 .../intellij/openapi/util/ActionCallback.java | 0 .../openapi/util/ExecutionCallback.java | 0 .../openapi/util/ModificationTracker.java | 0 .../intellij/openapi/util/SimpleTimer.java | 0 .../openapi/util/SimpleTimerTask.java | 0 .../intellij/openapi/vfs/CharsetToolkit.java | 0 .../intellij/openapi/vfs/JarFileSystem.java | 0 .../vfs/LocalFileOperationsHandler.java | 0 .../intellij/openapi/vfs/LocalFileSystem.java | 0 .../openapi/vfs/ModificationAttemptEvent.java | 0 .../vfs/ModificationAttemptListener.java | 0 .../intellij/openapi/vfs/SavingRequestor.java | 0 .../com/intellij/openapi/vfs/VfsBundle.java | 0 .../src/com/intellij/openapi/vfs/VfsUtil.java | 0 .../com/intellij/openapi/vfs/VirtualFile.java | 2 - .../openapi/vfs/VirtualFileCopyEvent.java | 0 .../openapi/vfs/VirtualFileEvent.java | 0 .../openapi/vfs/VirtualFileFilter.java | 0 .../openapi/vfs/VirtualFileListener.java | 0 .../openapi/vfs/VirtualFileManager.java | 0 .../vfs/VirtualFileManagerListener.java | 0 .../openapi/vfs/VirtualFileMoveEvent.java | 0 .../openapi/vfs/VirtualFilePropertyEvent.java | 0 .../openapi/vfs/VirtualFileSystem.java | 0 .../openapi/vfs/encoding/EncodingManager.java | 0 .../openapi/vfs/newvfs/BulkFileListener.java | 0 .../vfs/newvfs/FileSystemInterface.java | 0 .../vfs/newvfs/NewVirtualFileSystem.java | 0 .../newvfs/VirtualFileFilteringListener.java | 0 .../openapi/vfs/newvfs/events/VFileEvent.java | 0 .../events/VFilePropertyChangeEvent.java | 0 .../src/com/intellij/ui/InvokeUtil.java | 0 .../src/com/intellij/util/PathUtil.java | 0 platform/core-impl/core-impl.iml | 13 ++ .../editor/ex/DocumentBulkUpdateListener.java | 0 .../openapi/editor/ex/DocumentEx.java | 0 .../editor/ex/EditReadOnlyListener.java | 0 .../openapi/editor/ex/LineIterator.java | 0 .../ex/PrioritizedDocumentListener.java | 0 .../openapi/editor/ex/RangeMarkerEx.java | 0 .../openapi/editor/ex/SweepProcessor.java | 0 .../openapi/editor/ex/util/SegmentArray.java | 0 .../editor/ex/util/SegmentArrayWithData.java | 0 .../editor/impl/BulkChangesMerger.java | 0 .../openapi/editor/impl/CharArray.java | 0 .../openapi/editor/impl/DocumentImpl.java | 7 +- .../editor/impl/EditorDocumentPriorities.java | 0 .../intellij/openapi/editor/impl/Getable.java | 0 .../openapi/editor/impl/Interval.java | 0 .../openapi/editor/impl/IntervalTree.java | 0 .../openapi/editor/impl/IntervalTreeImpl.java | 198 +++++++++--------- .../openapi/editor/impl/LineIteratorImpl.java | 0 .../intellij/openapi/editor/impl/LineSet.java | 0 .../openapi/editor/impl/MutableInterval.java | 0 .../editor/impl/PersistentRangeMarker.java | 0 .../impl/PersistentRangeMarkerUtil.java | 0 .../openapi/editor/impl/RangeMarkerImpl.java | 0 .../openapi/editor/impl/RangeMarkerTree.java | 6 +- .../openapi/editor/impl/RedBlackTree.java | 0 .../editor/impl/StripedIDGenerator.java | 0 .../openapi/editor/impl/TextChangeImpl.java | 0 .../editor/impl/TextChangesStorage.java | 0 .../editor/impl/TextRangeInterval.java | 0 .../editor/impl/event/DocumentEventImpl.java | 0 platform/platform-api/platform-api.iml | 1 + platform/platform-impl/platform-impl.iml | 1 + 113 files changed, 136 insertions(+), 108 deletions(-) create mode 100644 platform/core-api/core-api.iml rename platform/{platform-api => core-api}/src/com/intellij/lang/Language.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/AccessToken.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/Application.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/ApplicationListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/ApplicationManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/BaseActionRunnable.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/CachedSingletonsRegistry.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/ModalityInvokator.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/ModalityState.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/Result.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/RunResult.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/application/WriteAction.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/command/CommandEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/command/CommandListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/command/CommandProcessor.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/command/UndoConfirmationPolicy.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/BaseComponent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/ComponentManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/NamedComponent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/ServiceManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/Document.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/DocumentRunnable.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/EditorBundle.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/RangeMarker.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/ReadOnlyFragmentModificationException.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/ReadOnlyModificationException.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/TextChange.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/actionSystem/DocCommandGroupId.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/actionSystem/ReadonlyFragmentModificationHandler.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/event/DocumentEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/editor/event/DocumentListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/ExactFileNameMatcher.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileNameMatcher.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileType.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileTypeEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileTypeListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileTypeManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/FileTypes.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/LanguageFileType.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/MockLanguageFileType.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/UnknownFileType.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/fileTypes/WildcardFileNameMatcher.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/options/Scheme.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/project/Project.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/ActionCallback.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/ExecutionCallback.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/ModificationTracker.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/SimpleTimer.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/SimpleTimerTask.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/CharsetToolkit.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/JarFileSystem.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/LocalFileOperationsHandler.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/LocalFileSystem.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/ModificationAttemptEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/ModificationAttemptListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/SavingRequestor.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VfsBundle.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VfsUtil.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFile.java (99%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileCopyEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileFilter.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileManagerListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileMoveEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFilePropertyEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/VirtualFileSystem.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/encoding/EncodingManager.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/FileSystemInterface.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/VirtualFileFilteringListener.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFileEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/vfs/newvfs/events/VFilePropertyChangeEvent.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/ui/InvokeUtil.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/util/PathUtil.java (100%) create mode 100644 platform/core-impl/core-impl.iml rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/DocumentBulkUpdateListener.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/DocumentEx.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/EditReadOnlyListener.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/LineIterator.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/PrioritizedDocumentListener.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/RangeMarkerEx.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/SweepProcessor.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/util/SegmentArray.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/ex/util/SegmentArrayWithData.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/BulkChangesMerger.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/CharArray.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/DocumentImpl.java (98%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/EditorDocumentPriorities.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/Getable.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/Interval.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/IntervalTree.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java (84%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/LineIteratorImpl.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/LineSet.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/MutableInterval.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/PersistentRangeMarker.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/PersistentRangeMarkerUtil.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java (98%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/RedBlackTree.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/StripedIDGenerator.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/TextChangeImpl.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/TextChangesStorage.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/TextRangeInterval.java (100%) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java (100%) diff --git a/platform/core-api/core-api.iml b/platform/core-api/core-api.iml new file mode 100644 index 000000000000..86d00e0493ab --- /dev/null +++ b/platform/core-api/core-api.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/platform/platform-api/src/com/intellij/lang/Language.java b/platform/core-api/src/com/intellij/lang/Language.java similarity index 100% rename from platform/platform-api/src/com/intellij/lang/Language.java rename to platform/core-api/src/com/intellij/lang/Language.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/AccessToken.java b/platform/core-api/src/com/intellij/openapi/application/AccessToken.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/AccessToken.java rename to platform/core-api/src/com/intellij/openapi/application/AccessToken.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/Application.java b/platform/core-api/src/com/intellij/openapi/application/Application.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/Application.java rename to platform/core-api/src/com/intellij/openapi/application/Application.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationListener.java b/platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/ApplicationListener.java rename to platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationManager.java b/platform/core-api/src/com/intellij/openapi/application/ApplicationManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/ApplicationManager.java rename to platform/core-api/src/com/intellij/openapi/application/ApplicationManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/BaseActionRunnable.java b/platform/core-api/src/com/intellij/openapi/application/BaseActionRunnable.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/BaseActionRunnable.java rename to platform/core-api/src/com/intellij/openapi/application/BaseActionRunnable.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/CachedSingletonsRegistry.java b/platform/core-api/src/com/intellij/openapi/application/CachedSingletonsRegistry.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/CachedSingletonsRegistry.java rename to platform/core-api/src/com/intellij/openapi/application/CachedSingletonsRegistry.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/ModalityInvokator.java b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/ModalityInvokator.java rename to platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/ModalityState.java b/platform/core-api/src/com/intellij/openapi/application/ModalityState.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/ModalityState.java rename to platform/core-api/src/com/intellij/openapi/application/ModalityState.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/Result.java b/platform/core-api/src/com/intellij/openapi/application/Result.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/Result.java rename to platform/core-api/src/com/intellij/openapi/application/Result.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/RunResult.java b/platform/core-api/src/com/intellij/openapi/application/RunResult.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/RunResult.java rename to platform/core-api/src/com/intellij/openapi/application/RunResult.java diff --git a/platform/platform-api/src/com/intellij/openapi/application/WriteAction.java b/platform/core-api/src/com/intellij/openapi/application/WriteAction.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/application/WriteAction.java rename to platform/core-api/src/com/intellij/openapi/application/WriteAction.java diff --git a/platform/platform-api/src/com/intellij/openapi/command/CommandEvent.java b/platform/core-api/src/com/intellij/openapi/command/CommandEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/command/CommandEvent.java rename to platform/core-api/src/com/intellij/openapi/command/CommandEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/command/CommandListener.java b/platform/core-api/src/com/intellij/openapi/command/CommandListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/command/CommandListener.java rename to platform/core-api/src/com/intellij/openapi/command/CommandListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/command/CommandProcessor.java b/platform/core-api/src/com/intellij/openapi/command/CommandProcessor.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/command/CommandProcessor.java rename to platform/core-api/src/com/intellij/openapi/command/CommandProcessor.java diff --git a/platform/platform-api/src/com/intellij/openapi/command/UndoConfirmationPolicy.java b/platform/core-api/src/com/intellij/openapi/command/UndoConfirmationPolicy.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/command/UndoConfirmationPolicy.java rename to platform/core-api/src/com/intellij/openapi/command/UndoConfirmationPolicy.java diff --git a/platform/platform-api/src/com/intellij/openapi/components/BaseComponent.java b/platform/core-api/src/com/intellij/openapi/components/BaseComponent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/components/BaseComponent.java rename to platform/core-api/src/com/intellij/openapi/components/BaseComponent.java diff --git a/platform/platform-api/src/com/intellij/openapi/components/ComponentManager.java b/platform/core-api/src/com/intellij/openapi/components/ComponentManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/components/ComponentManager.java rename to platform/core-api/src/com/intellij/openapi/components/ComponentManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/components/NamedComponent.java b/platform/core-api/src/com/intellij/openapi/components/NamedComponent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/components/NamedComponent.java rename to platform/core-api/src/com/intellij/openapi/components/NamedComponent.java diff --git a/platform/platform-api/src/com/intellij/openapi/components/ServiceManager.java b/platform/core-api/src/com/intellij/openapi/components/ServiceManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/components/ServiceManager.java rename to platform/core-api/src/com/intellij/openapi/components/ServiceManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/Document.java b/platform/core-api/src/com/intellij/openapi/editor/Document.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/Document.java rename to platform/core-api/src/com/intellij/openapi/editor/Document.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/DocumentRunnable.java b/platform/core-api/src/com/intellij/openapi/editor/DocumentRunnable.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/DocumentRunnable.java rename to platform/core-api/src/com/intellij/openapi/editor/DocumentRunnable.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorBundle.java b/platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/EditorBundle.java rename to platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/RangeMarker.java b/platform/core-api/src/com/intellij/openapi/editor/RangeMarker.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/RangeMarker.java rename to platform/core-api/src/com/intellij/openapi/editor/RangeMarker.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/ReadOnlyFragmentModificationException.java b/platform/core-api/src/com/intellij/openapi/editor/ReadOnlyFragmentModificationException.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/ReadOnlyFragmentModificationException.java rename to platform/core-api/src/com/intellij/openapi/editor/ReadOnlyFragmentModificationException.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/ReadOnlyModificationException.java b/platform/core-api/src/com/intellij/openapi/editor/ReadOnlyModificationException.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/ReadOnlyModificationException.java rename to platform/core-api/src/com/intellij/openapi/editor/ReadOnlyModificationException.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/TextChange.java b/platform/core-api/src/com/intellij/openapi/editor/TextChange.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/TextChange.java rename to platform/core-api/src/com/intellij/openapi/editor/TextChange.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/DocCommandGroupId.java b/platform/core-api/src/com/intellij/openapi/editor/actionSystem/DocCommandGroupId.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/actionSystem/DocCommandGroupId.java rename to platform/core-api/src/com/intellij/openapi/editor/actionSystem/DocCommandGroupId.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/ReadonlyFragmentModificationHandler.java b/platform/core-api/src/com/intellij/openapi/editor/actionSystem/ReadonlyFragmentModificationHandler.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/actionSystem/ReadonlyFragmentModificationHandler.java rename to platform/core-api/src/com/intellij/openapi/editor/actionSystem/ReadonlyFragmentModificationHandler.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/DocumentEvent.java b/platform/core-api/src/com/intellij/openapi/editor/event/DocumentEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/event/DocumentEvent.java rename to platform/core-api/src/com/intellij/openapi/editor/event/DocumentEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/DocumentListener.java b/platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/event/DocumentListener.java rename to platform/core-api/src/com/intellij/openapi/editor/event/DocumentListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/ExactFileNameMatcher.java b/platform/core-api/src/com/intellij/openapi/fileTypes/ExactFileNameMatcher.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/ExactFileNameMatcher.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/ExactFileNameMatcher.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java b/platform/core-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/ExtensionFileNameMatcher.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileNameMatcher.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileNameMatcher.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileNameMatcher.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileNameMatcher.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileType.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileType.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileType.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileType.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeEvent.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeEvent.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeListener.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeListener.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypes.java b/platform/core-api/src/com/intellij/openapi/fileTypes/FileTypes.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypes.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/FileTypes.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java b/platform/core-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/LanguageFileType.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java b/platform/core-api/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/MockFileTypeManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/MockLanguageFileType.java b/platform/core-api/src/com/intellij/openapi/fileTypes/MockLanguageFileType.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/MockLanguageFileType.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/MockLanguageFileType.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java b/platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/WildcardFileNameMatcher.java b/platform/core-api/src/com/intellij/openapi/fileTypes/WildcardFileNameMatcher.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/fileTypes/WildcardFileNameMatcher.java rename to platform/core-api/src/com/intellij/openapi/fileTypes/WildcardFileNameMatcher.java diff --git a/platform/platform-api/src/com/intellij/openapi/options/Scheme.java b/platform/core-api/src/com/intellij/openapi/options/Scheme.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/options/Scheme.java rename to platform/core-api/src/com/intellij/openapi/options/Scheme.java diff --git a/platform/platform-api/src/com/intellij/openapi/project/Project.java b/platform/core-api/src/com/intellij/openapi/project/Project.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/project/Project.java rename to platform/core-api/src/com/intellij/openapi/project/Project.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/ActionCallback.java b/platform/core-api/src/com/intellij/openapi/util/ActionCallback.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/ActionCallback.java rename to platform/core-api/src/com/intellij/openapi/util/ActionCallback.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/ExecutionCallback.java b/platform/core-api/src/com/intellij/openapi/util/ExecutionCallback.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/ExecutionCallback.java rename to platform/core-api/src/com/intellij/openapi/util/ExecutionCallback.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/ModificationTracker.java b/platform/core-api/src/com/intellij/openapi/util/ModificationTracker.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/ModificationTracker.java rename to platform/core-api/src/com/intellij/openapi/util/ModificationTracker.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java b/platform/core-api/src/com/intellij/openapi/util/SimpleTimer.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java rename to platform/core-api/src/com/intellij/openapi/util/SimpleTimer.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/SimpleTimerTask.java b/platform/core-api/src/com/intellij/openapi/util/SimpleTimerTask.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/SimpleTimerTask.java rename to platform/core-api/src/com/intellij/openapi/util/SimpleTimerTask.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/CharsetToolkit.java b/platform/core-api/src/com/intellij/openapi/vfs/CharsetToolkit.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/CharsetToolkit.java rename to platform/core-api/src/com/intellij/openapi/vfs/CharsetToolkit.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/JarFileSystem.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java rename to platform/core-api/src/com/intellij/openapi/vfs/JarFileSystem.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileOperationsHandler.java b/platform/core-api/src/com/intellij/openapi/vfs/LocalFileOperationsHandler.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/LocalFileOperationsHandler.java rename to platform/core-api/src/com/intellij/openapi/vfs/LocalFileOperationsHandler.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/LocalFileSystem.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java rename to platform/core-api/src/com/intellij/openapi/vfs/LocalFileSystem.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/ModificationAttemptEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/ModificationAttemptEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/ModificationAttemptEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/ModificationAttemptEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/ModificationAttemptListener.java b/platform/core-api/src/com/intellij/openapi/vfs/ModificationAttemptListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/ModificationAttemptListener.java rename to platform/core-api/src/com/intellij/openapi/vfs/ModificationAttemptListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java b/platform/core-api/src/com/intellij/openapi/vfs/SavingRequestor.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/SavingRequestor.java rename to platform/core-api/src/com/intellij/openapi/vfs/SavingRequestor.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsBundle.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsBundle.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VfsBundle.java rename to platform/core-api/src/com/intellij/openapi/vfs/VfsBundle.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtil.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java rename to platform/core-api/src/com/intellij/openapi/vfs/VfsUtil.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFile.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java index daa91d1cfa60..467765ee78a5 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFile.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java @@ -23,8 +23,6 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.encoding.EncodingManager; -import com.intellij.openapi.vfs.newvfs.BulkFileListener; -import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileCopyEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileCopyEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileCopyEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileCopyEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileFilter.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileFilter.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileFilter.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileFilter.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileListener.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileListener.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileManager.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileManager.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileManagerListener.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManagerListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileManagerListener.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManagerListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileMoveEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileMoveEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileMoveEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileMoveEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFilePropertyEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFilePropertyEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFilePropertyEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFilePropertyEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java rename to platform/core-api/src/com/intellij/openapi/vfs/VirtualFileSystem.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/encoding/EncodingManager.java b/platform/core-api/src/com/intellij/openapi/vfs/encoding/EncodingManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/encoding/EncodingManager.java rename to platform/core-api/src/com/intellij/openapi/vfs/encoding/EncodingManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/BulkFileListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileSystemInterface.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemInterface.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/FileSystemInterface.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/FileSystemInterface.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/NewVirtualFileSystem.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/VirtualFileFilteringListener.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/VirtualFileFilteringListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/VirtualFileFilteringListener.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/VirtualFileFilteringListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFileEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileEvent.java diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFilePropertyChangeEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFilePropertyChangeEvent.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vfs/newvfs/events/VFilePropertyChangeEvent.java rename to platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFilePropertyChangeEvent.java diff --git a/platform/platform-api/src/com/intellij/ui/InvokeUtil.java b/platform/core-api/src/com/intellij/ui/InvokeUtil.java similarity index 100% rename from platform/platform-api/src/com/intellij/ui/InvokeUtil.java rename to platform/core-api/src/com/intellij/ui/InvokeUtil.java diff --git a/platform/platform-api/src/com/intellij/util/PathUtil.java b/platform/core-api/src/com/intellij/util/PathUtil.java similarity index 100% rename from platform/platform-api/src/com/intellij/util/PathUtil.java rename to platform/core-api/src/com/intellij/util/PathUtil.java diff --git a/platform/core-impl/core-impl.iml b/platform/core-impl/core-impl.iml new file mode 100644 index 000000000000..caff682b4a06 --- /dev/null +++ b/platform/core-impl/core-impl.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentBulkUpdateListener.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/DocumentBulkUpdateListener.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentBulkUpdateListener.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/DocumentBulkUpdateListener.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/DocumentEx.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditReadOnlyListener.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/EditReadOnlyListener.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/EditReadOnlyListener.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/EditReadOnlyListener.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/LineIterator.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/LineIterator.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/LineIterator.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/LineIterator.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/PrioritizedDocumentListener.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/PrioritizedDocumentListener.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/PrioritizedDocumentListener.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/PrioritizedDocumentListener.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/RangeMarkerEx.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/RangeMarkerEx.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/RangeMarkerEx.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/RangeMarkerEx.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/SweepProcessor.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArray.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArrayWithData.java b/platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArrayWithData.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/util/SegmentArrayWithData.java rename to platform/core-impl/src/com/intellij/openapi/editor/ex/util/SegmentArrayWithData.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/BulkChangesMerger.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/BulkChangesMerger.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/BulkChangesMerger.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/BulkChangesMerger.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CharArray.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/CharArray.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java similarity index 98% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 79e59fba86be..459a6a352aa9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -20,10 +20,7 @@ import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.DocumentRunnable; -import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.editor.ReadOnlyFragmentModificationException; -import com.intellij.openapi.editor.ReadOnlyModificationException; +import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.DocCommandGroupId; import com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHandler; import com.intellij.openapi.editor.event.DocumentEvent; @@ -187,7 +184,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { public void setReadOnly(boolean isReadOnly) { if (myIsReadOnly != isReadOnly) { myIsReadOnly = isReadOnly; - myPropertyChangeSupport.firePropertyChange(PROP_WRITABLE, !isReadOnly, isReadOnly); + myPropertyChangeSupport.firePropertyChange(Document.PROP_WRITABLE, !isReadOnly, isReadOnly); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorDocumentPriorities.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/EditorDocumentPriorities.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorDocumentPriorities.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/EditorDocumentPriorities.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/Getable.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/Getable.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/Getable.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/Getable.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/Interval.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/Interval.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/Interval.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/Interval.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTree.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTree.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTree.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTree.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java similarity index 84% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java index b5ed541862dc..38171414b5e7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java @@ -41,51 +41,53 @@ public abstract class IntervalTreeImpl extends RedBla private int keySize; // number of all intervals, counting all duplicates, some of them maybe gced protected final ReadWriteLock l = new ReentrantReadWriteLock(); - protected abstract int compareEqualStartIntervals(@NotNull IntervalNode i1, @NotNull IntervalNode i2); + protected abstract int compareEqualStartIntervals(@NotNull IntervalNode i1, @NotNull IntervalNode i2); private final ReferenceQueue myReferenceQueue = new ReferenceQueue(); private int deadReferenceCount; - protected class IntervalNode extends RedBlackTree.Node implements MutableInterval { + protected static class IntervalNode extends RedBlackTree.Node implements MutableInterval { private volatile int myStart; private volatile int myEnd; private volatile boolean isValid = true; - protected final List> intervals; + protected final List> intervals; protected int maxEnd; // max of all intervalEnd()s among all children. protected int delta; // delta of startOffset. getStartOffset() = myStartOffset + Sum of deltas up to root private volatile int modCount; // if it equals to the com.intellij.openapi.editor.impl.RedBlackTree.modCount then deltaUpToRoot can be used, otherwise it is expired private volatile int deltaUpToRoot; // sum of all deltas up to the root (including this node' delta). Has valid value only if modCount == IntervalTreeImpl.this.modCount private volatile boolean allDeltasUpAreNull; // true if all deltas up the tree (including this node) are 0. Has valid value only if modCount == IntervalTreeImpl.this.modCount + private IntervalTreeImpl myIntervalTree; - public IntervalNode(@NotNull T key, int start, int end) { + public IntervalNode(IntervalTreeImpl intervalTree, @NotNull E key, int start, int end) { // maxEnd == 0 so to not disrupt existing maxes - intervals = new SmartList>(createGetable(key)); + intervals = new SmartList>(createGetable(key)); myStart = start; myEnd = end; + this.myIntervalTree = intervalTree; } @Override - public IntervalNode getLeft() { - return (IntervalNode)left; + public IntervalNode getLeft() { + return (IntervalNode)left; } @Override - public IntervalNode getRight() { - return (IntervalNode)right; + public IntervalNode getRight() { + return (IntervalNode)right; } @Override - public IntervalNode getParent() { - return (IntervalNode)parent; + public IntervalNode getParent() { + return (IntervalNode)parent; } @Override - public boolean processAliveKeys(@NotNull Processor processor) { + public boolean processAliveKeys(@NotNull Processor processor) { //noinspection ForLoopReplaceableByForEach for (int i = 0; i < intervals.size(); i++) { - Getable interval = intervals.get(i); - T key = interval.get(); + Getable interval = intervals.get(i); + E key = interval.get(); if (key != null && !processor.process(key)) return false; } return true; @@ -94,7 +96,7 @@ public abstract class IntervalTreeImpl extends RedBla public boolean hasAliveKey(boolean purgeDead) { boolean hasAliveInterval = false; for (int i = intervals.size() - 1; i >= 0; i--) { - Getable interval = intervals.get(i); + Getable interval = intervals.get(i); if (interval.get() != null) { hasAliveInterval = true; if (purgeDead) { @@ -105,7 +107,7 @@ public abstract class IntervalTreeImpl extends RedBla } } if (purgeDead) { - assertUnderWriteLock(); + myIntervalTree.assertUnderWriteLock(); removeIntervalInternal(i); } } @@ -114,16 +116,16 @@ public abstract class IntervalTreeImpl extends RedBla // removes interval and the node, if node became empty // returns true if node was removed - public boolean removeInterval(@NotNull T key) { - checkBelongsToTheTree(key, true); - assertUnderWriteLock(); + public boolean removeInterval(@NotNull E key) { + myIntervalTree.checkBelongsToTheTree(key, true); + myIntervalTree.assertUnderWriteLock(); for (int i = intervals.size() - 1; i >= 0; i--) { - Getable interval = intervals.get(i); - T t = interval.get(); + Getable interval = intervals.get(i); + E t = interval.get(); if (t == key) { removeIntervalInternal(i); if (intervals.isEmpty()) { - removeNode(this); + myIntervalTree.removeNode(this); return true; } return false; @@ -135,31 +137,31 @@ public abstract class IntervalTreeImpl extends RedBla public void removeIntervalInternal(int i) { intervals.remove(i); - assert keySize > 0 : keySize; - keySize--; + assert myIntervalTree.keySize > 0 : myIntervalTree.keySize; + myIntervalTree.keySize--; } - public void addInterval(@NotNull T interval) { - assertUnderWriteLock(); + public void addInterval(@NotNull E interval) { + myIntervalTree.assertUnderWriteLock(); intervals.add(createGetable(interval)); - keySize++; - setNode(interval, this); + myIntervalTree.keySize++; + myIntervalTree.setNode(interval, this); } - protected Getable createGetable(@NotNull T interval) { - return new WeakReferencedGetable(interval, myReferenceQueue); + protected Getable createGetable(@NotNull E interval) { + return new WeakReferencedGetable(interval, myIntervalTree.myReferenceQueue); } protected int computeDeltaUpToRoot() { if (!isValid()) return 0; - int treeModCount = IntervalTreeImpl.this.modCount; + int treeModCount = myIntervalTree.modCount; if (modCount == treeModCount) { return deltaUpToRoot; } IntervalNode node = this; int height = 0; long path = 0; // path to this node from the root; 0 bit means we turn left subtree, 1 bit means we turn right subtree - IntervalNode treeRoot = getRoot(); + IntervalNode treeRoot = myIntervalTree.getRoot(); int deltaUp = 0; boolean allDeltasAreNull = true; while (node != treeRoot) { @@ -244,8 +246,8 @@ public abstract class IntervalTreeImpl extends RedBla return myEnd; } - public IntervalTreeImpl getTree() { - return IntervalTreeImpl.this; + public IntervalTreeImpl getTree() { + return myIntervalTree; } } @@ -257,7 +259,7 @@ public abstract class IntervalTreeImpl extends RedBla return s.contains("Locked by thread"); } - private void pushDeltaFromRoot(IntervalNode node) { + private void pushDeltaFromRoot(IntervalNode node) { if (node != null) { if (node.allDeltasUpAreNull && node.isValid() && node.modCount == modCount) return; pushDeltaFromRoot(node.getParent()); @@ -266,11 +268,11 @@ public abstract class IntervalTreeImpl extends RedBla } @NotNull - protected abstract IntervalNode createNewNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer); - protected abstract IntervalNode lookupNode(@NotNull T key); + protected abstract IntervalNode createNewNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer); + protected abstract IntervalNode lookupNode(@NotNull T key); protected abstract void setNode(@NotNull T key, IntervalNode node); - private int compareNodes(@NotNull IntervalNode i1, int delta1, @NotNull IntervalNode i2, int delta2, @NotNull List invalid) { + private int compareNodes(@NotNull IntervalNode i1, int delta1, @NotNull IntervalNode i2, int delta2, @NotNull List> invalid) { if (!i2.hasAliveKey(false)) { invalid.add(i2); //gced } @@ -280,8 +282,8 @@ public abstract class IntervalTreeImpl extends RedBla return compareEqualStartIntervals(i1, i2); } - protected IntervalNode getRoot() { - return (IntervalNode)root; + protected IntervalNode getRoot() { + return (IntervalNode)root; } public boolean process(@NotNull Processor processor) { @@ -295,7 +297,7 @@ public abstract class IntervalTreeImpl extends RedBla } } - private boolean process(final IntervalNode root, final Processor processor, final int modCountBefore) { + private boolean process(final IntervalNode root, final Processor processor, final int modCountBefore) { if (root == null) return true; return WalkingState.processAll(root, INTERVAL_TREE_GUIDE_INSTANCE, new Processor() { @@ -319,7 +321,7 @@ public abstract class IntervalTreeImpl extends RedBla } } - private boolean processOverlappingWith(IntervalNode root, + private boolean processOverlappingWith(IntervalNode root, int start, int end, Processor processor, @@ -361,7 +363,7 @@ public abstract class IntervalTreeImpl extends RedBla l.readLock().unlock(); } } - private boolean processOverlappingWithOutside(IntervalNode root, + private boolean processOverlappingWithOutside(IntervalNode root, int start, int end, @NotNull Processor processor, @@ -401,7 +403,7 @@ public abstract class IntervalTreeImpl extends RedBla l.readLock().unlock(); } } - private boolean processContaining(IntervalNode root, + private boolean processContaining(IntervalNode root, int offset, Processor processor, int modCountBefore, @@ -434,7 +436,7 @@ public abstract class IntervalTreeImpl extends RedBla @NotNull Iterator overlappingIterator(final int startOffset, final int endOffset) { - final IntervalNode firstOverlap = findMinOverlappingWith(getRoot(), new TextRangeInterval(startOffset, endOffset), modCount, 0); + final IntervalNode firstOverlap = findMinOverlappingWith(getRoot(), new TextRangeInterval(startOffset, endOffset), modCount, 0); if (firstOverlap == null) { return ContainerUtil.emptyIterator(); } @@ -442,7 +444,7 @@ public abstract class IntervalTreeImpl extends RedBla final int firstOverlapStart = firstOverlap.intervalStart() + firstOverlapDelta; final int modCountBefore = modCount; return new Iterator() { - private IntervalNode currentNode = firstOverlap; + private IntervalNode currentNode = firstOverlap; private int deltaUpToRootExclusive = firstOverlapDelta-firstOverlap.delta; private int indexInCurrentList = 0; private T current; @@ -495,14 +497,14 @@ public abstract class IntervalTreeImpl extends RedBla } // next node in in-order traversal - private IntervalNode nextNode(@NotNull IntervalNode root) { + private IntervalNode nextNode(@NotNull IntervalNode root) { assert root.isValid(); int delta = deltaUpToRootExclusive + root.delta; int myMaxEnd = maxEndOf(root, deltaUpToRootExclusive); assert startOffset <= myMaxEnd; // try to go right down - IntervalNode right = root.getRight(); + IntervalNode right = root.getRight(); if (right != null) { int rightMaxEnd = maxEndOf(right, delta); if (startOffset <= rightMaxEnd) { @@ -518,7 +520,7 @@ public abstract class IntervalTreeImpl extends RedBla // go up while (true) { - IntervalNode parent = root.getParent(); + IntervalNode parent = root.getParent(); if (parent == null) return null; if (parent.intervalStart() + deltaUpToRootExclusive > endOffset) return null; // can't move right deltaUpToRootExclusive -= parent.delta; @@ -533,7 +535,7 @@ public abstract class IntervalTreeImpl extends RedBla }; } - private boolean overlaps(IntervalNode root, int startOffset, int endOffset, int deltaUpToRootExclusive) { + private boolean overlaps(IntervalNode root, int startOffset, int endOffset, int deltaUpToRootExclusive) { if (root == null) return false; int delta = root.delta + deltaUpToRootExclusive; int start = root.intervalStart() + delta; @@ -559,7 +561,7 @@ public abstract class IntervalTreeImpl extends RedBla return parent; } - protected IntervalNode findOrInsert(@NotNull IntervalNode node) { + protected IntervalNode findOrInsert(@NotNull IntervalNode node) { assertUnderWriteLock(); node.color = Color.RED; node.setParent(null); @@ -569,12 +571,12 @@ public abstract class IntervalTreeImpl extends RedBla node.setLeft(null); node.setRight(null); - List gced = new SmartList(); + List> gced = new SmartList>(); if (root == null) { root = node; } else { - IntervalNode current = getRoot(); + IntervalNode current = getRoot(); while (true) { pushDelta(current); int compResult = compareNodes(node, 0, current, 0, gced); @@ -612,11 +614,11 @@ public abstract class IntervalTreeImpl extends RedBla return node; } - private void deleteNodes(@NotNull List collectedAway) { + private void deleteNodes(@NotNull List> collectedAway) { if (collectedAway.isEmpty()) return; try { l.writeLock().lock(); - for (IntervalNode node : collectedAway) { + for (IntervalNode node : collectedAway) { removeNode(node); } } @@ -625,14 +627,14 @@ public abstract class IntervalTreeImpl extends RedBla } } - public IntervalTreeImpl.IntervalNode addInterval(@NotNull T interval, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { + public IntervalTreeImpl.IntervalNode addInterval(@NotNull T interval, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { try { l.writeLock().lock(); checkMax(true); processReferenceQueue(); modCount++; - IntervalNode newNode = createNewNode(interval, start, end, greedyToLeft, greedyToRight, layer); - IntervalNode insertedNode = findOrInsert(newNode); + IntervalNode newNode = createNewNode(interval, start, end, greedyToLeft, greedyToRight, layer); + IntervalNode insertedNode = findOrInsert(newNode); if (insertedNode == newNode) { setNode(interval, insertedNode); } @@ -674,7 +676,7 @@ public abstract class IntervalTreeImpl extends RedBla } // returns real (minStart, maxStart, maxEnd) - private Trinity checkMax(IntervalNode root, + private Trinity checkMax(IntervalNode root, int deltaUpToRootExclusive, boolean assertInvalid, Ref allValid, @@ -715,9 +717,9 @@ public abstract class IntervalTreeImpl extends RedBla if (assertInvalid) assert false : root; return Trinity.create(Math.min(minLeftStart, minRightStart), Math.max(maxLeftStart, maxRightStart), Math.max(maxRightEnd, maxLeftEnd)); } - IntervalNode parent = root.getParent(); + IntervalNode parent = root.getParent(); if (parent != null && assertInvalid && root.hasAliveKey(false)) { - int c = compareNodes(root, delta, parent, delta - root.delta, new SmartList()); + int c = compareNodes(root, delta, parent, delta - root.delta, new SmartList>()); assert c != 0; assert c < 0 && parent.getLeft() == root || c > 0 && parent.getRight() == root; } @@ -736,7 +738,7 @@ public abstract class IntervalTreeImpl extends RedBla @Override protected Node maximumNode(Node n) { - IntervalNode root = (IntervalNode)n; + IntervalNode root = (IntervalNode)n; pushDelta(root.getParent()); pushDelta(root); while (root.getRight() != null) { @@ -747,7 +749,7 @@ public abstract class IntervalTreeImpl extends RedBla } protected void checkBelongsToTheTree(T interval, boolean assertInvalid) { - IntervalNode root = lookupNode(interval); + IntervalNode root = lookupNode(interval); if (root == null) return; assert root.getTree() == this : root.getTree() +"; this: "+this; if (!VERIFY) return; @@ -783,7 +785,7 @@ public abstract class IntervalTreeImpl extends RedBla checkMax(true); processReferenceQueue(); - IntervalNode node = lookupNode(interval); + IntervalNode node = lookupNode(interval); if (node == null) return false; reportInvalidation(interval, "Explicit Dispose"); @@ -800,16 +802,16 @@ public abstract class IntervalTreeImpl extends RedBla } // run under write lock - void removeNode(@NotNull IntervalNode node) { + void removeNode(@NotNull IntervalNode node) { deleteNode(node); - IntervalNode parent = node.getParent(); + IntervalNode parent = node.getParent(); correctMaxUp(parent); } @Override protected void deleteNode(@NotNull Node n) { assertUnderWriteLock(); - IntervalNode node = (IntervalNode)n; + IntervalNode node = (IntervalNode)n; pushDeltaFromRoot(node); assertAllDeltasAreNull(node); super.deleteNode(n); @@ -824,9 +826,9 @@ public abstract class IntervalTreeImpl extends RedBla } // returns true if all deltas involved are still 0 - protected boolean pushDelta(IntervalNode root) { + protected boolean pushDelta(IntervalNode root) { if (root == null || !root.isValid()) return true; - IntervalNode parent = root.getParent(); + IntervalNode parent = root.getParent(); assertAllDeltasAreNull(parent); int delta = root.delta; root.modCount = 0; @@ -847,7 +849,7 @@ public abstract class IntervalTreeImpl extends RedBla } // returns true if all deltas involved are still 0 - private boolean incDelta(IntervalNode root, int delta) { + private boolean incDelta(IntervalNode root, int delta) { if (root == null) return true; if (root.isValid()) { int newDelta = root.changeDelta(delta); @@ -862,10 +864,10 @@ public abstract class IntervalTreeImpl extends RedBla } @Override - protected IntervalNode swapWithMaxPred(Node root, Node maxPred) { + protected IntervalNode swapWithMaxPred(Node root, Node maxPred) { checkMax(false); - IntervalNode a = (IntervalNode)root; - IntervalNode d = (IntervalNode)maxPred; + IntervalNode a = (IntervalNode)root; + IntervalNode d = (IntervalNode)maxPred; Color acolor = a.color; Color dcolor = d.color; assert !a.isValid() || a.delta == 0 : a.delta; @@ -889,13 +891,13 @@ public abstract class IntervalTreeImpl extends RedBla assert d.delta == 0 : d.delta; return a; } - private void swapNodes(IntervalNode n1, IntervalNode n2) { - IntervalNode l1 = n1.getLeft(); - IntervalNode r1 = n1.getRight(); - IntervalNode p1 = n1.getParent(); - IntervalNode l2 = n2.getLeft(); - IntervalNode r2 = n2.getRight(); - IntervalNode p2 = n2.getParent(); + private void swapNodes(IntervalNode n1, IntervalNode n2) { + IntervalNode l1 = n1.getLeft(); + IntervalNode r1 = n1.getRight(); + IntervalNode p1 = n1.getParent(); + IntervalNode l2 = n2.getLeft(); + IntervalNode r2 = n2.getRight(); + IntervalNode p2 = n2.getParent(); if (p1 != null) { if (p1.getLeft() == n1) p1.setLeft(n2); else p1.setRight(n2); @@ -923,7 +925,7 @@ public abstract class IntervalTreeImpl extends RedBla } // returns real max endOffset of all intervals below - private int maxEndOf(IntervalNode node, int deltaUpToRootExclusive) { + private int maxEndOf(IntervalNode node, int deltaUpToRootExclusive) { if (node == null) { return 0; } @@ -935,14 +937,14 @@ public abstract class IntervalTreeImpl extends RedBla } // max of n.left's maxend, n.right's maxend and its own interval endOffset - protected void correctMax(@NotNull IntervalNode node, int deltaUpToRoot) { + protected void correctMax(@NotNull IntervalNode node, int deltaUpToRoot) { if (!node.isValid()) return; int realMax = Math.max(Math.max(maxEndOf(node.getLeft(), deltaUpToRoot), maxEndOf(node.getRight(), deltaUpToRoot)), deltaUpToRoot + node.intervalEnd()); node.maxEnd = realMax - deltaUpToRoot; } - private void correctMaxUp(IntervalNode node) { + private void correctMaxUp(IntervalNode node) { int delta = node == null ? 0 : node.computeDeltaUpToRoot(); assert delta == 0 : delta; while (node != null) { @@ -959,9 +961,9 @@ public abstract class IntervalTreeImpl extends RedBla @Override protected void rotateRight(Node n) { checkMax(false); - IntervalNode node1 = (IntervalNode)n; - IntervalNode node2 = node1.getLeft(); - IntervalNode node3 = node1.getRight(); + IntervalNode node1 = (IntervalNode)n; + IntervalNode node2 = node1.getLeft(); + IntervalNode node3 = node1.getRight(); IntervalNode parent = node1.getParent(); int deltaUp = parent == null ? 0 : parent.computeDeltaUpToRoot(); @@ -985,9 +987,9 @@ public abstract class IntervalTreeImpl extends RedBla @Override protected void rotateLeft(Node n) { checkMax(false); - IntervalNode node1 = (IntervalNode)n; - IntervalNode node2 = node1.getLeft(); - IntervalNode node3 = node1.getRight(); + IntervalNode node1 = (IntervalNode)n; + IntervalNode node2 = node1.getLeft(); + IntervalNode node3 = node1.getRight(); IntervalNode parent = node1.getParent(); int deltaUp = parent == null ? 0 : parent.computeDeltaUpToRoot(); @@ -1011,9 +1013,9 @@ public abstract class IntervalTreeImpl extends RedBla @Override protected void replaceNode(@NotNull Node node, Node child) { - IntervalNode myNode = (IntervalNode)node; + IntervalNode myNode = (IntervalNode)node; pushDelta(myNode); - pushDelta((IntervalNode)child); + pushDelta((IntervalNode)child); super.replaceNode(node, child); if (child != null && myNode.isValid()) { @@ -1030,7 +1032,7 @@ public abstract class IntervalTreeImpl extends RedBla assert node.modCount != modCount || node.allDeltasUpAreNull; } - private IntervalNode findMinOverlappingWith(IntervalNode root, Interval interval, int modCountBefore, int deltaUpToRootExclusive) { + private IntervalNode findMinOverlappingWith(IntervalNode root, Interval interval, int modCountBefore, int deltaUpToRootExclusive) { if (root == null) { return null; } @@ -1041,7 +1043,7 @@ public abstract class IntervalTreeImpl extends RedBla return null; // right of the rightmost interval in the subtree } - IntervalNode inLeft = findMinOverlappingWith(root.getLeft(), interval, modCountBefore, delta); + IntervalNode inLeft = findMinOverlappingWith(root.getLeft(), interval, modCountBefore, delta); if (inLeft != null) return inLeft; int myStartOffset = root.intervalStart() + delta; int myEndOffset = root.intervalEnd() + delta; @@ -1060,7 +1062,7 @@ public abstract class IntervalTreeImpl extends RedBla try { l.writeLock().lock(); - IntervalNode node = lookupNode(interval); + IntervalNode node = lookupNode(interval); if (node == null) return; int before = size(); boolean nodeRemoved = node.removeInterval(interval); @@ -1097,7 +1099,7 @@ public abstract class IntervalTreeImpl extends RedBla private void purgeDeadNodes() { assertUnderWriteLock(); - List gced = new SmartList(); + List> gced = new SmartList>(); collectGced(getRoot(), gced); deleteNodes(gced); checkMax(true); @@ -1117,7 +1119,7 @@ public abstract class IntervalTreeImpl extends RedBla keySize = 0; } - private void collectGced(IntervalNode root, List gced) { + private void collectGced(IntervalNode root, List> gced) { if (root == null) return; if (!root.hasAliveKey(true)) gced.add(root); collectGced(root.getLeft(), gced); @@ -1126,7 +1128,7 @@ public abstract class IntervalTreeImpl extends RedBla private void printSorted() { printSorted(getRoot());} - private void printSorted(IntervalNode root) { + private void printSorted(IntervalNode root) { if (root == null) return; printSorted(root.getLeft()); System.out.println(root); @@ -1136,7 +1138,7 @@ public abstract class IntervalTreeImpl extends RedBla void reportInvalidation(T markerEx, Object reason) { } - private class IntervalTreeGuide implements WalkingState.TreeGuide { + private static class IntervalTreeGuide implements WalkingState.TreeGuide { @Override public IntervalNode getNextSibling(@NotNull IntervalNode element) { IntervalNode parent = element.getParent(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/LineIteratorImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/LineIteratorImpl.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/LineIteratorImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/LineIteratorImpl.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/LineSet.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/LineSet.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/LineSet.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/LineSet.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MutableInterval.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/MutableInterval.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/MutableInterval.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/MutableInterval.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarker.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarker.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarker.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarker.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarkerUtil.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarkerUtil.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarkerUtil.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/PersistentRangeMarkerUtil.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java similarity index 98% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java index 2b27387099d0..452b01d44d9f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/RangeMarkerTree.java @@ -58,7 +58,7 @@ public class RangeMarkerTree extends IntervalTreeImpl.IntervalNode i1, @NotNull IntervalTreeImpl.IntervalNode i2) { + protected int compareEqualStartIntervals(@NotNull IntervalTreeImpl.IntervalNode i1, @NotNull IntervalTreeImpl.IntervalNode i2) { RMNode o1 = (RMNode)i1; RMNode o2 = (RMNode)i2; boolean greedyL1 = o1.isGreedyToLeft(); @@ -150,12 +150,12 @@ public class RangeMarkerTree extends IntervalTreeImpl.IntervalNode { + public class RMNode extends IntervalTreeImpl.IntervalNode { private final boolean isExpandToLeft; private final boolean isExpandToRight; public RMNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight) { - super(key, start, end); + super(RangeMarkerTree.this, key, start, end); isExpandToLeft = greedyToLeft; isExpandToRight = greedyToRight; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RedBlackTree.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/RedBlackTree.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RedBlackTree.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/RedBlackTree.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/StripedIDGenerator.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/StripedIDGenerator.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/StripedIDGenerator.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/StripedIDGenerator.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/TextChangesStorage.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangesStorage.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/TextChangesStorage.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangesStorage.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/TextRangeInterval.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/TextRangeInterval.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/TextRangeInterval.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/TextRangeInterval.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java rename to platform/core-impl/src/com/intellij/openapi/editor/impl/event/DocumentEventImpl.java diff --git a/platform/platform-api/platform-api.iml b/platform/platform-api/platform-api.iml index 8dde337c2b2d..414c5495b870 100644 --- a/platform/platform-api/platform-api.iml +++ b/platform/platform-api/platform-api.iml @@ -10,6 +10,7 @@ + diff --git a/platform/platform-impl/platform-impl.iml b/platform/platform-impl/platform-impl.iml index df4448cb35f4..b24f58c1d15f 100644 --- a/platform/platform-impl/platform-impl.iml +++ b/platform/platform-impl/platform-impl.iml @@ -30,6 +30,7 @@ + From 780e9d1fb8c1ac5de16a0a9288b72a3634a922f5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 20:38:47 +0400 Subject: [PATCH 61/74] add core-api and core-impl to build scripts --- build/scripts/layouts.gant | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 9b9e81a3764b..2da278d6d8de 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -8,6 +8,7 @@ target('default' : "Developers update") { private List platformImplementationModules() { return [ + "core-impl", "platform-impl", "vcs-impl", "lang-impl", @@ -25,7 +26,7 @@ private List platformImplementationModules() { } private List platformApiModules() { - return ["platform-api", "lvcs-api", "lang-api", "vcs-api", "usageView", "xdebugger-api", "xml-openapi"] + return ["core-api", "platform-api", "lvcs-api", "lang-api", "vcs-api", "usageView", "xdebugger-api", "xml-openapi"] } def layoutFull(String home, String targetDirectory) { From f65d25386442b43f16dfd935563f56bf7bb1e736 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 17 Aug 2011 20:57:04 +0400 Subject: [PATCH 62/74] IElementType and Lexer go to core-api --- .../{platform-api => core-api}/src/com/intellij/lexer/Lexer.java | 0 .../src/com/intellij/lexer/LexerPosition.java | 0 .../src/com/intellij/psi/tree/IElementType.java | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename platform/{platform-api => core-api}/src/com/intellij/lexer/Lexer.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/lexer/LexerPosition.java (100%) rename platform/{platform-api => core-api}/src/com/intellij/psi/tree/IElementType.java (100%) diff --git a/platform/platform-api/src/com/intellij/lexer/Lexer.java b/platform/core-api/src/com/intellij/lexer/Lexer.java similarity index 100% rename from platform/platform-api/src/com/intellij/lexer/Lexer.java rename to platform/core-api/src/com/intellij/lexer/Lexer.java diff --git a/platform/platform-api/src/com/intellij/lexer/LexerPosition.java b/platform/core-api/src/com/intellij/lexer/LexerPosition.java similarity index 100% rename from platform/platform-api/src/com/intellij/lexer/LexerPosition.java rename to platform/core-api/src/com/intellij/lexer/LexerPosition.java diff --git a/platform/platform-api/src/com/intellij/psi/tree/IElementType.java b/platform/core-api/src/com/intellij/psi/tree/IElementType.java similarity index 100% rename from platform/platform-api/src/com/intellij/psi/tree/IElementType.java rename to platform/core-api/src/com/intellij/psi/tree/IElementType.java From af226862f23c9bf20cfc174eaab504f4062fb689 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 17 Aug 2011 21:32:07 +0400 Subject: [PATCH 63/74] UIUtil. added style - MINI. --- .../util/src/com/intellij/util/ui/UIUtil.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index c4beb644c2f0..0fc33f329d8d 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -75,10 +75,10 @@ public class UIUtil { JComponent c = (JComponent)comp; if (SystemInfo.isMac) { - c.putClientProperty("JComponent.sizeVariant", style == Style.REGULAR ? "regular" : "small"); + c.putClientProperty("JComponent.sizeVariant", style == Style.REGULAR ? "regular" : style == Style.SMALL ? "small" : "mini"); } else { - c.setFont(getFont(style == Style.SMALL ? FontSize.SMALL : FontSize.NORMAL, c.getFont())); + c.setFont(getFont(style == Style.REGULAR ? FontSize.NORMAL : style == Style.SMALL ? FontSize.SMALL : FontSize.MINI, c.getFont())); } Container p = c.getParent(); if (p != null) { @@ -86,7 +86,7 @@ public class UIUtil { } } - public enum FontSize { NORMAL, SMALL } + public enum FontSize { NORMAL, SMALL, MINI } public static final char MNEMONIC = 0x1B; @NonNls public static final String HTML_MIME = "text/html"; @@ -256,18 +256,15 @@ public class UIUtil { @NotNull public static Font getFont(@NotNull FontSize size, @Nullable Font base) { Font defFont = getLabelFont(); + if (base == null) base = defFont; - if (size == FontSize.SMALL) { - if (base == null) base = defFont; - return base.deriveFont(defFont.getSize() * (SystemInfo.isMac ? 0.85f: 0.8f)); - } - else { - if (base != null) { + switch (size) { + case SMALL: + return base.deriveFont(defFont.getSize() * (SystemInfo.isMac ? 0.85f: 0.8f)); + case MINI: + return base.deriveFont(defFont.getSize() * 0.7f); + default: return base.deriveFont(defFont.getSize()); - } - else { - return defFont; - } } } @@ -278,7 +275,7 @@ public class UIUtil { if (isBold) { return defFont.deriveFont((float)Math.max(defFont.getSize() - 2, 11)).deriveFont(Font.BOLD); } - return defFont.deriveFont((float)Math.max(defFont.getSize() - 1, 11)); + return defFont.deriveFont((float)Math.max(defFont.getSize() - 2, 11)); } if (isBold) { return defFont.deriveFont(Font.BOLD); @@ -2371,7 +2368,7 @@ public class UIUtil { return c instanceof JFrame || c instanceof JDialog || c instanceof JWindow || c instanceof JRootPane; } - public enum Style {REGULAR, SMALL} + public enum Style {REGULAR, SMALL, MINI} public static Timer createNamedTimer(@NonNls @NotNull final String name, int delay, @NotNull ActionListener listener) { return new Timer(delay, listener){ From 21299f9448a77875266683b0dfae83f81034dc89 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 17 Aug 2011 21:32:34 +0400 Subject: [PATCH 64/74] TitledSeparator fix --- .../platform-api/src/com/intellij/ui/TitledSeparator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/TitledSeparator.java b/platform/platform-api/src/com/intellij/ui/TitledSeparator.java index 8692242660bf..09c18e2c4adb 100644 --- a/platform/platform-api/src/com/intellij/ui/TitledSeparator.java +++ b/platform/platform-api/src/com/intellij/ui/TitledSeparator.java @@ -51,6 +51,8 @@ public class TitledSeparator extends JPanel { setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 5, 5)); setTitleFont(UIUtil.getBorderFont(smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, boldFont)); + this.boldFont = boldFont; + this.smallFont = smallFont; setText(text); } @@ -80,12 +82,12 @@ public class TitledSeparator extends JPanel { public void setBoldFont(boolean boldFont) { this.boldFont = boldFont; - setTitleFont(UIUtil.getBorderFont(smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, boldFont)); + setTitleFont(UIUtil.getBorderFont(this.smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, this.boldFont)); } public void setSmallFont(boolean smallFont) { this.smallFont = smallFont; - setTitleFont(UIUtil.getBorderFont(smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, boldFont)); + setTitleFont(UIUtil.getBorderFont(this.smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, this.boldFont)); } } From e6655fcd92511a51b3f4475b9183f4dc85c8cc30 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 17 Aug 2011 21:34:49 +0400 Subject: [PATCH 65/74] LebeledComponent. added hgap and vgap. added label preferred size property. --- .../intellij/openapi/ui/LabeledComponent.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LabeledComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/LabeledComponent.java index 4ac4f75f1486..07665c4a2ad1 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LabeledComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LabeledComponent.java @@ -18,6 +18,7 @@ package com.intellij.openapi.ui; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.IdeBorderFactory; +import com.intellij.uiDesigner.core.AbstractLayout; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -31,10 +32,8 @@ public class LabeledComponent extends JPanel { private String myLabelConstraints = BorderLayout.NORTH; public LabeledComponent() { - super(new BorderLayout()); + super(new BorderLayout(AbstractLayout.DEFAULT_HGAP, AbstractLayout.DEFAULT_VGAP)); insertLabel(); - updateLabelBorder(); - updateUI(); } @NotNull @@ -45,25 +44,19 @@ public class LabeledComponent extends JPanel { return labeledComponent; } - private void updateLabelBorder() { - int left = 0; - int bottom = 0; - if (BorderLayout.NORTH.equals(myLabelConstraints)) { - bottom = 2; - } - myLabel.setBorder(BorderFactory.createEmptyBorder(0, left, bottom, 0)); - } - - public void updateUI() { - super.updateUI(); - if (myLabel != null) updateLabelBorder(); - } - private void insertLabel() { remove(myLabel); add(myLabel, myLabelConstraints); } + public void setLabelPreferredSize(Dimension d) { + myLabel.setPreferredSize(d); + } + + public Dimension getLabelPreferredSize() { + return myLabel.getPreferredSize(); + } + public void setText(String textWithMnemonic) { if (!StringUtil.endsWithChar(textWithMnemonic, ':')) textWithMnemonic += ":"; TextWithMnemonic withMnemonic = TextWithMnemonic.fromTextWithMnemonic(textWithMnemonic); From 58ca60481d7ed46153a780638e6d096ccd2c8b7c Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 17 Aug 2011 21:35:55 +0400 Subject: [PATCH 66/74] IdeBorderFactory. Insets around plain border made larger --- .../src/com/intellij/ui/IdeBorderFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java b/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java index bdf362c0693e..96633c610ccf 100644 --- a/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java +++ b/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java @@ -60,10 +60,16 @@ public class IdeBorderFactory { public static IdeaTitledBorder createTitledBorder(String title, boolean hasBoldFont, boolean hasIndent, boolean hasSmallFont) { Font font = UIUtil.getBorderFont(hasSmallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, hasBoldFont); int indent = hasIndent ? (hasBoldFont ? 18 : 15) : 0; - Insets insets = hasBoldFont ? new Insets(5, 0, 10, 0) : new Insets(3, 0, 6, 0); + Insets insets = new Insets(5, 0, 10, 0); return new IdeaTitledBorder(title, font, UIUtil.getBorderColor(), indent, 1, insets); } + public static IdeaTitledBorder createTitledBorder(String title, boolean hasBoldFont, boolean hasIndent, boolean hasSmallFont, Insets insets) { + Font font = UIUtil.getBorderFont(hasSmallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, hasBoldFont); + int indent = hasIndent ? (hasBoldFont ? 18 : 15) : 0; + return new IdeaTitledBorder(title, font, UIUtil.getBorderColor(), indent, 1, insets); + } + @Deprecated // Don't remove, used in TeamCity plugin. public static TitledBorder createTitledHeaderBorder(String title) { From 41c63cc31b77a04e728ea137f6fc6fabf779eab4 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 17 Aug 2011 21:36:52 +0400 Subject: [PATCH 67/74] Run configaration's form refactored and some other forms too --- .../eclipse/EclipseCompilerConfigurable.form | 6 +- .../javaCompiler/javac/JavacOptionsPanel.form | 6 +- .../javaCompiler/jikes/JikesOptionsPanel.form | 18 +- .../options/CompilerOptionsPanel.form | 80 ++++----- .../compiler/options/RmicOptionsPanel.form | 34 ++-- .../execution/applet/AppletConfigurable.form | 49 +++--- .../application/ApplicationConfigurable.form | 9 +- .../execution/ui/AlternativeJREPanel.java | 8 +- .../ui/CommonJavaParametersPanel.java | 5 + .../ui/classFilter/ClassFilterEditor.java | 8 +- .../application/options/CodeCompletion.form | 99 +++++------ .../options/TabbedLanguageCodeStylePanel.java | 2 + .../ConfigurationSettingsEditorWrapper.form | 6 +- .../ui/CommonProgramParametersPanel.java | 6 + .../ide/todo/configurable/FilterDialog.java | 2 +- .../internal/psiView/PsiViewerDialog.form | 4 +- .../encoding/FileEncodingConfigurable.form | 4 +- .../intellij/ui/OptionalChooserComponent.form | 4 +- .../intellij/ui/PathsChooserComponent.form | 4 +- .../com/intellij/ui/TabbedPaneWrapper.java | 2 + .../src/messages/ExecutionBundle.properties | 5 +- .../src/messages/VcsBundle.properties | 2 +- .../VcsGeneralConfigurationPanel.form | 154 ++++++++---------- .../intelliLang/AdvancedSettingsUI.form | 14 +- .../run/testing/TestRunParameters.form | 7 +- .../src/run/PluginRunConfigurationEditor.java | 11 +- .../src/git4idea/i18n/GitBundle.properties | 4 +- .../update/GitUpdateOptionsPanel.form | 48 +++--- .../groovy/mvc/MvcRunConfigurationEditor.form | 10 +- .../runner/GroovyRunConfigurationEditor.form | 114 +++++++------ .../runner/GroovyRunConfigurationEditor.java | 4 +- .../groovy/util/SdkHomeConfigurable.java | 2 +- .../configuration/JUnitConfigurable.form | 61 ++++--- .../execution/MavenRunnerConfigurable.java | 10 +- .../MavenRunnerParametersConfigurable.form | 10 +- .../settings/SpellCheckerSettingsPane.form | 10 +- .../tasks/config/BaseRepositoryEditor.form | 4 +- .../TestNGConfigurationEditor.form | 18 +- .../xpath/xslt/run/RunSettingsEditor.form | 69 ++++---- 39 files changed, 483 insertions(+), 430 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.form b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.form index 4d452482d19b..4d16b23ed4a6 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.form +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/eclipse/EclipseCompilerConfigurable.form @@ -7,7 +7,7 @@ - + @@ -38,8 +38,8 @@ - - + + diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOptionsPanel.form index ede31f90580e..113e6ace5179 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOptionsPanel.form @@ -7,7 +7,7 @@ - + @@ -37,8 +37,8 @@ - - + + diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form index 1936157f726f..39da15a2f707 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesOptionsPanel.form @@ -1,13 +1,13 @@
- + - + - + @@ -46,10 +46,10 @@ - - + + - + @@ -93,10 +93,10 @@ - - + + - + diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form index 11cf203ae50b..4ec4d8bd8c01 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form @@ -16,45 +16,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -63,7 +29,6 @@ - @@ -72,7 +37,6 @@ - @@ -81,10 +45,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/compiler/impl/src/com/intellij/compiler/options/RmicOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/options/RmicOptionsPanel.form index a2cd37ad0ff7..a5a4aafe6385 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/RmicOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/options/RmicOptionsPanel.form @@ -1,27 +1,24 @@ - + - - + - - + - - + @@ -29,8 +26,7 @@ - - + @@ -38,8 +34,7 @@ - - + @@ -48,8 +43,7 @@ - - + @@ -57,19 +51,17 @@ - - + + - - + - - + @@ -77,11 +69,11 @@ - - + + diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.form b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.form index b6fa04e745f5..6a0c22b8ae78 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.form +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfigurable.form @@ -1,9 +1,9 @@ - + - + @@ -22,7 +22,7 @@ - + @@ -37,33 +37,38 @@ - + - + + + - + - + + + - + - + + @@ -75,16 +80,16 @@ - - + + - + - + @@ -104,8 +109,8 @@ - - + + @@ -113,9 +118,9 @@ - + - + @@ -252,12 +257,18 @@ - + - + + + + + + + diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.form b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.form index a70c36b0911a..d3c691ce357d 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.form +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.form @@ -1,6 +1,6 @@ - + @@ -21,9 +21,13 @@ - + + + + + @@ -33,6 +37,7 @@ + diff --git a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java index f2f9cb8cc63a..973cc74c180b 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java +++ b/java/execution/impl/src/com/intellij/execution/ui/AlternativeJREPanel.java @@ -45,8 +45,9 @@ public class AlternativeJREPanel extends JPanel { super(new GridBagLayout()); myCbEnabled = new JCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox")); - final GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(2, -2, 2, 2), 0, 0); + myCbEnabled.setPreferredSize(new Dimension(154, 16)); + final GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, + GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); add(myCbEnabled, gc); myFieldWithHistory = new TextFieldWithHistory(); @@ -61,7 +62,8 @@ public class AlternativeJREPanel extends JPanel { ExecutionBundle.message("run.configuration.select.jre.dir.label"), null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); - gc.insets.left = 20; + gc.gridx = 1; + gc.weightx = 1; add(myPathField, gc); InsertPathAction.addTo(myFieldWithHistory.getTextEditor()); diff --git a/java/execution/impl/src/com/intellij/execution/ui/CommonJavaParametersPanel.java b/java/execution/impl/src/com/intellij/execution/ui/CommonJavaParametersPanel.java index 2c980cb9d75e..35442ec0d697 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/CommonJavaParametersPanel.java +++ b/java/execution/impl/src/com/intellij/execution/ui/CommonJavaParametersPanel.java @@ -20,6 +20,8 @@ import com.intellij.execution.ExecutionBundle; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.ui.RawCommandLineEditor; +import java.awt.*; + public class CommonJavaParametersPanel extends CommonProgramParametersPanel { private LabeledComponent myVMParameters; @@ -33,6 +35,9 @@ public class CommonJavaParametersPanel extends CommonProgramParametersPanel { ExecutionBundle.message("run.configuration.java.vm.parameters.label")); copyDialogCaption(myVMParameters); + myVMParameters.setLabelLocation(BorderLayout.WEST); + myVMParameters.setLabelPreferredSize(super.getProgramParametersComponent().getLabelPreferredSize()); + add(myVMParameters); super.addComponents(); } diff --git a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java index 77bc11669912..b772186338b7 100644 --- a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java +++ b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java @@ -72,10 +72,10 @@ public class ClassFilterEditor extends JPanel implements ComponentWithEmptyText myTable = new JBTable(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); - add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 6), 0, 0)); - add(myAddClassButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 4), 0, 0)); - add(myAddPatternButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 4), 0, 0)); - add(myRemoveButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 4), 0, 0)); + add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 0, 4, 6), 0, 0)); + add(myAddClassButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); + add(myAddPatternButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); + add(myRemoveButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0)); myChooserFilter = classFilter; myProject = project; diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeCompletion.form b/platform/lang-impl/src/com/intellij/application/options/CodeCompletion.form index bc914ba1a65f..2506873a81ce 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeCompletion.form +++ b/platform/lang-impl/src/com/intellij/application/options/CodeCompletion.form @@ -1,9 +1,9 @@ - + - + @@ -18,10 +18,10 @@ - + - + @@ -119,6 +119,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +