Commit 83b49960 authored by Sebastian Pretscher's avatar Sebastian Pretscher

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

Conflicts:
	CupPlugin/src/de/tum/in/www2/cupplugin/controller/DocumentDidChangeJob.java
parents ea6781c5 591a80ea
......@@ -14,6 +14,10 @@ local.properties
.settings/
.loadpath
# generated files
CupParser/src/de/in/tum/www2/cup/internal/Lexer.java
CupParser/src/de/in/tum/www2/cup/internal/Parser.java
# External tool builders
.externalToolBuilders/
......
<project name="Compiler" default ="compile" basedir=".">
<property name="cup" location="src/cup" />
<property name="jflex" location="src/jflex" />
<property name="java" location="src" />
<property name="classes" location="bin/cls" />
<property name="result" location="bin/jar" />
<property name="lib" location="lib" />
<property name="tools" location="tools" />
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="${tools}/JFlex.jar" />
<taskdef name="cup" classname="java_cup.anttask.CUPTask" classpath="${tools}/java-cup-11b.jar" />
<target name="generate">
<jflex file="${jflex}/Lexer.jflex" destdir="${java}" />
<cup srcfile="${cup}/Parser.cup" destdir="${java}"
<property name="cup" location="src/cup" />
<property name="jflex" location="src/jflex" />
<property name="java" location="src" />
<property name="classes" location="bin/cls" />
<property name="result" location="bin/jar" />
<property name="lib" location="lib" />
<property name="tools" location="tools" />
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="${tools}/JFlex.jar" />
<taskdef name="cup" classname="java_cup.anttask.CUPTask" classpath="${tools}/java-cup-11b.jar" />
<target name="generate">
<jflex file="${jflex}/Lexer.jflex" destdir="${java}" />
<cup srcfile="${cup}/Parser.cup" destdir="${java}"
parser="Parser" interface="true" locations="false" />
</target>
<path id="libraries">
<files includes="${lib}/java-cup-11b-runtime.jar" />
</path>
<target name="compile" depends="generate">
<mkdir dir="${classes}"/>
<mkdir dir="${result}"/>
<javac srcdir="${java}" destdir="${classes}">
<classpath refid="libraries" />
</javac>
<jar destfile="${result}/CupParser.jar" basedir="${classes}">
<manifest>
</manifest>
</jar>
<echo>Deploy in </echo>
<copy todir="../CupReferencedLibraries/" overwrite="true">
<fileset dir="${result}/" includes="*.jar"/>
</copy>
</target>
<target name="clean">
<delete file="${java}/Parser.java" />
<delete file="${java}/sym.java" />
<delete file="${java}/Scanner.java" />
<delete dir="${classes}" />
<delete dir="${result}" />
</target>
</target>
<path id="libraries"> <files includes="${lib}/java-cup-11b-runtime.jar" /> </path>
<target name="compile" depends="generate">
<mkdir dir="${classes}"/>
<mkdir dir="${result}"/>
<javac srcdir="${java}" destdir="${classes}">
<classpath refid="libraries" />
</javac>
<jar destfile="${result}/CupParser.jar" basedir="${classes}">
<manifest>
</manifest>
</jar>
</target>
<target name="clean">
<delete file="${java}/Parser.java" />
<delete file="${java}/sym.java" />
<delete file="${java}/Scanner.java" />
<delete dir="${classes}" />
<delete dir="${result}" />
</target>
</project>
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,5 +34,15 @@
extensions="cup">
</participant>
</extension>
<extension
id="org.tum.in.www2.cupplugin.markers.problem"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<persistent
value="true">
</persistent>
</extension>
</plugin>
......@@ -24,7 +24,7 @@ public class Controller {
private final Object lock = new Object();
/*
* Static singelton getter
* Static singleton getter
*/
public static Controller getInstance(IDocument doc) {
Controller instance = instances.get(doc);
......
......@@ -3,6 +3,7 @@ package de.tum.in.www2.cupplugin.controller;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
......
package de.tum.in.www2.cupplugin.editors;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
......@@ -7,13 +10,41 @@ import de.tum.in.www2.cupplugin.controller.Controller;
class CTEDocumentListener implements IDocumentListener {
@Override
private IFile file;
public CTEDocumentListener(IFile file) {
this.file = file;
}
public void documentAboutToBeChanged(DocumentEvent event) {
return;
}
@Override
public void documentChanged(DocumentEvent event) {
// TODO: does not belong here...
try {
// file.findMarker();
IMarker marker;
marker = file.createMarker("org.tum.in.www2.cupplugin.markers.problem");
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute(IMarker.MESSAGE, "hello world from problem marker!");
marker.setAttribute(IMarker.LINE_NUMBER, 3);
// marker.delete();
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("starting job chain"); // Log message TODO: DELETE!
Controller controller = Controller.getInstance(event.getDocument());
controller.notifyChange();
......
package de.tum.in.www2.cupplugin.editors;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.swt.widgets.MessageBox;
public class CupContentOutlinePage extends ContentOutlinePage {
class LabelProvider implements ILabelProvider {
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return true;
}
public void removeListener(ILabelProviderListener listener) {
}
public Image getImage(Object element) {
return null;
}
public String getText(Object element) {
return "hello";
}
}
class Entry {
public int id;
public Entry(int id) {
this.id = id;
}
}
class ContentProvider implements ITreeContentProvider {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
// handles the root object.
return getChildren(inputElement);
}
public Object[] getChildren(Object parentElement) {
int id = ((Entry) parentElement).id + 1;
return new Object[] { new Entry(id), new Entry(id+1) };
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
if (((Entry) element).id < 10)
return true;
return false;
}
}
@Override
public void createControl(Composite parent) {
super.createControl(parent);
TreeViewer viewer = getTreeViewer();
viewer.setContentProvider(new ContentProvider());
viewer.setLabelProvider(new LabelProvider());
viewer.addSelectionChangedListener(this);
viewer.setInput(new Entry(3));
viewer.refresh();
viewer.expandAll();
}
}
......@@ -7,7 +7,6 @@ import org.eclipse.jface.text.rules.FastPartitioner;
public class CupDocumentSetupParticipant implements IDocumentSetupParticipant {
@Override
public void setup(IDocument document) {
IDocumentPartitioner partitioner = new FastPartitioner(new CupPartionScanner(), CupPartionScanner.PARTITION_TYPES);
document.setDocumentPartitioner(partitioner);
......
......@@ -42,7 +42,6 @@ public class CupGraphView implements CupGraphModelObserver {
g.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
}
@Override
public void modelChanged(Model model) {
// TODO Auto-generated method stub
......
......@@ -90,7 +90,6 @@ public class CupPartionScanner extends RuleBasedPartitionScanner {
/*
* @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
*/
@Override
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
return super.evaluate(scanner);
}
......
......@@ -76,7 +76,6 @@ public class CupSourceViewerConfiguration extends SourceViewerConfiguration {
sym.NON, sym.PRECEDENCE, sym.INIT, sym.CODE, sym.EXTENDS);
private List<Integer> constants = Arrays.asList();
@Override
public void setRange(IDocument document, int offset, int length) {
scanner = new CupScanner(new DefaultErrorReporter(), new StringReader(document.get()
......@@ -86,7 +85,6 @@ public class CupSourceViewerConfiguration extends SourceViewerConfiguration {
}
@Override
public IToken nextToken() {
try {
last = (ComplexSymbol)scanner.next_token();
......@@ -106,13 +104,11 @@ public class CupSourceViewerConfiguration extends SourceViewerConfiguration {
}
}
@Override
public int getTokenOffset() {
int mOffset = this.offset + last.left;
return mOffset;
}
@Override
public int getTokenLength() {
int length = last.right-last.left;
return length;
......
......@@ -9,12 +9,15 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import java_cup.*;
import java_cup.runtime.ComplexSymbolFactory;
public class CupTextEditor extends TextEditor {
private CupContentOutlinePage outlinePage;
static Color blue = new Color (Display.getCurrent(), 0, 0, 255);
static Color green = new Color (Display.getCurrent(), 0, 255, 0);
static Color red = new Color (Display.getCurrent(), 255, 0, 0);
......@@ -31,7 +34,16 @@ public class CupTextEditor extends TextEditor {
// java_cup.Lexer = new java_cup.Lexer(arg0, f);
}
public Object getAdapter(Class required) {
if (IContentOutlinePage.class.equals(required)) {
if (outlinePage == null) {
outlinePage = new CupContentOutlinePage();
// getDocumentProvider(), this);
// outlinePage.setInput(getEditorInput());
}
return outlinePage;
}
return super.getAdapter(required);
}
}
......@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
......@@ -207,6 +208,8 @@ public class MultiPageEditor extends MultiPageEditorPart implements IResourceCha
boolean addHooksToMainTextEditor(ITextEditor editor) {
IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
// Add Document listener to react on changes
IDocumentProvider dp = editor.getDocumentProvider();
if(dp == null){
......@@ -216,7 +219,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements IResourceCha
if(doc == null){
return false;
}
doc.addDocumentListener(new CTEDocumentListener());
doc.addDocumentListener(new CTEDocumentListener(file));
return true;
}
......
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