Commit c7d7e77b authored by Johannes Roith's avatar Johannes Roith

Merge branch 'master' of github.com:jroith/cup-eclipse

parents b06d4e8b 6af014cb
......@@ -57,7 +57,7 @@ public class GetDebuggerMappingVisitor extends Visitor<Object>
if (range != null) {
for (int line : lines) {
if (line >= node.getBegin().getLine() &&
line >= node.getEnd().getLine())
line <= node.getEnd().getLine())
{
int lineOffset = line - node.getBegin().getLine();
mappings.add(new Mapping(node.getDebugId(), lineOffset));
......
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CupPlugin
Bundle-SymbolicName: de.tum.in.www2.CupPlugin;singleton:=true
Bundle-Version: 1.0
Bundle-Activator: de.tum.in.www2.cupplugin.Activator
Bundle-Vendor: de.tum.in.www2
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.core.resources,
org.eclipse.ui.editors,
org.eclipse.ui.ide,
org.eclipse.zest.core;bundle-version="1.5.100",
org.eclipse.zest.layouts;bundle-version="1.1.100",
CupReferencedLibraries;bundle-version="1.0.0",
org.eclipse.ui.views;bundle-version="3.7.0",
org.eclipse.core.expressions;bundle-version="3.4.600",
org.eclipse.debug.core;bundle-version="3.9.1",
org.eclipse.debug.ui;bundle-version="3.10.1",
org.eclipse.jdt.core;bundle-version="3.10.0",
org.eclipse.jdt.ui;bundle-version="3.10.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
......@@ -94,6 +94,8 @@ public final class PluginUtility {
return;
}
/**
* Find the generated file that matches our cup file.
* @param cupFile The original cup file.
......@@ -134,4 +136,4 @@ public final class PluginUtility {
}
\ No newline at end of file
}
......@@ -124,7 +124,7 @@ public class DocumentDidChangeJob extends Job {
IFile file = ((FileEditorInput) myEditor.getEditorInput()).getFile();
CupEditorErrorReporter errorReporter = new CupEditorErrorReporter(file);
if (jobs.contains(JobsToDo.parseCode)) {
InputStream in = new ByteArrayInputStream(codeText.getBytes());
......@@ -140,10 +140,10 @@ public class DocumentDidChangeJob extends Job {
e.printStackTrace();
}
//errorReporter.pushToUIThread();
// TODO
// errorReporter.pushToUIThread();
// errorReporter.pushToUIThread();
// TODO
// errorReporter.pushToUIThread();
if (result != null) {
// System.out.println(result.toString());
......@@ -160,31 +160,30 @@ public class DocumentDidChangeJob extends Job {
} else {
return Status.CANCEL_STATUS;
}
}
/*
if (jobs.contains(JobsToDo.buildTable)) {
lalrResult = null;
// try {
// if (!p.hasParseErrors()) {
// lalrResult = LALRResult.Compute(context,
// context.start_production);
// }
// } catch (internal_error e) {
try {
// if (!p.hasParseErrors()) {
lalrResult = LALRResult.Compute(context,
context.start_production);
// }
} catch (internal_error e) {
// TODO Auto-generated catch block
// e.printStackTrace();
// }
errorReporter.pushToUIThread();
e.printStackTrace();
}
// errorReporter.pushToUIThread();
if (lalrResult != null) {
LaLrResultJob resultLaLrModelJob = new LaLrResultJob(lalrResult, revNumber, context);
LaLrResultJob resultLaLrModelJob = new LaLrResultJob(
lalrResult, revNumber, context);
resultLaLrModelJob.setSystem(true);
resultLaLrModelJob.schedule();
try {
......@@ -196,7 +195,7 @@ public class DocumentDidChangeJob extends Job {
} else {
return Status.CANCEL_STATUS;
}
}*/
}
System.out.println(jobs);
......@@ -208,7 +207,7 @@ public class DocumentDidChangeJob extends Job {
CallbackJob cb = new CallbackJob(myEditor);
cb.setSystem(true);
cb.schedule();
return Status.OK_STATUS;
}
......@@ -261,14 +260,15 @@ public class DocumentDidChangeJob extends Job {
LALRResult lalrResult;
long lalrResulRevisionNumber;
CupContext lalrContext;
public LaLrResultJob(LALRResult result, long revisionNumber, CupContext context) {
public LaLrResultJob(LALRResult result, long revisionNumber,
CupContext context) {
super("LaLr Result UI Job");
this.lalrResult = result;
this.lalrResulRevisionNumber = revisionNumber;
this.lalrContext = context;
}
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IDocumentProvider provider = myEditor.getDocumentProvider();
......@@ -277,15 +277,16 @@ public class DocumentDidChangeJob extends Job {
.getEditorInput());
if (document != null) {
Model model = Model.getInstanceForDocument(document);
model.setLaLrResultModel(this.lalrResult, lalrResulRevisionNumber, lalrContext);
model.setLaLrResultModel(this.lalrResult,
lalrResulRevisionNumber, lalrContext);
return Status.OK_STATUS;
}
}
return Status.CANCEL_STATUS;
}
}
class SetupJob extends UIJob {
private DocumentDidChangeJob documentDidChangeJob;
......
......@@ -11,6 +11,7 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
......@@ -18,6 +19,7 @@ import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import de.in.tum.www2.cup.analysis.GetDebuggerMappingVisitor.Mapping;
import de.tum.in.www2.cupplugin.PluginUtility;
public class BreakpointMapper {
......@@ -40,6 +42,11 @@ public class BreakpointMapper {
protected void addRemoteBreakpoint(CupLineBreakpoint origin) {
IJavaLineBreakpoint remote = null;
IResource originResource = origin.getMarker().getResource();
if(originResource == null){
return;
}
IFile resource = PluginUtility.findGenerated(((IFile) origin
.getResource()));
if(resource == null){
......@@ -63,20 +70,23 @@ public class BreakpointMapper {
if(originLineNumber == -1){
return;
}
debugIds.add(originLineNumber);
Mapping debugId = Debugger.getInstance(originResource).getDebugId(originLineNumber);
if(debugId == null){
return;
}
debugIds.add(debugId.getDebugId());
int remoteLineNumber = lineMatcher.debuggerFindCase(debugIds).get(0);
int remoteLineNumber = lineMatcher.debuggerFindCase(debugIds).get(0) + debugId.getLineOffsetFromId();
if(remoteLineNumber == -1){
return;
}
//remoteLineNumber = 5;//TODO nur zum testen
attributes.put(IBreakpoint.PERSISTED, false);
if (resource != null) {
try {
remote = JDIDebugModel.createLineBreakpoint(resource,
Debugger.getGeneratedTargetClass(origin), remoteLineNumber, -1, -1, 0,
Debugger.getInstance(originResource).getGeneratedTargetClass(origin), remoteLineNumber, -1, -1, 0,
true, attributes);
remote.setEnabled(true);
......
......@@ -11,18 +11,21 @@ import org.eclipse.ui.IEditorInput;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.model.Model;
import de.in.tum.www2.cup.analysis.FindNextCodeBlockLineVisitor;
import de.in.tum.www2.cup.analysis.GetDebuggerMappingVisitor;
import de.in.tum.www2.cup.analysis.GetDebuggerMappingVisitor.Mapping;
import de.in.tum.www2.cup.ast.ParserResult;
public class Debugger {
public class Debugger {
static final String DEBUG_ID = "de.tum.www2.cupplugin.debug.Debugger";
// Static reference to the controller instance per document
static HashMap<CupTextEditor, Debugger> instances = new HashMap<CupTextEditor, Debugger>();
static HashMap<IResource, Debugger> delayedInstances = new HashMap<IResource, Debugger>();
private static final BreakpointMapper breakpointMapper = new BreakpointMapper();
private static final String DEFAULT_CLASS = "Test";//TODO: auf Parser umstellen
private static final BreakpointMapper breakpointMapper = new BreakpointMapper();
private static final String DEFAULT_CLASS = "Test";// TODO: auf Parser
// umstellen
/**
* Add Debug hooks to an editor
*
......@@ -70,8 +73,8 @@ public class Debugger {
return instances.get(editor);
}
}
public static BreakpointMapper getBreakpointMapper(){
public static BreakpointMapper getBreakpointMapper() {
return breakpointMapper;
}
......@@ -116,12 +119,13 @@ public class Debugger {
return DefaultBreakPointManager;
}
/**
* Get the next useful location for a breakpointmarker
* @param line the line, the action was triggered on
* @return the next useful line
*/
/**
* Get the next useful location for a breakpointmarker
*
* @param line
* the line, the action was triggered on
* @return the next useful line
*/
public int getNextCodeBlockForLineBreakpoint(int line) {
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider()
......@@ -136,15 +140,50 @@ public class Debugger {
return v.getResult();
}
/**
* The java class in which a remote breakpoint will be set. The Java debugger needs that information to break correctly.
* example: Parser
* Parser$NestedSubClass
* @param breakpoint the breakpoint that asks
* @return the class name
*/
public static String getGeneratedTargetClass(CupLineBreakpoint breakpoint){
/**
* The java class in which a remote breakpoint will be set. The Java
* debugger needs that information to break correctly. example: Parser
* Parser$NestedSubClass
*
* @param breakpoint
* the breakpoint that asks
* @return the class name
*/
public String getGeneratedTargetClass(CupLineBreakpoint breakpoint) {
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider()
.getDocument(myEditor.getEditorInput()));
try {
String rname = m.getAstModel().className.getName().name;
if (!rname.trim().equals("")) {
return rname;
}
} catch (NullPointerException e) {
return DEFAULT_CLASS;
}
return DEFAULT_CLASS;
}
public Mapping getDebugId(int lineNumber) {
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider()
.getDocument(myEditor.getEditorInput()));
ParserResult astModel = m.getAstModel();
if (astModel == null) {
return null;
}
// create Visitor
int lines[] = {lineNumber};
GetDebuggerMappingVisitor v = new GetDebuggerMappingVisitor(lines);
astModel.accept(v, null);
if(v.getMappings().size() < 1){
return null;
}
return v.getMappings().get(0);
}
}
\ No newline at end of file
......@@ -30,10 +30,12 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
import org.eclipse.zest.core.viewers.EntityConnectionData;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IEntityConnectionStyleProvider;
import org.eclipse.zest.core.viewers.IEntityStyleProvider;
import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
import org.eclipse.zest.core.viewers.internal.ZoomManager;
import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutAlgorithm;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.CompositeLayoutAlgorithm;
......@@ -314,9 +316,10 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
}
visitedStates.add(state.getState());
lalr_transition trans = state.getState().transitions();
//System.out.println("Trans Symbol is non term: "+trans.on_symbol().is_non_term());
while (trans != null) {
if (visitedStates.contains(trans.to_state())
|| !trans.on_symbol().is_non_term()) {
|| trans.on_symbol().is_non_term()) {
trans = trans.next();
continue;
} else {
......@@ -333,7 +336,7 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
trans = state.getState().transitions();
while (trans != null) {
if (visitedStates.contains(trans.to_state())
|| trans.on_symbol().is_non_term()) {
|| !trans.on_symbol().is_non_term()) {
trans = trans.next();
continue;
} else {
......@@ -531,7 +534,7 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
}
static class ParserConflictLabelProvider extends LabelProvider implements
IEntityStyleProvider {
IEntityStyleProvider, IEntityConnectionStyleProvider {
private List<ParserConflictConnection> connections;
......@@ -570,8 +573,8 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
@Override
public Color getNodeHighlightColor(Object entity) {
// TODO Auto-generated method stub
return null;
Device device = Display.getCurrent();
return device.getSystemColor(SWT.COLOR_BLUE);
}
@Override
......@@ -600,10 +603,10 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
ParserConflictNode n = (ParserConflictNode) entity;
if (showColordStartState && n.id == 0) {
Device device = Display.getCurrent();
return new Color(device, 255, 0, 0);
return device.getSystemColor(SWT.COLOR_RED);
} else if (showColordEndStates && n.getConnectedTo().isEmpty()) {
Device device = Display.getCurrent();
return new Color(device, 255, 255, 0);
return device.getSystemColor(SWT.COLOR_GREEN);
}
return null;
}
......@@ -612,7 +615,6 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
@Override
public Color getForegroundColour(Object entity) {
// TODO Auto-generated method stub
return null;
}
......@@ -633,6 +635,29 @@ public class CupConflictGraphView implements CupParserLaLrChangeObserver,
// TODO Auto-generated method stub
return false;
}
@Override
public int getConnectionStyle(Object src, Object dest) {
return ZestStyles.CONNECTIONS_DIRECTED;
}
@Override
public Color getColor(Object src, Object dest) {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getHighlightColor(Object src, Object dest) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getLineWidth(Object src, Object dest) {
// TODO Auto-generated method stub
return 0;
}
}
}
......@@ -46,6 +46,7 @@ import org.eclipse.ui.progress.UIJob;
import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
import org.eclipse.zest.core.viewers.EntityConnectionData;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IEntityConnectionStyleProvider;
import org.eclipse.zest.core.viewers.IEntityStyleProvider;
import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
......@@ -54,6 +55,7 @@ import org.eclipse.zest.core.viewers.internal.ZoomManager;
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutAlgorithm;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.CompositeLayoutAlgorithm;
......@@ -112,7 +114,9 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
ParserReduceLabelProvider labelProvider = new ParserReduceLabelProvider(
nodeModel.getConnections());
graphViewer.setLabelProvider(labelProvider);
//graphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
graphViewer.setInput(nodeModel.getNodes());
LayoutAlgorithm layout = new CompositeLayoutAlgorithm(
......@@ -212,6 +216,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
if (e.widget instanceof Combo) {
Combo c = (Combo)e.widget;
int idx = c.getSelectionIndex();
String s = levels[idx];
zoomManager.setZoomAsText(levels[idx]);
}
System.out.println(e.widget + " - Default Selection");
......@@ -237,7 +242,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
graphViewer.applyLayout();
synchronized (CupReduceGraphView.modelBuildLock) {
graphViewer.refresh();
}
}
}
@Override
......@@ -516,7 +521,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
}
static class ParserReduceLabelProvider extends LabelProvider implements
IEntityStyleProvider {
IEntityStyleProvider, IEntityConnectionStyleProvider {
private List<ParserReduceConnection> connections;
......@@ -555,8 +560,8 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
@Override
public Color getNodeHighlightColor(Object entity) {
// TODO Auto-generated method stub
return null;
Device device = Display.getCurrent();
return device.getSystemColor(SWT.COLOR_BLUE);
}
@Override
......@@ -585,10 +590,10 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
ParserReduceNode n = (ParserReduceNode) entity;
if (showColordStartState && n.id == 0) {
Device device = Display.getCurrent();
return new Color(device, 255, 0, 0);
return device.getSystemColor(SWT.COLOR_RED);
} else if (showColordEndStates && n.getConnectedTo().isEmpty()) {
Device device = Display.getCurrent();
return new Color(device, 255, 255, 0);
return device.getSystemColor(SWT.COLOR_GREEN);
}
return null;
}
......@@ -597,7 +602,6 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
@Override
public Color getForegroundColour(Object entity) {
// TODO Auto-generated method stub
return null;
}
......@@ -619,6 +623,29 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
return false;
}
@Override
public int getConnectionStyle(Object src, Object dest) {
return ZestStyles.CONNECTIONS_DIRECTED;
}
@Override
public Color getColor(Object src, Object dest) {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getHighlightColor(Object src, Object dest) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getLineWidth(Object src, Object dest) {
// TODO Auto-generated method stub
return 0;
}
}
static class CupToolTipHelper extends PopUpHelper {
......
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