Commit 25f989f1 authored by ekuleshov's avatar ekuleshov

implemented content extraction for Bytecode Reference View and dodc splitted...

implemented content extraction for Bytecode Reference View and dodc splitted into separate resources
parent c4cd8e52
<toc label="JVM Instruction Reference" topic="about.html">
<topic label="aaload" href="opcodes.xml#aaload"/>
<topic label="aastore" href="opcodes.xml#aastore"/>
<topic label="aconst_null" href="opcodes.xml#aconst_null"/>
<topic label="aload" href="opcodes.xml#aload"/>
<topic label="aload_n" href="opcodes.xml#aload_%3Cn%3E"/>
<topic label="anewarray" href="opcodes.xml#anewarray"/>
<topic label="areturn" href="opcodes.xml#areturn"/>
<topic label="arraylength" href="opcodes.xml#arraylength"/>
<topic label="astore" href="opcodes.xml#astore"/>
<topic label="astore_n" href="opcodes.xml#astore_%3Cn%3E"/>
<topic label="athrow" href="opcodes.xml#athrow"/>
<topic label="baload" href="opcodes.xml#baload"/>
<topic label="bastore" href="opcodes.xml#bastore"/>
<topic label="bipush" href="opcodes.xml#bipush"/>
<topic label="breakpoint" href="opcodes.xml#breakpoint"/>
<topic label="caload" href="opcodes.xml#caload"/>
<topic label="castore" href="opcodes.xml#castore"/>
<topic label="checkcast" href="opcodes.xml#checkcast"/>
<topic label="d2f" href="opcodes.xml#d2f"/>
<topic label="d2i" href="opcodes.xml#d2i"/>
<topic label="d2l" href="opcodes.xml#d2l"/>
<topic label="dadd" href="opcodes.xml#dadd"/>
<topic label="daload" href="opcodes.xml#daload"/>
<topic label="dastore" href="opcodes.xml#dastore"/>
<topic label="dcmpg" href="opcodes.xml#dcmpg"/>
<topic label="dcmpl" href="opcodes.xml#dcmpl"/>
<topic label="dconst_d" href="opcodes.xml#dconst_%3Cd%3E"/>
<topic label="ddiv" href="opcodes.xml#ddiv"/>
<topic label="dload" href="opcodes.xml#dload"/>
<topic label="dload_n" href="opcodes.xml#dload_%3Cn%3E"/>
<topic label="dmul" href="opcodes.xml#dmul"/>
<topic label="dneg" href="opcodes.xml#dneg"/>
<topic label="drem" href="opcodes.xml#drem"/>
<topic label="dreturn" href="opcodes.xml#dreturn"/>
<topic label="dstore" href="opcodes.xml#dstore"/>
<topic label="dstore_n" href="opcodes.xml#dstore_%3Cn%3E"/>
<topic label="dsub" href="opcodes.xml#dsub"/>
<topic label="dup" href="opcodes.xml#dup"/>
<topic label="dup_x1" href="opcodes.xml#dup_x1"/>
<topic label="dup_x2" href="opcodes.xml#dup_x2"/>
<topic label="dup2" href="opcodes.xml#dup2"/>
<topic label="dup2_x1" href="opcodes.xml#dup2_x1"/>
<topic label="dup2_x2" href="opcodes.xml#dup2_x2"/>
<topic label="f2d" href="opcodes.xml#f2d"/>
<topic label="f2i" href="opcodes.xml#f2i"/>
<topic label="f2l" href="opcodes.xml#f2l"/>
<topic label="fadd" href="opcodes.xml#fadd"/>
<topic label="faload" href="opcodes.xml#faload"/>
<topic label="fastore" href="opcodes.xml#fastore"/>
<topic label="fcmpg" href="opcodes.xml#fcmpg"/>
<topic label="fcmpl" href="opcodes.xml#fcmpl"/>
<topic label="fconst_f" href="opcodes.xml#fconst_%3Cf%3E"/>
<topic label="fdiv" href="opcodes.xml#fdiv"/>
<topic label="fload" href="opcodes.xml#fload"/>
<topic label="fload_n" href="opcodes.xml#fload_%3Cn%3E"/>
<topic label="fmul" href="opcodes.xml#fmul"/>
<topic label="fneg" href="opcodes.xml#fneg"/>
<topic label="frem" href="opcodes.xml#frem"/>
<topic label="freturn" href="opcodes.xml#freturn"/>
<topic label="fstore" href="opcodes.xml#fstore"/>
<topic label="fstore_n" href="opcodes.xml#fstore_%3Cn%3E"/>
<topic label="fsub" href="opcodes.xml#fsub"/>
<topic label="getfield" href="opcodes.xml#getfield"/>
<topic label="getstatic" href="opcodes.xml#getstatic"/>
<topic label="goto" href="opcodes.xml#goto"/>
<topic label="goto_w" href="opcodes.xml#goto_w"/>
<topic label="i2b" href="opcodes.xml#i2b"/>
<topic label="i2c" href="opcodes.xml#i2c"/>
<topic label="i2d" href="opcodes.xml#i2d"/>
<topic label="i2f" href="opcodes.xml#i2f"/>
<topic label="i2l" href="opcodes.xml#i2l"/>
<topic label="i2s" href="opcodes.xml#i2s"/>
<topic label="iadd" href="opcodes.xml#iadd"/>
<topic label="iaload" href="opcodes.xml#iaload"/>
<topic label="iand" href="opcodes.xml#iand"/>
<topic label="iastore" href="opcodes.xml#iastore"/>
<topic label="iconst_n" href="opcodes.xml#iconst_%3Cn%3E"/>
<topic label="iconst_m1" href="opcodes.xml#iconst_m1"/>
<topic label="idiv" href="opcodes.xml#idiv"/>
<topic label="if_acmpeq" href="opcodes.xml#if_acmpeq"/>
<topic label="if_acmpne" href="opcodes.xml#if_acmpne"/>
<topic label="if_icmpeq" href="opcodes.xml#if_icmpeq"/>
<topic label="if_icmpge" href="opcodes.xml#if_icmpge"/>
<topic label="if_icmpgt" href="opcodes.xml#if_icmpgt"/>
<topic label="if_icmple" href="opcodes.xml#if_icmple"/>
<topic label="if_icmplt" href="opcodes.xml#if_icmplt"/>
<topic label="if_icmpne" href="opcodes.xml#if_icmpne"/>
<topic label="ifeq" href="opcodes.xml#ifeq"/>
<topic label="ifge" href="opcodes.xml#ifge"/>
<topic label="ifgt" href="opcodes.xml#ifgt"/>
<topic label="ifle" href="opcodes.xml#ifle"/>
<topic label="iflt" href="opcodes.xml#iflt"/>
<topic label="ifne" href="opcodes.xml#ifne"/>
<topic label="ifnonnull" href="opcodes.xml#ifnonnull"/>
<topic label="ifnull" href="opcodes.xml#ifnull"/>
<topic label="iinc" href="opcodes.xml#iinc"/>
<topic label="iload" href="opcodes.xml#iload"/>
<topic label="iload_n" href="opcodes.xml#iload_%3Cn%3E"/>
<topic label="impdep1" href="opcodes.xml#impdep1"/>
<topic label="impdep2" href="opcodes.xml#impdep2"/>
<topic label="imul" href="opcodes.xml#imul"/>
<topic label="ineg" href="opcodes.xml#ineg"/>
<topic label="instanceof" href="opcodes.xml#instanceof"/>
<topic label="invokeinterface" href="opcodes.xml#invokeinterface"/>
<topic label="invokespecial" href="opcodes.xml#invokespecial"/>
<topic label="invokestatic" href="opcodes.xml#invokestatic"/>
<topic label="invokevirtual" href="opcodes.xml#invokevirtual"/>
<topic label="ior" href="opcodes.xml#ior"/>
<topic label="irem" href="opcodes.xml#irem"/>
<topic label="ireturn" href="opcodes.xml#ireturn"/>
<topic label="ishl" href="opcodes.xml#ishl"/>
<topic label="ishr" href="opcodes.xml#ishr"/>
<topic label="istore" href="opcodes.xml#istore"/>
<topic label="istore_n" href="opcodes.xml#istore_%3Cn%3E"/>
<topic label="isub" href="opcodes.xml#isub"/>
<topic label="iushr" href="opcodes.xml#iushr"/>
<topic label="ixor" href="opcodes.xml#ixor"/>
<topic label="jsr" href="opcodes.xml#jsr"/>
<topic label="jsr_w" href="opcodes.xml#jsr_w"/>
<topic label="l2d" href="opcodes.xml#l2d"/>
<topic label="l2f" href="opcodes.xml#l2f"/>
<topic label="l2i" href="opcodes.xml#l2i"/>
<topic label="ladd" href="opcodes.xml#ladd"/>
<topic label="laload" href="opcodes.xml#laload"/>
<topic label="land" href="opcodes.xml#land"/>
<topic label="lastore" href="opcodes.xml#lastore"/>
<topic label="lcmp" href="opcodes.xml#lcmp"/>
<topic label="lconst_l" href="opcodes.xml#lconst_%3Cl%3E"/>
<topic label="ldc" href="opcodes.xml#ldc"/>
<topic label="ldc_w" href="opcodes.xml#ldc_w"/>
<topic label="ldc2_w" href="opcodes.xml#ldc2_w"/>
<topic label="ldiv" href="opcodes.xml#ldiv"/>
<topic label="lload" href="opcodes.xml#lload"/>
<topic label="lload_n" href="opcodes.xml#lload_%3Cn%3E"/>
<topic label="lmul" href="opcodes.xml#lmul"/>
<topic label="lneg" href="opcodes.xml#lneg"/>
<topic label="lookupswitch" href="opcodes.xml#lookupswitch"/>
<topic label="lor" href="opcodes.xml#lor"/>
<topic label="lrem" href="opcodes.xml#lrem"/>
<topic label="lreturn" href="opcodes.xml#lreturn"/>
<topic label="lshl" href="opcodes.xml#lshl"/>
<topic label="lshr" href="opcodes.xml#lshr"/>
<topic label="lstore" href="opcodes.xml#lstore"/>
<topic label="lstore_n" href="opcodes.xml#lstore_%3Cn%3E"/>
<topic label="lsub" href="opcodes.xml#lsub"/>
<topic label="lushr" href="opcodes.xml#lushr"/>
<topic label="lxor" href="opcodes.xml#lxor"/>
<topic label="monitorenter" href="opcodes.xml#monitorenter"/>
<topic label="monitorexit" href="opcodes.xml#monitorexit"/>
<topic label="multianewarray" href="opcodes.xml#multianewarray"/>
<topic label="new" href="opcodes.xml#new"/>
<topic label="newarray" href="opcodes.xml#newarray"/>
<topic label="nop" href="opcodes.xml#nop"/>
<topic label="pop" href="opcodes.xml#pop"/>
<topic label="pop2" href="opcodes.xml#pop2"/>
<topic label="putfield" href="opcodes.xml#putfield"/>
<topic label="putstatic" href="opcodes.xml#putstatic"/>
<topic label="ret" href="opcodes.xml#ret"/>
<topic label="return" href="opcodes.xml#return"/>
<topic label="saload" href="opcodes.xml#saload"/>
<topic label="sastore" href="opcodes.xml#sastore"/>
<topic label="sipush" href="opcodes.xml#sipush"/>
<topic label="swap" href="opcodes.xml#swap"/>
<topic label="tableswitch" href="opcodes.xml#tableswitch"/>
<topic label="wide" href="opcodes.xml#wide"/>
</toc>
......@@ -64,20 +64,18 @@
</zip>
</target>
<target name="plugin" depends="jars">
<target name="plugin" depends="jars,xslt">
<zip zipfile="${out}/${plugin.jar}">
<zipfileset dir="${out}" includes="BytecodeOutline.jar,BytecodeOutlinesrc.zip"/>
<fileset dir=".">
<include name="META-INF/MANIFEST.MF"/>
<include name="externals/*.jar"/>
<include name="icons/**/*"/>
<include name="plugin.xml"/>
<include name="book.xml"/>
<include name="about.html"/>
<include name="opcodes.xml"/>
<include name="opcodes.xsl"/>
<include name="*.txt"/>
</fileset>
<fileset dir="${out}/doc" includes="toc.xml"/>
<zipfileset dir="${out}/doc" includes="*.html" prefix="doc"/>
</zip>
</target>
......@@ -101,4 +99,12 @@
</delete>
</target>
<target name="xslt">
<mkdir dir="${out}/doc"/>
<xslt basedir="." destdir="${out}/doc" includes="opcodes.xml"
style="opcodes-doc.xsl" force="true">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl fo">
<xsl:output method="html" indent="no" omit-xml-declaration="yes" encoding="UTF-8" name="html"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8" name="xml"/>
<xsl:template match="opcodes">
<!-- TOC -->
<xsl:result-document format="xml" href="toc.xml">
<toc label="JVM Instruction Reference" topic="about.html">
<xsl:for-each select='opcode'>
<xsl:sort/>
<topic label="aaload" href="opcodes.html#aaload">
<xsl:attribute name='label'><xsl:value-of select="name/text()"/></xsl:attribute>
<xsl:attribute name='href'>doc/ref-<xsl:value-of select="name/text()"/>.html</xsl:attribute>
</topic>
</xsl:for-each>
</toc>
</xsl:result-document>
<!-- Details -->
<xsl:apply-templates select="*">
<xsl:sort/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="opcode">
<xsl:variable name="filename" select="concat('ref-', name, '.html')"/>
<xsl:result-document format="html" href="{$filename}">
<html>
<body>
<dl>
<dt>
<a><xsl:attribute name='name'><xsl:value-of select="name"/></xsl:attribute></a>
<b><xsl:value-of select="name"/></b> :
<xsl:apply-templates select="short/text()"/>
</dt>
<xsl:apply-templates select="desc"/>
<xsl:apply-templates select="exceptions"/>
<xsl:apply-templates select="example"/>
<xsl:apply-templates select="note"/>
<xsl:apply-templates select="see"/>
<xsl:apply-templates select="stack"/>
<xsl:apply-templates select="bytecode"/>
</dl>
</body>
</html>
</xsl:result-document>
</xsl:template>
<!-- Sections -->
<xsl:template match="stack">
<dt><i>Stack</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<xsl:template match="desc">
<dt><i>Description</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<xsl:template match="bytecode">
<dt><i>Bytecode</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<xsl:template match="example">
<dt><i>Example</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<xsl:template match="note">
<dt><i>Notes</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<xsl:template match="see">
<dt><i>See also</i></dt>
<dd>
<xsl:call-template name="seeFormat"><xsl:with-param name="string" select="text()"/></xsl:call-template>
</dd>
</xsl:template>
<xsl:template match="exceptions">
<dt><i>Exceptions</i></dt>
<dd><xsl:apply-templates select="*|text()"/></dd>
</xsl:template>
<!-- Formatting -->
<xsl:template match="table">
<table border="1" cellspacing="0" cellpadding="3">
<xsl:apply-templates select="*"/>
</table>
</xsl:template>
<xsl:template match='text()'>
<xsl:call-template name="docFormat"><xsl:with-param name="string" select="."/></xsl:call-template>
</xsl:template>
<xsl:template name="docFormat">
<xsl:param name="string"/>
<!-- double CRLF will be replaced with <BR><BR> -->
<xsl:choose>
<xsl:when test="contains($string, '&#xA;&#xA;')">
<xsl:value-of select="substring-before($string, '&#xA;&#xA;')"/>
<br/>
<xsl:call-template name="docFormat">
<xsl:with-param name="string" select="substring-after($string, '&#xA;&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="seeFormat">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, ',')">
<a>
<xsl:attribute name="href">ref-<xsl:value-of select="normalize-space(substring-before($string, ','))"/>.html</xsl:attribute>
<xsl:value-of select="normalize-space(substring-before($string, ','))"/>
</a>
<xsl:value-of select="string( ' ')"/>
<xsl:call-template name="seeFormat">
<xsl:with-param name="string" select="substring-after($string, ',')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<a>
<xsl:attribute name="href">ref-<xsl:value-of select="normalize-space($string)"/>.html</xsl:attribute>
<xsl:value-of select="normalize-space($string)"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Copy everything else -->
<xsl:template match='*|@*'>
<xsl:copy>
<xsl:apply-templates select='node()|@*'/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This diff is collapsed.
......@@ -37,13 +37,13 @@
<b><xsl:value-of select="name"/></b> :
<xsl:apply-templates select="short/text()"/>
</dt>
<xsl:apply-templates select="stack"/>
<xsl:apply-templates select="desc"/>
<xsl:apply-templates select="exceptions"/>
<xsl:apply-templates select="example"/>
<xsl:apply-templates select="bytecode"/>
<xsl:apply-templates select="note"/>
<xsl:apply-templates select="see"/>
<xsl:apply-templates select="stack"/>
<xsl:apply-templates select="bytecode"/>
</dl>
<hr/>
......
......@@ -127,7 +127,7 @@
</extension>
<extension point="org.eclipse.help.toc">
<toc file="book.xml" primary="true" />
<toc file="toc.xml" primary="true" />
</extension>
</plugin>
......@@ -4,6 +4,13 @@
package de.loskutov.bco.views;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
......@@ -12,8 +19,12 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ViewPart;
import org.osgi.framework.Bundle;
import org.objectweb.asm.util.AbstractVisitor;
import de.loskutov.bco.BytecodeOutlinePlugin;
public class BytecodeReferenceView extends ViewPart implements ISelectionListener {
......@@ -32,16 +43,61 @@ public class BytecodeReferenceView extends ViewPart implements ISelectionListene
if (selection instanceof ITextSelection && part instanceof BytecodeOutlineView) {
int line = ((ITextSelection)selection).getStartLine();
int opcode = ((BytecodeOutlineView)part).getBytecodeInstructionAtLine(line);
/* TODO replace code below with something that gets HTML content from opcode */
String opcodeName = null;
if (opcode != -1) {
opcodeName = AbstractVisitor.OPCODES[opcode];
}
if (opcodeName != null) {
browser.setText("<html><body>" + opcodeName + "</body></html>");
URL url = getHelpResource( opcodeName);
if( url!=null) {
browser.setText( getContent( url));
} else {
browser.setText("");
}
} else {
browser.setText("");
}
}
}
private String getContent(URL url) {
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(url.openStream()));
if (r == null)
return null;
StringBuffer sb = new StringBuffer();
String l;
while ((l = r.readLine()) != null) {
sb.append(l).append("\n");
}
return sb.toString();
} catch (IOException ex) {
//
} finally {
try {
r.close();
} catch (IOException e) {
//
}
}
return null;
}
private URL getHelpResource( String name) {
String pluginId = BytecodeOutlinePlugin.getDefault().getBundle().getSymbolicName();
Bundle bundle = Platform.getBundle(pluginId);
int state = bundle.getState(); // verify if bundle is ready
if(( state & ( Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING))==0) {
return null;
}
return Platform.find(bundle, new Path( "doc/ref-"+name.toLowerCase()+".html"));
}
}
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