Commit afb30f3e authored by Kirill Smelov's avatar Kirill Smelov
Browse files

SSR: Allow Profile extensions to enable type related fields in EditVarConstraintsDialog

parent 559f4ec7
Showing with 23 additions and 21 deletions
+23 -21
...@@ -802,4 +802,9 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile { ...@@ -802,4 +802,9 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return offset; return offset;
} }
@Override
public boolean typeRelatedVarConstraintsSupported() {
return true;
}
} }
...@@ -278,4 +278,11 @@ public abstract class StructuralSearchProfile { ...@@ -278,4 +278,11 @@ public abstract class StructuralSearchProfile {
public PsiElement getPresentableElement(PsiElement element) { public PsiElement getPresentableElement(PsiElement element) {
return isIdentifier(element) ? element.getParent() : element; return isIdentifier(element) ? element.getParent() : element;
} }
/**
* @see com.intellij.structuralsearch.plugin.ui.EditVarConstraintsDialog
*/
public boolean typeRelatedVarConstraintsSupported() {
return false;
}
} }
...@@ -19,7 +19,6 @@ import com.intellij.openapi.editor.ex.EditorEx; ...@@ -19,7 +19,6 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.ComponentWithBrowseButton;
...@@ -115,11 +114,14 @@ class EditVarConstraintsDialog extends DialogWrapper { ...@@ -115,11 +114,14 @@ class EditVarConstraintsDialog extends DialogWrapper {
setTitle(SSRBundle.message("editvarcontraints.edit.variables")); setTitle(SSRBundle.message("editvarcontraints.edit.variables"));
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType);
final boolean typesSupported = profile != null && profile.typeRelatedVarConstraintsSupported();
regexp.getDocument().addDocumentListener(new MyDocumentListener(notRegexp, wholeWordsOnly)); regexp.getDocument().addDocumentListener(new MyDocumentListener(notRegexp, wholeWordsOnly));
regexp.getDocument().addDocumentListener(new DocumentListener() { regexp.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override
public void documentChanged(DocumentEvent e) { public void documentChanged(DocumentEvent e) {
applyWithinTypeHierarchy.setEnabled(e.getDocument().getTextLength() > 0 && fileType == StdFileTypes.JAVA); applyWithinTypeHierarchy.setEnabled(e.getDocument().getTextLength() > 0 && typesSupported);
} }
}); });
myZeroZeroButton.addActionListener(new ActionListener() { myZeroZeroButton.addActionListener(new ActionListener() {
...@@ -180,27 +182,15 @@ class EditVarConstraintsDialog extends DialogWrapper { ...@@ -180,27 +182,15 @@ class EditVarConstraintsDialog extends DialogWrapper {
variables.add(new Variable(Configuration.CONTEXT_VAR_NAME, "", "", true)); variables.add(new Variable(Configuration.CONTEXT_VAR_NAME, "", "", true));
} }
if (fileType == StdFileTypes.JAVA) { formalArgTypeWithinHierarchy.setEnabled(typesSupported);
formalArgTypeWithinHierarchy.setEnabled(true); invertFormalArgType.setEnabled(typesSupported);
invertFormalArgType.setEnabled(true); formalArgType.setEnabled(typesSupported);
formalArgType.setEnabled(true);
exprTypeWithinHierarchy.setEnabled(true);
notExprType.setEnabled(true);
regexprForExprType.setEnabled(true);
applyWithinTypeHierarchy.setEnabled(true); exprTypeWithinHierarchy.setEnabled(typesSupported);
} else { notExprType.setEnabled(typesSupported);
formalArgTypeWithinHierarchy.setEnabled(false); regexprForExprType.setEnabled(typesSupported);
invertFormalArgType.setEnabled(false);
formalArgType.setEnabled(false);
exprTypeWithinHierarchy.setEnabled(false); applyWithinTypeHierarchy.setEnabled(typesSupported);
notExprType.setEnabled(false);
regexprForExprType.setEnabled(false);
applyWithinTypeHierarchy.setEnabled(false);
}
parameterList.setModel( parameterList.setModel(
new AbstractListModel<Variable>() { new AbstractListModel<Variable>() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment