Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dr. Michael Petter
CUP Eclipse Plugin
Commits
6f1f8810
Commit
6f1f8810
authored
Dec 05, 2014
by
Johannes Roith
Browse files
Merge branch 'master' of github.com:jroith/cup-eclipse
parents
8f3d1e1f
345ab207
Changes
3
Hide whitespace changes
Inline
Side-by-side
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupContentAssistProcessor.java
View file @
6f1f8810
...
...
@@ -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
()));
}
}
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/wizards/CupFileWizard.java
View file @
6f1f8810
...
...
@@ -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
{
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/wizards/CupJavaProjectWizard.java
View file @
6f1f8810
...
...
@@ -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"
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment