Commit 6f1f8810 authored by Johannes Roith's avatar Johannes Roith

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

parents 8f3d1e1f 345ab207
......@@ -3,38 +3,24 @@ package de.tum.in.www2.cupplugin.editors;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.jdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor;
import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor;
import org.eclipse.jdt.internal.ui.text.javadoc.JavadocCompletionProcessor;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.texteditor.ITextEditor;
import de.in.tum.www2.cup.CupSymbol;
import de.in.tum.www2.cup.Declarations;
import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.IDisposable;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.model.*;
@SuppressWarnings("restriction")
public class CupContentAssistProcessor implements IContentAssistProcessor,
IDisposable, ICupParserASTChangeObserver {
......@@ -43,9 +29,8 @@ public class CupContentAssistProcessor implements IContentAssistProcessor,
/*
* TODO: Find the way to get the Java Code assistant here
*/
private IContentAssistProcessor javaProcessor = null;
private IContentAssistProcessor javaProcessor = null;
public CupContentAssistProcessor(IDocument doc) {
this.decls = new Declarations();
......@@ -53,23 +38,15 @@ public class CupContentAssistProcessor implements IContentAssistProcessor,
Model model = Model.getInstanceForDocument(doc);
updateFromParserResult(model.getAstModel());
model.registerModelObserver(this);
this.javaProcessor = getJavaContentAssistProcessor();
}
@SuppressWarnings("restriction")
private IContentAssistProcessor getJavaContentAssistProcessor() {
JavaCompletionProcessor r = null;
return r;
}
public void dispose() {
Model.getInstanceForDocument(doc).unregisterModelObserver(this);
}
......@@ -162,8 +139,8 @@ public class CupContentAssistProcessor implements IContentAssistProcessor,
&& ((myWord.equals("")) || (terminalName.length() >= myWord
.length() && terminalName.substring(0,
myWord.length()).equals(myWord)))) {
proposals.add(new CompletionProposal(terminalName,
offset - myWord.length(), myFullWord.length(),
proposals.add(new CompletionProposal(terminalName, offset
- myWord.length(), myFullWord.length(),
terminalName.length()));
}
}
......
......@@ -75,8 +75,9 @@ public class CupFileWizard extends Wizard implements INewWizard {
final IFile file = container.getFile(new Path(fileName));
try {
ClassLoader cl = this.getClass().getClassLoader();
InputStream stream = cl.getResourceAsStream("/templates/parser.cup");
InputStream stream = cl
.getResourceAsStream("/templates/parser.cup");
if (file.exists()) {
file.setContents(stream, true, true, monitor);
} else {
......
......@@ -2,7 +2,6 @@ package de.tum.in.www2.cupplugin.wizards;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.Thread.State;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -206,25 +205,27 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
IFile parserFile;
if (generateCalculator) {
parserFile = createFile(project, monitor, "parser.cup",
parserFile = createFile(project, monitor, "parser.cup",
getTemplate("parser.cup"));
createFile(project, monitor, "lexer.jflex",
getTemplate("lexer.jflex"));
createFile(project, monitor, "input.txt", getTemplate("input.txt"));
createFile(project, monitor, "build.xml", getTemplate("build_jflex.xml"));
createFile(project, monitor, "build.xml",
getTemplate("build_jflex.xml"));
} else {
parserFile = createFile(project, monitor, "parser.cup",
parserFile = createFile(project, monitor, "parser.cup",
getTemplate("empty_file"));
if (useJflex) {
createFile(project, monitor, "lexer.jflex",
getTemplate("empty_file"));
createFile(project, monitor, "build.xml", getTemplate("build_jflex.xml"));
}else{
createFile(project, monitor, "build.xml", getTemplate("build.xml"));
createFile(project, monitor, "build.xml",
getTemplate("build_jflex.xml"));
} else {
createFile(project, monitor, "build.xml",
getTemplate("build.xml"));
}
}
createFile(exampleDir, monitor, "Driver.java",
......@@ -232,11 +233,10 @@ public class CupJavaProjectWizard extends Wizard implements INewWizard {
IFolder folder = createDirectory(project, monitor, "tools");
if(useJflex){
if (useJflex) {
createFile(folder, monitor, "JFlex.jar", getTemplate("JFlex.jar"));
}
IFile runtimeFile = createFile(folder, monitor,
"java-cup-11b-runtime.jar",
getTemplate("java-cup-11b-runtime.jar"));
......
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