Skip to content

Commit 96d6e61

Browse files
committed
Added configuration options
1 parent 725809f commit 96d6e61

File tree

3 files changed

+108
-5
lines changed

3 files changed

+108
-5
lines changed

META-INF/plugin.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<li>Add diff view popup which shows the differences with the previous version of bytecode</li>
1212
<li>Search in every output directory, including test files</li>
1313
<li>Support for Groovy @groovyx.ast.bytecode.Bytecode annotation</li>
14+
<li>Configuration of ASM ClassReader flags</li>
15+
<li>Configuration of Groovy code style</li>
1416
</ul>
1517
<b>Version 0.2</b>
1618
<ul>
@@ -22,10 +24,14 @@
2224
]]></change-notes>
2325

2426
<application-components>
27+
2528
</application-components>
2629

2730
<project-components>
28-
</project-components>
31+
<component>
32+
<implementation-class>org.objectweb.asm.idea.config.ASMPluginComponent</implementation-class>
33+
</component>
34+
</project-components>
2935

3036
<actions>
3137
<action id="showBytecodeOutline" class="org.objectweb.asm.idea.ShowBytecodeOutlineAction"

src/org/objectweb/asm/idea/ShowBytecodeOutlineAction.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,26 @@
3232
import com.intellij.openapi.fileEditor.FileDocumentManager;
3333
import com.intellij.openapi.module.Module;
3434
import com.intellij.openapi.module.ModuleUtil;
35+
import com.intellij.openapi.options.Configurable;
36+
import com.intellij.openapi.options.ConfigurationException;
3537
import com.intellij.openapi.project.Project;
3638
import com.intellij.openapi.roots.CompilerModuleExtension;
3739
import com.intellij.openapi.util.Computable;
40+
import com.intellij.openapi.util.IconLoader;
3841
import com.intellij.openapi.vfs.VirtualFile;
3942
import com.intellij.openapi.wm.ToolWindowManager;
4043
import com.intellij.psi.*;
4144
import com.intellij.psi.codeStyle.CodeStyleManager;
45+
import org.jetbrains.annotations.Nls;
4246
import org.objectweb.asm.Attribute;
4347
import org.objectweb.asm.ClassReader;
4448
import org.objectweb.asm.ClassVisitor;
49+
import org.objectweb.asm.idea.config.ASMPluginComponent;
50+
import org.objectweb.asm.idea.config.ASMPluginConfiguration;
4551
import org.objectweb.asm.util.ASMifierClassVisitor;
4652
import org.objectweb.asm.util.TraceClassVisitor;
4753

54+
import javax.swing.*;
4855
import java.io.IOException;
4956
import java.io.PrintWriter;
5057
import java.io.StringWriter;
@@ -200,15 +207,22 @@ public void run() {
200207
} catch (IOException e) {
201208
return;
202209
}
203-
reader.accept(visitor, new Attribute[0], 0);
210+
int flags = 0;
211+
final ASMPluginComponent config = project.getComponent(ASMPluginComponent.class);
212+
if (config.isSkipDebug()) flags = flags | ClassReader.SKIP_DEBUG;
213+
if (config.isSkipFrames()) flags = flags | ClassReader.SKIP_FRAMES;
214+
if (config.isSkipCode()) flags = flags | ClassReader.EXPAND_FRAMES;
215+
if (config.isSkipCode()) flags = flags | ClassReader.SKIP_CODE;
216+
217+
reader.accept(visitor, flags);
204218
BytecodeOutline.getInstance(project).setCode(file,stringWriter.toString());
205219
stringWriter.getBuffer().setLength(0);
206220
visitor = new GroovifiedTraceVisitor(new PrintWriter(stringWriter));
207-
reader.accept(visitor, 0);
221+
reader.accept(visitor, ClassReader.SKIP_FRAMES|ClassReader.SKIP_DEBUG);
208222
GroovifiedView.getInstance(project).setCode(file,stringWriter.toString());
209223
stringWriter.getBuffer().setLength(0);
210224
visitor = new ASMifierClassVisitor(new PrintWriter(stringWriter));
211-
reader.accept(visitor, ClassReader.SKIP_FRAMES|ClassReader.SKIP_DEBUG|ClassReader.SKIP_CODE);
225+
reader.accept(visitor, flags);
212226
final BytecodeASMified asmified = BytecodeASMified.getInstance(project);
213227
PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("asm.java", stringWriter.toString());
214228
CodeStyleManager.getInstance(project).reformat(psiFile);
@@ -217,5 +231,4 @@ public void run() {
217231
}
218232
});
219233
}
220-
221234
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.objectweb.asm.idea.config.ASMPluginConfiguration">
3+
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="10" left="10" bottom="10" right="10"/>
5+
<constraints>
6+
<xy x="48" y="54" width="436" height="297"/>
7+
</constraints>
8+
<properties/>
9+
<border type="none"/>
10+
<children>
11+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
12+
<margin top="0" left="0" bottom="0" right="0"/>
13+
<constraints>
14+
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
15+
</constraints>
16+
<properties/>
17+
<border type="none"/>
18+
<children>
19+
<component id="908f9" class="javax.swing.JCheckBox" binding="skipDebugCheckBox" default-binding="true">
20+
<constraints>
21+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
22+
</constraints>
23+
<properties>
24+
<text value="Skip debug"/>
25+
</properties>
26+
</component>
27+
<component id="76b4c" class="javax.swing.JCheckBox" binding="skipFramesCheckBox" default-binding="true">
28+
<constraints>
29+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
30+
</constraints>
31+
<properties>
32+
<text value="Skip frames"/>
33+
</properties>
34+
</component>
35+
<component id="8887b" class="javax.swing.JCheckBox" binding="skipCodeCheckBox" default-binding="true">
36+
<constraints>
37+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
38+
</constraints>
39+
<properties>
40+
<text value="Skip code"/>
41+
</properties>
42+
</component>
43+
<component id="72fde" class="javax.swing.JCheckBox" binding="expandFramesCheckBox" default-binding="true">
44+
<constraints>
45+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
46+
</constraints>
47+
<properties>
48+
<text value="Expand frames"/>
49+
</properties>
50+
</component>
51+
<grid id="562b9" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
52+
<margin top="0" left="0" bottom="0" right="0"/>
53+
<constraints>
54+
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
55+
</constraints>
56+
<properties/>
57+
<border type="none"/>
58+
<children>
59+
<component id="a7d13" class="javax.swing.JLabel">
60+
<constraints>
61+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
62+
</constraints>
63+
<properties>
64+
<text value="Groovy code style"/>
65+
</properties>
66+
</component>
67+
<component id="afc8c" class="javax.swing.JComboBox" binding="groovyCodeStyleComboBox" custom-create="true">
68+
<constraints>
69+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
70+
</constraints>
71+
<properties/>
72+
</component>
73+
</children>
74+
</grid>
75+
</children>
76+
</grid>
77+
<vspacer id="679f2">
78+
<constraints>
79+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
80+
</constraints>
81+
</vspacer>
82+
</children>
83+
</grid>
84+
</form>

0 commit comments

Comments
 (0)