Commit 3823a240 authored by Benedikt Engeser's avatar Benedikt Engeser

änderung zugunsten von Controller.getInstance(IDocument)

parent 91f84c0c
package de.tum.in.www2.cupplugin.controller;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.IDocument;
......@@ -13,7 +14,7 @@ public class Controller {
// Static reference to the controller instance per document
static HashMap<CupTextEditor, Controller> instances = new HashMap<CupTextEditor, Controller>();
static CupTextEditor AnonymousEditor = null;
// attributes
// The Job that's executed after a document change is detected (changeJob)
private DocumentDidChangeJob myJob = null;
......@@ -37,6 +38,16 @@ public class Controller {
return instances.get(edit);
}
}
public static Controller getInstance(IDocument doc) {
for(Map.Entry<CupTextEditor,Controller> e : instances.entrySet()){
if(e.getKey().getDocumentProvider().getDocument(e.getKey().getEditorInput()).equals(doc)){
return e.getValue();
}
}
//this is hacky, but it shouldn't happen anyways...
return getInstance(AnonymousEditor);
}
/*
* The Constructor, taking the editor it's controlling as a parameter
......
......@@ -11,6 +11,7 @@ import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import de.tum.in.www2.cupplugin.controller.Controller;
import java_cup.*;
import java_cup.runtime.ComplexSymbolFactory;
......@@ -30,6 +31,8 @@ public class CupTextEditor extends TextEditor {
public CupTextEditor() {
super();
setSourceViewerConfiguration(new CupSourceViewerConfiguration(this));
//create controller for this editor
Controller.getInstance(this);
// ComplexSymbolFactory f = new ComplexSymbolFactory();
// java_cup.Lexer = new java_cup.Lexer(arg0, f);
}
......
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