Merge remote-tracking branch 'origin/master'
@@ -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(".")
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PsiClass> result = new ArrayList<PsiClass>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,4 +41,5 @@ public interface JavaParameterInfo extends ParameterInfo {
|
||||
|
||||
boolean isVarargType();
|
||||
|
||||
default void setType(@Nullable PsiType type) {}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ public class ParameterInfoImpl implements JavaParameterInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(PsiType type) {
|
||||
myType = CanonicalTypes.createTypeWrapper(type);
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -156,8 +156,8 @@ public class PullUpDialog extends PullUpDialogBase<MemberInfoStorage, MemberInfo
|
||||
boolean hasJavadoc = false;
|
||||
for (MemberInfo info : myMemberInfos) {
|
||||
final PsiMember member = info.getMember();
|
||||
info.setToAbstract(myMemberInfoModel.isAbstractWhenDisabled(info));
|
||||
if (myMemberInfoModel.isAbstractEnabled(info)) {
|
||||
info.setToAbstract(myMemberInfoModel.isAbstractWhenDisabled(info));
|
||||
if (!hasJavadoc &&
|
||||
member instanceof PsiDocCommentOwner &&
|
||||
((PsiDocCommentOwner)member).getDocComment() != null) {
|
||||
|
||||
@@ -15,100 +15,59 @@
|
||||
*/
|
||||
package com.intellij.refactoring.util;
|
||||
|
||||
import com.intellij.lang.LanguageNamesValidation;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.ui.TypeSelector;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManager;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.ui.BooleanTableCellRenderer;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.components.JBComboBoxLabel;
|
||||
import com.intellij.ui.components.editors.JBComboBoxTableCellEditorComponent;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class ParameterTablePanel extends JPanel {
|
||||
private final Project myProject;
|
||||
private final VariableData[] myVariableData;
|
||||
private final TypeSelector[] myParameterTypeSelectors;
|
||||
|
||||
private final JBTable myTable;
|
||||
private final MyTableModel myTableModel;
|
||||
private final JComboBox myTypeRendererCombo;
|
||||
public abstract class ParameterTablePanel extends AbstractParameterTablePanel<VariableData> {
|
||||
|
||||
public VariableData[] getVariableData() {
|
||||
return myVariableData;
|
||||
private TypeSelector[] myParameterTypeSelectors;
|
||||
private JComboBox<VariableData> 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<String> 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<VariableData>(getVariableData());
|
||||
myTypeRendererCombo.setOpaque(true);
|
||||
myTypeRendererCombo.setBorder(null);
|
||||
myTypeRendererCombo.setRenderer(new ListCellRendererWrapper<VariableData>() {
|
||||
@@ -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<Object, String>() {
|
||||
@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<VariableData>(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<VariableData, PsiType> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PsiClass, Pair<List<PsiClass>, AtomicIntegerArray>> DIRECT_SUB_CLASSES = createWeakCache();
|
||||
// baseClass -> all sub classes transitively, including anonymous
|
||||
final ConcurrentMap<PsiClass, Collection<PsiClass>> ALL_SUB_CLASSES = createWeakCache();
|
||||
final ConcurrentMap<PsiClass, Iterable<PsiClass>> ALL_SUB_CLASSES = createWeakCache();
|
||||
// baseMethod -> all overriding methods
|
||||
final Map<PsiMethod, Collection<PsiMethod>> OVERRIDING_METHODS = createWeakCache();
|
||||
final Map<PsiMethod, Iterable<PsiMethod>> OVERRIDING_METHODS = createWeakCache();
|
||||
|
||||
@NotNull
|
||||
private <T,V> ConcurrentMap<T,V> createWeakCache() {
|
||||
|
||||
@@ -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<PsiClass, Cla
|
||||
return processLocalScope(project, parameters, (LocalSearchScope)searchScope, baseClass, consumer);
|
||||
}
|
||||
|
||||
Collection<PsiClass> cached = getOrComputeSubClasses(project, parameters.getClassToProcess());
|
||||
Iterable<PsiClass> cached = getOrComputeSubClasses(project, parameters.getClassToProcess());
|
||||
|
||||
for (final PsiClass subClass : cached) {
|
||||
ProgressManager.checkCanceled();
|
||||
@@ -102,9 +101,9 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<PsiClass> getOrComputeSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) {
|
||||
ConcurrentMap<PsiClass, Collection<PsiClass>> CACHE = HighlightingCaches.getInstance(project).ALL_SUB_CLASSES;
|
||||
Collection<PsiClass> cached = CACHE.get(baseClass);
|
||||
private static Iterable<PsiClass> getOrComputeSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) {
|
||||
ConcurrentMap<PsiClass, Iterable<PsiClass>> CACHE = HighlightingCaches.getInstance(project).ALL_SUB_CLASSES;
|
||||
Iterable<PsiClass> 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<PsiClass, Cla
|
||||
|
||||
@NotNull
|
||||
// returns lazy collection of subclasses. Each call to next() leads to calculation of next batch of subclasses.
|
||||
private static Collection<PsiClass> computeAllSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) {
|
||||
private static Iterable<PsiClass> computeAllSubClasses(@NotNull Project project, @NotNull PsiClass baseClass) {
|
||||
return new AllSubClassesLazyCollection(project, baseClass);
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ public class JavaClassInheritorsSearcher extends QueryExecutorBase<PsiClass, Cla
|
||||
return ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> baseClass.hasModifierProperty(PsiModifier.FINAL));
|
||||
}
|
||||
|
||||
private static class AllSubClassesLazyCollection extends AbstractCollection<PsiClass> {
|
||||
private static class AllSubClassesLazyCollection implements Iterable<PsiClass> {
|
||||
// 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<PsiClass, Cla
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private Iterator<PsiClass> candidatesToFindSubclassesIterator; // guarded by lock
|
||||
|
||||
private void findNextSubclasses() {
|
||||
|
||||
@@ -160,11 +160,11 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
return cached;
|
||||
}
|
||||
|
||||
final String className = ApplicationManager.getApplication().runReadAction((Computable<String>)baseClass::getName);
|
||||
if (StringUtil.isEmpty(className)) {
|
||||
final String baseClassName = ApplicationManager.getApplication().runReadAction((Computable<String>)baseClass::getName);
|
||||
if (StringUtil.isEmpty(baseClassName)) {
|
||||
return Pair.create(Collections.emptyList(), new AtomicIntegerArray(0));
|
||||
}
|
||||
Pair<List<PsiClass>, AtomicIntegerArray> pair = calculateDirectSubClasses(project, baseClass, className);
|
||||
Pair<List<PsiClass>, 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<PsiClass, Dir
|
||||
@NotNull
|
||||
private static Pair<List<PsiClass>, AtomicIntegerArray> calculateDirectSubClasses(@NotNull Project project,
|
||||
@NotNull PsiClass baseClass,
|
||||
@NotNull String className) {
|
||||
@NotNull String baseClassName) {
|
||||
GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
|
||||
Collection<PsiReferenceList> candidates =
|
||||
MethodUsagesSearcher
|
||||
.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(className, project, allScope));
|
||||
MethodUsagesSearcher.resolveInReadAction(project, () -> JavaSuperClassNameOccurenceIndex.getInstance().get(baseClassName, project, allScope));
|
||||
|
||||
Map<String, List<PsiClass>> classes = new HashMap<>();
|
||||
int count = 0;
|
||||
@@ -196,7 +195,7 @@ public class JavaDirectInheritorsSearcher implements QueryExecutor<PsiClass, Dir
|
||||
}
|
||||
|
||||
Collection<PsiAnonymousClass> anonymousCandidates =
|
||||
MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(className, project, allScope));
|
||||
MethodUsagesSearcher.resolveInReadAction(project, () -> JavaAnonymousClassBaseRefOccurenceIndex.getInstance().get(baseClassName, project, allScope));
|
||||
|
||||
List<PsiClass> result = new ArrayList<>(count + classes.size() + anonymousCandidates.size() + 1);
|
||||
for (Map.Entry<String, List<PsiClass>> entry : classes.entrySet()) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JavaOverridingMethodsSearcher implements QueryExecutor<PsiMethod, O
|
||||
return processLocalScope((LocalSearchScope)searchScope, method, project, consumer);
|
||||
}
|
||||
|
||||
Collection<PsiMethod> cached = HighlightingCaches.getInstance(project).OVERRIDING_METHODS.get(method);
|
||||
Iterable<PsiMethod> 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<PsiMethod, O
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<PsiMethod> compute(@NotNull PsiMethod method, @NotNull Project project) {
|
||||
private static Iterable<PsiMethod> compute(@NotNull PsiMethod method, @NotNull Project project) {
|
||||
Collection<PsiMethod> result = new LinkedHashSet<>();
|
||||
|
||||
Application application = ApplicationManager.getApplication();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test<T> {
|
||||
{
|
||||
Supplier<T> aNew = T::<error descr="Cannot resolve constructor 'T'">new</error>;
|
||||
}
|
||||
}
|
||||
@@ -506,6 +506,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeParameterInstantiation() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/missingModuleSourcesOrderEntry.iml" filepath="$PROJECT_DIR$/missingModuleSourcesOrderEntry.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.4" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -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<JpsDependencyElement> 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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -503,4 +503,8 @@ public class FileReferenceSet {
|
||||
public void setEmptyPathAllowed(boolean emptyPathAllowed) {
|
||||
myEmptyPathAllowed = emptyPathAllowed;
|
||||
}
|
||||
|
||||
public boolean supportsExtendedCompletion() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 918 B |
|
After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 221 B |
|
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 461 B |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 928 B |
|
After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 221 B |
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 548 B |
|
After Width: | Height: | Size: 547 B |
|
After Width: | Height: | Size: 290 B |
|
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 477 B |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 919 B |
|
After Width: | Height: | Size: 949 B |
|
After Width: | Height: | Size: 220 B |
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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<InspectionTreeNode> 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<InspectionTreeNode>() {
|
||||
@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<AnAction> 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<InspectionProfile> profiles = new HashSet<InspectionProfile>();
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<InspectionProfile> profiles = new HashSet<InspectionProfile>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<AnAction> 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<AnAction> createActions() {
|
||||
final List<AnAction> result = new ArrayList<AnAction>();
|
||||
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<PsiElement> files = new HashSet<PsiElement>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PsiElement> files = new HashSet<PsiElement>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<InspectionTreeNode> myNodesToSuppress = new HashSet<InspectionTreeNode>();
|
||||
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<GlobalInspectionContextImpl> globalInspectionContexts = myManager.getRunningContexts();
|
||||
final Set<GlobalInspectionContextImpl> 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<PsiElement, CommonProblemDescriptor> 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<PsiElement, CommonProblemDescriptor> 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<GlobalInspectionContextImpl> globalInspectionContexts = myManager.getRunningContexts();
|
||||
final Set<GlobalInspectionContextImpl> 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<PsiElement, CommonProblemDescriptor> 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<InspectionTreeNode> getNodesToSuppress(@NotNull InspectionResultsView view) {
|
||||
final TreePath[] paths = view.getTree().getSelectionPaths();
|
||||
if (paths == null) return Collections.emptySet();
|
||||
final Set<InspectionTreeNode> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Direction> 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<Usage> usages = new ArrayList<Usage>();
|
||||
final List<Usage> 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<Pair<TextRange, String>> rangesToChange = new ArrayList<Pair<TextRange, String>>();
|
||||
List<Pair<TextRange, String>> 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<Pair<TextRange, String>>() {
|
||||
@Override
|
||||
public int compare(Pair<TextRange, String> o1, Pair<TextRange, String> o2) {
|
||||
return o1.getFirst().getStartOffset() - o2.getFirst().getStartOffset();
|
||||
}
|
||||
});
|
||||
Collections.sort(rangesToChange, (o1, o2) -> o1.getFirst().getStartOffset() - o2.getFirst().getStartOffset());
|
||||
int offsetBefore = 0;
|
||||
for (Pair<TextRange, String> 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<SmartPsiElementPointer> pointers = ContainerUtil.map(targets, new Function<PsiElement, SmartPsiElementPointer>() {
|
||||
@Override
|
||||
public SmartPsiElementPointer fun(PsiElement psiElement) {
|
||||
return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement);
|
||||
}
|
||||
});
|
||||
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
|
||||
List<SmartPsiElementPointer> 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<CaretState> caretStates = new ArrayList<CaretState>();
|
||||
ArrayList<CaretState> caretStates = new ArrayList<>();
|
||||
while (resultIterator.hasNext()) {
|
||||
FindResult findResult = resultIterator.next();
|
||||
int caretOffset = getCaretPosition(findResult, caretShiftFromSelectionStart);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -162,7 +162,6 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
private Map<String, String> myConfigurables = new HashMap<String, String>();
|
||||
|
||||
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}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class GeneralColorsPage implements ColorSettingsPage, InspectionColorSett
|
||||
"<todo>//TODO: Visit JB Web resources:</todo>\n"+
|
||||
"JetBrains Home Page: <hyperlink_f>http://www.jetbrains.com</hyperlink_f>\n" +
|
||||
"JetBrains Developer Community: <hyperlink>https://www.jetbrains.com/devnet</hyperlink>\n" +
|
||||
"<ref_hyperlink>ReferenceHyperlink</ref_hyperlink>\n" +
|
||||
"\n" +
|
||||
"Search:\n" +
|
||||
" <search_result_wr>result</search_result_wr> = \"<search_text>text</search_text>, <search_text>text</search_text>, <search_text>text</search_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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -71,7 +71,7 @@ class EncodingFileTreeTable extends AbstractFileTreeTable<Charset> {
|
||||
setText(encodingText + (failReason == null ? "" : " (" + failReason + ")"));
|
||||
}
|
||||
|
||||
setEnabled(enabled);
|
||||
setEnabled(enabled || isSelected); // do not use grayed text on selected row
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -148,7 +148,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
extension instanceof StringStubIndexExtension && ((StringStubIndexExtension)extension).traceKeyHashToVirtualFileMapping()
|
||||
);
|
||||
|
||||
final MemoryIndexStorage<K, StubIdList> memStorage = new MemoryIndexStorage<K, StubIdList>(storage);
|
||||
final MemoryIndexStorage<K, StubIdList> memStorage = new MemoryIndexStorage<K, StubIdList>(storage, indexKey);
|
||||
MyIndex<K> index = new MyIndex<>(new IndexExtension<K, StubIdList, Void>() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/RefactoringBundle" title-key="refactoring.extract.method.dialog.parameters"/>
|
||||
<children>
|
||||
<component id="d4ee9" class="com.intellij.refactoring.extractMethod.AbstractParameterTablePanel" binding="myParametersPanel" custom-create="true">
|
||||
<component id="d4ee9" class="com.intellij.refactoring.util.SimpleParameterTablePanel" binding="myParametersPanel" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
||||
@@ -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<String> args) {
|
||||
public static AbstractVariableData[] createVariableDataByNames(final List<String> 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<String> args) {
|
||||
return com.intellij.refactoring.extractMethod.AbstractVariableData.copy(createVariableDataByNames(args));
|
||||
}
|
||||
|
||||
public static Map<String, AbstractVariableData> createVariableMap(final AbstractVariableData[] data) {
|
||||
final HashMap<String, AbstractVariableData> map = new HashMap<String, AbstractVariableData>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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<PsiElement> PARAMETER = Key.create("PARAMETER");
|
||||
private final Collection<String> myOutputVariables;
|
||||
|
||||
@Deprecated
|
||||
public SimpleDuplicatesFinder(@NotNull final PsiElement statement1,
|
||||
@NotNull final PsiElement statement2,
|
||||
AbstractVariableData[] variableData, Collection<String> variables) {
|
||||
com.intellij.refactoring.extractMethod.AbstractVariableData[] variableData,
|
||||
Collection<String> variables) {
|
||||
this(statement1, statement2, variables, variableData);
|
||||
}
|
||||
|
||||
public SimpleDuplicatesFinder(@NotNull final PsiElement statement1,
|
||||
@NotNull final PsiElement statement2,
|
||||
Collection<String> variables,
|
||||
AbstractVariableData[] variableData) {
|
||||
myOutputVariables = variables;
|
||||
myParameters = new HashSet<String>();
|
||||
for (AbstractVariableData data : variableData) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<P extends AbstractVariableData> 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<AbstractVariableData, String> {
|
||||
private final Predicate<String> myNameValidator;
|
||||
|
||||
public NameColumnInfo(Predicate<String> 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<AbstractVariableData, Boolean> {
|
||||
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<AbstractVariableData> 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;
|
||||
}
|
||||
}
|
||||
@@ -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<AbstractVariableData> {
|
||||
public SimpleParameterTablePanel(Predicate<String> parameterNameValidator) {
|
||||
super(new PassParameterColumnInfo(), new NameColumnInfo(parameterNameValidator));
|
||||
}
|
||||
}
|
||||
@@ -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<K, V>(storage)),
|
||||
createIndex(extension, new MemoryIndexStorage<K, V>(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);
|
||||
|
||||
|
||||
@@ -76,6 +76,14 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (myStorage instanceof MemoryIndexStorage) {
|
||||
getWriteLock().lock();
|
||||
try {
|
||||
((MemoryIndexStorage<Key, Value>)myStorage).clearCaches();
|
||||
} finally {
|
||||
getWriteLock().unlock();
|
||||
}
|
||||
}
|
||||
flush();
|
||||
} catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
|
||||
@NotNull
|
||||
private final IndexStorage<Key, Value> myBackendStorage;
|
||||
private final List<BufferingStateListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final ID<?, ?> myIndexId;
|
||||
private boolean myBufferingEnabled;
|
||||
|
||||
public interface BufferingStateListener {
|
||||
@@ -45,7 +46,12 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
|
||||
}
|
||||
|
||||
public MemoryIndexStorage(@NotNull IndexStorage<Key, Value> backend) {
|
||||
this(backend, null);
|
||||
}
|
||||
|
||||
public MemoryIndexStorage(@NotNull IndexStorage<Key, Value> backend, ID<?, ?> indexId) {
|
||||
myBackendStorage = backend;
|
||||
myIndexId = indexId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -85,6 +91,16 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
|
||||
}
|
||||
}
|
||||
|
||||
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<Value> v:myMap.values()) {
|
||||
v.dropMergedData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws StorageException {
|
||||
myBackendStorage.close();
|
||||
|
||||
@@ -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<T extends MutableTreeNode> extends TreeNodeExclusionAction<T> {
|
||||
public ExcludeTreeNodeAction() {
|
||||
super(true);
|
||||
}
|
||||
}
|
||||
@@ -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<T extends MutableTreeNode> extends Disposable {
|
||||
DataKey<ExclusionHandler> 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);
|
||||
}
|
||||
@@ -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<T extends MutableTreeNode> extends TreeNodeExclusionAction<T> {
|
||||
public IncludeTreeNodeAction() {
|
||||
super(false);
|
||||
}
|
||||
}
|
||||
@@ -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<T extends MutableTreeNode> 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<T> 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<T> 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";
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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 : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,10 +131,7 @@ public class CertificateManager implements PersistentStateComponent<CertificateM
|
||||
// Don't do this: protocol created this way will ignore SSL tunnels. See IDEA-115708.
|
||||
// Protocol.registerProtocol("https", CertificateManager.createDefault().createProtocol());
|
||||
if (Registry.is("ide.certificate.manager")) {
|
||||
SSLContext sslContext = getSslContext();
|
||||
SSLContext.setDefault(sslContext);
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(HOSTNAME_VERIFIER);
|
||||
SSLContext.setDefault(getSslContext());
|
||||
LOG.debug("Default SSL context initialized");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,16 +23,18 @@ import com.intellij.notification.EventLog;
|
||||
import com.intellij.notification.LogModel;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.impl.ui.NotificationsUtil;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.CustomStatusBarWidget;
|
||||
import com.intellij.openapi.wm.IconLikeCustomStatusBarWidget;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -125,15 +127,17 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget
|
||||
}
|
||||
|
||||
private LayeredIcon createIconWithNotificationCount(ArrayList<Notification> 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();
|
||||
|
||||
@@ -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<String> myContent;
|
||||
private List<String> 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()) {
|
||||
|
||||
@@ -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<String, Integer> systemFontData = UIUtil.getSystemFontData();
|
||||
if (systemFontData != null) {
|
||||
fontName = systemFontData.first;
|
||||
}
|
||||
}
|
||||
return StringUtil.isEmpty(fontName) ? null : "font-family:" + fontName + ";";
|
||||
Pair<String, Integer> systemFontData = UIUtil.getSystemFontData();
|
||||
return systemFontData == null ? null : systemFontData.first;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||