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

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

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