Adds latest debugger's features to Eclipse plugin

This commit is contained in:
konsoletyper 2014-08-07 15:28:47 +04:00
parent 569d6fa3e8
commit befde46ca2
11 changed files with 213 additions and 6 deletions

View File

@ -85,6 +85,8 @@
<instructions> <instructions>
<Export-Package>org.teavm.*</Export-Package> <Export-Package>org.teavm.*</Export-Package>
<Bundle-SymbolicName>teavm-core</Bundle-SymbolicName> <Bundle-SymbolicName>teavm-core</Bundle-SymbolicName>
<Import-Package>org.apache.commons.io;version="[1.4,2.5)",org.junit,org.objectweb.asm;version="[4.2,6)",
org.objectweb.asm.tree;version="[4.2,6)"</Import-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -5,6 +5,7 @@ Bundle-SymbolicName: teavm-eclipse-plugin;singleton:=true
Bundle-Version: 0.2.0.qualifer Bundle-Version: 0.2.0.qualifer
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com> Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: org.teavm.eclipse.TeaVMEclipsePlugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)", Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)",
org.eclipse.debug.core;bundle-version="[3.7.0,4.0)", org.eclipse.debug.core;bundle-version="[3.7.0,4.0)",
org.eclipse.debug.ui;bundle-version="[3.8.0,4.0)", org.eclipse.debug.ui;bundle-version="[3.8.0,4.0)",

View File

@ -1,4 +1,4 @@
source.. = src/java/ source.. = src/main/java/
output.. = target/ output.. = target/
bin.includes = plugin.xml,\ bin.includes = plugin.xml,\
META-INF/,\ META-INF/,\

View File

