diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java index e0fb1f6de051..4b76c29ba56f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/ProcessedModulesTable.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. @@ -28,6 +28,7 @@ import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.table.JBTable; import com.intellij.util.ui.EditableModel; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; @@ -71,7 +72,7 @@ public class ProcessedModulesTable extends JPanel { final JPanel panel = ToolbarDecorator.createDecorator(myTable) .disableUpDownActions() - .setPreferredSize(new Dimension(100, 155)) + .setPreferredSize(JBUI.size(100, 155)) .createPanel(); add(panel, BorderLayout.CENTER); diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java b/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java index 0998927415be..c58bbc80fcd6 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -39,12 +39,12 @@ import com.intellij.packaging.artifacts.*; import com.intellij.packaging.impl.compiler.ArtifactCompileScope; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBUI; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -135,7 +135,7 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider(pointers)); chooser.markElements(task.getArtifactPointers()); - chooser.setPreferredSize(new Dimension(400, 300)); + chooser.setPreferredSize(JBUI.size(400, 300)); DialogBuilder builder = new DialogBuilder(myProject); builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title")); diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java index daabf75e51db..098928e1eb52 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ViewTextAction.java @@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.EditorTextField; +import com.intellij.util.ui.JBUI; import com.intellij.xdebugger.impl.ui.TextViewer; import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree; import com.intellij.xdebugger.impl.ui.tree.actions.XFetchValueActionBase; @@ -95,7 +96,7 @@ public class ViewTextAction extends XFetchValueActionBase { protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new BorderLayout()); panel.add(myTextViewer, BorderLayout.CENTER); - panel.setPreferredSize(new Dimension(300, 200)); + panel.setPreferredSize(JBUI.size(300, 200)); return panel; } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java index 071e0a1cf909..1c50ab9c1596 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.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. @@ -255,7 +255,7 @@ public class PositionManagerImpl implements PositionManager { baseClassNameRef.set(parentClassName); } else { - LOG.error("The name of a parent of a local (anonymous) class is null"); + LOG.error("The name of a parent " + topLevelClass + " of a local (anonymous) class " + psiClass + " is null"); } } else { diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerDataViewsConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerDataViewsConfigurable.java index 8785e687eff3..23b9fbd29046 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerDataViewsConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerDataViewsConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -28,7 +28,7 @@ import com.intellij.openapi.util.registry.ui.RegistryCheckBox; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.StateRestoringCheckBox; import com.intellij.ui.classFilter.ClassFilterEditor; -import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -179,7 +179,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable { panel.add(myCbEnableToString, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0)); panel.add(myRbAllThatOverride, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 12, 0, 0), 0, 0)); panel.add(myRbFromList, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 12, 0, 0), 0, 0)); - myToStringFilterEditor.setMinimumSize(new Dimension(50, 100)); + myToStringFilterEditor.setMinimumSize(JBUI.size(50, 100)); panel.add(myToStringFilterEditor, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 12, 0, 0), 0, 0)); return panel; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/CompletedInputDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/CompletedInputDialog.java index 979723a6c7ae..6610c84058a6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/CompletedInputDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/CompletedInputDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -15,15 +15,16 @@ */ package com.intellij.debugger.ui; -import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.DebuggerBundle; -import com.intellij.debugger.engine.evaluation.TextWithImports; +import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.engine.evaluation.DefaultCodeFragmentFactory; +import com.intellij.debugger.engine.evaluation.TextWithImports; import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.impl.PositionUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.psi.PsiElement; +import com.intellij.util.ui.JBUI; import javax.swing.*; import java.awt.*; @@ -66,7 +67,7 @@ public class CompletedInputDialog extends DialogWrapper { myPanel.add(myCombo, new GridBagConstraints(0, 1, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 1, 0, 1), 0, 0)); - myPanel.setPreferredSize(new Dimension(200, 50)); + myPanel.setPreferredSize(JBUI.size(200, 50)); return myPanel; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/ExportDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/ExportDialog.java index e970653db12a..b67aaefcaf4d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/ExportDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/ExportDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -40,6 +40,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ScrollPaneFactory; +import com.intellij.util.ui.JBUI; import com.sun.jdi.*; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -102,7 +103,7 @@ public class ExportDialog extends DialogWrapper { protected JComponent createCenterPanel() { myTextArea.setEditable(false); JScrollPane pane = ScrollPaneFactory.createScrollPane(myTextArea); - pane.setPreferredSize(new Dimension(400, 300)); + pane.setPreferredSize(JBUI.size(400, 300)); return pane; } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditClassFiltersDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditClassFiltersDialog.java index 0f0de4a62455..1b623a946ee9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditClassFiltersDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditClassFiltersDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.classFilter.ClassFilterEditor; +import com.intellij.util.ui.JBUI; import javax.swing.*; import java.awt.*; @@ -55,13 +56,13 @@ public class EditClassFiltersDialog extends DialogWrapper { Box mainPanel = Box.createHorizontalBox(); myClassFilterEditor = new ClassFilterEditor(myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); - myClassFilterEditor.setPreferredSize(new Dimension(400, 200)); + myClassFilterEditor.setPreferredSize(JBUI.size(400, 200)); myClassFilterEditor.setBorder(IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"), false)); mainPanel.add(myClassFilterEditor); myClassExclusionFilterEditor = new ClassFilterEditor(myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); - myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200)); + myClassExclusionFilterEditor.setPreferredSize(JBUI.size(400, 200)); myClassExclusionFilterEditor.setBorder(IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"), false)); mainPanel.add(myClassExclusionFilterEditor); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java index dbc211120bed..2894a3997869 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/EditInstanceFiltersDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -15,13 +15,14 @@ */ package com.intellij.debugger.ui.breakpoints; -import com.intellij.ui.classFilter.ClassFilter; -import com.intellij.debugger.InstanceFilter; import com.intellij.debugger.DebuggerBundle; +import com.intellij.debugger.InstanceFilter; import com.intellij.debugger.ui.InstanceFilterEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.IdeBorderFactory; +import com.intellij.ui.classFilter.ClassFilter; +import com.intellij.util.ui.JBUI; import javax.swing.*; import java.awt.*; @@ -48,7 +49,7 @@ public class EditInstanceFiltersDialog extends DialogWrapper{ Box mainPanel = Box.createHorizontalBox(); myInstanceFilterEditor = new InstanceFilterEditor(myProject); - myInstanceFilterEditor.setPreferredSize(new Dimension(400, 200)); + myInstanceFilterEditor.setPreferredSize(JBUI.size(400, 200)); myInstanceFilterEditor.setBorder(IdeBorderFactory.createTitledBorder( DebuggerBundle.message("instance.filters.dialog.instance.filters.group"), false)); mainPanel.add(myInstanceFilterEditor); diff --git a/java/idea-ui/src/com/intellij/ide/util/importProject/ProjectLayoutPanel.java b/java/idea-ui/src/com/intellij/ide/util/importProject/ProjectLayoutPanel.java index 4e50df79e28f..44f232d1a36b 100644 --- a/java/idea-ui/src/com/intellij/ide/util/importProject/ProjectLayoutPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/importProject/ProjectLayoutPanel.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. @@ -34,6 +34,7 @@ import com.intellij.util.PlatformIcons; import com.intellij.util.StringBuilderSpinAllocator; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.FormBuilder; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -518,7 +519,7 @@ abstract class ProjectLayoutPanel extends JPanel { FormBuilder builder = FormBuilder.createFormBuilder().setVertical(true); builder.addLabeledComponent("&Name:", myNameField); builder.addLabeledComponent(getSplitDialogChooseFilesPrompt(), myChooser); - myChooser.setPreferredSize(new Dimension(450, 300)); + myChooser.setPreferredSize(JBUI.size(450, 300)); return builder.getPanel(); } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index 540502ba1761..78801b6fbb9a 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -43,6 +43,7 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -120,12 +121,12 @@ public class AddSupportForFrameworksPanel implements Disposable { JPanel treePanel = new JPanel(new BorderLayout()); treePanel.add(ScrollPaneFactory.createScrollPane(myFrameworksTree), BorderLayout.CENTER); - treePanel.setMinimumSize(new Dimension(200, 300)); + treePanel.setMinimumSize(JBUI.size(200, 300)); splitter.setFirstComponent(treePanel); myOptionsPanel = new JPanel(new CardLayout()); JPanel emptyCard = new JPanel(); - emptyCard.setPreferredSize(new Dimension(400, 100)); + emptyCard.setPreferredSize(JBUI.size(400, 100)); myOptionsPanel.add(EMPTY_CARD, emptyCard); splitter.setSecondComponent(myOptionsPanel); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java index 2bc8499e6c01..6844b8c11a66 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectConfigurable.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. @@ -46,6 +46,7 @@ import com.intellij.pom.java.LanguageLevel; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.FieldPanel; import com.intellij.ui.InsertPathAction; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -121,7 +122,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable() { public String convert(TreePath path) { diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java index 1a3ce4e0cea2..e473f5c67281 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java @@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author anna @@ -28,6 +29,7 @@ public class JavaVersionServiceImpl extends JavaVersionService { return JavaSdkVersionUtil.isAtLeast(element, version); } + @Nullable @Override public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { return JavaSdkVersionUtil.getJavaSdkVersion(element); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java index 59afecefda75..9c3e6d95f520 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.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. @@ -41,6 +41,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.VisibilityUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.DialogUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -111,8 +112,8 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac myVariableData = inputVariables; myHelpId = helpId; mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE); - mySignature.setPreferredSize(new Dimension(500, 100)); - mySignature.setMinimumSize(new Dimension(500, 100)); + mySignature.setPreferredSize(JBUI.size(500, 100)); + mySignature.setMinimumSize(JBUI.size(500, 100)); setTitle(title); myNameField = new NameSuggestionsField(suggestMethodNames(), myProject); @@ -456,7 +457,7 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac } myParamTable = createParameterTableComponent(); - myParamTable.setMinimumSize(new Dimension(500, 100)); + myParamTable.setMinimumSize(JBUI.size(500, 100)); myCenterPanel.add(myParamTable, BorderLayout.CENTER); final JTable table = UIUtil.findComponentOfType(myParamTable, JTable.class); myCenterPanel.add(SeparatorFactory.createSeparator("&Parameters", table), BorderLayout.NORTH); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java index 04042c004add..9a5a59ff8a80 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java @@ -52,6 +52,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Collection; import java.util.List; /** @@ -272,6 +273,14 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer } } + @Override + protected void addReferenceAtCaret(Collection refs) { + if (!isReplaceAllOccurrences() && getExpr() == null && !myReplaceSelf) { + return; + } + super.addReferenceAtCaret(refs); + } + private static void appendTypeCasts(List occurrenceMarkers, PsiFile file, Project project, diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java index fb356601ae45..080024807d11 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java @@ -15,8 +15,10 @@ */ package com.intellij.refactoring.introduceVariable; +import com.google.common.annotations.VisibleForTesting; import com.intellij.codeInsight.template.impl.TemplateManagerImpl; import com.intellij.codeInsight.template.impl.TemplateState; +import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.ui.ListCellRendererWrapper; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -37,6 +39,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.util.Collection; /** * User: anna @@ -49,7 +52,8 @@ public class ReassignVariableUtil { private ReassignVariableUtil() { } - static boolean reassign(final Editor editor) { + @VisibleForTesting + public static boolean reassign(final Editor editor) { final SmartPsiElementPointer pointer = editor.getUserData(DECLARATION_KEY); final PsiDeclarationStatement declaration = pointer != null ? pointer.getElement() : null; final PsiType type = getVariableType(declaration); @@ -138,18 +142,13 @@ public class ReassignVariableUtil { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(variable.getProject()); final String chosenVariableName = variable.getName(); //would generate red code for final variables - PsiElement newDeclaration = elementFactory.createStatementFromText(chosenVariableName + " = " + initializer.getText() + ";", - declaration); + PsiElement newDeclaration = elementFactory.createStatementFromText(chosenVariableName + " = " + initializer.getText() + ";", declaration); + final Collection references = ReferencesSearch.search(var).findAll(); newDeclaration = declaration.replace(newDeclaration); - final PsiFile containingFile = newDeclaration.getContainingFile(); - final RangeMarker[] occurrenceMarkers = editor.getUserData(OCCURRENCES_KEY); - if (occurrenceMarkers != null) { - for (RangeMarker marker : occurrenceMarkers) { - final PsiElement refVariableElement = containingFile.findElementAt(marker.getStartOffset()); - final PsiExpression expression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class); - if (expression != null) { - expression.replace(elementFactory.createExpressionFromText(chosenVariableName, newDeclaration)); - } + for (PsiReference reference : references) { + final PsiElement element = reference.getElement(); + if (element instanceof PsiExpression) { + element.replace(elementFactory.createExpressionFromText(chosenVariableName, newDeclaration)); } } } diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java index ed51aa5120b4..43758f620342 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java @@ -718,6 +718,7 @@ public class RefactoringUtil { PsiUtil.setModifierProperty(method, PsiModifier.FINAL, false); PsiUtil.setModifierProperty(method, PsiModifier.SYNCHRONIZED, false); PsiUtil.setModifierProperty(method, PsiModifier.NATIVE, false); + PsiUtil.setModifierProperty(method, PsiModifier.PUBLIC, false); removeFinalParameters(method); } diff --git a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java index 5108c592c6ac..fe1873fdfd8d 100644 --- a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java +++ b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java @@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class JavaVersionService { public static JavaVersionService getInstance() { @@ -33,6 +34,7 @@ public class JavaVersionService { return PsiUtil.getLanguageLevel(element).isAtLeast(version.getMaxLanguageLevel()); } + @Nullable public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { return JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element)); } diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename.java new file mode 100644 index 000000000000..eeb6ae4c7329 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename.java @@ -0,0 +1,5 @@ +class C { + { + Runnable r = () -> System.out.println("extract me"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename_after.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename_after.java new file mode 100644 index 000000000000..e9ef5b66af89 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/placeInsideLoopAndRename_after.java @@ -0,0 +1,8 @@ +class C { + { + Runnable r = () -> { + String expr = "extract me"; + System.out.println(expr); + }; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple.java new file mode 100644 index 000000000000..1acccaf6b216 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple.java @@ -0,0 +1,6 @@ +class C { + { + String s; + System.out.println(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple_after.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple_after.java new file mode 100644 index 000000000000..107bdd38a5c7 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignSimple_after.java @@ -0,0 +1,7 @@ +class C { + { + String s; + s = ""; + System.out.println(s); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody.java new file mode 100644 index 000000000000..5654220a05b6 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody.java @@ -0,0 +1,7 @@ +class C { + { + String strA = "bar"; + if (true + ) System.out.println(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody_after.java b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody_after.java new file mode 100644 index 000000000000..aa38c9719ff5 --- /dev/null +++ b/java/java-tests/testData/refactoring/inplaceIntroduceVariable/reassignWhenVariableWasPutInLoopBody_after.java @@ -0,0 +1,10 @@ +class C { + { + String strA = "bar"; + if (true + ) { + strA = ""; + System.out.println(strA); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pullUp/AsDefault.java b/java/java-tests/testData/refactoring/pullUp/AsDefault.java index 3379c19a779e..05cf9b018841 100644 --- a/java/java-tests/testData/refactoring/pullUp/AsDefault.java +++ b/java/java-tests/testData/refactoring/pullUp/AsDefault.java @@ -3,5 +3,5 @@ interface Bar { } interface Base { } class Foo implements Base { - void get(Bar bar) { } + public void get(Bar bar) { } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java index 6da536d86d2c..ad12ef131055 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingProcessingOnDocumentModificationTest.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.codeInsight.folding.CodeFoldingManager; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.FoldRegion; import com.intellij.testFramework.TestFileType; @@ -55,7 +56,31 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT assertFalse(foldRegion.isExpanded()); } + public void testCollapseAllHappensBeforeFirstCodeFoldingPass() throws Exception { + init("class Foo {\n" + + " void m() {\n" + + " System.out.println();\n" + + " System.out.println();\n" + + " }\n" + + "}", TestFileType.JAVA); + + buildInitialFoldRegions(); + executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS); + runFoldingPass(true); + assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length); + } + + private static void buildInitialFoldRegions() { + CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor); + } + private static void updateFoldRegions() { CodeFoldingManager.getInstance(getProject()).updateFoldRegions(myEditor); } + + private static void runFoldingPass(boolean firstTime) { + Runnable runnable = CodeFoldingManager.getInstance(getProject()).updateFoldRegionsAsync(myEditor, firstTime); + assertNotNull(runnable); + runnable.run(); + } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceVariableTest.java index 6e75fbb2bdd8..4c434ed86517 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceVariableTest.java @@ -55,6 +55,15 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe }); } + public void testPlaceInsideLoopAndRename() throws Exception { + doTest(new Pass() { + @Override + public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) { + type("expr"); + } + }); + } + public void testRanges() throws Exception { doTest(new Pass() { @Override diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InplaceReassignVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InplaceReassignVariableTest.java new file mode 100644 index 000000000000..45ec638d7cba --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/refactoring/InplaceReassignVariableTest.java @@ -0,0 +1,67 @@ +/* + * 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.refactoring; + +import com.intellij.codeInsight.template.impl.TemplateManagerImpl; +import com.intellij.codeInsight.template.impl.TemplateState; +import com.intellij.refactoring.introduceVariable.ReassignVariableUtil; + +public class InplaceReassignVariableTest extends AbstractJavaInplaceIntroduceTest { + + @Override + protected void runTest() throws Throwable { + doRunTest(); + } + + public void testReassignSimple() throws Exception { + doTest(); + } + + public void testReassignWhenVariableWasPutInLoopBody() throws Exception { + doTest(); + } + + private void doTest() { + String name = getTestName(true); + configureByFile(getBasePath() + name + getExtension()); + final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled(); + try { + TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable()); + getEditor().getSettings().setVariableInplaceRenameEnabled(true); + + invokeRefactoring(); + ReassignVariableUtil.reassign(getEditor()); + + TemplateState state = TemplateManagerImpl.getTemplateState(getEditor()); + assert state != null; + state.gotoEnd(false); + checkResultByFile(getBasePath() + name + "_after" + getExtension()); + } + finally { + getEditor().getSettings().setVariableInplaceRenameEnabled(enabled); + } + } + + @Override + protected String getBasePath() { + return "/refactoring/inplaceIntroduceVariable/"; + } + + @Override + protected MyIntroduceHandler createIntroduceHandler() { + return new InplaceIntroduceVariableTest.MyIntroduceVariableHandler(); + } +} diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index 2f82e8df8b21..f8f576dec0fa 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -16,10 +16,7 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.LowMemoryWatcher; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.UserDataHolder; -import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.SmartList; @@ -84,7 +81,7 @@ import java.util.concurrent.atomic.AtomicReference; public class IncProjectBuilder { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder"); - private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index"; + private static final String CLASSPATH_INDEX_FILE_NAME = "classpath.index"; private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false")); private static final boolean SYNC_DELETE = Boolean.parseBoolean(System.getProperty("jps.sync.delete", SystemInfo.isWindows ? "true" : "false")); private static final GlobalContextKey>> TARGET_WITH_CLEARED_OUTPUT = GlobalContextKey.create("_targets_with_cleared_output_"); @@ -334,7 +331,25 @@ public class IncProjectBuilder { BuildRunner.PARALLEL_BUILD_ENABLED); context.addBuildListener(new ChainedTargetsBuildListener(context)); + + //Deletes class loader classpath index files for changed output roots + context.addBuildListener(new BuildListener() { + @Override + public void filesGenerated(Collection> paths) { + final Set outputs = new THashSet(FileUtil.FILE_HASHING_STRATEGY); + for (Pair pair : paths) { + outputs.add(new File(pair.getFirst())); + } + for (File root : outputs) { + //noinspection ResultOfMethodCallIgnored + new File(root, CLASSPATH_INDEX_FILE_NAME).delete(); + } + } + @Override + public void filesDeleted(Collection paths) { + } + }); for (TargetBuilder builder : myBuilderRegistry.getTargetBuilders()) { builder.buildStarted(context); } @@ -965,7 +980,7 @@ public class IncProjectBuilder { File outputDir = ((ModuleBuildTarget)target).getOutputDir(); if (outputDir != null && outputDirs.add(outputDir)) { try { - BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FINE_NAME))); + BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outputDir, CLASSPATH_INDEX_FILE_NAME))); try { writeIndex(writer, outputDir, ""); } diff --git a/platform/bootstrap/src/com/intellij/idea/Main.java b/platform/bootstrap/src/com/intellij/idea/Main.java index 373f8dbf7a38..74f7736c168e 100644 --- a/platform/bootstrap/src/com/intellij/idea/Main.java +++ b/platform/bootstrap/src/com/intellij/idea/Main.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. @@ -22,6 +22,7 @@ import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.ArrayUtilRt; import com.intellij.util.Restarter; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -228,7 +229,7 @@ public class Main { textPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); - int maxHeight = Math.min(600, Toolkit.getDefaultToolkit().getScreenSize().height - 150); + int maxHeight = Math.min(JBUI.scale(600), Toolkit.getDefaultToolkit().getScreenSize().height - 150); Dimension component = scrollPane.getPreferredSize(); if (component.height >= maxHeight) { Object setting = UIManager.get("ScrollBar.width"); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java index ab978d5f3bd9..e422328c8575 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -17,6 +17,7 @@ package com.intellij.openapi.actionSystem; import com.intellij.ui.switcher.QuickActionProvider; import com.intellij.ui.switcher.SwitchProvider; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -47,9 +48,9 @@ public interface ActionToolbar extends SwitchProvider, QuickActionProvider { int AUTO_LAYOUT_POLICY = 2; /** This is default minimum size of the toolbar button */ - Dimension DEFAULT_MINIMUM_BUTTON_SIZE = new Dimension(25, 25); + Dimension DEFAULT_MINIMUM_BUTTON_SIZE = JBUI.size(25, 25); - Dimension NAVBAR_MINIMUM_BUTTON_SIZE = new Dimension(20, 20); + Dimension NAVBAR_MINIMUM_BUTTON_SIZE = JBUI.size(20, 20); /** * @return component which represents the tool bar on UI diff --git a/platform/icons/src/debugger/console_log.png b/platform/icons/src/debugger/console_log.png new file mode 100644 index 000000000000..9b18e1e769a8 Binary files /dev/null and b/platform/icons/src/debugger/console_log.png differ diff --git a/platform/icons/src/debugger/console_log@2x.png b/platform/icons/src/debugger/console_log@2x.png new file mode 100644 index 000000000000..993bdd5e4576 Binary files /dev/null and b/platform/icons/src/debugger/console_log@2x.png differ diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java index 04f02ab9b380..0fcccb7c742e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/PasteHandler.java @@ -49,11 +49,15 @@ import com.intellij.util.Producer; import com.intellij.util.containers.HashMap; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; public class PasteHandler extends EditorActionHandler implements EditorTextInsertHandler { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.PasteHandler"); @@ -73,6 +77,9 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser @Override public void execute(final Editor editor, final DataContext dataContext, @Nullable final Producer producer) { + final Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(producer); + if (transferable == null) return; + if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; final Document document = editor.getDocument(); @@ -80,15 +87,18 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser return; } - DataContext context = dataContext; - if (producer != null) { - context = new DataContext() { - @Override - public Object getData(@NonNls String dataId) { - return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? producer : dataContext.getData(dataId); - } - }; - } + DataContext context = new DataContext() { + @Override + public Object getData(@NonNls String dataId) { + return PasteAction.TRANSFERABLE_PROVIDER.is(dataId) ? new Producer() { + @Nullable + @Override + public Transferable produce() { + return transferable; + } + } : dataContext.getData(dataId); + } + }; final Project project = editor.getProject(); if (project == null || editor.isColumnMode() || editor.getCaretModel().getCaretCount() > 1) { @@ -114,7 +124,7 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser return; } } - doPaste(editor, project, file, document, producer); + doPaste(editor, project, file, document, transferable); } catch (ReadOnlyFragmentModificationException e) { EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e); @@ -128,152 +138,137 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser final Project project, final PsiFile file, final Document document, - final Producer producer) { - Transferable content = null; + @NotNull final Transferable content) { + CopyPasteManager.getInstance().stopKillRings(); + + String text = null; + try { + text = (String)content.getTransferData(DataFlavor.stringFlavor); + } + catch (Exception e) { + editor.getComponent().getToolkit().beep(); + } + if (text == null) return; - if (producer != null) { - content = producer.produce(); + final CodeInsightSettings settings = CodeInsightSettings.getInstance(); + + final Map> extraData = new HashMap>(); + Collection allValues = new ArrayList(); + + DumbService.getInstance(project).setAlternativeResolveEnabled(true); + try { + for (CopyPastePostProcessor processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) { + List data = processor.extractTransferableData(content); + if (!data.isEmpty()) { + extraData.put(processor, data); + allValues.addAll(data); + } + } + } + finally { + DumbService.getInstance(project).setAlternativeResolveEnabled(false); + } + + text = TextBlockTransferable.convertLineSeparators(editor, text, allValues); + + final CaretModel caretModel = editor.getCaretModel(); + final SelectionModel selectionModel = editor.getSelectionModel(); + final int col = caretModel.getLogicalPosition().column; + + // There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located + // inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column + // then, hence, inserted block of text should be indented according to the selection start as well. + final int blockIndentAnchorColumn; + final int caretOffset = caretModel.getOffset(); + if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) { + blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column; } else { - CopyPasteManager manager = CopyPasteManager.getInstance(); - if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) { - content = manager.getContents(); - if (content != null) { - manager.stopKillRings(); - } - } + blockIndentAnchorColumn = col; } - if (content != null) { - String text = null; - try { - text = (String)content.getTransferData(DataFlavor.stringFlavor); - } - catch (Exception e) { - editor.getComponent().getToolkit().beep(); - } - if (text == null) return; + // We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any). - final CodeInsightSettings settings = CodeInsightSettings.getInstance(); + RawText rawText = RawText.fromTransferable(content); + String newText = text; + for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) { + newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText); + } + int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK; + text = newText; - final Map> extraData = new HashMap>(); - Collection allValues = new ArrayList(); - - DumbService.getInstance(project).setAlternativeResolveEnabled(true); - try { - for (CopyPastePostProcessor processor : Extensions.getExtensions(CopyPastePostProcessor.EP_NAME)) { - List data = processor.extractTransferableData(content); - if (!data.isEmpty()) { - extraData.put(processor, data); - allValues.addAll(data); - } + if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) { + indentOptions = CodeInsightSettings.INDENT_BLOCK; + } + + final String _text = text; + ApplicationManager.getApplication().runWriteAction( + new Runnable() { + @Override + public void run() { + EditorModificationUtil.insertStringAtCaret(editor, _text, false, true); } } - finally { - DumbService.getInstance(project).setAlternativeResolveEnabled(false); - } + ); - text = TextBlockTransferable.convertLineSeparators(editor, text, allValues); + int length = text.length(); + int offset = caretModel.getOffset() - length; + if (offset < 0) { + length += offset; + offset = 0; + } + final RangeMarker bounds = document.createRangeMarker(offset, offset + length); - final CaretModel caretModel = editor.getCaretModel(); - final SelectionModel selectionModel = editor.getSelectionModel(); - final int col = caretModel.getLogicalPosition().column; + caretModel.moveToOffset(bounds.getEndOffset()); + editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); + selectionModel.removeSelection(); - // There is a possible case that we want to perform paste while there is an active selection at the editor and caret is located - // inside it (e.g. Ctrl+A is pressed while caret is not at the zero column). We want to insert the text at selection start column - // then, hence, inserted block of text should be indented according to the selection start as well. - final int blockIndentAnchorColumn; - final int caretOffset = caretModel.getOffset(); - if (selectionModel.hasSelection() && caretOffset >= selectionModel.getSelectionStart()) { - blockIndentAnchorColumn = editor.offsetToLogicalPosition(selectionModel.getSelectionStart()).column; - } - else { - blockIndentAnchorColumn = col; - } + final Ref indented = new Ref(Boolean.FALSE); + for (Map.Entry> e : extraData.entrySet()) { + //noinspection unchecked + e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue()); + } - // We assume that EditorModificationUtil.insertStringAtCaret() is smart enough to remove currently selected text (if any). + boolean pastedTextContainsWhiteSpacesOnly = + CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset(); - RawText rawText = RawText.fromTransferable(content); - String newText = text; - for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) { - newText = preProcessor.preprocessOnPaste(project, file, editor, newText, rawText); - } - int indentOptions = text.equals(newText) ? settings.REFORMAT_ON_PASTE : CodeInsightSettings.REFORMAT_BLOCK; - text = newText; + VirtualFile virtualFile = file.getVirtualFile(); + if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) { + final int indentOptions1 = indentOptions; - if (LanguageFormatting.INSTANCE.forContext(file) == null && indentOptions != CodeInsightSettings.NO_REFORMAT) { - indentOptions = CodeInsightSettings.INDENT_BLOCK; - } - - final String _text = text; ApplicationManager.getApplication().runWriteAction( new Runnable() { @Override public void run() { - EditorModificationUtil.insertStringAtCaret(editor, _text, false, true); + PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document); + switch (indentOptions1) { + case CodeInsightSettings.INDENT_BLOCK: + if (!indented.get()) { + indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn); + } + break; + + case CodeInsightSettings.INDENT_EACH_LINE: + if (!indented.get()) { + indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); + } + break; + + case CodeInsightSettings.REFORMAT_BLOCK: + indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method + reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); + break; + } } } ); + } - int length = text.length(); - int offset = caretModel.getOffset() - length; - if (offset < 0) { - length += offset; - offset = 0; - } - final RangeMarker bounds = document.createRangeMarker(offset, offset + length); - + if (bounds.isValid()) { caretModel.moveToOffset(bounds.getEndOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); selectionModel.removeSelection(); - - final Ref indented = new Ref(Boolean.FALSE); - for (Map.Entry> e : extraData.entrySet()) { - //noinspection unchecked - e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue()); - } - - boolean pastedTextContainsWhiteSpacesOnly = - CharArrayUtil.shiftForward(document.getCharsSequence(), bounds.getStartOffset(), " \n\t") >= bounds.getEndOffset(); - - VirtualFile virtualFile = file.getVirtualFile(); - if (!pastedTextContainsWhiteSpacesOnly && (virtualFile == null || !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile))) { - final int indentOptions1 = indentOptions; - - ApplicationManager.getApplication().runWriteAction( - new Runnable() { - @Override - public void run() { - PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document); - switch (indentOptions1) { - case CodeInsightSettings.INDENT_BLOCK: - if (!indented.get()) { - indentBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset(), blockIndentAnchorColumn); - } - break; - - case CodeInsightSettings.INDENT_EACH_LINE: - if (!indented.get()) { - indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); - } - break; - - case CodeInsightSettings.REFORMAT_BLOCK: - indentEachLine(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); // this is needed for example when inserting a comment before method - reformatBlock(project, editor, bounds.getStartOffset(), bounds.getEndOffset()); - break; - } - } - } - ); - } - - if (bounds.isValid()) { - caretModel.moveToOffset(bounds.getEndOffset()); - editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); - selectionModel.removeSelection(); - editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds)); - } + editor.putUserData(EditorEx.LAST_PASTED_REGION, TextRange.create(bounds)); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java index 07bd92cb687a..333725920ac6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java @@ -281,6 +281,13 @@ public class FoldingUpdate { } public static class FoldingMap extends MultiMap{ + public FoldingMap() { + } + + public FoldingMap(FoldingMap map) { + super(map); + } + @NotNull @Override protected Map> createMap() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java index ad0992d6128f..3e0d504fddd2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/UpdateFoldRegionsOperation.java @@ -76,11 +76,14 @@ class UpdateFoldRegionsOperation implements Runnable { FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel(); Map rangeToExpandStatusMap = newTroveMap(); - removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap); + // FoldingUpdate caches instances of our object, so they must be immutable. + FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap); + + removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap); Map shouldExpand = newTroveMap(); Map groupExpand = newTroveMap(); - List newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand); + List newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand); applyExpandStatus(newRegions, shouldExpand, groupExpand); } @@ -100,14 +103,14 @@ class UpdateFoldRegionsOperation implements Runnable { private List addNewRegions(@NotNull EditorFoldingInfo info, @NotNull FoldingModelEx foldingModel, - @NotNull Map rangeToExpandStatusMap, + FoldingUpdate.FoldingMap elementsToFold, @NotNull Map rangeToExpandStatusMap, @NotNull Map shouldExpand, @NotNull Map groupExpand) { List newRegions = newArrayList(); SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject); - for (PsiElement element : myElementsToFoldMap.keySet()) { + for (PsiElement element : elementsToFold.keySet()) { ProgressManager.checkCanceled(); - final Collection descriptors = myElementsToFoldMap.get(element); + final Collection descriptors = elementsToFold.get(element); for (FoldingDescriptor descriptor : descriptors) { FoldingGroup group = descriptor.getGroup(); TextRange range = descriptor.getRange(); @@ -165,7 +168,7 @@ class UpdateFoldRegionsOperation implements Runnable { private void removeInvalidRegions(@NotNull EditorFoldingInfo info, @NotNull FoldingModelEx foldingModel, - @NotNull Map rangeToExpandStatusMap) { + FoldingUpdate.FoldingMap elementsToFold, @NotNull Map rangeToExpandStatusMap) { List toRemove = newArrayList(); InjectedLanguageManager injectedManager = InjectedLanguageManager.getInstance(myProject); for (FoldRegion region : foldingModel.getAllFoldRegions()) { @@ -176,7 +179,7 @@ class UpdateFoldRegionsOperation implements Runnable { if (isInjected != myForInjected) continue; } final Collection descriptors; - if (element != null && !(descriptors = myElementsToFoldMap.get(element)).isEmpty()) { + if (element != null && !(descriptors = elementsToFold.get(element)).isEmpty()) { boolean matchingDescriptorFound = false; FoldingDescriptor[] array = descriptors.toArray(new FoldingDescriptor[descriptors.size()]); for (FoldingDescriptor descriptor : array) { @@ -194,7 +197,7 @@ class UpdateFoldRegionsOperation implements Runnable { break; } else { - myElementsToFoldMap.remove(element, descriptor); + elementsToFold.remove(element, descriptor); } } } diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index be22d49c1672..15157890609b 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.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. @@ -61,6 +61,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.SideBorder; import com.intellij.util.*; import com.intellij.util.ui.AbstractLayoutManager; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -230,8 +231,8 @@ public class LanguageConsoleImpl implements LanguageConsole, DataProvider { if (SEPARATOR_THICKNESS > 0 && myShowSeparatorLine) { myHistoryViewer.getComponent().setBorder(new SideBorder(JBColor.LIGHT_GRAY, SideBorder.BOTTOM)); } - myHistoryViewer.getComponent().setMinimumSize(new Dimension(0, 0)); - myHistoryViewer.getComponent().setPreferredSize(new Dimension(0, 0)); + myHistoryViewer.getComponent().setMinimumSize(JBUI.emptySize()); + myHistoryViewer.getComponent().setPreferredSize(JBUI.emptySize()); myHistoryViewer.setCaretEnabled(false); myConsoleEditor.setHorizontalScrollbarVisible(true); diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java index 6628c78f1851..7d116a0bbb1f 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.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. @@ -95,7 +95,7 @@ public abstract class RunTab implements DataProvider, Disposable { logConsoleManager = new LogConsoleManagerBase(myProject, mySearchScope) { @Override protected Icon getDefaultIcon() { - return AllIcons.Debugger.Console; + return AllIcons.Debugger.Console_log; } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 4bcc12c7164f..6ce52a5ab56e 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -1682,10 +1682,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA myProgressIndicator, new Processor() { @Override public boolean process(Object o) { - if (o instanceof PsiElement && !(((PsiElement)o).getParent() instanceof PsiFile)) { + if (isSymbol(o)) { final PsiElement element = (PsiElement)o; final PsiFile file = element.getContainingFile(); - if (!myListModel.contains(o) && + if (!myListModel.contains(o) && !symbols.contains(o) && //some elements are non-physical like DB columns (file == null || (file.getVirtualFile() != null && (includeLibs || scope.accept(file.getVirtualFile()))))) { symbols.add(o); @@ -1698,6 +1698,16 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA return symbols; } + protected boolean isSymbol(Object o) { + if (o instanceof PsiElement) { + final PsiElement e = (PsiElement)o; + //todo[kb] need a better way to avoid mixing java classes with symbols. Same to other languages where + //todo[kb] symbol provider returns classes. We need kind of suppressor API & EP here. + return !e.getLanguage().is(Language.findLanguageByID("JAVA")) || !(e.getParent() instanceof PsiFile); + } + return false; + } + private SearchResult getClasses(String pattern, boolean includeLibs, final int max, ChooseByNamePopup chooseByNamePopup) { final SearchResult classes = new SearchResult(); if (chooseByNamePopup == null) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java index f36f1e8f9bc7..d4802b60188c 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeEditorPanel.java @@ -38,6 +38,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.Alarm; +import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import com.intellij.util.ui.ColorIcon; import com.intellij.util.ui.UIUtil; @@ -237,11 +238,11 @@ public class ScopeEditorPanel { myPackageTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { - final boolean recursiveEnabled = isButtonEnabled(true, e.getPaths(), e); + final boolean recursiveEnabled = isButtonEnabled(true); includeRec.setEnabled(recursiveEnabled); excludeRec.setEnabled(recursiveEnabled); - final boolean nonRecursiveEnabled = isButtonEnabled(false, e.getPaths(), e); + final boolean nonRecursiveEnabled = isButtonEnabled(false); include.setEnabled(nonRecursiveEnabled); exclude.setEnabled(nonRecursiveEnabled); } @@ -281,19 +282,6 @@ public class ScopeEditorPanel { return buttonsPanel; } - static boolean isButtonEnabled(boolean rec, TreePath[] paths, TreeSelectionEvent e) { - if (paths != null) { - for (TreePath path : paths) { - if (!e.isAddedPath(path)) continue; - final PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent(); - if (PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE).createPackageSet(node, rec) != null) { - return true; - } - } - } - return false; - } - boolean isButtonEnabled(boolean rec) { final TreePath[] paths = myPackageTree.getSelectionPaths(); if (paths != null) { diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java index 003af8789fc9..fd36104424f9 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java @@ -197,6 +197,17 @@ public class EditorModificationUtil { zeroWidthBlockSelectionAtCaretColumn(editor, caretLine, caretLine); } + @Nullable + public static Transferable getContentsToPasteToEditor(@Nullable Producer producer) { + if (producer == null) { + CopyPasteManager manager = CopyPasteManager.getInstance(); + return manager.areDataFlavorsAvailable(DataFlavor.stringFlavor) ? manager.getContents() : null; + } + else { + return producer.produce(); + } + } + @Nullable public static String getStringContent(@NotNull Transferable content) { RawText raw = RawText.fromTransferable(content); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorWriteActionHandler.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorWriteActionHandler.java index ba4111af46e9..879f921afe67 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorWriteActionHandler.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorWriteActionHandler.java @@ -23,6 +23,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.Nullable; +/** + * Base class for {@link EditorActionHandler} instances, which need to modify the document. + * Implementations should override {@link #executeWriteAction(Editor, Caret, DataContext)}. + */ public abstract class EditorWriteActionHandler extends EditorActionHandler { private boolean inExecution; @@ -34,7 +38,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler { } @Override - public final void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) { + public void doExecute(final Editor editor, @Nullable final Caret caret, final DataContext dataContext) { if (editor.isViewer()) return; if (dataContext != null) { @@ -63,7 +67,7 @@ public abstract class EditorWriteActionHandler extends EditorActionHandler { /** * @deprecated Use/override - * {@link #executeWriteAction(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)} + * {@link #executeWriteAction(Editor, Caret, DataContext)} * instead. */ public void executeWriteAction(Editor editor, DataContext dataContext) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/TextFieldWithBrowseButton.java b/platform/platform-api/src/com/intellij/openapi/ui/TextFieldWithBrowseButton.java index c29bc137dee0..04c8438f3897 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/TextFieldWithBrowseButton.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/TextFieldWithBrowseButton.java @@ -49,7 +49,7 @@ public class TextFieldWithBrowseButton extends ComponentWithBrowseButton extends JPanel implements Component myTableModel = new MyTableModel(elementsCanBeMarked); myTable = new Table(myTableModel); myTable.setShowGrid(false); - myTable.setIntercellSpacing(new Dimension(0, 0)); + myTable.setIntercellSpacing(JBUI.emptySize()); myTable.setTableHeader(null); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); myTable.setColumnSelectionAllowed(false); diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 897590d7096f..453681b96b1e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.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. @@ -83,7 +83,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { */ private final List myComponentBounds = new ArrayList(); - private Dimension myMinimumButtonSize = new Dimension(0, 0); + private Dimension myMinimumButtonSize = JBUI.emptySize(); /** * @see ActionToolbar#getLayoutPolicy() @@ -753,7 +753,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { public Dimension getPreferredSize() { final ArrayList bounds = new ArrayList(); calculateBounds(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), bounds); - if (bounds.isEmpty()) return new Dimension(0, 0); + if (bounds.isEmpty()) return JBUI.emptySize(); int xLeft = Integer.MAX_VALUE; int yTop = Integer.MAX_VALUE; int xRight = Integer.MIN_VALUE; @@ -798,10 +798,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { public MySeparator() { if (myOrientation == SwingConstants.HORIZONTAL) { - mySize = new Dimension(6, 24); + mySize = JBUI.size(6, 24); } else { - mySize = new Dimension(24, 6); + mySize = JBUI.size(24, 6); } } @@ -1247,7 +1247,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { myMinimalMode = minimalMode; if (myMinimalMode) { - setMinimumButtonSize(new Dimension(0, 0)); + setMinimumButtonSize(JBUI.emptySize()); setLayoutPolicy(NOWRAP_LAYOUT_POLICY); setBorder(new EmptyBorder(0, 0, 0, 0)); setOpaque(false); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/BasePasteHandler.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/BasePasteHandler.java new file mode 100644 index 000000000000..cf3bbecae8c6 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/BasePasteHandler.java @@ -0,0 +1,57 @@ +/* + * 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.editor.actions; + +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.editor.Caret; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorCopyPasteHelper; +import com.intellij.openapi.editor.EditorModificationUtil; +import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler; +import com.intellij.util.Producer; +import org.jetbrains.annotations.Nullable; + +import java.awt.datatransfer.Transferable; + +public abstract class BasePasteHandler extends EditorWriteActionHandler { + protected Transferable myTransferable; + + @Override + public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) { + // We capture the contents to paste here, so it that it won't be affected by possible clipboard operations later (e.g. during unlocking + // of current file for writing) + myTransferable = getContentsToPaste(editor, dataContext); + try { + super.doExecute(editor, caret, dataContext); + } + finally { + myTransferable = null; + } + } + + @Override + public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) { + if (myTransferable != null) { + EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable); + } + } + + protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) { + Producer producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext); + return EditorModificationUtil.getContentsToPasteToEditor(producer); + } + +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/MultiplePasteAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/MultiplePasteAction.java index f2d26ef0b4e6..3f779c7c1ba1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/MultiplePasteAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/MultiplePasteAction.java @@ -19,10 +19,9 @@ import com.intellij.ide.CopyPasteManagerEx; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.ide.CopyPasteManager; -import com.intellij.openapi.project.Project; import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.ui.UIBundle; @@ -100,9 +99,6 @@ public class MultiplePasteAction extends AnAction implements DumbAware { if (editor != null) { if (editor.isViewer()) return; - if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)){ - return; - } final AnAction pasteAction = ActionManager.getInstance().getAction(IdeActions.ACTION_PASTE); AnActionEvent newEvent = new AnActionEvent(e.getInputEvent(), diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteAction.java index 8f7cea0fc61d..1ba31dac63e2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteAction.java @@ -17,10 +17,10 @@ package com.intellij.openapi.editor.actions; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKey; +import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorModificationUtil; +import com.intellij.openapi.editor.EditorCopyPasteHelper; import com.intellij.openapi.editor.actionSystem.EditorAction; -import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.util.TextRange; import com.intellij.util.Producer; @@ -38,17 +38,17 @@ public class PasteAction extends EditorAction { super(new Handler()); } - private static class Handler extends EditorWriteActionHandler { + private static class Handler extends BasePasteHandler { @Override - public void executeWriteAction(Editor editor, DataContext dataContext) { - Producer producer = TRANSFERABLE_PROVIDER.getData(dataContext); - if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) { - EditorModificationUtil.pasteTransferableAsBlock(editor, producer); - } - else { - TextRange range = EditorModificationUtil.pasteTransferable(editor, producer); - editor.putUserData(EditorEx.LAST_PASTED_REGION, range); + public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) { + TextRange range = null; + if (myTransferable != null) { + TextRange[] ranges = EditorCopyPasteHelper.getInstance().pasteTransferable(editor, myTransferable); + if (ranges != null && ranges.length == 1) { + range = ranges[0]; + } } + editor.putUserData(EditorEx.LAST_PASTED_REGION, range); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java index 3e20ba800dae..e95ba62ad394 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/PasteFromX11Action.java @@ -21,15 +21,9 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorModificationUtil; import com.intellij.openapi.editor.actionSystem.EditorAction; -import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler; import com.intellij.openapi.editor.event.EditorMouseEventArea; -import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.TextRange; -import com.intellij.util.Producer; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -71,30 +65,19 @@ public class PasteFromX11Action extends EditorAction { } } - public static class Handler extends EditorWriteActionHandler { + public static class Handler extends BasePasteHandler { @Override - public void executeWriteAction(Editor editor, DataContext dataContext) { + protected Transferable getContentsToPaste(Editor editor, DataContext dataContext) { Clipboard clip = editor.getComponent().getToolkit().getSystemSelection(); - if (clip == null) return; + if (clip == null) return null; - final Transferable content; try { - content = clip.getContents(null); + return clip.getContents(null); } catch (Exception e) { LOG.info(e); - return; + return null; } - if (content == null) return; - - TextRange range = EditorModificationUtil.pasteTransferable(editor, new Producer() { - @Nullable - @Override - public Transferable produce() { - return content; - } - }); - editor.putUserData(EditorEx.LAST_PASTED_REGION, range); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/SimplePasteAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/SimplePasteAction.java index 59a6cbca29a6..0efcdb1d8705 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/SimplePasteAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/SimplePasteAction.java @@ -19,15 +19,10 @@ import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorModificationUtil; import com.intellij.openapi.editor.actionSystem.EditorAction; -import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler; -import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.util.TextRange; -import com.intellij.util.Producer; - -import java.awt.datatransfer.Transferable; +import org.jetbrains.annotations.NotNull; /** * @author max @@ -47,21 +42,9 @@ public class SimplePasteAction extends EditorAction { } } - private static class Handler extends EditorWriteActionHandler { + private static class Handler extends BasePasteHandler { @Override - public void executeWriteAction(Editor editor, DataContext dataContext) { - Producer producer = PasteAction.TRANSFERABLE_PROVIDER.getData(dataContext); - if (!editor.getCaretModel().supportsMultipleCarets() && editor.isColumnMode()) { - EditorModificationUtil.pasteTransferableAsBlock(editor, producer); - } - else { - TextRange range = EditorModificationUtil.pasteTransferable(editor, producer); - editor.putUserData(EditorEx.LAST_PASTED_REGION, range); - } - } - - @Override - public boolean isEnabled(Editor editor, DataContext dataContext) { + public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { return !editor.isViewer(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorCopyPasteHelperImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorCopyPasteHelperImpl.java index 6f4dcb458306..783854a1dee1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorCopyPasteHelperImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorCopyPasteHelperImpl.java @@ -26,12 +26,12 @@ import com.intellij.openapi.util.text.LineTokenizer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper { private static final Logger LOG = Logger.getInstance(EditorCopyPasteHelperImpl.class); @@ -72,14 +72,8 @@ public class EditorCopyPasteHelperImpl extends EditorCopyPasteHelper { @Nullable @Override public TextRange[] pasteFromClipboard(@NotNull Editor editor) { - CopyPasteManager manager = CopyPasteManager.getInstance(); - if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) { - Transferable clipboardContents = manager.getContents(); - if (clipboardContents != null) { - return pasteTransferable(editor, clipboardContents); - } - } - return null; + Transferable transferable = EditorModificationUtil.getContentsToPasteToEditor(null); + return transferable == null ? null : pasteTransferable(editor, transferable); } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/LeftHandScrollbarLayout.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/LeftHandScrollbarLayout.java index 7f60c023763b..63936af98c83 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/LeftHandScrollbarLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/LeftHandScrollbarLayout.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -15,6 +15,8 @@ */ package com.intellij.openapi.editor.impl; +import com.intellij.util.ui.JBUI; + import javax.swing.*; import javax.swing.border.Border; import java.awt.*; @@ -777,11 +779,11 @@ public class LeftHandScrollbarLayout extends ScrollPaneLayout { Component view = (viewport != null) ? viewport.getView() : null; Dimension viewPrefSize = (view != null) ? view.getPreferredSize() - : new Dimension(0, 0); + : JBUI.emptySize(); Dimension extentSize = (viewport != null) ? viewport.toViewCoordinates(availR.getSize()) - : new Dimension(0, 0); + : JBUI.emptySize(); boolean viewTracksViewportWidth = false; boolean viewTracksViewportHeight = false; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java index ecee36ecf18a..ab518964a4ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.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. @@ -28,6 +28,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Weighted; import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -85,7 +86,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent setLayout(null); myFocusProxy.setOpaque(false); - myFocusProxy.setPreferredSize(new Dimension(0, 0)); + myFocusProxy.setPreferredSize(JBUI.emptySize()); myFocusProxy.setFocusable(true); UIUtil.setFocusProxy(myFocusProxy, true); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java index 89a0da4ee3b5..4a10dc207ace 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -39,6 +39,7 @@ import com.intellij.ui.PopupHandler; import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.JBPanel; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -342,7 +343,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { mbd = menuBar.getPreferredSize(); } else { - mbd = new Dimension(0, 0); + mbd = JBUI.emptySize(); } return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right, rd.height + mbd.height + i.top + i.bottom); @@ -361,7 +362,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { mbd = menuBar.getMinimumSize(); } else { - mbd = new Dimension(0, 0); + mbd = JBUI.emptySize(); } return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right, rd.height + mbd.height + i.top + i.bottom); @@ -374,7 +375,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { mbd = menuBar.getMaximumSize(); } else { - mbd = new Dimension(0, 0); + mbd = JBUI.emptySize(); } if (contentPane != null) { rd = contentPane.getMaximumSize(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java index 68adaed74fd1..5565459f085a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -22,6 +22,7 @@ import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.awt.RelativeRectangle; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManagerEvent; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import java.awt.*; @@ -54,7 +55,7 @@ class ComboContentLayout extends ContentLayout { @Override public void layout() { Rectangle bounds = myUi.getBounds(); - Dimension idSize = isIdVisible() ? myIdLabel.getPreferredSize() : new Dimension(0, 0); + Dimension idSize = isIdVisible() ? myIdLabel.getPreferredSize() : JBUI.emptySize(); int eachX = 0; int eachY = 0; diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index 88353779a83c..2ce4252445a7 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.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. @@ -1071,7 +1071,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui { @Override Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) { - final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize); + final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize); return new Point(center.x, targetPoint.y); } @@ -1128,7 +1128,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui { @Override Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) { - final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize); + final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize); return new Point(center.x, targetPoint.y - balloonSize.height); } @@ -1186,7 +1186,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui { @Override Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) { - final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize); + final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize); return new Point(targetPoint.x, center.y); } @@ -1243,7 +1243,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui { @Override Point getLocation(final Dimension containerSize, final Point targetPoint, final Dimension balloonSize) { - final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, new Dimension(0, 0)), balloonSize); + final Point center = UIUtil.getCenterPoint(new Rectangle(targetPoint, JBUI.emptySize()), balloonSize); return new Point(targetPoint.x - balloonSize.width, center.y); } diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java index 7837b48ab3fa..e9627386eb88 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java @@ -25,6 +25,7 @@ import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; import com.intellij.ui.mac.MacMainFrameDecorator; +import com.intellij.util.IJSwingUtilities; import com.intellij.util.ui.Animator; import org.jetbrains.annotations.NotNull; @@ -221,6 +222,7 @@ public class SheetMessage { staticImage = null; myWindow.setContentPane(myController.getPanel(myWindow)); + IJSwingUtilities.moveMousePointerOn(myWindow.getRootPane().getDefaultButton()); myController.requestFocus(); } else { if (restoreFullScreenButton) { diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index ba051086dd92..01b8c5e80e0d 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -100,7 +100,7 @@ inspection.empty.method.delete.quickfix=Delete unnecessary method(s) inspection.empty.method.problem.descriptor=Method only calls its super inspection.empty.method.problem.descriptor1=Empty method overrides empty method inspection.empty.method.problem.descriptor2=The method is empty -inspection.empty.method.problem.descriptor3=The method and all it's derivables are empty +inspection.empty.method.problem.descriptor3=The method and all its derivables are empty inspection.empty.method.problem.descriptor4=All implementations of this method are empty #redundant cast diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index baf7d20c0c52..8cd7594ebaaa 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -716,9 +716,6 @@ - - - diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java index 3dd79e16175c..5ff5999ccb8c 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java @@ -1,5 +1,7 @@ package com.intellij.structuralsearch.plugin.ui; +import com.intellij.ide.ui.search.SearchUtil; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.structuralsearch.SSRBundle; @@ -9,7 +11,9 @@ import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.containers.Convertor; +import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.tree.*; @@ -90,25 +94,37 @@ public class ExistingTemplatesComponent { } panel = ToolbarDecorator.createDecorator(patternTree) - .setAddAction(new AnActionButtonRunnable() { + .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { - addSelectedTreeNodeAndClose(); + final Object selection = patternTree.getLastSelectedPathComponent(); + if (!(selection instanceof DefaultMutableTreeNode)) { + return; + } + final DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection; + if (!(node.getUserObject() instanceof Configuration)) { + return; + } + final Configuration configuration = (Configuration)node.getUserObject(); + if (configuration.isPredefined()) { + return; + } + patternTreeModel.removeNodeFromParent(node); + configurationManager.removeConfiguration(configuration); } - }).setRemoveAction(new AnActionButtonRunnable() { + }).setRemoveActionUpdater(new AnActionButtonUpdater() { @Override - public void run(AnActionButton button) { - Object selection = patternTree.getLastSelectedPathComponent(); - + public boolean isEnabled(AnActionEvent e) { + final Object selection = patternTree.getLastSelectedPathComponent(); if (selection instanceof DefaultMutableTreeNode) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection; - - if (node.getUserObject() instanceof Configuration) { - Configuration configuration = (Configuration)node.getUserObject(); - patternTreeModel.removeNodeFromParent(node); - configurationManager.removeConfiguration(configuration); + final DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection; + final Object userObject = node.getUserObject(); + if (userObject instanceof Configuration) { + final Configuration configuration = (Configuration)userObject; + return !configuration.isPredefined(); } } + return false; } }).createPanel(); @@ -118,23 +134,19 @@ public class ExistingTemplatesComponent { historyModel = new DefaultListModel(); historyPanel = new JPanel(new BorderLayout()); - historyPanel.add( - BorderLayout.NORTH, - new JLabel(SSRBundle.message("used.templates")) - ); - Component view = historyList = new JBList(historyModel); - historyPanel.add( - BorderLayout.CENTER, - ScrollPaneFactory.createScrollPane(view) - ); - - historyList.setCellRenderer( - new ListCellRenderer() - ); + historyPanel.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("used.templates"))); + historyList = new JBList(historyModel); + historyPanel.add(BorderLayout.CENTER, ScrollPaneFactory.createScrollPane(historyList)); historyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - new ListSpeedSearch(historyList); + final ListSpeedSearch speedSearch = new ListSpeedSearch(historyList, new Convertor() { + @Override + public String convert(Object o) { + return o instanceof Configuration ? ((Configuration)o).getName() : o.toString(); + } + }); + historyList.setCellRenderer(new ExistingTemplatesListCellRenderer(speedSearch)); if (configurationManager.getHistoryConfigurations() != null) { for (final Configuration configuration : configurationManager.getHistoryConfigurations()) { @@ -167,13 +179,6 @@ public class ExistingTemplatesComponent { }.installOn(component); } - private void addSelectedTreeNodeAndClose() { - addConfigurationToUserTemplates( - Configuration.getConfigurationCreator().createConfiguration() - ); - owner.close(DialogWrapper.OK_EXIT_CODE); - } - private static Tree createTree(TreeModel treeModel) { final Tree tree = new Tree(treeModel); @@ -183,25 +188,17 @@ public class ExistingTemplatesComponent { tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); - tree.setCellRenderer(new TreeCellRenderer()); - new TreeSpeedSearch( + final TreeSpeedSearch speedSearch = new TreeSpeedSearch( tree, new Convertor() { public String convert(TreePath object) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)object.getLastPathComponent(); - Object displayValue = node.getUserObject(); - - if (displayValue instanceof Configuration) { - displayValue = ((Configuration)displayValue).getName(); - } - else { - displayValue = ""; - } - return displayValue.toString(); + final Object userObject = ((DefaultMutableTreeNode)object.getLastPathComponent()).getUserObject(); + return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString(); } } ); + tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch)); return tree; } @@ -224,56 +221,60 @@ public class ExistingTemplatesComponent { return plugin.getExistingTemplatesComponent(); } - static class ListCellRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + private static class ExistingTemplatesListCellRenderer extends ColoredListCellRenderer { + + private final ListSpeedSearch mySpeedSearch; + + public ExistingTemplatesListCellRenderer(ListSpeedSearch speedSearch) { + mySpeedSearch = speedSearch; + } + @Override + protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean focus) { if (value instanceof Configuration) { value = ((Configuration)value).getName(); } - - Component comp = super.getListCellRendererComponent( - list, - value, - index, - isSelected, - cellHasFocus - ); - - return comp; + final Color background = (selected && !focus) ? + UIUtil.getListUnfocusedSelectionBackground() : UIUtil.getListBackground(selected); + final Color foreground = UIUtil.getListForeground(selected); + setPaintFocusBorder(false); + SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), value.toString(), SimpleTextAttributes.STYLE_PLAIN, + foreground, background, this); } } - static class TreeCellRenderer extends DefaultTreeCellRenderer { - TreeCellRenderer() { - setOpenIcon(null); - setLeafIcon(null); - setClosedIcon(null); + private static class ExistingTemplatesTreeCellRenderer extends ColoredTreeCellRenderer { + + private final TreeSpeedSearch mySpeedSearch; + + ExistingTemplatesTreeCellRenderer(TreeSpeedSearch speedSearch) { + mySpeedSearch = speedSearch; } - public Component getTreeCellRendererComponent(JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) { - DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; - Object displayValue = treeNode.getUserObject(); + @Override + public void customizeCellRenderer(@NotNull JTree tree, + Object value, + boolean selected, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { + final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; + final Object userObject = treeNode.getUserObject(); - if (displayValue instanceof Configuration) { - displayValue = ((Configuration)displayValue).getName(); + final Color background = selected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeTextBackground(); + final Color foreground = selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground(); + + final String text; + final int style; + if (userObject instanceof Configuration) { + text = ((Configuration)userObject).getName(); + style = SimpleTextAttributes.STYLE_PLAIN; } - - Component comp = super.getTreeCellRendererComponent( - tree, - displayValue, - sel, - expanded, - leaf, - row, - hasFocus - ); - - return comp; + else { + text = userObject.toString(); + style = SimpleTextAttributes.STYLE_BOLD; + } + SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), text, style, foreground, background, this); } } diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index 9ffc141b32b0..372e456c9f8a 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -46,7 +46,7 @@ incorrect.pattern.message=Incorrect pattern used.templates.history.dialog.title=Used Templates History existing.templates.dialog.title=Existing Templates selecttemplate.template.preview=Template preview: -selecttemplate.template.label.please.select.template=
Please select template in the tree on the left.
+selecttemplate.template.label.please.select.template=
Please select a template in the tree on the left.
# Replace Dialog specific titles/options structural.replace.title=Structural Replace diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index 19c6e60a7c70..b6ddc195f597 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -215,6 +215,7 @@ public class AllIcons { public static final Icon Class_filter = IconLoader.getIcon("/debugger/class_filter.png"); // 16x16 public static final Icon CommandLine = IconLoader.getIcon("/debugger/commandLine.png"); // 16x16 public static final Icon Console = IconLoader.getIcon("/debugger/console.png"); // 16x16 + public static final Icon Console_log = IconLoader.getIcon("/debugger/console_log.png"); // 16x16 public static final Icon Db_array = IconLoader.getIcon("/debugger/db_array.png"); // 16x16 public static final Icon Db_db_object = IconLoader.getIcon("/debugger/db_db_object.png"); // 16x16 public static final Icon Db_dep_exception_breakpoint = IconLoader.getIcon("/debugger/db_dep_exception_breakpoint.png"); // 12x12 diff --git a/platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java b/platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java index eec2638b72e2..4c7c4c60b950 100644 --- a/platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java +++ b/platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 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. @@ -15,6 +15,7 @@ */ package com.intellij.openapi.ui; +import com.intellij.util.ui.JBUI; import org.intellij.lang.annotations.MagicConstant; import java.awt.*; @@ -139,7 +140,7 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable { @Override public Dimension minimumLayoutSize(Container container) { - Dimension dimension = new Dimension(0, 0); + Dimension dimension = JBUI.emptySize(); for(int i = 0; i < container.getComponentCount(); i++){ Component component = container.getComponent(i); if (!component.isVisible()) continue; @@ -158,7 +159,7 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable { @Override public Dimension preferredLayoutSize(Container container) { - Dimension dimension = new Dimension(0, 0); + Dimension dimension = JBUI.emptySize(); for(int i = 0; i < container.getComponentCount(); i++){ Component component = container.getComponent(i); if (!component.isVisible()) continue; diff --git a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java index d734d4b4faa7..cbcf77d90fe6 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileSystemUtil.java @@ -305,12 +305,13 @@ public class FileSystemUtil { @Override protected boolean clonePermissions(@NotNull String source, @NotNull String target) throws Exception { if (SystemInfo.isUnix) { - Object pathObj = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY); - Map attributes = (Map)myReadAttributes.invoke(null, pathObj, "posix:permissions", myLinkOptions); + Object sourcePath = myGetPath.invoke(myDefaultFileSystem, source, ArrayUtil.EMPTY_STRING_ARRAY); + Object targetPath = myGetPath.invoke(myDefaultFileSystem, target, ArrayUtil.EMPTY_STRING_ARRAY); + Map attributes = (Map)myReadAttributes.invoke(null, sourcePath, "posix:permissions", myLinkOptions); if (attributes != null) { Object permissions = attributes.get("permissions"); if (permissions instanceof Collection) { - mySetAttribute.invoke(null, pathObj, "posix:permissions", permissions, myLinkOptions); + mySetAttribute.invoke(null, targetPath, "posix:permissions", permissions, myLinkOptions); return true; } } diff --git a/platform/util/src/com/intellij/ui/TitlePanel.java b/platform/util/src/com/intellij/ui/TitlePanel.java index 937dc82a5928..9803323c0b08 100644 --- a/platform/util/src/com/intellij/ui/TitlePanel.java +++ b/platform/util/src/com/intellij/ui/TitlePanel.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. @@ -20,7 +20,6 @@ import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import javax.swing.*; -import javax.swing.border.EmptyBorder; import java.awt.*; /** @@ -77,12 +76,13 @@ public class TitlePanel extends CaptionPanel { public Dimension getPreferredSize() { final String text = myLabel.getText(); if (text == null || text.trim().isEmpty()) { - return new Dimension(0, 0); + return JBUI.emptySize(); } final Dimension preferredSize = super.getPreferredSize(); - if (!myHtml && preferredSize.width > 350) { // do not allow caption to extend parent container - return new Dimension(350, preferredSize.height); + int maxWidth = JBUI.scale(350); + if (!myHtml && preferredSize.width > maxWidth) { // do not allow caption to extend parent container + return new Dimension(maxWidth, preferredSize.height); } return preferredSize; diff --git a/platform/util/src/com/intellij/util/Restarter.java b/platform/util/src/com/intellij/util/Restarter.java index 8ee6f46b1093..fdcc4f876b3f 100644 --- a/platform/util/src/com/intellij/util/Restarter.java +++ b/platform/util/src/com/intellij/util/Restarter.java @@ -156,6 +156,7 @@ public class Restarter { public static File createTempExecutable(File executable) throws IOException { File executableDir = new File(System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart"); File copy = new File(executableDir.getPath() + "/" + executable.getName()); + if (!FileUtilRt.createDirectory(executableDir)) throw new IOException("Cannot create dir: " + executableDir); if (!FileUtilRt.ensureCanCreateFile(copy) || (copy.exists() && !copy.delete())) { String ext = FileUtilRt.getExtension(executable.getName()); copy = FileUtilRt.createTempFile(executableDir, FileUtilRt.getNameWithoutExtension(copy.getName()), diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index 8554441672e0..4fd929658c8f 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -56,6 +56,10 @@ public class JBUI { return (EmptyIcon)EmptyIcon.create(scale(i)); } + public static JBDimension emptySize() { + return new JBDimension(0, 0); + } + public static float scale(float f) { return f * scale(1); } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml index fdb98efa8491..fe80d85060a5 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml @@ -578,6 +578,10 @@ key="non.public.clone.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.cloning.issues" enabledByDefault="false" level="WARNING" implementationClass="com.siyeh.ig.cloneable.NonPublicCloneInspection"/> + #ref() +use.of.clone.call.method.problem.descriptor=Implementation of #ref() +use.of.clone.reference.problem.descriptor=Use of #ref diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsConstructorsInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsConstructorsInspection.java index 3cafe5dcfabd..2854cce8da7a 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsConstructorsInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsConstructorsInspection.java @@ -53,7 +53,7 @@ public class CloneCallsConstructorsInspection extends BaseInspection { return; } final PsiClass aClass = method.getContainingClass(); - if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL) || !CloneUtils.isCloneable(aClass)) { + if (aClass == null || aClass.hasModifierProperty(PsiModifier.FINAL)) { return; } method.accept(new JavaRecursiveElementVisitor() { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java index 43317990ac9b..646a5929795c 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,15 +77,10 @@ public class CloneCallsSuperCloneInspection extends BaseInspection { containingClass.isAnnotationType()) { return; } - if (CloneUtils.onlyThrowsCloneNotSupportedException(method)) { - if (method.hasModifierProperty(PsiModifier.FINAL) || - containingClass.hasModifierProperty( - PsiModifier.FINAL)) { - return; - } + if (CloneUtils.onlyThrowsException(method)) { + return; } - final CallToSuperCloneVisitor visitor = - new CallToSuperCloneVisitor(); + final CallToSuperCloneVisitor visitor = new CallToSuperCloneVisitor(); method.accept(visitor); if (visitor.isCallToSuperCloneFound()) { return; diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneInNonCloneableClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneInNonCloneableClassInspection.java index f23e9c16991a..d726500808c9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneInNonCloneableClassInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneInNonCloneableClassInspection.java @@ -104,10 +104,7 @@ public class CloneInNonCloneableClassInspection extends BaseInspection { return; } final PsiClass containingClass = method.getContainingClass(); - if (CloneUtils.isCloneable(containingClass)) { - return; - } - if (method.hasModifierProperty(PsiModifier.FINAL) && CloneUtils.onlyThrowsCloneNotSupportedException(method)) { + if (CloneUtils.isCloneable(containingClass) || CloneUtils.onlyThrowsException(method)) { return; } registerMethodError(method, containingClass); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java new file mode 100644 index 000000000000..9d9f349dbf84 --- /dev/null +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/UseOfCloneInspection.java @@ -0,0 +1,100 @@ +/* + * 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.ig.cloneable; + +import com.intellij.psi.*; +import com.siyeh.HardcodedMethodConstants; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.psiutils.CloneUtils; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +/** + * @author Bas Leijdekkers + */ +public class UseOfCloneInspection extends BaseInspection { + + @Nls + @NotNull + @Override + public String getDisplayName() { + return InspectionGadgetsBundle.message("use.of.clone.display.name"); + } + + @NotNull + @Override + protected String buildErrorString(Object... infos) { + final Object errorElement = infos[0]; + if (errorElement instanceof PsiMethodCallExpression) { + return InspectionGadgetsBundle.message("use.of.clone.call.problem.descriptor"); + } + else if (errorElement instanceof PsiMethod) { + return InspectionGadgetsBundle.message("use.of.clone.call.method.problem.descriptor"); + } + else { + return InspectionGadgetsBundle.message("use.of.clone.reference.problem.descriptor"); + } + } + + @Override + public BaseInspectionVisitor buildVisitor() { + return new UseOfCloneVisitor(); + } + + private static class UseOfCloneVisitor extends BaseInspectionVisitor { + + @Override + public void visitMethodCallExpression(PsiMethodCallExpression expression) { + final PsiReferenceExpression methodExpression = expression.getMethodExpression(); + final String referenceName = methodExpression.getReferenceName(); + if (!HardcodedMethodConstants.CLONE.equals(referenceName)) { + return; + } + final PsiExpressionList argumentList = expression.getArgumentList(); + final PsiExpression[] arguments = argumentList.getExpressions(); + if (arguments.length != 0) { + return; + } + final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); + if (qualifierExpression != null) { + final PsiType type = qualifierExpression.getType(); + if (type instanceof PsiArrayType) { + return; + } + } + registerMethodCallError(expression, expression); + } + + @Override + public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { + final String qualifiedName = reference.getQualifiedName(); + if (!CommonClassNames.JAVA_LANG_CLONEABLE.equals(qualifiedName)) { + return; + } + registerError(reference, reference); + } + + @Override + public void visitMethod(PsiMethod method) { + if (!CloneUtils.isClone(method) || CloneUtils.onlyThrowsException(method)) { + return; + } + registerMethodError(method, method); + } + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CloneUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CloneUtils.java index 4513a60bd033..0da1027ebafc 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CloneUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/CloneUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,32 +60,22 @@ public class CloneUtils { HardcodedMethodConstants.CLONE, PsiType.EMPTY_ARRAY); } - public static boolean onlyThrowsCloneNotSupportedException( - @NotNull PsiMethod method) { + public static boolean onlyThrowsException(@NotNull PsiMethod method) { + if (!method.hasModifierProperty(PsiModifier.FINAL)) { + final PsiClass aClass = method.getContainingClass(); + if (aClass == null || !aClass.hasModifierProperty(PsiModifier.FINAL)) { + return false; + } + } final PsiCodeBlock body = method.getBody(); if (body == null) { return false; } final PsiStatement[] statements = body.getStatements(); - if (statements.length != 1) { + if (statements.length == 0) { return false; } - final PsiStatement statement = statements[0]; - if (!(statement instanceof PsiThrowStatement)) { - return false; - } - final PsiThrowStatement throwStatement = (PsiThrowStatement)statement; - final PsiExpression exception = ParenthesesUtils.stripParentheses(throwStatement.getException()); - if (!(exception instanceof PsiNewExpression)) { - return false; - } - final PsiNewExpression newExpression = (PsiNewExpression)exception; - final PsiJavaCodeReferenceElement classReference = - newExpression.getClassReference(); - if (classReference == null) { - return false; - } - final String qualifiedName = classReference.getQualifiedName(); - return qualifiedName.equals("java.lang.CloneNotSupportedException"); + final PsiStatement statement = statements[statements.length - 1]; + return statement instanceof PsiThrowStatement; } } diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfClone.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfClone.html new file mode 100644 index 000000000000..2f4c5a2ac6fc --- /dev/null +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfClone.html @@ -0,0 +1,11 @@ + + +Reports calls to and implementations of the clone() method and uses of java.lang.Cloneable. +Some coding standards prohibit clone() usage, and recommend using a copy constructor or static factory method. +Calls to clone() on arrays are ignored, because that is a common, correct, efficient and compact way to copy an array. + + +

