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,18 +148,23 @@ public class Debugger {
} }
public Breakpoint createBreakpoint(SourceLocation location) { public Breakpoint createBreakpoint(SourceLocation location) {
synchronized (breakpoints) {
Breakpoint breakpoint = new Breakpoint(this, location); Breakpoint breakpoint = new Breakpoint(this, location);
breakpoints.put(breakpoint, dummyObject); breakpoints.put(breakpoint, dummyObject);
updateInternalBreakpoints(breakpoint); updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false); updateBreakpointStatus(breakpoint, false);
return breakpoint; return breakpoint;
} }
}
public Set<Breakpoint> getBreakpoints() { public Set<Breakpoint> getBreakpoints() {
return new HashSet<>(breakpoints.keySet()); return new HashSet<>(breakpoints.keySet());
} }
void updateInternalBreakpoints(Breakpoint breakpoint) { void updateInternalBreakpoints(Breakpoint breakpoint) {
if (breakpoint.isDestroyed()) {
return;
}
for (JavaScriptBreakpoint jsBreakpoint : breakpoint.jsBreakpoints) { for (JavaScriptBreakpoint jsBreakpoint : breakpoint.jsBreakpoints) {
breakpointMap.remove(jsBreakpoint); breakpointMap.remove(jsBreakpoint);
jsBreakpoint.destroy(); jsBreakpoint.destroy();
@ -263,11 +268,13 @@ public class Debugger {
} }
private void updateBreakpoints() { private void updateBreakpoints() {
synchronized (breakpointMap) {
for (Breakpoint breakpoint : breakpoints.keySet()) { for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint); updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, true); updateBreakpointStatus(breakpoint, true);
} }
} }
}
public boolean isAttached() { public boolean isAttached() {
return javaScriptDebugger.isAttached(); return javaScriptDebugger.isAttached();
@ -298,10 +305,12 @@ public class Debugger {
} }
private void fireAttached() { private void fireAttached() {
synchronized (breakpointMap) {
for (Breakpoint breakpoint : breakpoints.keySet()) { for (Breakpoint breakpoint : breakpoints.keySet()) {
updateInternalBreakpoints(breakpoint); updateInternalBreakpoints(breakpoint);
updateBreakpointStatus(breakpoint, false); updateBreakpointStatus(breakpoint, false);
} }
}
for (DebuggerListener listener : getListeners()) { for (DebuggerListener listener : getListeners()) {
listener.attached(); listener.attached();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ public class TeaVMValue implements IValue {
@Override @Override
public String getModelIdentifier() { public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.value"; return TeaVMDebugConstants.VALUE_ID;
} }
@SuppressWarnings("rawtypes") @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.IValue;
import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.core.model.IVariable;
import org.teavm.debugging.Variable; import org.teavm.debugging.Variable;
import org.teavm.eclipse.TeaVMEclipsePlugin;
/** /**
* *
@ -25,12 +26,12 @@ public class TeaVMVariable implements IVariable {
@Override @Override
public void setValue(IValue arg0) throws DebugException { 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 @Override
public void setValue(String arg0) throws DebugException { 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 @Override
@ -60,7 +61,7 @@ public class TeaVMVariable implements IVariable {
@Override @Override
public String getModelIdentifier() { public String getModelIdentifier() {
return "org.teavm.eclipse.debugger.variable"; return TeaVMDebugConstants.VARIABLE_ID;
} }
@SuppressWarnings("rawtypes") @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.core.resources.IFile;
import org.eclipse.debug.core.model.ILineBreakpoint; 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.jface.viewers.LabelProvider;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput; 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.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
@ -23,6 +22,7 @@ public class TeaVMTab extends AbstractLaunchConfigurationTab {
@Override @Override
public void createControl(Composite container) { public void createControl(Composite container) {
Composite root = new Composite(container, SWT.NONE); Composite root = new Composite(container, SWT.NONE);
setControl(root);
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.verticalSpacing = 6; layout.verticalSpacing = 6;
layout.numColumns = 2; layout.numColumns = 2;
@ -31,10 +31,8 @@ public class TeaVMTab extends AbstractLaunchConfigurationTab {
Label portLabel = new Label(root, SWT.NONE); Label portLabel = new Label(root, SWT.NONE);
portLabel.setText("&Port"); portLabel.setText("&Port");
portLabel.setLayoutData(new GridData(GridData.BEGINNING));
portField = new Text(root, SWT.SINGLE | SWT.BORDER); portField = new Text(root, SWT.SINGLE | SWT.BORDER);
portField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
portField.addModifyListener(new ModifyListener() { portField.addModifyListener(new ModifyListener() {
@Override public void modifyText(ModifyEvent event) { @Override public void modifyText(ModifyEvent event) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();

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 SourceLookupTab(), new CommonTab() }); setTabs(new ILaunchConfigurationTab[] { new TeaVMTab(), new SourceLookupTab(), new CommonTab() });
} }
} }