@ -9,6 +9,10 @@ import org.eclipse.core.runtime.Plugin;
public class TeaVMEclipsePlugin extends Plugin { public class TeaVMEclipsePlugin extends Plugin {
private static TeaVMEclipsePlugin defaultInstance; private static TeaVMEclipsePlugin defaultInstance;
static {
System.out.println();
}
public TeaVMEclipsePlugin() { public TeaVMEclipsePlugin() {
defaultInstance = this; defaultInstance = this;
} }

View File

@ -10,12 +10,14 @@ import org.teavm.debugging.CallFrame;
* @author Alexey Andreev <konsoletyper@gmail.com> * @author Alexey Andreev <konsoletyper@gmail.com>
*/ */
public class TeaVMStackFrame implements IStackFrame { public class TeaVMStackFrame implements IStackFrame {
private TeaVMThread thread; TeaVMThread thread;
CallFrame callFrame; CallFrame callFrame;
private TeaVMVariablesHolder variablesHolder;
public TeaVMStackFrame(TeaVMThread thread, CallFrame callFrame) { public TeaVMStackFrame(TeaVMThread thread, CallFrame callFrame) {
this.thread = thread; this.thread = thread;
this.callFrame = callFrame; this.callFrame = callFrame;
this.variablesHolder = new TeaVMVariablesHolder(thread.debugTarget, callFrame.getVariables().values());
} }
@Override @Override
@ -150,7 +152,7 @@ public class TeaVMStackFrame implements IStackFrame {
@Override @Override
public IVariable[] getVariables() throws DebugException { public IVariable[] getVariables() throws DebugException {
return new IVariable[0]; return variablesHolder.getVariables();
} }
@Override @Override

View File

@ -19,7 +19,7 @@ import org.teavm.debugging.DebuggerListener;
*/ */
public class TeaVMThread implements IThread { public class TeaVMThread implements IThread {
private Debugger teavmDebugger; private Debugger teavmDebugger;
private TeaVMDebugTarget debugTarget; TeaVMDebugTarget debugTarget;
private volatile TeaVMStackFrame[] stackTrace; private volatile TeaVMStackFrame[] stackTrace;
public TeaVMThread(TeaVMDebugTarget debugTarget) { public TeaVMThread(TeaVMDebugTarget debugTarget) {

View File

@ -0,0 +1,70 @@
package org.teavm.eclipse.debugger;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.teavm.debugging.Value;
/**
*
* @author Alexey Andreev
*/
public class TeaVMValue implements IValue {
TeaVMDebugTarget debugTarget;
private Value teavmValue;
private TeaVMVariablesHolder variablesHolder;
public TeaVMValue(TeaVMDebugTarget debugTarget, Value teavmValue) {
this.debugTarget = debugTarget;
this.teavmValue = teavmValue;
this.variablesHolder = new TeaVMVariablesHolder(debugTarget, teavmValue.getProperties().values());
}
@Override
public IDebugTarget getDebugTarget() {
return debugTarget;
}
@Override
public ILaunch getLaunch() {
return debugTarget.getLaunch();
}
@Override
public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.value";
}
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class arg0) {
return null;
}
@Override
public String getReferenceTypeName() throws DebugException {
return teavmValue.getType();
}
@Override
public String getValueString() throws DebugException {
return teavmValue.getRepresentation();
}
@Override
public IVariable[] getVariables() throws DebugException {
return variablesHolder.getVariables();
}
@Override
public boolean hasVariables() throws DebugException {
return true;
}
@Override
public boolean isAllocated() throws DebugException {
return true;
}
}

View File

@ -0,0 +1,91 @@
package org.teavm.eclipse.debugger;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.teavm.debugging.Variable;
/**
*
* @author Alexey Andreev
*/
public class TeaVMVariable implements IVariable {
private TeaVMDebugTarget debugTarget;
private Variable var;
private TeaVMValue value;
public TeaVMVariable(TeaVMDebugTarget debugTarget, Variable var) {
this.debugTarget = debugTarget;
this.var = var;
this.value = new TeaVMValue(debugTarget, var.getValue());
}
@Override
public void setValue(IValue arg0) throws DebugException {
throw new DebugException(new Status(Status.ERROR, "org.teavm.eclipse", "Can't set value"));
}
@Override
public void setValue(String arg0) throws DebugException {
throw new DebugException(new Status(Status.ERROR, "org.teavm.eclipse", "Can't set value"));
}
@Override
public boolean supportsValueModification() {
return false;
}
@Override
public boolean verifyValue(IValue arg0) throws DebugException {
return false;
}
@Override
public boolean verifyValue(String arg0) throws DebugException {
return false;
}
@Override
public IDebugTarget getDebugTarget() {
return debugTarget;
}
@Override
public ILaunch getLaunch() {
return debugTarget.getLaunch();
}
@Override
public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.variable";
}
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class arg0) {
return null;
}
@Override
public String getName() throws DebugException {
return var.getName();
}
@Override
public String getReferenceTypeName() throws DebugException {
return var.getValue().getType();
}
@Override
public IValue getValue() throws DebugException {
return value;
}
@Override
public boolean hasValueChanged() throws DebugException {
return false;
}
}

View File

@ -0,0 +1,37 @@
package org.teavm.eclipse.debugger;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import org.teavm.debugging.Variable;
/**
*
* @author Alexey Andreev
*/
public class TeaVMVariablesHolder {
private TeaVMDebugTarget debugTarget;
private Collection<Variable> teavmVariables;
private AtomicReference<TeaVMVariable[]> variables = new AtomicReference<>();
public TeaVMVariablesHolder(TeaVMDebugTarget debugTarget, Collection<Variable> teavmVariables) {
this.debugTarget = debugTarget;
this.teavmVariables = teavmVariables;
}
public TeaVMVariable[] getVariables() {
if (variables.get() == null) {
TeaVMVariable[] newVariables = new TeaVMVariable[teavmVariables.size()];
List<Variable> teavmVarList = new ArrayList<>(teavmVariables);
Collections.sort(teavmVarList, new Comparator<Variable>() {
@Override public int compare(Variable o1, Variable o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (int i = 0; i < teavmVarList.size(); ++i) {
newVariables[i] = new TeaVMVariable(debugTarget, teavmVarList.get(i));
}
variables.compareAndSet(null, newVariables);
}
return variables.get();
}
}

View File

@ -13,6 +13,6 @@ import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
public class TeaVMTabGroup extends AbstractLaunchConfigurationTabGroup { public class TeaVMTabGroup extends AbstractLaunchConfigurationTabGroup {
@Override @Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) { public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
setTabs(new ILaunchConfigurationTab[] { new TeaVMTab(), new SourceLookupTab(), new CommonTab() }); setTabs(new ILaunchConfigurationTab[] { new SourceLookupTab(), new CommonTab() });
} }
} }

View File

@ -3,7 +3,7 @@
<description name="TeaVM update site"> <description name="TeaVM update site">
TeaVM update site TeaVM update site
</description> </description>
<feature url="features/teavm.eclipse.feature_0.2.0.201408032032.jar" id="teavm.eclipse.feature" version="0.2.0.201408032032" os="aix,hpux,linux,macosx,qnx,solaris,win32" ws="carbon,cocoa,gtk,motif,photon,win32,wpf" arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64"> <feature url="features/teavm.eclipse.feature_0.2.0.201408071508.jar" id="teavm.eclipse.feature" version="0.2.0.201408071508" os="aix,hpux,linux,macosx,qnx,solaris,win32" ws="carbon,cocoa,gtk,motif,photon,win32,wpf" arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64">
<category name="teavm"/> <category name="teavm"/>
</feature> </feature>
<category-def name="teavm" label="TeaVM"/> <category-def name="teavm" label="TeaVM"/>