mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Devin Steffler.
Further updates to DOM AST View.
This commit is contained in:
parent
e6868902c5
commit
493b29d4e4
5 changed files with 62 additions and 22 deletions
BIN
core/org.eclipse.cdt.ui.tests/icons/used/collapseall.gif
Normal file
BIN
core/org.eclipse.cdt.ui.tests/icons/used/collapseall.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 157 B |
BIN
core/org.eclipse.cdt.ui.tests/icons/used/expandall.gif
Normal file
BIN
core/org.eclipse.cdt.ui.tests/icons/used/expandall.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 B |
|
@ -98,20 +98,24 @@ import org.eclipse.ui.part.ViewPart;
|
|||
*/
|
||||
|
||||
public class DOMAST extends ViewPart {
|
||||
private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1$
|
||||
private static final String COLLAPSE_ALL = "Collapse ALL"; //$NON-NLS-1$
|
||||
private static final String EXPAND_ALL = "Expand All"; //$NON-NLS-1$
|
||||
private static final String REFRESH_DOM_AST = "Refresh DOM AST"; //$NON-NLS-1$
|
||||
private static final String VIEW_NAME = "DOM View"; //$NON-NLS-1$
|
||||
private static final String POPUPMENU = "#PopupMenu"; //$NON-NLS-1$
|
||||
private static final String OPEN_DECLARATIONS = "Open Declarations"; //$NON-NLS-1$
|
||||
private static final String OPEN_REFERENCES = "Open References"; //$NON-NLS-1$
|
||||
TreeViewer viewer;
|
||||
private DrillDownAdapter drillDownAdapter;
|
||||
private Action action1;
|
||||
private Action action2;
|
||||
Action singleClickAction;
|
||||
private Action openDeclarationsAction;
|
||||
private Action openReferencesAction;
|
||||
private Action singleClickAction;
|
||||
private Action refreshAction;
|
||||
IFile file = null;
|
||||
private Action expandAllAction;
|
||||
private Action collapseAllAction;
|
||||
private IFile file = null;
|
||||
private IEditorPart part = null;
|
||||
ParserLanguage lang = null;
|
||||
private ParserLanguage lang = null;
|
||||
|
||||
/*
|
||||
* The content provider class is responsible for providing objects to the
|
||||
|
@ -363,8 +367,8 @@ public class DOMAST extends ViewPart {
|
|||
}
|
||||
|
||||
void fillContextMenu(IMenuManager manager) {
|
||||
manager.add(action1);
|
||||
manager.add(action2);
|
||||
manager.add(openDeclarationsAction);
|
||||
manager.add(openReferencesAction);
|
||||
manager.add(new Separator());
|
||||
drillDownAdapter.addNavigationActions(manager);
|
||||
// Other plug-ins can contribute there actions here
|
||||
|
@ -372,46 +376,73 @@ public class DOMAST extends ViewPart {
|
|||
}
|
||||
|
||||
private void fillLocalToolBar(IToolBarManager manager) {
|
||||
manager.add(refreshAction);
|
||||
manager.add(expandAllAction);
|
||||
manager.add(collapseAllAction);
|
||||
manager.add(refreshAction);
|
||||
manager.add(new Separator());
|
||||
drillDownAdapter.addNavigationActions(manager);
|
||||
}
|
||||
|
||||
private void makeActions() {
|
||||
refreshAction = new Action() {
|
||||
refreshAction = new Action() {
|
||||
public void run() {
|
||||
setContentProvider(new ViewContentProvider(file));
|
||||
// TODO take a snapshot of the tree expansion
|
||||
|
||||
|
||||
// set the new content provider
|
||||
setContentProvider(new ViewContentProvider(file));
|
||||
|
||||
// TODO set the expansion of the view based on the original snapshot (educated guess)
|
||||
|
||||
}
|
||||
};
|
||||
refreshAction.setText(REFRESH_DOM_AST);
|
||||
refreshAction.setToolTipText(REFRESH_DOM_AST);
|
||||
refreshAction.setImageDescriptor(DOMASTPluginImages.DESC_IASTInitializer);
|
||||
|
||||
action1 = new Action() {
|
||||
expandAllAction = new Action() {
|
||||
public void run() {
|
||||
viewer.expandAll();
|
||||
}
|
||||
};
|
||||
expandAllAction.setText(EXPAND_ALL);
|
||||
expandAllAction.setToolTipText(EXPAND_ALL);
|
||||
expandAllAction.setImageDescriptor(DOMASTPluginImages.DESC_EXPAND_ALL);
|
||||
|
||||
collapseAllAction = new Action() {
|
||||
public void run() {
|
||||
viewer.collapseAll();
|
||||
}
|
||||
};
|
||||
collapseAllAction.setText(COLLAPSE_ALL);
|
||||
collapseAllAction.setToolTipText(COLLAPSE_ALL);
|
||||
collapseAllAction.setImageDescriptor(DOMASTPluginImages.DESC_COLLAPSE_ALL);
|
||||
|
||||
openDeclarationsAction = new Action() {
|
||||
public void run() {
|
||||
showMessage("Action 1 executed"); // TODO open declarations action //$NON-NLS-1$
|
||||
// ... use annotations
|
||||
}
|
||||
};
|
||||
action1.setText(OPEN_DECLARATIONS);
|
||||
action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
|
||||
openDeclarationsAction.setText(OPEN_DECLARATIONS);
|
||||
openDeclarationsAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
|
||||
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
|
||||
|
||||
action2 = new Action() {
|
||||
openReferencesAction = new Action() {
|
||||
public void run() {
|
||||
showMessage("Action 2 executed"); // TODO open references action ... //$NON-NLS-1$
|
||||
// use annotations
|
||||
}
|
||||
};
|
||||
action2.setText(OPEN_REFERENCES);
|
||||
action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
|
||||
openReferencesAction.setText(OPEN_REFERENCES);
|
||||
openReferencesAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
|
||||
.getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
|
||||
|
||||
singleClickAction = new ASTHighlighterAction(part);
|
||||
}
|
||||
|
||||
private class ASTHighlighterAction extends Action {
|
||||
IEditorPart aPart = null;
|
||||
IEditorPart aPart = null;
|
||||
|
||||
public ASTHighlighterAction(IEditorPart part) {
|
||||
this.aPart = part;
|
||||
|
@ -441,6 +472,10 @@ public class DOMAST extends ViewPart {
|
|||
Object obj = ((IStructuredSelection) selection).getFirstElement();
|
||||
if (aPart instanceof CEditor && obj instanceof TreeObject) {
|
||||
String filename = ((TreeObject) obj).getFilename();
|
||||
|
||||
if (filename.equals(TreeObject.BLANK_FILENAME))
|
||||
return;
|
||||
|
||||
IResource r = ParserUtil.getResourceForFilename(filename);
|
||||
if (r != null) {
|
||||
try {
|
||||
|
|
|
@ -72,6 +72,8 @@ public class DOMASTPluginImages {
|
|||
public static final String IMG_ICPPASTConstructorChainInitializer = NAME_PREFIX + "jump_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_ICPPASTTemplateParameter = NAME_PREFIX + "disassembly.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_DEFAULT = NAME_PREFIX + "brkpd_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_EXPAND_ALL = NAME_PREFIX + "expandall.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final ImageDescriptor DESC_IASTArrayModifier= createManaged(ICON_PREFIX, IMG_IASTArrayModifier);
|
||||
public static final ImageDescriptor DESC_IASTDeclaration= createManaged(ICON_PREFIX, IMG_IASTDeclaration);
|
||||
|
@ -93,6 +95,8 @@ public class DOMASTPluginImages {
|
|||
public static final ImageDescriptor DESC_ICPPASTConstructorChainInitializer= createManaged(ICON_PREFIX, IMG_ICPPASTConstructorChainInitializer);
|
||||
public static final ImageDescriptor DESC_ICPPASTTemplateParameter= createManaged(ICON_PREFIX, IMG_ICPPASTTemplateParameter);
|
||||
public static final ImageDescriptor DESC_DEFAULT= createManaged(ICON_PREFIX, IMG_DEFAULT);
|
||||
public static final ImageDescriptor DESC_EXPAND_ALL= createManaged(ICON_PREFIX, IMG_EXPAND_ALL);
|
||||
public static final ImageDescriptor DESC_COLLAPSE_ALL= createManaged(ICON_PREFIX, IMG_COLLAPSE_ALL);
|
||||
|
||||
private static ImageDescriptor createManaged(String prefix, String name) {
|
||||
return createManaged(imageRegistry, prefix, name);
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IAdaptable;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class TreeObject implements IAdaptable {
|
||||
public static final String BLANK_FILENAME = ""; //$NON-NLS-1$
|
||||
private static final String IGCCAST_PREFIX = "IGCCAST"; //$NON-NLS-1$
|
||||
private static final String IGNUAST_PREFIX = "IGNUAST"; //$NON-NLS-1$
|
||||
private static final String IGPPAST_PREFIX = "IGPPAST"; //$NON-NLS-1$
|
||||
|
@ -59,7 +60,7 @@ public class TreeObject implements IAdaptable {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
if( node == null ) return ""; //$NON-NLS-1$ //TODO Devin is this the best way???
|
||||
if( node == null ) return BLANK_FILENAME; //$NON-NLS-1$ //TODO Devin is this the best way???
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
Class[] classes = node.getClass().getInterfaces();
|
||||
|
@ -85,11 +86,11 @@ public class TreeObject implements IAdaptable {
|
|||
|
||||
public String getFilename()
|
||||
{
|
||||
if ( node == null ) return ""; //$NON-NLS-1$
|
||||
if ( node == null ) return BLANK_FILENAME;
|
||||
IASTNodeLocation [] location = node.getNodeLocations();
|
||||
if( location[0] instanceof IASTFileLocation )
|
||||
if( location.length > 0 && location[0] instanceof IASTFileLocation )
|
||||
return ((IASTFileLocation)location[0]).getFileName();
|
||||
return ""; //$NON-NLS-1$
|
||||
return BLANK_FILENAME; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
|
|
Loading…
Add table
Reference in a new issue