diff --git a/build/scripts/download_kotlin.gant b/build/scripts/download_kotlin.gant index 63d9bc039c7e..b383fade563c 100644 --- a/build/scripts/download_kotlin.gant +++ b/build/scripts/download_kotlin.gant @@ -26,7 +26,7 @@ import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant") -String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_Rc_Idea142branch150versionNoTests" +String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_101andRc_Idea142branch150versionNoTests" target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') { def communityHome = guessHome(this) @@ -190,7 +190,7 @@ private String readKotlinClassVersionOfCompiledClasses() { } } -private String readKotlinClassFileVersion(InputStream classFileStream) { +private static String readKotlinClassFileVersion(InputStream classFileStream) { def reader = new ClassReader(classFileStream) String kotlinBytecodeVersion = null String kotlinMetaDataVersion = null @@ -209,7 +209,8 @@ private String readKotlinClassFileVersion(InputStream classFileStream) { return new AnnotationVisitor(Opcodes.ASM5) { void visit(String name, Object value) { if (name == "mv") { - kotlinMetaDataVersion = (value as Integer[]).join(".") + //strip patch number of metadata version because changes in patch updates are forward and backward compatible + kotlinMetaDataVersion = (value as Integer[]).toList().dropRight(1).join(".") } else if (name == "bv") { kotlinBytecodeVersion = (value as Integer[]).join(".") diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 4acb533d5409..a9c6135446e2 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -1156,7 +1156,7 @@ public class BuildManager implements Disposable { cmdLine.addParameter("-D" + PathManager.PROPERTY_PLUGINS_PATH + "=" + PathManager.getPluginsPath()); cmdLine.addParameter("-D" + GlobalOptions.LOG_DIR_OPTION + "=" + FileUtil.toSystemIndependentName(getBuildLogDirectory().getAbsolutePath())); - cmdLine.addParameter("-D" + GlobalOptions.FALLBACK_JDK_HOME + "=" + SystemProperties.getJavaHome()); + cmdLine.addParameter("-D" + GlobalOptions.FALLBACK_JDK_HOME + "=" + FileUtil.toSystemIndependentName(SystemProperties.getJavaHome())); cmdLine.addParameter("-D" + GlobalOptions.FALLBACK_JDK_VERSION + "=" + SystemProperties.getJavaVersion()); final File workDirectory = getBuildSystemDirectory(); @@ -1463,7 +1463,7 @@ public class BuildManager implements Disposable { String text; synchronized (this) { - if (myStoredLength > 2048) { + if (myStoredLength > 16384) { return; } text = event.getText(); diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index c061dba79582..0e0cc7d63a3c 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -594,6 +594,9 @@ public class HighlightUtil extends HighlightUtilBase { } parent = parent.getParent(); } + if (parent instanceof PsiCodeFragment) { + return null; + } String description; HighlightInfo errorResult = null; if (method == null && lambda != null) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/AccessCanBeTightenedInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/AccessCanBeTightenedInspection.java index 465279bbc5d6..b5c52c42d4c1 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/AccessCanBeTightenedInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/visibility/AccessCanBeTightenedInspection.java @@ -147,7 +147,7 @@ class AccessCanBeTightenedInspection extends BaseJavaBatchLocalInspectionTool { final PsiPackage memberPackage = memberDirectory == null ? null : JavaDirectoryService.getInstance().getPackage(memberDirectory); log(member.getName()+ ": checking effective level for "+member); - UnusedSymbolUtil.processUsages(project, memberFile, member, new EmptyProgressIndicator(), null, info -> { + boolean proceed = UnusedSymbolUtil.processUsages(project, memberFile, member, new EmptyProgressIndicator(), null, info -> { PsiElement element = info.getElement(); if (element == null) return true; PsiFile psiFile = info.getFile(); @@ -156,7 +156,7 @@ class AccessCanBeTightenedInspection extends BaseJavaBatchLocalInspectionTool { return handleUsage(member, memberClass, memberFile, maxLevel, memberPackage, element, psiFile, foundUsage); }); - if (member instanceof PsiClass && ((PsiClass)member).isInterface()) { + if (proceed && member instanceof PsiClass && LambdaUtil.isFunctionalClass((PsiClass)member)) { // there can be lambda implementing this interface implicitly FunctionalExpressionSearch.search((PsiClass)member).forEach(functionalExpression -> { PsiFile psiFile = functionalExpression.getContainingFile(); diff --git a/java/java-analysis-impl/src/com/intellij/refactoring/util/VariableData.java b/java/java-analysis-impl/src/com/intellij/refactoring/util/VariableData.java index bcb4e271d545..d367ceb0e768 100644 --- a/java/java-analysis-impl/src/com/intellij/refactoring/util/VariableData.java +++ b/java/java-analysis-impl/src/com/intellij/refactoring/util/VariableData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,23 +18,27 @@ package com.intellij.refactoring.util; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class VariableData { +public class VariableData extends AbstractVariableData { public final PsiVariable variable; public PsiType type; - public String name; - public boolean passAsParameter; public VariableData(@NotNull PsiVariable var) { variable = var; type = var.getType(); } - public VariableData(@NotNull PsiVariable var, @NotNull PsiType type) { + public VariableData(@Nullable PsiVariable var, PsiType type) { variable = var; - if (type instanceof PsiLambdaParameterType || type instanceof PsiLambdaExpressionType || type instanceof PsiMethodReferenceType) { - type = PsiType.getJavaLangObject(var.getManager(), GlobalSearchScope.allScope(var.getProject())); + if (var != null) { + if (type instanceof PsiLambdaParameterType || type instanceof PsiLambdaExpressionType || type instanceof PsiMethodReferenceType) { + type = PsiType.getJavaLangObject(var.getManager(), GlobalSearchScope.allScope(var.getProject())); + } + this.type = SmartTypePointerManager.getInstance(var.getProject()).createSmartTypePointer(type).getType(); + } + else { + this.type = type; } - this.type = SmartTypePointerManager.getInstance(var.getProject()).createSmartTypePointer(type).getType(); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java index 0ffe3732748b..cdd8e6814326 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,7 +163,8 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix { PsiFile fromFile = element.getContainingFile(); List result = new ArrayList(); for (PsiClass psiClass : classes) { - if (dependencyValidationManager.getViolatorDependencyRule(fromFile, psiClass.getContainingFile()) == null) { + PsiFile containingFile = psiClass.getContainingFile(); + if (containingFile != null && dependencyValidationManager.getViolatorDependencyRule(fromFile, containingFile) == null) { result.add(psiClass); } } diff --git a/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java b/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java index c8c9434fe8e6..6a486935ebba 100644 --- a/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java +++ b/java/java-impl/src/com/intellij/psi/refResolve/RefResolveServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -235,12 +235,12 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable }); myApplication.addApplicationListener(new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { disable(); } @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { enable(); } diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaParameterInfo.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaParameterInfo.java index 99a9f63a431d..bc5740508172 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaParameterInfo.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaParameterInfo.java @@ -41,4 +41,5 @@ public interface JavaParameterInfo extends ParameterInfo { boolean isVarargType(); + default void setType(@Nullable PsiType type) {} } diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java index ecb68903d1da..9bc2bba3b570 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java @@ -124,6 +124,7 @@ public class ParameterInfoImpl implements JavaParameterInfo { } } + @Override public void setType(PsiType type) { myType = CanonicalTypes.createTypeWrapper(type); } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java index 4a1482c390a4..fa89c769b200 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java @@ -259,7 +259,7 @@ public class IntroduceParameterObjectDialog extends RefactoringDialog { protected JComponent createCenterPanel() { sourceMethodTextField.setEditable(false); - final ParameterTablePanel paramsPanel = new ParameterTablePanel(myProject, parameterInfo, sourceMethod) { + final ParameterTablePanel paramsPanel = new ParameterTablePanel(myProject, parameterInfo) { protected void updateSignature() {} protected void doEnterAction() {} diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java index 779711b15e74..6f454ed3f563 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpDialog.java @@ -156,8 +156,8 @@ public class PullUpDialog extends PullUpDialogBase { - public VariableData[] getVariableData() { - return myVariableData; + private TypeSelector[] myParameterTypeSelectors; + private JComboBox myTypeRendererCombo; + + public ParameterTablePanel(Project project, + VariableData[] variableData, + PsiElement... scopeElements) { + this(paramName -> LanguageNamesValidation.INSTANCE.forLanguage(JavaLanguage.INSTANCE).isIdentifier(paramName, project)); + init(variableData, project, scopeElements); } - protected abstract void updateSignature(); - - protected abstract void doEnterAction(); - - protected abstract void doCancelAction(); - - protected boolean areTypesDirected() { - return true; + public ParameterTablePanel(Predicate parameterNameValidator) { + super(new PassParameterColumnInfo(), + new TypeColumnInfo(), + new NameColumnInfo(parameterNameValidator)); } - public ParameterTablePanel(Project project, VariableData[] variableData, final PsiElement... scopeElements) { - super(new BorderLayout()); - myProject = project; - myVariableData = variableData; - - myTableModel = new MyTableModel(); - myTable = new JBTable(myTableModel); - DefaultCellEditor defaultEditor = (DefaultCellEditor)myTable.getDefaultEditor(Object.class); - defaultEditor.setClickCountToStart(1); - - - myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - myTable.setCellSelectionEnabled(true); - TableColumn checkboxColumn = myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN); - TableUtil.setupCheckboxColumn(checkboxColumn); - checkboxColumn.setCellRenderer(new CheckBoxTableCellRenderer()); - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_NAME_COLUMN).setCellRenderer(new DefaultTableCellRenderer() { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - VariableData data = getVariableData()[row]; - setText(data.name); - return this; - } - }); + public void init(VariableData[] variableData, Project project, PsiElement... scopeElements) { + super.init(variableData); myParameterTypeSelectors = new TypeSelector[getVariableData().length]; for (int i = 0; i < myParameterTypeSelectors.length; i++) { - final PsiVariable variable = getVariableData()[i].variable; - final PsiExpression[] occurrences = findVariableOccurrences(scopeElements, variable); - final TypeSelectorManager manager = new TypeSelectorManagerImpl(myProject, getVariableData()[i].type, occurrences, areTypesDirected()) { - @Override - protected boolean isUsedAfter() { - return ParameterTablePanel.this.isUsedAfter(variable); - } - }; - myParameterTypeSelectors[i] = manager.getTypeSelector(); + final VariableData data = variableData[i]; + final TypeSelector selector = createSelector(project, data, scopeElements); + myParameterTypeSelectors[i] = selector; getVariableData()[i].type = myParameterTypeSelectors[i].getSelectedType(); //reverse order } - myTypeRendererCombo = new JComboBox(getVariableData()); + myTypeRendererCombo = new ComboBox(getVariableData()); myTypeRendererCombo.setOpaque(true); myTypeRendererCombo.setBorder(null); myTypeRendererCombo.setRenderer(new ListCellRendererWrapper() { @@ -121,7 +80,7 @@ public abstract class ParameterTablePanel extends JPanel { }); - final TableColumn typeColumn = myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN); + final TableColumn typeColumn = myTable.getColumnModel().getColumn(1); typeColumn.setCellEditor(new AbstractTableCellEditor() { TypeSelector myCurrentSelector; final JBComboBoxTableCellEditorComponent myEditorComponent = new JBComboBoxTableCellEditorComponent(); @@ -139,12 +98,7 @@ public abstract class ParameterTablePanel extends JPanel { myEditorComponent.setCell(table, row, column); myEditorComponent.setOptions(myParameterTypeSelectors[row].getTypes()); myEditorComponent.setDefaultValue(getVariableData()[row].type); - myEditorComponent.setToString(new Function() { - @Override - public String fun(Object o) { - return ((PsiType)o).getPresentableText(); - } - }); + myEditorComponent.setToString(o -> ((PsiType)o).getPresentableText()); myCurrentSelector = myParameterTypeSelectors[row]; return myEditorComponent; @@ -152,96 +106,40 @@ public abstract class ParameterTablePanel extends JPanel { }); - - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellRenderer(new DefaultTableCellRenderer() { + myTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() { private final JBComboBoxLabel myLabel = new JBComboBoxLabel(); - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - myLabel.setText(String.valueOf(value)); + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + myLabel.setText(((PsiType)value).getPresentableText()); myLabel.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground()); myLabel.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); if (isSelected) { myLabel.setSelectionIcon(); - } else { + } + else { myLabel.setRegularIcon(); } return myLabel; } }); + } - myTable.setPreferredScrollableViewportSize(new Dimension(250, myTable.getRowHeight() * 5)); - myTable.setShowGrid(false); - myTable.setIntercellSpacing(new Dimension(0, 0)); - @NonNls final InputMap inputMap = myTable.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable"); - @NonNls final ActionMap actionMap = myTable.getActionMap(); - actionMap.put("enable_disable", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - if (myTable.isEditing()) return; - int[] rows = myTable.getSelectedRows(); - if (rows.length > 0) { - boolean valueToBeSet = false; - for (int row : rows) { - if (!getVariableData()[row].passAsParameter) { - valueToBeSet = true; - break; - } - } - for (int row : rows) { - getVariableData()[row].passAsParameter = valueToBeSet; - } - myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]); - TableUtil.selectRows(myTable, rows); + protected TypeSelector createSelector(final Project project, final VariableData data, PsiElement[] scopeElements) { + final PsiVariable variable = data.variable; + final PsiExpression[] occurrences = findVariableOccurrences(scopeElements, variable); + final TypeSelectorManager manager = + new TypeSelectorManagerImpl(project, data.type, occurrences, areTypesDirected()) { + @Override + protected boolean isUsedAfter() { + return ParameterTablePanel.this.isUsedAfter(variable); } - } - }); - //// F2 should edit the name - //inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name"); - //actionMap.put("edit_parameter_name", new AbstractAction() { - // public void actionPerformed(ActionEvent e) { - // if (!myTable.isEditing()) { - // int row = myTable.getSelectedRow(); - // if (row >= 0 && row < myTableModel.getRowCount()) { - // TableUtil.editCellAt(myTable, row, MyTableModel.PARAMETER_NAME_COLUMN); - // } - // } - // } - //}); - - //// make ENTER work when the table has focus - //inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl"); - //actionMap.put("invokeImpl", new AbstractAction() { - // public void actionPerformed(ActionEvent e) { - // TableCellEditor editor = myTable.getCellEditor(); - // if (editor != null) { - // editor.stopCellEditing(); - // } - // else { - // doEnterAction(); - // } - // } - //}); - - // make ESCAPE work when the table has focus - actionMap.put("doCancel", new AbstractAction() { - public void actionPerformed(ActionEvent e) { - TableCellEditor editor = myTable.getCellEditor(); - if (editor != null) { - editor.stopCellEditing(); - } - else { - doCancelAction(); - } - } - }); - - - JPanel listPanel = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel(); - add(listPanel, BorderLayout.CENTER); - - if (getVariableData().length > 1) { - myTable.getSelectionModel().setSelectionInterval(0, 0); - } + }; + return manager.getTypeSelector(); } protected boolean isUsedAfter(PsiVariable variable) { @@ -263,141 +161,40 @@ public abstract class ParameterTablePanel extends JPanel { return result.toArray(new PsiExpression[result.size()]); } - - public void setEnabled(boolean enabled) { - myTable.setEnabled(enabled); - super.setEnabled(enabled); + @Override + protected void exchangeRows(int row, int targetRow, VariableData currentItem) { + super.exchangeRows(row, targetRow, currentItem); + TypeSelector currentSelector = myParameterTypeSelectors[row]; + myParameterTypeSelectors[row] = myParameterTypeSelectors[targetRow]; + myParameterTypeSelectors[targetRow] = currentSelector; + myTypeRendererCombo.setModel(new DefaultComboBoxModel(getVariableData())); } - private class MyTableModel extends AbstractTableModel implements EditableModel { - public static final int CHECKMARK_COLUMN = 0; - public static final int PARAMETER_TYPE_COLUMN = 1; - public static final int PARAMETER_NAME_COLUMN = 2; + private static class TypeColumnInfo extends ColumnInfo { - public int getRowCount() { - return getVariableData().length; - } - - public int getColumnCount() { - return 3; - } - - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - return getVariableData()[rowIndex].passAsParameter; - } - case PARAMETER_NAME_COLUMN: { - return getVariableData()[rowIndex].name; - } - case PARAMETER_TYPE_COLUMN: { - return getVariableData()[rowIndex].type.getPresentableText(); - } - } - assert false; - return null; - } - - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - getVariableData()[rowIndex].passAsParameter = ((Boolean)aValue).booleanValue(); - fireTableRowsUpdated(rowIndex, rowIndex); - myTable.getSelectionModel().setSelectionInterval(rowIndex, rowIndex); - updateSignature(); - break; - } - case PARAMETER_NAME_COLUMN: { - VariableData data = getVariableData()[rowIndex]; - String name = (String)aValue; - if (PsiNameHelper.getInstance(myProject).isIdentifier(name)) { - data.name = name; - } - updateSignature(); - break; - } - case PARAMETER_TYPE_COLUMN: { - VariableData data = getVariableData()[rowIndex]; - data.type = (PsiType)aValue; - updateSignature(); - break; - } - } + public TypeColumnInfo() { + super("Type"); } @Override - public String getColumnName(int column) { - switch (column) { - case CHECKMARK_COLUMN: return ""; - case PARAMETER_TYPE_COLUMN: return "Type"; - case PARAMETER_NAME_COLUMN: return "Name"; - } - return ""; + public void setValue(VariableData data, PsiType value) { + data.type = value; } - public boolean isCellEditable(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: - return isEnabled(); - case PARAMETER_NAME_COLUMN: - return isEnabled() && getVariableData()[rowIndex].passAsParameter; - case PARAMETER_TYPE_COLUMN: - return isEnabled() && getVariableData()[rowIndex].passAsParameter && !(myParameterTypeSelectors[rowIndex].getComponent() instanceof JLabel); - default: - return false; - } - } - - public Class getColumnClass(int columnIndex) { - if (columnIndex == CHECKMARK_COLUMN) { - return Boolean.class; - } - return super.getColumnClass(columnIndex); + @Nullable + @Override + public PsiType valueOf(VariableData data) { + return data.type; } @Override - public void addRow() { - throw new IllegalAccessError("Not implemented"); + public Class getColumnClass() { + return PsiType.class; } @Override - public void removeRow(int index) { - throw new IllegalAccessError("Not implemented"); - } - - @Override - public void exchangeRows(int row, int targetRow) { - if (row < 0 || row >= getVariableData().length) return; - if (targetRow < 0 || targetRow >= getVariableData().length) return; - - final VariableData currentItem = getVariableData()[row]; - getVariableData()[row] = getVariableData()[targetRow]; - getVariableData()[targetRow] = currentItem; - - TypeSelector currentSelector = myParameterTypeSelectors[row]; - myParameterTypeSelectors[row] = myParameterTypeSelectors[targetRow]; - myParameterTypeSelectors[targetRow] = currentSelector; - - myTypeRendererCombo.setModel(new DefaultComboBoxModel(getVariableData())); - - myTableModel.fireTableRowsUpdated(Math.min(targetRow, row), Math.max(targetRow, row)); - myTable.getSelectionModel().setSelectionInterval(targetRow, targetRow); - updateSignature(); - } - - @Override - public boolean canExchangeRows(int row, int targetRow) { - if (row < 0 || row >= getVariableData().length) return false; - if (targetRow < 0 || targetRow >= getVariableData().length) return false; + public boolean isCellEditable(VariableData data) { return true; } } - - private class CheckBoxTableCellRenderer extends BooleanTableCellRenderer { - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - rendererComponent.setEnabled(ParameterTablePanel.this.isEnabled()); - return rendererComponent; - } - } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/HighlightingCaches.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/HighlightingCaches.java index 94ee67becd3a..72aed9ebf3d7 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/HighlightingCaches.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/HighlightingCaches.java @@ -25,7 +25,6 @@ import com.intellij.psi.impl.PsiManagerImpl; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentMap; @@ -57,9 +56,9 @@ class HighlightingCaches { // baseClass -> (list of direct subclasses, isInheritor flag array) final Map, AtomicIntegerArray>> DIRECT_SUB_CLASSES = createWeakCache(); // baseClass -> all sub classes transitively, including anonymous - final ConcurrentMap> ALL_SUB_CLASSES = createWeakCache(); + final ConcurrentMap> ALL_SUB_CLASSES = createWeakCache(); // baseMethod -> all overriding methods - final Map> OVERRIDING_METHODS = createWeakCache(); + final Map> OVERRIDING_METHODS = createWeakCache(); @NotNull private ConcurrentMap createWeakCache() { diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaClassInheritorsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaClassInheritorsSearcher.java index ccc430fc3344..9dc4d1ee0d44 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaClassInheritorsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaClassInheritorsSearcher.java @@ -38,7 +38,6 @@ import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.HashSetQueue; import org.jetbrains.annotations.NotNull; -import java.util.AbstractCollection; import java.util.Collection; import java.util.Iterator; import java.util.concurrent.ConcurrentMap; @@ -86,7 +85,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase cached = getOrComputeSubClasses(project, parameters.getClassToProcess()); + Iterable cached = getOrComputeSubClasses(project, parameters.getClassToProcess()); for (final PsiClass subClass : cached) { ProgressManager.checkCanceled(); @@ -102,9 +101,9 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase getOrComputeSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) { - ConcurrentMap> CACHE = HighlightingCaches.getInstance(project).ALL_SUB_CLASSES; - Collection cached = CACHE.get(baseClass); + private static Iterable getOrComputeSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) { + ConcurrentMap> CACHE = HighlightingCaches.getInstance(project).ALL_SUB_CLASSES; + Iterable cached = CACHE.get(baseClass); if (cached == null) { cached = computeAllSubClasses(project, baseClass); // it's almost empty now, no big deal // make sure concurrent calls of this method always return the same collection to avoid expensive duplicate work @@ -115,7 +114,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase computeAllSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) { + private static Iterable computeAllSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) { return new AllSubClassesLazyCollection(project, baseClass); } @@ -188,7 +187,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase)() -> baseClass.hasModifierProperty(PsiModifier.FINAL)); } - private static class AllSubClassesLazyCollection extends AbstractCollection { + private static class AllSubClassesLazyCollection implements Iterable { // Computes all sub classes of the 'baseClass' transitively by calling DirectClassInheritorsSearch repeatedly. // Already computed subclasses in this collection. // There are two iterators maintained for this collection: @@ -235,11 +234,6 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase candidatesToFindSubclassesIterator; // guarded by lock private void findNextSubclasses() { diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java index e9f6b483ad86..ded26be91cc9 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaDirectInheritorsSearcher.java @@ -160,11 +160,11 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor)baseClass::getName); - if (StringUtil.isEmpty(className)) { + final String baseClassName = ApplicationManager.getApplication().runReadAction((Computable)baseClass::getName); + if (StringUtil.isEmpty(baseClassName)) { return Pair.create(Collections.emptyList(), new AtomicIntegerArray(0)); } - Pair, AtomicIntegerArray> pair = calculateDirectSubClasses(project, baseClass, className); + Pair, AtomicIntegerArray> pair = calculateDirectSubClasses(project, baseClass, baseClassName); HighlightingCaches.getInstance(project).DIRECT_SUB_CLASSES.put(baseClass, pair); return pair; } @@ -172,11 +172,10 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor, AtomicIntegerArray> calculateDirectSubClasses(@NotNull Project project, @NotNull PsiClass baseClass, - @NotNull String className) { + @NotNull String baseClassName) { GlobalSearchScope allScope = GlobalSearchScope.allScope(project); Collection candidates = - MethodUsagesSearcher - .resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(className, project, allScope)); + MethodUsagesSearcher.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(baseClassName, project, allScope)); Map> classes = new HashMap<>(); int count = 0; @@ -196,7 +195,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor anonymousCandidates = - MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(className, project, allScope)); + MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(baseClassName, project, allScope)); List result = new ArrayList<>(count + classes.size() + anonymousCandidates.size() + 1); for (Map.Entry> entry : classes.entrySet()) { diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaOverridingMethodsSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaOverridingMethodsSearcher.java index 33817855456b..c8dd2eb2483f 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaOverridingMethodsSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/JavaOverridingMethodsSearcher.java @@ -54,7 +54,7 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor cached = HighlightingCaches.getInstance(project).OVERRIDING_METHODS.get(method); + Iterable cached = HighlightingCaches.getInstance(project).OVERRIDING_METHODS.get(method); if (cached == null) { cached = compute(method, project); HighlightingCaches.getInstance(project).OVERRIDING_METHODS.put(method, cached); @@ -112,7 +112,7 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor compute(@NotNull PsiMethod method, @NotNull Project project) { + private static Iterable compute(@NotNull PsiMethod method, @NotNull Project project) { Collection result = new LinkedHashSet<>(); Application application = ApplicationManager.getApplication(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java index c449aa665f99..d9b0c797a3ae 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiDiamondTypeUtil.java @@ -195,7 +195,9 @@ public class PsiDiamondTypeUtil { final PsiFile fileCopy = (PsiFile)containingFile.copy(); copy = fileCopy.findElementAt(offset); if (method != null && method.getContainingFile() == containingFile) { - method = PsiTreeUtil.getParentOfType(fileCopy.findElementAt(method.getTextOffset()), PsiMethod.class); + final PsiElement startMethodElementInCopy = fileCopy.findElementAt(method.getTextOffset()); + method = PsiTreeUtil.getParentOfType(startMethodElementInCopy, PsiMethod.class); + LOG.assertTrue(method != null, startMethodElementInCopy); } } final PsiCallExpression exprCopy = PsiTreeUtil.getParentOfType(copy, PsiCallExpression.class, false); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java index 785cb7e57d4d..8d40e2914d9c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java @@ -54,7 +54,9 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR final PsiElement element = reference.getReferenceNameElement(); final boolean isConstructor = reference.isConstructor(); if (element instanceof PsiIdentifier || isConstructor) { - if (isConstructor && (containingClass.isEnum() || containingClass.hasModifierProperty(PsiModifier.ABSTRACT))) { + if (isConstructor && (containingClass.isEnum() || + containingClass.hasModifierProperty(PsiModifier.ABSTRACT) || + containingClass instanceof PsiTypeParameter)) { return JavaResolveResult.EMPTY_ARRAY; } final PsiType functionalInterfaceType = getInterfaceType(reference); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParameterInstantiation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParameterInstantiation.java new file mode 100644 index 000000000000..8c2124022fa9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/TypeParameterInstantiation.java @@ -0,0 +1,8 @@ + +import java.util.function.Supplier; + +class Test { + { + Supplier aNew = T::new; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index 5a2a9368959f..c140584b90ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -506,6 +506,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testTypeParameterInstantiation() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java index c16ea7f0c04b..b61cf5bd524a 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java @@ -8,6 +8,7 @@ import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.impl.quickfix.VariableTypeFix; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.undo.UndoUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; @@ -74,7 +75,7 @@ public class TypeMigrationVariableTypeFixProvider implements ChangeVariableTypeQ final TypeMigrationRules rules = new TypeMigrationRules(); rules.setBoundScope(GlobalSearchScope.projectScope(project)); TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, variable, targetType, optimizeImports); - JavaCodeStyleManager.getInstance(project).shortenClassReferences(variable); + WriteAction.run(() -> JavaCodeStyleManager.getInstance(project).shortenClassReferences(variable)); UndoUtil.markPsiFileForUndo(variable.getContainingFile()); } catch (IncorrectOperationException e) { diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/module/JpsModuleRootModelSerializer.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/module/JpsModuleRootModelSerializer.java index 211d8d1a5bbd..4c1fbf0e6ffc 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/module/JpsModuleRootModelSerializer.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/module/JpsModuleRootModelSerializer.java @@ -91,10 +91,12 @@ public class JpsModuleRootModelSerializer { dependenciesList.clear(); final JpsElementFactory elementFactory = JpsElementFactory.getInstance(); UniqueNameGenerator nameGenerator = new UniqueNameGenerator(); + boolean moduleSourceAdded = false; for (Element orderEntry : getChildren(rootModelComponent, ORDER_ENTRY_TAG)) { String type = orderEntry.getAttributeValue(TYPE_ATTRIBUTE); if (SOURCE_FOLDER_TYPE.equals(type)) { dependenciesList.addModuleSourceDependency(); + moduleSourceAdded = true; } else if (JDK_TYPE.equals(type)) { String sdkName = orderEntry.getAttributeValue(JDK_NAME_ATTRIBUTE); @@ -140,6 +142,9 @@ public class JpsModuleRootModelSerializer { loadModuleDependencyProperties(dependency, orderEntry); } } + if (!moduleSourceAdded) { + dependenciesList.addModuleSourceDependency(); + } for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { extension.loadRootModel(module, rootModelComponent); diff --git a/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.iml b/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.iml new file mode 100644 index 000000000000..088307e94146 --- /dev/null +++ b/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.iml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.ipr b/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.ipr new file mode 100644 index 000000000000..bad34659d510 --- /dev/null +++ b/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.ipr @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java index ae80493e3e3f..506c6fcc7f27 100644 --- a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java +++ b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java @@ -179,6 +179,15 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase { doTestSaveModule(module, projectPath + "resourceRoots.iml"); } + public void testMissingModuleSourcesOrderEntry() { + loadProject("/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.ipr"); + JpsModule module = assertOneElement(myProject.getModules()); + List dependencies = module.getDependenciesList().getDependencies(); + assertEquals(2, dependencies.size()); + assertInstanceOf(dependencies.get(0), JpsSdkDependency.class); + assertInstanceOf(dependencies.get(1), JpsModuleSourceDependency.class); + } + private static void checkResourceRoot(JpsModuleSourceRoot root, boolean forGenerated, String relativeOutput) { assertSame(JavaResourceRootType.RESOURCE, root.getRootType()); JavaResourceRootProperties properties = root.getProperties(JavaResourceRootType.RESOURCE); diff --git a/lib/pty4j-0.6.jar b/lib/pty4j-0.6.jar index 950ab6129ad4..af105c2ff1ef 100644 Binary files a/lib/pty4j-0.6.jar and b/lib/pty4j-0.6.jar differ diff --git a/lib/src/pty4j-0.6-src.jar b/lib/src/pty4j-0.6-src.jar index b6ef30cdc34b..52e9d1e7ad4c 100644 Binary files a/lib/src/pty4j-0.6-src.jar and b/lib/src/pty4j-0.6-src.jar differ diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java index 3ac277c96d8e..d0e642abae10 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java @@ -67,7 +67,7 @@ public class ProblemDescriptorBase extends CommonProblemDescriptorImpl implement LOG.assertTrue(endElementRange != null, endElement); if (startElementRange.getStartOffset() >= endElementRange.getEndOffset()) { if (!(startElement instanceof PsiFile && endElement instanceof PsiFile)) { - LOG.error("Empty PSI elements should not be passed to createDescriptor. Start: " + startElement + ", end: " + endElement); + LOG.error("Empty PSI elements should not be passed to createDescriptor. Start: " + startElement + ", end: " + endElement + ", startContainingFile: " + startContainingFile); } } diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java index 2d10ceb873be..a8c583904a5e 100644 --- a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java +++ b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java @@ -503,4 +503,8 @@ public class FileReferenceSet { public void setEmptyPathAllowed(boolean emptyPathAllowed) { myEmptyPathAllowed = emptyPathAllowed; } + + public boolean supportsExtendedCompletion() { + return true; + } } diff --git a/platform/analysis-impl/src/com/intellij/refactoring/util/AbstractVariableData.java b/platform/analysis-impl/src/com/intellij/refactoring/util/AbstractVariableData.java new file mode 100644 index 000000000000..3723525b56be --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/refactoring/util/AbstractVariableData.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.refactoring.util; + +public class AbstractVariableData { + public String originalName; + public String name; + public boolean passAsParameter; + + public String getName() { + return name; + } + + public String getOriginalName() { + return originalName; + } + + public boolean isPassAsParameter() { + return passAsParameter; + } +} diff --git a/platform/core-api/src/com/intellij/openapi/application/Application.java b/platform/core-api/src/com/intellij/openapi/application/Application.java index d47a915fa93c..7231e3a0d79f 100644 --- a/platform/core-api/src/com/intellij/openapi/application/Application.java +++ b/platform/core-api/src/com/intellij/openapi/application/Application.java @@ -22,7 +22,6 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.ThrowableComputable; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.concurrent.Callable; @@ -105,7 +104,7 @@ public interface Application extends ComponentManager { * @param actionClass the class of the write action to return. * @return true if the action is running, or false if no action of the specified class is currently executing. */ - boolean hasWriteAction(@Nullable Class actionClass); + boolean hasWriteAction(@NotNull Class actionClass); /** * Asserts whether the read access is allowed. @@ -414,7 +413,7 @@ public interface Application extends ComponentManager { * Returns lock used for write operations, should be closed in finally block */ @NotNull - AccessToken acquireWriteActionLock(/*@NotNull*/ Class marker); + AccessToken acquireWriteActionLock(@NotNull Class marker); boolean isInternal(); diff --git a/platform/core-api/src/com/intellij/openapi/application/ApplicationAdapter.java b/platform/core-api/src/com/intellij/openapi/application/ApplicationAdapter.java index 3c3f509ebecb..d3f0abafe44c 100644 --- a/platform/core-api/src/com/intellij/openapi/application/ApplicationAdapter.java +++ b/platform/core-api/src/com/intellij/openapi/application/ApplicationAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package com.intellij.openapi.application; +import org.jetbrains.annotations.NotNull; + public abstract class ApplicationAdapter implements ApplicationListener { @Override public boolean canExitApplication() { @@ -26,14 +28,14 @@ public abstract class ApplicationAdapter implements ApplicationListener { } @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { } @Override - public void writeActionStarted(Object action) { + public void writeActionStarted(@NotNull Object action) { } @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { } } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java b/platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java index d42737d474f8..f9845687227f 100644 --- a/platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java +++ b/platform/core-api/src/com/intellij/openapi/application/ApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package com.intellij.openapi.application; +import org.jetbrains.annotations.NotNull; + import java.util.EventListener; /** @@ -35,15 +37,15 @@ public interface ApplicationListener extends EventListener { /** * Is called before action start. */ - void beforeWriteActionStart(Object action); + void beforeWriteActionStart(@NotNull Object action); /** * Is called on action start. */ - void writeActionStarted(Object action); + void writeActionStarted(@NotNull Object action); /** * Is called on action finish. */ - void writeActionFinished(Object action); + void writeActionFinished(@NotNull Object action); } \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/mock/MockApplication.java b/platform/core-impl/src/com/intellij/mock/MockApplication.java index a1d9f142bd88..f59a40f57a1d 100644 --- a/platform/core-impl/src/com/intellij/mock/MockApplication.java +++ b/platform/core-impl/src/com/intellij/mock/MockApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,7 +162,7 @@ public class MockApplication extends MockComponentManager implements Application } @Override - public boolean hasWriteAction(@Nullable Class actionClass) { + public boolean hasWriteAction(@NotNull Class actionClass) { return false; } diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index 0dd36a9c90de..bbff39c7d03e 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -105,7 +105,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi assert !application.isWriteAccessAllowed() || application.isUnitTestMode(); // crazy stuff happens in tests, e.g. UIUtil.dispatchInvocationEvents() inside write action application.addApplicationListener(new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { int writeActionsBefore = runningWriteActions++; if (writeActionsBefore == 0) { disable("Write action started: " + action); @@ -113,7 +113,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi } @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { // crazy things happen when running tests, like starting write action in one thread but firing its end in the other int writeActionsAfter = runningWriteActions = Math.max(0,runningWriteActions-1); if (writeActionsAfter == 0) { diff --git a/platform/icons/src/ide/notification/errorEvents.png b/platform/icons/src/ide/notification/errorEvents.png index 8fe04b8971c0..d271acd2e6e4 100644 Binary files a/platform/icons/src/ide/notification/errorEvents.png and b/platform/icons/src/ide/notification/errorEvents.png differ diff --git a/platform/icons/src/ide/notification/errorEvents@2x.png b/platform/icons/src/ide/notification/errorEvents@2x.png index 7450904c5d57..42d5517b0965 100644 Binary files a/platform/icons/src/ide/notification/errorEvents@2x.png and b/platform/icons/src/ide/notification/errorEvents@2x.png differ diff --git a/platform/icons/src/ide/notification/errorEvents@2x_dark.png b/platform/icons/src/ide/notification/errorEvents@2x_dark.png new file mode 100644 index 000000000000..dc0d8b8eb0c6 Binary files /dev/null and b/platform/icons/src/ide/notification/errorEvents@2x_dark.png differ diff --git a/platform/icons/src/ide/notification/errorEvents_dark.png b/platform/icons/src/ide/notification/errorEvents_dark.png new file mode 100644 index 000000000000..bc4661a16847 Binary files /dev/null and b/platform/icons/src/ide/notification/errorEvents_dark.png differ diff --git a/platform/icons/src/ide/notification/infoEvents.png b/platform/icons/src/ide/notification/infoEvents.png index 3ce39c835959..09ffd5ac1a4f 100644 Binary files a/platform/icons/src/ide/notification/infoEvents.png and b/platform/icons/src/ide/notification/infoEvents.png differ diff --git a/platform/icons/src/ide/notification/infoEvents@2x.png b/platform/icons/src/ide/notification/infoEvents@2x.png index c9fb87e2400d..fb467e8e0301 100644 Binary files a/platform/icons/src/ide/notification/infoEvents@2x.png and b/platform/icons/src/ide/notification/infoEvents@2x.png differ diff --git a/platform/icons/src/ide/notification/infoEvents@2x_dark.png b/platform/icons/src/ide/notification/infoEvents@2x_dark.png new file mode 100644 index 000000000000..05a6020f95e7 Binary files /dev/null and b/platform/icons/src/ide/notification/infoEvents@2x_dark.png differ diff --git a/platform/icons/src/ide/notification/infoEvents_dark.png b/platform/icons/src/ide/notification/infoEvents_dark.png new file mode 100644 index 000000000000..1ff6d93461cc Binary files /dev/null and b/platform/icons/src/ide/notification/infoEvents_dark.png differ diff --git a/platform/icons/src/ide/notification/noEvents.png b/platform/icons/src/ide/notification/noEvents.png index 0cbeeed2a9fb..da816bfad5c7 100644 Binary files a/platform/icons/src/ide/notification/noEvents.png and b/platform/icons/src/ide/notification/noEvents.png differ diff --git a/platform/icons/src/ide/notification/noEvents@2x.png b/platform/icons/src/ide/notification/noEvents@2x.png index 9ef60cceccdb..e6aea9da012b 100644 Binary files a/platform/icons/src/ide/notification/noEvents@2x.png and b/platform/icons/src/ide/notification/noEvents@2x.png differ diff --git a/platform/icons/src/ide/notification/noEvents@2x_dark.png b/platform/icons/src/ide/notification/noEvents@2x_dark.png new file mode 100644 index 000000000000..2b8483d65769 Binary files /dev/null and b/platform/icons/src/ide/notification/noEvents@2x_dark.png differ diff --git a/platform/icons/src/ide/notification/noEvents_dark.png b/platform/icons/src/ide/notification/noEvents_dark.png new file mode 100644 index 000000000000..1cd65b8f64be Binary files /dev/null and b/platform/icons/src/ide/notification/noEvents_dark.png differ diff --git a/platform/icons/src/ide/notification/warningEvents.png b/platform/icons/src/ide/notification/warningEvents.png index 7a2696747933..cc57f81d9406 100644 Binary files a/platform/icons/src/ide/notification/warningEvents.png and b/platform/icons/src/ide/notification/warningEvents.png differ diff --git a/platform/icons/src/ide/notification/warningEvents@2x.png b/platform/icons/src/ide/notification/warningEvents@2x.png index acd4f27c739e..4e6d79899a50 100644 Binary files a/platform/icons/src/ide/notification/warningEvents@2x.png and b/platform/icons/src/ide/notification/warningEvents@2x.png differ diff --git a/platform/icons/src/ide/notification/warningEvents@2x_dark.png b/platform/icons/src/ide/notification/warningEvents@2x_dark.png new file mode 100644 index 000000000000..1963cf4b4d95 Binary files /dev/null and b/platform/icons/src/ide/notification/warningEvents@2x_dark.png differ diff --git a/platform/icons/src/ide/notification/warningEvents_dark.png b/platform/icons/src/ide/notification/warningEvents_dark.png new file mode 100644 index 000000000000..3b0a345f219b Binary files /dev/null and b/platform/icons/src/ide/notification/warningEvents_dark.png differ diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java index b997934523f6..bcaeeb0976b2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ public abstract class CompletionPhase implements Disposable { super(indicator); ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { if (!indicator.getLookup().isLookupDisposed() && !indicator.isCanceled()) { indicator.scheduleRestart(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java index 4a34e9460718..8071b97d6fe6 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java @@ -241,14 +241,18 @@ public class FilePathCompletionContributor extends CompletionContributor { final PsiMultiReference multiReference = (PsiMultiReference)original; for (PsiReference reference : multiReference.getReferences()) { if (reference instanceof FileReference) { - return Pair.create((FileReference) reference, false); + if (((FileReference)reference).getFileReferenceSet().supportsExtendedCompletion()) { + return Pair.create((FileReference)reference, false); + } } } } else if (original instanceof FileReferenceOwner) { final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference(); if (fileReference instanceof FileReference) { - return Pair.create((FileReference) fileReference, true); + if (((FileReference)fileReference).getFileReferenceSet().supportsExtendedCompletion()) { + return Pair.create((FileReference) fileReference, true); + } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index 2b1d64b2fcfd..dd17e8ef98dc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -407,14 +407,14 @@ public class DaemonListeners implements Disposable { private boolean myDaemonWasRunning; @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { myDaemonWasRunning = myDaemonCodeAnalyzer.isRunning(); if (!myDaemonWasRunning) return; // we'll restart in writeActionFinished() stopDaemon(true, "Write action start"); } @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { stopDaemon(true, "Write action finish"); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java index 2f91efed0e73..bbd78f6372f1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/DocumentFoldingInfo.java @@ -33,6 +33,7 @@ import com.intellij.openapi.fileEditor.impl.text.CodeFoldingState; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.util.containers.ContainerUtil; @@ -67,7 +68,7 @@ class DocumentFoldingInfo implements JDOMExternalizable, CodeFoldingState { @NonNls private static final String EXPANDED_ATT = "expanded"; @NonNls private static final String MARKER_TAG = "marker"; @NonNls private static final String DATE_ATT = "date"; - @NonNls private static final String PLACEHOLDER_ATT = "placeholder"; + @NonNls private static final String PLACEHOLDER_ATT = "ph"; DocumentFoldingInfo(@NotNull Project project, @NotNull Document document) { myProject = project; @@ -274,7 +275,7 @@ class DocumentFoldingInfo implements JDOMExternalizable, CodeFoldingState { String signature = Integer.valueOf(marker.getStartOffset()) + ":" + Integer.valueOf(marker.getEndOffset()); e.setAttribute(SIGNATURE_ATT, signature); String placeHolderText = fi == null ? DEFAULT_PLACEHOLDER : fi.placeHolder; - e.setAttribute(PLACEHOLDER_ATT, placeHolderText); + e.setAttribute(PLACEHOLDER_ATT, StringUtil.escapeIllegalXmlChars(placeHolderText)); element.addContent(e); } } @@ -331,8 +332,9 @@ class DocumentFoldingInfo implements JDOMExternalizable, CodeFoldingState { if (start < 0 || end >= document.getTextLength() || start > end) continue; RangeMarker marker = document.createRangeMarker(start, end); myRangeMarkers.add(marker); - String placeHolderText = e.getAttributeValue(PLACEHOLDER_ATT); - if (placeHolderText == null) placeHolderText = DEFAULT_PLACEHOLDER; + String placeholderAttributeValue = e.getAttributeValue(PLACEHOLDER_ATT); + String placeHolderText = placeholderAttributeValue == null ? DEFAULT_PLACEHOLDER + : StringUtil.unescapeIllegalXmlChars(placeholderAttributeValue); FoldingInfo fi = new FoldingInfo(placeHolderText, expanded); marker.putUserData(FOLDING_INFO_KEY, fi); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java index 0e5bd5c69ef5..b46e55ecc3fd 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java @@ -72,6 +72,8 @@ public class InspectionManagerEx extends InspectionManagerBase { toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection); new ContentManagerWatcher(toolWindow, contentManager); contentManager.addContentManagerListener(new ContentManagerAdapter() { + private static final String PREFIX = "of "; + @Override public void contentAdded(ContentManagerEvent event) { handleContentSizeChanged(); @@ -84,16 +86,19 @@ public class InspectionManagerEx extends InspectionManagerBase { private void handleContentSizeChanged() { final int count = contentManager.getContentCount(); - String newStripeTitle = null; if (count == 1) { - newStripeTitle = InspectionsBundle.message("inspection.tool.window.stripe.title.single.content"); + final Content content = contentManager.getContent(0); + final String displayName = content.getDisplayName(); + if (!content.getDisplayName().startsWith(PREFIX)) { + content.setDisplayName(PREFIX + displayName); + } } else if (count > 1) { - newStripeTitle = InspectionsBundle.message("inspection.tool.window.stripe.title.multiple.content"); - } - final String stripeTitle = toolWindow.getStripeTitle(); - if (newStripeTitle != null && !stripeTitle.equals(newStripeTitle)) { - toolWindow.setStripeTitle(newStripeTitle); + for (Content content : contentManager.getContents()) { + if (content.getDisplayName().startsWith(PREFIX)) { + content.setDisplayName(content.getDisplayName().substring(PREFIX.length())); + } + } } } }); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 3d9eca458109..4b1e89f86781 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -32,6 +32,7 @@ import com.intellij.diff.util.DiffUtil; import com.intellij.icons.AllIcons; import com.intellij.ide.*; import com.intellij.ide.actions.ContextHelpAction; +import com.intellij.ide.actions.exclusion.ExclusionHandler; import com.intellij.injected.editor.VirtualFileWindow; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; @@ -55,7 +56,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.pom.Navigatable; -import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -119,8 +119,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren @NotNull private final InspectionRVContentProvider myProvider; - private AnAction myIncludeAction; - private AnAction myExcludeAction; + private final ExclusionHandler myExclusionHandler; private EditorEx myPreviewEditor; private InspectionTreeLoadingProgressAware myLoadingProgressPreview; private final ExcludedInspectionTreeNodesManager myExcludedInspectionTreeNodesManager = new ExcludedInspectionTreeNodesManager(); @@ -151,6 +150,43 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } }); add(mySplitter, BorderLayout.CENTER); + myExclusionHandler = new ExclusionHandler() { + @Override + public boolean isNodeExcluded(@NotNull InspectionTreeNode node) { + return node.isResolved(myExcludedInspectionTreeNodesManager); + } + + @Override + public void excludeNode(@NotNull InspectionTreeNode node) { + node.ignoreElement(myExcludedInspectionTreeNodesManager); + } + + @Override + public void includeNode(@NotNull InspectionTreeNode node) { + node.amnesty(myExcludedInspectionTreeNodesManager); + } + + @Override + public boolean isActionEnabled(boolean isExcludeAction) { + return isExcludeAction || !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS; + } + + @Override + public void onDone(boolean isExcludeAction) { + if (isExcludeAction && myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS) { + update(); + } + else { + myTree.queueUpdate(); + } + } + + @Override + public void dispose() { + + } + }; + Disposer.register(this, myExclusionHandler); createActionsToolbar(); } @@ -177,13 +213,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } }); - myTree.addMouseListener(new PopupHandler() { - @Override - public void invokePopup(Component comp, int x, int y) { - popupInvoked(comp, x, y); - } - }); - + PopupHandler.installPopupHandler(myTree, IdeActions.INSPECTION_TOOL_WINDOW_TREE_POPUP, ActionPlaces.CODE_INSPECTION); SmartExpander.installOn(myTree); } @@ -244,64 +274,13 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren @SuppressWarnings({"NonStaticInitializer"}) private JComponent createRightActionsToolbar() { - myIncludeAction = new AnAction(InspectionsBundle.message("inspections.result.view.include.action.text")) { - { - registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); - } - - @Override - public void actionPerformed(AnActionEvent e) { - final TreePath[] paths = myTree.getSelectionPaths(); - if (paths != null) { - for (TreePath path : paths) { - ((InspectionTreeNode)path.getLastPathComponent()).amnesty(myExcludedInspectionTreeNodesManager); - } - } - myTree.queueUpdate(); - } - - @Override - public void update(final AnActionEvent e) { - final TreePath[] paths = myTree.getSelectionPaths(); - e.getPresentation().setEnabled(paths != null && paths.length > 0 && - !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS); - } - }; - - myExcludeAction = new AnAction(InspectionsBundle.message("inspections.result.view.exclude.action.text")) { - { - registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree); - } - - @Override - public void actionPerformed(final AnActionEvent e) { - final TreePath[] paths = myTree.getSelectionPaths(); - if (paths != null) { - for (TreePath path : paths) { - ((InspectionTreeNode)path.getLastPathComponent()).ignoreElement(myExcludedInspectionTreeNodesManager); - } - } - if (myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS) { - InspectionResultsView.this.update(); - } else { - myTree.queueUpdate(); - } - } - - @Override - public void update(final AnActionEvent e) { - final TreePath[] path = myTree.getSelectionPaths(); - e.getPresentation().setEnabled(path != null && path.length > 0); - } - }; - DefaultActionGroup specialGroup = new DefaultActionGroup(); specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupBySeverityAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupByDirectoryAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createFilterResolvedItemsAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createShowOutdatedProblemsAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createShowDiffOnlyAction(this)); - specialGroup.add(new EditSettingsAction()); + specialGroup.add(ActionManager.getInstance().getAction("EditInspectionSettings")); specialGroup.add(new InvokeQuickFixAction(this)); specialGroup.add(new InspectionsOptionsToolbarAction(this)); return createToolbar(specialGroup); @@ -785,6 +764,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren public Object getData(String dataId) { if (PlatformDataKeys.HELP_ID.is(dataId)) return HELP_ID; if (DATA_KEY.is(dataId)) return this; + if (ExclusionHandler.EXCLUSION_HANDLER.is(dataId)) return myExclusionHandler; if (myTree == null) return null; TreePath[] paths = myTree.getSelectionPaths(); @@ -895,48 +875,6 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren return PsiUtilCore.toPsiElementArray(psiElements); } - private void popupInvoked(Component component, int x, int y) { - final TreePath path = myTree.getLeadSelectionPath(); - - if (path == null) return; - - final DefaultActionGroup actions = new DefaultActionGroup(); - final ActionManager actionManager = ActionManager.getInstance(); - actions.add(actionManager.getAction(IdeActions.ACTION_EDIT_SOURCE)); - actions.add(actionManager.getAction(IdeActions.ACTION_FIND_USAGES)); - - actions.add(myIncludeAction); - actions.add(myExcludeAction); - - actions.addSeparator(); - - final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper(); - if (toolWrapper != null) { - final QuickFixAction[] quickFixes = myProvider.getQuickFixes(toolWrapper, myTree); - if (quickFixes != null) { - for (QuickFixAction quickFix : quickFixes) { - actions.add(quickFix); - } - } - final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); - if (key == null) return; //e.g. DummyEntryPointsTool - - //options - actions.addSeparator(); - actions.add(new EditSettingsAction()); - final List options = new InspectionsOptionsToolbarAction(this).createActions(); - for (AnAction action : options) { - actions.add(action); - } - } - - actions.addSeparator(); - actions.add(actionManager.getAction(IdeActions.GROUP_VERSION_CONTROLS)); - - final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.CODE_INSPECTION, actions); - menu.getComponent().show(component, x, y); - } - @NotNull public InspectionTree getTree() { return myTree; @@ -962,24 +900,6 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren return rerun; } - private InspectionProfile guessProfileToSelect(final InspectionProjectProfileManager profileManager) { - final Set profiles = new HashSet(); - final RefEntity[] selectedElements = myTree.getSelectedElements(); - for (RefEntity selectedElement : selectedElements) { - if (selectedElement instanceof RefElement) { - final RefElement refElement = (RefElement)selectedElement; - final PsiElement element = refElement.getElement(); - if (element != null) { - profiles.add(profileManager.getInspectionProfile()); - } - } - } - if (profiles.isEmpty()) { - return (InspectionProfile)profileManager.getProjectProfileImpl(); - } - return profiles.iterator().next(); - } - public boolean isProfileDefined() { return myInspectionProfile != null && myInspectionProfile.isEditable(); } @@ -1045,39 +965,6 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } } - private class EditSettingsAction extends AnAction { - private EditSettingsAction() { - super(InspectionsBundle.message("inspection.action.edit.settings"), InspectionsBundle.message("inspection.action.edit.settings"), - AllIcons.General.Settings); - } - - @Override - public void actionPerformed(AnActionEvent e) { - final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(myProject); - final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper(); - InspectionProfile inspectionProfile = myInspectionProfile; - final boolean profileIsDefined = isProfileDefined(); - if (!profileIsDefined) { - inspectionProfile = guessProfileToSelect(profileManager); - } - - if (toolWrapper != null) { - final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool - if (key != null) { - if (new EditInspectionToolsSettingsAction(key) - .editToolSettings(myProject, (InspectionProfileImpl)inspectionProfile, profileIsDefined) - && profileIsDefined) { - updateCurrentProfile(); - } - return; - } - } - if (EditInspectionToolsSettingsAction.editToolSettings(myProject, inspectionProfile, profileIsDefined, null) && profileIsDefined) { - updateCurrentProfile(); - } - } - } - public void updateCurrentProfile() { final String name = myInspectionProfile.getName(); myInspectionProfile = (InspectionProfile)myInspectionProfile.getProfileManager().getProfile(name); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewDecorator.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewDecorator.java index 38e0999ab18c..72ec034701a2 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewDecorator.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewDecorator.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.QuickFixAction; import com.intellij.codeInspection.ui.actions.SuppressActionWrapper; import com.intellij.icons.AllIcons; +import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ComboBoxAction; import com.intellij.openapi.diagnostic.Logger; @@ -100,8 +101,6 @@ public class QuickFixPreviewDecorator extends JPanel implements InspectionTreeLo private void fillPanel(@Nullable QuickFixAction[] fixes, CommonProblemDescriptor[] descriptors) { if (myFoldings != null) myFoldings.appendFoldings(descriptors); - InspectionTree tree = myView.getTree(); - Project project = myView.getProject(); boolean hasFixes = fixes != null && fixes.length != 0; int problemCount = descriptors.length; boolean multipleDescriptors = problemCount > 1; @@ -114,7 +113,7 @@ public class QuickFixPreviewDecorator extends JPanel implements InspectionTreeLo if (hasFixes) { actions.addAll(createFixActions(fixes, multipleDescriptors)); } - actions.add(createSuppressionCombo(myWrapper, tree.getSelectionPaths(), project)); + actions.add(createSuppressionCombo(myView)); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actions, true); final JComponent component = toolbar.getComponent(); toolbar.setTargetComponent(this); @@ -144,10 +143,8 @@ public class QuickFixPreviewDecorator extends JPanel implements InspectionTreeLo label.append(problemsCount + " problems:"); } - private static AnAction createSuppressionCombo(@NotNull final InspectionToolWrapper toolWrapper, - @NotNull final TreePath[] paths, - @NotNull final Project project) { - final AnAction[] suppressors = new SuppressActionWrapper(project, toolWrapper, paths).getChildren(null); + private static AnAction createSuppressionCombo(InspectionResultsView view) { + final AnAction[] suppressors = new SuppressActionWrapper().getChildren(AnActionEvent.createFromDataContext(ActionPlaces.CODE_INSPECTION, null, DataManager.getInstance().getDataContext(view))); final ComboBoxAction action = new ComboBoxAction() { { getTemplatePresentation().setText("Suppress"); @@ -157,7 +154,7 @@ public class QuickFixPreviewDecorator extends JPanel implements InspectionTreeLo @NotNull @Override protected DefaultActionGroup createPopupActionGroup(JComponent button) { - DefaultActionGroup group = new DefaultActionGroup(); + DefaultActionGroup group = new DefaultCompactActionGroup(); group.addAll(suppressors); return group; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java new file mode 100644 index 000000000000..1ef8f39aaa8a --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java @@ -0,0 +1,90 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection.ui.actions; + +import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.InspectionProfile; +import com.intellij.codeInspection.InspectionsBundle; +import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction; +import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.codeInspection.ex.InspectionToolWrapper; +import com.intellij.codeInspection.reference.RefElement; +import com.intellij.codeInspection.reference.RefEntity; +import com.intellij.codeInspection.ui.InspectionResultsView; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.profile.codeInspection.InspectionProjectProfileManager; +import com.intellij.psi.PsiElement; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Dmitry Batkovich + */ +public class EditSettingsAction extends InspectionViewActionBase { + public EditSettingsAction() { + super(InspectionsBundle.message("inspection.action.edit.settings"), + InspectionsBundle.message("inspection.action.edit.settings"), + AllIcons.General.Settings); + } + + @Override + public void actionPerformed(AnActionEvent e) { + final InspectionResultsView view = getView(e); + final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(view.getProject()); + final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(); + InspectionProfile inspectionProfile = view.getCurrentProfile(); + final boolean profileIsDefined = view.isProfileDefined(); + if (!profileIsDefined) { + inspectionProfile = guessProfileToSelect(view, profileManager); + } + + if (toolWrapper != null) { + final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool + if (key != null) { + if (new EditInspectionToolsSettingsAction(key) + .editToolSettings(view.getProject(), (InspectionProfileImpl)inspectionProfile, profileIsDefined) + && profileIsDefined) { + view.updateCurrentProfile(); + } + return; + } + } + if (EditInspectionToolsSettingsAction.editToolSettings(view.getProject(), inspectionProfile, profileIsDefined, null) && profileIsDefined) { + view.updateCurrentProfile(); + } + } + + private static InspectionProfile guessProfileToSelect(final InspectionResultsView view, + final InspectionProjectProfileManager profileManager) { + final Set profiles = new HashSet(); + final RefEntity[] selectedElements = view.getTree().getSelectedElements(); + for (RefEntity selectedElement : selectedElements) { + if (selectedElement instanceof RefElement) { + final RefElement refElement = (RefElement)selectedElement; + final PsiElement element = refElement.getElement(); + if (element != null) { + profiles.add(profileManager.getInspectionProfile()); + } + } + } + if (profiles.isEmpty()) { + return (InspectionProfile)profileManager.getProjectProfileImpl(); + } + return profiles.iterator().next(); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionViewActionBase.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionViewActionBase.java new file mode 100644 index 000000000000..d95cb42c2414 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionViewActionBase.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection.ui.actions; + +import com.intellij.codeInspection.ui.InspectionResultsView; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.Presentation; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +/** + * @author Dmitry Batkovich + */ +public abstract class InspectionViewActionBase extends AnAction { + public InspectionViewActionBase(@Nullable String text, @Nullable String description, @Nullable Icon icon) { + super(text, description, icon); + } + + public InspectionViewActionBase(String name) { + super(name); + } + + @Override + public final void update(AnActionEvent e) { + final InspectionResultsView view = getView(e); + final boolean enabled = view != null && isEnabled(view); + final Presentation presentation = e.getPresentation(); + presentation.setEnabled(enabled); + } + + protected boolean isEnabled(@NotNull InspectionResultsView view) { + return true; + } + + public static InspectionResultsView getView(@Nullable AnActionEvent event) { + if (event == null) { + return null; + } + final InspectionResultsView view = InspectionResultsView.DATA_KEY.getData(event.getDataContext()); + return view == null || view.isDisposed() ? null : view; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java index 1d4635bf07c8..ff3c80f7db31 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java @@ -1,38 +1,16 @@ package com.intellij.codeInspection.ui.actions; -import com.intellij.CommonBundle; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.InspectionsBundle; -import com.intellij.codeInspection.ModifiableModel; -import com.intellij.codeInspection.actions.RunInspectionIntention; -import com.intellij.codeInspection.ex.DisableInspectionToolAction; -import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolWrapper; -import com.intellij.codeInspection.reference.RefElement; -import com.intellij.codeInspection.reference.RefEntity; import com.intellij.codeInspection.ui.InspectionResultsView; -import com.intellij.codeInspection.ui.InspectionTree; import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; -import com.intellij.profile.codeInspection.InspectionProjectProfileManager; -import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - /** * User: anna * Date: 11-Jan-2006 @@ -47,15 +25,12 @@ public class InspectionsOptionsToolbarAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { - final DefaultActionGroup options = new DefaultActionGroup(); - final List actions = createActions(); - for (AnAction action : actions) { - options.add(action); - } - final DataContext dataContext = e.getDataContext(); final ListPopup popup = JBPopupFactory.getInstance() - .createActionGroupPopup(getSelectedToolWrapper().getDisplayName(), options, dataContext, - JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); + .createActionGroupPopup(getSelectedToolWrapper().getDisplayName(), + (ActionGroup)ActionManager.getInstance().getAction("InspectionsOptions"), + e.getDataContext(), + JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, + false); InspectionResultsView.showPopup(e, popup); } @@ -86,89 +61,4 @@ public class InspectionsOptionsToolbarAction extends AnAction { private static String getToolOptions(@Nullable final InspectionToolWrapper toolWrapper) { return InspectionsBundle.message("inspections.view.options.title", toolWrapper != null ? toolWrapper.getDisplayName() : ""); } - - public List createActions() { - final List result = new ArrayList(); - final InspectionTree tree = myView.getTree(); - final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(); - if (toolWrapper == null) return result; - final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); - if (key == null) return result; - - result.add(new DisableInspectionAction(key)); - - result.add(new AnAction(InspectionsBundle.message("run.inspection.on.file.intention.text")) { - @Override - public void actionPerformed(final AnActionEvent e) { - final PsiElement psiElement = getPsiElement(tree); - assert psiElement != null; - new RunInspectionIntention(toolWrapper).invoke(myView.getProject(), null, psiElement.getContainingFile()); - } - - @Override - public void update(AnActionEvent e) { - e.getPresentation().setEnabled(getPsiElement(tree) != null); - } - - @Nullable - private PsiElement getPsiElement(InspectionTree tree) { - final RefEntity[] selectedElements = tree.getSelectedElements(); - - final PsiElement psiElement; - if (selectedElements.length > 0 && selectedElements[0] instanceof RefElement) { - psiElement = ((RefElement)selectedElements[0]).getElement(); - } - else { - psiElement = null; - } - return psiElement; - } - }); - - result.add(new SuppressActionWrapper(myView.getProject(), toolWrapper, tree.getSelectionPaths())); - - - return result; - } - - private class DisableInspectionAction extends AnAction { - private final HighlightDisplayKey myKey; - - public DisableInspectionAction(final HighlightDisplayKey key) { - super(DisableInspectionToolAction.NAME); - myKey = key; - } - - @Override - public void actionPerformed(final AnActionEvent e) { - try { - if (myView.isProfileDefined()) { - final ModifiableModel model = myView.getCurrentProfile().getModifiableModel(); - model.disableTool(myKey.toString(), myView.getProject()); - model.commit(); - myView.updateCurrentProfile(); - } else { - final RefEntity[] selectedElements = myView.getTree().getSelectedElements(); - final Set files = new HashSet(); - final Project project = myView.getProject(); - final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); - for (RefEntity selectedElement : selectedElements) { - if (selectedElement instanceof RefElement) { - final PsiElement element = ((RefElement)selectedElement).getElement(); - files.add(element); - } - } - ModifiableModel model = ((InspectionProfileImpl)profileManager.getProjectProfileImpl()).getModifiableModel(); - for (PsiElement element : files) { - model.disableTool(myKey.toString(), element); - } - model.commit(); - DaemonCodeAnalyzer.getInstance(project).restart(); - } - } - catch (IOException e1) { - Messages.showErrorDialog(myView.getProject(), e1.getMessage(), CommonBundle.getErrorTitle()); - } - } - } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java new file mode 100644 index 000000000000..7757e27d1ce5 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java @@ -0,0 +1,134 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection.ui.actions; + +import com.intellij.CommonBundle; +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.InspectionsBundle; +import com.intellij.codeInspection.ModifiableModel; +import com.intellij.codeInspection.actions.RunInspectionIntention; +import com.intellij.codeInspection.ex.DisableInspectionToolAction; +import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.codeInspection.ex.InspectionToolWrapper; +import com.intellij.codeInspection.reference.RefElement; +import com.intellij.codeInspection.reference.RefEntity; +import com.intellij.codeInspection.ui.InspectionResultsView; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.profile.codeInspection.InspectionProjectProfileManager; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Dmitry Batkovich + */ +public abstract class KeyAwareInspectionViewAction extends InspectionViewActionBase { + public KeyAwareInspectionViewAction(String name) { + super(name); + } + + @Override + protected boolean isEnabled(@NotNull InspectionResultsView view) { + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + return wrapper != null && HighlightDisplayKey.find(wrapper.getShortName()) != null; + } + + @Override + public void actionPerformed(AnActionEvent e) { + final InspectionResultsView view = getView(e); + final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper().getShortName()); + actionPerformed(view, key); + } + + protected abstract void actionPerformed(@NotNull InspectionResultsView view, @NotNull HighlightDisplayKey key); + + public static class DisableInspection extends KeyAwareInspectionViewAction { + public DisableInspection() { + super(DisableInspectionToolAction.NAME); + } + + @Override + protected void actionPerformed(@NotNull InspectionResultsView view, @NotNull HighlightDisplayKey key) { + try { + if (view.isProfileDefined()) { + final ModifiableModel model = view.getCurrentProfile().getModifiableModel(); + model.disableTool(key.toString(), view.getProject()); + model.commit(); + view.updateCurrentProfile(); + } else { + final RefEntity[] selectedElements = view.getTree().getSelectedElements(); + final Set files = new HashSet(); + final Project project = view.getProject(); + final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); + for (RefEntity selectedElement : selectedElements) { + if (selectedElement instanceof RefElement) { + final PsiElement element = ((RefElement)selectedElement).getElement(); + files.add(element); + } + } + ModifiableModel model = ((InspectionProfileImpl)profileManager.getProjectProfileImpl()).getModifiableModel(); + for (PsiElement element : files) { + model.disableTool(key.toString(), element); + } + model.commit(); + DaemonCodeAnalyzer.getInstance(project).restart(); + } + } + catch (IOException e1) { + Messages.showErrorDialog(view.getProject(), e1.getMessage(), CommonBundle.getErrorTitle()); + } + } + } + + public static class RunInspectionOn extends KeyAwareInspectionViewAction { + public RunInspectionOn() { + super(InspectionsBundle.message("run.inspection.on.file.intention.text")); + } + + @Override + protected boolean isEnabled(@NotNull InspectionResultsView view) { + return super.isEnabled(view) && getPsiElement(view) != null; + } + + @Override + protected void actionPerformed(@NotNull InspectionResultsView view, @NotNull HighlightDisplayKey key) { + final PsiElement psiElement = getPsiElement(view); + assert psiElement != null; + new RunInspectionIntention(key).invoke(view.getProject(), null, psiElement.getContainingFile()); + } + + @Nullable + private static PsiElement getPsiElement(InspectionResultsView view) { + final RefEntity[] selectedElements = view.getTree().getSelectedElements(); + + final PsiElement psiElement; + if (selectedElements.length > 0 && selectedElements[0] instanceof RefElement) { + psiElement = ((RefElement)selectedElements[0]).getElement(); + } + else { + psiElement = null; + } + return psiElement; + } + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java new file mode 100644 index 000000000000..994df27eef7e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection.ui.actions; + +import com.intellij.codeInspection.ex.InspectionToolWrapper; +import com.intellij.codeInspection.ex.QuickFixAction; +import com.intellij.codeInspection.ui.InspectionResultsView; +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static com.intellij.codeInspection.ui.actions.InspectionViewActionBase.getView; + +/** + * @author Dmitry Batkovich + */ +public class QuickFixesViewActionGroup extends ActionGroup { + @NotNull + @Override + public AnAction[] getChildren(@Nullable AnActionEvent e) { + final InspectionResultsView view = getView(e); + if (view == null) { + return AnAction.EMPTY_ARRAY; + } + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + if (wrapper == null) return AnAction.EMPTY_ARRAY; + + final QuickFixAction[] fixes = view.getProvider().getQuickFixes(wrapper, view.getTree()); + return fixes == null ? AnAction.EMPTY_ARRAY : fixes; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java index 3b0399299785..576bab57e023 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java @@ -20,19 +20,18 @@ */ package com.intellij.codeInspection.ui.actions; +import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.GlobalInspectionContextImpl; import com.intellij.codeInspection.ex.InspectionManagerEx; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.reference.RefEntity; +import com.intellij.codeInspection.ui.InspectionResultsView; import com.intellij.codeInspection.ui.InspectionTreeNode; import com.intellij.codeInspection.ui.ProblemDescriptionNode; import com.intellij.codeInspection.ui.RefElementNode; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Separator; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; @@ -51,43 +50,27 @@ import org.jetbrains.annotations.Nullable; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; import java.util.Set; -public class SuppressActionWrapper extends ActionGroup { - private final Project myProject; - private final InspectionManagerEx myManager; - private final Set myNodesToSuppress = new HashSet(); - private final InspectionToolWrapper myToolWrapper; +import static com.intellij.codeInspection.ui.actions.InspectionViewActionBase.getView; + +public class SuppressActionWrapper extends ActionGroup implements CompactActionGroup { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.actions.SuppressActionWrapper"); - public SuppressActionWrapper(@NotNull final Project project, - @NotNull final InspectionToolWrapper toolWrapper, - @NotNull final TreePath... paths) { + public SuppressActionWrapper() { super(InspectionsBundle.message("suppress.inspection.problem"), false); - myProject = project; - myManager = (InspectionManagerEx)InspectionManager.getInstance(myProject); - for (TreePath path : paths) { - final Object node = path.getLastPathComponent(); - if (!(node instanceof TreeNode)) continue; - TreeUtil.traverse((TreeNode)node, new TreeUtil.Traverse() { - @Override - public boolean accept(final Object node) { //fetch leaves - final InspectionTreeNode n = (InspectionTreeNode)node; - if (n.isLeaf()) { - myNodesToSuppress.add(n); - } - return true; - } - }); - } - myToolWrapper = toolWrapper; } @Override @NotNull public AnAction[] getChildren(@Nullable final AnActionEvent e) { - final SuppressIntentionAction[] suppressActions = InspectionManagerEx.getSuppressActions(myToolWrapper); + final InspectionResultsView view = getView(e); + if (view == null) return AnAction.EMPTY_ARRAY; + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + if (wrapper == null) return AnAction.EMPTY_ARRAY; + final SuppressIntentionAction[] suppressActions = InspectionManagerEx.getSuppressActions(wrapper); if (suppressActions == null || suppressActions.length == 0) return new SuppressTreeAction[0]; final AnAction[] actions = new AnAction[suppressActions.length + 1]; for (int i = 0; i < suppressActions.length; i++) { @@ -108,18 +91,19 @@ public class SuppressActionWrapper extends ActionGroup { return actions; } - private boolean suppress(@NotNull final PsiElement element, - final CommonProblemDescriptor descriptor, - final SuppressIntentionAction action, - final RefEntity refEntity) { + private static boolean suppress(@NotNull final PsiElement element, + final CommonProblemDescriptor descriptor, + final SuppressIntentionAction action, + @NotNull final RefEntity refEntity, InspectionToolWrapper wrapper) { if (action instanceof SuppressIntentionActionFromFix && !(descriptor instanceof ProblemDescriptor)) { - LOG.info("local suppression fix for specific problem descriptor: " + myToolWrapper.getTool().getClass().getName()); + LOG.info("local suppression fix for specific problem descriptor: " + wrapper.getTool().getClass().getName()); } - final PsiModificationTracker tracker = PsiManager.getInstance(myProject).getModificationTracker(); + final Project project = element.getProject(); + final PsiModificationTracker tracker = PsiManager.getInstance(project).getModificationTracker(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { - PsiDocumentManager.getInstance(myProject).commitAllDocuments(); + PsiDocumentManager.getInstance(project).commitAllDocuments(); try { final long startModificationCount = tracker.getModificationCount(); @@ -131,15 +115,15 @@ public class SuppressActionWrapper extends ActionGroup { container = element; } - if (action.isAvailable(myProject, null, element)) { - action.invoke(myProject, null, element); + if (action.isAvailable(project, null, element)) { + action.invoke(project, null, element); } if (startModificationCount != tracker.getModificationCount()) { - final Set globalInspectionContexts = myManager.getRunningContexts(); + final Set globalInspectionContexts = ((InspectionManagerEx)InspectionManager.getInstance(element.getProject())).getRunningContexts(); for (GlobalInspectionContextImpl context : globalInspectionContexts) { - context.ignoreElement(myToolWrapper.getTool(), container); + context.ignoreElement(wrapper.getTool(), container); if (descriptor != null) { - context.getPresentation(myToolWrapper).ignoreCurrentElementProblem(refEntity, descriptor); + context.getPresentation(wrapper).ignoreCurrentElementProblem(refEntity, descriptor); } } } @@ -152,12 +136,6 @@ public class SuppressActionWrapper extends ActionGroup { return true; } - @Override - public void update(final AnActionEvent e) { - super.update(e); - e.getPresentation().setEnabled(InspectionManagerEx.getSuppressActions(myToolWrapper) != null); - } - private static Pair getContentToSuppress(InspectionTreeNode node) { RefElement refElement = null; CommonProblemDescriptor descriptor = null; @@ -177,7 +155,7 @@ public class SuppressActionWrapper extends ActionGroup { return Pair.create(element, descriptor); } - public class SuppressTreeAction extends AnAction { + public static class SuppressTreeAction extends KeyAwareInspectionViewAction { private final SuppressIntentionAction mySuppressAction; public SuppressTreeAction(final SuppressIntentionAction suppressAction) { @@ -186,14 +164,16 @@ public class SuppressActionWrapper extends ActionGroup { } @Override - public void actionPerformed(final AnActionEvent e) { + protected void actionPerformed(@NotNull InspectionResultsView view, @NotNull HighlightDisplayKey key) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { + Project project = view.getProject(); + CommandProcessor.getInstance().executeCommand(project, new Runnable() { @Override public void run() { - for (InspectionTreeNode node : myNodesToSuppress) { + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + for (InspectionTreeNode node : getNodesToSuppress(view)) { final Pair content = getContentToSuppress(node); if (content.first == null) break; final PsiElement element = content.first; @@ -203,13 +183,13 @@ public class SuppressActionWrapper extends ActionGroup { } else if (node instanceof ProblemDescriptionNode) { refEntity = ((ProblemDescriptionNode)node).getElement(); } - if (!suppress(element, content.second, mySuppressAction, refEntity)) break; + if (!suppress(element, content.second, mySuppressAction, refEntity, wrapper)) break; } - final Set globalInspectionContexts = myManager.getRunningContexts(); + final Set globalInspectionContexts = ((InspectionManagerEx)InspectionManager.getInstance(project)).getRunningContexts(); for (GlobalInspectionContextImpl context : globalInspectionContexts) { context.refreshViews(); } - CommandProcessor.getInstance().markCurrentCommandAsGlobal(myProject); + CommandProcessor.getInstance().markCurrentCommandAsGlobal(project); } }, getTemplatePresentation().getText(), null); } @@ -217,17 +197,12 @@ public class SuppressActionWrapper extends ActionGroup { } @Override - public void update(final AnActionEvent e) { - super.update(e); - if (!isAvailable()) e.getPresentation().setVisible(false); - } - - public boolean isAvailable() { - for (InspectionTreeNode node : myNodesToSuppress) { + protected boolean isEnabled(@NotNull InspectionResultsView view) { + for (InspectionTreeNode node : getNodesToSuppress(view)) { final Pair content = getContentToSuppress(node); if (content.first == null) continue; final PsiElement element = content.first; - if (mySuppressAction.isAvailable(myProject, null, element)) { + if (mySuppressAction.isAvailable(view.getProject(), null, element)) { return true; } } @@ -238,4 +213,25 @@ public class SuppressActionWrapper extends ActionGroup { return mySuppressAction.isSuppressAll(); } } + + private static Set getNodesToSuppress(@NotNull InspectionResultsView view) { + final TreePath[] paths = view.getTree().getSelectionPaths(); + if (paths == null) return Collections.emptySet(); + final Set result = new HashSet<>(); + for (TreePath path : paths) { + final Object node = path.getLastPathComponent(); + if (!(node instanceof TreeNode)) continue; + TreeUtil.traverse((TreeNode)node, new TreeUtil.Traverse() { + @Override + public boolean accept(final Object node) { //fetch leaves + final InspectionTreeNode n = (InspectionTreeNode)node; + if (n.isLeaf()) { + result.add(n); + } + return true; + } + }); + } + return result; + } } diff --git a/platform/lang-impl/src/com/intellij/find/FindUtil.java b/platform/lang-impl/src/com/intellij/find/FindUtil.java index 9830fd669572..489f6936c4c5 100644 --- a/platform/lang-impl/src/com/intellij/find/FindUtil.java +++ b/platform/lang-impl/src/com/intellij/find/FindUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,13 +63,15 @@ import com.intellij.ui.LightweightHint; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.usages.impl.UsageViewImpl; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; public class FindUtil { private static final Key KEY = Key.create("FindUtil.KEY"); @@ -78,7 +80,7 @@ public class FindUtil { } @Nullable - static VirtualFile getVirtualFile(@NotNull Editor myEditor) { + private static VirtualFile getVirtualFile(@NotNull Editor myEditor) { Project project = myEditor.getProject(); PsiFile file = project != null ? PsiDocumentManager.getInstance(project).getPsiFile(myEditor.getDocument()) : null; return file != null ? file.getVirtualFile() : null; @@ -135,12 +137,7 @@ public class FindUtil { } } else { - if (firstSearch) { - stringToFind = ""; - } - else { - stringToFind = model.getStringToFind(); - } + stringToFind = firstSearch ? "" : model.getStringToFind(); } model.setReplaceState(replace); model.setStringToFind(stringToFind); @@ -234,48 +231,45 @@ public class FindUtil { model.setReplaceState(false); model.setFindAllEnabled(PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()) != null); - findManager.showFindDialog(model, new Runnable() { - @Override - public void run() { - if (model.isFindAll()) { - findManager.setFindNextModel(model); - findAllAndShow(project, editor, model); + findManager.showFindDialog(model, () -> { + if (model.isFindAll()) { + findManager.setFindNextModel(model); + findAllAndShow(project, editor, model); + return; + } + + if (!model.isGlobal() && editor.getSelectionModel().hasSelection()) { + int offset = model.isForward() + ? editor.getSelectionModel().getSelectionStart() + : editor.getSelectionModel().getSelectionEnd(); + ScrollType scrollType = model.isForward() ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP; + moveCaretAndDontChangeSelection(editor, offset, scrollType); + } + + int offset; + if (model.isGlobal()) { + if (model.isFromCursor()) { + offset = editor.getCaretModel().getOffset(); + } + else { + offset = model.isForward() ? 0 : editor.getDocument().getTextLength(); + } + } + else { + // in selection + + if (!editor.getSelectionModel().hasSelection()) { + // TODO[anton] actually, this should never happen - Find dialog should not allow such combination + findManager.setFindNextModel(null); return; } - if (!model.isGlobal() && editor.getSelectionModel().hasSelection()) { - int offset = model.isForward() - ? editor.getSelectionModel().getSelectionStart() - : editor.getSelectionModel().getSelectionEnd(); - ScrollType scrollType = model.isForward() ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP; - moveCaretAndDontChangeSelection(editor, offset, scrollType); - } - - int offset; - if (model.isGlobal()) { - if (model.isFromCursor()) { - offset = editor.getCaretModel().getOffset(); - } - else { - offset = model.isForward() ? 0 : editor.getDocument().getTextLength(); - } - } - else { - // in selection - - if (!editor.getSelectionModel().hasSelection()) { - // TODO[anton] actually, this should never happen - Find dialog should not allow such combination - findManager.setFindNextModel(null); - return; - } - - offset = model.isForward() ? editor.getSelectionModel().getSelectionStart() : editor.getSelectionModel().getSelectionEnd(); - } - - findManager.setFindNextModel(null); - findManager.getFindInFileModel().copyFrom(model); - doSearch(project, editor, offset, true, model, true); + offset = model.isForward() ? editor.getSelectionModel().getSelectionStart() : editor.getSelectionModel().getSelectionEnd(); } + + findManager.setFindNextModel(null); + findManager.getFindInFileModel().copyFrom(model); + doSearch(project, editor, offset, true, model, true); }); } @@ -287,7 +281,7 @@ public class FindUtil { CharSequence text = document.getCharsSequence(); int textLength = document.getTextLength(); - final List usages = new ArrayList(); + final List usages = new ArrayList<>(); FindManager findManager = FindManager.getInstance(project); findModel.setForward(true); // when find all there is no diff in direction @@ -369,7 +363,7 @@ public class FindUtil { return searchAgain(project, editor, context); } - public static boolean searchAgain(final Project project, final Editor editor, @Nullable DataContext context) { + private static boolean searchAgain(final Project project, final Editor editor, @Nullable DataContext context) { FindManager findManager = FindManager.getInstance(project); if (!findManager.findWasPerformed() && !findManager.selectNextOccurrenceWasPerformed()) { new IncrementalFindAction().getHandler().execute(editor, context); @@ -434,62 +428,54 @@ public class FindUtil { } model.setReplaceState(true); - findManager.showFindDialog(model, new Runnable() { - @Override - public void run() { - if (!model.isGlobal() && editor.getSelectionModel().hasSelection()) { - int offset = model.isForward() - ? editor.getSelectionModel().getSelectionStart() - : editor.getSelectionModel().getSelectionEnd(); - ScrollType scrollType = model.isForward() ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP; - moveCaretAndDontChangeSelection(editor, offset, scrollType); - } - int offset; - if (model.isGlobal()) { - if (model.isFromCursor()) { - offset = editor.getCaretModel().getOffset(); - if (!model.isForward()) { - offset++; - } - } - else { - offset = model.isForward() ? 0 : editor.getDocument().getTextLength(); + findManager.showFindDialog(model, () -> { + if (!model.isGlobal() && editor.getSelectionModel().hasSelection()) { + int offset = model.isForward() + ? editor.getSelectionModel().getSelectionStart() + : editor.getSelectionModel().getSelectionEnd(); + ScrollType scrollType = model.isForward() ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP; + moveCaretAndDontChangeSelection(editor, offset, scrollType); + } + int offset; + if (model.isGlobal()) { + if (model.isFromCursor()) { + offset = editor.getCaretModel().getOffset(); + if (!model.isForward()) { + offset++; } } else { - // in selection - - if (!editor.getSelectionModel().hasSelection()) { - // TODO[anton] actually, this should never happen - Find dialog should not allow such combination - findManager.setFindNextModel(null); - return; - } - - offset = model.isForward() ? editor.getSelectionModel().getSelectionStart() : editor.getSelectionModel().getSelectionEnd(); + offset = model.isForward() ? 0 : editor.getDocument().getTextLength(); } - - if (s != null && editor.getSelectionModel().hasSelection() && s.equals(model.getStringToFind())) { - if (model.isFromCursor() && model.isForward()) { - offset = Math.min(editor.getSelectionModel().getSelectionStart(), offset); - } - else if (model.isFromCursor() && !model.isForward()) { - offset = Math.max(editor.getSelectionModel().getSelectionEnd(), offset); - } - } - findManager.setFindNextModel(null); - findManager.getFindInFileModel().copyFrom(model); - replace(project, editor, offset, model); } + else { + // in selection + + if (!editor.getSelectionModel().hasSelection()) { + // TODO[anton] actually, this should never happen - Find dialog should not allow such combination + findManager.setFindNextModel(null); + return; + } + + offset = model.isForward() ? editor.getSelectionModel().getSelectionStart() : editor.getSelectionModel().getSelectionEnd(); + } + + if (s != null && editor.getSelectionModel().hasSelection() && s.equals(model.getStringToFind())) { + if (model.isFromCursor() && model.isForward()) { + offset = Math.min(editor.getSelectionModel().getSelectionStart(), offset); + } + else if (model.isFromCursor() && !model.isForward()) { + offset = Math.max(editor.getSelectionModel().getSelectionEnd(), offset); + } + } + findManager.setFindNextModel(null); + findManager.getFindInFileModel().copyFrom(model); + replace(project, editor, offset, model); }); } public static boolean replace(Project project, Editor editor, int offset, FindModel model) { - return replace(project, editor, offset, model, new ReplaceDelegate() { - @Override - public boolean shouldReplace(TextRange range, String replace) { - return true; - } - }); + return replace(project, editor, offset, model, (range, replace) -> true); } public static boolean replace(Project project, Editor editor, int offset, FindModel model, ReplaceDelegate delegate) { @@ -521,7 +507,7 @@ public class FindUtil { final FindModel model = aModel.clone(); int occurrences = 0; - List> rangesToChange = new ArrayList>(); + List> rangesToChange = new ArrayList<>(); boolean replaced = false; boolean reallyReplaced = false; @@ -591,12 +577,7 @@ public class FindUtil { if (!toPrompt) { CharSequence text = document.getCharsSequence(); final StringBuilder newText = new StringBuilder(document.getTextLength()); - Collections.sort(rangesToChange, new Comparator>() { - @Override - public int compare(Pair o1, Pair o2) { - return o1.getFirst().getStartOffset() - o2.getFirst().getStartOffset(); - } - }); + Collections.sort(rangesToChange, (o1, o2) -> o1.getFirst().getStartOffset() - o2.getFirst().getStartOffset()); int offsetBefore = 0; for (Pair pair : rangesToChange) { TextRange range = pair.getFirst(); @@ -618,21 +599,13 @@ public class FindUtil { caretOffset = newText.length(); } final int finalCaretOffset = caretOffset; - CommandProcessor.getInstance().executeCommand(project, new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - document.setText(newText); - editor.getCaretModel().moveToOffset(finalCaretOffset); - if (model.isGlobal()) { - editor.getSelectionModel().removeSelection(); - } - } - }); + CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { + document.setText(newText); + editor.getCaretModel().moveToOffset(finalCaretOffset); + if (model.isGlobal()) { + editor.getSelectionModel().removeSelection(); } - }, null, document); + }), null, document); } else { if (reallyReplaced) { @@ -725,12 +698,9 @@ public class FindUtil { selection.removeSelection(); scrollingModel.scrollToCaret(scrollType); scrollingModel.runActionOnScrollingFinished( - new Runnable() { - @Override - public void run() { - scrollingModel.scrollTo(editor.offsetToLogicalPosition(result.getStartOffset()), scrollType); - scrollingModel.scrollTo(editor.offsetToLogicalPosition(result.getEndOffset()), scrollType); - } + () -> { + scrollingModel.scrollTo(editor.offsetToLogicalPosition(result.getStartOffset()), scrollType); + scrollingModel.scrollTo(editor.offsetToLogicalPosition(result.getEndOffset()), scrollType); } ); } @@ -804,7 +774,7 @@ public class FindUtil { AnAction action = ActionManager.getInstance().getAction( modelForNextSearch.isForward() ? IdeActions.ACTION_FIND_NEXT : IdeActions.ACTION_FIND_PREVIOUS); String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action); - if (shortcutsText.length() > 0) { + if (!shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.top.hotkey.message", message, shortcutsText); } else { @@ -816,7 +786,7 @@ public class FindUtil { AnAction action = ActionManager.getInstance().getAction( modelForNextSearch.isForward() ? IdeActions.ACTION_FIND_PREVIOUS : IdeActions.ACTION_FIND_NEXT); String shortcutsText = KeymapUtil.getFirstKeyboardShortcutText(action); - if (shortcutsText.length() > 0) { + if (!shortcutsText.isEmpty()) { message = FindBundle.message("find.search.again.from.bottom.hotkey.message", message, shortcutsText); } else { @@ -893,24 +863,16 @@ public class FindUtil { return new TextRange(start, end); } - public static int doReplace(Project project, - final Document document, - final int startOffset, - final int endOffset, - final String stringToReplace) { + private static int doReplace(Project project, + final Document document, + final int startOffset, + final int endOffset, + final String stringToReplace) { final String converted = StringUtil.convertLineSeparators(stringToReplace); - CommandProcessor.getInstance().executeCommand(project, new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - //[ven] I doubt converting is a good solution to SCR 21224 - document.replaceString(startOffset, endOffset, converted); - } - }); - } - }, null, null); + CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { + //[ven] I doubt converting is a good solution to SCR 21224 + document.replaceString(startOffset, endOffset, converted); + }), null, null); return startOffset + converted.length(); } @@ -920,31 +882,28 @@ public class FindUtil { editor.getScrollingModel().scrollToCaret(scrollType); } + @FunctionalInterface public interface ReplaceDelegate { boolean shouldReplace(TextRange range, String replace); } @Nullable - public static UsageView showInUsageView(PsiElement sourceElement, @NotNull PsiElement[] targets, @NotNull String title, @NotNull final Project project) { + public static UsageView showInUsageView(@Nullable PsiElement sourceElement, + @NotNull PsiElement[] targets, + @NotNull String title, + @NotNull final Project project) { if (targets.length == 0) return null; final UsageViewPresentation presentation = new UsageViewPresentation(); presentation.setCodeUsagesString(title); presentation.setTabName(title); presentation.setTabText(title); - final UsageTarget[] usageTargets = - sourceElement == null ? UsageTarget.EMPTY_ARRAY : new UsageTarget[]{new PsiElement2UsageTargetAdapter(sourceElement)}; + UsageTarget[] usageTargets = sourceElement == null ? UsageTarget.EMPTY_ARRAY : new UsageTarget[]{new PsiElement2UsageTargetAdapter(sourceElement)}; - final PsiElement[] primary = sourceElement == null ? PsiElement.EMPTY_ARRAY : new PsiElement[]{sourceElement}; - final Usage[] usages = {UsageInfoToUsageConverter.convert(primary, new UsageInfo(targets[0]))}; - final UsageView view = - UsageViewManager.getInstance(project).showUsages(usageTargets, usages, presentation); + PsiElement[] primary = sourceElement == null ? PsiElement.EMPTY_ARRAY : new PsiElement[]{sourceElement}; + UsageView view = UsageViewManager.getInstance(project).showUsages(usageTargets, Usage.EMPTY_ARRAY, presentation); - final List pointers = ContainerUtil.map(targets, new Function() { - @Override - public SmartPsiElementPointer fun(PsiElement psiElement) { - return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement); - } - }); + SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project); + List pointers = ContainerUtil.map(targets, smartPointerManager::createSmartPsiElementPointer); // usage view will load document/AST so still referencing all these PSI elements might lead to out of memory //noinspection UnusedAssignment @@ -955,13 +914,10 @@ public class FindUtil { public void run(@NotNull ProgressIndicator indicator) { for (final SmartPsiElementPointer pointer : pointers) { if (((UsageViewImpl)view).isDisposed()) break; - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - public void run() { - final PsiElement target = pointer.getElement(); - if (target != null) { - view.appendUsage(UsageInfoToUsageConverter.convert(primary, new UsageInfo(target))); - } + ApplicationManager.getApplication().runReadAction(() -> { + final PsiElement target = pointer.getElement(); + if (target != null) { + view.appendUsage(UsageInfoToUsageConverter.convert(primary, new UsageInfo(target))); } }); } @@ -982,7 +938,7 @@ public class FindUtil { if (!editor.getCaretModel().supportsMultipleCarets()) { return; } - ArrayList caretStates = new ArrayList(); + ArrayList caretStates = new ArrayList<>(); while (resultIterator.hasNext()) { FindResult findResult = resultIterator.next(); int caretOffset = getCaretPosition(findResult, caretShiftFromSelectionStart); diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java index 7b02fa8cfb6b..0ed1020218de 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java @@ -53,6 +53,7 @@ import com.intellij.openapi.progress.util.ReadTask; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.*; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; @@ -93,6 +94,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import static com.intellij.ui.SimpleTextAttributes.STYLE_PLAIN; + public class FindDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance("#com.intellij.find.impl.FindDialog"); @@ -397,7 +400,7 @@ public class FindDialog extends DialogWrapper { component.getActionMap().put(newActionKey, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - if(isResultsPreviewTabActive()) { + if(isResultsPreviewTabActive() && !component.isPopupVisible()) { newAction.run(); return; } @@ -1679,6 +1682,9 @@ public class FindDialog extends DialogWrapper { } }; private final ColoredTableCellRenderer myFileAndLineNumber = new ColoredTableCellRenderer() { + private final SimpleTextAttributes REPEATED_FILE_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, new JBColor(0xCCCCCC, 0x5E5E5E)); + private final SimpleTextAttributes ORDINAL_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, new JBColor(0x999999, 0x999999)); + @Override protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof UsageInfo2UsageAdapter) { @@ -1687,11 +1693,22 @@ public class FindDialog extends DialogWrapper { // line number / file info VirtualFile file = usageAdapter.getFile(); String uniqueVirtualFilePath = myOmitFileExtension ? file.getNameWithoutExtension() : file.getName(); - append(uniqueVirtualFilePath + " " + text[0].getText(), SimpleTextAttributes.GRAYED_ATTRIBUTES); + VirtualFile prevFile = findPrevFile(table, row, column); + SimpleTextAttributes attributes = Comparing.equal(file, prevFile) ? REPEATED_FILE_ATTRIBUTES : ORDINAL_ATTRIBUTES; + append(uniqueVirtualFilePath, attributes); + append(" " + text[0].getText(), ORDINAL_ATTRIBUTES); } setBorder(null); } + + @Nullable + private VirtualFile findPrevFile(@NotNull JTable table, int row, int column) { + if (row <= 0) return null; + Object prev = table.getValueAt(row - 1, column); + return prev instanceof UsageInfo2UsageAdapter ? ((UsageInfo2UsageAdapter)prev).getFile() : null; + } }; + private static final int MARGIN = 2; private final boolean myOmitFileExtension; private final boolean myUseBold; diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index c133972de151..eb0d172a52a5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -162,7 +162,6 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private Map myConfigurables = new HashMap(); private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, ApplicationManager.getApplication()); - private Alarm myUpdateAlarm = new Alarm(ApplicationManager.getApplication()); private JBList myList; private JCheckBox myNonProjectCheckBox; private AnActionEvent myActionEvent; @@ -932,33 +931,36 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA final Object value = myList.getSelectedValue(); if (CommonDataKeys.PSI_ELEMENT.is(dataId) && value instanceof PsiElement) { return value; - } else if (CommonDataKeys.VIRTUAL_FILE.is(dataId) && value instanceof VirtualFile) { + } + if (CommonDataKeys.VIRTUAL_FILE.is(dataId) && value instanceof VirtualFile) { return value; - } else if (CommonDataKeys.NAVIGATABLE.is(dataId)) { - if (value instanceof Navigatable) return value; - if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) { - final Object config = ((ChooseRunConfigurationPopup.ItemWrapper)value).getValue(); - if (config instanceof RunnerAndConfigurationSettings) { - return new Navigatable() { - @Override - public void navigate(boolean requestFocus) { - Executor executor = findExecutor((RunnerAndConfigurationSettings)config); - RunDialog.editConfiguration(project, (RunnerAndConfigurationSettings)config, "Edit Configuration", executor); - } - - @Override - public boolean canNavigate() { - return true; - } - - @Override - public boolean canNavigateToSource() { - return true; - } - }; + } + if (CommonDataKeys.NAVIGATABLE.is(dataId)) { + if (value instanceof Navigatable) return value; + if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) { + final Object config = ((ChooseRunConfigurationPopup.ItemWrapper)value).getValue(); + if (config instanceof RunnerAndConfigurationSettings) { + return new Navigatable() { + @Override + public void navigate(boolean requestFocus) { + Executor executor = findExecutor((RunnerAndConfigurationSettings)config); + RunDialog.editConfiguration(project, (RunnerAndConfigurationSettings)config, "Edit Configuration", executor); } - } - } else if (PlatformDataKeys.SEARCH_INPUT_TEXT.is(dataId)) { + + @Override + public boolean canNavigate() { + return true; + } + + @Override + public boolean canNavigateToSource() { + return true; + } + }; + } + } + } + if (PlatformDataKeys.SEARCH_INPUT_TEXT.is(dataId)) { return myPopupField == null ? null : myPopupField.getText(); } return null; @@ -1076,7 +1078,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private class MyListRenderer extends ColoredListCellRenderer { ColoredListCellRenderer myLocation = new ColoredListCellRenderer() { @Override - protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { + protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) { setPaintFocusBorder(false); append(myLocationString, SimpleTextAttributes.GRAYED_ATTRIBUTES); setIcon(myLocationIcon); @@ -1193,7 +1195,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } @Override - protected void customizeCellRenderer(JList list, final Object value, int index, final boolean selected, boolean hasFocus) { + protected void customizeCellRenderer(@NotNull JList list, final Object value, int index, final boolean selected, boolean hasFocus) { setPaintFocusBorder(false); setIcon(EmptyIcon.ICON_16); ApplicationManager.getApplication().runReadAction(new Runnable() { @@ -1241,7 +1243,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } } - append(templatePresentation.getText()); + append(String.valueOf(templatePresentation.getText())); if (actionWithParentGroup != null) { final String groupName = actionWithParentGroup.getGroupName(); if (!StringUtil.isEmpty(groupName)) { @@ -2663,16 +2665,13 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA JLabel titleLabel = new JLabel(titleText); titleLabel.setFont(getTitleFont()); titleLabel.setForeground(UIUtil.getLabelDisabledForeground()); - final Color bg = UIUtil.getListBackground(); SeparatorComponent separatorComponent = new SeparatorComponent(titleLabel.getPreferredSize().height / 2, new JBColor(Gray._220, Gray._80), null); - JPanel result = new JPanel(new BorderLayout(5, 10)); - result.add(titleLabel, BorderLayout.WEST); - result.add(separatorComponent, BorderLayout.CENTER); - result.setBackground(bg); - - return result; + return JBUI.Panels.simplePanel(5, 10) + .addToCenter(separatorComponent) + .addToLeft(titleLabel) + .withBackground(UIUtil.getListBackground()); } private enum HistoryType {PSI, FILE, SETTING, ACTION, RUN_CONFIGURATION} diff --git a/platform/lang-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java b/platform/lang-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java index 1071b412ac9f..0327f604c1c0 100644 --- a/platform/lang-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java +++ b/platform/lang-impl/src/com/intellij/openapi/options/colors/pages/GeneralColorsPage.java @@ -46,6 +46,7 @@ public class GeneralColorsPage implements ColorSettingsPage, InspectionColorSett "//TODO: Visit JB Web resources:\n"+ "JetBrains Home Page: http://www.jetbrains.com\n" + "JetBrains Developer Community: https://www.jetbrains.com/devnet\n" + + "ReferenceHyperlink\n" + "\n" + "Search:\n" + " result = \"text, text, text\";\n" + @@ -145,6 +146,7 @@ public class GeneralColorsPage implements ColorSettingsPage, InspectionColorSett ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("todo", CodeInsightColors.TODO_DEFAULT_ATTRIBUTES); ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("hyperlink", CodeInsightColors.HYPERLINK_ATTRIBUTES); ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("hyperlink_f", CodeInsightColors.FOLLOWED_HYPERLINK_ATTRIBUTES); + ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("ref_hyperlink", EditorColors.REFERENCE_HYPERLINK_COLOR); ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("wrong_ref", CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); ADDITIONAL_HIGHLIGHT_DESCRIPTORS.put("deprecated", CodeInsightColors.DEPRECATED_ATTRIBUTES); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java index 7a37554e950e..5acf72be1258 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -316,12 +316,12 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen private class AppListener extends ApplicationAdapter { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { myInsideRefresh++; } @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { if (--myInsideRefresh == 0) { if (myPointerChangesDetected) { myPointerChangesDetected = false; diff --git a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java index bbb53e327534..3b52f3c54882 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java +++ b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java @@ -71,7 +71,7 @@ class EncodingFileTreeTable extends AbstractFileTreeTable { setText(encodingText + (failReason == null ? "" : " (" + failReason + ")")); } - setEnabled(enabled); + setEnabled(enabled || isSelected); // do not use grayed text on selected row return this; } }); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java b/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java index 2b803d02a853..ce8aaacc2965 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class PostprocessReformattingAspect implements PomModelAspect { ApplicationListener applicationListener = new ApplicationAdapter() { @Override - public void writeActionStarted(final Object action) { + public void writeActionStarted(@NotNull final Object action) { if (processor != null) { final Project project = processor.getCurrentCommandProject(); if (project == myProject) { @@ -96,7 +96,7 @@ public class PostprocessReformattingAspect implements PomModelAspect { } @Override - public void writeActionFinished(final Object action) { + public void writeActionFinished(@NotNull final Object action) { if (processor != null) { final Project project = processor.getCurrentCommandProject(); if (project == myProject) { diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index a295767004a8..84ce4d8c5183 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -148,7 +148,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe extension instanceof StringStubIndexExtension && ((StringStubIndexExtension)extension).traceKeyHashToVirtualFileMapping() ); - final MemoryIndexStorage memStorage = new MemoryIndexStorage(storage); + final MemoryIndexStorage memStorage = new MemoryIndexStorage(storage, indexKey); MyIndex index = new MyIndex<>(new IndexExtension() { @NotNull @Override diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form index 1de53ad6f31b..bb971d7b95eb 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form @@ -48,7 +48,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java index 1fc9dc3e7fcc..bbca1a5cba1c 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java @@ -23,6 +23,8 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.MethodSignatureComponent; +import com.intellij.refactoring.util.AbstractVariableData; +import com.intellij.refactoring.util.SimpleParameterTablePanel; import com.intellij.ui.DocumentAdapter; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; @@ -36,7 +38,7 @@ import java.util.Map; public class AbstractExtractMethodDialog extends DialogWrapper implements ExtractMethodSettings { private JPanel myContentPane; - private AbstractParameterTablePanel myParametersPanel; + private SimpleParameterTablePanel myParametersPanel; private JTextField myMethodNameTextField; private MethodSignatureComponent mySignaturePreviewTextArea; private JTextArea myOutputVariablesTextArea; @@ -90,10 +92,9 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac }); - myVariableData = createVariableData(myArguments); + myVariableData = createVariableDataByNames(myArguments); myVariablesMap = createVariableMap(myVariableData); - myParametersPanel.setVariableData(myVariableData); - myParametersPanel.init(); + myParametersPanel.init(myVariableData); updateOutputVariables(); updateSignature(); @@ -105,7 +106,7 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac return myMethodNameTextField; } - public static AbstractVariableData[] createVariableData(final List args) { + public static AbstractVariableData[] createVariableDataByNames(final List args) { final AbstractVariableData[] datas = new AbstractVariableData[args.size()]; for (int i = 0; i < args.size(); i++) { final AbstractVariableData data = new AbstractVariableData(); @@ -118,6 +119,11 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac return datas; } + @Deprecated + public static com.intellij.refactoring.extractMethod.AbstractVariableData[] createVariableData(final List args) { + return com.intellij.refactoring.extractMethod.AbstractVariableData.copy(createVariableDataByNames(args)); + } + public static Map createVariableMap(final AbstractVariableData[] data) { final HashMap map = new HashMap(); for (AbstractVariableData variableData : data) { @@ -158,7 +164,7 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac } private void createUIComponents() { - myParametersPanel = new AbstractParameterTablePanel(myValidator){ + myParametersPanel = new SimpleParameterTablePanel(myValidator::isValidName) { @Override protected void doCancelAction() { AbstractExtractMethodDialog.this.doCancelAction(); @@ -197,7 +203,7 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac } private void updateSignature() { - mySignaturePreviewTextArea.setSignature(myDecorator.createMethodPreview(getMethodName(), myVariableData)); + mySignaturePreviewTextArea.setSignature(myDecorator.createMethodSignature(getMethodName(), myVariableData)); } private void updateOkStatus() { @@ -210,7 +216,7 @@ public class AbstractExtractMethodDialog extends DialogWrapper implements Extrac } @Override - public AbstractVariableData[] getVariableData() { + public AbstractVariableData[] getAbstractVariableData() { return myVariableData; } diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractParameterTablePanel.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractParameterTablePanel.java deleted file mode 100644 index c62a9cb3dc26..000000000000 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractParameterTablePanel.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.refactoring.extractMethod; - -import com.intellij.ui.TableUtil; -import com.intellij.ui.ToolbarDecorator; -import com.intellij.ui.table.JBTable; -import com.intellij.util.ui.EditableModel; -import com.intellij.util.ui.JBUI; -import org.jetbrains.annotations.NonNls; - -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.DefaultTableCellRenderer; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; - -/** - * @author oleg - * It`s a modified copy of com.intellij.refactoring.util.ParameterTablePanel - */ -public abstract class AbstractParameterTablePanel extends JPanel { - private AbstractVariableData[] myVariableData; - - private JBTable myTable; - private MyTableModel myTableModel; - private final ExtractMethodValidator myValidator; - - protected abstract void updateSignature(); - - protected abstract void doEnterAction(); - - protected abstract void doCancelAction(); - - public void setVariableData(AbstractVariableData[] variableData) { - myVariableData = variableData; - } - - public AbstractParameterTablePanel(final ExtractMethodValidator validator) { - super(new BorderLayout()); - myValidator = validator; - } - - public void init() { - myTableModel = new MyTableModel(); - myTable = new JBTable(myTableModel); - DefaultCellEditor defaultEditor = (DefaultCellEditor)myTable.getDefaultEditor(Object.class); - defaultEditor.setClickCountToStart(1); - - myTable.setTableHeader(null); - myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - TableUtil.setupCheckboxColumn(myTable, MyTableModel.CHECKMARK_COLUMN); - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_NAME_COLUMN).setCellRenderer(new DefaultTableCellRenderer() { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - AbstractVariableData data = myVariableData[row]; - setText(data.name); - return this; - } - }); - - - myTable.setPreferredScrollableViewportSize(new Dimension(250, myTable.getRowHeight() * 5)); - myTable.setShowGrid(false); - myTable.setIntercellSpacing(JBUI.emptySize()); - @NonNls final InputMap inputMap = myTable.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable"); - @NonNls final ActionMap actionMap = myTable.getActionMap(); - actionMap.put("enable_disable", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (myTable.isEditing()) return; - int[] rows = myTable.getSelectedRows(); - if (rows.length > 0) { - boolean valueToBeSet = false; - for (int row : rows) { - if (!myVariableData[row].passAsParameter) { - valueToBeSet = true; - break; - } - } - for (int row : rows) { - myVariableData[row].passAsParameter = valueToBeSet; - } - myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]); - TableUtil.selectRows(myTable, rows); - } - } - }); - // F2 should edit the name - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name"); - actionMap.put("edit_parameter_name", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (!myTable.isEditing()) { - int row = myTable.getSelectedRow(); - if (row >= 0 && row < myTableModel.getRowCount()) { - TableUtil.editCellAt(myTable, row, MyTableModel.PARAMETER_NAME_COLUMN); - } - } - } - }); - - JPanel listPanel = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel(); - add(listPanel, BorderLayout.CENTER); - - if (myVariableData.length > 1) { - myTable.getSelectionModel().setSelectionInterval(0, 0); - } - } - - @Override - public void setEnabled(boolean enabled) { - myTable.setEnabled(enabled); - super.setEnabled(enabled); - } - - public AbstractVariableData[] getVariableData() { - return myVariableData; - } - - private class MyTableModel extends AbstractTableModel implements EditableModel { - public static final int CHECKMARK_COLUMN = 0; - public static final int PARAMETER_NAME_COLUMN = 1; - - @Override - public int getRowCount() { - return myVariableData.length; - } - - @Override - public int getColumnCount() { - return 2; - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - return myVariableData[rowIndex].passAsParameter; - } - case PARAMETER_NAME_COLUMN: { - return myVariableData[rowIndex].name; - } - } - assert false; - return null; - } - - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - myVariableData[rowIndex].passAsParameter = ((Boolean)aValue).booleanValue(); - fireTableRowsUpdated(rowIndex, rowIndex); - myTable.getSelectionModel().setSelectionInterval(rowIndex, rowIndex); - updateSignature(); - break; - } - case PARAMETER_NAME_COLUMN: { - AbstractVariableData data = myVariableData[rowIndex]; - String name = (String)aValue; - if (myValidator.isValidName(name)) { - data.name = name; - } - updateSignature(); - break; - } - } - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: - return isEnabled(); - case PARAMETER_NAME_COLUMN: - return isEnabled() && myVariableData[rowIndex].passAsParameter; - default: - return false; - } - } - - @Override - public Class getColumnClass(int columnIndex) { - if (columnIndex == CHECKMARK_COLUMN) { - return Boolean.class; - } - return super.getColumnClass(columnIndex); - } - - @Override - public void addRow() { - throw new IllegalAccessError("Not implemented"); - } - - @Override - public void removeRow(int index) { - throw new IllegalAccessError("Not implemented"); - } - - @Override - public void exchangeRows(int row, int targetRow) { - if (row < 0 || row >= getVariableData().length) return; - if (targetRow < 0 || targetRow >= getVariableData().length) return; - - final AbstractVariableData currentItem = getVariableData()[row]; - getVariableData()[row] = getVariableData()[targetRow]; - getVariableData()[targetRow] = currentItem; - - myTableModel.fireTableRowsUpdated(Math.min(targetRow, row), Math.max(targetRow, row)); - myTable.getSelectionModel().setSelectionInterval(targetRow, targetRow); - updateSignature(); - } - - @Override - public boolean canExchangeRows(int row, int targetRow) { - if (row < 0 || row >= getVariableData().length) return false; - if (targetRow < 0 || targetRow >= getVariableData().length) return false; - return true; - } - } -} diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractVariableData.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractVariableData.java index e6346120a48c..31fb4cb9f51b 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractVariableData.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractVariableData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +16,23 @@ package com.intellij.refactoring.extractMethod; /** -* @author oleg +* Would be deleted during 2016.2 EAP! */ -public class AbstractVariableData { - public String originalName; - public String name; - public boolean passAsParameter; - - public String getName() { - return name; +@Deprecated +public class AbstractVariableData extends com.intellij.refactoring.util.AbstractVariableData { + public static AbstractVariableData copy(com.intellij.refactoring.util.AbstractVariableData data) { + final AbstractVariableData cdata = new AbstractVariableData(); + cdata.passAsParameter = data.passAsParameter; + cdata.name = data.name; + cdata.originalName = data.originalName; + return cdata; } - public String getOriginalName() { - return originalName; - } - - public boolean isPassAsParameter() { - return passAsParameter; + public static AbstractVariableData[] copy(com.intellij.refactoring.util.AbstractVariableData[] data) { + final AbstractVariableData[] cdata = new AbstractVariableData[data.length]; + for (int i = 0; i < data.length; i++) { + cdata[i] = copy(data[i]); + } + return cdata; } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDecorator.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDecorator.java index e4826ece5f72..9443fb44f0de 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDecorator.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDecorator.java @@ -15,9 +15,18 @@ */ package com.intellij.refactoring.extractMethod; +import com.intellij.refactoring.util.AbstractVariableData; + /** * @author oleg */ public interface ExtractMethodDecorator { - String createMethodPreview(String methodName, AbstractVariableData[] variableDatas); + default String createMethodSignature(String methodName, AbstractVariableData[] variableDatas) { + return createMethodPreview(methodName, com.intellij.refactoring.extractMethod.AbstractVariableData.copy(variableDatas)); + } + + @Deprecated + default String createMethodPreview(String methodName, com.intellij.refactoring.extractMethod.AbstractVariableData[] variableDatas) { + return null; + } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSettings.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSettings.java index 6a9dcc4d155b..d47533a00ed2 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSettings.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodSettings.java @@ -15,10 +15,17 @@ */ package com.intellij.refactoring.extractMethod; +import com.intellij.refactoring.util.AbstractVariableData; + /** * @author oleg */ public interface ExtractMethodSettings { String getMethodName(); - AbstractVariableData[] getVariableData(); + AbstractVariableData[] getAbstractVariableData(); + + @Deprecated + default com.intellij.refactoring.extractMethod.AbstractVariableData[] getVariableData() { + return com.intellij.refactoring.extractMethod.AbstractVariableData.copy(getAbstractVariableData()); + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java index 1a09a761986f..241daf23293f 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java @@ -8,6 +8,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiRecursiveElementWalkingVisitor; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.refactoring.util.AbstractVariableData; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,9 +28,18 @@ public class SimpleDuplicatesFinder { public static final Key PARAMETER = Key.create("PARAMETER"); private final Collection myOutputVariables; + @Deprecated public SimpleDuplicatesFinder(@NotNull final PsiElement statement1, @NotNull final PsiElement statement2, - AbstractVariableData[] variableData, Collection variables) { + com.intellij.refactoring.extractMethod.AbstractVariableData[] variableData, + Collection variables) { + this(statement1, statement2, variables, variableData); + } + + public SimpleDuplicatesFinder(@NotNull final PsiElement statement1, + @NotNull final PsiElement statement2, + Collection variables, + AbstractVariableData[] variableData) { myOutputVariables = variables; myParameters = new HashSet(); for (AbstractVariableData data : variableData) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesHelper.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesHelper.java index c354dddf5c15..30acd20da80e 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesHelper.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesHelper.java @@ -121,9 +121,9 @@ public abstract class MoveDirectoryWithClassesHelper { } private static class MyUsageInfo extends UsageInfo { - private final PsiFileSystemItem myFile; + private final @NotNull PsiFileSystemItem myFile; - public MyUsageInfo(@NotNull PsiReference reference, PsiFileSystemItem file) { + public MyUsageInfo(@NotNull PsiReference reference, @NotNull PsiFileSystemItem file) { super(reference); myFile = file; } diff --git a/platform/lang-impl/src/com/intellij/refactoring/util/AbstractParameterTablePanel.java b/platform/lang-impl/src/com/intellij/refactoring/util/AbstractParameterTablePanel.java new file mode 100644 index 000000000000..769046fe29a5 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/refactoring/util/AbstractParameterTablePanel.java @@ -0,0 +1,244 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.refactoring.util; + +import com.intellij.ui.BooleanTableCellRenderer; +import com.intellij.ui.TableUtil; +import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.table.JBTable; +import com.intellij.util.ui.ColumnInfo; +import com.intellij.util.ui.EditableModel; +import com.intellij.util.ui.ListTableModel; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.function.Predicate; + +public abstract class AbstractParameterTablePanel

