Commit efb1104d authored by ekuleshov's avatar ekuleshov

implemented hide/expand StackMap

reworked preference page
parent d64f898e
......@@ -22,28 +22,17 @@ BytecodeOutlineView.toggle.automatic.label=&Automatic View Orientation
BytecodeReferenceView.empty.selection.text=<html><head><title>Bytecode reference</title></head><body bgcolor='#D3D3D3'>Please select any bytecode instruction in the bytecode outline view.</body></html>
BCOPreferencePage.defaultsGroup=Default selections for Bytecode Outline view
BCOPreferencePage.expandStackMap=Expand stack map
BCOPreferencePage.recalculateStackMap=Recalculate stack map
BCOPreferencePage.showVariables=Show Variables
BCOPreferencePage.showLineInfo=Show line info
BCOPreferencePage.showRawBytecode=Show raw bytecode
BCOPreferencePage.showStackMap=Show stack map
BCOPreferencePage.expandStackMap=Expand stack map
BCOPreferencePage.recalculateStackMap=Recalculate stack map
BCOPreferencePage.showRawBytecode=Show internal types
BCOPreferencePage.showAnalyzer=Show analyzer pane
BCOPreferencePage.showAsmifierCode=Show ASMifier code
BCOPreferencePage.showOnlySelected=Show bytecode for selected element only
BCOPreferencePage.linkViewToEditor=Link bytecode view to editor
#TODO add meaningful tooltips for default settings checkboxes
BCOPreferencePage.defaultsGroupTip=Default selections for Bytecode Outline view
BCOPreferencePage.expandStackMapTip=Expand stack map
BCOPreferencePage.recalculateStackMapTip=Recalculate stack map
BCOPreferencePage.showVariablesTip=Show Variables
BCOPreferencePage.showLineInfoTip=Show line info
BCOPreferencePage.showRawBytecodeTip=Show raw bytecode
BCOPreferencePage.showAnalyzerTip=Show analyzer pane
BCOPreferencePage.showAsmifierCodeTip=Show ASMifier code
BCOPreferencePage.showOnlySelectedTip=Show bytecode for selected element only
BCOPreferencePage.linkViewToEditorTip=Link bytecode view to editor
action.showVariables.text=Show local variables
action.showVariables.toolTipText=Show local variables (if available in bytecode)
action.showVariables.image=icons/hide_locals.gif
......@@ -52,6 +41,14 @@ action.showLineInfo.text=Show line info
action.showLineInfo.toolTipText=Show line info (if available in bytecode)
action.showLineInfo.image=icons/hide_line_info.gif
action.showStackmap.text=Show StackMap
action.showStackmap.toolTipText=Show StackMap info (if available in bytecode)
action.showStackmap.image=icons/stackmap.gif
action.expandStackmap.text=Expand StackMap
action.expandStackmap.toolTipText=Expand StackMap frames (if StackMap is available in bytecode)
action.expandStackmap.image=icons/stackmapexp.gif
action.showASMifierCode.text=Toggle ASMifier mode on/off
action.showASMifierCode.toolTipText=Show ASMified code
action.showASMifierCode.image=icons/asm.gif
......@@ -61,7 +58,7 @@ action.showAnalyzer.toolTipText=Show state of the execution stack frames
action.showAnalyzer.image=icons/verify.gif
action.showRawBytecode.text=Show readable bytecode
action.showRawBytecode.toolTipText=Post-process decompiled bytecode for humans
action.showRawBytecode.toolTipText=Show internal types
action.showRawBytecode.image=icons/raw_mode.gif
action.showOnlySelectedElement.text=Show current element only
......
......@@ -54,6 +54,10 @@ public class DecompilerClassVisitor extends ClassAdapter {
final String field, final String method, final BitSet modes, final ClassLoader cl)
throws IOException {
ClassReader cr = new ClassReader(is);
int crFlags = 0;
if(modes.get(BCOConstants.F_EXPAND_STACKMAP)) {
crFlags |= ClassReader.EXPAND_FRAMES;
}
ClassVisitor cv;
if (modes.get(BCOConstants.F_SHOW_ASMIFIER_CODE)) {
cv = new ASMifierClassVisitor(null) {
......@@ -90,12 +94,19 @@ public class DecompilerClassVisitor extends ClassAdapter {
}
}
public void visitLabel(Label label) {
// TODO Auto-generated method stub
super.visitLabel(label);
}
public void visitFrame(int type, int nLocal,
Object[] local, int nStack, Object[] stack) {
if (modes.get(BCOConstants.F_SHOW_STACKMAP)) {
super.visitFrame(
type, nLocal, local, nStack, stack);
}
}
};
}
}, 0);
}, crFlags);
return dcv.getResult(cl);
}
......
......@@ -44,6 +44,8 @@ public class BytecodeCompare extends CompareEditorInput {
protected Action hideLineInfoAction;
/** Action used in compare view/bytecode view to hide/show local variables. */
protected Action hideLocalsAction;
protected Action hideStackMapAction;
protected Action expandStackMapAction;
protected IReusableEditor myEditor;
......@@ -89,6 +91,30 @@ public class BytecodeCompare extends CompareEditorInput {
}
}
});
hideStackMapAction = new DefaultToggleAction(BCOConstants.SHOW_STACKMAP,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_SHOW_STACKMAP,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
expandStackMapAction = new DefaultToggleAction(BCOConstants.EXPAND_STACKMAP,
new IPropertyChangeListener(){
public void propertyChange(PropertyChangeEvent event) {
if(IAction.CHECKED.equals(event.getProperty())){
toggleMode(
BCOConstants.F_EXPAND_STACKMAP,
Boolean.TRUE == event.getNewValue(),
toggleAsmifierModeAction.isChecked());
}
}
});
}
/** @see CompareEditorInput#prepareInput(IProgressMonitor) */
......@@ -179,6 +205,24 @@ public class BytecodeCompare extends CompareEditorInput {
toolBarManager2.insertBefore("bco", hideLocalsAction); //$NON-NLS-1$
toolBarManager2.update(true);
}
if (toolBarManager2.find(hideStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", hideStackMapAction); //$NON-NLS-1$
toolBarManager2.update(true);
}
if (toolBarManager2.find(expandStackMapAction.getId()) == null) {
if(!separatorExist) {
separatorExist = true;
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
}
toolBarManager2.insertBefore("bco", expandStackMapAction); //$NON-NLS-1$
toolBarManager2.update(true);
}
if (toolBarManager2.find(toggleAsmifierModeAction.getId()) == null) {
if(!separatorExist) {
toolBarManager2.insert(0, new Separator("bco")); //$NON-NLS-1$
......
......@@ -47,12 +47,17 @@ public interface BCOConstants {
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG)
*/
String RECALCULATE_STACKMAP = "recalculateStackmap";
String SHOW_STACKMAP = "showStackmap";
/**
* expand stackmap frames
*/
String EXPAND_STACKMAP = "expandStackmap";
/**
* recalculate stackmap (to see computed frames, works for all classes even before MUSTANG)
*/
String RECALCULATE_STACKMAP = "recalculateStackmap";
/**
* show "analyzer" - LVT and stack tables (for current bytecode selection)
......@@ -69,5 +74,6 @@ public interface BCOConstants {
int F_RECALCULATE_STACKMAP = 6;
int F_EXPAND_STACKMAP = 7;
int F_SHOW_ANALYZER = 8;
int F_SHOW_STACKMAP = 9;
}
......@@ -24,15 +24,20 @@ public class BCOPreferenceInitializer extends AbstractPreferenceInitializer {
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
store.setDefault(BCOConstants.EXPAND_STACKMAP, false);
store.setDefault(BCOConstants.LINK_VIEW_TO_EDITOR, true);
store.setDefault(BCOConstants.RECALCULATE_STACKMAP, false);
store.setDefault(BCOConstants.SHOW_ASMIFIER_CODE, false);
store.setDefault(BCOConstants.SHOW_ANALYZER, false);
store.setDefault(BCOConstants.SHOW_LINE_INFO, true);
store.setDefault(BCOConstants.SHOW_ONLY_SELECTED_ELEMENT, true);
store.setDefault(BCOConstants.SHOW_RAW_BYTECODE, false);
store.setDefault(BCOConstants.SHOW_ASMIFIER_CODE, false);
store.setDefault(BCOConstants.SHOW_ANALYZER, false);
store.setDefault(BCOConstants.SHOW_VARIABLES, true);
store.setDefault(BCOConstants.SHOW_LINE_INFO, true);
store.setDefault(BCOConstants.SHOW_STACKMAP, true);
store.setDefault(BCOConstants.EXPAND_STACKMAP, false);
store.setDefault(BCOConstants.RECALCULATE_STACKMAP, false);
}
}
......@@ -95,6 +95,8 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
modes.set(BCOConstants.F_SHOW_VARIABLES, store.getBoolean(BCOConstants.SHOW_VARIABLES));
modes.set(BCOConstants.F_SHOW_ASMIFIER_CODE, store.getBoolean(BCOConstants.SHOW_ASMIFIER_CODE));
modes.set(BCOConstants.F_SHOW_ANALYZER, store.getBoolean(BCOConstants.SHOW_ANALYZER));
modes.set(BCOConstants.F_SHOW_STACKMAP, store.getBoolean(BCOConstants.SHOW_STACKMAP));
modes.set(BCOConstants.F_EXPAND_STACKMAP, store.getBoolean(BCOConstants.EXPAND_STACKMAP));
return modes;
}
......
......@@ -151,6 +151,8 @@ public class BytecodeOutlineView extends ViewPart {
protected Action toggleASMifierModeAction;
protected Action hideLineInfoAction;
protected Action hideLocalsAction;
protected Action hideStackMapAction;
protected Action expandStackMapAction;
protected Action toggleVerifierAction;
protected StatusLineManager statusLineManager;
protected BCOViewSelectionProvider viewSelectionProvider;
......@@ -227,6 +229,7 @@ public class BytecodeOutlineView extends ViewPart {
toggleVerifierAction.setEnabled(on);
hideLocalsAction.setEnabled(on);
hideLineInfoAction.setEnabled(on);
hideStackMapAction.setEnabled(on);
toggleASMifierModeAction.setEnabled(on);
if(on && !toggleASMifierModeAction.isChecked()) {
setRawModeAction.setEnabled(true);
......@@ -373,6 +376,8 @@ public class BytecodeOutlineView extends ViewPart {
modes.set(BCOConstants.F_SHOW_RAW_BYTECODE, store.getBoolean(BCOConstants.SHOW_RAW_BYTECODE));
modes.set(BCOConstants.F_SHOW_LINE_INFO, store.getBoolean(BCOConstants.SHOW_LINE_INFO));
modes.set(BCOConstants.F_SHOW_VARIABLES, store.getBoolean(BCOConstants.SHOW_VARIABLES));
modes.set(BCOConstants.F_SHOW_STACKMAP, store.getBoolean(BCOConstants.SHOW_STACKMAP));
modes.set(BCOConstants.F_EXPAND_STACKMAP, store.getBoolean(BCOConstants.EXPAND_STACKMAP));
modes.set(BCOConstants.F_SHOW_ASMIFIER_CODE, store.getBoolean(BCOConstants.SHOW_ASMIFIER_CODE));
modes.set(BCOConstants.F_SHOW_ANALYZER, store.getBoolean(BCOConstants.SHOW_ANALYZER));
}
......@@ -463,6 +468,28 @@ public class BytecodeOutlineView extends ViewPart {
}
});
hideStackMapAction = new DefaultToggleAction(BCOConstants.SHOW_STACKMAP,
new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (IAction.CHECKED.equals(event.getProperty())) {
modes.set(BCOConstants.F_SHOW_STACKMAP, Boolean.TRUE == event.getNewValue());
inputChanged = true;
refreshView();
}
}
});
expandStackMapAction = new DefaultToggleAction(BCOConstants.EXPAND_STACKMAP,
new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (IAction.CHECKED.equals(event.getProperty())) {
modes.set(BCOConstants.F_EXPAND_STACKMAP, Boolean.TRUE == event.getNewValue());
inputChanged = true;
refreshView();
}
}
});
toggleASMifierModeAction = new DefaultToggleAction(BCOConstants.SHOW_ASMIFIER_CODE,
new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
......@@ -514,6 +541,8 @@ public class BytecodeOutlineView extends ViewPart {
mmanager.add(setRawModeAction);
mmanager.add(hideLineInfoAction);
mmanager.add(hideLocalsAction);
mmanager.add(hideStackMapAction);
mmanager.add(expandStackMapAction);
mmanager.add(toggleASMifierModeAction);
mmanager.add(toggleVerifierAction);
......@@ -530,8 +559,8 @@ public class BytecodeOutlineView extends ViewPart {
tmanager.add(linkWithEditorAction);
tmanager.add(showSelectedOnlyAction);
tmanager.add(setRawModeAction);
tmanager.add(hideLineInfoAction);
tmanager.add(hideLocalsAction);
// tmanager.add(hideLineInfoAction);
// tmanager.add(hideLocalsAction);
tmanager.add(toggleASMifierModeAction);
tmanager.add(toggleVerifierAction);
}
......@@ -717,6 +746,8 @@ public class BytecodeOutlineView extends ViewPart {
toggleASMifierModeAction = null;
hideLineInfoAction = null;
hideLocalsAction = null;
hideStackMapAction = null;
expandStackMapAction = null;
toggleVerifierAction = null;
lastDecompiledResult = null;
super.dispose();
......
Markdown is supported
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