From 28907fde4ff07ea4f7e72b5c7a94b2e2aca850b4 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Mon, 29 Jun 2015 14:02:07 +0200 Subject: [PATCH 01/48] Remove obsolete deprecation. --- .../ContentBasedFileSubstitutor.java | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java diff --git a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java b/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java deleted file mode 100644 index 2889c14ea2e4..000000000000 --- a/platform/core-api/src/com/intellij/openapi/fileTypes/ContentBasedFileSubstitutor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2015 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.lang.Language; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** @deprecated use com.intellij.psi.compiled.ClassFileDecompilers or com.intellij.psi.LanguageSubstitutors API (to remove in IDEA 14) */ -@SuppressWarnings("deprecation") -public interface ContentBasedFileSubstitutor { - ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.contentBasedClassFileProcessor"); - - boolean isApplicable(Project project, VirtualFile vFile); - - @NotNull - String obtainFileText(Project project, VirtualFile file); - - @Nullable - Language obtainLanguageForFile(VirtualFile file); -} From 18f454c532e98227d7d9e6fb5f2e96b04cea2db8 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Mon, 29 Jun 2015 15:05:12 +0300 Subject: [PATCH 02/48] Update binary skeletons path on every SDK update and clean up obsolete paths (PY-15499) Sometimes paths to binary skeletons in jdk.table.xml used to become corrupted or invalid. There used to be no way of fixing that since the paths had been added there only once during the SDK set up. Now we restore them every time the SDK gets updated. The paths should be in the jdk.table.xml because they are the part of SDK paths and they are required for indexing. Indexing contributors don't allow to associate paths with modules. --- .../python/sdk/PythonSdkUpdater.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java b/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java index 409f860d71fd..47ab071f2c6b 100644 --- a/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java +++ b/python/src/com/jetbrains/python/sdk/PythonSdkUpdater.java @@ -19,6 +19,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; @@ -34,6 +35,7 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.startup.StartupActivity; import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.PathMappingSettings; import com.jetbrains.python.PyBundle; @@ -193,6 +195,7 @@ public class PythonSdkUpdater implements StartupActivity { boolean changed = addNewSysPathEntries(sdk, modificator, sysPath); changed = removeSourceRoots(sdk, modificator) || changed; changed = removeDuplicateClassRoots(sdk, modificator) || changed; + changed = updateSkeletonsPath(sdk, modificator) || changed; if (changed) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override @@ -257,6 +260,36 @@ public class PythonSdkUpdater implements StartupActivity { return false; } + /** + * Updates binary skeletons path in the Python SDK table. + */ + private static boolean updateSkeletonsPath(@NotNull Sdk sdk, @NotNull SdkModificator modificator) { + boolean changed = false; + final String skeletonsPath = PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), sdk.getHomePath()); + if (skeletonsPath != null) { + final VirtualFile skeletonsDir = StandardFileSystems.local().refreshAndFindFileByPath(skeletonsPath); + if (skeletonsDir != null) { + LOG.info("Binary skeletons directory for SDK \"" + sdk.getName() + "\" (" + sdk.getHomePath() + "): " + skeletonsDir.getPath()); + final List sourceRoots = Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES)); + boolean skeletonsDirFound = false; + for (VirtualFile root : sourceRoots) { + if (root.equals(skeletonsDir)) { + skeletonsDirFound = true; + } + if (PythonSdkType.isSkeletonsPath(root.getPath()) && !skeletonsDirFound) { + modificator.removeRoot(root, OrderRootType.CLASSES); + changed = true; + } + } + if (!skeletonsDirFound) { + modificator.addRoot(skeletonsDir, OrderRootType.CLASSES); + changed = true; + } + } + } + return changed; + } + private static boolean wasOldRoot(@NotNull String root, @NotNull Collection oldRoots) { final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(root); if (file != null) { From 6ed9af59f37f4099473123f92c55daf2b4497689 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 26 Jun 2015 15:59:02 +0300 Subject: [PATCH 03/48] [groovy] show console on ctrl+enter (IDEA-140463) --- .../src/org/jetbrains/plugins/groovy/console/GroovyConsole.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java index 5e80030caa93..dd7acfdeb031 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java @@ -92,6 +92,7 @@ public class GroovyConsole { myConsoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT); myConsoleView.print("Result: ", ConsoleViewContentType.SYSTEM_OUTPUT); send(myProcessHandler, StringUtil.replace(command, "\n", "###\\n")); + ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(defaultExecutor, myContentDescriptor); } public boolean stop() { From 60ee51855f57a5f3de9726d165e6e430626ea227 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 26 Jun 2015 16:03:43 +0300 Subject: [PATCH 04/48] [groovy] use simple string as console name instead of hex --- .../groovy/console/GroovyConsoleRootType.java | 15 ++++++++++++++- .../console/actions/GrNewConsoleAction.java | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java index 7d7c604d4167..e4da3885eab6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java @@ -23,6 +23,7 @@ import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,6 +36,7 @@ import javax.swing.*; public final class GroovyConsoleRootType extends ConsoleRootType { public static final AnAction executeAction = new GrExecuteCommandAction(); + public static final String CONTENT_ID = "groovy_console"; @NotNull public static GroovyConsoleRootType getInstance() { @@ -56,10 +58,21 @@ public final class GroovyConsoleRootType extends ConsoleRootType { return !GroovyConsoleStateService.getInstance(project).isProjectConsole(element); } + @NotNull + @Override + public String getContentPathName(@NotNull String id) { + assert id == CONTENT_ID; + return CONTENT_ID; + } + @Nullable @Override public String substituteName(@NotNull Project project, @NotNull VirtualFile file) { - return GroovyConsoleStateService.getInstance(project).getSelectedModuleTitle(file); + final String name = file.getName(); + final String moduleTitle = GroovyConsoleStateService.getInstance(project).getSelectedModuleTitle(file); + return name.startsWith(CONTENT_ID) + ? StringUtil.replace(name, CONTENT_ID, moduleTitle == null ? "unknown" : moduleTitle) + : String.format("%s-%s", moduleTitle, name); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrNewConsoleAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrNewConsoleAction.java index c8beee6ff240..677d95a359fc 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrNewConsoleAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrNewConsoleAction.java @@ -49,7 +49,7 @@ public class GrNewConsoleAction extends AnAction { final VirtualFile contentFile = ConsoleHistoryController.getContentFile( GroovyConsoleRootType.getInstance(), - "groovy-console", + GroovyConsoleRootType.CONTENT_ID, ScratchFileService.Option.create_new_always ); assert contentFile != null; From 9650a0e9b6b7f4c9b7a988081eb834df27750cb5 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 26 Jun 2015 16:28:58 +0300 Subject: [PATCH 05/48] [groovy] add execute button to the editor toolbar --- .../plugins/groovy/console/GroovyConsoleRootType.java | 6 +++--- .../groovy/console/actions/GrExecuteCommandAction.java | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java index e4da3885eab6..d7c16c6d6b7d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRootType.java @@ -35,7 +35,7 @@ import javax.swing.*; public final class GroovyConsoleRootType extends ConsoleRootType { - public static final AnAction executeAction = new GrExecuteCommandAction(); + public static final AnAction EXECUTE_ACTION = new GrExecuteCommandAction(); public static final String CONTENT_ID = "groovy_console"; @NotNull @@ -84,11 +84,11 @@ public final class GroovyConsoleRootType extends ConsoleRootType { if (!(fileEditor instanceof TextEditor)) continue; final Editor editor = ((TextEditor)fileEditor).getEditor(); final JPanel panel = new EditorHeaderComponent(); - final DefaultActionGroup actionGroup = new DefaultActionGroup(new GrSelectModuleAction(projectConsole, file)); + final DefaultActionGroup actionGroup = new DefaultActionGroup(EXECUTE_ACTION, new GrSelectModuleAction(projectConsole, file)); final ActionToolbar menu = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true); panel.add(menu.getComponent()); editor.setHeaderComponent(panel); - executeAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent()); + EXECUTE_ACTION.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent()); } } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrExecuteCommandAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrExecuteCommandAction.java index 0f82785578a4..b1f30abaf616 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrExecuteCommandAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrExecuteCommandAction.java @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.groovy.console.actions; +import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -29,6 +30,10 @@ import org.jetbrains.plugins.groovy.console.GroovyConsole; public class GrExecuteCommandAction extends AnAction { + public GrExecuteCommandAction() { + super(AllIcons.Toolwindows.ToolWindowRun); + } + @Override public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); From 825a441ff747d4c4e82a0f2205eb40454bc3e669 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 26 Jun 2015 17:03:25 +0300 Subject: [PATCH 06/48] [groovy] console: do not execute empty commands --- .../org/jetbrains/plugins/groovy/console/GroovyConsole.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java index dd7acfdeb031..7ff7d43ec6f6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java @@ -78,7 +78,7 @@ public class GroovyConsole { myProcessHandler = handler; } - public void execute(@NotNull String command) { + private void doExecute(@NotNull String command) { // dirty hack if (first) { first = false; @@ -92,6 +92,10 @@ public class GroovyConsole { myConsoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT); myConsoleView.print("Result: ", ConsoleViewContentType.SYSTEM_OUTPUT); send(myProcessHandler, StringUtil.replace(command, "\n", "###\\n")); + } + + public void execute(@NotNull String command) { + if (!StringUtil.isEmptyOrSpaces(command)) doExecute(command); ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(defaultExecutor, myContentDescriptor); } From ac43b909bfa0593e057607941b20809ccf853b00 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Fri, 26 Jun 2015 18:03:17 +0300 Subject: [PATCH 07/48] [groovy] shut down process when console file is closed --- .../plugins/groovy/console/GroovyConsole.java | 45 ++++++++++++++----- .../console/actions/GrSelectModuleAction.java | 11 +++-- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java index 7ff7d43ec6f6..b337fb10aa9b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsole.java @@ -27,11 +27,11 @@ import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.actions.CloseAction; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.ActionToolbar; -import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.FileEditorManagerAdapter; +import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkType; @@ -99,8 +99,9 @@ public class GroovyConsole { ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(defaultExecutor, myContentDescriptor); } - public boolean stop() { - return ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(defaultExecutor, myContentDescriptor); + public void stop() { + myProcessHandler.destroyProcess(); // use force + ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(defaultExecutor, myContentDescriptor); } private static void send(@NotNull ProcessHandler processHandler, @NotNull String command) { @@ -168,7 +169,13 @@ public class GroovyConsole { actionGroup.add(new BuildAndRestartConsoleAction(module, project, defaultExecutor, descriptor, restarter(project, contentFile))); actionGroup.addSeparator(); actionGroup.addAll(consoleView.createConsoleActions()); - actionGroup.add(new CloseAction(defaultExecutor, descriptor, project)); + actionGroup.add(new CloseAction(defaultExecutor, descriptor, project) { + @Override + public void actionPerformed(AnActionEvent e) { + processHandler.destroyProcess(); // use force + super.actionPerformed(e); + } + }); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false); toolbar.setTargetComponent(consoleViewComponent); @@ -177,19 +184,30 @@ public class GroovyConsole { ui.add(consoleViewComponent, BorderLayout.CENTER); ui.add(toolbar.getComponent(), BorderLayout.WEST); - consoleView.attachToProcess(processHandler); + project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() { + @Override + public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { + if (file.equals(contentFile)) { + // if file was closed then kill process and hide console content + console.stop(); + } + } + }); processHandler.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(ProcessEvent event) { if (contentFile.getUserData(GROOVY_CONSOLE) == console) { + // process terminated either by closing file or by close action contentFile.putUserData(GROOVY_CONSOLE, null); } } }); - processHandler.startNotify(); - ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, descriptor); contentFile.putUserData(GROOVY_CONSOLE, console); + consoleView.attachToProcess(processHandler); + processHandler.startNotify(); + + ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, descriptor); return console; } @@ -203,7 +221,12 @@ public class GroovyConsole { final String exePath = ((JavaSdkType)sdkType).getVMExecutablePath(sdk); final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(exePath, javaParameters, true); final Process process = commandLine.createProcess(); - return new OSProcessHandler(process, commandLine.getCommandLineString()); + return new OSProcessHandler(process, commandLine.getCommandLineString()) { + @Override + public boolean isSilentlyDestroyOnClose() { + return true; + } + }; } catch (ExecutionException e) { LOG.warn(e); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrSelectModuleAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrSelectModuleAction.java index ef42d563b50c..dda0ec39a546 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrSelectModuleAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/actions/GrSelectModuleAction.java @@ -70,12 +70,11 @@ public class GrSelectModuleAction extends AnAction { public void consume(Module module) { final Module existingModule = myProjectConsole.getSelectedModule(myFile); if (module.equals(existingModule)) return; - final GroovyConsole groovyConsole = myFile.getUserData(GroovyConsole.GROOVY_CONSOLE); - if (groovyConsole == null || groovyConsole.stop()) { - myProjectConsole.setFileModule(myFile, module); - myFile.putUserData(GroovyConsole.GROOVY_CONSOLE, null); - ProjectView.getInstance(project).refresh(); - } + final GroovyConsole existingConsole = myFile.getUserData(GroovyConsole.GROOVY_CONSOLE); + if (existingConsole != null) existingConsole.stop(); + myProjectConsole.setFileModule(myFile, module); + myFile.putUserData(GroovyConsole.GROOVY_CONSOLE, null); + ProjectView.getInstance(project).refresh(); } }, e.getDataContext()); } From 6f0ce380fd12ddc3a04a9c38712eb9dbb257eb8a Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 29 Jun 2015 15:20:06 +0300 Subject: [PATCH 08/48] lst: correct range painting at the end of file in default mode click area is still bugged though --- .../vcs/ex/LineStatusTrackerDrawing.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java index 0e485f220f02..5f042f4c49ea 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java @@ -91,23 +91,22 @@ public class LineStatusTrackerDrawing { final int x = r.x + r.width - 3; final int endX = gutter.getWhitespaceSeparatorOffset(); - if (range.getInnerRanges() == null) { // actual painter - if (r.height > 0) { - paintRect(g, gutterColor, borderColor, x, r.y, endX, r.y + r.height); + final int y = lineToY(editor, range.getLine1()); + final int endY = lineToY(editor, range.getLine2()); + + if (range.getInnerRanges() == null) { // Mode.DEFAULT + if (y != endY) { + paintRect(g, gutterColor, borderColor, x, y, endX, endY); } else { - paintTriangle(g, gutterColor, borderColor, x, endX, r.y); + paintTriangle(g, gutterColor, borderColor, x, endX, y); } } - else { // registry: diff.status.tracker.smart - if (range.getType() == Range.DELETED) { - final int y = lineToY(editor, range.getLine1()); + else { // Mode.SMART + if (y == endY) { paintTriangle(g, gutterColor, borderColor, x, endX, y); } else { - final int y = lineToY(editor, range.getLine1()); - int endY = lineToY(editor, range.getLine2()); - List innerRanges = range.getInnerRanges(); for (Range.InnerRange innerRange : innerRanges) { if (innerRange.getType() == Range.DELETED) continue; From 2579debf47ea47c78c114d42b2284c063e10d1e8 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Mon, 29 Jun 2015 15:34:34 +0300 Subject: [PATCH 09/48] get rid of unused field --- .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 2 -- 1 file changed, 2 deletions(-) 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 380bf2c2233d..32e2987f75cf 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 @@ -885,8 +885,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } } - private static boolean firstCharTyped = true; - private void initComponent() { myPanel.setLayout(new BorderLayout()); From 70bb8d4a42bef5c323a51d756240b7027d362bf9 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 27 Jun 2015 21:14:29 +0200 Subject: [PATCH 10/48] Remove duplicate check from intention --- .../intention/impl/AddOnDemandStaticImportAction.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java index 36344aa00785..cea0b4f47bb8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -198,9 +198,6 @@ public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAc } private static boolean isParameterizedReference(final PsiJavaCodeReferenceElement expression) { - if (expression.getParameterList() == null) { - return false; - } PsiReferenceParameterList parameterList = expression.getParameterList(); return parameterList != null && parameterList.getFirstChild() != null; } From fd9e165adb836411dd0c76267692f793e5bb4e85 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 27 Jun 2015 21:16:25 +0200 Subject: [PATCH 11/48] cleanup --- .../intellij/psi/impl/PsiDiamondTypeUtil.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java index 8539b55835a6..2909317e370c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -118,15 +118,11 @@ public class PsiDiamondTypeUtil { if (!(parent instanceof PsiJavaCodeReferenceElement)) { return parent; } - final PsiJavaCodeReferenceElement javaCodeReferenceElement = - (PsiJavaCodeReferenceElement) parent; - final PsiReferenceParameterList referenceParameterList = - (PsiReferenceParameterList) element; + final PsiJavaCodeReferenceElement javaCodeReferenceElement = (PsiJavaCodeReferenceElement) parent; final StringBuilder text = new StringBuilder(); text.append(javaCodeReferenceElement.getQualifiedName()); text.append('<'); - final PsiTypeElement[] typeElements = referenceParameterList.getTypeParameterElements(); - final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(typeElements[0], PsiNewExpression.class); + final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class); final PsiDiamondType.DiamondInferenceResult result = PsiDiamondTypeImpl.resolveInferredTypesNoCheck(newExpression, newExpression); text.append(StringUtil.join(result.getInferredTypes(), new Function() { @Override @@ -135,10 +131,8 @@ public class PsiDiamondTypeUtil { } }, ",")); text.append('>'); - final PsiElementFactory elementFactory = - JavaPsiFacade.getElementFactory(element.getProject()); - final PsiJavaCodeReferenceElement newReference = - elementFactory.createReferenceFromText(text.toString(), element); + final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(element.getProject()); + final PsiJavaCodeReferenceElement newReference = elementFactory.createReferenceFromText(text.toString(), element); return CodeStyleManager.getInstance(javaCodeReferenceElement.getProject()).reformat(javaCodeReferenceElement.replace(newReference)); } From 76fcd98a1e2835d7831473e22b62017ccf1b0e2e Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 27 Jun 2015 21:18:35 +0200 Subject: [PATCH 12/48] IDEA-141963 (Intention. Switch prefix/postfix operator.) --- .../src/META-INF/IntentionPowerPack.xml | 5 ++ .../siyeh/IntentionPowerPackBundle.properties | 2 + .../ipp/opassign/PostfixPrefixIntention.java | 71 +++++++++++++++++++ .../after.java.template | 5 ++ .../before.java.template | 5 ++ .../PostfixPrefixIntention/description.html | 5 ++ .../opassign/postfix_prefix/Incomplete.java | 5 ++ .../ipp/opassign/postfix_prefix/Simple.java | 6 ++ .../opassign/postfix_prefix/Simple_after.java | 6 ++ .../opassign/PostfixPrefixIntentionTest.java | 37 ++++++++++ 10 files changed, 147 insertions(+) create mode 100644 plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java create mode 100644 plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template create mode 100644 plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template create mode 100644 plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java create mode 100644 plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java diff --git a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml index 95c585fef36c..ad885b84f380 100644 --- a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml +++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml @@ -622,5 +622,10 @@ com.siyeh.IntentionPowerPackBundle intention.category.other + + com.siyeh.ipp.opassign.PostfixPrefixIntention + com.siyeh.IntentionPowerPackBundle + intention.category.other + diff --git a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties index 6a5d499f42da..0d5c4217eb4d 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties +++ b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties @@ -186,6 +186,7 @@ negate.conditional.intention.name=Negate '?:' negate.conditional.intention.family.name=Negate Conditional objects.require.non.null.intention.name=Use 'java.util.Objects.requireNonNull()' expression objects.require.non.null.intention.family.name=Use 'java.util.Objects.requireNonNull()' Expression +postfix.prefix.intention.family.name=Flip prefix/postfix expression #hand made demorgans.intention.name1=Replace '\\&\\&' with '||' @@ -220,6 +221,7 @@ adapter.to.listener.intention.name=Replace extension of ''{0}'' with ''Listener' obscure.thrown.exceptions.intention.name=Replace with ''throws {0}'' add.array.creation.expression.intention.name=Add ''new {0}'' change.variable.type.to.rhs.type.intention.name=Declare ''{0}'' with type ''{1}'' +postfix.prefix.intention.name=Replace with ''{0}'' #categories diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java new file mode 100644 index 000000000000..ceddc5bcc595 --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/opassign/PostfixPrefixIntention.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2015 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.siyeh.ipp.opassign; + +import com.intellij.psi.*; +import com.siyeh.IntentionPowerPackBundle;import com.siyeh.ig.PsiReplacementUtil; +import com.siyeh.ipp.base.MutablyNamedIntention; +import com.siyeh.ipp.base.PsiElementPredicate; +import org.jetbrains.annotations.NotNull; + +/** + * @author Bas Leijdekkers + */ +public class PostfixPrefixIntention extends MutablyNamedIntention { + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + if (element instanceof PsiPrefixExpression) { + final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element; + return prefixExpression.getOperand() != null; + } + return element instanceof PsiPostfixExpression; + } + }; + } + + @Override + protected String getTextForElement(PsiElement element) { + return IntentionPowerPackBundle.message("postfix.prefix.intention.name", getReplacementText(element)); + } + + @NotNull + private static String getReplacementText(PsiElement element) { + if (element instanceof PsiPrefixExpression) { + final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element; + final PsiExpression operand = prefixExpression.getOperand(); + assert operand != null; + final PsiJavaToken sign = prefixExpression.getOperationSign(); + return operand.getText() + sign.getText(); + } + else { + final PsiPostfixExpression postfixExpression = (PsiPostfixExpression)element; + final PsiExpression operand = postfixExpression.getOperand(); + final PsiJavaToken sign = postfixExpression.getOperationSign(); + return sign.getText() + operand.getText(); + } + } + + @Override + protected void processIntention(@NotNull PsiElement element) { + final PsiExpression expression = (PsiExpression)element; + PsiReplacementUtil.replaceExpression(expression, getReplacementText(element)); + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template new file mode 100644 index 000000000000..62ff7e5742d2 --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/after.java.template @@ -0,0 +1,5 @@ +public class X { + void f(int i) { + ++i; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template new file mode 100644 index 000000000000..ce2d4d35c298 --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/before.java.template @@ -0,0 +1,5 @@ +public class X { + void f(int i) { + i++; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html new file mode 100644 index 000000000000..6a031b16018b --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/PostfixPrefixIntention/description.html @@ -0,0 +1,5 @@ + + +Replaces a postfix expression with a prefix expression and vice versa. + + diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java new file mode 100644 index 000000000000..e5e2497aa54f --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Incomplete.java @@ -0,0 +1,5 @@ +class Incomplete { + void m(int i) { + ++ + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java new file mode 100644 index 000000000000..9595d54d7030 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple.java @@ -0,0 +1,6 @@ +class Simple { + + void m(int i) { + i++; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java new file mode 100644 index 000000000000..d23b2ee884d9 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/opassign/postfix_prefix/Simple_after.java @@ -0,0 +1,6 @@ +class Simple { + + void m(int i) { + ++i; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java new file mode 100644 index 000000000000..94dcb427d56e --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/opassign/PostfixPrefixIntentionTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2015 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.siyeh.ipp.opassign; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +/** + * @see PostfixPrefixIntention + */ +public class PostfixPrefixIntentionTest extends IPPTestCase { + public void testSimple() { doTest(); } + public void testIncomplete() { assertIntentionNotAvailable(); } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("postfix.prefix.intention.name", "++i"); + } + + @Override + protected String getRelativePath() { + return "opassign/postfix_prefix"; + } +} From e063dc41c9f03e3863701ecc63edcbc6b2e8882a Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 29 Jun 2015 12:05:25 +0200 Subject: [PATCH 13/48] fix intention description template --- .../ChangeClassParametersIntention/after.java.template | 2 +- .../ChangeClassParametersIntention/before.java.template | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template index 413db792c422..bdcaa88da7c2 100644 --- a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template +++ b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template @@ -5,6 +5,6 @@ public class X { public int compareTo(String o) { return 0; } - } + }; } } \ No newline at end of file diff --git a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template index 96eb1b46dbd2..45429f9bbe36 100644 --- a/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template +++ b/java/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template @@ -1,10 +1,10 @@ public class X { { - new Comparable<Object>() { + new Comparable<Object>() { @Override public int compareTo(Object o) { return 0; } - } + }; } } \ No newline at end of file From aac660f7114a0b05bc110ce30f1c8e15817f5f69 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 29 Jun 2015 13:03:15 +0200 Subject: [PATCH 14/48] Add input checking and result highlighting to "Change class type parameter" intention --- .../ChangeClassParametersIntention.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java index 0a317ce4a497..e1bddda7f392 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java @@ -1,6 +1,7 @@ package com.intellij.refactoring.typeMigration.intentions; import com.intellij.codeInsight.FileModificationService; +import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.codeInsight.intention.impl.TypeExpression; @@ -101,13 +102,26 @@ public class ChangeClassParametersIntention extends PsiElementBaseIntentionActio if (!brokenOff) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); try { - final PsiType targetParam = elementFactory.createTypeFromText(myNewType, aClass); + final PsiType targetParam = elementFactory.createTypeFromText(myNewType, typeElement); + if (!(targetParam instanceof PsiClassType)) { + HintManager.getInstance().showErrorHint(editor, + JavaErrorMessages.message("generics.type.argument.cannot.be.of.primitive.type")); + return; + } + final PsiClassType classType = (PsiClassType)targetParam; + final PsiClass target = classType.resolve(); + if (target == null) { + HintManager.getInstance().showErrorHint(editor, JavaErrorMessages.message("cannot.resolve.symbol", + classType.getPresentableText())); + return; + } final TypeMigrationRules myRules = new TypeMigrationRules(((PsiAnonymousClass)aClass).getBaseClassType()); final PsiSubstitutor substitutor = result.getSubstitutor().put(typeParameter, targetParam); final PsiType targetClassType = elementFactory.createType(baseClass, substitutor); myRules.setMigrationRootType(targetClassType); myRules.setBoundScope(new LocalSearchScope(aClass)); - new TypeMigrationProcessor(project, ((PsiAnonymousClass)aClass).getBaseClassReference().getParameterList(), myRules).run(); + TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, myRules, + ((PsiAnonymousClass)aClass).getBaseClassReference().getParameterList()); } catch (IncorrectOperationException e) { HintManager.getInstance().showErrorHint(editor, "Incorrect type"); From 7f4effab9c21714ca709245b8ae1efeeb8f628e3 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 29 Jun 2015 13:05:02 +0200 Subject: [PATCH 15/48] IPP: Move "Create Enum Switch Branches" intention to "Control Flow" category --- plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml index ad885b84f380..b051209cf1cf 100644 --- a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml +++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml @@ -585,7 +585,7 @@ com.siyeh.ipp.enumswitch.CreateEnumSwitchBranchesIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.control.flow com.siyeh.ipp.constant.ConstantExpressionIntention From 1a2339d3947cad81dad66eca756a855ba4fa158b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 29 Jun 2015 13:09:40 +0200 Subject: [PATCH 16/48] Move intentions to better matching categories --- .../src/META-INF/IntentionPowerPack.xml | 6 +++--- resources/src/META-INF/IdeaPlugin.xml | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml index b051209cf1cf..8bea2a590c58 100644 --- a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml +++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml @@ -530,7 +530,7 @@ com.siyeh.ipp.exceptions.ObscureThrownExceptionsIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.declaration com.siyeh.ipp.opassign.ReplaceWithOperatorAssignmentIntention @@ -575,12 +575,12 @@ com.siyeh.ipp.asserttoif.AssertToIfIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.control.flow com.siyeh.ipp.asserttoif.IfToAssertionIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.control.flow com.siyeh.ipp.enumswitch.CreateEnumSwitchBranchesIntention diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index e4cb9111458d..92f24b612b1d 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -763,22 +763,22 @@ com.intellij.codeInsight.intention.impl.AddNotNullAnnotationIntention - Control Flow + Annotations AddAnnotationFix com.intellij.codeInsight.intention.impl.AddDeprecationAnnotationIntention - Control Flow + Annotations AddAnnotationFix com.intellij.codeInsight.intention.impl.AddNullableAnnotationIntention - Control Flow + Annotations AddAnnotationFix com.intellij.codeInspection.dataFlow.EditContractIntention - Control Flow + Annotations EditContractIntention @@ -787,7 +787,7 @@ com.intellij.codeInsight.intention.impl.DeannotateIntentionAction - Control Flow + Annotations com.intellij.codeInsight.intention.impl.CreateSwitchIntention @@ -876,7 +876,7 @@ com.intellij.codeInsight.intention.impl.AddOverrideAnnotationAction - Declaration + Annotations com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction @@ -961,7 +961,7 @@ com.intellij.codeInsight.intention.impl.BreakStringOnLineBreaksIntentionAction - Other + Strings From 56c94f63523ed8ba58fe225e0b0cf8bc6ac3dd91 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 29 Jun 2015 13:25:07 +0200 Subject: [PATCH 17/48] introduce "Try Statements" intention category --- .../src/META-INF/IntentionPowerPack.xml | 12 ++++++------ .../com/siyeh/IntentionPowerPackBundle.properties | 1 + resources/src/META-INF/IdeaPlugin.xml | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml index 8bea2a590c58..e82df033e4b4 100644 --- a/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml +++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml @@ -500,32 +500,32 @@ com.siyeh.ipp.exceptions.DetailExceptionsIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.ConvertCatchToThrowsIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.SplitMultiCatchIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.ReplaceArmWithTryFinallyIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.MergeNestedTryStatementsIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.SplitTryWithMultipleResourcesIntention com.siyeh.IntentionPowerPackBundle - intention.category.other + intention.category.try.statements com.siyeh.ipp.exceptions.ObscureThrownExceptionsIntention diff --git a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties index 0d5c4217eb4d..505c62657666 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties +++ b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties @@ -237,6 +237,7 @@ intention.category.comments=Comments intention.category.control.flow=Control Flow intention.category.strings=Strings intention.category.modifiers=Modifiers +intention.category.try.statements=Try Statements intention.category.other=Other #warnings diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 92f24b612b1d..26bc49d9633c 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -985,7 +985,7 @@ com.intellij.codeInsight.intention.impl.SurroundAutoCloseableAction - Declaration + Try Statements From 3daa8399fe11fc90a9ab7c467ce3ff98d7b2b1ce Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 29 Jun 2015 13:14:19 +0300 Subject: [PATCH 18/48] don't clear selection during repaint to avoid blinking of test's tree when selection is hold by a leaf of a collapsed node --- .../platform-api/src/com/intellij/ui/treeStructure/Tree.java | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index f63b457222f0..67bfb2fed12f 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -658,7 +658,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith public void holdSelection() { myHeldSelection = getSelectionPaths(); - clearSelection(); } public void unholdSelection() { From 3028d3e54a7298f40bf85d7fd97bd22d217858fe Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 29 Jun 2015 14:27:23 +0300 Subject: [PATCH 19/48] provide context for generated variable declaration: otherwise e.g. language level for generated element would be defined by project language level instead of module one --- .../introduceVariable/IntroduceVariableBase.java | 4 ++-- .../src/com/intellij/psi/PsiElementFactory.java | 10 +++++++++- .../intellij/psi/impl/PsiElementFactoryImpl.java | 13 +++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index 385fe8b578ee..9a7ab1f1f15d 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -872,7 +872,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase { } PsiDeclarationStatement declaration = JavaPsiFacade.getInstance(project).getElementFactory() - .createVariableDeclarationStatement(settings.getEnteredName(), selectedType.getType(), initializer); + .createVariableDeclarationStatement(settings.getEnteredName(), selectedType.getType(), initializer, container); if (!isInsideLoop) { declaration = addDeclaration(declaration, initializer); LOG.assertTrue(expr1.isValid()); @@ -978,7 +978,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase { if (initializer instanceof PsiNewExpression) { final PsiNewExpression newExpression = (PsiNewExpression)initializer; final PsiExpression tryToDetectDiamondNewExpr = ((PsiVariable)JavaPsiFacade.getElementFactory(initializer.getProject()) - .createVariableDeclarationStatement("x", expectedType, initializer).getDeclaredElements()[0]) + .createVariableDeclarationStatement("x", expectedType, initializer, initializer).getDeclaredElements()[0]) .getInitializer(); if (tryToDetectDiamondNewExpr instanceof PsiNewExpression && PsiDiamondTypeUtil.canCollapseToDiamond((PsiNewExpression)tryToDetectDiamondNewExpr, diff --git a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java index 99960483bfe7..235872ec67cb 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java @@ -367,6 +367,12 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor */ @NotNull PsiImportStatement createImportStatementOnDemand(@NotNull @NonNls String packageName) throws IncorrectOperationException; + /** + * @see #createVariableDeclarationStatement(String, PsiType, PsiExpression, PsiElement) + */ + @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, @Nullable PsiExpression initializer) + throws IncorrectOperationException; + /** * Creates a local variable declaration statement with the specified name, type and initializer, * optionally without reformatting the declaration. @@ -374,11 +380,13 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor * @param name the name of the variable to create. * @param type the type of the variable to create. * @param initializer the initializer for the variable. + * @param context the context for dummy holder * @return the variable instance. * @throws IncorrectOperationException if name is not a valid identifier or * type is not a valid type. */ - @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, @Nullable PsiExpression initializer) + @NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, + @Nullable PsiExpression initializer, @Nullable PsiElement context) throws IncorrectOperationException; /** diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java index ede86356fdfe..58169e20f193 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java @@ -609,9 +609,18 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps @NotNull @Override - public PsiDeclarationStatement createVariableDeclarationStatement(@NotNull String name, + public PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, @Nullable PsiExpression initializer) throws IncorrectOperationException { + return createVariableDeclarationStatement(name, type, initializer, null); + } + + @NotNull + @Override + public PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, + @NotNull PsiType type, + @Nullable PsiExpression initializer, + @Nullable PsiElement context) throws IncorrectOperationException { if (!isIdentifier(name)) { throw new IncorrectOperationException("\"" + name + "\" is not an identifier."); } @@ -620,7 +629,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps } String text = "X " + name + (initializer != null ? " = x" : "") + ";"; - PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, null); + PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, context); PsiVariable variable = (PsiVariable)statement.getDeclaredElements()[0]; replace(variable.getTypeElement(), createTypeElement(type), text); From c3e425aaed64c0beb30c0c81c6634a965dda8d84 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 29 Jun 2015 15:01:27 +0300 Subject: [PATCH 20/48] make coverage view dump aware (IDEA-141999) --- .../src/com/intellij/coverage/view/CoverageView.java | 4 +++- .../src/com/intellij/coverage/view/CoverageViewManager.java | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java index 524076cf086f..3385d5ab01bf 100644 --- a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java +++ b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageView.java @@ -32,6 +32,8 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.SystemInfo; @@ -301,7 +303,7 @@ public class CoverageView extends BorderLayoutPanel implements DataProvider, Dis } } - private class GoUpAction extends AnAction { + private class GoUpAction extends DumbAwareAction { private final CoverageViewTreeStructure myTreeStructure; diff --git a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java index 6e59698622f8..c4b8ae410552 100644 --- a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java +++ b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java @@ -18,7 +18,6 @@ import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import org.jetbrains.annotations.NotNull; -import javax.swing.*; import java.util.HashMap; import java.util.Map; @@ -44,7 +43,7 @@ public class CoverageViewManager implements PersistentStateComponent Date: Mon, 29 Jun 2015 15:48:59 +0300 Subject: [PATCH 21/48] disable static import sfor code fragments (EA-70109 - CCE: AddSingleMemberStaticImportAction.bindAllClassRefs) --- .../daemon/impl/quickfix/StaticImportMethodFix.java | 1 + .../intention/impl/AddSingleMemberStaticImportAction.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java index d59feaa805a4..9bde59121c4f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java @@ -83,6 +83,7 @@ public class StaticImportMethodFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return PsiUtil.isLanguageLevel5OrHigher(file) + && file instanceof PsiJavaFile && myMethodCall.getElement() != null && myMethodCall.getElement().isValid() && myMethodCall.getElement().getMethodExpression().getQualifierExpression() == null diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java index 1e63ee0055ca..1c2d0ae16fda 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java @@ -157,6 +157,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti if (availability.resolved instanceof PsiClass) { setText(CodeInsightBundle.message("intention.add.single.member.import.text", availability.qName)); } else { + if (!(element.getContainingFile() instanceof PsiJavaFile)) return false; setText(CodeInsightBundle.message("intention.add.single.member.static.import.text", availability.qName)); } } @@ -198,7 +199,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti if (resolved != null && findExistingImport(file, resolvedClass, referenceName) == null) { if (resolved instanceof PsiClass) { - ((PsiJavaFile) file).importClass((PsiClass) resolved); + ((PsiImportHolder) file).importClass((PsiClass) resolved); } else { PsiReferenceExpressionImpl.bindToElementViaStaticImport(resolvedClass, referenceName, ((PsiJavaFile)file).getImportList()); } From 962a8853f43511f0511ba87147e709d97f701ae4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 29 Jun 2015 15:55:06 +0300 Subject: [PATCH 22/48] EA-70062 - assert: PsiWalkingState.elementStarted --- .../refactoring/inline/ReferencedElementsCollector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java b/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java index fc1e2680c173..0372f065c0cb 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/ReferencedElementsCollector.java @@ -23,7 +23,7 @@ import java.util.HashSet; /** * @author ven */ -public class ReferencedElementsCollector extends JavaRecursiveElementWalkingVisitor { +public class ReferencedElementsCollector extends JavaRecursiveElementVisitor { final HashSet myReferencedMembers = new HashSet(); @Override public void visitReferenceExpression(PsiReferenceExpression expression) { From 4974d87c11e2be27d7bdcfd9f6903f51ade75114 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 29 Jun 2015 16:15:53 +0300 Subject: [PATCH 23/48] IDEA-79921 Suspend one thread while debugging --- .../src/com/intellij/debugger/actions/ResumeThreadAction.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java index a2e3129e634a..58c4ae70b651 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java @@ -46,6 +46,7 @@ public class ResumeThreadAction extends DebuggerAction{ final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference(); debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) { public void contextAction() throws Exception { + debugProcess.getSession().getXDebugSession().sessionResumed(); debugProcess.createResumeThreadCommand(getSuspendContext(), thread).run(); debuggerTreeNode.calcValue(); } From 1250f0fa66ffcfce611d17a500a860d2b5fb8633 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 29 Jun 2015 15:27:07 +0200 Subject: [PATCH 24/48] CompletionUtil: cleanup, javadoc --- .../completion/CompletionUtil.java | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java index b2817b0786e4..66759b08bdd2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java @@ -108,24 +108,6 @@ public class CompletionUtil { return mainData != null ? mainData : ourGenericCompletionData; } - /** @see CompletionDataEP */ - @Deprecated - public static void registerCompletionData(FileType fileType, NotNullLazyValue completionData) { - ourCustomCompletionDatas.put(fileType, completionData); - } - - /** @see CompletionDataEP */ - @Deprecated - public static void registerCompletionData(FileType fileType, final CompletionData completionData) { - registerCompletionData(fileType, new NotNullLazyValue() { - @Override - @NotNull - protected CompletionData compute() { - return completionData; - } - }); - } - @Nullable public static CompletionData getCompletionDataByFileType(FileType fileType) { for(CompletionDataEP ep: Extensions.getExtensions(CompletionDataEP.EP_NAME)) { @@ -254,6 +236,11 @@ public class CompletionUtil { return element == null ? psi : element; } + /** + * Filters _names for strings that match given matcher and sorts them. + * "Start matching" items go first, then others. + * Within both groups names are sorted lexicographically in a case-insensitive way. + */ public static LinkedHashSet sortMatching(final PrefixMatcher matcher, Collection _names) { ProgressManager.checkCanceled(); if (matcher.getPrefix().isEmpty()) { From 67eda1b686bb97fba97ccf1429fe4608d23361f2 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 29 Jun 2015 15:29:17 +0200 Subject: [PATCH 25/48] wrap content to JBUI.Panels --- .../intellij/diff/tools/ErrorDiffTool.java | 5 ++--- .../tools/fragmented/UnifiedDiffPanel.java | 9 ++------- .../diff/tools/util/SimpleDiffPanel.java | 7 ++----- .../intellij/dvcs/push/ui/VcsPushDialog.java | 19 +++++++------------ 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java b/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java index e9120e1284e3..1d835bc583ed 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/ErrorDiffTool.java @@ -31,12 +31,12 @@ import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.*; import java.util.List; public class ErrorDiffTool implements FrameDiffTool { @@ -69,8 +69,7 @@ public class ErrorDiffTool implements FrameDiffTool { myContext = context; myRequest = request; - myPanel = new JPanel(new BorderLayout()); - myPanel.add(createComponent(request), BorderLayout.CENTER); + myPanel = JBUI.Panels.simplePanel(createComponent(request)); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java index 862bcf897577..2730ddf23ac3 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedDiffPanel.java @@ -21,11 +21,11 @@ import com.intellij.diff.tools.util.base.DiffPanelBase; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.project.Project; import com.intellij.util.ui.AsyncProcessIcon; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.*; import static com.intellij.diff.util.DiffUtil.createMessagePanel; @@ -43,13 +43,8 @@ public class UnifiedDiffPanel extends DiffPanelBase { @NotNull DataProvider provider, @NotNull DiffContext context) { super(project, provider, context); - myBusyIcon = new AsyncProcessIcon.Big("UnifiedDiff"); - - JPanel centerPanel = new JPanel(new BorderLayout()); - centerPanel.add(myNotificationsPanel, BorderLayout.NORTH); - centerPanel.add(content, BorderLayout.CENTER); - + JPanel centerPanel = JBUI.Panels.simplePanel(content).addToTop(myNotificationsPanel); myContentPanel.add(centerPanel, GOOD_CONTENT); myContentPanel.add(myBusyIcon, LOADING_CONTENT); myContentPanel.add(createMessagePanel("Can not calculate diff. " + DiffTooBigException.MESSAGE), TOO_BIG_CONTENT); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java index d723d0c83fca..d2be844f7e66 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/SimpleDiffPanel.java @@ -19,10 +19,10 @@ import com.intellij.diff.DiffContext; import com.intellij.diff.tools.util.base.DiffPanelBase; import com.intellij.diff.util.DiffUtil; import com.intellij.openapi.actionSystem.DataProvider; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.*; public class SimpleDiffPanel extends DiffPanelBase { private static final String GOOD_CONTENT = "GoodContent"; @@ -32,10 +32,7 @@ public class SimpleDiffPanel extends DiffPanelBase { @NotNull DataProvider dataProvider, @NotNull DiffContext context) { super(context.getProject(), dataProvider, context); - - JPanel centerPanel = new JPanel(new BorderLayout()); - centerPanel.add(myNotificationsPanel, BorderLayout.NORTH); - centerPanel.add(editorPanel, BorderLayout.CENTER); + JPanel centerPanel = JBUI.Panels.simplePanel(editorPanel).addToTop(myNotificationsPanel); myContentPanel.add(centerPanel, GOOD_CONTENT); myContentPanel.add(DiffUtil.createMessagePanel("Error"), ERROR_CONTENT); diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java index ed635890bd70..66f97400fb77 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java @@ -27,12 +27,12 @@ import com.intellij.openapi.ui.OptionAction; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.ui.components.labels.ActionLink; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.components.BorderLayoutPanel; import net.miginfocom.swing.MigLayout; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.*; import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.List; @@ -66,20 +66,18 @@ public class VcsPushDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - JComponent rootPanel = new JPanel(new BorderLayout(0, JBUI.scale(2))); - rootPanel.add(myListPanel, BorderLayout.CENTER); JPanel optionsPanel = new JPanel(new MigLayout("ins 0 0, flowx")); for (VcsPushOptionsPanel panel : myAdditionalPanels.values()) { optionsPanel.add(panel); } optionsPanel.setBorder(JBUI.Borders.emptyTop(6)); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(optionsPanel); + BorderLayoutPanel panel = JBUI.Panels.simplePanel(optionsPanel); if (!myController.isForcePushEnabled()) { - panel.add(createForcePushInfoLabel(), BorderLayout.NORTH); + panel.addToTop(createForcePushInfoLabel()); } - rootPanel.add(panel, BorderLayout.SOUTH); - return rootPanel; + return JBUI.Panels.simplePanel(0, 2) + .addToCenter(myListPanel) + .addToBottom(panel); } @NotNull @@ -100,10 +98,7 @@ public class VcsPushDialog extends DialogWrapper { }); here.setFont(JBUI.Fonts.smallFont()); text.add(here); - JPanel wrap = new JPanel(new BorderLayout()); - wrap.add(text, BorderLayout.EAST); - wrap.setBorder(JBUI.Borders.emptyBottom(4)); - return wrap; + return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4)); } @Override From 6e64187976bce1af5b878d2cb66b8f9a8aca060d Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Mon, 29 Jun 2015 15:39:35 +0200 Subject: [PATCH 26/48] Rename python template service. --- resources-en/src/search/searchableOptions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources-en/src/search/searchableOptions.xml b/resources-en/src/search/searchableOptions.xml index e00643e4f211..7665f8efb8d9 100644 --- a/resources-en/src/search/searchableOptions.xml +++ b/resources-en/src/search/searchableOptions.xml @@ -20084,7 +20084,7 @@