From 980198df58f0b988df6e711179fa3e3713ec8ef3 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 27 Dec 2011 19:32:46 +0100 Subject: [PATCH 01/11] CCE fix --- .../ui/treeStructure/filtered/FilteringTreeStructure.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java b/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java index b39c5fa021fc..8202a571a027 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/filtered/FilteringTreeStructure.java @@ -46,9 +46,6 @@ public class FilteringTreeStructure extends AbstractTreeStructure { } public void refilter() { - if (myStructure instanceof FilteringTreeStructure) { - ((FilteringTreeStructure)myStructure).refilter(); - } myRoot.clear(); myNodeObject2Node.clear(); fillChildren(myRoot, getStructure().getRootElement()); @@ -218,7 +215,10 @@ public class FilteringTreeStructure extends AbstractTreeStructure { @Override public boolean isAlwaysLeaf(Object element) { - return ((Node)element).isAlwaysLeaf(); + if (element instanceof Node) { + return ((Node)element).isAlwaysLeaf(); + } + return false; } @NotNull From 22341c80559929a7a5984f57a2dd5c2c86e8e94d Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 27 Dec 2011 19:49:12 +0100 Subject: [PATCH 02/11] cleanup --- .../intellij/ide/util/FileStructurePopup.java | 209 +----------------- 1 file changed, 8 insertions(+), 201 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 2b675f1b1c0a..648d063b76e8 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -16,25 +16,18 @@ package com.intellij.ide.util; import com.intellij.ide.IdeBundle; -import com.intellij.ide.commander.CommanderPanel; -import com.intellij.ide.commander.ProjectListBuilder; -import com.intellij.ide.structureView.StructureViewBuilder; import com.intellij.ide.structureView.StructureViewModel; import com.intellij.ide.structureView.StructureViewTreeElement; -import com.intellij.ide.structureView.TreeBasedStructureViewBuilder; import com.intellij.ide.structureView.newStructureView.StructureViewComponent; import com.intellij.ide.structureView.newStructureView.TreeActionsOwner; import com.intellij.ide.structureView.newStructureView.TreeModelWrapper; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.ide.util.treeView.smartTree.*; -import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.openapi.Disposable; import com.intellij.openapi.MnemonicHelper; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; @@ -49,7 +42,6 @@ import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.ui.ListScrollingUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SpeedSearchBase; import com.intellij.ui.TreeSpeedSearch; @@ -61,22 +53,18 @@ import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder; import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.tree.DefaultMutableTreeNode; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -100,8 +88,7 @@ public class FileStructurePopup implements Disposable { private FilteringTreeBuilder myAbstractTreeBuilder; private String myTitle; private TreeSpeedSearch mySpeedSearch; - private final FilteringTreeStructure myStructure; - private SmartTreeStructure mySmartTreeStructure; + private SmartTreeStructure myTreeStructure; public FileStructurePopup(StructureViewModel structureViewModel, @Nullable Editor editor, @@ -127,18 +114,7 @@ public class FileStructurePopup implements Disposable { final PsiElement psiElement = getCurrentElement(psiFile); - //myDialog.setUndecorated(true); - - if (psiElement != null) { - if (structureViewModel.shouldEnterElement(psiElement)) { - //myCommanderPanel.getBuilder().enterElement(psiElement, PsiUtilBase.getVirtualFile(psiElement)); - } - else { - //myCommanderPanel.getBuilder().selectElement(psiElement, PsiUtilBase.getVirtualFile(psiElement)); - } - } - - mySmartTreeStructure = new SmartTreeStructure(project, myTreeModel){ + myTreeStructure = new SmartTreeStructure(project, myTreeModel){ public void rebuildTree() { if (!myPopup.isDisposed()) { super.rebuildTree(); @@ -158,16 +134,12 @@ public class FileStructurePopup implements Disposable { return "structure view tree structure(model=" + myTreeModel + ")"; } }; - ElementFilter filter = new FileStructurePopupFilter(); - myStructure = new FilteringTreeStructure(project, filter, mySmartTreeStructure); - - //final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode(treeStructure.getRootElement())); - myTree = new Tree(new DefaultMutableTreeNode(myStructure.getRootElement())); + myTree = new Tree(new DefaultMutableTreeNode(myTreeStructure.getRootElement())); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); mySpeedSearch = new TreeSpeedSearch(myTree, TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING, true); - myAbstractTreeBuilder = new FilteringTreeBuilder(project, myTree, filter, myStructure, null) { + myAbstractTreeBuilder = new FilteringTreeBuilder(project, myTree, new FileStructurePopupFilter(), myTreeStructure, null) { @Override protected boolean validateNode(Object child) { return StructureViewComponent.isValid(child); @@ -225,11 +197,6 @@ public class FileStructurePopup implements Disposable { return PsiDocumentManager.getInstance(project).getPsiFile(myEditor.getDocument()); } - @Nullable - protected Border createContentPaneBorder() { - return null; - } - public void dispose() { } @@ -313,7 +280,7 @@ public class FileStructurePopup implements Disposable { return panel; } - + @Nullable private AbstractTreeNode getSelectedNode() { Object component = myTree.getSelectionPath().getLastPathComponent(); @@ -321,11 +288,8 @@ public class FileStructurePopup implements Disposable { component = ((DefaultMutableTreeNode)component).getUserObject(); if (component instanceof FilteringTreeStructure.Node) { component = ((FilteringTreeStructure.Node)component).getDelegate(); - if (component instanceof FilteringTreeStructure.Node) { - component = ((FilteringTreeStructure.Node)component).getDelegate(); - if (component instanceof AbstractTreeNode) { - return (AbstractTreeNode)component; - } + if (component instanceof AbstractTreeNode) { + return (AbstractTreeNode)component; } } } @@ -359,11 +323,6 @@ public class FileStructurePopup implements Disposable { return succeeded.get(); } - protected boolean isShowRoot(final PsiFile psiFile) { - StructureViewBuilder viewBuilder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile); - return viewBuilder instanceof TreeBasedStructureViewBuilder && ((TreeBasedStructureViewBuilder)viewBuilder).isRootNodeShown(); - } - private void addNarrowDownCheckbox(final JPanel panel) { final JCheckBox checkBox = new JCheckBox(IdeBundle.message("checkbox.narrow.down.the.list.on.typing")); checkBox.setSelected(PropertiesComponent.getInstance().isTrueValue(ourPropertyKey)); @@ -378,7 +337,6 @@ public class FileStructurePopup implements Disposable { checkBox.setFocusable(false); panel.add(checkBox); - //,new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); } private void addCheckbox(final JPanel panel, final TreeAction action) { @@ -405,7 +363,7 @@ public class FileStructurePopup implements Disposable { } final boolean state = chkFilter.isSelected(); myTreeActionsOwner.setActionIncluded(action, action instanceof FileStructureFilter ? !state : state); - mySmartTreeStructure.rebuildTree(); + myTreeStructure.rebuildTree(); myAbstractTreeBuilder.refilter(); //todo full update myAbstractTreeBuilder.queueUpdate(); if (currentParent != null) { @@ -436,163 +394,12 @@ public class FileStructurePopup implements Disposable { } chkFilter.setText(text); panel.add(chkFilter); - //,new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - } - - @Nullable - protected JComponent createSouthPanel() { - return null; } public void setTitle(String title) { myTitle = title; } - private class MyCommanderPanel extends CommanderPanel implements DataProvider { - @Override - protected boolean shouldDrillDownOnEmptyElement(final AbstractTreeNode node) { - return false; - } - - public MyCommanderPanel(Project _project) { - super(_project, false, true); - myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - myListSpeedSearch.addChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - ProjectListBuilder builder = (ProjectListBuilder)getBuilder(); - if (builder == null) { - return; - } - builder.addUpdateRequest(hasPrefixShortened(evt)); - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - int index = myList.getSelectedIndex(); - if (index != -1 && index < myList.getModel().getSize()) { - myList.clearSelection(); - ListScrollingUtil.selectItem(myList, index); - } - else { - ListScrollingUtil.ensureSelectionExists(myList); - } - } - }); - - myList.repaint(); // to update match highlighting - } - }); - myListSpeedSearch.setComparator(createSpeedSearchComparator()); - } - - private boolean hasPrefixShortened(final PropertyChangeEvent evt) { - return evt.getNewValue() != null && evt.getOldValue() != null && - ((String)evt.getNewValue()).length() < ((String)evt.getOldValue()).length(); - } - - public boolean navigateSelectedElement() { - final Ref succeeded = new Ref(); - final CommandProcessor commandProcessor = CommandProcessor.getInstance(); - commandProcessor.executeCommand(myProject, new Runnable() { - public void run() { - final AbstractTreeNode selectedNode = getSelectedNode(); - if (selectedNode != null) { - if (selectedNode.canNavigateToSource()) { - selectedNode.navigate(true); - succeeded.set(true); - } else { - succeeded.set(false); - } - } else { - succeeded.set(false); - } - - - IdeDocumentHistory.getInstance(myProject).includeCurrentCommandAsNavigation(); - } - }, "Navigate", null); - if (succeeded.get()) { - myPopup.cancel(); - } - return succeeded.get(); - } - - public Object getData(String dataId) { - Object selectedElement = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements()); - - if (selectedElement instanceof TreeElement) selectedElement = ((StructureViewTreeElement)selectedElement).getValue(); - - if (PlatformDataKeys.NAVIGATABLE.is(dataId)) { - return selectedElement instanceof Navigatable ? selectedElement : myNavigatable; - } - - if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) return myEditor; - - return getDataImpl(dataId); - } - - public String getEnteredPrefix() { - return myListSpeedSearch.getEnteredPrefix(); - } - - public void updateSpeedSearch() { - myListSpeedSearch.refreshSelection(); - } - - public void scrollSelectionInView() { - int selectedIndex = myList.getSelectedIndex(); - if (selectedIndex >= 0) { - ListScrollingUtil.ensureIndexIsVisible(myList, selectedIndex, 0); - } - } - } - - private class MyStructureTreeStructure extends SmartTreeStructure { - public MyStructureTreeStructure(Project project) { - super(project, myTreeModel); - } - - public Object[] getChildElements(Object element) { - Object[] childElements = super.getChildElements(element); - - if (!myShouldNarrowDown) { - return childElements; - } - - String enteredPrefix = null;//todo myCommanderPanel.getEnteredPrefix(); - if (enteredPrefix == null) { - return childElements; - } - - ArrayList filteredElements = new ArrayList(childElements.length); - SpeedSearchBase.SpeedSearchComparator speedSearchComparator = createSpeedSearchComparator(); - - for (Object child : childElements) { - if (child instanceof AbstractTreeNode) { - Object value = ((AbstractTreeNode)child).getValue(); - if (value instanceof TreeElement) { - String name = ((TreeElement)value).getPresentation().getPresentableText(); - if (name == null) { - continue; - } - if (speedSearchComparator.matchingFragments(enteredPrefix, name) == null) { - continue; - } - } - } - filteredElements.add(child); - } - return ArrayUtil.toObjectArray(filteredElements); - } - - public void rebuildTree() { - getChildElements(getRootElement()); // for some reason necessary to rebuild tree correctly - super.rebuildTree(); - } - } - - private static SpeedSearchBase.SpeedSearchComparator createSpeedSearchComparator() { - return new SpeedSearchBase.SpeedSearchComparator(false); - } - private class MyTreeActionsOwner implements TreeActionsOwner { private final Set myActions = new HashSet(); From 527ce9d6a148e9e81baa145fb1b0e9cc53d2505f Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 18:50:46 +0100 Subject: [PATCH 03/11] EA-31493 - IAE: ClsClassImpl.isInheritor --- .../JavaVariableConflictResolver.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaVariableConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaVariableConflictResolver.java index 4992105bdf41..d13b323cad68 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaVariableConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaVariableConflictResolver.java @@ -67,26 +67,28 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{ final PsiElement scope = currentResult.getCurrentFileResolveScope(); Boolean oldClassIsInheritor = null; - if (newClass.isInheritor(oldClass, true)) { - if (!(scope instanceof PsiClass) || - scope.equals(oldClass) || - scope.equals(newClass) || - !((PsiClass)scope).isInheritorDeep(oldClass, newClass)) { - // candidate is better - conflicts.remove(currentResult); - currentResult = candidate; - currentElement = currentResult.getElement(); - continue; + if (newClass != null && oldClass != null) { + if (newClass.isInheritor(oldClass, true)) { + if (!(scope instanceof PsiClass) || + scope.equals(oldClass) || + scope.equals(newClass) || + !((PsiClass)scope).isInheritorDeep(oldClass, newClass)) { + // candidate is better + conflicts.remove(currentResult); + currentResult = candidate; + currentElement = currentResult.getElement(); + continue; + } } - } - else if (oldClassIsInheritor = oldClass.isInheritor(newClass, true)) { - if (!(scope instanceof PsiClass) || - scope.equals(oldClass) || - scope.equals(newClass) || - !((PsiClass)scope).isInheritorDeep(newClass, oldClass)) { - // candidate is worse - conflicts.remove(candidate); - continue; + else if (oldClassIsInheritor = oldClass.isInheritor(newClass, true)) { + if (!(scope instanceof PsiClass) || + scope.equals(oldClass) || + scope.equals(newClass) || + !((PsiClass)scope).isInheritorDeep(newClass, oldClass)) { + // candidate is worse + conflicts.remove(candidate); + continue; + } } } @@ -108,7 +110,7 @@ public class JavaVariableConflictResolver implements PsiConflictResolver{ } if (oldClassIsInheritor == null) { - oldClassIsInheritor = oldClass.isInheritor(newClass, true); + oldClassIsInheritor = oldClass != null && newClass != null && oldClass.isInheritor(newClass, true); } if (oldClassIsInheritor) { // both fields are accessible From 6367299e64d907c83803dd26e671eda38bcba352 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 19:24:11 +0100 Subject: [PATCH 04/11] EA-32199 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText(cherry picked from commit 52f323e) --- .../daemon/impl/quickfix/SimplifyBooleanExpressionFix.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java index 096fdc09a8f5..c553a64486c0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java @@ -255,7 +255,7 @@ public class SimplifyBooleanExpressionFix implements IntentionAction { } else { final PsiJavaToken javaToken = expression.getTokenBeforeOperand(operand); - if (javaToken != null && !PsiTreeUtil.hasErrorElements(operand)) { + if (javaToken != null && !PsiTreeUtil.hasErrorElements(operand) && !PsiTreeUtil.hasErrorElements(lExpr)) { resultExpression = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(lExpr.getText() + javaToken.getText() + operand.getText(), expression); } else { resultExpression = null; From 95613712835f690dfd9393c22e367f68e394d84a Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 19:53:06 +0100 Subject: [PATCH 05/11] empty arrays --- .../com/intellij/patterns/compiler/PatternCompilerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/patterns/compiler/PatternCompilerImpl.java b/platform/platform-impl/src/com/intellij/patterns/compiler/PatternCompilerImpl.java index 333f3ae153bf..8db207dd45d4 100644 --- a/platform/platform-impl/src/com/intellij/patterns/compiler/PatternCompilerImpl.java +++ b/platform/platform-impl/src/com/intellij/patterns/compiler/PatternCompilerImpl.java @@ -24,6 +24,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.patterns.ElementPattern; import com.intellij.patterns.ElementPatternCondition; import com.intellij.patterns.InitialPatternCondition; +import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.ProcessingContext; import com.intellij.util.ReflectionCache; @@ -88,7 +89,7 @@ public class PatternCompilerImpl implements PatternCompiler { for (int i = 0, argsLength = args.length; i < argsLength; i++) { args[i] = args[i] instanceof String ? myStringInterner.intern((String)args[i]) : args[i]; } - return new Node((Node)frame.target, myStringInterner.intern(frame.methodName), args); + return new Node((Node)frame.target, myStringInterner.intern(frame.methodName), args.length == 0 ? ArrayUtil.EMPTY_OBJECT_ARRAY : args); } }); return new LazyPresentablePattern(node); From 6e1b69cce29390eb12ca8b411de397da0b5e3f48 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Tue, 27 Dec 2011 23:02:13 +0400 Subject: [PATCH 06/11] IDEA-78745 Vertical flicker when mouse crosses over Recent Projects list --- .../intellij/ui/SimpleColoredComponent.java | 2 +- .../wm/impl/welcomeScreen/WelcomeScreen.java | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index fe90cc54a9ab..e561c56e0cd0 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -65,7 +65,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { /** * Gap between icon and text. It is used only if icon is defined. */ - private int myIconTextGap; + protected int myIconTextGap; /** * Defines whether the focus border around the text is painted or not. * For example, text can have a border if the component represents a selected item diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java index eb225e263c86..254db9821ba5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java @@ -100,6 +100,7 @@ public class WelcomeScreen implements Disposable { @NonNls private static final String HTML_SUFFIX = ""; @NonNls private static final String ___HTML_SUFFIX = "..."; @NonNls private static final String ESC_NEW_LINE = "\\n"; + public static final Icon ICON = IconLoader.getIcon("/actions/closeNew.png"); private final JPanel myWelcomePanel; private final JPanel myMainPanel; @@ -242,7 +243,19 @@ public class WelcomeScreen implements Disposable { int row = 1; for (final AnAction action : recentProjectsActions) { - final SimpleColoredComponent actionLabel = new SimpleColoredComponent(); + final SimpleColoredComponent actionLabel = new SimpleColoredComponent() { + @Override + public Dimension getPreferredSize() { + boolean hasIcon = getIcon() != null; + Dimension preferredSize = super.getPreferredSize(); + return new Dimension(preferredSize.width + (hasIcon ? 0 : ICON.getIconWidth() + myIconTextGap), preferredSize.height); + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + }; actionLabel.append(String.valueOf(row), CAPTION_UNDERLINE_ATTRIBUTES); actionLabel.append(". ", new SimpleTextAttributes(0, CAPTION_COLOR)); actionLabel.append(action.getTemplatePresentation().getText(), CAPTION_BOLD_UNDERLINE_ATTRIBUTES); @@ -298,9 +311,7 @@ public class WelcomeScreen implements Disposable { @Override public void mouseEntered(MouseEvent e) { - if (actionLabel.getSize().width > actionLabel.getPreferredSize().width) { - actionLabel.setIcon(IconLoader.getIcon("/actions/closeNew.png")); - } + actionLabel.setIcon(ICON); } @Override From 2ecb9f67b1b10745660b0c47089543723446775b Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 27 Dec 2011 20:07:57 +0100 Subject: [PATCH 07/11] move: do not bind to non-physical elements (EA-32749 - IOE: FileReference.bindToElement) --- .../com/intellij/refactoring/move/FileReferenceContextUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/FileReferenceContextUtil.java b/platform/lang-impl/src/com/intellij/refactoring/move/FileReferenceContextUtil.java index 784e4b47a48d..e5fafd442a26 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/FileReferenceContextUtil.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/FileReferenceContextUtil.java @@ -114,7 +114,7 @@ public class FileReferenceContextUtil { } private static PsiElement bindElement(final PsiElement element, PsiFileSystemItem item) { - if (item != null && item.isValid()) { + if (item != null && item.isValid() && item.getVirtualFile() != null) { PsiReference[] refs = element.getReferences(); for (PsiReference ref : refs) { if (ref instanceof FileReferenceOwner) { From 026079252b31cbbd3da929671182604c70e3efbe Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 27 Dec 2011 22:40:29 +0100 Subject: [PATCH 08/11] a bit more tolerance to weird system configurations --- .../src/com/intellij/ide/ui/LafManagerImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java index 9de98fdff018..1f4fd6388ea8 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java @@ -248,17 +248,20 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo */ private UIManager.LookAndFeelInfo getDefaultLaf() { final String lowercaseProductName = ApplicationNamesInfo.getInstance().getLowercaseProductName(); + final String systemLafClassName = UIManager.getSystemLookAndFeelClassName(); if (SystemInfo.isMac) { - UIManager.LookAndFeelInfo laf = findLaf(UIManager.getSystemLookAndFeelClassName()); + UIManager.LookAndFeelInfo laf = findLaf(systemLafClassName); LOG.assertTrue(laf != null); return laf; } if ("Rubymine".equals(lowercaseProductName) || "Pycharm".equals(lowercaseProductName)) { final String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); if ("gnome".equals(desktop)) { - UIManager.LookAndFeelInfo laf=findLaf(UIManager.getSystemLookAndFeelClassName()); - LOG.assertTrue(laf!=null); - return laf; + UIManager.LookAndFeelInfo laf=findLaf(systemLafClassName); + if (laf != null) { + return laf; + } + LOG.info("Could not find system look and feel: " + laf); } } // Default From 1e0714b310b396dc5701e65bc738bde34819b98b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 27 Dec 2011 22:42:59 +0100 Subject: [PATCH 09/11] register JavaResolveCache in JavaCoreEnvironment --- .../intellij/core/JavaCoreEnvironment.java | 4 +++- .../impl/source/resolve/JavaResolveCache.java | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java index 5d048e6a762c..3abd69097571 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java @@ -37,6 +37,7 @@ import com.intellij.psi.impl.compiled.ClassFileStubBuilder; import com.intellij.psi.impl.compiled.ClsStubBuilderFactory; import com.intellij.psi.impl.compiled.DefaultClsStubBuilderFactory; import com.intellij.psi.impl.file.PsiPackageImplementationHelper; +import com.intellij.psi.impl.source.resolve.JavaResolveCache; import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl; import com.intellij.psi.impl.source.tree.CoreJavaASTFactory; import com.intellij.psi.stubs.BinaryFileStubBuilders; @@ -80,7 +81,8 @@ public class JavaCoreEnvironment extends CoreEnvironment { myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager)); myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension()); myProject.registerService(PackageIndex.class, myFileManager); - + myProject.registerService(JavaResolveCache.class, new JavaResolveCache(null)); + myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl()); myApplication.registerService(JavaDirectoryService.class, new CoreJavaDirectoryService()); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java index 38eb67cdd892..e63943379f8b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java @@ -70,16 +70,18 @@ public class JavaResolveCache { myVarToConstValueMapPhysical = new ConcurrentWeakHashMap(); myVarToConstValueMapNonPhysical = new ConcurrentWeakHashMap(); - messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() { - @Override - public void beforePsiChanged(boolean isPhysical) { - clearCaches(isPhysical); - } - - @Override - public void afterPsiChanged(boolean isPhysical) { - } - }); + if (messageBus != null) { + messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() { + @Override + public void beforePsiChanged(boolean isPhysical) { + clearCaches(isPhysical); + } + + @Override + public void afterPsiChanged(boolean isPhysical) { + } + }); + } } private void clearCaches(boolean isPhysical) { From 881aa60d8a4358e71cbaae64bc01e95092e10e21 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 26 Dec 2011 13:57:05 +0400 Subject: [PATCH 10/11] cleanup --- .../src/com/intellij/refactoring/ui/MethodCellRenderer.java | 4 +--- platform/core-api/src/com/intellij/psi/impl/ElementBase.java | 2 +- .../codeInsight/lookup/DefaultLookupItemRenderer.java | 5 ++--- .../src/com/intellij/openapi/ui/VerticalFlowLayout.java | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/ui/MethodCellRenderer.java b/java/java-impl/src/com/intellij/refactoring/ui/MethodCellRenderer.java index 99cfd34f29b1..b7ddf433ecad 100644 --- a/java/java-impl/src/com/intellij/refactoring/ui/MethodCellRenderer.java +++ b/java/java-impl/src/com/intellij/refactoring/ui/MethodCellRenderer.java @@ -42,9 +42,7 @@ public class MethodCellRenderer extends DefaultListCellRenderer { PsiFormatUtil.SHOW_TYPE); setText(text); - final int flags = Iconable.ICON_FLAG_VISIBILITY; - - Icon icon = method.getIcon(flags); + Icon icon = method.getIcon(Iconable.ICON_FLAG_VISIBILITY); if(icon != null) setIcon(icon); return this; } diff --git a/platform/core-api/src/com/intellij/psi/impl/ElementBase.java b/platform/core-api/src/com/intellij/psi/impl/ElementBase.java index 9b9be421e145..f3a46d39df0f 100644 --- a/platform/core-api/src/com/intellij/psi/impl/ElementBase.java +++ b/platform/core-api/src/com/intellij/psi/impl/ElementBase.java @@ -150,7 +150,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable } public static boolean isNativeFileType(FileType fileType) { - return (fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon()) || fileType instanceof UnknownFileType; + return fileType instanceof INativeFileType && ((INativeFileType) fileType).useNativeIcon() || fileType instanceof UnknownFileType; } protected Icon getAdjustedBaseIcon(Icon icon, int flags) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/DefaultLookupItemRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/DefaultLookupItemRenderer.java index 6d6d7b78ae94..bd6a7f45aed7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/DefaultLookupItemRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/DefaultLookupItemRenderer.java @@ -61,7 +61,6 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer Object o = item.getObject(); - int flags = Iconable.ICON_FLAG_VISIBILITY; if (!real) { if (item.getObject() instanceof String) { return EmptyIcon.ICON_0; @@ -71,7 +70,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer } if (o instanceof Iconable && !(o instanceof PsiElement)) { - return ((Iconable)o).getIcon(flags); + return ((Iconable)o).getIcon(Iconable.ICON_FLAG_VISIBILITY); } if (o instanceof LookupValueWithPsiElement) { @@ -80,7 +79,7 @@ public class DefaultLookupItemRenderer extends LookupElementRenderer if (o instanceof PsiElement) { final PsiElement element = (PsiElement)o; if (element.isValid()) { - return element.getIcon(flags); + return element.getIcon(Iconable.ICON_FLAG_VISIBILITY); } } return null; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java b/platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java index e80b9e36a4bd..782257819c0b 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java @@ -24,8 +24,8 @@ public class VerticalFlowLayout extends FlowLayout implements Serializable { public static final int TOP = 0; private boolean myVerticalFill; private boolean myHorizontalFill; - private int vGap; - private int hGap; + private final int vGap; + private final int hGap; public VerticalFlowLayout() { this(TOP, 5, 5, true, false); From 4fecca48873b741a39c28138aab6234f7eeff076 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 28 Dec 2011 12:37:58 +0400 Subject: [PATCH 11/11] cleanup --- .../intellij/peer/impl/PeerFactoryImpl.java | 13 ++- .../ExternalAnnotationsManagerImpl.java | 91 +++++++++---------- .../completion/ModifierChooser.java | 2 +- .../impl/analysis/HighlightMessageUtil.java | 5 +- .../impl/quickfix/CreateFromUsageUtils.java | 2 +- .../impl/quickfix/CreateMethodQuickFix.java | 8 +- .../quickfix/CreateParameterFromUsageFix.java | 2 +- .../generation/ui/SimpleFieldChooser.java | 8 +- .../codeInspection/dataFlow/DfaUtil.java | 20 ++-- .../reference/RefJavaElementImpl.java | 1 - .../lang/java/JavaDocumentationProvider.java | 21 +++-- .../intellij/psi/impl/light/LightField.java | 2 +- .../typeMigration/ui/MigrationPanel.java | 28 ++---- .../duplicates/MethodDuplicatesHandler.java | 2 +- .../impl/source/PsiMethodReceiverImpl.java | 2 +- .../refactoring/EncapsulateFieldsTest.java | 2 - .../ExternalAnnotationsManager.java | 19 ++-- .../colors/ColorAndFontDescriptionPanel.java | 4 +- .../codeInsight/lookup/LookupItem.java | 2 +- .../ui/InspectionsConfigTreeRenderer.java | 4 +- .../ChangeSignatureDialogBase.java | 5 +- .../ui/debugger/extensions/FocusDebugger.java | 4 +- .../openapi/actionSystem/ActionPlaces.java | 4 +- .../impl/ComplementaryFontsRegistry.java | 4 +- .../generate/tostring/psi/PsiAdapter.java | 12 +-- .../intentions/CreateClassActionBase.java | 2 +- .../packaging/GrPackageDefinitionImpl.java | 3 +- .../convertToJava/StubGenerator.java | 2 +- .../dynamicMembers/GrDynamicMethodImpl.java | 2 +- .../dynamicMembers/GrDynamicPropertyImpl.java | 2 +- .../execution/junit2/ui/TestColumnInfo.java | 6 +- .../execution/junit2/ui/TestRenderer.java | 3 +- .../configuration/browser/MethodList.java | 11 ++- 33 files changed, 154 insertions(+), 144 deletions(-) diff --git a/java/idea-ui/src/com/intellij/peer/impl/PeerFactoryImpl.java b/java/idea-ui/src/com/intellij/peer/impl/PeerFactoryImpl.java index 86443a6e1d20..f39213655274 100644 --- a/java/idea-ui/src/com/intellij/peer/impl/PeerFactoryImpl.java +++ b/java/idea-ui/src/com/intellij/peer/impl/PeerFactoryImpl.java @@ -47,6 +47,7 @@ import com.intellij.peer.PeerFactory; import com.intellij.psi.*; import com.intellij.psi.search.scope.packageSet.PackageSetFactory; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.ui.*; import com.intellij.ui.TextComponent; import com.intellij.ui.content.ContentFactory; @@ -197,18 +198,22 @@ public class PeerFactoryImpl extends PeerFactory { private static String getPsiElementText(PsiElement psiElement) { if (psiElement instanceof PsiClass) { - return PsiFormatUtil.formatClass((PsiClass)psiElement, PsiFormatUtil.SHOW_NAME | - PsiFormatUtil.SHOW_FQ_NAME); + return PsiFormatUtil.formatClass((PsiClass)psiElement, PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_FQ_NAME); } else if (psiElement instanceof PsiMethod) { return PsiFormatUtil.formatMethod((PsiMethod)psiElement, PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_CONTAINING_CLASS, + PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_PARAMETERS | + PsiFormatUtilBase.SHOW_CONTAINING_CLASS, 0); } else if (psiElement instanceof PsiField) { return PsiFormatUtil.formatVariable((PsiField)psiElement, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_CONTAINING_CLASS, + PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_TYPE | + PsiFormatUtilBase.SHOW_CONTAINING_CLASS, PsiSubstitutor.EMPTY); } else { diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index bb0c6eed7d53..486ad032946b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -121,12 +121,12 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } @Nullable - public PsiAnnotation findExternalAnnotation(final PsiModifierListOwner listOwner, final String annotationFQN) { + public PsiAnnotation findExternalAnnotation(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) { return collectExternalAnnotations(listOwner).get(annotationFQN); } @Nullable - public PsiAnnotation[] findExternalAnnotations(final PsiModifierListOwner listOwner) { + public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) { final Map result = collectExternalAnnotations(listOwner); return result.isEmpty() ? null : result.values().toArray(new PsiAnnotation[result.size()]); } @@ -136,43 +136,42 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap(); final Map result = new HashMap(); final List files = findExternalAnnotationsFile(listOwner); - if (files != null) { - for (XmlFile file : files) { - if (file.isValid()) { - final XmlDocument document = file.getDocument(); - if (document != null) { - final XmlTag rootTag = document.getRootTag(); - if (rootTag != null) { - final String externalName = PsiFormatUtil.getExternalName(listOwner, false); - final String oldExternalName = getNormalizedExternalName(listOwner); - for (final XmlTag tag : rootTag.getSubTags()) { - final String className = tag.getAttributeValue("name"); - if (Comparing.strEqual(className, externalName) || Comparing.strEqual(className, oldExternalName)) { - for (XmlTag annotationTag : tag.getSubTags()) { - final String annotationFQN = annotationTag.getAttributeValue("name"); - final StringBuilder buf = new StringBuilder(); - for (XmlTag annotationaParameter : annotationTag.getSubTags()) { - buf.append(","); - final String nameValue = annotationaParameter.getAttributeValue("name"); - if (nameValue != null) { - buf.append(nameValue).append("="); - } - buf.append(StringUtil.unescapeXml(annotationaParameter.getAttributeValue("val"))); - } - final String annotationText = - "@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : ""); - try { - result.put(annotationFQN, - JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText( - annotationText, null)); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - } - } - } + if (files == null) { + return Collections.emptyMap(); + } + for (XmlFile file : files) { + if (!file.isValid()) continue; + final XmlDocument document = file.getDocument(); + if (document == null) continue; + final XmlTag rootTag = document.getRootTag(); + if (rootTag == null) continue; + final String externalName = PsiFormatUtil.getExternalName(listOwner, false); + final String oldExternalName = getNormalizedExternalName(listOwner); + for (final XmlTag tag : rootTag.getSubTags()) { + final String className = tag.getAttributeValue("name"); + if (!Comparing.strEqual(className, externalName) && !Comparing.strEqual(className, oldExternalName)) { + continue; + } + for (XmlTag annotationTag : tag.getSubTags()) { + final String annotationFQN = annotationTag.getAttributeValue("name"); + final StringBuilder buf = new StringBuilder(); + for (XmlTag annotationParameter : annotationTag.getSubTags()) { + buf.append(","); + final String nameValue = annotationParameter.getAttributeValue("name"); + if (nameValue != null) { + buf.append(nameValue).append("="); } + buf.append(StringUtil.unescapeXml(annotationParameter.getAttributeValue("val"))); + } + final String annotationText = + "@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : ""); + try { + result.put(annotationFQN, + JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText( + annotationText, null)); + } + catch (IncorrectOperationException e) { + LOG.error(e); } } } @@ -181,9 +180,9 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } - public void annotateExternally(final PsiModifierListOwner listOwner, - final String annotationFQName, - final PsiFile fromFile, + public void annotateExternally(@NotNull final PsiModifierListOwner listOwner, + @NotNull final String annotationFQName, + @NotNull final PsiFile fromFile, final PsiNameValuePair[] value) { final Project project = listOwner.getProject(); final PsiFile containingFile = listOwner.getContainingFile(); @@ -246,7 +245,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } } - private void chooseRootAndAnnotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, final PsiFile fromFile, + private void chooseRootAndAnnotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, @NotNull final PsiFile fromFile, final Project project, final String packageName, final VirtualFile virtualFile, final VirtualFile[] virtualFiles, final PsiNameValuePair[] value) { if (virtualFiles.length > 1) { @@ -277,7 +276,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { final String packageName, final VirtualFile virtualFile, final String annotationFQName, - final PsiFile fromFile, + @NotNull final PsiFile fromFile, final PsiNameValuePair[] value) { final XmlFile[] annotationsXml = new XmlFile[1]; List xmlFiles = findExternalAnnotationsFile(listOwner); @@ -309,7 +308,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { }.execute(); } - public boolean deannotate(final PsiModifierListOwner listOwner, final String annotationFQN) { + public boolean deannotate(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) { final List files = findExternalAnnotationsFile(listOwner); if (files != null) { for (XmlFile file : files) { @@ -440,7 +439,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { private static void annotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, @Nullable final XmlFile xmlFile, - final PsiFile codeUsageFile, PsiNameValuePair[] values) { + @NotNull PsiFile codeUsageFile, PsiNameValuePair[] values) { if (xmlFile == null) return; try { final XmlDocument document = xmlFile.getDocument(); @@ -535,7 +534,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager { } @Nullable - private List findExternalAnnotationsFile(PsiModifierListOwner listOwner) { + private List findExternalAnnotationsFile(@NotNull PsiModifierListOwner listOwner) { final Project project = listOwner.getProject(); final PsiFile containingFile = listOwner.getContainingFile(); if (containingFile instanceof PsiJavaFile) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/ModifierChooser.java b/java/java-impl/src/com/intellij/codeInsight/completion/ModifierChooser.java index 66f378d631d7..71c70f4c657e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/ModifierChooser.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/ModifierChooser.java @@ -90,7 +90,7 @@ public class ModifierChooser { final String[] keywords = keywordSets[keywordSets.length - i - 1]; boolean containModifierFlag = false; if (list != null) { - for (@Modifier String keyword : keywords) { + for (String keyword : keywords) { if (list.hasExplicitModifier(keyword)) { containModifierFlag = true; break; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java index 6f28962feb97..2e74ed7f3f91 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMessageUtil.java @@ -18,6 +18,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.lang.LangBundle; import com.intellij.psi.*; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,8 +42,8 @@ public class HighlightMessageUtil { } else if (symbol instanceof PsiMethod) { symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol, - substitutor, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, - PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES); + substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, + PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES); } else if (symbol instanceof PsiVariable) { symbolName = ((PsiVariable)symbol).getName(); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index b06471bdb01a..ebd05b22788e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -400,7 +400,7 @@ public class CreateFromUsageUtils { return null; } if (!facade.getResolveHelper().isAccessible(targetClass, contextElement, null)) { - PsiUtil.setModifierProperty(targetClass, PsiKeyword.PUBLIC, true); + PsiUtil.setModifierProperty(targetClass, PsiModifier.PUBLIC, true); } } else { //tests diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodQuickFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodQuickFix.java index 6be06c0a1bcc..28de8496e7aa 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodQuickFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodQuickFix.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -50,8 +51,11 @@ public class CreateMethodQuickFix implements LocalQuickFix { public String getName() { String signature = PsiFormatUtil.formatMethod(createMethod(myTargetClass.getProject()), PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_RAW_TYPE, - PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_RAW_TYPE, 2); + PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_TYPE | + PsiFormatUtilBase.SHOW_PARAMETERS | + PsiFormatUtilBase.SHOW_RAW_TYPE, + PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_RAW_TYPE, 2); return QuickFixBundle.message("create.method.from.usage.text", signature); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java index fa0c5b5f61b8..d1377f691e39 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java @@ -95,7 +95,7 @@ public class CreateParameterFromUsageFix extends CreateVarFromUsageFix { if (ApplicationManager.getApplication().isUnitTestMode()) { ParameterInfoImpl[] array = parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]); - @Modifier String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(method.getModifierList())); + String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(method.getModifierList())); ChangeSignatureProcessor processor = new ChangeSignatureProcessor(project, method, false, modifier, method.getName(), method.getReturnType(), array); processor.run(); diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/ui/SimpleFieldChooser.java b/java/java-impl/src/com/intellij/codeInsight/generation/ui/SimpleFieldChooser.java index d4c8fc9bfe96..ff013dec0d16 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/ui/SimpleFieldChooser.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/ui/SimpleFieldChooser.java @@ -18,9 +18,9 @@ package com.intellij.codeInsight.generation.ui; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.psi.PsiField; -import com.intellij.psi.PsiNamedElement; import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.ui.components.JBList; import javax.swing.*; @@ -68,14 +68,14 @@ public class SimpleFieldChooser extends DialogWrapper { return myList.getSelectedValues(); } - private class MyListCellRenderer extends DefaultListCellRenderer { + private static class MyListCellRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Icon icon = null; super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + Icon icon = null; if (value instanceof PsiField) { PsiField field = (PsiField)value; icon = field.getIcon(0); - final String text = PsiFormatUtil.formatVariable(field, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE, PsiSubstitutor.EMPTY); + final String text = PsiFormatUtil.formatVariable(field, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE, PsiSubstitutor.EMPTY); setText(text); } super.setIcon(icon); diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java index 740bcee30bf9..a31bdafc1e04 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java @@ -144,21 +144,23 @@ public class DfaUtil { return codeBlock; } + @NotNull public static Collection getPossibleInitializationElements(final PsiElement qualifierExpression) { if (qualifierExpression instanceof PsiMethodCallExpression) { return Collections.singletonList(qualifierExpression); } - else if (qualifierExpression instanceof PsiReferenceExpression) { + if (qualifierExpression instanceof PsiReferenceExpression) { final PsiElement targetElement = ((PsiReferenceExpression)qualifierExpression).resolve(); - if (targetElement instanceof PsiVariable) { - final Collection variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression); - if ((variableValues == null || variableValues.isEmpty())) { - return getVariableAssignmentsInFile((PsiVariable)targetElement, false, qualifierExpression); - } - return variableValues; + if (!(targetElement instanceof PsiVariable)) { + return Collections.emptyList(); } + final Collection variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression); + if (variableValues == null || variableValues.isEmpty()) { + return getVariableAssignmentsInFile((PsiVariable)targetElement, false, qualifierExpression); + } + return variableValues; } - else if (qualifierExpression instanceof PsiLiteralExpression) { + if (qualifierExpression instanceof PsiLiteralExpression) { return Collections.singletonList(qualifierExpression); } return Collections.emptyList(); @@ -239,7 +241,7 @@ public class DfaUtil { final Set myNotNulls = new THashSet(); private final PsiElement myContext; - public ValuableInstructionVisitor(PsiElement context) { + public ValuableInstructionVisitor(@NotNull PsiElement context) { myContext = context; } diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java index 769d78878f38..1a9ac6b11bfd 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaElementImpl.java @@ -152,7 +152,6 @@ public abstract class RefJavaElementImpl extends RefElementImpl implements RefJa setFlag(b, IS_SYNTHETIC_JSP_ELEMENT); } - @Modifier @Nullable public String getAccessModifier() { long access_id = myFlags & ACCESS_MODIFIER_MASK; diff --git a/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java b/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java index e8776917a740..8fe14eb39185 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java @@ -46,6 +46,7 @@ import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.javadoc.PsiDocTag; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.util.StringBuilderSpinAllocator; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NonNls; @@ -130,7 +131,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } private static void generateModifiers(StringBuilder buffer, PsiElement element) { - String modifiers = PsiFormatUtil.formatModifiers(element, PsiFormatUtil.JAVADOC_MODIFIERS_ONLY); + String modifiers = PsiFormatUtil.formatModifiers(element, PsiFormatUtilBase.JAVADOC_MODIFIERS_ONLY); if (modifiers.length() > 0) { buffer.append(modifiers); @@ -531,8 +532,10 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } final String str = PsiFormatUtil.formatMethod((PsiMethod)element, candidate.getSubstitutor(), - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_PARAMETERS, - PsiFormatUtil.SHOW_TYPE); + PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_TYPE | + PsiFormatUtilBase.SHOW_PARAMETERS, + PsiFormatUtilBase.SHOW_TYPE); createElementLink(sb, element, StringUtil.escapeXml(str)); } @@ -583,8 +586,8 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext urls.add(classUrl + "#" + signature); } signature = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, - PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES, 999); + PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, + PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES, 999); for (String classUrl : classUrls) { urls.add(classUrl + "#" + signature); } @@ -614,8 +617,12 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext public static String formatMethodSignature(PsiMethod method) { return PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS | PsiFormatUtil.SHOW_RAW_NON_TOP_TYPE, - PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES | PsiFormatUtil.SHOW_RAW_NON_TOP_TYPE, + PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_PARAMETERS | + PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE, + PsiFormatUtilBase.SHOW_TYPE | + PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES | + PsiFormatUtilBase.SHOW_RAW_NON_TOP_TYPE, 999); } diff --git a/java/java-impl/src/com/intellij/psi/impl/light/LightField.java b/java/java-impl/src/com/intellij/psi/impl/light/LightField.java index e337f7ae7cd2..8e15c1620552 100644 --- a/java/java-impl/src/com/intellij/psi/impl/light/LightField.java +++ b/java/java-impl/src/com/intellij/psi/impl/light/LightField.java @@ -119,7 +119,7 @@ public class LightField extends LightElement implements PsiField { } @Override - public boolean hasModifierProperty(@Modifier @NonNls @NotNull final String name) { + public boolean hasModifierProperty(@NonNls @NotNull final String name) { return myField.hasModifierProperty(name); } diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java index 588cd58de723..0433fb97b059 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java @@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.presentation.java.SymbolPresentationUtil; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.typeMigration.ChangeTypeSignatureHandler; @@ -456,28 +457,19 @@ public class MigrationPanel extends JPanel implements Disposable { else { final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class); if (member instanceof PsiField) { - location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtil - .SHOW_NAME | - PsiFormatUtil - .SHOW_CONTAINING_CLASS | - PsiFormatUtil - .SHOW_FQ_NAME, PsiSubstitutor.EMPTY); + location = PsiFormatUtil.formatVariable((PsiVariable)member, PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_CONTAINING_CLASS | + PsiFormatUtilBase.SHOW_FQ_NAME, PsiSubstitutor.EMPTY); } else if (member instanceof PsiMethod) { - location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtil - .SHOW_NAME | - PsiFormatUtil - .SHOW_CONTAINING_CLASS | - PsiFormatUtil - .SHOW_FQ_NAME, PsiFormatUtil.SHOW_TYPE); + location = PsiFormatUtil.formatMethod((PsiMethod)member, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_CONTAINING_CLASS | + PsiFormatUtilBase.SHOW_FQ_NAME, + PsiFormatUtilBase.SHOW_TYPE); } else if (member instanceof PsiClass) { - location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtil - .SHOW_NAME | - PsiFormatUtil - .SHOW_CONTAINING_CLASS | - PsiFormatUtil - .SHOW_FQ_NAME); + location = PsiFormatUtil.formatClass((PsiClass)member, PsiFormatUtilBase.SHOW_NAME | + PsiFormatUtilBase.SHOW_FQ_NAME); } else { location = null; diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesHandler.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesHandler.java index 19bb6ef9c388..2a90270b12a3 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesHandler.java @@ -369,7 +369,7 @@ public class MethodDuplicatesHandler implements RefactoringActionHandler { @Nullable public String getConfirmDuplicatePrompt(final Match match) { final PsiElement matchStart = match.getMatchStart(); - @Modifier String visibility = VisibilityUtil.getPossibleVisibility(myMethod, matchStart); + String visibility = VisibilityUtil.getPossibleVisibility(myMethod, matchStart); final boolean shouldBeStatic = isEssentialStaticContextAbsent(match); final String signature = match.getChangedSignature(myMethod, myMethod.hasModifierProperty(PsiModifier.STATIC) || shouldBeStatic, visibility); if (signature != null) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiMethodReceiverImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiMethodReceiverImpl.java index b8a936c7e0ca..166e157a4fb6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiMethodReceiverImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiMethodReceiverImpl.java @@ -113,7 +113,7 @@ public class PsiMethodReceiverImpl extends CompositePsiElement implements PsiMet } @Override - public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) { + public boolean hasModifierProperty(@NonNls @NotNull String name) { return false; } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/EncapsulateFieldsTest.java b/java/java-tests/testSrc/com/intellij/refactoring/EncapsulateFieldsTest.java index e80107deef0e..a880f1217976 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/EncapsulateFieldsTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/EncapsulateFieldsTest.java @@ -131,13 +131,11 @@ public class EncapsulateFieldsTest extends MultiFileTestCase{ } @Override - @Modifier public String getFieldsVisibility() { return null; } @Override - @Modifier public String getAccessorsVisibility() { return PsiModifier.PUBLIC; } diff --git a/java/openapi/src/com/intellij/codeInsight/ExternalAnnotationsManager.java b/java/openapi/src/com/intellij/codeInsight/ExternalAnnotationsManager.java index e9d48d8a370f..67fd1cffb3e0 100644 --- a/java/openapi/src/com/intellij/codeInsight/ExternalAnnotationsManager.java +++ b/java/openapi/src/com/intellij/codeInsight/ExternalAnnotationsManager.java @@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NotNullLazyKey; import com.intellij.psi.*; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public abstract class ExternalAnnotationsManager { @@ -38,23 +39,23 @@ public abstract class ExternalAnnotationsManager { private static final NotNullLazyKey INSTANCE_KEY = ServiceManager.createLazyKey(ExternalAnnotationsManager.class); - public static ExternalAnnotationsManager getInstance(Project project) { + public static ExternalAnnotationsManager getInstance(@NotNull Project project) { return INSTANCE_KEY.getValue(project); } @Nullable - public abstract PsiAnnotation findExternalAnnotation(final PsiModifierListOwner listOwner, final String annotationFQN); + public abstract PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN); @Nullable - public abstract PsiAnnotation[] findExternalAnnotations(final PsiModifierListOwner listOwner); + public abstract PsiAnnotation[] findExternalAnnotations(@NotNull PsiModifierListOwner listOwner); - public abstract void annotateExternally(final PsiModifierListOwner listOwner, - final String annotationFQName, - final PsiFile fromFile, - final PsiNameValuePair[] value); + public abstract void annotateExternally(@NotNull PsiModifierListOwner listOwner, + @NotNull String annotationFQName, + @NotNull PsiFile fromFile, + PsiNameValuePair[] value); - public abstract boolean deannotate(final PsiModifierListOwner listOwner, final String annotationFQN); + public abstract boolean deannotate(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN); - public abstract AnnotationPlace chooseAnnotationsPlace(final PsiElement element); + public abstract AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java index 4bfe1239bbe9..700344b363de 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java @@ -381,8 +381,8 @@ public class ColorAndFontDescriptionPanel extends JPanel { public void apply(ColorAndFontDescription description, EditorColorsScheme scheme) { if (description != null) { int fontType = Font.PLAIN; - if (myCbBold.isSelected()) fontType += Font.BOLD; - if (myCbItalic.isSelected()) fontType += Font.ITALIC; + if (myCbBold.isSelected()) fontType |= Font.BOLD; + if (myCbItalic.isSelected()) fontType |= Font.ITALIC; description.setFontType(fontType); description.setForegroundChecked(myCbForeground.isSelected()); description.setForegroundColor(myForegroundChooser.getSelectedColor()); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupItem.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupItem.java index dd9c7ea5193e..9131a5ab84da 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupItem.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupItem.java @@ -71,7 +71,7 @@ public class LookupItem extends MutableLookupElement implements Comparable private AutoCompletionPolicy myAutoCompletionPolicy = AutoCompletionPolicy.SETTINGS_DEPENDENT; /** - * @deprecated use LookupElementBuilder + * @deprecated use {@link LookupElementBuilder} */ public LookupItem(T o, @NotNull @NonNls String lookupString) { setObject(o); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java index 904d101cf700..3fa4229745f9 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java @@ -54,11 +54,11 @@ abstract class InspectionsConfigTreeRenderer extends CheckboxTree.CheckboxTreeCe selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting ? Color.BLUE : UIUtil.getTreeTextForeground(); @NonNls String text = null; - int style = Font.PLAIN; + int style = SimpleTextAttributes.STYLE_PLAIN; String hint = null; if (object instanceof String) { text = (String)object; - style = Font.BOLD; + style = SimpleTextAttributes.STYLE_BOLD; } else { final Descriptor descriptor = node.getDesriptor(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java index fa324b0344e2..f1d63f26a277 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java @@ -53,7 +53,6 @@ import com.intellij.util.ui.table.JBListTable; import com.intellij.util.ui.table.JBTableRow; import com.intellij.util.ui.table.JBTableRowEditor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -65,8 +64,10 @@ import javax.swing.table.TableCellEditor; import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Set; /** * @author Konstantin Bulenkov diff --git a/platform/lang-impl/src/com/intellij/ui/debugger/extensions/FocusDebugger.java b/platform/lang-impl/src/com/intellij/ui/debugger/extensions/FocusDebugger.java index 2c311ee6aabe..63ff0484e9ef 100644 --- a/platform/lang-impl/src/com/intellij/ui/debugger/extensions/FocusDebugger.java +++ b/platform/lang-impl/src/com/intellij/ui/debugger/extensions/FocusDebugger.java @@ -161,7 +161,7 @@ public class FocusDebugger implements UiDebuggerExtension, PropertyChangeListene return greyOut ? attr.derive(attr.getStyle(), Color.gray, attr.getBgColor(), attr.getWaveColor()) : attr; } - class FocusElementRenderer extends ColoredListCellRenderer { + static class FocusElementRenderer extends ColoredListCellRenderer { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { clear(); @@ -175,7 +175,7 @@ public class FocusDebugger implements UiDebuggerExtension, PropertyChangeListene } } - class FocusElement { + static class FocusElement { private final SimpleColoredText myText; private final Throwable myAllocation; diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java index 9b80ee15d7dc..87dde8a28e90 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java @@ -111,7 +111,7 @@ public abstract class ActionPlaces { public static final String CHANGES_LOCAL_DIFF_SETTINGS = "CHANGES_LOCAL_DIFF_SETTINGS"; - private static final String[] ourToolbarPlaces = new String[]{EDITOR_TOOLBAR, PROJECT_VIEW_TOOLBAR, TESTTREE_VIEW_TOOLBAR, MAIN_TOOLBAR, + private static final String[] ourToolbarPlaces = {EDITOR_TOOLBAR, PROJECT_VIEW_TOOLBAR, TESTTREE_VIEW_TOOLBAR, MAIN_TOOLBAR, ANT_EXPLORER_TOOLBAR, ANT_MESSAGES_TOOLBAR, COMPILER_MESSAGES_TOOLBAR, TODO_VIEW_TOOLBAR, STRUCTURE_VIEW_TOOLBAR, USAGE_VIEW_TOOLBAR, DEBUGGER_TOOLBAR, CALL_HIERARCHY_VIEW_TOOLBAR, METHOD_HIERARCHY_VIEW_TOOLBAR, TYPE_HIERARCHY_VIEW_TOOLBAR, JAVADOC_TOOLBAR, FILE_HISTORY_TOOLBAR, FILEHISTORY_VIEW_TOOLBAR, LVCS_DIRECTORY_HISTORY_TOOLBAR, CHANGES_VIEW_TOOLBAR, PHING_EXPLORER_TOOLBAR, @@ -122,7 +122,7 @@ public abstract class ActionPlaces { return ArrayUtil.find(ourToolbarPlaces, place) != -1; } - private static final String[] ourPopupPlaces = new String[]{EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP, + private static final String[] ourPopupPlaces = {EDITOR_POPUP, EDITOR_TAB_POPUP, COMMANDER_POPUP, PROJECT_VIEW_POPUP, FAVORITES_VIEW_POPUP, SCOPE_VIEW_POPUP, TESTTREE_VIEW_POPUP, TESTSTATISTICS_VIEW_POPUP, TYPE_HIERARCHY_VIEW_POPUP, METHOD_HIERARCHY_VIEW_POPUP, CALL_HIERARCHY_VIEW_POPUP, J2EE_ATTRIBUTES_VIEW_POPUP, J2EE_VIEW_POPUP, USAGE_VIEW_POPUP, STRUCTURE_VIEW_POPUP, TODO_VIEW_POPUP, COMPILER_MESSAGES_POPUP, ANT_MESSAGES_POPUP, ANT_EXPLORER_POPUP, UPDATE_POPUP, diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java index deaab11d67a2..ade1655f8a25 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ComplementaryFontsRegistry.java @@ -104,11 +104,11 @@ public class ComplementaryFontsRegistry { if (!SystemInfo.isMac || style == 0) return Pair.create(familyName, style); StringBuilder st = new StringBuilder(familyName).append('-'); - if ((style & Font.BOLD) == Font.BOLD) { + if ((style & Font.BOLD) != 0) { st.append("Bold"); } - if ((style & Font.ITALIC) == Font.ITALIC) { + if ((style & Font.ITALIC) != 0) { st.append("Italic"); } diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java index ee85628d4878..034b0939ce2c 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java @@ -384,12 +384,12 @@ public class PsiAdapter { // is it public static void main(String[] args) for (PsiMethod method : methods) { // must be public - if (!method.hasModifierProperty("public")) { + if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { continue; } // must be static - if (!method.hasModifierProperty("static")) { + if (!method.hasModifierProperty(PsiModifier.STATIC)) { continue; } @@ -566,12 +566,12 @@ public class PsiAdapter { // is it public boolean equals(Object o) for (PsiMethod method : methods) { // must be public - if (!method.hasModifierProperty("public")) { + if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { continue; } // must not be static - if (method.hasModifierProperty("static")) { + if (method.hasModifierProperty(PsiModifier.STATIC)) { continue; } @@ -613,12 +613,12 @@ public class PsiAdapter { // is it public int hashCode() for (PsiMethod method : methods) { // must be public - if (!method.hasModifierProperty("public")) { + if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { continue; } // must not be static - if (method.hasModifierProperty("static")) { + if (method.hasModifierProperty(PsiModifier.STATIC)) { continue; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java index f63d21ab2ab1..8ecc7dc27c86 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java @@ -109,7 +109,7 @@ public abstract class CreateClassActionBase implements IntentionAction { if (contextElement != null && !JavaPsiFacade.getInstance(manager.getProject()).getResolveHelper().isAccessible(targetClass, contextElement, null) && modifiers != null) { - modifiers.setModifierProperty(PsiKeyword.PUBLIC, true); + modifiers.setModifierProperty(PsiModifier.PUBLIC, true); } return targetClass; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/packaging/GrPackageDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/packaging/GrPackageDefinitionImpl.java index 3041aa24363c..510e3c053871 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/packaging/GrPackageDefinitionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/packaging/GrPackageDefinitionImpl.java @@ -17,7 +17,6 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.toplevel.packaging; import com.intellij.lang.ASTNode; -import com.intellij.psi.Modifier; import com.intellij.psi.PsiModifierList; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -66,7 +65,7 @@ public class GrPackageDefinitionImpl extends GroovyPsiElementImpl implements GrP } @Override - public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) { + public boolean hasModifierProperty(@NonNls @NotNull String name) { final PsiModifierList list = getModifierList(); return list != null && list.hasExplicitModifier(name); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java index 725aabf12d8f..2f0ee33e22ab 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java @@ -52,7 +52,7 @@ import static org.jetbrains.plugins.groovy.refactoring.convertToJava.GenerationU * @author Maxim.Medvedev */ public class StubGenerator implements ClassItemGenerator { - public static final String[] STUB_MODIFIERS = new String[]{ + public static final String[] STUB_MODIFIERS = { PsiModifier.PUBLIC, PsiModifier.PROTECTED, PsiModifier.PRIVATE, diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java index 4721f45d063c..b16babb4618b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java @@ -118,7 +118,7 @@ public class GrDynamicMethodImpl extends LightElement implements GrMethod { return myMethod.getModifierList(); } - public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) { + public boolean hasModifierProperty(@NonNls @NotNull String name) { return myMethod.hasModifierProperty(name); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java index 2d365c447e55..dd36f4777268 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java @@ -107,7 +107,7 @@ public class GrDynamicPropertyImpl extends LightElement implements GrField { return myField.getTypeElement(); } - public boolean hasModifierProperty(@Modifier @NonNls @NotNull String name) { + public boolean hasModifierProperty(@NonNls @NotNull String name) { return myField.hasModifierProperty(name); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestColumnInfo.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestColumnInfo.java index bd6de4f72b5a..50fdc866805c 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestColumnInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestColumnInfo.java @@ -169,13 +169,13 @@ public abstract class TestColumnInfo extends ColumnInfo implements Comparator { } private static class CountDefectsRenderer extends JPanel implements TableCellRenderer { - private static final SimpleTextAttributes RUNNING_COLOR = new SimpleTextAttributes(Font.PLAIN, Color.BLACK); - private static final SimpleTextAttributes DEFECT_ATTRIBUTE = new SimpleTextAttributes(Font.BOLD, Color.RED); + private static final SimpleTextAttributes RUNNING_COLOR = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.BLACK); + private static final SimpleTextAttributes DEFECT_ATTRIBUTE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, Color.RED); private final SimpleColoredRenderer myCounters = new SimpleColoredRenderer(); private final SimpleColoredRenderer myProgressIndicator = new SimpleColoredRenderer(); private final TableCellState myCellState = new TableCellState(); - private static final SimpleTextAttributes TERMINATED_ATTRIBUTE = new SimpleTextAttributes(Font.BOLD, Color.ORANGE); + private static final SimpleTextAttributes TERMINATED_ATTRIBUTE = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, Color.ORANGE); public CountDefectsRenderer() { super(new BorderLayout()); diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestRenderer.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestRenderer.java index 6f478670ab50..9c59f18f01d2 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestRenderer.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestRenderer.java @@ -27,7 +27,6 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.containers.HashMap; import javax.swing.*; -import java.awt.*; import java.util.Map; class TestRenderer { @@ -42,7 +41,7 @@ class TestRenderer { } private static SimpleTextAttributes getSpecialAttributes() { - return new SimpleTextAttributes(Font.BOLD, TestsUIUtil.PASSED_COLOR); + return new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, TestsUIUtil.PASSED_COLOR); } static { diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/browser/MethodList.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/browser/MethodList.java index df6e8d066e84..adf86f0b674d 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/browser/MethodList.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/browser/MethodList.java @@ -18,15 +18,18 @@ package com.theoryinpractice.testng.configuration.browser; import com.intellij.ide.structureView.impl.StructureNodeRenderer; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.util.Condition; -import com.intellij.psi.*; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.util.PsiFormatUtil; +import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.theoryinpractice.testng.util.TestNGUtil; -import java.awt.BorderLayout; -import java.util.Comparator; import javax.swing.*; +import java.awt.*; +import java.util.Comparator; public class MethodList extends JPanel { @@ -64,7 +67,7 @@ public class MethodList extends JPanel protected void customizeCellRenderer(JList jlist, Object obj, int i, boolean flag, boolean flag1) { PsiMethod psimethod = (PsiMethod)obj; - append(PsiFormatUtil.formatMethod(psimethod, PsiSubstitutor.EMPTY, 1, 0), StructureNodeRenderer.applyDeprecation(psimethod, SimpleTextAttributes.REGULAR_ATTRIBUTES)); + append(PsiFormatUtil.formatMethod(psimethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME, 0), StructureNodeRenderer.applyDeprecation(psimethod, SimpleTextAttributes.REGULAR_ATTRIBUTES)); PsiClass psiclass1 = psimethod.getContainingClass(); if(!MethodList.this.psiClass.equals(psiclass1)) { append(" (" + psiclass1.getQualifiedName() + ')', StructureNodeRenderer.applyDeprecation(psiclass1, SimpleTextAttributes.GRAY_ATTRIBUTES));