From c08c00a43d2b41266008ba650dcfe0f8c0d09d97 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 20 Oct 2011 13:20:03 +0200 Subject: [PATCH 1/5] inplace introduce: reinit default type before show dialog on the second key stroke; correct undo chain --- .../IntroduceConstantHandler.java | 11 ++++++----- .../introduceField/IntroduceFieldHandler.java | 15 ++++++++------- .../AbstractJavaInplaceIntroducer.java | 2 +- .../IntroduceParameterHandler.java | 18 ++++++++++-------- .../inplace/AbstractInplaceIntroducer.java | 9 +++++++-- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java index 242cf0c19f4e..78c73c0b537a 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java @@ -93,7 +93,7 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler { protected Settings showRefactoringDialog(Project project, - Editor editor, + final Editor editor, PsiClass parentClass, PsiExpression expr, PsiType type, @@ -150,31 +150,32 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler { String enteredName = null; boolean replaceAllOccurrences = true; - final TypeSelectorManagerImpl typeSelectorManager = new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences); if (editor != null && editor.getSettings().isVariableInplaceRenameEnabled() && (expr == null || expr.isPhysical())) { final AbstractInplaceIntroducer activeIntroducer = AbstractInplaceIntroducer.getActiveIntroducer(editor); if (activeIntroducer == null) { myInplaceIntroduceConstantPopup = - new InplaceIntroduceConstantPopup(project, editor, parentClass, expr, localVariable, occurrences, typeSelectorManager, + new InplaceIntroduceConstantPopup(project, editor, parentClass, expr, localVariable, occurrences, + new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences), anchorElement, anchorElementIfAll, expr != null ? createOccurrenceManager(expr, parentClass) : null); if (myInplaceIntroduceConstantPopup.startInplaceIntroduceTemplate() ){ return null; } } else { - AbstractInplaceIntroducer.stopIntroduce(editor); + activeIntroducer.stopIntroduce(editor); expr = (PsiExpression)activeIntroducer.getExpr(); localVariable = (PsiLocalVariable)activeIntroducer.getLocalVariable(); occurrences = (PsiExpression[])activeIntroducer.getOccurrences(); enteredName = activeIntroducer.getInputName(); replaceAllOccurrences = activeIntroducer.isReplaceAllOccurrences(); + type = ((InplaceIntroduceConstantPopup)activeIntroducer).getType(); } } final IntroduceConstantDialog dialog = new IntroduceConstantDialog(project, parentClass, expr, localVariable, localVariable != null, occurrences, getParentClass(), - typeSelectorManager, enteredName); + new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences), enteredName); dialog.setReplaceAllOccurrences(replaceAllOccurrences); dialog.show(); if (!dialog.isOK()) { diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java index fa7fb3b81aa2..77284b936479 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java @@ -25,6 +25,7 @@ import com.intellij.psi.util.PsiUtil; import com.intellij.refactoring.HelpID; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer; +import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer; import com.intellij.refactoring.ui.TypeSelectorManagerImpl; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.occurrences.*; @@ -102,7 +103,6 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { final boolean currentMethodConstructor = containingMethod != null && containingMethod.isConstructor(); final boolean allowInitInMethod = (!currentMethodConstructor || !isInSuperOrThis) && (anchorElement instanceof PsiLocalVariable || anchorElement instanceof PsiStatement); final boolean allowInitInMethodIfAll = (!currentMethodConstructor || !isInSuperOrThis) && anchorElementIfAll instanceof PsiStatement; - final TypeSelectorManagerImpl typeSelectorManager = new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences); String enteredName = null; boolean replaceAll = false; @@ -110,20 +110,21 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { final AbstractInplaceIntroducer activeIntroducer = AbstractInplaceIntroducer.getActiveIntroducer(editor); if (activeIntroducer == null) { myInplaceIntroduceFieldPopup = - new InplaceIntroduceFieldPopup(localVariable, parentClass, declareStatic, currentMethodConstructor, occurrences, expr, typeSelectorManager, editor, - allowInitInMethod, allowInitInMethodIfAll, anchorElement, anchorElementIfAll, expr != null ? createOccurrenceManager( - expr, parentClass) : null, - project); + new InplaceIntroduceFieldPopup(localVariable, parentClass, declareStatic, currentMethodConstructor, occurrences, expr, + new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences), editor, + allowInitInMethod, allowInitInMethodIfAll, anchorElement, anchorElementIfAll, + expr != null ? createOccurrenceManager(expr, parentClass) : null,project); if (myInplaceIntroduceFieldPopup.startInplaceIntroduceTemplate()) { return null; } } else { - AbstractInplaceIntroducer.stopIntroduce(editor); + activeIntroducer.stopIntroduce(editor); expr = (PsiExpression)activeIntroducer.getExpr(); localVariable = (PsiLocalVariable)activeIntroducer.getLocalVariable(); occurrences = (PsiExpression[])activeIntroducer.getOccurrences(); enteredName = activeIntroducer.getInputName(); replaceAll = activeIntroducer.isReplaceAllOccurrences(); + type = ((AbstractJavaInplaceIntroducer)activeIntroducer).getType(); IntroduceFieldDialog.ourLastInitializerPlace = ((InplaceIntroduceFieldPopup)activeIntroducer).getInitializerPlace(); } } @@ -133,7 +134,7 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { currentMethodConstructor, localVariable != null, declareStatic, occurrences, allowInitInMethod, allowInitInMethodIfAll, - typeSelectorManager, + new TypeSelectorManagerImpl(project, type, containingMethod, expr, occurrences), enteredName ); dialog.setReplaceAllOccurrences(replaceAll); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java index ec59f37cf5b4..6265d9309062 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java @@ -96,7 +96,7 @@ public abstract class AbstractJavaInplaceIntroducer extends AbstractInplaceIntro TypeSelectorManagerImpl.typeSelected(psiVariable.getType(), getType());//myDefaultType.getType()); } - protected PsiType getType() { + public PsiType getType() { return myTypeSelectorManager.getDefaultType(); } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java index 53d170a73c6f..a29f7d3eba25 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java @@ -400,11 +400,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R final String propName = myLocalVar != null ? JavaCodeStyleManager .getInstance(myProject).variableNameToPropertyName(myLocalVar.getName(), VariableKind.LOCAL_VARIABLE) : null; - final PsiType initializerType = IntroduceParameterProcessor.getInitializerType(null, myExpr, myLocalVar); - - TypeSelectorManagerImpl typeSelectorManager = myExpr != null - ? new TypeSelectorManagerImpl(myProject, initializerType, myExpr, occurences) - : new TypeSelectorManagerImpl(myProject, initializerType, occurences); + PsiType initializerType = IntroduceParameterProcessor.getInitializerType(null, myExpr, myLocalVar); boolean isInplaceAvailableOnDataContext = myEditor != null && myEditor.getSettings().isVariableInplaceRenameEnabled(); @@ -421,7 +417,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R myInplaceIntroduceParameterPopup = new InplaceIntroduceParameterPopup(myProject, myEditor, classMemberRefs, - typeSelectorManager, + createTypeSelectorManager(occurences, initializerType), myExpr, myLocalVar, method, methodToSearchFor, occurences, getParamsToRemove(method, occurences), mustBeFinal); @@ -430,13 +426,14 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R } } else { - AbstractInplaceIntroducer.stopIntroduce(myEditor); + activeIntroducer.stopIntroduce(myEditor); myExpr = (PsiExpression)activeIntroducer.getExpr(); myLocalVar = (PsiLocalVariable)activeIntroducer.getLocalVariable(); occurences = (PsiExpression[])activeIntroducer.getOccurrences(); enteredName = activeIntroducer.getInputName(); replaceAllOccurrences = activeIntroducer.isReplaceAllOccurrences(); delegate = ((InplaceIntroduceParameterPopup)activeIntroducer).isGenerateDelegate(); + initializerType = ((AbstractJavaInplaceIntroducer)activeIntroducer).getType(); } } if (ApplicationManager.getApplication().isUnitTestMode()) { @@ -455,7 +452,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R final IntroduceParameterDialog dialog = new IntroduceParameterDialog(myProject, classMemberRefs, occurences, myLocalVar, myExpr, createNameSuggestionGenerator(myExpr, propName, myProject, enteredName), - typeSelectorManager, methodToSearchFor, method, getParamsToRemove(method, occurences), mustBeFinal); + createTypeSelectorManager(occurences, initializerType), methodToSearchFor, method, getParamsToRemove(method, occurences), mustBeFinal); dialog.setReplaceAllOccurrences(replaceAllOccurrences); dialog.setGenerateDelegate(delegate); dialog.show(); @@ -465,6 +462,11 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R } } + private TypeSelectorManagerImpl createTypeSelectorManager(PsiExpression[] occurences, PsiType initializerType) { + return myExpr != null ? new TypeSelectorManagerImpl(myProject, initializerType, myExpr, occurences) + : new TypeSelectorManagerImpl(myProject, initializerType, occurences); + } + private TIntArrayList getParamsToRemove(PsiMethod method, PsiExpression[] occurences) { PsiExpression expressionToRemoveParamFrom = myExpr; if (myExpr == null) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java index 57b95e7cc434..b4dbff208521 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java @@ -531,10 +531,15 @@ public abstract class AbstractInplaceIntroducer Date: Thu, 20 Oct 2011 14:04:22 +0200 Subject: [PATCH 2/5] skip check for unused parameters for methods annotated with ... (IDEA-75640) --- .../deadCode/UnusedDeclarationInspection.java | 16 ++---------- .../ex/EntryPointsManagerImpl.java | 25 ++++++++++++++++++ .../UnusedParametersInspection.java | 16 ++++++++++++ .../unusedSymbol/OptionsPanel.form | 2 +- .../UnusedSymbolLocalInspection.java | 26 ++++++------------- 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index e6f03d4b0136..5ff1af1018b8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -38,9 +38,7 @@ import com.intellij.codeInspection.ui.EntryPointsNode; import com.intellij.codeInspection.ui.InspectionNode; import com.intellij.codeInspection.ui.InspectionTreeNode; import com.intellij.codeInspection.util.RefFilter; -import com.intellij.ide.DataManager; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -49,7 +47,6 @@ import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.*; import com.intellij.psi.*; import com.intellij.psi.impl.PsiClassImplUtil; @@ -203,15 +200,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { gc.gridy++; add(myNonJavaCheckbox, gc); - final JButton configureAnnotations = new JButton("Configure annotations"); - configureAnnotations.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(OptionsPanel.this)); - if (project == null) project = ProjectManager.getInstance().getDefaultProject(); - EntryPointsManagerImpl.getInstance(project).configureAnnotations(); - } - }); + final JButton configureAnnotations = EntryPointsManagerImpl.createConfigureAnnotationsBtn(this); gc.fill = GridBagConstraints.NONE; gc.gridy++; @@ -446,8 +435,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { if (RefUtil.isImplicitUsage(element)) return true; if (element instanceof PsiModifierListOwner) { final EntryPointsManagerImpl entryPointsManager = EntryPointsManagerImpl.getInstance(element.getProject()); - if (AnnotationUtil.isAnnotated((PsiModifierListOwner)element, entryPointsManager.ADDITIONAL_ANNOTATIONS) || - AnnotationUtil.isAnnotated((PsiModifierListOwner)element, entryPointsManager.getAdditionalAnnotations())) { + if (entryPointsManager.isEntryPoint((PsiModifierListOwner)element)) { return true; } } diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java index d9ae487120db..c1d316ff0914 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java @@ -25,8 +25,11 @@ package com.intellij.codeInspection.ex; import com.intellij.ExtensionPoints; +import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; @@ -37,10 +40,12 @@ import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.*; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.psi.PsiManager; +import com.intellij.psi.PsiModifierListOwner; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import org.jdom.Element; @@ -49,6 +54,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.*; @State( @@ -360,6 +367,19 @@ public class EntryPointsManagerImpl implements PersistentStateComponent }.show(); } + public static JButton createConfigureAnnotationsBtn(final JComponent parent) { + final JButton configureAnnotations = new JButton("Configure annotations..."); + configureAnnotations.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(parent)); + if (project == null) project = ProjectManager.getInstance().getDefaultProject(); + EntryPointsManagerImpl.getInstance(project).configureAnnotations(); + } + }); + return configureAnnotations; + } + public void addAllPersistentEntries(EntryPointsManagerImpl manager) { myPersistentEntryPoints.putAll(manager.myPersistentEntryPoints); } @@ -411,4 +431,9 @@ public class EntryPointsManagerImpl implements PersistentStateComponent public void setAddNonJavaEntries(final boolean addNonJavaEntries) { myAddNonJavaEntries = addNonJavaEntries; } + + public boolean isEntryPoint(PsiModifierListOwner element) { + return AnnotationUtil.isAnnotated(element, ADDITIONAL_ANNOTATIONS) || + AnnotationUtil.isAnnotated(element, getAdditionalAnnotations()); + } } diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java index ed608257a9fc..d61aa226a3f5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedParameters/UnusedParametersInspection.java @@ -28,6 +28,7 @@ import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInspection.*; +import com.intellij.codeInspection.ex.EntryPointsManagerImpl; import com.intellij.codeInspection.reference.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; @@ -45,6 +46,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; +import java.awt.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -71,6 +74,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { if ((refMethod.isAbstract() || refMethod.getOwnerClass().isInterface()) && refMethod.getDerivedMethods().isEmpty()) return null; if (RefUtil.isEntryPoint(refMethod)) return null; + if (EntryPointsManagerImpl.getInstance(manager.getProject()).isEntryPoint(refMethod.getElement())) return null; if (refMethod.isAppMain()) return null; @@ -215,6 +219,18 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool { return SHORT_NAME; } + @Override + public JComponent createOptionsPanel() { + final JPanel panel = new JPanel(new GridBagLayout()); + final GridBagConstraints gc = + new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new Insets(5, 0, 0, 0), 0, 0); + panel.add(EntryPointsManagerImpl.createConfigureAnnotationsBtn(panel), gc); + gc.weightx = 1; + gc.fill = GridBagConstraints.HORIZONTAL; + panel.add(Box.createHorizontalBox(), gc); + return panel; + } private static class AcceptSuggested implements LocalQuickFix { private final RefManager myManager; diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/OptionsPanel.form b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/OptionsPanel.form index 85ad51f4ba1c..5800c27a6bd2 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/OptionsPanel.form +++ b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/OptionsPanel.form @@ -46,7 +46,7 @@ - + diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java index 4ede61a08dbc..4db4e778770b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java @@ -16,7 +16,6 @@ package com.intellij.codeInspection.unusedSymbol; -import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -25,10 +24,7 @@ import com.intellij.codeInspection.BaseJavaLocalInspectionTool; import com.intellij.codeInspection.ex.EntryPointsManagerImpl; import com.intellij.codeInspection.ex.UnfairLocalInspectionTool; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; import com.intellij.psi.PsiModifierListOwner; import org.intellij.lang.annotations.Pattern; import org.jetbrains.annotations.NonNls; @@ -128,17 +124,13 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp myCheckClassesCheckBox.addActionListener(listener); myCheckParametersCheckBox.addActionListener(listener); myReportUnusedParametersInPublics.addActionListener(listener); - - final JButton configureAnnotations = new JButton("Configure annotations"); - configureAnnotations.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel)); - if (project == null) project = ProjectManager.getInstance().getDefaultProject(); - EntryPointsManagerImpl.getInstance(project).configureAnnotations(); - } - }); - myAnnos.add(configureAnnotations, BorderLayout.NORTH); + final GridBagConstraints gc = + new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new Insets(0, 0, 0, 0), 0, 0); + myAnnos.add(EntryPointsManagerImpl.createConfigureAnnotationsBtn(myPanel), gc); + gc.weightx = 1; + gc.fill = GridBagConstraints.HORIZONTAL; + myAnnos.add(Box.createHorizontalBox(), gc); } public JComponent getPanel() { @@ -160,8 +152,6 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp } public static boolean isInjected(final PsiModifierListOwner modifierListOwner) { - final EntryPointsManagerImpl entryPointsManager = EntryPointsManagerImpl.getInstance(modifierListOwner.getProject()); - return AnnotationUtil.isAnnotated(modifierListOwner, entryPointsManager.ADDITIONAL_ANNOTATIONS) || - AnnotationUtil.isAnnotated(modifierListOwner, entryPointsManager.getAdditionalAnnotations()); + return EntryPointsManagerImpl.getInstance(modifierListOwner.getProject()).isEntryPoint(modifierListOwner); } } From 4fbc686cb54b281b957fa47879364a47d572ed24 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 20 Oct 2011 16:04:40 +0200 Subject: [PATCH 3/5] do not change package when chooser was canceled --- .../ui/PackageNameReferenceEditorCombo.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/ui/PackageNameReferenceEditorCombo.java b/java/java-impl/src/com/intellij/refactoring/ui/PackageNameReferenceEditorCombo.java index 86864bf2dc47..a5e0591adb81 100644 --- a/java/java-impl/src/com/intellij/refactoring/ui/PackageNameReferenceEditorCombo.java +++ b/java/java-impl/src/com/intellij/refactoring/ui/PackageNameReferenceEditorCombo.java @@ -33,12 +33,14 @@ public class PackageNameReferenceEditorCombo extends ReferenceEditorComboWithBro super(null, text, project, false, recentsKey); addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - PackageChooserDialog chooser = new PackageChooserDialog(chooserTitle, project); + final PackageChooserDialog chooser = new PackageChooserDialog(chooserTitle, project); chooser.selectPackage(getText()); chooser.show(); - PsiPackage aPackage = chooser.getSelectedPackage(); - if (aPackage != null) { - setText(aPackage.getQualifiedName()); + if (chooser.isOK()) { + final PsiPackage aPackage = chooser.getSelectedPackage(); + if (aPackage != null) { + setText(aPackage.getQualifiedName()); + } } } }); From 49c599c36af1959e91c72abbcf69b939d32de51a Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 20 Oct 2011 16:24:34 +0200 Subject: [PATCH 4/5] test console: follow running tests, scroll to the beginning for the completed tests only (IDEA-75565) --- .../ui/TestsOutputConsolePrinter.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsOutputConsolePrinter.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsOutputConsolePrinter.java index 78d9c99c84d0..0a105eb26f83 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsOutputConsolePrinter.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsOutputConsolePrinter.java @@ -106,15 +106,14 @@ public class TestsOutputConsolePrinter implements Printer, Disposable { scrollToBeginning(); } }; - if (isRoot() && myUnboundOutputRoot != null) { - myUnboundOutputRoot.invokeInAlarm(clearRunnable); - myUnboundOutputRoot.printOn(this); - myUnboundOutputRoot.invokeInAlarm(scrollRunnable); - } else { - myCurrentTest.invokeInAlarm(clearRunnable); - myCurrentTest.printOn(this); - myCurrentTest.invokeInAlarm(scrollRunnable); - } + final AbstractTestProxy currentProxyOrRoot = getCurrentProxyOrRoot(); + currentProxyOrRoot.invokeInAlarm(clearRunnable); + currentProxyOrRoot.printOn(this); + currentProxyOrRoot.invokeInAlarm(scrollRunnable); + } + + private AbstractTestProxy getCurrentProxyOrRoot() { + return isRoot() && myUnboundOutputRoot != null ? myUnboundOutputRoot : myCurrentTest; } public boolean isCurrent(CompositePrintable printable) { @@ -145,7 +144,11 @@ public class TestsOutputConsolePrinter implements Printer, Disposable { protected void scrollToBeginning() { myConsole.performWhenNoDeferredOutput(new Runnable() { public void run() { - myConsole.scrollTo(myMarkOffset); + final AbstractTestProxy currentProxyOrRoot = getCurrentProxyOrRoot(); + if (!currentProxyOrRoot.isInProgress()) { + //do not scroll to any mark during run + myConsole.scrollTo(myMarkOffset); + } } }); } From 888ba9b3305a242db3ccc68b52b5cc532fcfa0d7 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 20 Oct 2011 19:26:38 +0400 Subject: [PATCH 5/5] IDEA-75441 Fix prompthooks.py to pass 3 args to readauthforuri if needed. --- plugins/hg4idea/resources/python/prompthooks.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/hg4idea/resources/python/prompthooks.py b/plugins/hg4idea/resources/python/prompthooks.py index 9bcaf0e84384..a8ac9d47bca5 100644 --- a/plugins/hg4idea/resources/python/prompthooks.py +++ b/plugins/hg4idea/resources/python/prompthooks.py @@ -177,12 +177,18 @@ def find_user_password(self, realm, authuri): else: def read_hgrc_authtoken(ui, authuri): try: - # hg 1.8 + # since hg 1.8 from mercurial.url import readauthforuri except ImportError: # hg 1.9: readauthforuri moved to httpconnection from mercurial.httpconnection import readauthforuri - res = readauthforuri(self.ui, authuri) + from inspect import getargspec + args, _, _, _ = getargspec(readauthforuri) + if len(args) == 2: + res = readauthforuri(self.ui, authuri) + else: + # since hg 1.9.2 readauthforuri accepts 3 required arguments instead of 2 + res = readauthforuri(self.ui, authuri, "") if res: group, auth = res return auth @@ -201,4 +207,4 @@ def find_user_password(self, realm, authuri): raise util.Abort(_('http authorization required')) user, passwd = retrievedPass self.add_password(realm, authuri, user, passwd) - return retrievedPass \ No newline at end of file + return retrievedPass \ No newline at end of file