mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
scopes, configured for inspections: add scope, set level fixes (IDEA-83491;IDEA-83492;IDEA-83495)
This commit is contained in:
@@ -426,11 +426,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
}
|
||||
|
||||
public void disableToolByDefault(String toolId) {
|
||||
getTools(toolId).getDefaultState().setEnabled(false);
|
||||
getToolDefaultState(toolId).setEnabled(false);
|
||||
}
|
||||
|
||||
public ScopeToolState getToolDefaultState(String toolId) {
|
||||
return getTools(toolId).getDefaultState();
|
||||
}
|
||||
|
||||
public void enableToolByDefault(String toolId) {
|
||||
getTools(toolId).getDefaultState().setEnabled(true);
|
||||
getToolDefaultState(toolId).setEnabled(true);
|
||||
}
|
||||
|
||||
public boolean wasInitialized() {
|
||||
|
||||
+20
-19
@@ -1048,29 +1048,13 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
for (int i = 0; rows != null && i < rows.length; i++) {
|
||||
final InspectionConfigTreeNode node = (InspectionConfigTreeNode)myTree.getPathForRow(rows[i]).getLastPathComponent();
|
||||
final InspectionConfigTreeNode parent = (InspectionConfigTreeNode)node.getParent();
|
||||
if (node.getUserObject() instanceof Descriptor) {
|
||||
final Object userObject = node.getUserObject();
|
||||
if (userObject instanceof Descriptor && (node.getScopeName() != null || node.isLeaf())) {
|
||||
updateErrorLevel(node, showOptionsAndDescriptorPanels, level);
|
||||
updateUpHierarchy(node, parent);
|
||||
}
|
||||
else {
|
||||
node.isProperSetting = false;
|
||||
for (int j = 0; j < node.getChildCount(); j++) {
|
||||
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
|
||||
if (child.getUserObject() instanceof Descriptor) { //group node
|
||||
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
else { //root node
|
||||
child.isProperSetting = false;
|
||||
for (int k = 0; k < child.getChildCount(); k++) {
|
||||
final InspectionConfigTreeNode descriptorNode = (InspectionConfigTreeNode)child.getChildAt(k);
|
||||
if (descriptorNode.getUserObject() instanceof Descriptor) {
|
||||
updateErrorLevel(descriptorNode, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
child.isProperSetting |= descriptorNode.isProperSetting;
|
||||
}
|
||||
}
|
||||
node.isProperSetting |= child.isProperSetting;
|
||||
}
|
||||
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node);
|
||||
updateUpHierarchy(node, parent);
|
||||
}
|
||||
}
|
||||
@@ -1083,6 +1067,23 @@ public class SingleInspectionProfilePanel extends JPanel {
|
||||
repaintTableData();
|
||||
}
|
||||
|
||||
private void updateErrorLevelUpInHierarchy(HighlightDisplayLevel level,
|
||||
boolean showOptionsAndDescriptorPanels,
|
||||
InspectionConfigTreeNode node) {
|
||||
node.isProperSetting = false;
|
||||
for (int j = 0; j < node.getChildCount(); j++) {
|
||||
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
|
||||
final Object userObject = child.getUserObject();
|
||||
if (userObject instanceof Descriptor && (child.getScopeName() != null || child.isLeaf())) {
|
||||
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
|
||||
}
|
||||
else {
|
||||
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, child);
|
||||
}
|
||||
node.isProperSetting |= child.isProperSetting;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateErrorLevel(final InspectionConfigTreeNode child,
|
||||
final boolean showOptionsAndDescriptorPanels, final HighlightDisplayLevel level) {
|
||||
final HighlightDisplayKey key = child.getDesriptor().getKey();
|
||||
|
||||
+29
-14
@@ -59,13 +59,11 @@ public abstract class AddScopeAction extends AnAction {
|
||||
if (getSelectedProfile() == null) return;
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) return;
|
||||
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
if (selectedNodes == null) return;
|
||||
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
for (InspectionConfigTreeNode node : nodes) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (descriptor != null && node.getScopeName() == null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
for (InspectionConfigTreeNode node : selectedNodes) {
|
||||
collect(descriptors, new ArrayList<InspectionConfigTreeNode>(), node);
|
||||
}
|
||||
|
||||
presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty());
|
||||
@@ -73,13 +71,13 @@ public abstract class AddScopeAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
for (InspectionConfigTreeNode node : nodes) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (node.getScopeName() == null && descriptor != null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
|
||||
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
|
||||
LOG.assertTrue(selectedNodes != null);
|
||||
|
||||
final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>(Arrays.asList(selectedNodes));
|
||||
for (InspectionConfigTreeNode node : selectedNodes) {
|
||||
collect(descriptors, nodes, node);
|
||||
}
|
||||
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
@@ -97,7 +95,7 @@ public abstract class AddScopeAction extends AnAction {
|
||||
getSelectedProfile().isToolEnabled(descriptor.getKey()));
|
||||
final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile());
|
||||
if (node.getChildCount() == 0) {
|
||||
node.add(new InspectionConfigTreeNode(descriptor, scopeToolState, true, true, false));
|
||||
node.add(new InspectionConfigTreeNode(descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().getID()), true, true, false));
|
||||
}
|
||||
node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, true, false), 0);
|
||||
node.setInspectionNode(false);
|
||||
@@ -108,6 +106,23 @@ public abstract class AddScopeAction extends AnAction {
|
||||
myTree.revalidate();
|
||||
}
|
||||
|
||||
private static void collect(List<Descriptor> descriptors,
|
||||
List<InspectionConfigTreeNode> nodes,
|
||||
InspectionConfigTreeNode node) {
|
||||
final Descriptor descriptor = node.getDesriptor();
|
||||
if (descriptor != null) {
|
||||
if (node.getScopeName() == null) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
} else if (node.getUserObject() instanceof String) {
|
||||
for(int i = 0; i < node.getChildCount(); i++) {
|
||||
final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i);
|
||||
nodes.add(childNode);
|
||||
collect(descriptors, nodes, childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) {
|
||||
final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
|
||||
for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
|
||||
|
||||
Reference in New Issue
Block a user