+ New in 14.1 + + \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/CloneCallsSuperCloneInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/CloneCallsSuperCloneInspection.java deleted file mode 100644 index 2d18b36fdcae..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/CloneCallsSuperCloneInspection.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.siyeh.igtest.cloneable; - -public class CloneCallsSuperCloneInspection implements Cloneable -{ - - public void foo() - { - - } - - public Object clone() - { - return this; - } -} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_constructors/CloneCallsConstructors.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_constructors/CloneCallsConstructors.java index ec7fa278e29b..d42bc71b643e 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_constructors/CloneCallsConstructors.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_constructors/CloneCallsConstructors.java @@ -10,7 +10,7 @@ class CloneCallsConstructors implements Cloneable { class One { @Override public Object clone() throws CloneNotSupportedException { - return new One(); + return new One(); } } final class Two implements Cloneable { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java new file mode 100644 index 000000000000..3a95546ee4f8 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java @@ -0,0 +1,36 @@ +package com.siyeh.igtest.cloneable.clone_calls_super_clone; + +public class CloneCallsSuperClone implements Cloneable +{ + + public void foo() + { + + } + + public Object clone() + { + return this; + } +} +class One { + + public final One clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } +} +final class Two { + public Two clone() throws CloneNotSupportedException { + throw (new CloneNotSupportedException()); + } +} +class Three { + public Three clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } +} +class Four { + public final Four clone() { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/use_of_clone/UseOfClone.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/use_of_clone/UseOfClone.java new file mode 100644 index 000000000000..f6bd815abcd4 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/use_of_clone/UseOfClone.java @@ -0,0 +1,18 @@ +package use_of_clone; + +class UseOfClone implements Cloneable { + + void f(int[] is) { + System.out.println(is.clone()); // don't warn when cloning an array + } + + public UseOfClone clone() { + return this; + } + + void g(UseOfClone o) { + o.clone(); + } +} +interface I extends Cloneable { +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspectionTest.java new file mode 100644 index 000000000000..2c9ee37c6482 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspectionTest.java @@ -0,0 +1,36 @@ +/* + * 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.ig.cloneable; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers. + */ +public class CloneCallsSuperCloneInspectionTest extends LightInspectionTestCase { + + public void testCloneCallsSuperClone() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new CloneCallsSuperCloneInspection(); + } +} diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/UseOfCloneInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/UseOfCloneInspectionTest.java new file mode 100644 index 000000000000..8f8df76d0e72 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/cloneable/UseOfCloneInspectionTest.java @@ -0,0 +1,36 @@ +/* + * 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.ig.cloneable; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers. + */ +public class UseOfCloneInspectionTest extends LightInspectionTestCase { + + public void testUseOfClone() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new UseOfCloneInspection(); + } +} diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java index 1b4e43ec4df1..035507d22122 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.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. @@ -229,15 +229,17 @@ public class InjectorUtils { public static BaseInjection findCommentInjection(@NotNull PsiElement context, @NotNull String supportId, @Nullable Ref causeRef) { PsiElement target = CompletionUtil.getOriginalOrSelf(context); PsiFile file = target.getContainingFile(); + if (file == null || file.getFileType().isBinary()) return null; TreeMap map = getInjectionMap(file); - Map.Entry entry = map == null ? null : map.lowerEntry(target.getTextRange()); + if (map == null) return null; + Map.Entry entry = map.lowerEntry(target.getTextRange()); if (entry == null) return null; PsiComment psiComment = PsiTreeUtil.findElementOfClassAtOffset(file, entry.getKey().getStartOffset(), PsiComment.class, false); if (psiComment == null) return null; TextRange r0 = psiComment.getTextRange(); - // calulate topmost siblings & heights + // calculate topmost siblings & heights PsiElement commonParent = PsiTreeUtil.findCommonParent(psiComment, target); int h1 = 0, h2 = 0; PsiElement e1 = psiComment, e2 = target; @@ -269,8 +271,7 @@ public class InjectorUtils { } @Nullable - private static TreeMap getInjectionMap(@Nullable final PsiFile file) { - if (file == null) return null; // e.g. null for synthetic groovy variables + private static TreeMap getInjectionMap(@NotNull final PsiFile file) { return CachedValuesManager.getCachedValue(file, new CachedValueProvider>() { @Nullable @Override diff --git a/plugins/devkit/src/util/ChooseModulesDialog.java b/plugins/devkit/src/util/ChooseModulesDialog.java index dcc43c17b7e9..34b62d26ea10 100644 --- a/plugins/devkit/src/util/ChooseModulesDialog.java +++ b/plugins/devkit/src/util/ChooseModulesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -30,6 +30,7 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.TableUtil; import com.intellij.ui.components.JBList; import com.intellij.ui.table.JBTable; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.devkit.DevKitBundle; import org.jetbrains.idea.devkit.module.PluginModuleType; @@ -142,7 +143,7 @@ public class ChooseModulesDialog extends DialogWrapper { final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane(); jScrollPane.setViewportView(myView); - jScrollPane.setPreferredSize(new Dimension(300, 80)); + jScrollPane.setPreferredSize(JBUI.size(300, 80)); panel.add(jScrollPane, BorderLayout.SOUTH); return panel; } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java index de1d162148bb..267707e08207 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/DslActivationStatus.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. @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.dsl; import com.intellij.openapi.components.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import gnu.trove.THashMap; @@ -49,11 +50,16 @@ public class DslActivationStatus implements PersistentStateComponent { @Nullable public synchronized String getInactivityReason(VirtualFile file) { String status = myStatus.get(file); - return status == null || status == ENABLED ? null : status; + return ENABLED.equals(status) ? null : status; } public synchronized boolean isActivated(VirtualFile file) { - return myStatus.get(file) == ENABLED; + final String status = myStatus.get(file); + if (status == null) { + myStatus.put(file, ENABLED); + return true; + } + return ENABLED.equals(status); } @Nullable @@ -66,7 +72,9 @@ public class DslActivationStatus implements PersistentStateComponent { Element element = new Element("file"); root.addContent(element); element.setAttribute("url", file.getUrl()); - element.setAttribute("status", (status == ENABLED ? "" : status)); + if (!ENABLED.equals(status)) { + element.setAttribute("status", status); + } } return root; } @@ -76,10 +84,10 @@ public class DslActivationStatus implements PersistentStateComponent { List children = state.getChildren("file"); for (Element element : children) { String url = element.getAttributeValue("url", ""); - String status = element.getAttributeValue("status", ENABLED); + String status = element.getAttributeValue("status"); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); if (file != null) { - myStatus.put(file, status); + myStatus.put(file, StringUtil.isNotEmpty(status) ? status : ENABLED); } } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java index e9692292588f..692aab0efc4c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java @@ -74,7 +74,7 @@ import java.util.regex.Pattern; */ public class GroovyDslFileIndex extends ScalarIndexExtension { private static final Key> CACHED_EXECUTOR = Key.create("CachedGdslExecutor"); - private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex"); + private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class); @NonNls public static final ID NAME = ID.create("GroovyDslFileIndex"); @NonNls private static final String OUR_KEY = "ourKey"; @@ -412,7 +412,10 @@ public class GroovyDslFileIndex extends ScalarIndexExtension { if (!vfile.isValid()) { continue; } - if (!fileIndex.isInLibraryClasses(vfile) && !fileIndex.isInLibrarySource(vfile)) { + if (fileIndex.isInLibrarySource(vfile)) { + continue; + } + if (!fileIndex.isInLibraryClasses(vfile)) { if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) { continue; } diff --git a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.java b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.java index 93650c2da4af..72e0f4f06512 100644 --- a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.java +++ b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.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. @@ -183,8 +183,9 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light { } decompiler.decompileContext(); - file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY, - new ExactMatchLineNumbersMapping(saver.myMapping)); + if (saver.myMapping != null) { + file.putUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY, new ExactMatchLineNumbersMapping(saver.myMapping)); + } return saver.myResult; } @@ -344,7 +345,7 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light { private static class ExactMatchLineNumbersMapping implements LineNumbersMapping { private int[] myMapping; - private ExactMatchLineNumbersMapping(int[] mapping) { + private ExactMatchLineNumbersMapping(@NotNull int[] mapping) { myMapping = mapping; } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index d5114377c313..85adb5468958 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -106,6 +106,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit private boolean myDisposed; private VirtualFileListener myVfsListener; private Editor mySelectedEditor; + private String myPropertyToSelectWhenVisible; public ResourceBundleEditor(@NotNull ResourceBundle resourceBundle) { myProject = resourceBundle.getProject(); @@ -208,6 +209,9 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit if (newEditor == this) { if (oldEditor instanceof TextEditor) { setStructureViewSelectionFromPropertiesFile(((TextEditor)oldEditor).getEditor()); + } else if (myPropertyToSelectWhenVisible != null) { + setStructureViewSelection(myPropertyToSelectWhenVisible); + myPropertyToSelectWhenVisible = null; } } else if (newEditor instanceof TextEditor) { @@ -239,6 +243,17 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit Object root = tree.getModel().getRoot(); if (AbstractTreeUi.isLoadingChildrenFor(root)) { + boolean isEditorVisible = false; + for (FileEditor editor : FileEditorManager.getInstance(myProject).getSelectedEditors()) { + if (editor == this) { + isEditorVisible = true; + break; + } + } + if (!isEditorVisible) { + myPropertyToSelectWhenVisible = propertyName; + return; + } mySelectionChangeAlarm.cancelAllRequests(); mySelectionChangeAlarm.addRequest(new Runnable() { @Override diff --git a/plugins/ui-designer/src/com/intellij/ide/palette/impl/PaletteContentWindow.java b/plugins/ui-designer/src/com/intellij/ide/palette/impl/PaletteContentWindow.java index b5aaccad7b29..68d456c6d63f 100644 --- a/plugins/ui-designer/src/com/intellij/ide/palette/impl/PaletteContentWindow.java +++ b/plugins/ui-designer/src/com/intellij/ide/palette/impl/PaletteContentWindow.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -16,6 +16,7 @@ package com.intellij.ide.palette.impl; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -90,7 +91,7 @@ public class PaletteContentWindow extends JPanel implements Scrollable { } public Dimension minimumLayoutSize(Container parent) { - return new Dimension(0, 0); + return JBUI.emptySize(); } public Dimension preferredLayoutSize(Container parent) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/AbstractDimensionProperty.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/AbstractDimensionProperty.java index 34cf815f4b36..e77d979d83b5 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/AbstractDimensionProperty.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/AbstractDimensionProperty.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -16,13 +16,14 @@ package com.intellij.uiDesigner.propertyInspector.properties; import com.intellij.uiDesigner.FormEditingUtil; -import com.intellij.uiDesigner.radComponents.RadComponent; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.propertyInspector.Property; import com.intellij.uiDesigner.propertyInspector.PropertyEditor; import com.intellij.uiDesigner.propertyInspector.PropertyRenderer; import com.intellij.uiDesigner.propertyInspector.editors.IntRegexEditor; import com.intellij.uiDesigner.propertyInspector.renderers.DimensionRenderer; +import com.intellij.uiDesigner.radComponents.RadComponent; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -43,8 +44,8 @@ public abstract class AbstractDimensionProperty extends public AbstractDimensionProperty(@NonNls final String name){ super(null, name); myChildren=new Property[]{ - new IntFieldProperty(this, "width", -1, new Dimension(0, 0)), - new IntFieldProperty(this, "height", -1, new Dimension(0, 0)), + new IntFieldProperty(this, "width", -1, JBUI.emptySize()), + new IntFieldProperty(this, "height", -1, JBUI.emptySize()), }; myRenderer = new DimensionRenderer(); myEditor = new IntRegexEditor(Dimension.class, myRenderer, new int[] { -1, -1 }); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IntroDimensionProperty.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IntroDimensionProperty.java index bd4c57fea689..4682d09ba14f 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IntroDimensionProperty.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/properties/IntroDimensionProperty.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -15,20 +15,21 @@ */ package com.intellij.uiDesigner.propertyInspector.properties; -import com.intellij.uiDesigner.XmlWriter; import com.intellij.uiDesigner.SwingProperties; -import com.intellij.uiDesigner.snapShooter.SnapshotContext; -import com.intellij.uiDesigner.radComponents.RadComponent; +import com.intellij.uiDesigner.XmlWriter; import com.intellij.uiDesigner.propertyInspector.IntrospectedProperty; import com.intellij.uiDesigner.propertyInspector.Property; import com.intellij.uiDesigner.propertyInspector.PropertyEditor; import com.intellij.uiDesigner.propertyInspector.PropertyRenderer; import com.intellij.uiDesigner.propertyInspector.editors.IntRegexEditor; import com.intellij.uiDesigner.propertyInspector.renderers.DimensionRenderer; +import com.intellij.uiDesigner.radComponents.RadComponent; +import com.intellij.uiDesigner.snapShooter.SnapshotContext; +import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.Dimension; +import java.awt.*; import java.lang.reflect.Method; /** @@ -43,8 +44,8 @@ public final class IntroDimensionProperty extends IntrospectedProperty(Dimension.class, myRenderer, new int[] { -1, -1 }); diff --git a/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java b/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java index 585ce5c16680..4e805355e83a 100644 --- a/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java +++ b/python/pluginSrc/com/jetbrains/python/module/PyProjectStructureDetector.java @@ -49,11 +49,15 @@ public class PyProjectStructureDetector extends ProjectStructureDetector { @NotNull List result) { LOG.info("Detecting roots under " + dir); for (File child : children) { - if (FileUtilRt.extensionEquals(child.getName(), "py")) { + final String name = child.getName(); + if (FileUtilRt.extensionEquals(name, "py")) { LOG.info("Found Python file " + child.getPath()); result.add(new DetectedContentRoot(dir, "Python", PythonModuleTypeBase.getInstance(), WebModuleType.getInstance())); return DirectoryProcessingResult.SKIP_CHILDREN; } + if ("node_modules".equals(name)) { + return DirectoryProcessingResult.SKIP_CHILDREN; + } } return DirectoryProcessingResult.PROCESS_CHILDREN; } diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 7836da0b2add..4d4329d87e6d 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -70,6 +70,7 @@ +