Minor fixes & refactoring

This commit is contained in:
konsoletyper 2014-08-14 12:20:23 +04:00
parent 14fdf9b797
commit 95f532aca6
13 changed files with 61 additions and 32 deletions

View File

@ -148,11 +148,13 @@ public class Debugger {
}
public Breakpoint createBreakpoint(SourceLocation location) {
Breakpoint breakpoint = new Breakpoint(this, location);
breakpoints.put(breakpoint, dummyObject);
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false);
return breakpoint;
synchronized (breakpoints) {
Breakpoint breakpoint = new Breakpoint(this, location);
breakpoints.put(breakpoint, dummyObject);
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false);
return breakpoint;
}
}
public Set<Breakpoint> getBreakpoints() {
@ -160,6 +162,9 @@ public class Debugger {
}
void updateInternalBreakpoints(Breakpoint breakpoint) {
if (breakpoint.isDestroyed()) {
return;
}
for (JavaScriptBreakpoint jsBreakpoint : breakpoint.jsBreakpoints) {
breakpointMap.remove(jsBreakpoint);
jsBreakpoint.destroy();
@ -263,9 +268,11 @@ public class Debugger {
}
private void updateBreakpoints() {
for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, true);
synchronized (breakpointMap) {
for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, true);
}
}
}
@ -298,9 +305,11 @@ public class Debugger {
}
private void fireAttached() {
for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false);
synchronized (breakpointMap) {
for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false);
}
}
for (DebuggerListener listener : getListeners()) {
listener.attached();

View File

@ -52,5 +52,4 @@ Bundle-ClassPath: .,
lib/websocket-common-9.2.1.v20140609.jar,
lib/websocket-server-9.2.1.v20140609.jar,
lib/websocket-servlet-9.2.1.v20140609.jar
Export-Package: org.teavm.eclipse.debugger,
org.teavm.eclipse.debugger.ui
Export-Package: org.teavm.eclipse.debugger

View File

@ -34,8 +34,8 @@
</extension>
<extension point="org.eclipse.debug.ui.debugModelPresentations">
<debugModelPresentation
class="org.teavm.eclipse.debugger.TeaVMDebugModelPresentation"
id="org.teavm.eclipse.debugger.thread">
class="org.teavm.eclipse.debugger.ui.TeaVMDebugModelPresentation"
id="org.teavm.eclipse.debugger.frame">
</debugModelPresentation>
</extension>
</plugin>

View File

@ -20,4 +20,6 @@ public class TeaVMEclipsePlugin extends Plugin {
public static TeaVMEclipsePlugin getDefault() {
return defaultInstance;
}
public static final String ID = "org.teavm.eclipse";
}

View File

@ -0,0 +1,19 @@
package org.teavm.eclipse.debugger;
/**
*
* @author Alexey Andreev
*/
public interface 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";
public static final String THREAD_ID = DEBUG_TARGET_ID + ".thread";
public static final String STACK_FRAME_ID = DEBUG_TARGET_ID + ".frame";
public static final String VALUE_ID = DEBUG_TARGET_ID + ".value";
public static final String VARIABLE_ID = DEBUG_TARGET_ID + ".variable";
}

View File

@ -15,6 +15,8 @@ import org.teavm.debugging.Breakpoint;
import org.teavm.debugging.Debugger;
import org.teavm.debugging.DebuggerListener;
import org.teavm.debugging.JavaScriptDebugger;
import static org.teavm.eclipse.debugger.TeaVMDebugConstants.*;
/**
*
@ -80,10 +82,10 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
IJavaLineBreakpoint breakpoint = breakpointBackMap.get(teavmBreakpoint);
if (breakpoint != null) {
try {
if (!teavmBreakpoint.isValid() && teavmDebugger.isAttached()) {
breakpoint.getMarker().setAttribute("org.eclipse.jdt.debug.core.installCount", 0);
if (!teavmBreakpoint.isValid() || !teavmDebugger.isAttached()) {
breakpoint.getMarker().setAttribute(JAVA_BREAKPOINT_INSTALL_COUNT, 0);
} else {
breakpoint.getMarker().setAttribute("org.eclipse.jdt.debug.core.installCount", 1);
breakpoint.getMarker().setAttribute(JAVA_BREAKPOINT_INSTALL_COUNT, 1);
}
DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(breakpoint);
} catch (CoreException e) {
@ -140,8 +142,6 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta markerDelta) {
breakpointRemoved(breakpoint, markerDelta);
breakpointAdded(breakpoint);
}
@Override
@ -200,7 +200,7 @@ public class TeaVMDebugTarget implements IDebugTarget, IStep {
@Override
public String getModelIdentifier() {
return "org.teavm.eclipse.debugger";
return DEBUG_TARGET_ID;
}
@Override

View File

@ -111,7 +111,7 @@ public class TeaVMStackFrame implements IStackFrame {
@Override
public String getModelIdentifier() {
return thread.getModelIdentifier() + ".thread";
return TeaVMDebugConstants.STACK_FRAME_ID;
}
@Override

View File

@ -164,7 +164,7 @@ public class TeaVMThread implements IThread {
@Override
public String getModelIdentifier() {
return debugTarget.getModelIdentifier();
return TeaVMDebugConstants.THREAD_ID;
}
@Override

View File

@ -34,7 +34,7 @@ public class TeaVMValue implements IValue {
@Override
public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.value";
return TeaVMDebugConstants.VALUE_ID;
}
@SuppressWarnings("rawtypes")

View File

@ -7,6 +7,7 @@ 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;
import org.teavm.eclipse.TeaVMEclipsePlugin;
/**
*
@ -25,12 +26,12 @@ public class TeaVMVariable implements IVariable {
@Override
public void setValue(IValue arg0) throws DebugException {
throw new DebugException(new Status(Status.ERROR, "org.teavm.eclipse", "Can't set value"));
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, "org.teavm.eclipse", "Can't set value"));
throw new DebugException(new Status(Status.ERROR, TeaVMEclipsePlugin.ID, "Can't set value"));
}
@Override
@ -60,7 +61,7 @@ public class TeaVMVariable implements IVariable {
@Override
public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.variable";
return TeaVMDebugConstants.VARIABLE_ID;
}
@SuppressWarnings("rawtypes")

View File

@ -1,4 +1,4 @@
package org.teavm.eclipse.debugger;
package org.teavm.eclipse.debugger.ui;
import org.eclipse.core.resources.IFile;
import org.eclipse.debug.core.model.ILineBreakpoint;
@ -9,6 +9,7 @@ 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.eclipse.debugger.TeaVMStackFrame;
/**
*

View File

@ -7,7 +7,6 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@ -23,6 +22,7 @@ public class TeaVMTab extends AbstractLaunchConfigurationTab {
@Override
public void createControl(Composite container) {
Composite root = new Composite(container, SWT.NONE);
setControl(root);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 6;
layout.numColumns = 2;
@ -31,10 +31,8 @@ public class TeaVMTab extends AbstractLaunchConfigurationTab {
Label portLabel = new Label(root, SWT.NONE);
portLabel.setText("&Port");
portLabel.setLayoutData(new GridData(GridData.BEGINNING));
portField = new Text(root, SWT.SINGLE | SWT.BORDER);
portField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
portField.addModifyListener(new ModifyListener() {
@Override public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog();

View File

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