extends JPanel { + private P[] myParameterData; + + protected final JBTable myTable; + private final MyTableModel myTableModel; + + public P[] getVariableData() { + return myParameterData; + } + + protected abstract void updateSignature(); + + protected abstract void doEnterAction(); + + protected abstract void doCancelAction(); + + protected boolean areTypesDirected() { + return true; + } + + public AbstractParameterTablePanel(P[] parameterData, + ColumnInfo... columnInfos) { + this(columnInfos); + init(parameterData); + } + + public AbstractParameterTablePanel(ColumnInfo... columnInfos) { + super(new BorderLayout()); + myTableModel = new MyTableModel(columnInfos); + myTable = new JBTable(myTableModel); + + for (int i = 0; i < columnInfos.length; i++) { + if (columnInfos[i] instanceof PassParameterColumnInfo) { + TableUtil.setupCheckboxColumn(myTable, i); + } + } + + DefaultCellEditor defaultEditor = (DefaultCellEditor)myTable.getDefaultEditor(Object.class); + defaultEditor.setClickCountToStart(1); + + + myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + myTable.setCellSelectionEnabled(true); + + myTable.setPreferredScrollableViewportSize(new Dimension(250, myTable.getRowHeight() * 5)); + myTable.setShowGrid(false); + myTable.setIntercellSpacing(new Dimension(0, 0)); + @NonNls final InputMap inputMap = myTable.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable"); + @NonNls final ActionMap actionMap = myTable.getActionMap(); + actionMap.put("enable_disable", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + if (myTable.isEditing()) return; + int[] rows = myTable.getSelectedRows(); + if (rows.length > 0) { + boolean valueToBeSet = false; + for (int row : rows) { + if (!getVariableData()[row].isPassAsParameter()) { + valueToBeSet = true; + break; + } + } + for (int row : rows) { + getVariableData()[row].passAsParameter = valueToBeSet; + } + myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]); + TableUtil.selectRows(myTable, rows); + } + } + }); + + // make ESCAPE work when the table has focus + actionMap.put("doCancel", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + TableCellEditor editor = myTable.getCellEditor(); + if (editor != null) { + editor.stopCellEditing(); + } + else { + doCancelAction(); + } + } + }); + + + JPanel listPanel = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel(); + add(listPanel, BorderLayout.CENTER); + + + myTableModel.addTableModelListener(e -> updateSignature()); + } + + public void init(P[] parameterData) { + myParameterData = parameterData; + myTableModel.setItems(Arrays.asList(parameterData)); + if (parameterData.length > 1) { + myTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + + public void setEnabled(boolean enabled) { + myTable.setEnabled(enabled); + super.setEnabled(enabled); + } + + public static class NameColumnInfo extends ColumnInfo { + private final Predicate myNameValidator; + + public NameColumnInfo(Predicate nameValidator) { + super("Name"); + myNameValidator = nameValidator; + } + + @Nullable + @Override + public String valueOf(AbstractVariableData data) { + return data.getName(); + } + + @Override + public void setValue(AbstractVariableData data, String value) { + if (myNameValidator.test(value)) { + data.name = value; + } + } + + @Override + public boolean isCellEditable(AbstractVariableData data) { + return true; + } + } + + public static class PassParameterColumnInfo extends ColumnInfo { + public PassParameterColumnInfo() { + super(""); + } + + @Nullable + @Override + public TableCellRenderer getRenderer(AbstractVariableData data) { + return new BooleanTableCellRenderer(); + } + + @Nullable + @Override + public Boolean valueOf(AbstractVariableData data) { + return data.isPassAsParameter(); + } + + @Override + public void setValue(AbstractVariableData data, Boolean value) { + data.passAsParameter = value; + } + + @Override + public boolean isCellEditable(AbstractVariableData data) { + return true; + } + + @Override + public Class getColumnClass() { + return Boolean.class; + } + } + + private class MyTableModel extends ListTableModel implements EditableModel { + public MyTableModel(@NotNull ColumnInfo... columnInfos) { + super(columnInfos); + } + + @Override + public void addRow() { + throw new IllegalAccessError("Not implemented"); + } + + @Override + public void removeRow(int index) { + throw new IllegalAccessError("Not implemented"); + } + + @Override + public void exchangeRows(int row, int targetRow) { + if (row < 0 || row >= getVariableData().length) return; + if (targetRow < 0 || targetRow >= getVariableData().length) return; + + final P currentItem = getVariableData()[row]; + AbstractParameterTablePanel.this.exchangeRows(row, targetRow, currentItem); + + myTableModel.fireTableRowsUpdated(Math.min(targetRow, row), Math.max(targetRow, row)); + myTable.getSelectionModel().setSelectionInterval(targetRow, targetRow); + updateSignature(); + } + + @Override + public boolean canExchangeRows(int row, int targetRow) { + if (row < 0 || row >= getVariableData().length) return false; + if (targetRow < 0 || targetRow >= getVariableData().length) return false; + return true; + } + } + + protected void exchangeRows(int row, int targetRow, P currentItem) { + getVariableData()[row] = getVariableData()[targetRow]; + getVariableData()[targetRow] = currentItem; + } +} diff --git a/platform/lang-impl/src/com/intellij/refactoring/util/SimpleParameterTablePanel.java b/platform/lang-impl/src/com/intellij/refactoring/util/SimpleParameterTablePanel.java new file mode 100644 index 000000000000..083b3be6d917 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/refactoring/util/SimpleParameterTablePanel.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.refactoring.util; + +import java.util.function.Predicate; + +public abstract class SimpleParameterTablePanel extends AbstractParameterTablePanel { + public SimpleParameterTablePanel(Predicate parameterNameValidator) { + super(new PassParameterColumnInfo(), new NameColumnInfo(parameterNameValidator)); + } +} diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index cb08da424c04..321e532de859 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -261,7 +261,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override - public void writeActionStarted(Object action) { + public void writeActionStarted(@NotNull Object action) { myUpToDateIndicesForUnsavedOrTransactedDocuments.clear(); } }); @@ -388,7 +388,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { } state.registerIndex(name, - createIndex(extension, new MemoryIndexStorage(storage)), + createIndex(extension, new MemoryIndexStorage(storage, name)), new FileBasedIndex.InputFilter() { @Override @@ -1791,8 +1791,8 @@ public class FileBasedIndexImpl extends FileBasedIndex { clearUpToDateStateForPsiIndicesOfUnsavedDocuments(file); - // the file is for sure not a dir and it was previously indexed by at least one index AND it belongs to some update set - if (!isTooLarge(file) && getIndexableSetForFile(file) != null) myChangedFilesCollector.scheduleForUpdate(file); + // the file is for sure not a dir and it was previously indexed by at least one index + if (!isTooLarge(file)) myChangedFilesCollector.scheduleForUpdate(file); } } else if (!fileIndexedStatesToUpdate.isEmpty()) { // file was removed, its data should be (lazily) wiped for every index @@ -1854,10 +1854,10 @@ public class FileBasedIndexImpl extends FileBasedIndex { } } - if (scheduleForUpdate) { - if (resetStamp) IndexingStamp.flushCache(fileId); - myChangedFilesCollector.scheduleForUpdate(file); - } + if (scheduleForUpdate) { + if (resetStamp) IndexingStamp.flushCache(fileId); + myChangedFilesCollector.scheduleForUpdate(file); + } if (!myUpToDateIndicesForUnsavedOrTransactedDocuments.isEmpty()) { clearUpToDateStateForPsiIndicesOfUnsavedDocuments(file); @@ -1922,6 +1922,12 @@ public class FileBasedIndexImpl extends FileBasedIndex { } void scheduleForUpdate(VirtualFile file) { + if (!(file instanceof DeletedVirtualFileStub)) { + IndexableFileSet setForFile = getIndexableSetForFile(file); + if (setForFile == null) { + return; + } + } final int fileId = Math.abs(getIdMaskingNonIdBasedFile(file)); final VirtualFile previousVirtualFile = myFilesToUpdate.put(fileId, file); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java index d3a7ca988288..436802bccbc6 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java @@ -76,6 +76,14 @@ public class MapReduceIndex implements UpdatableIndex)myStorage).clearCaches(); + } finally { + getWriteLock().unlock(); + } + } flush(); } catch (StorageException e) { LOG.info(e); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MemoryIndexStorage.java b/platform/lang-impl/src/com/intellij/util/indexing/MemoryIndexStorage.java index 6055feb67a0a..8b8503bf1765 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/MemoryIndexStorage.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/MemoryIndexStorage.java @@ -36,6 +36,7 @@ public class MemoryIndexStorage implements IndexStorage @NotNull private final IndexStorage myBackendStorage; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); + private final ID myIndexId; private boolean myBufferingEnabled; public interface BufferingStateListener { @@ -45,7 +46,12 @@ public class MemoryIndexStorage implements IndexStorage } public MemoryIndexStorage(@NotNull IndexStorage backend) { + this(backend, null); + } + + public MemoryIndexStorage(@NotNull IndexStorage backend, ID indexId) { myBackendStorage = backend; + myIndexId = indexId; } @NotNull @@ -85,6 +91,16 @@ public class MemoryIndexStorage implements IndexStorage } } + void clearCaches() { + if (myMap.size() == 0) return; + String message = "Dropping caches for " + (myIndexId != null ? myIndexId:this) + ", number of items:" + myMap.size(); + FileBasedIndexImpl.LOG.info(message); + + for(ChangeTrackingValueContainer v:myMap.values()) { + v.dropMergedData(); + } + } + @Override public void close() throws StorageException { myBackendStorage.close(); diff --git a/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExcludeTreeNodeAction.java b/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExcludeTreeNodeAction.java new file mode 100644 index 000000000000..119252c24241 --- /dev/null +++ b/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExcludeTreeNodeAction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.actions.exclusion; + +import javax.swing.tree.MutableTreeNode; + +/** + * @author Dmitry Batkovich + */ +public final class ExcludeTreeNodeAction extends TreeNodeExclusionAction { + public ExcludeTreeNodeAction() { + super(true); + } +} diff --git a/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExclusionHandler.java b/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExclusionHandler.java new file mode 100644 index 000000000000..2c3ea411ed53 --- /dev/null +++ b/platform/platform-api/src/com/intellij/ide/actions/exclusion/ExclusionHandler.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.actions.exclusion; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.DataKey; +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.MutableTreeNode; + +/** + * @author Dmitry Batkovich + */ +public interface ExclusionHandler extends Disposable { + DataKey EXCLUSION_HANDLER = DataKey.create("tree.exclusion.handler"); + + boolean isNodeExcluded(@NotNull T node); + + void excludeNode(@NotNull T node); + + void includeNode(@NotNull T node); + + boolean isActionEnabled(boolean isExcludeAction); + + void onDone(boolean isExcludeAction); +} diff --git a/platform/platform-api/src/com/intellij/ide/actions/exclusion/IncludeTreeNodeAction.java b/platform/platform-api/src/com/intellij/ide/actions/exclusion/IncludeTreeNodeAction.java new file mode 100644 index 000000000000..b700840faecf --- /dev/null +++ b/platform/platform-api/src/com/intellij/ide/actions/exclusion/IncludeTreeNodeAction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.actions.exclusion; + +import javax.swing.tree.MutableTreeNode; + +/** + * @author Dmitry Batkovich + */ +public final class IncludeTreeNodeAction extends TreeNodeExclusionAction { + public IncludeTreeNodeAction() { + super(false); + } +} diff --git a/platform/platform-api/src/com/intellij/ide/actions/exclusion/TreeNodeExclusionAction.java b/platform/platform-api/src/com/intellij/ide/actions/exclusion/TreeNodeExclusionAction.java new file mode 100644 index 000000000000..a60ddfdb9269 --- /dev/null +++ b/platform/platform-api/src/com/intellij/ide/actions/exclusion/TreeNodeExclusionAction.java @@ -0,0 +1,102 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.actions.exclusion; + +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Disposer; + +import javax.swing.*; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.TreePath; +import java.awt.*; + +/** + * @author Dmitry Batkovich. + */ +class TreeNodeExclusionAction extends AnAction { + private final static Logger LOG = Logger.getInstance(TreeNodeExclusionAction.class); + + private final boolean myIsExclude; + + TreeNodeExclusionAction(boolean isExclude) { + myIsExclude = isExclude; + getTemplatePresentation().setText(getActionText()); + } + + @Override + public void update(AnActionEvent e) { + final ExclusionHandler exclusionProcessor = ExclusionHandler.EXCLUSION_HANDLER.getData(e.getDataContext()); + if (exclusionProcessor == null || Disposer.isDisposed(exclusionProcessor)) { + e.getPresentation().setEnabledAndVisible(false); + return; + } + final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext()); + final Presentation presentation = e.getPresentation(); + if (!(component instanceof JTree) || !exclusionProcessor.isActionEnabled(myIsExclude)) { + presentation.setEnabledAndVisible(false); + return; + } + JTree tree = (JTree) component; + final TreePath[] selection = tree.getSelectionPaths(); + if (selection == null) { + presentation.setEnabledAndVisible(false); + return; + } + boolean isEnabled = false; + for (TreePath path : selection) { + final T node = (T)path.getLastPathComponent(); + final Boolean isNodeExcluded = exclusionProcessor.isNodeExcluded(node); + if (myIsExclude != isNodeExcluded) { + isEnabled = true; + break; + } + } + presentation.setEnabledAndVisible(isEnabled); + if (isEnabled) { + String text = getActionText(); + if (selection.length > 1) { + text += " All"; + } + presentation.setText(text); + } + } + + @Override + public void actionPerformed(AnActionEvent e) { + final JTree tree = (JTree)PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext()); + LOG.assertTrue(tree != null); + final TreePath[] paths = tree.getSelectionPaths(); + LOG.assertTrue(paths != null); + final ExclusionHandler exclusionProcessor = ExclusionHandler.EXCLUSION_HANDLER.getData(e.getDataContext()); + LOG.assertTrue(exclusionProcessor != null); + for (TreePath path : paths) { + final T node = (T)path.getLastPathComponent(); + if (Boolean.valueOf(myIsExclude) != exclusionProcessor.isNodeExcluded(node)) { + if (myIsExclude) { + exclusionProcessor.excludeNode(node); + } else { + exclusionProcessor.includeNode(node); + } + } + } + exclusionProcessor.onDone(myIsExclude); + } + + private String getActionText() { + return myIsExclude ? "Exclude" : "Include"; + } +} diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java index 3cb240e070ca..4d427ed51591 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java @@ -326,4 +326,6 @@ public interface IdeActions { String ACTION_MARK_ALL_NOTIFICATIONS_AS_READ = "MarkNotificationsAsRead"; String ACTION_SWITCHER = "Switcher"; + + @NonNls String INSPECTION_TOOL_WINDOW_TREE_POPUP = "InspectionToolWindow.TreePopup"; } diff --git a/platform/platform-api/src/com/intellij/util/Alarm.java b/platform/platform-api/src/com/intellij/util/Alarm.java index 0df57002c02d..a67e23244650 100644 --- a/platform/platform-api/src/com/intellij/util/Alarm.java +++ b/platform/platform-api/src/com/intellij/util/Alarm.java @@ -427,10 +427,11 @@ public class Alarm implements Disposable { @Override public String toString() { + Runnable task; synchronized (LOCK) { - Runnable task = myTask; - return super.toString() + (task != null ? ": "+task : ""); + task = myTask; } + return super.toString() + (task != null ? ": "+task : ""); } } diff --git a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateManager.java b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateManager.java index 32f37e24c797..de7ac7d1b5e0 100644 --- a/platform/platform-api/src/com/intellij/util/net/ssl/CertificateManager.java +++ b/platform/platform-api/src/com/intellij/util/net/ssl/CertificateManager.java @@ -131,10 +131,7 @@ public class CertificateManager implements PersistentStateComponent notifications) { + return createIconWithNotificationCount(this, getMaximumType(notifications), notifications.size()); + } + + @NotNull + public static LayeredIcon createIconWithNotificationCount(JComponent component, NotificationType type, int size) { LayeredIcon icon = new LayeredIcon(2); - NotificationType type = getMaximumType(notifications); - Icon statusIcon = getPendingNotificationsIcon(AllIcons.Ide.Notification.NoEvents, type); - icon.setIcon(statusIcon, 0); - int size = notifications.size(); + icon.setIcon(getPendingNotificationsIcon(AllIcons.Ide.Notification.NoEvents, type), 0); if (size > 0) { //noinspection UseJBColor - Color textColor = type == NotificationType.ERROR ? Color.white : Color.black; - icon.setIcon(new TextIcon(this, size < 10 ? String.valueOf(size) : "9+", textColor), 1); + Color textColor = type == NotificationType.ERROR ? new JBColor(Color.white, new Color(0xF2F2F2)) : new Color(0x333333); + icon.setIcon(new TextIcon(component, size < 10 ? String.valueOf(size) : "9+", textColor), 1); } return icon; } @@ -181,12 +185,14 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget private final JComponent myComponent; private final Color myTextColor; private final int myWidth; + private final Font myFont; public TextIcon(JComponent component, @NotNull String str, @NotNull Color textColor) { myStr = str; myComponent = component; myTextColor = textColor; - myWidth = myComponent.getFontMetrics(calcFont()).stringWidth(myStr); + myFont = new Font(NotificationsUtil.getFontName(), Font.BOLD, 9); + myWidth = myComponent.getFontMetrics(myFont).stringWidth(myStr); } @Override @@ -217,13 +223,10 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget Font originalFont = g.getFont(); Color originalColor = g.getColor(); - g.setFont(calcFont()); + g.setFont(myFont); x += (getIconWidth() - myWidth) / 2; - y += getIconHeight() / 2 + g.getFontMetrics().getDescent(); - if (!SystemInfo.isLinux && myStr.length() > 1) { - x++; - } + y += SimpleColoredComponent.getTextBaseLine(g.getFontMetrics(), getIconHeight()); g.setColor(myTextColor); g.drawString(myStr, x, y); @@ -232,14 +235,6 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget g.setColor(originalColor); } - private Font calcFont() { - float size = (float)getIconHeight() * 3 / 5; - if (myStr.length() > 1) { - size--; - } - return myComponent.getFont().deriveFont(size); - } - @Override public int getIconWidth() { return AllIcons.Ide.Notification.NoEvents.getIconWidth(); diff --git a/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java b/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java index 5a44d0a1a731..95fae4f3f789 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java @@ -175,6 +175,9 @@ public class NotificationTestAction extends AnAction implements DumbAware { notification.setActions(StringUtil.split(value, ",")); } } + else if (line.startsWith("Type:")) { + notification.setType(StringUtil.substringAfter(line, ":")); + } else if (line.startsWith("Sticky:")) { notification.setSticky("true".equals(StringUtil.substringAfter(line, ":"))); } @@ -200,6 +203,7 @@ public class NotificationTestAction extends AnAction implements DumbAware { private String mySubtitle; private List myContent; private List myActions; + private NotificationType myType = NotificationType.INFORMATION; private boolean mySticky; private boolean myAddListener; @@ -218,10 +222,10 @@ public class NotificationTestAction extends AnAction implements DumbAware { String content = myContent == null ? "" : StringUtil.join(myContent, "\n"); if (icon == null) { myNotification = - new Notification(displayId, StringUtil.notNullize(myTitle), content, NotificationType.INFORMATION, getListener()); + new Notification(displayId, StringUtil.notNullize(myTitle), content, myType, getListener()); } else { - myNotification = new Notification(displayId, icon, myTitle, mySubtitle, content, NotificationType.INFORMATION, getListener()); + myNotification = new Notification(displayId, icon, myTitle, mySubtitle, content, myType, getListener()); if (myActions != null) { for (String action : myActions) { myNotification.addAction(new MyAnAction(action)); @@ -268,6 +272,18 @@ public class NotificationTestAction extends AnAction implements DumbAware { mySticky = sticky; } + public void setType(@Nullable String type) { + if ("info".equals(type)) { + myType = NotificationType.INFORMATION; + } + else if ("error".equals(type)) { + myType = NotificationType.ERROR; + } + else if ("warn".equals(type)) { + myType = NotificationType.WARNING; + } + } + @Override public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { if (MessageDialogBuilder.yesNo("Notification Listener", event.getDescription() + " Expire?").is()) { diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java index 1a3f8698f3ce..ad2a40882e31 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java @@ -124,18 +124,18 @@ public class NotificationsUtil { @Nullable public static String getFontStyle() { - String fontName = null; + String fontName = getFontName(); + return StringUtil.isEmpty(fontName) ? null : "font-family:" + fontName + ";"; + } + + @Nullable + public static String getFontName() { UISettings uiSettings = UISettings.getInstance(); if (uiSettings.OVERRIDE_NONIDEA_LAF_FONTS) { - fontName = uiSettings.FONT_FACE; + return uiSettings.FONT_FACE; } - else { - Pair systemFontData = UIUtil.getSystemFontData(); - if (systemFontData != null) { - fontName = systemFontData.first; - } - } - return StringUtil.isEmpty(fontName) ? null : "font-family:" + fontName + ";"; + Pair systemFontData = UIUtil.getSystemFontData(); + return systemFontData == null ? null : systemFontData.first; } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java index 2b42a7297f65..12a81b8df6d4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenu.java @@ -359,6 +359,10 @@ public final class ActionMenu extends JMenu { private SingleAlarm myCallbackAlarm; private MouseEvent myEventToRedispatch; + private long myLastEventTime = 0L; + private boolean myInBounds = false; + private SingleAlarm myCheckAlarm; + private UsabilityHelper(Component component) { myCallbackAlarm = new SingleAlarm(new Runnable() { @Override @@ -370,6 +374,17 @@ public final class ActionMenu extends JMenu { } } }, 50, this); + myCheckAlarm = new SingleAlarm(new Runnable() { + @Override + public void run() { + if (myLastEventTime > 0 && System.currentTimeMillis() - myLastEventTime > 1500) { + if (!myInBounds && myCallbackAlarm != null && !myCallbackAlarm.isDisposed()) { + myCallbackAlarm.request(); + } + } + myCheckAlarm.request(); + } + }, 100, this); myComponent = component; PointerInfo info = MouseInfo.getPointerInfo(); myLastMousePoint = info != null ? info.getLocation() : null; @@ -410,17 +425,19 @@ public final class ActionMenu extends JMenu { Point point = ((MouseEvent)e).getLocationOnScreen(); Rectangle bounds = myComponent.getBounds(); bounds.setLocation(myComponent.getLocationOnScreen()); - - myCallbackAlarm.cancel(); - boolean isMouseMovingTowardsSubmenu = bounds.contains(point) || new Polygon( + myInBounds = bounds.contains(point); + boolean isMouseMovingTowardsSubmenu = myInBounds || new Polygon( new int[]{myLastMousePoint.x, myUpperTargetPoint.x, myLowerTargetPoint.x}, new int[]{myLastMousePoint.y, myUpperTargetPoint.y, myLowerTargetPoint.y}, 3).contains(point); myEventToRedispatch = (MouseEvent)e; + myLastEventTime = System.currentTimeMillis(); if (!isMouseMovingTowardsSubmenu) { myCallbackAlarm.request(); + } else { + myCallbackAlarm.cancel(); } myLastMousePoint = point; return true; diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 18c7c8e30a69..71a6370004f0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -557,7 +557,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App final JComponent parentComponent, final String cancelText) { assertIsDispatchThread(); - boolean writeAccessAllowed = isInsideWriteActionEDTOnly(); + boolean writeAccessAllowed = isWriteAccessAllowed(); if (writeAccessAllowed // Disallow running process in separate thread from under write action. // The thread will deadlock trying to get read action otherwise. || isHeadlessEnvironment() && !isUnitTestMode() @@ -614,7 +614,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App final String cancelText, final JComponent parentComponent, @NotNull final Runnable process) { assertIsDispatchThread(); - boolean writeAccessAllowed = isInsideWriteActionEDTOnly(); + boolean writeAccessAllowed = isWriteAccessAllowed(); if (writeAccessAllowed // Disallow running process in separate thread from under write action. // The thread will deadlock trying to get read action otherwise. ) { @@ -965,12 +965,12 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App } @Override - public boolean hasWriteAction(@Nullable Class actionClass) { + public boolean hasWriteAction(@NotNull Class actionClass) { assertIsDispatchThread(); for (int i = myWriteActionsStack.size() - 1; i >= 0; i--) { Class action = myWriteActionsStack.get(i); - if (actionClass == action || action != null && actionClass != null && ReflectionUtil.isAssignable(actionClass, action)) return true; + if (actionClass == action || ReflectionUtil.isAssignable(actionClass, action)) return true; } return false; } @@ -1102,7 +1102,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App private final boolean gatherWriteActionStatistics; private final PausesStat writePauses; - private void startWrite(/*@NotNull*/ Class clazz) { + private void startWrite(@NotNull Class clazz) { assertIsDispatchThread("Write access is allowed from event dispatch thread only"); HeavyProcessLatch.INSTANCE.stopThreadPrioritizing(); // let non-cancellable read actions complete faster, if present if (!isDisposed() && !isDisposeInProgress() && !((TransactionGuardImpl)TransactionGuard.getInstance()).isWriteActionAllowed()) { @@ -1141,7 +1141,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App fireWriteActionStarted(clazz); } - private void endWrite(/*@NotNull*/ Class clazz) { + private void endWrite(@NotNull Class clazz) { try { fireWriteActionFinished(clazz); // fire listeners before popping stack because if somebody starts write action in a listener, @@ -1160,17 +1160,14 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App @NotNull @Override - public AccessToken acquireWriteActionLock(/*@NotNull */Class clazz) { - if (clazz == null) { - LOG.warn("Parameter must be not null", new Throwable()); - } + public AccessToken acquireWriteActionLock(@NotNull Class clazz) { return new WriteAccessToken(clazz); } private class WriteAccessToken extends AccessToken { - private final Class clazz; + @NotNull private final Class clazz; - public WriteAccessToken(/*@NotNull*/ Class clazz) { + public WriteAccessToken(@NotNull Class clazz) { this.clazz = clazz; startWrite(clazz); markThreadNameInStackTrace(); @@ -1253,11 +1250,6 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App return isDispatchThread() && myLock.isWriteLocked(); } - // cheaper version of isWriteAccessAllowed(). must be called from EDT - private boolean isInsideWriteActionEDTOnly() { - return !myWriteActionsStack.isEmpty(); - } - @Override public boolean isWriteActionInProgress() { return myLock.isWriteLocked(); @@ -1291,15 +1283,15 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App myDispatcher.getMulticaster().applicationExiting(); } - private void fireBeforeWriteActionStart(Class action) { + private void fireBeforeWriteActionStart(@NotNull Class action) { myDispatcher.getMulticaster().beforeWriteActionStart(action); } - private void fireWriteActionStarted(Class action) { + private void fireWriteActionStarted(@NotNull Class action) { myDispatcher.getMulticaster().writeActionStarted(action); } - private void fireWriteActionFinished(Class action) { + private void fireWriteActionFinished(@NotNull Class action) { myDispatcher.getMulticaster().writeActionFinished(action); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index b355a31e636e..529699f4b361 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1080,7 +1080,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi * @param fontSize new font size * @param zoomCenter zoom point, relative to viewport */ - private void setFontSize(final int fontSize, @Nullable Point zoomCenter) { + private void setFontSize(int fontSize, @Nullable Point zoomCenter) { int oldFontSize = myScheme.getEditorFontSize(); Rectangle visibleArea = myScrollingModel.getVisibleArea(); @@ -1091,6 +1091,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi int intraLineOffset = zoomCenterAbsolute.y % oldLineHeight; myScheme.setEditorFontSize(fontSize); + fontSize = myScheme.getEditorFontSize(); // resulting font size might be different due to applied min/max limits myPropertyChangeSupport.firePropertyChange(PROP_FONT_SIZE, oldFontSize, fontSize); // Update vertical scroll bar bounds if necessary (we had a problem that use increased editor font size and it was not possible // to scroll to the bottom of the document). diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutFilteringPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutFilteringPanel.java index 96e4979bbe19..f00cffce4f55 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutFilteringPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutFilteringPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.openapi.keymap.impl.ui; import com.intellij.icons.AllIcons; +import com.intellij.ide.IdeEventQueue; import com.intellij.openapi.actionSystem.KeyboardShortcut; import com.intellij.openapi.actionSystem.MouseShortcut; import com.intellij.openapi.actionSystem.Shortcut; @@ -26,14 +27,13 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.ui.components.panels.VerticalLayout; import com.intellij.util.ui.JBUI; -import java.awt.BorderLayout; -import java.awt.Component; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import javax.swing.JLabel; -import javax.swing.JPanel; +import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; /** * @author Sergey.Malenkov @@ -146,6 +146,20 @@ final class ShortcutFilteringPanel extends JPanel { .setCancelKeyEnabled(false) .setMovable(true) .createPopup(); + IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() { + boolean isEscWasPressed = false; + @Override + public boolean dispatch(AWTEvent e) { + if (e instanceof KeyEvent && e.getID() == KeyEvent.KEY_PRESSED) { + boolean isEsc = ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ESCAPE; + if (isEscWasPressed && isEsc) { + myPopup.cancel(); + } + isEscWasPressed = isEsc; + } + return false; + } + }, myPopup); } myPopup.showUnderneathOf(component); } diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutTextField.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutTextField.java index faf1dbc7e431..4c1ff440dca3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutTextField.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ShortcutTextField.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,14 +56,13 @@ public final class ShortcutTextField extends JTextField { protected void processKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { int keyCode = e.getKeyCode(); - if ( - keyCode == KeyEvent.VK_SHIFT || - keyCode == KeyEvent.VK_ALT || - keyCode == KeyEvent.VK_CONTROL || - keyCode == KeyEvent.VK_ALT_GRAPH || - keyCode == KeyEvent.VK_META || - absolutelyUnknownKey(e) - ){ + + if (keyCode == KeyEvent.VK_SHIFT || + keyCode == KeyEvent.VK_ALT || + keyCode == KeyEvent.VK_CONTROL || + keyCode == KeyEvent.VK_ALT_GRAPH || + keyCode == KeyEvent.VK_META || + absolutelyUnknownKey(e)) { return; } setKeyStroke(KeyStrokeAdapter.getDefaultKeyStroke(e)); diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java index 139de38b1af7..7287555569af 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java @@ -49,7 +49,7 @@ public class ProgressIndicatorUtils { public static ProgressIndicator forceWriteActionPriority(@NotNull final ProgressIndicator progress, @NotNull final Disposable builder) { ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { if (progress.isRunning()) { progress.cancel(); } @@ -114,7 +114,7 @@ public class ProgressIndicatorUtils { final ApplicationAdapter listener = new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { if (!progressIndicator.isCanceled()) progressIndicator.cancel(); } }; @@ -162,7 +162,7 @@ public class ProgressIndicatorUtils { if (application.isDisposed()) return; final ApplicationAdapter listener = new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { if (!progressIndicator.isCanceled()) { progressIndicator.cancel(); readTask.onCanceled(progressIndicator); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java index aef3eeb9bc44..9004e5113471 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java @@ -105,7 +105,7 @@ public class CacheUpdateRunner { }; final ApplicationAdapter canceller = new ApplicationAdapter() { @Override - public void beforeWriteActionStart(Object action) { + public void beforeWriteActionStart(@NotNull Object action) { innerIndicator.cancel(); } }; diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java index 9d21e6b3e176..e80117e0b1eb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public class VfsData { static { ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() { @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { // after top-level write action is finished, all the deletion listeners should have processed the deleted files // and their data is considered safe to remove. From this point on accessing a removed file will result in an exception. if (!ApplicationManager.getApplication().isWriteAccessAllowed()) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java index 63287d96a8dc..c579afd0d46c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java @@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl; import com.intellij.ide.UiActivity; import com.intellij.ide.UiActivityMonitor; import com.intellij.ide.impl.ContentManagerWatcher; +import com.intellij.notification.EventLog; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.application.ApplicationManager; @@ -393,8 +394,10 @@ public final class ToolWindowImpl implements ToolWindowEx { public final void setIcon(final Icon icon) { ApplicationManager.getApplication().assertIsDispatchThread(); final Icon oldIcon = getIcon(); - if (oldIcon != icon && icon != null && !(icon instanceof LayeredIcon) && (icon.getIconHeight() != JBUI.scale(13) || icon.getIconWidth() != JBUI.scale(13))) { - LOG.warn("ToolWindow icons should be 13x13. Please fix ToolWindow (ID: " + getId() + ") or icon " + icon); + if (!EventLog.LOG_TOOL_WINDOW_ID.equals(getId())) { + if (oldIcon != icon && icon != null && !(icon instanceof LayeredIcon) && (icon.getIconHeight() != JBUI.scale(13) || icon.getIconWidth() != JBUI.scale(13))) { + LOG.warn("ToolWindow icons should be 13x13. Please fix ToolWindow (ID: " + getId() + ") or icon " + icon); + } } //getSelectedContent().setIcon(icon); myIcon = icon; diff --git a/platform/platform-impl/src/com/intellij/ui/Splash.java b/platform/platform-impl/src/com/intellij/ui/Splash.java index 2df4853d4b5f..f4cca64aa7b5 100644 --- a/platform/platform-impl/src/com/intellij/ui/Splash.java +++ b/platform/platform-impl/src/com/intellij/ui/Splash.java @@ -185,7 +185,7 @@ public class Splash extends JDialog implements StartupProgress { if (Registry.is("ide.new.about")) { ApplicationInfo info = getAppInfo(); if (info instanceof ApplicationInfoImpl) { - offsetX = Math.max(offsetX, ((ApplicationInfoImpl)info).getProgressX()); + offsetX = Math.max(offsetX, uiScale(((ApplicationInfoImpl)info).getProgressX())); offsetY = ((ApplicationInfoImpl)info).getLicenseOffsetY(); } else { return false; diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index f4343273e879..7e617bd06883 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -656,8 +656,6 @@ parsing.inspections.dump.progress.title=Parsing inspections XML dump suppress.inspection.problem=Suppress inspections.view.options.title=Inspection {0} options -inspections.result.view.exclude.action.text=Exclude -inspections.result.view.include.action.text=Include xml.suppressable.for.tag.title=Suppress for tag xml.suppressable.for.file.title=Suppress for file xml.suppressable.all.for.file.title=Suppress all for file @@ -712,5 +710,3 @@ todo.comment.problem.descriptor=TODO comment #ref #loc long.line.display.name=Line is longer than allowed by code style inspection.default.annotation.param=Default annotation parameter value -inspection.tool.window.stripe.title.single.content=Inspection Results of -inspection.tool.window.stripe.title.multiple.content=Inspection Results diff --git a/platform/platform-resources-en/src/messages/UIBundle.properties b/platform/platform-resources-en/src/messages/UIBundle.properties index 73a3770f0b8e..013a21d00003 100644 --- a/platform/platform-resources-en/src/messages/UIBundle.properties +++ b/platform/platform-resources-en/src/messages/UIBundle.properties @@ -51,7 +51,7 @@ tool.window.name.run=Run tool.window.name.find=Find tool.window.name.cvs=CVS tool.window.name.hierarchy=Hierarchy -tool.window.name.inspection=Inspection +tool.window.name.inspection=Inspection Results tool.window.name.todo=TODO tool.window.name.dependency.viewer=Dependency Viewer tool.window.name.version.control=Version Control diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 780094342e27..c332d188420b 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -988,5 +988,26 @@ + + + + + > + + + + + + + + + + + + + + + + diff --git a/platform/platform-tests/testSrc/com/intellij/execution/PtyCommandLineTest.java b/platform/platform-tests/testSrc/com/intellij/execution/PtyCommandLineTest.java index cfcbbb27f61c..d3cb2bc5ae0c 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/PtyCommandLineTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/PtyCommandLineTest.java @@ -36,29 +36,4 @@ public class PtyCommandLineTest extends GeneralCommandLineTest { return cmd; } - - @Override - public void unicodePath() { - assumeFalse(SystemInfo.isWindows); - } - - @Override - public void unicodeClassPath() { - assumeFalse(SystemInfo.isWindows); - } - - @Override - public void passingArgumentsToJavaApp() { - assumeFalse(SystemInfo.isWindows); - } - - @Override - public void passingArgumentsToJavaAppThroughWinShell() { - assumeFalse(SystemInfo.isWindows); - } - - @Override - public void passingArgumentsToJavaAppThroughCmdScriptAndWinShell() { - assumeFalse(SystemInfo.isWindows); - } } \ No newline at end of file diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/VariablesHost.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/VariablesHost.java index a0f189409166..746016d690cf 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/VariablesHost.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/VariablesHost.java @@ -34,7 +34,7 @@ public abstract class VariablesHost { @NotNull @Override - public Promise> load(@NotNull VariablesHost host) { + public Promise load(@NotNull VariablesHost host) { return host.valueManager.isObsolete() ? ValueManager.Companion.reject() : host.load(); } }; diff --git a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java index 7c56b4a0a9f4..c7d756a39ca5 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java @@ -207,6 +207,7 @@ public class UsagePreviewPanel extends UsageContextPanelBase { settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(0); settings.setVirtualSpace(true); + settings.setAnimatedScrolling(false); } @Override diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 456a0ac0d5c0..b65c9d5ef958 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -24,6 +24,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; import com.intellij.util.text.CharSequenceSubSequence; import com.intellij.util.text.StringFactory; +import org.jdom.Verifier; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -579,6 +580,16 @@ public class StringUtil extends StringUtilRt { @Nullable String additionalChars, boolean escapeSlash, @NotNull @NonNls StringBuilder buffer) { + return escapeStringCharacters(length, str, additionalChars, escapeSlash, true, buffer); + } + + @NotNull + public static StringBuilder escapeStringCharacters(int length, + @NotNull String str, + @Nullable String additionalChars, + boolean escapeSlash, + boolean escapeUnicode, + @NotNull @NonNls StringBuilder buffer) { char prev = 0; for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); @@ -610,7 +621,7 @@ public class StringUtil extends StringUtilRt { else if (additionalChars != null && additionalChars.indexOf(ch) > -1 && (escapeSlash || prev != '\\')) { buffer.append("\\").append(ch); } - else if (!isPrintableUnicode(ch)) { + else if (escapeUnicode && !isPrintableUnicode(ch)) { CharSequence hexCode = StringUtilRt.toUpperCase(Integer.toHexString(ch)); buffer.append("\\u"); int paddingCount = 4 - hexCode.length(); @@ -2184,6 +2195,66 @@ public class StringUtil extends StringUtilRt { } } + /** + * Some characters are illegal in XML even as numerical character references. This method performs escaping of them + * in a custom format, which is supposed to be unescaped on retrieving from XML using {@link #unescapeIllegalXmlChars(String)}. + * Resulting text can be part of XML version 1.0 document. + * + * @see https://www.w3.org/International/questions/qa-controls + * @see Verifier#isXMLCharacter(int) + */ + @NotNull + public static String escapeIllegalXmlChars(@NotNull String text) { + StringBuilder b = null; + int lastPos = 0; + for (int i = 0; i < text.length(); i++) { + int c = text.codePointAt(i); + if (Character.isSupplementaryCodePoint(c)) { + //noinspection AssignmentToForLoopParameter + i++; + } + if (c == '#' || !Verifier.isXMLCharacter(c)) { + if (b == null) b = new StringBuilder(text.length() + 5); // assuming there's one 'large' char (e.g. 0xFFFF) to escape numerically + b.append(text, lastPos, i).append('#'); + if (c != '#') b.append(Integer.toHexString(c)); + b.append('#'); + lastPos = i + 1; + } + } + return b == null ? text : b.append(text, lastPos, text.length()).toString(); + } + + /** + * @see #escapeIllegalXmlChars(String) + */ + @NotNull + public static String unescapeIllegalXmlChars(@NotNull String text) { + StringBuilder b = null; + int lastPos = 0; + for (int i = 0; i < text.length(); i++) { + int c = text.charAt(i); + if (c == '#') { + int numberEnd = text.indexOf('#', i + 1); + if (numberEnd > 0) { + int charCode; + try { + charCode = numberEnd == (i + 1) ? '#' : Integer.parseInt(text.substring(i + 1, numberEnd), 16); + } + catch (NumberFormatException e) { + continue; + } + if (b == null) b = new StringBuilder(text.length()); + b.append(text, lastPos, i); + b.append((char) charCode); + //noinspection AssignmentToForLoopParameter + i = numberEnd; + lastPos = i + 1; + } + } + } + return b == null ? text : b.append(text, lastPos, text.length()).toString(); + } + public static void quote(@NotNull final StringBuilder builder) { quote(builder, '\"'); } diff --git a/platform/util/src/com/intellij/ui/components/JBPanel.java b/platform/util/src/com/intellij/ui/components/JBPanel.java index fb0101033965..fc6b6fee1860 100644 --- a/platform/util/src/com/intellij/ui/components/JBPanel.java +++ b/platform/util/src/com/intellij/ui/components/JBPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.ui.components; import com.intellij.util.ui.JBFont; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.components.JBComponent; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.Border; @@ -75,6 +76,11 @@ public class JBPanel extends JPanel implements JBComponent return (T)this; } + public T withBackground(@Nullable Color background) { + setBackground(background); + return (T)this; + } + public T withPreferredWidth(int width) { myPreferredWidth = width; return (T)this; diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java index f8136aebdde0..0d37f66d1db2 100644 --- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java +++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java @@ -19,6 +19,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.LineSeparator; import com.intellij.xml.util.XmlStringUtil; +import org.jdom.Verifier; import org.junit.Test; import java.nio.CharBuffer; @@ -492,4 +493,13 @@ public class StringUtilTest { assertEquals(3, StringUtil.lastIndexOf("axaxa", 'x', 0, 5)); assertEquals(2, StringUtil.lastIndexOf("abcd", 'c', -42, 99)); // #IDEA-144968 } + + @Test + public void testEscapingIllegalXmlChars() { + for (String s : new String[]{"ab\n\0\r\tde", "\\abc\1\2\3\uFFFFdef"}) { + String escapedText = StringUtil.escapeIllegalXmlChars(s); + assertNull(Verifier.checkCharacterData(escapedText)); + assertEquals(s, StringUtil.unescapeIllegalXmlChars(escapedText)); + } + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java index 3768338f2648..3724d54db348 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -369,7 +369,7 @@ public class LineStatusTracker { private class MyApplicationListener extends ApplicationAdapter { @Override - public void writeActionFinished(Object action) { + public void writeActionFinished(@NotNull Object action) { if (!myInitialized || myReleased || myBulkUpdate || myDuringRollback || myAnathemaThrown) return; if (myDirtyRange != null) { try { diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/api/printer/PrintElementGenerator.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/api/printer/PrintElementGenerator.java index 1ed689cde270..9411f82cb21d 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/api/printer/PrintElementGenerator.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/api/printer/PrintElementGenerator.java @@ -28,5 +28,5 @@ public interface PrintElementGenerator { Collection getPrintElements(int visibleRow); @NotNull - PrintElementWithGraphElement toPrintElementWithGraphElement(@NotNull PrintElement printElement); + PrintElementWithGraphElement withGraphElement(@NotNull PrintElement printElement); } diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java index b05fcba42334..7e2f5d915188 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java @@ -205,7 +205,7 @@ public class VisibleGraphImpl implements VisibleGraph { private LinearGraphAction convert(@NotNull GraphAction graphAction) { PrintElementWithGraphElement printElement = null; if (graphAction.getAffectedElement() != null) { - printElement = myPrintElementGenerator.toPrintElementWithGraphElement(graphAction.getAffectedElement()); + printElement = myPrintElementGenerator.withGraphElement(graphAction.getAffectedElement()); } return new LinearGraphActionImpl(printElement, graphAction.getType()); } diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/AbstractPrintElementGenerator.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/AbstractPrintElementGenerator.java index 1a48f05100f5..569632bd44bf 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/AbstractPrintElementGenerator.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/AbstractPrintElementGenerator.java @@ -93,14 +93,16 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener return result; } - private SimplePrintElementImpl createSimplePrintElement(int rowIndex, SimpleRowElement rowElement) { + @NotNull + private SimplePrintElementImpl createSimplePrintElement(int rowIndex, @NotNull SimpleRowElement rowElement) { return new SimplePrintElementImpl(rowIndex, rowElement.myPosition, rowElement.myElement, myPrintElementManager); } + @NotNull private EdgePrintElementImpl createEdgePrintElement(int rowIndex, @NotNull ShortEdge shortEdge, @NotNull EdgePrintElement.Type type, - @NotNull boolean hasArrow) { + boolean hasArrow) { int positionInCurrentRow, positionInOtherRow; if (type == EdgePrintElement.Type.DOWN) { positionInCurrentRow = shortEdge.myUpPosition; @@ -116,7 +118,7 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener @NotNull @Override - public PrintElementWithGraphElement toPrintElementWithGraphElement(@NotNull PrintElement printElement) { + public PrintElementWithGraphElement withGraphElement(@NotNull PrintElement printElement) { if (printElement instanceof PrintElementWithGraphElement) { return (PrintElementWithGraphElement)printElement; } diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/elements/PrintElementWithGraphElement.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/elements/PrintElementWithGraphElement.java index b1f93f358360..510137a86386 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/elements/PrintElementWithGraphElement.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/print/elements/PrintElementWithGraphElement.java @@ -64,6 +64,7 @@ public abstract class PrintElementWithGraphElement implements PrintElement { return myPrintElementManager.isSelected(this); } + @NotNull public static PrintElementWithGraphElement converted(@NotNull PrintElementWithGraphElement element, @NotNull GraphElement convertedGraphElement) { return new PrintElementWithGraphElement(element.getRowIndex(), element.getPositionInCurrentRow(), convertedGraphElement, diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index f2b582be401e..f07f73083965 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -55,7 +55,7 @@ import com.intellij.vcs.log.ui.VcsLogColorManager; import com.intellij.vcs.log.ui.VcsLogColorManagerImpl; import com.intellij.vcs.log.ui.VcsLogUiImpl; import com.intellij.vcs.log.ui.render.GraphCommitCell; -import com.intellij.vcs.log.ui.render.GraphCommitCellRender; +import com.intellij.vcs.log.ui.render.GraphCommitCellRenderer; import com.intellij.vcs.log.ui.tables.GraphTableModel; import com.intellij.vcs.log.util.VcsUserUtil; import gnu.trove.TIntHashSet; @@ -92,7 +92,7 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi @NotNull private final VcsLogDataManager myLogDataManager; @NotNull private final MyDummyTableCellEditor myDummyEditor = new MyDummyTableCellEditor(); @NotNull private final TableCellRenderer myDummyRenderer = new DefaultTableCellRenderer(); - @NotNull private final GraphCommitCellRender myGraphCommitCellRenderer; + @NotNull private final GraphCommitCellRenderer myGraphCommitCellRenderer; private boolean myColumnsSizeInitialized = false; @Nullable private Selection mySelection = null; @@ -109,7 +109,7 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi super(new GraphTableModel(initialDataPack, logDataManager, ui)); myUi = ui; myLogDataManager = logDataManager; - myGraphCommitCellRenderer = new GraphCommitCellRender(logDataManager, myGraphCellPainter, this); + myGraphCommitCellRenderer = new GraphCommitCellRenderer(logDataManager, myGraphCellPainter, this); setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUi)); setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRenderer); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java similarity index 96% rename from platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java rename to platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java index cfe770837ec1..b9c53dd5ce63 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRender.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java @@ -24,9 +24,9 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class GraphCommitCellRender extends ColoredTableCellRenderer { +public class GraphCommitCellRenderer extends ColoredTableCellRenderer { - private static final Logger LOG = Logger.getInstance(GraphCommitCellRender.class); + private static final Logger LOG = Logger.getInstance(GraphCommitCellRenderer.class); @NotNull private final VcsLogDataManager myDataManager; @NotNull private final GraphCellPainter myPainter; @@ -39,9 +39,9 @@ public class GraphCommitCellRender extends ColoredTableCellRenderer { @NotNull private Font myFont; private int myHeight; - public GraphCommitCellRender(@NotNull VcsLogDataManager dataManager, - @NotNull GraphCellPainter painter, - @NotNull VcsLogGraphTable table) { + public GraphCommitCellRenderer(@NotNull VcsLogDataManager dataManager, + @NotNull GraphCellPainter painter, + @NotNull VcsLogGraphTable table) { myDataManager = dataManager; myPainter = painter; myGraphTable = table; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java index f1c6d7a35144..9e70f0f94202 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java @@ -133,11 +133,11 @@ public class XBreakpointUtil { * - if folded, checks if line breakpoints could be toggled inside folded text */ @NotNull - public static Promise toggleLineBreakpoint(@NotNull Project project, - @NotNull XSourcePosition position, - @Nullable Editor editor, - boolean temporary, - boolean moveCarret) { + public static Promise toggleLineBreakpoint(@NotNull Project project, + @NotNull XSourcePosition position, + @Nullable Editor editor, + boolean temporary, + boolean moveCarret) { int lineStart = position.getLine(); VirtualFile file = position.getFile(); // for folded text check each line and find out type with the biggest priority diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java index dcbaf0d6b44a..e889d6c4ad71 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java @@ -52,10 +52,12 @@ import com.intellij.util.ui.update.Update; import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.breakpoints.SuspendPolicy; import com.intellij.xdebugger.breakpoints.XBreakpoint; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import com.intellij.xdebugger.impl.XSourcePositionImpl; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; +import org.jetbrains.concurrency.Promise; import java.awt.event.MouseEvent; import java.util.Collection; @@ -280,8 +282,8 @@ public class XLineBreakpointManager { if (line >= 0 && line < document.getLineCount() && file != null) { ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent()); - XBreakpointUtil - .toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false) + final Promise lineBreakpoint = XBreakpointUtil.toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false); + lineBreakpoint .done(breakpoint -> { if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) { breakpoint.setSuspendPolicy(SuspendPolicy.NONE); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodCallUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodCallUtils.java index 35da41e6d8c5..66e29475b579 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodCallUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodCallUtils.java @@ -150,7 +150,7 @@ public class MethodCallUtils { } public static boolean isCallDuringObjectConstruction(PsiMethodCallExpression expression) { - final PsiMember member = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, PsiClassInitializer.class, PsiField.class); + final PsiMember member = PsiTreeUtil.getParentOfType(expression, PsiMember.class, true, PsiClass.class, PsiLambdaExpression.class); if (member == null) { return false; } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/initialization/abstract_method_call_in_constructor/AbstractMethodCallInConstructor.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/initialization/abstract_method_call_in_constructor/AbstractMethodCallInConstructor.java new file mode 100644 index 000000000000..88ad0be72eda --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/initialization/abstract_method_call_in_constructor/AbstractMethodCallInConstructor.java @@ -0,0 +1,13 @@ +abstract class A { + public A() { + Runnable r = () -> foo(); + Runnable r1 = new Runnable() { + public void run() { + foo(); + } + }; + + } + + abstract void foo(); +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/initialization/AbstractMethodCallInConstructorInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/initialization/AbstractMethodCallInConstructorInspectionTest.java new file mode 100644 index 000000000000..26c16148c326 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/initialization/AbstractMethodCallInConstructorInspectionTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.initialization; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; + +public class AbstractMethodCallInConstructorInspectionTest extends LightInspectionTestCase { + + public void testAbstractMethodCallInConstructor() { + doTest(); + } + + @Override + protected InspectionProfileEntry getInspection() { + return new AbstractMethodCallInConstructorInspection(); + } +} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsContentRevision.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsContentRevision.java index a329c60cd6b4..d1403b0851a1 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsContentRevision.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsContentRevision.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback; import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler; import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation; import com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate; +import com.intellij.cvsSupport2.history.CvsRevisionNumber; import com.intellij.openapi.cvsIntegration.CvsResult; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; @@ -65,6 +66,7 @@ public class CvsContentRevision implements ByteBackedContentRevision { myProject = project; } + @Override @Nullable public String getContent() throws VcsException { byte[] content = getContentAsBytes(); @@ -96,14 +98,20 @@ public class CvsContentRevision implements ByteBackedContentRevision { return myContent; } + @Override @NotNull public FilePath getFile() { return myLocalFile; } + @Override @NotNull public VcsRevisionNumber getRevisionNumber() { - return myRevision.getCvsRevisionNumber(); + final CvsRevisionNumber cvsRevisionNumber = myRevision.getCvsRevisionNumber(); + if (cvsRevisionNumber == null) { + return VcsRevisionNumber.NULL; + } + return cvsRevisionNumber; } @Override @NonNls diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseColorSchemeImporter.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseColorSchemeImporter.java index 06468197c6cd..7c0dc077b112 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseColorSchemeImporter.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseColorSchemeImporter.java @@ -89,7 +89,11 @@ public class EclipseColorSchemeImporter implements SchemeImporter params = new ArrayList(); for (ParameterInfo info : infos) { - if (info.passAsParameter()) { - PsiType paramType = info.getType(); + if (info.passAsParameter) { + PsiType paramType = info.type; final PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(paramType); if (unboxed != null) paramType = unboxed; @@ -474,7 +474,7 @@ public class ExtractUtil { buffer.append("("); int number = 0; for (ParameterInfo info : helper.getParameterInfos()) { - if (info.passAsParameter()) number++; + if (info.passAsParameter) number++; } int i = 0; String[] argumentNames = helper.getArgumentNames(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GrParameterTablePanel.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GrParameterTablePanel.java new file mode 100644 index 000000000000..6f6212f2d6eb --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GrParameterTablePanel.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.plugins.groovy.refactoring.extract; + +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiManager; +import com.intellij.psi.PsiType; +import com.intellij.refactoring.ui.TypeSelector; +import com.intellij.refactoring.util.ParameterTablePanel; +import com.intellij.refactoring.util.VariableData; +import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; + +/** + * @author ilyas + */ +public abstract class GrParameterTablePanel extends ParameterTablePanel { + + public GrParameterTablePanel() { + super(GroovyNamesUtil::isIdentifier); + } + + public void init(ExtractInfoHelper helper) { + super.init(helper.getParameterInfos(), helper.getProject(), helper.getContext()); + } + + @Override + protected TypeSelector createSelector(Project project, VariableData data, PsiElement[] scopeElements) { + final PsiType type = data.type; + return new TypeSelector(type != null ? type : PsiType.getJavaLangObject(PsiManager.getInstance(project), scopeElements[0].getResolveScope()), project); + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterInfo.java index 0b05c58d0168..b335049fb4b6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterInfo.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterInfo.java @@ -17,29 +17,23 @@ package org.jetbrains.plugins.groovy.refactoring.extract; import com.intellij.psi.PsiType; +import com.intellij.refactoring.util.VariableData; import org.jetbrains.annotations.NotNull; /** * @author ilyas */ -public class ParameterInfo { - private final String myOldName; - private String myNewName; +public class ParameterInfo extends VariableData { private int myPosition; - private boolean myPassAsParameter = true; - private PsiType myType; public ParameterInfo(@NotNull String oldName, int position, PsiType psiType){ - myOldName = oldName; - setType(psiType); - myNewName = myOldName; + super(null, psiType); + name = oldName; + passAsParameter = true; + originalName = oldName; myPosition = position; } - public String getOldName() { - return myOldName; - } - public int getPosition() { return myPosition; } @@ -47,28 +41,4 @@ public class ParameterInfo { public void setPosition(int position) { myPosition = position; } - - public String getName() { - return myNewName; - } - - public PsiType getType() { - return myType; - } - - public void setNewName(String newName) { - myNewName = newName; - } - - public boolean passAsParameter() { - return myPassAsParameter; - } - - public void setPassAsParameter(boolean passAsParameter) { - myPassAsParameter = passAsParameter; - } - - public void setType(PsiType type) { - myType = type; - } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java deleted file mode 100644 index 9b9a9ffbd3f5..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.plugins.groovy.refactoring.extract; - -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiManager; -import com.intellij.psi.PsiPrimitiveType; -import com.intellij.psi.PsiType; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.refactoring.ui.TypeSelector; -import com.intellij.ui.*; -import com.intellij.ui.table.JBTable; -import com.intellij.util.ui.AbstractTableCellEditor; -import com.intellij.util.ui.EditableModel; -import com.intellij.util.ui.JBUI; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; -import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; - -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableColumn; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; - -/** - * @author ilyas - */ -public abstract class ParameterTablePanel extends JPanel { - - private ParameterInfo[] myParameterInfos; - private TypeSelector[] myParameterTypeSelectors; - - private JBTable myTable; - private MyTableModel myTableModel; - private JComboBox myTypeRendererCombo; - - public ParameterTablePanel() { - super(new BorderLayout()); - } - - public void init(ExtractInfoHelper helper) { - - setBorder(IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("parameters.border.title"), false)); - - myParameterInfos = helper.getParameterInfos(); - - myTableModel = new MyTableModel(); - myTable = new JBTable(myTableModel); - DefaultCellEditor defaultEditor = (DefaultCellEditor)myTable.getDefaultEditor(Object.class); - defaultEditor.setClickCountToStart(1); - - myTable.setTableHeader(null); - myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - TableColumn checkBoxColumn = myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN); - TableUtil.setupCheckboxColumn(checkBoxColumn); - checkBoxColumn.setCellRenderer(new CheckBoxTableCellRenderer()); - - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_NAME_COLUMN).setCellRenderer(new DefaultTableCellRenderer() { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - ParameterInfo info = myParameterInfos[row]; - setText(info.getName()); - return this; - } - }); - - Project project = helper.getProject(); - PsiManager manager = PsiManager.getInstance(project); - GlobalSearchScope scope = GlobalSearchScope.allScope(project); - myParameterTypeSelectors = new TypeSelector[myParameterInfos.length]; - for (int i = 0; i < myParameterTypeSelectors.length; i++) { -// final GrExpression[] occurrences = ExtractUtil.findVariableOccurrences(helper.getStatements(), myParameterInfos[i].getName()); -// final TypeSelectorManager manager = new TypeSelectorManagerImpl(myProject, myParameterInfos[i].getType(), occurrences, areTypesDirected()); - PsiType type = myParameterInfos[i].getType(); - myParameterTypeSelectors[i] = new TypeSelector(type != null ? type : PsiType.getJavaLangObject(manager, scope), project); -// myParameterInfos[i].setTypeName(myParameterTypeSelectors[i].getSelectedType()); - } - - myTypeRendererCombo = new JComboBox(myParameterInfos); - myTypeRendererCombo.setOpaque(true); - myTypeRendererCombo.setBorder(null); - - myTypeRendererCombo.setRenderer(new ListCellRendererWrapper() { - @Override - public void customize(JList list, ParameterInfo info, int index, boolean selected, boolean hasFocus) { - PsiType type = info.getType(); - PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(type); - type = unboxed != null ? unboxed : type; - setText(type != null ? type.getPresentableText() : ""); - } - }); - - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellEditor(new AbstractTableCellEditor() { - TypeSelector myCurrentSelector; - - @Override - public Object getCellEditorValue() { - return myCurrentSelector.getSelectedType(); - } - - @Override - public Component getTableCellEditorComponent(final JTable table, - final Object value, - final boolean isSelected, - final int row, - final int column) { - myCurrentSelector = myParameterTypeSelectors[row]; - return myCurrentSelector.getComponent(); - } - }); - - myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellRenderer(new DefaultTableCellRenderer() { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - if (myParameterTypeSelectors[row].getComponent() instanceof JComboBox) { - myTypeRendererCombo.setSelectedIndex(row); - return myTypeRendererCombo; - } - - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - ParameterInfo info = myParameterInfos[row]; - PsiType type = info.getType(); - PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(type); - type = unboxed != null ? unboxed : type; - setText(type != null ? type.getPresentableText() : ""); - return this; - } - }); - - myTable.setPreferredScrollableViewportSize(JBUI.size(250, myTable.getRowHeight() * 5)); - myTable.setShowGrid(false); - myTable.setIntercellSpacing(JBUI.emptySize()); - @NonNls final InputMap inputMap = myTable.getInputMap(); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable"); - @NonNls final ActionMap actionMap = myTable.getActionMap(); - actionMap.put("enable_disable", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (myTable.isEditing()) return; - int[] rows = myTable.getSelectedRows(); - if (rows.length > 0) { - boolean valueToBeSet = false; - for (int row : rows) { - if (!myParameterInfos[row].passAsParameter()) { - valueToBeSet = true; - break; - } - } - for (int row : rows) { - myParameterInfos[row].setPassAsParameter(valueToBeSet); - } - myTableModel.fireTableRowsUpdated(rows[0], rows[rows.length - 1]); - TableUtil.selectRows(myTable, rows); - } - } - }); - // F2 should edit the name - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name"); - actionMap.put("edit_parameter_name", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - if (!myTable.isEditing()) { - int row = myTable.getSelectedRow(); - if (row >= 0 && row < myTableModel.getRowCount()) { - TableUtil.editCellAt(myTable, row, MyTableModel.PARAMETER_NAME_COLUMN); - } - } - } - }); - - // make ENTER work when the table has focus - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl"); - actionMap.put("invokeImpl", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - TableCellEditor editor = myTable.getCellEditor(); - if (editor != null) { - editor.stopCellEditing(); - } - else { - doEnterAction(); - } - } - }); - - // make ESCAPE work when the table has focus - actionMap.put("doCancel", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - TableCellEditor editor = myTable.getCellEditor(); - if (editor != null) { - editor.stopCellEditing(); - } - else { - doCancelAction(); - } - } - }); - - JPanel listPanel = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction().createPanel(); - add(listPanel, BorderLayout.CENTER); - } - - protected abstract void updateSignature(); - - protected abstract void doEnterAction(); - - protected abstract void doCancelAction(); - - private class MyTableModel extends AbstractTableModel implements EditableModel { - public static final int CHECKMARK_COLUMN = 0; - public static final int PARAMETER_TYPE_COLUMN = 1; - public static final int PARAMETER_NAME_COLUMN = 2; - - @Override - public void addRow() { - throw new IllegalAccessError("Not implemented"); - } - - @Override - public void removeRow(int index) { - throw new IllegalAccessError("Not implemented"); - } - - @Override - public void exchangeRows(int oldIndex, int newIndex) { - if (oldIndex < 0 || newIndex < 0) return; - if (oldIndex >= myParameterInfos.length || newIndex >= myParameterInfos.length) return; - - final ParameterInfo old = myParameterInfos[oldIndex]; - myParameterInfos[oldIndex] = myParameterInfos[newIndex]; - myParameterInfos[newIndex] = old; - - myParameterInfos[oldIndex].setPosition(oldIndex); - myParameterInfos[newIndex].setPosition(newIndex); - - fireTableRowsUpdated(Math.min(oldIndex, newIndex), Math.max(oldIndex, newIndex)); - updateSignature(); - } - - @Override - public boolean canExchangeRows(int oldIndex, int newIndex) { - if (oldIndex < 0 || newIndex < 0) return false; - if (oldIndex >= myParameterInfos.length || newIndex >= myParameterInfos.length) return false; - return true; - } - - @Override - public int getRowCount() { - return myParameterInfos.length; - } - - @Override - public int getColumnCount() { - return 3; - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - return myParameterInfos[rowIndex].passAsParameter(); - } - case PARAMETER_NAME_COLUMN: { - return myParameterInfos[rowIndex].getName(); - } - case PARAMETER_TYPE_COLUMN: { - PsiType type = myParameterInfos[rowIndex].getType(); - return type != null ? type.getPresentableText() : ""; - } - } - assert false; - return null; - } - - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: { - myParameterInfos[rowIndex].setPassAsParameter((Boolean)aValue); - fireTableRowsUpdated(rowIndex, rowIndex); - myTable.getSelectionModel().setSelectionInterval(rowIndex, rowIndex); - updateSignature(); - break; - } - case PARAMETER_NAME_COLUMN: { - ParameterInfo info = myParameterInfos[rowIndex]; - String name = (String)aValue; - if (GroovyNamesUtil.isIdentifier(name)) { - info.setNewName(name); - } - updateSignature(); - break; - } - case PARAMETER_TYPE_COLUMN: { - ParameterInfo info = myParameterInfos[rowIndex]; - info.setType((PsiType)aValue); - updateSignature(); - break; - } - } - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - switch (columnIndex) { - case CHECKMARK_COLUMN: - return isEnabled(); - case PARAMETER_NAME_COLUMN: - return isEnabled() && myParameterInfos[rowIndex].passAsParameter(); - case PARAMETER_TYPE_COLUMN: - return isEnabled() && - myParameterInfos[rowIndex].passAsParameter() && - !(myParameterTypeSelectors[rowIndex].getComponent() instanceof JLabel); - default: - return false; - } - } - - @Override - public Class getColumnClass(int columnIndex) { - if (columnIndex == CHECKMARK_COLUMN) { - return Boolean.class; - } - return super.getColumnClass(columnIndex); - } - } - - private class CheckBoxTableCellRenderer extends BooleanTableCellRenderer { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - rendererComponent.setEnabled(ParameterTablePanel.this.isEnabled()); - return rendererComponent; - } - } -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java index 60a41dae6c1c..69fe683fcfde 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodDialog.java @@ -44,8 +44,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.utils.DuplicatesUtil; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil; import org.jetbrains.plugins.groovy.refactoring.extract.ExtractUtil; +import org.jetbrains.plugins.groovy.refactoring.extract.GrParameterTablePanel; import org.jetbrains.plugins.groovy.refactoring.extract.InitialInfo; -import org.jetbrains.plugins.groovy.refactoring.extract.ParameterTablePanel; import org.jetbrains.plugins.groovy.refactoring.ui.GrMethodSignatureComponent; import org.jetbrains.plugins.groovy.refactoring.ui.GroovyComboboxVisibilityPanel; import org.jetbrains.plugins.groovy.settings.GroovyApplicationSettings; @@ -76,7 +76,7 @@ public class GroovyExtractMethodDialog extends DialogWrapper { private ComboBoxVisibilityPanel myVisibilityPanel; private Splitter mySplitter; private JCheckBox myForceReturnCheckBox; - private ParameterTablePanel myParameterTablePanel; + private GrParameterTablePanel myParameterTablePanel; private final Project myProject; public GroovyExtractMethodDialog(InitialInfo info, PsiClass owner) { @@ -247,7 +247,7 @@ public class GroovyExtractMethodDialog extends DialogWrapper { } }); - myParameterTablePanel = new ParameterTablePanel() { + myParameterTablePanel = new GrParameterTablePanel() { @Override protected void updateSignature(){ GroovyExtractMethodDialog.this.updateSignature(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodHandler.java index d6872c464d56..c44580432699 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/method/GroovyExtractMethodHandler.java @@ -275,7 +275,7 @@ public class GroovyExtractMethodHandler implements RefactoringActionHandler { final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(helper.getProject()); for (ParameterInfo info : helper.getParameterInfos()) { - final String oldName = info.getOldName(); + final String oldName = info.getOriginalName(); final String newName = info.getName(); final ArrayList result = new ArrayList(); if (!oldName.equals(newName)) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java index 85d638f1f296..934ec49e0612 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java @@ -57,8 +57,8 @@ import org.jetbrains.plugins.groovy.refactoring.GrRefactoringError; import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; import org.jetbrains.plugins.groovy.refactoring.HelpID; import org.jetbrains.plugins.groovy.refactoring.extract.ExtractUtil; +import org.jetbrains.plugins.groovy.refactoring.extract.GrParameterTablePanel; import org.jetbrains.plugins.groovy.refactoring.extract.ParameterInfo; -import org.jetbrains.plugins.groovy.refactoring.extract.ParameterTablePanel; import org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromClosureProcessor; import org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromMethodProcessor; import org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureHelperImpl; @@ -89,7 +89,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper { private final TObjectIntHashMap toRemoveCBs; private GrMethodSignatureComponent mySignature; - private ParameterTablePanel myTable; + private GrParameterTablePanel myTable; private JPanel mySignaturePanel; private JCheckBox myForceReturnCheckBox; private final Project myProject; @@ -139,7 +139,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper { final GrParameter param = parameters[index]; final ParameterInfo pinfo = findParamByOldName(param.getName()); if (pinfo != null) { - pinfo.setPassAsParameter(false); + pinfo.passAsParameter = false; } return true; } @@ -207,7 +207,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper { private JPanel createSignaturePanel() { mySignature = new GrMethodSignatureComponent("", myProject); - myTable = new ParameterTablePanel() { + myTable = new GrParameterTablePanel() { @Override protected void updateSignature() { GrIntroduceParameterDialog.this.updateSignature(); @@ -406,7 +406,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper { final GrParameter param = myInfo.getToReplaceIn().getParameters()[index]; final ParameterInfo pinfo = findParamByOldName(param.getName()); - if (pinfo == null || !pinfo.passAsParameter()) return true; + if (pinfo == null || !pinfo.passAsParameter) return true; final String message = GroovyRefactoringBundle .message("you.cannot.pass.as.parameter.0.because.you.remove.1.from.base.method", pinfo.getName(), param.getName()); @@ -425,7 +425,7 @@ public class GrIntroduceParameterDialog extends DialogWrapper { @Nullable private ParameterInfo findParamByOldName(String name) { for (ParameterInfo info : myInfo.getParameterInfos()) { - if (name.equals(info.getOldName())) return info; + if (name.equals(info.getOriginalName())) return info; } return null; } diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudySwingToolWindow.java b/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudySwingToolWindow.java index f076c9e4e14e..ef66218d3398 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudySwingToolWindow.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudySwingToolWindow.java @@ -14,11 +14,13 @@ * limitations under the License. */ package com.jetbrains.edu.learning.ui; + import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.project.Project; import com.intellij.ui.BrowserHyperlinkListener; import com.intellij.ui.ColorUtil; +import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -37,6 +39,7 @@ public class StudySwingToolWindow extends StudyToolWindow { @Override public JComponent createTaskInfoPanel(String taskText, Project project) { myTaskTextPane = new JTextPane(); + final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane); myTaskTextPane.setContentType(new HTMLEditorKit().getContentType()); final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); int fontSize = editorColorsScheme.getEditorFontSize(); @@ -56,7 +59,7 @@ public class StudySwingToolWindow extends StudyToolWindow { myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10)); myTaskTextPane.setText(taskText); myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE); - return myTaskTextPane; + return scrollPane; } public void setTaskText(String text) { diff --git a/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java b/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java index 2898211f315e..a47c87a6c0e4 100644 --- a/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java +++ b/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java @@ -37,6 +37,7 @@ import com.intellij.refactoring.listeners.RefactoringElementListenerComposite; import com.intellij.refactoring.listeners.RefactoringEventData; import com.intellij.refactoring.listeners.RefactoringEventListener; import com.intellij.refactoring.rename.RenameUtil; +import com.intellij.refactoring.util.AbstractVariableData; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.usageView.UsageInfo; import com.intellij.util.Consumer; @@ -105,7 +106,7 @@ public class PyExtractMethodUtil { final String methodName = data.first; final AbstractVariableData[] variableData = data.second; - final SimpleDuplicatesFinder finder = new SimpleDuplicatesFinder(statement1, statement2, variableData, fragment.getOutputVariables()); + final SimpleDuplicatesFinder finder = new SimpleDuplicatesFinder(statement1, statement2, fragment.getOutputVariables(), variableData); CommandProcessor.getInstance().executeCommand(project, new Runnable() { public void run() { @@ -300,7 +301,7 @@ public class PyExtractMethodUtil { final String methodName = data.first; final AbstractVariableData[] variableData = data.second; - final SimpleDuplicatesFinder finder = new SimpleDuplicatesFinder(expression, expression, variableData, fragment.getOutputVariables()); + final SimpleDuplicatesFinder finder = new SimpleDuplicatesFinder(expression, expression, fragment.getOutputVariables(), variableData); if (fragment.getOutputVariables().isEmpty()) { CommandProcessor.getInstance().executeCommand(project, new Runnable() { @Override @@ -625,7 +626,7 @@ public class PyExtractMethodUtil { final boolean isMethod = PyPsiUtils.isMethodContext(element); final ExtractMethodDecorator decorator = new ExtractMethodDecorator() { @NotNull - public String createMethodPreview(final String methodName, @NotNull final AbstractVariableData[] variableDatas) { + public String createMethodSignature(final String methodName, @NotNull final AbstractVariableData[] variableDatas) { final StringBuilder builder = new StringBuilder(); if (isClassMethod) { builder.append("cls"); @@ -663,7 +664,7 @@ public class PyExtractMethodUtil { return Pair.empty(); } - return Pair.create(dialog.getMethodName(), dialog.getVariableData()); + return Pair.create(dialog.getMethodName(), dialog.getAbstractVariableData()); } @NotNull diff --git a/resources-en/src/messages/QuickFixBundle.properties b/resources-en/src/messages/QuickFixBundle.properties index 10115b7fd7b2..091b95496c7e 100644 --- a/resources-en/src/messages/QuickFixBundle.properties +++ b/resources-en/src/messages/QuickFixBundle.properties @@ -223,6 +223,7 @@ orderEntry.fix.add.library.to.classpath=Add library ''{0}'' to classpath orderEntry.fix.family.add.library.to.classpath=Add library to classpath orderEntry.fix.circular.dependency.warning=Adding dependency on module ''{0}'' will introduce circular dependency between modules ''{1}'' and ''{2}''.\nAdd dependency anyway? orderEntry.fix.title.circular.dependency.warning=Circular Dependency Warning +orderEntry.fix.add.junit.jar.to.classpath=Add JUnit to classpath static.import.method.text=Static import method static.import.method.choose.method.to.import=Choose Method to Import