Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric committed Jan 8, 2011
0 parents commit e639832
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ASM-BO.iml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="IDEA IU-99.32" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/asm-debug-all-3.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

30 changes: 30 additions & 0 deletions META-INF/plugin.xml
@@ -0,0 +1,30 @@
<idea-plugin version="2">
<name>ASM Bytecode Outline</name>
<description>Displays bytecode for Java classes and ASM code for generating them.</description>
<version>0.1</version>
<vendor>Cédric Champeau</vendor>
<idea-version since-build="8000"/>

<application-components>
</application-components>

<project-components>
</project-components>

<actions>
<action id="showBytecodeOutline" class="org.objectweb.asm.idea.ShowBytecodeOutlineAction"
text="Show Bytecode outline"
description="Shows the bytecode outline and ASMified code from the current class">
<add-to-group group-id="EditorPopupMenu" anchor="last"/>
</action>
</actions>

<extensions defaultExtensionNs="com.intellij">
<toolWindow id="ASM" anchor="right" icon="/images/asm.gif"
factoryClass="org.objectweb.asm.idea.BytecodeOutlineToolWindowFactory"/>
<projectService serviceInterface="org.objectweb.asm.idea.BytecodeOutline"
serviceImplementation="org.objectweb.asm.idea.BytecodeOutline"/>
<projectService serviceInterface="org.objectweb.asm.idea.BytecodeASMified"
serviceImplementation="org.objectweb.asm.idea.BytecodeASMified"/>
</extensions>
</idea-plugin>
1 change: 1 addition & 0 deletions README
@@ -0,0 +1 @@
This file was created by IntelliJ IDEA 10.0.1 for binding GitHub repository
Binary file added lib/asm-debug-all-3.3.1.jar
Binary file not shown.
Binary file added src/images/asm.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions src/org/objectweb/asm/idea/ACodeView.java
@@ -0,0 +1,85 @@
/*
*
* Copyright 2011 Cédric Champeau
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/

package org.objectweb.asm.idea;
/**
* Created by IntelliJ IDEA.
* User: cedric
* Date: 07/01/11
* Time: 22:18
*/

import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowManager;

import javax.swing.*;
import java.awt.*;

/**
* Base class for editors which displays bytecode or ASMified code.
*/
public class ACodeView extends JPanel implements Disposable {
protected final Project project;
protected final ToolWindowManager toolWindowManager;
protected final KeymapManager keymapManager;

private final String extension;
protected Editor editor;
protected Document document;


public ACodeView(final ToolWindowManager toolWindowManager, KeymapManager keymapManager, final Project project, final String fileExtension) {
super(new BorderLayout());
this.toolWindowManager = toolWindowManager;
this.keymapManager = keymapManager;
this.project = project;
this.extension = fileExtension;
setupUI();
}

public ACodeView(final ToolWindowManager toolWindowManager, KeymapManager keymapManager, final Project project) {
this(toolWindowManager, keymapManager, project, "java");
}

private void setupUI() {
final EditorFactory editorFactory = EditorFactory.getInstance();
document = editorFactory.createDocument("");
editor = editorFactory.createEditor(document, project, FileTypeManager.getInstance().getFileTypeByExtension(extension), true);

add(editor.getComponent());
}

public void setCode(final String code) {
document.setText(code);
}


public void dispose() {
if (editor != null) {
final EditorFactory editorFactory = EditorFactory.getInstance();
editorFactory.releaseEditor(editor);
editor = null;
}
}
}
49 changes: 49 additions & 0 deletions src/org/objectweb/asm/idea/BytecodeASMified.java
@@ -0,0 +1,49 @@
/*
*
* Copyright 2011 Cédric Champeau
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/

package org.objectweb.asm.idea;

import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindowManager;

import javax.swing.*;
import java.awt.*;


/**
* Created by IntelliJ IDEA.
* User: cedric
* Date: 07/01/11
* Time: 17:07
*/

/**
* ASMified code view.
*/
public class BytecodeASMified extends ACodeView {

public BytecodeASMified(final ToolWindowManager toolWindowManager, KeymapManager keymapManager, final Project project) {
super(toolWindowManager, keymapManager, project);
}

public static BytecodeASMified getInstance(Project project) {
return ServiceManager.getService(project, BytecodeASMified.class);
}
}
54 changes: 54 additions & 0 deletions src/org/objectweb/asm/idea/BytecodeOutline.java
@@ -0,0 +1,54 @@
/*
*
* Copyright 2011 Cédric Champeau
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/

package org.objectweb.asm.idea;

import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentContainer;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;


/**
* Created by IntelliJ IDEA.
* User: cedric
* Date: 07/01/11
* Time: 17:07
*/

/**
* Bytecode view.
*/
public class BytecodeOutline extends ACodeView {

public BytecodeOutline(final Project project, KeymapManager keymapManager, final ToolWindowManager toolWindowManager) {
super(toolWindowManager, keymapManager, project);
}

public static BytecodeOutline getInstance(Project project) {
return ServiceManager.getService(project, BytecodeOutline.class);
}
}
37 changes: 37 additions & 0 deletions src/org/objectweb/asm/idea/BytecodeOutlineToolWindowFactory.java
@@ -0,0 +1,37 @@
/*
*
* Copyright 2011 Cédric Champeau
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/

package org.objectweb.asm.idea;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.content.ContentFactory;

/**
* ASM ToolWindow factory
*/
public class BytecodeOutlineToolWindowFactory implements ToolWindowFactory{
public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
BytecodeOutline outline = BytecodeOutline.getInstance(project);
BytecodeASMified asmified = BytecodeASMified.getInstance(project);
toolWindow.getContentManager().addContent(ContentFactory.SERVICE.getInstance().createContent(outline, "Bytecode", false));
toolWindow.getContentManager().addContent(ContentFactory.SERVICE.getInstance().createContent(asmified, "ASMified", false));
}
}

0 comments on commit e639832

Please sign in to comment.