From 238cb69fb9d21bd2d07b2e3ce2ee013766309ca7 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sun, 31 Aug 2014 11:07:45 +0400 Subject: [PATCH] Add license header. Add JavaScript thread --- teavm-eclipse/teavm-eclipse-plugin/.project | 6 + .../org/teavm/eclipse/TeaVMEclipsePlugin.java | 15 ++ .../eclipse/debugger/TeaVMDebugConstants.java | 20 +- .../eclipse/debugger/TeaVMDebugProcess.java | 15 ++ .../eclipse/debugger/TeaVMDebugTarget.java | 26 ++- .../eclipse/debugger/TeaVMJSStackFrame.java | 188 +++++++++++++++ .../teavm/eclipse/debugger/TeaVMJSThread.java | 221 ++++++++++++++++++ .../teavm/eclipse/debugger/TeaVMJSValue.java | 87 +++++++ .../eclipse/debugger/TeaVMJSVariable.java | 107 +++++++++ .../debugger/TeaVMJSVariablesHolder.java | 52 +++++ .../TeaVMLaunchConfigurationDelegate.java | 17 +- .../debugger/TeaVMSourceLookupDirector.java | 15 ++ .../TeaVMSourceLookupParticipant.java | 15 ++ .../TeaVMSourcePathComputerDelegate.java | 15 ++ .../eclipse/debugger/TeaVMStackFrame.java | 19 ++ .../eclipse/debugger/TeaVMStreamMonitor.java | 15 ++ .../eclipse/debugger/TeaVMStreamsProxy.java | 15 ++ .../teavm/eclipse/debugger/TeaVMThread.java | 15 ++ .../teavm/eclipse/debugger/TeaVMValue.java | 15 ++ .../teavm/eclipse/debugger/TeaVMVariable.java | 15 ++ .../debugger/TeaVMVariablesHolder.java | 15 ++ .../ui/TeaVMDebugModelPresentation.java | 107 ++++++++- .../teavm/eclipse/debugger/ui/TeaVMTab.java | 15 ++ .../eclipse/debugger/ui/TeaVMTabGroup.java | 15 ++ 24 files changed, 1039 insertions(+), 6 deletions(-) create mode 100644 teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java create mode 100644 teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSThread.java create mode 100644 teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSValue.java create mode 100644 teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariable.java create mode 100644 teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariablesHolder.java diff --git a/teavm-eclipse/teavm-eclipse-plugin/.project b/teavm-eclipse/teavm-eclipse-plugin/.project index f240a85f5..f53f80956 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/.project +++ b/teavm-eclipse/teavm-eclipse-plugin/.project @@ -20,9 +20,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java index cc579e473..876552f08 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/TeaVMEclipsePlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse; import org.eclipse.core.runtime.Plugin; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugConstants.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugConstants.java index 78cf5f3ad..621338dc2 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugConstants.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugConstants.java @@ -1,10 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; /** * * @author Alexey Andreev */ -public interface TeaVMDebugConstants { +public final class TeaVMDebugConstants { + private TeaVMDebugConstants() { + } + public static final String JAVA_BREAKPOINT_INSTALL_COUNT = "org.eclipse.jdt.debug.core.installCount"; public static final String DEBUG_TARGET_ID = "org.teavm.eclipse.debugger"; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java index 8e44bcaf2..c55d06378 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugProcess.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import java.util.HashMap; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java index 6aaf86f1c..d65490c21 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMDebugTarget.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import static org.teavm.eclipse.debugger.TeaVMDebugConstants.DEBUG_TARGET_ID; @@ -18,7 +33,6 @@ import org.teavm.debugging.Debugger; import org.teavm.debugging.DebuggerListener; import org.teavm.debugging.javascript.JavaScriptDebugger; - /** * * @author Alexey Andreev @@ -32,15 +46,19 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { private volatile boolean terminated; private TeaVMDebugProcess process; private TeaVMThread thread; + private TeaVMJSThread jsThread; ConcurrentMap breakpointMap = new ConcurrentHashMap<>(); ConcurrentMap breakpointBackMap = new ConcurrentHashMap<>(); - public TeaVMDebugTarget(ILaunch launch, final Debugger teavmDebugger, ChromeRDPServer server) { + public TeaVMDebugTarget(ILaunch launch, final Debugger teavmDebugger, JavaScriptDebugger jsDebugger, + ChromeRDPServer server) { this.launch = launch; this.teavmDebugger = teavmDebugger; + this.jsDebugger = jsDebugger; this.server = server; this.process = new TeaVMDebugProcess(launch, this); this.thread = new TeaVMThread(this); + this.jsThread = new TeaVMJSThread(this); DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); for (IBreakpoint breakpoint : DebugPlugin.getDefault().getBreakpointManager().getBreakpoints()) { breakpointAdded(breakpoint); @@ -116,6 +134,8 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { server.stop(); fireEvent(new DebugEvent(thread, DebugEvent.TERMINATE)); fireEvent(new DebugEvent(thread, DebugEvent.CHANGE)); + fireEvent(new DebugEvent(jsThread, DebugEvent.TERMINATE)); + fireEvent(new DebugEvent(jsThread, DebugEvent.CHANGE)); fireEvent(new DebugEvent(process, DebugEvent.TERMINATE)); fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); } @@ -228,7 +248,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep { @Override public IThread[] getThreads() throws DebugException { - return !terminated ? new IThread[] { thread } : new IThread[0]; + return !terminated ? new IThread[] { thread, jsThread } : new IThread[0]; } @Override diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java new file mode 100644 index 000000000..6cdf57399 --- /dev/null +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSStackFrame.java @@ -0,0 +1,188 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.*; +import org.teavm.debugging.javascript.JavaScriptCallFrame; + +/** + * + * @author Alexey Andreev + */ +public class TeaVMJSStackFrame implements IStackFrame { + TeaVMJSThread thread; + JavaScriptCallFrame callFrame; + private TeaVMJSVariablesHolder variablesHolder; + + public TeaVMJSStackFrame(TeaVMJSThread thread, JavaScriptCallFrame callFrame) { + this.thread = thread; + this.callFrame = callFrame; + this.variablesHolder = new TeaVMJSVariablesHolder(thread.debugTarget, callFrame.getVariables().values()); + } + + public JavaScriptCallFrame getCallFrame() { + return callFrame; + } + + @Override + public boolean canTerminate() { + return thread.canTerminate(); + } + + @Override + public boolean isTerminated() { + return thread.isTerminated(); + } + + @Override + public void terminate() throws DebugException { + thread.terminate(); + } + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { + return null; + } + + @Override + public boolean canStepInto() { + return thread.getTopStackFrame() == this; + } + + @Override + public boolean canStepOver() { + return thread.getTopStackFrame() == this; + } + + @Override + public boolean canStepReturn() { + return thread.getTopStackFrame() == this; + } + + @Override + public boolean isStepping() { + return false; + } + + @Override + public void stepInto() throws DebugException { + thread.stepInto(); + } + + @Override + public void stepOver() throws DebugException { + thread.stepOver(); + } + + @Override + public void stepReturn() throws DebugException { + thread.stepReturn(); + } + + @Override + public boolean canResume() { + return thread.getTopStackFrame() == this; + } + + @Override + public boolean canSuspend() { + return thread.getTopStackFrame() == this; + } + + @Override + public boolean isSuspended() { + return thread.isSuspended(); + } + + @Override + public void resume() throws DebugException { + thread.resume(); + } + + @Override + public void suspend() throws DebugException { + thread.suspend(); + } + + @Override + public IDebugTarget getDebugTarget() { + return thread.getDebugTarget(); + } + + @Override + public ILaunch getLaunch() { + return thread.getLaunch(); + } + + @Override + public String getModelIdentifier() { + return TeaVMDebugConstants.STACK_FRAME_ID; + } + + @Override + public int getCharEnd() throws DebugException { + return callFrame.getLocation() != null ? callFrame.getLocation().getColumn() + 2 : -1; + } + + @Override + public int getCharStart() throws DebugException { + return callFrame.getLocation() != null ? callFrame.getLocation().getColumn() + 1 : -1; + } + + @Override + public int getLineNumber() throws DebugException { + return callFrame.getLocation() != null ? callFrame.getLocation().getLine() + 1 : -1; + } + + @Override + public String getName() { + StringBuilder sb = new StringBuilder(); + String fileName = callFrame.getLocation() != null ? callFrame.getLocation().getScript(): null; + sb.append(fileName != null ? fileName : "unknown"); + if (callFrame.getLocation() != null) { + sb.append(" at ").append(callFrame.getLocation().getLine() + 1).append(";").append( + callFrame.getLocation().getColumn() + 1); + } + return sb.toString(); + } + + @Override + public IRegisterGroup[] getRegisterGroups() throws DebugException { + return null; + } + + @Override + public IThread getThread() { + return thread; + } + + @Override + public IVariable[] getVariables() throws DebugException { + return variablesHolder.getVariables(); + } + + @Override + public boolean hasRegisterGroups() throws DebugException { + return false; + } + + @Override + public boolean hasVariables() throws DebugException { + return true; + } +} diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSThread.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSThread.java new file mode 100644 index 000000000..13cd5c5fd --- /dev/null +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSThread.java @@ -0,0 +1,221 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; + +import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.model.IThread; +import org.teavm.debugging.javascript.JavaScriptBreakpoint; +import org.teavm.debugging.javascript.JavaScriptCallFrame; +import org.teavm.debugging.javascript.JavaScriptDebugger; +import org.teavm.debugging.javascript.JavaScriptDebuggerListener; + +/** + * + * @author Alexey Andreev + */ +public class TeaVMJSThread implements IThread { + private JavaScriptDebugger jsDebugger; + TeaVMDebugTarget debugTarget; + private volatile TeaVMJSStackFrame[] stackTrace; + + public TeaVMJSThread(TeaVMDebugTarget debugTarget) { + this.debugTarget = debugTarget; + this.jsDebugger = debugTarget.jsDebugger; + jsDebugger.addListener(new JavaScriptDebuggerListener() { + @Override + public void scriptAdded(String name) { + } + @Override + public void resumed() { + updateStackTrace(); + fireEvent(new DebugEvent(TeaVMJSThread.this, DebugEvent.RESUME)); + } + @Override + public void paused() { + updateStackTrace(); + fireEvent(new DebugEvent(TeaVMJSThread.this, DebugEvent.SUSPEND)); + } + @Override + public void detached() { + } + @Override + public void breakpointChanged(JavaScriptBreakpoint breakpoint) { + } + @Override + public void attached() { + } + }); + } + + private void updateStackTrace() { + if (jsDebugger.getCallStack() == null) { + this.stackTrace = null; + } else { + JavaScriptCallFrame[] jsCallStack = jsDebugger.getCallStack(); + TeaVMJSStackFrame[] stackTrace = new TeaVMJSStackFrame[jsCallStack.length]; + for (int i = 0; i < jsCallStack.length; ++i) { + JavaScriptCallFrame jsFrame = jsCallStack[i]; + stackTrace[i] = new TeaVMJSStackFrame(this, jsFrame); + } + this.stackTrace = stackTrace; + } + fireEvent(new DebugEvent(this, DebugEvent.CHANGE)); + } + + private void fireEvent(DebugEvent event) { + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event }); + } + + @Override + public boolean canTerminate() { + return debugTarget.canTerminate(); + } + + @Override + public boolean isTerminated() { + return debugTarget.isTerminated(); + } + + @Override + public void terminate() throws DebugException { + debugTarget.terminate(); + } + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class type) { + return null; + } + + @Override + public boolean canResume() { + return debugTarget.canResume(); + } + + @Override + public boolean canSuspend() { + return debugTarget.canSuspend(); + } + + @Override + public boolean isSuspended() { + return jsDebugger.isSuspended(); + } + + @Override + public void resume() throws DebugException { + jsDebugger.resume(); + } + + @Override + public void suspend() throws DebugException { + jsDebugger.suspend(); + } + + @Override + public boolean canStepInto() { + return debugTarget.canStepInto(); + } + + @Override + public boolean canStepOver() { + return debugTarget.canStepOver(); + } + + @Override + public boolean canStepReturn() { + return debugTarget.canStepReturn(); + } + + @Override + public boolean isStepping() { + return debugTarget.isStepping(); + } + + @Override + public void stepInto() throws DebugException { + jsDebugger.stepInto(); + } + + @Override + public void stepOver() throws DebugException { + jsDebugger.stepOver(); + } + + @Override + public void stepReturn() throws DebugException { + jsDebugger.stepOut(); + } + + @Override + public IDebugTarget getDebugTarget() { + return debugTarget; + } + + @Override + public ILaunch getLaunch() { + return debugTarget.launch; + } + + @Override + public String getModelIdentifier() { + return TeaVMDebugConstants.THREAD_ID; + } + + @Override + public IBreakpoint[] getBreakpoints() { + return debugTarget.breakpointMap.keySet().toArray(new IBreakpoint[0]); + } + + @Override + public String getName() throws DebugException { + return "JavaScript"; + } + + @Override + public int getPriority() throws DebugException { + return 0; + } + + @Override + public IStackFrame[] getStackFrames() throws DebugException { + if (isTerminated()) { + return new IStackFrame[0]; + } + TeaVMJSStackFrame[] stackTrace = this.stackTrace; + return stackTrace != null ? stackTrace.clone() : new IStackFrame[0]; + } + + @Override + public IStackFrame getTopStackFrame() { + if (isTerminated()) { + return null; + } + TeaVMJSStackFrame[] stackTrace = this.stackTrace; + return stackTrace != null && stackTrace.length > 0 ? stackTrace[0] : null; + } + + @Override + public boolean hasStackFrames() throws DebugException { + return !isTerminated() && stackTrace != null; + } +} diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSValue.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSValue.java new file mode 100644 index 000000000..087e82662 --- /dev/null +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSValue.java @@ -0,0 +1,87 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.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.javascript.JavaScriptValue; + +/** + * + * @author Alexey Andreev + */ +public class TeaVMJSValue implements IValue { + TeaVMDebugTarget debugTarget; + private JavaScriptValue teavmValue; + private TeaVMJSVariablesHolder variablesHolder; + private boolean innerStructure; + + public TeaVMJSValue(TeaVMDebugTarget debugTarget, JavaScriptValue teavmValue) { + this.debugTarget = debugTarget; + this.teavmValue = teavmValue; + this.innerStructure = teavmValue.hasInnerStructure(); + this.variablesHolder = new TeaVMJSVariablesHolder(debugTarget, teavmValue.getProperties().values()); + } + + @Override + public IDebugTarget getDebugTarget() { + return debugTarget; + } + + @Override + public ILaunch getLaunch() { + return debugTarget.getLaunch(); + } + + @Override + public String getModelIdentifier() { + return TeaVMDebugConstants.VALUE_ID; + } + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class arg0) { + return null; + } + + @Override + public String getReferenceTypeName() throws DebugException { + return teavmValue.getClassName(); + } + + @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 innerStructure; + } + + @Override + public boolean isAllocated() throws DebugException { + return true; + } +} diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariable.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariable.java new file mode 100644 index 000000000..27f65387a --- /dev/null +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariable.java @@ -0,0 +1,107 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.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.javascript.JavaScriptVariable; +import org.teavm.eclipse.TeaVMEclipsePlugin; + +/** + * + * @author Alexey Andreev + */ +public class TeaVMJSVariable implements IVariable { + private TeaVMDebugTarget debugTarget; + private JavaScriptVariable var; + private TeaVMJSValue value; + + public TeaVMJSVariable(TeaVMDebugTarget debugTarget, JavaScriptVariable var) { + this.debugTarget = debugTarget; + this.var = var; + this.value = new TeaVMJSValue(debugTarget, var.getValue()); + } + + @Override + public void setValue(IValue arg0) throws DebugException { + throw new DebugException(new Status(Status.ERROR, TeaVMEclipsePlugin.ID, "Can't set value")); + } + + @Override + public void setValue(String arg0) throws DebugException { + throw new DebugException(new Status(Status.ERROR, TeaVMEclipsePlugin.ID, "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 TeaVMDebugConstants.VARIABLE_ID; + } + + @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().getClassName(); + } + + @Override + public IValue getValue() throws DebugException { + return value; + } + + @Override + public boolean hasValueChanged() throws DebugException { + return false; + } +} diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariablesHolder.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariablesHolder.java new file mode 100644 index 000000000..e79690cee --- /dev/null +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMJSVariablesHolder.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; + +import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import org.teavm.debugging.javascript.JavaScriptVariable; + +/** + * + * @author Alexey Andreev + */ +public class TeaVMJSVariablesHolder { + private TeaVMDebugTarget debugTarget; + private Collection teavmVariables; + private AtomicReference variables = new AtomicReference<>(); + + public TeaVMJSVariablesHolder(TeaVMDebugTarget debugTarget, Collection teavmVariables) { + this.debugTarget = debugTarget; + this.teavmVariables = teavmVariables; + } + + public TeaVMJSVariable[] getVariables() { + if (variables.get() == null) { + TeaVMJSVariable[] newVariables = new TeaVMJSVariable[teavmVariables.size()]; + List teavmVarList = new ArrayList<>(teavmVariables); + Collections.sort(teavmVarList, new Comparator() { + @Override public int compare(JavaScriptVariable o1, JavaScriptVariable o2) { + return o1.getName().compareTo(o2.getName()); + } + }); + for (int i = 0; i < teavmVarList.size(); ++i) { + newVariables[i] = new TeaVMJSVariable(debugTarget, teavmVarList.get(i)); + } + variables.compareAndSet(null, newVariables); + } + return variables.get(); + } +} diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java index c93bd9ce9..dd62d622a 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMLaunchConfigurationDelegate.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.core.runtime.CoreException; @@ -33,7 +48,7 @@ public class TeaVMLaunchConfigurationDelegate implements ILaunchConfigurationDel server.start(); } }.start(); - TeaVMDebugTarget target = new TeaVMDebugTarget(launch, debugger, server); + TeaVMDebugTarget target = new TeaVMDebugTarget(launch, debugger, jsDebugger, server); launch.addDebugTarget(target); launch.addProcess(target.getProcess()); } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupDirector.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupDirector.java index 4018547c7..d43ee6bce 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupDirector.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupDirector.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java index 5a2d1be27..3e0e4db0c 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourceLookupParticipant.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.core.runtime.CoreException; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourcePathComputerDelegate.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourcePathComputerDelegate.java index 569022efd..4325d9fc0 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourcePathComputerDelegate.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMSourcePathComputerDelegate.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import java.util.ArrayList; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java index 33e13d726..7243e91d1 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStackFrame.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.debug.core.DebugException; @@ -20,6 +35,10 @@ public class TeaVMStackFrame implements IStackFrame { this.variablesHolder = new TeaVMVariablesHolder(thread.debugTarget, callFrame.getVariables().values()); } + public CallFrame getCallFrame() { + return callFrame; + } + @Override public boolean canTerminate() { return thread.canTerminate(); diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamMonitor.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamMonitor.java index 152fd0fb4..c85f4e3b8 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamMonitor.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamMonitor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.debug.core.IStreamListener; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamsProxy.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamsProxy.java index 51975a5de..2b5a6cfa4 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamsProxy.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMStreamsProxy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import java.io.IOException; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java index a892a043f..6e8b11b41 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMThread.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.debug.core.DebugEvent; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java index 893dc9fbd..ef085fcdf 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMValue.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.debug.core.DebugException; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariable.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariable.java index 498352dc3..df654b2ce 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariable.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariable.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import org.eclipse.core.runtime.Status; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariablesHolder.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariablesHolder.java index 898348c35..876933e9c 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariablesHolder.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/TeaVMVariablesHolder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger; import java.util.*; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java index 3dd635081..4a07aec41 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger.ui; import org.eclipse.core.resources.IFile; @@ -9,7 +24,13 @@ import org.eclipse.jdt.ui.JavaUI; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.part.FileEditorInput; +import org.teavm.debugging.CallFrame; +import org.teavm.debugging.javascript.JavaScriptCallFrame; +import org.teavm.eclipse.debugger.TeaVMJSStackFrame; import org.teavm.eclipse.debugger.TeaVMStackFrame; +import org.teavm.model.MethodDescriptor; +import org.teavm.model.MethodReference; +import org.teavm.model.ValueType; /** * @@ -46,8 +67,92 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug @Override public String getText(Object element) { if (element instanceof TeaVMStackFrame) { - return ((TeaVMStackFrame)element).getName(); + TeaVMStackFrame stackFrame = (TeaVMStackFrame)element; + return callFrameAsString(stackFrame.getCallFrame()); + } else if (element instanceof TeaVMJSStackFrame) { + TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)element; + return callFrameAsString(stackFrame.getCallFrame()); } return super.getText(element); } + + private String callFrameAsString(CallFrame callFrame) { + MethodReference method = callFrame.getMethod(); + if (method == null) { + return ""; + } + StringBuilder sb = new StringBuilder(); + sb.append(classAsString(method.getClassName())).append('.').append(method.getName()).append('('); + MethodDescriptor desc = method.getDescriptor(); + for (int i = 0; i < desc.parameterCount(); ++i) { + if (i > 0) { + sb.append(','); + } + sb.append(typeAsString(desc.parameterType(i))); + } + sb.append(')'); + if (callFrame.getLocation() != null && callFrame.getLocation().getLine() >= 0) { + sb.append(" line " + callFrame.getLocation().getLine()); + } else { + sb.append(" unknown line"); + } + return sb.toString(); + } + + private String typeAsString(ValueType type) { + int arrayDegree = 0; + StringBuilder sb = new StringBuilder(); + while (type instanceof ValueType.Array) { + ++arrayDegree; + type = ((ValueType.Array)type).getItemType(); + } + if (type instanceof ValueType.Primitive) { + switch (((ValueType.Primitive)type).getKind()) { + case BOOLEAN: + sb.append("boolean"); + break; + case BYTE: + sb.append("byte"); + break; + case SHORT: + sb.append("short"); + break; + case CHARACTER: + sb.append("char"); + break; + case INTEGER: + sb.append("int"); + break; + case LONG: + sb.append("long"); + break; + case FLOAT: + sb.append("float"); + break; + case DOUBLE: + sb.append("double"); + break; + } + } else if (type instanceof ValueType.Object) { + String className = ((ValueType.Object)type).getClassName(); + sb.append(classAsString(className)); + } + while (arrayDegree-- > 0) { + sb.append("[]"); + } + return sb.toString(); + } + + private String classAsString(String className) { + return className.substring(className.lastIndexOf('.') + 1); + } + + private String callFrameAsString(JavaScriptCallFrame callFrame) { + StringBuilder sb = new StringBuilder(); + String script = callFrame.getLocation().getScript(); + sb.append(script.substring(script.lastIndexOf('/') + 1)); + sb.append(" at ").append(callFrame.getLocation().getLine() + 1).append(";") + .append(callFrame.getLocation().getColumn() + 1); + return sb.toString(); + } } diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTab.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTab.java index fd68c7a71..117f71944 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTab.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTab.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger.ui; import org.eclipse.core.runtime.CoreException; diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTabGroup.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTabGroup.java index 1e67f7abe..5d5c73104 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTabGroup.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMTabGroup.java @@ -1,3 +1,18 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * 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.teavm.eclipse.debugger.ui; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;