mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 01:35:39 +02:00
Patch for Devin Steffler.
Added filter for AST view for problems.
This commit is contained in:
parent
24d6abba7f
commit
761524840a
6 changed files with 100 additions and 21 deletions
|
@ -93,6 +93,17 @@
|
|||
</visibility>
|
||||
</viewerContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.cdt.ui.CElementFilters">
|
||||
<filter
|
||||
targetId="org.eclipse.cdt.ui.tests.DOMAST.DOMASTFilterGroup"
|
||||
name="Problem Filter"
|
||||
enabled="false"
|
||||
description="Filter Problems"
|
||||
class="org.eclipse.cdt.ui.tests.DOMAST.ProblemHolderFilter"
|
||||
id="org.eclipse.cdt.ui.tests.DOMAST.DOMAST.ProblemHolderFilter">
|
||||
</filter>
|
||||
</extension>
|
||||
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
|
@ -67,12 +68,16 @@ public class CPPPopulateASTViewAction extends CPPBaseVisitorAction implements IP
|
|||
|
||||
TreeParent parent = root.findParentOfNode(node);
|
||||
|
||||
if ( parent != null ) {
|
||||
parent.addChild(new TreeParent(node));
|
||||
} else {
|
||||
root.addChild(new TreeParent(node));
|
||||
}
|
||||
if (parent == null)
|
||||
parent = root;
|
||||
|
||||
TreeParent tree = new TreeParent(node);
|
||||
parent.addChild(tree);
|
||||
|
||||
if (node instanceof IASTProblemHolder)
|
||||
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
|
||||
if (node instanceof IASTProblem)
|
||||
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -25,11 +25,11 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction;
|
||||
|
@ -69,12 +69,16 @@ public class CPopulateASTViewAction extends CBaseVisitorAction implements IPopul
|
|||
|
||||
TreeParent parent = root.findParentOfNode(node);
|
||||
|
||||
if ( parent != null ) {
|
||||
parent.addChild(new TreeParent(node));
|
||||
} else {
|
||||
root.addChild(new TreeParent(node));
|
||||
}
|
||||
if (parent == null)
|
||||
parent = root;
|
||||
|
||||
TreeParent tree = new TreeParent(node);
|
||||
parent.addChild(tree);
|
||||
|
||||
if (node instanceof IASTProblemHolder)
|
||||
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
|
||||
if (node instanceof IASTProblem)
|
||||
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -106,6 +107,7 @@ import org.eclipse.ui.part.ViewPart;
|
|||
*/
|
||||
|
||||
public class DOMAST extends ViewPart {
|
||||
private static final String DOMAST_FILTER_GROUP_ID = "org.eclipse.cdt.ui.tests.DOMAST.DOMASTFilterGroup"; //$NON-NLS-1$
|
||||
private static final String EXTENSION_CXX = "CXX"; //$NON-NLS-1$
|
||||
private static final String EXTENSION_CPP = "CPP"; //$NON-NLS-1$
|
||||
private static final String EXTENSION_CC = "CC"; //$NON-NLS-1$
|
||||
|
@ -132,6 +134,8 @@ private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1
|
|||
private IEditorPart part = null;
|
||||
private ParserLanguage lang = null;
|
||||
|
||||
private CustomFiltersActionGroup customFiltersActionGroup;
|
||||
|
||||
/*
|
||||
* The content provider class is responsible for providing objects to the
|
||||
* view. It can wrap existing objects in adapters or simply return objects
|
||||
|
@ -338,6 +342,8 @@ private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1
|
|||
makeActions();
|
||||
hookContextMenu();
|
||||
hookSingleClickAction();
|
||||
|
||||
customFiltersActionGroup = new CustomFiltersActionGroup(DOMAST_FILTER_GROUP_ID, viewer);
|
||||
contributeToActionBars();
|
||||
}
|
||||
|
||||
|
@ -379,6 +385,7 @@ private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1
|
|||
IActionBars bars = getViewSite().getActionBars();
|
||||
fillLocalPullDown(bars.getMenuManager());
|
||||
fillLocalToolBar(bars.getToolBarManager());
|
||||
customFiltersActionGroup.fillActionBars(bars);
|
||||
}
|
||||
|
||||
private void fillLocalPullDown(IMenuManager manager) {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Canada and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.DOMAST;
|
||||
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class ProblemHolderFilter extends ViewerFilter {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (element instanceof TreeObject) {
|
||||
int flag = ((TreeObject)element).getFiltersFlag() & TreeObject.FLAG_PROBLEM;
|
||||
if (flag != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -107,6 +107,11 @@ public class TreeObject implements IAdaptable {
|
|||
private IASTNode node = null;
|
||||
private TreeParent parent;
|
||||
|
||||
// used for applying filters to the tree, since it is lazily populated
|
||||
// all parents of the desired tree object to display need to have a flag as well
|
||||
private int filterFlag = 0;
|
||||
public static final int FLAG_PROBLEM = 0x1;
|
||||
|
||||
public TreeObject(IASTNode node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
@ -469,4 +474,16 @@ public class TreeObject implements IAdaptable {
|
|||
return location[0].getNodeLength();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setFiltersFlag(int flag) {
|
||||
filterFlag |= flag;
|
||||
|
||||
if (parent != null ) {
|
||||
parent.setFiltersFlag(flag);
|
||||
}
|
||||
}
|
||||
|
||||
public int getFiltersFlag() {
|
||||
return filterFlag;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue