Initial commit.
This commit is contained in:
commit
0c2d6f4ee7
16
JavaCompilerPlugin/.classpath
Normal file
16
JavaCompilerPlugin/.classpath
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/JavaCompilerCoreOsgiInline/target/JavaCompilerCoreOsgiInline-0.1.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
2
JavaCompilerPlugin/.gitignore
vendored
Normal file
2
JavaCompilerPlugin/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.settings/
|
||||
/target/
|
7
JavaCompilerPlugin/.mvn/extensions.xml
Normal file
7
JavaCompilerPlugin/.mvn/extensions.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.eclipse.tycho.extras</groupId>
|
||||
<artifactId>tycho-pomless</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</extension>
|
||||
</extensions>
|
23
JavaCompilerPlugin/.project
Normal file
23
JavaCompilerPlugin/.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="/JavaCompilerCoreOsgiInline/target/JavaCompilerCoreOsgiInline-0.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
3
JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/.gitignore
vendored
Normal file
3
JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/target/
|
||||
/.settings/
|
||||
/bin/
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin.Plugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,18 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Plugin
|
||||
Bundle-SymbolicName: JavaCompilerPlugin.Plugin;singleton:=true
|
||||
Bundle-Version: 0.1.0
|
||||
Bundle-Vendor: de.dhbwstuttgart
|
||||
Automatic-Module-Name: JavaCompilerPlugin.Plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.jface.text,
|
||||
org.eclipse.ui.editors,
|
||||
org.eclipse.ui.workbench,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.ui.ide,
|
||||
org.eclipse.ui.views,
|
||||
de.dhbwstuttgart.JavaCompilerCoreOsgi
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-Activator: typinferenzplugin.Activator
|
@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
@ -0,0 +1,64 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
* @author Andreas Stadelmeier
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "TypinferenzPlugin"; //$NON-NLS-1$
|
||||
|
||||
public static final String TYPINFERENZMARKER_NAME = "typinferenzplugin.replacemarker";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given
|
||||
* plug-in relative path
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return imageDescriptorFromPlugin(PLUGIN_ID, path);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class CodePoint {
|
||||
|
||||
public final Token offset;
|
||||
|
||||
public CodePoint(Token offset){
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public int getPositionInCode() {
|
||||
return offset.getStartIndex();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj){
|
||||
if(!(obj instanceof CodePoint))return false;
|
||||
CodePoint p = (CodePoint) obj;
|
||||
if(p.getPositionInCode()!=this.getPositionInCode())return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
|
||||
import typinferenzplugin.editor.JavEditor;
|
||||
|
||||
public class ErrorMarker extends JavMarker{
|
||||
|
||||
private String message;
|
||||
private CodePoint point;
|
||||
|
||||
public ErrorMarker(String message ,CodePoint p){
|
||||
this.message = message;
|
||||
this.point = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(){
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
String ret = "";
|
||||
ret+="ErrorMarker: "+this.getMessage();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodePoint getPoint() {
|
||||
return this.point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object eq){
|
||||
if(! (eq instanceof ErrorMarker))return false;
|
||||
ErrorMarker equals = (ErrorMarker) eq;
|
||||
if(!(equals.point.equals(this.point)))return false;
|
||||
if(!(equals.getMessage().equals(this.getMessage())))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnnotation(Annotation addAnnotation) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
|
||||
public abstract class JavMarker {
|
||||
|
||||
private Annotation annotation;
|
||||
|
||||
public abstract CodePoint getPoint();
|
||||
public abstract String getMessage();
|
||||
|
||||
public void setAnnotation(Annotation addAnnotation) {
|
||||
this.annotation = addAnnotation;
|
||||
}
|
||||
|
||||
public Annotation getAnnotation() {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertPoint;
|
||||
import typinferenzplugin.editor.JavEditor;
|
||||
|
||||
public class TypeReplaceMarker extends JavMarker{
|
||||
|
||||
private JavEditor editor;
|
||||
private CodePoint point;
|
||||
private TypeInsert tip;
|
||||
|
||||
public TypeReplaceMarker(JavEditor editor, TypeInsert point){
|
||||
this.editor = editor;
|
||||
this.point = new CodePoint(point.point.point);
|
||||
this.tip = point;
|
||||
}
|
||||
|
||||
public void run(){
|
||||
editor.runReplaceMarker(this);
|
||||
}
|
||||
|
||||
public TypeInsert getInsertPoint() {
|
||||
return tip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
String ret = "";
|
||||
ret+="TypeReplaceMarker: "+tip.toString();
|
||||
/*
|
||||
for(TypeInsertPoint point : this.points.points){
|
||||
ret+=point.getTypeInsertString()+", ";
|
||||
}
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodePoint getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
String ret = "";
|
||||
/*
|
||||
Iterator<TypeInsertPoint> it = this.points.points.iterator();
|
||||
while(it.hasNext()){
|
||||
ret+=it.next().getTypeInsertString();
|
||||
if(it.hasNext())ret+=", ";
|
||||
}
|
||||
*/
|
||||
ret+=this.tip.getInsertString()+" einsetzen";
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String insertType(String fileContent) {
|
||||
return this.tip.insert(fileContent);
|
||||
}
|
||||
|
||||
/* PL 2018-06-18
|
||||
* Zwei TypeReplaceMarkers's sind gleich , wenn ihre tip's gleich sind
|
||||
* eingefuegt damit man TypeReplaceMarker vergleichen kann
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof TypeReplaceMarker)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return ((TypeReplaceMarker)obj).tip.equals(this.tip);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package typinferenzplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.bcel.classfile.JavaClass;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.exceptions.*;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import typinferenzplugin.editor.JavEditor;
|
||||
import typinferenzplugin.error.ErrorOutput;
|
||||
import java.util.*;
|
||||
|
||||
public class Typinferenz {
|
||||
|
||||
private JavEditor editor;
|
||||
private SourceFile parsedSource;
|
||||
|
||||
public Typinferenz(JavEditor forEditor)
|
||||
{
|
||||
this.editor = forEditor;
|
||||
}
|
||||
|
||||
public Vector<TypeReplaceMarker> run() throws TypeinferenceException{
|
||||
Vector<TypeReplaceMarker> ret = new Vector<TypeReplaceMarker>();
|
||||
try{
|
||||
//JavaTXCompiler compiler = new JavaTXCompiler(Arrays.asList(editor.getFilePath().toFile()), false);
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(editor.getFilePath().toFile(), false);
|
||||
this.parsedSource = compiler.sourceFiles.get(editor.getFilePath().toFile());
|
||||
List<ResultSet> tiResults = compiler.typeInference();
|
||||
Set<TypeInsert> tips = new HashSet<>();
|
||||
for(ResultSet tiResult : tiResults) {
|
||||
tips.addAll(TypeInsertFactory.createTypeInsertPoints(parsedSource, tiResult));
|
||||
int numberOfSolutions = 0; //Zählt mit, wie viele verschiedene Lösungen angeboten werden
|
||||
for(TypeInsert p : tips){
|
||||
TypeReplaceMarker toAdd = new TypeReplaceMarker(editor,p);
|
||||
if(!ret.contains(toAdd)){
|
||||
ret.add(toAdd);
|
||||
}
|
||||
else{
|
||||
System.out.println("Marker bereits vorhanden: "+toAdd.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//Bytecode generieren:
|
||||
String outputDirectory = editor.getFilePath().toString();
|
||||
outputDirectory = outputDirectory.substring(0, outputDirectory.length()-editor.getFilePath().lastSegment().length());//".jav" hat länge 4
|
||||
List<ByteCodeResult> bytecodeResults = compiler.generateBytecode(parsedSourceFiles, new TypeinferenceResults(results));
|
||||
for(ByteCodeResult result: bytecodeResults){
|
||||
JavaClass javaClass = result.getByteCode().getJavaClass();
|
||||
javaClass.dump(new File(outputDirectory+javaClass.getClassName()+".class"));
|
||||
|
||||
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
||||
JavaClass jc = cg.getJavaClass();
|
||||
jc.dump(new File(outputDirectory+jc.getClassName()+".class"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
String outputDirectory = editor.getFilePath().toString();
|
||||
outputDirectory = outputDirectory.substring(0, outputDirectory.length()-editor.getFilePath().lastSegment().length());//".jav" hat länge 4
|
||||
//if(tips.size() == 0 && tiResults.size()>0) {
|
||||
if(tiResults.size()>0) {
|
||||
for(SourceFile sf : compiler.sourceFiles.values()){
|
||||
//HashMap<String,byte[]> bytecode = getBytecode(sf, tiResults.get(0));
|
||||
HashMap<String,byte[]> bytecode = getBytecode(sf, tiResults, outputDirectory);
|
||||
this.writeClassFile(outputDirectory, bytecode);
|
||||
}
|
||||
}
|
||||
}catch(TypeinferenceException texc){
|
||||
throw texc; //Die aufrufende Instanz sollte daraus dann einen ErrorMarker generieren.
|
||||
}catch(Exception exc){
|
||||
exc.printStackTrace(); //Hier wird kein Marker generiert... nur Debug-Output
|
||||
new ErrorOutput("Fehler beim Parsen und Inferieren");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String,byte[]> getBytecode(SourceFile sf, List<ResultSet> resultSets, String path) {
|
||||
HashMap<String,byte[]> classFiles = new HashMap<>();
|
||||
BytecodeGen bytecodeGen = new BytecodeGen(classFiles, resultSets, sf, path);
|
||||
bytecodeGen.visit(sf);
|
||||
return bytecodeGen.getClassFiles();
|
||||
}
|
||||
|
||||
public void writeClassFile(String outputDirectory, HashMap<String,byte[]> classFiles) {
|
||||
FileOutputStream output;
|
||||
for(String name : classFiles.keySet()) {
|
||||
byte[] bytecode = classFiles.get(name);
|
||||
try {
|
||||
System.out.println("generating"+name+ ".class file");
|
||||
//output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
|
||||
output = new FileOutputStream(new File(outputDirectory +name+".class"));
|
||||
output.write(bytecode);
|
||||
output.close();
|
||||
System.out.println(name+".class file generated");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SourceFile getSourceFile() {
|
||||
return parsedSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.reconciler.DirtyRegion;
|
||||
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
|
||||
|
||||
//Die Methoden in dieser Klasse werden wohl aufgerufen, wenn im Editor eine Datei verändert wird.
|
||||
//Kann also zum dynamischen generieren von Annotations genutzt werden.
|
||||
public class AnnotationProvider implements IReconcilingStrategy{
|
||||
|
||||
@Override
|
||||
public void setDocument(IDocument document) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconcile(IRegion partition) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,271 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import typinferenzplugin.*;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.internal.resources.Marker;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.editors.text.TextEditor;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
|
||||
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
|
||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import typinferenzplugin.TypeReplaceMarker;
|
||||
import typinferenzplugin.Typinferenz;
|
||||
import typinferenzplugin.error.ErrorOutput;
|
||||
|
||||
//Example from: http://help.eclipse.org/indigo/index.jsp
|
||||
/**
|
||||
* Editor für .jav-Dateien
|
||||
* Anmerkung: Für jede geöffnete Datei wird eine Instanz des Editors erstellt
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class JavEditor extends TextEditor{
|
||||
private Typinferenz typeinference;
|
||||
|
||||
private JavOutline outlinePage;
|
||||
/**
|
||||
* Der SyntaxBaum für das aktuell geöffnete Dokument.
|
||||
*/
|
||||
private SourceFile sourceFile;
|
||||
|
||||
/**
|
||||
* Die TypeReplaceMarker für das aktuell geöffnete Dokument
|
||||
*/
|
||||
private Vector<JavMarker> errorMarkers = new Vector<JavMarker>();
|
||||
|
||||
private Vector<TypeReplaceMarker> typeReplaceMarkers = new Vector<TypeReplaceMarker>();
|
||||
|
||||
//Help: http://wiki.eclipse.org/FAQ_How_do_I_get_started_with_creating_a_custom_text_editor%3F
|
||||
public JavEditor(){
|
||||
super();
|
||||
//install the source configuration
|
||||
//setSourceViewerConfiguration(new HTMLConfiguration());
|
||||
//install the document provider
|
||||
//setDocumentProvider(new HTMLDocumentProvider());
|
||||
typeinference = new Typinferenz(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void doSetInput(IEditorInput input) throws CoreException {
|
||||
super.doSetInput(input);
|
||||
this.typeReconstruction(); // Marker generieren
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on AbstractTextEditor
|
||||
*/
|
||||
protected void initializeEditor() {
|
||||
super.initializeEditor();
|
||||
setSourceViewerConfiguration(new JavViewerConfiguration(this));
|
||||
//install the document provider
|
||||
//setDocumentProvider(new JavFileProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave(IProgressMonitor monitor) {
|
||||
super.doSave(monitor);
|
||||
//Wird aufgerufen, sobald das Dokument gespeichert wird.
|
||||
this.removeMarkers();
|
||||
this.typeReconstruction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Typinferenzalgorithmus, zuvor sollten alle Marker entfernt werden
|
||||
*/
|
||||
private void typeReconstruction() {
|
||||
Vector<JavMarker> markers= new Vector<JavMarker>();
|
||||
if(!this.typeReplaceMarkers.isEmpty() || !this.errorMarkers.isEmpty()){
|
||||
new ErrorOutput("Fehler: Zuerst Marker löschen, bevor Typinferenz durchgeführt werden kann");
|
||||
return;
|
||||
}
|
||||
//this.typeReplaceMarkers = new Vector<TypeReplaceMarker>();
|
||||
//this.errorMarkers = new Vector<JavMarker>();
|
||||
try{
|
||||
this.typeReplaceMarkers = typeinference.run();
|
||||
for(TypeReplaceMarker m : this.getTypeReplaceMarkers()){
|
||||
markers.add(m);
|
||||
};
|
||||
}catch(TypeinferenceException texc){
|
||||
markers.add(new ErrorMarker(texc.getMessage(),new CodePoint(texc.getOffset())));
|
||||
}
|
||||
//Anschließend die TypeReplaceMarker im Quellcode anzeigen: https://stackoverflow.com/questions/8945371/how-to-implement-quick-fix-quick-assist-for-custom-eclipse-editor
|
||||
System.out.println("Typinferez durchgeführt. Berechnete Marker:\n"+markers);
|
||||
|
||||
IResource activeDocument = extractResource();
|
||||
if(activeDocument == null){
|
||||
new ErrorOutput("Kann das aktive Dokument nicht ermitteln");
|
||||
}else{
|
||||
this.placeMarkers(activeDocument, markers);
|
||||
}
|
||||
this.sourceFile = typeinference.getSourceFile();
|
||||
this.updateOutlinePage();
|
||||
//this.outlinePage.update(this.sourceFile,this.markers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
IResource extractResource() {
|
||||
IEditorInput input = this.getEditorInput();
|
||||
if (!(input instanceof IFileEditorInput))
|
||||
return null;
|
||||
return ((IFileEditorInput)input).getFile();
|
||||
}
|
||||
|
||||
private void placeMarkers(IResource inDocument, Vector<? extends JavMarker> markers){
|
||||
//Marker Tut: http://wiki.eclipse.org/FAQ_How_do_I_create_my_own_tasks,_problems,_bookmarks,_and_so_on%3F
|
||||
//ResourceMarkerAnnotationModel model = new ResourceMarkerAnnotationModel(inDocument.);
|
||||
for(JavMarker rm : markers){
|
||||
CodePoint point = rm.getPoint();
|
||||
try {
|
||||
IMarker m = inDocument.createMarker(Activator.TYPINFERENZMARKER_NAME);
|
||||
m.setAttribute(IMarker.CHAR_START, point.getPositionInCode());
|
||||
m.setAttribute(IMarker.CHAR_END, point.getPositionInCode()+1);
|
||||
String message = rm.getMessage();
|
||||
m.setAttribute(IMarker.MESSAGE, message);
|
||||
m.setAttribute(IMarker.SEVERITY, 1);
|
||||
rm.setAnnotation(this.addAnnotation(m, point.getPositionInCode()));
|
||||
} catch (CoreException e) {
|
||||
new ErrorOutput("Fehler beim Generieren eines Markers");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Annotation addAnnotation(IMarker marker, int offset) {
|
||||
//The DocumentProvider enables to get the document currently loaded in the editor
|
||||
IDocumentProvider idp = this.getDocumentProvider();
|
||||
|
||||
//This is the document we want to connect to. This is taken from
|
||||
//the current editor input.
|
||||
IDocument document = idp.getDocument(this.getEditorInput());
|
||||
|
||||
//The IannotationModel enables to add/remove/change annotation to a Document
|
||||
//loaded in an Editor
|
||||
IAnnotationModel iamf = idp.getAnnotationModel(this.getEditorInput());
|
||||
|
||||
//Note: The annotation type id specify that you want to create one of your
|
||||
//annotations
|
||||
SimpleMarkerAnnotation ma = new SimpleMarkerAnnotation("typinferenzplugin.annotation",marker);
|
||||
|
||||
//Finally add the new annotation to the model
|
||||
iamf.connect(document);
|
||||
iamf.addAnnotation(ma,new Position(offset,1));
|
||||
iamf.disconnect(document);
|
||||
return ma;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht die zu marker gehörende Annotation
|
||||
* @param marker
|
||||
*/
|
||||
private void deleteAnnotation(JavMarker marker){
|
||||
IDocumentProvider idp = this.getDocumentProvider();
|
||||
IDocument document = idp.getDocument(this.getEditorInput());
|
||||
IAnnotationModel iamf = idp.getAnnotationModel(this.getEditorInput());
|
||||
|
||||
iamf.connect(document);
|
||||
iamf.removeAnnotation(marker.getAnnotation());
|
||||
iamf.disconnect(document);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Outline-View
|
||||
*/
|
||||
public Object getAdapter(Class required) {
|
||||
if (IContentOutlinePage.class.equals(required)) {
|
||||
if (outlinePage == null) {
|
||||
outlinePage= new JavOutline(this.sourceFile, this.getTypeReplaceMarkers());
|
||||
}
|
||||
this.updateOutlinePage();
|
||||
return outlinePage;
|
||||
}
|
||||
return super.getAdapter(required);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Diese Funktion führt einen ReplaceMarker aus.
|
||||
* @param typeReplaceMarker
|
||||
*/
|
||||
public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) {
|
||||
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
|
||||
document.set(typeReplaceMarker.insertType(document.get()));
|
||||
this.removeMarkers();
|
||||
//Erneut den Typinferenzalgorithmus ausführen:
|
||||
this.typeReconstruction();
|
||||
}
|
||||
|
||||
private void removeMarkers(){
|
||||
IResource document = this.extractResource();
|
||||
try {
|
||||
document.deleteMarkers(Activator.TYPINFERENZMARKER_NAME, true, IProject.DEPTH_INFINITE);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for(JavMarker jm : errorMarkers)this.deleteAnnotation(jm);
|
||||
for(JavMarker jm : typeReplaceMarkers)this.deleteAnnotation(jm);
|
||||
this.errorMarkers.removeAllElements();
|
||||
this.typeReplaceMarkers.removeAllElements();
|
||||
this.updateOutlinePage();
|
||||
//this.outlinePage.update(sourceFile, markers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die OutlinePage, falls vorhanden.
|
||||
* Muss nach Änderungen an markers aufgerufen werden.
|
||||
*/
|
||||
private void updateOutlinePage() {
|
||||
if(this.outlinePage!= null && this.sourceFile != null && this.errorMarkers != null)
|
||||
this.outlinePage.update(sourceFile, this.getTypeReplaceMarkers());
|
||||
}
|
||||
|
||||
public String getSourceCode() {
|
||||
return this.getDocumentProvider().getDocument(this.getEditorInput()).get();
|
||||
}
|
||||
|
||||
private Vector<TypeReplaceMarker> getTypeReplaceMarkers(){
|
||||
return this.typeReplaceMarkers ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt die momentan an dem Dokument, für welches dieser Editor zuständig ist, angebrachten TypeReplaceMarker.
|
||||
* Dabei werden die ReplaceMarker herausgefiltert, welche mindestens einen Typ an dem übergebenen offset einsetzen.
|
||||
* @param offset
|
||||
* @return
|
||||
*/
|
||||
public Vector<TypeReplaceMarker> getMarkersAt(int offset){
|
||||
return null;
|
||||
}
|
||||
|
||||
public IPath getFilePath() {
|
||||
return ((FileEditorInput) this.getEditorInput()).getPath();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.ITreeSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerCell;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.actions.ActionFactory;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import typinferenzplugin.TypeReplaceMarker;
|
||||
import typinferenzplugin.editor.treeView.SyntaxTreeOperations;
|
||||
|
||||
public class JavOutline extends ContentOutlinePage{
|
||||
//HOWTO Controls: http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fswt_widgets_controls.htm&resultof=%22outline%22%20%22outlin%22%20%22control%22
|
||||
|
||||
|
||||
private SourceFile syntaxTree;
|
||||
private Vector<TypeReplaceMarker> markers;
|
||||
|
||||
public JavOutline(SourceFile syntaxTree, Vector<TypeReplaceMarker> markers) {
|
||||
this.syntaxTree = syntaxTree;
|
||||
this.markers = markers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on ContentOutlinePage
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
|
||||
super.createControl(parent);
|
||||
|
||||
TreeViewer viewer = getTreeViewer();
|
||||
viewer.setContentProvider(new SyntaxTreeContentProvider(syntaxTree));
|
||||
viewer.setLabelProvider(new SyntaxTreeLabelProvider());
|
||||
viewer.addSelectionChangedListener(this);
|
||||
if(this.syntaxTree!=null)viewer.setInput(this.syntaxTree);
|
||||
|
||||
//ContextMenu für die TreeView:
|
||||
final MenuManager menuMgr = new MenuManager();
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
menuMgr.addMenuListener(new FillContextMenu(viewer, this));
|
||||
final Control tree = viewer.getControl();
|
||||
final Menu menu = menuMgr.createContextMenu(tree);
|
||||
tree.setMenu(menu);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on ContentOutlinePage
|
||||
*/
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
|
||||
super.selectionChanged(event);
|
||||
/*
|
||||
ISelection selection= event.getSelection();
|
||||
if (selection.isEmpty())
|
||||
fTextEditor.resetHighlightRange();
|
||||
else {
|
||||
Segment segment= (Segment) ((IStructuredSelection) selection).getFirstElement();
|
||||
int start= segment.position.getOffset();
|
||||
int length= segment.position.getLength();
|
||||
try {
|
||||
fTextEditor.setHighlightRange(start, length, true);
|
||||
} catch (IllegalArgumentException x) {
|
||||
fTextEditor.resetHighlightRange();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void update(SourceFile sourceFile, Vector<TypeReplaceMarker> markers) {
|
||||
this.markers = markers;
|
||||
TreeViewer viewer= getTreeViewer();
|
||||
|
||||
if (viewer != null) {
|
||||
Control control= viewer.getControl();
|
||||
if (control != null && !control.isDisposed()) {
|
||||
control.setRedraw(false);
|
||||
viewer.setInput(sourceFile);
|
||||
viewer.expandAll();
|
||||
control.setRedraw(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<TypeReplaceMarker> getMarkers() {
|
||||
return this.markers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FillContextMenu implements IMenuListener
|
||||
{
|
||||
private TreeViewer tree;
|
||||
private JavOutline outline;
|
||||
|
||||
public FillContextMenu(TreeViewer forTree, JavOutline outline){
|
||||
this.tree = forTree;
|
||||
this.outline = outline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void menuAboutToShow(IMenuManager manager) {
|
||||
//Der SyntaxTreeNode der angeklickt wurde:
|
||||
//TODO: Im Voraus HashMap mit den Syntaxtreenodes und den zugehörigen TypeInserts berechnen.
|
||||
//Diese dann bei Gelegenheit anzeigen
|
||||
Object selectedObject = ((ITreeSelection)this.tree.getSelection()).getFirstElement();
|
||||
if(selectedObject instanceof Field){
|
||||
Field node = (Field) selectedObject;
|
||||
|
||||
if(this.outline != null)for(TypeReplaceMarker marker : this.outline.getMarkers()){
|
||||
TypeInsert point = marker.getInsertPoint();
|
||||
if(marker.getPoint().offset.equals(node.getType().getOffset())){
|
||||
String label = point.getInsertString()+" einsetzen";
|
||||
manager.add(new InsertTypeAction(label, marker));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(selectedObject instanceof Method){
|
||||
Method node = (Method) selectedObject;
|
||||
|
||||
if(this.outline != null)for(TypeReplaceMarker marker : this.outline.getMarkers()){
|
||||
TypeInsert point = marker.getInsertPoint();
|
||||
if(marker.getPoint().offset.equals(node.getReturnType().getOffset())){
|
||||
String label = point.getInsertString()+" einsetzen";
|
||||
manager.add(new InsertTypeAction(label, marker));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(selectedObject instanceof FormalParameter) {
|
||||
FormalParameter node = (FormalParameter) selectedObject;
|
||||
|
||||
if(this.outline != null)for(TypeReplaceMarker marker : this.outline.getMarkers()){
|
||||
TypeInsert point = marker.getInsertPoint();
|
||||
if(marker.getPoint().offset.equals(node.getType().getOffset())){
|
||||
String label = point.getInsertString()+" einsetzen";
|
||||
manager.add(new InsertTypeAction(label, marker));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InsertTypeAction extends Action{
|
||||
|
||||
private String text;
|
||||
private TypeReplaceMarker marker;
|
||||
|
||||
public InsertTypeAction(String text, TypeReplaceMarker marker){
|
||||
this.text = text;
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
marker.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SyntaxTreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
private SourceFile ast;
|
||||
|
||||
public SyntaxTreeContentProvider(SourceFile ast) {
|
||||
this.ast = ast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if(inputElement instanceof SyntaxTreeNode)
|
||||
return SyntaxTreeOperations.getChildren((SyntaxTreeNode)inputElement).toArray();
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
return getElements(parentElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if(! (element instanceof SyntaxTreeNode))return null;
|
||||
return SyntaxTreeOperations.getParent((SyntaxTreeNode)element, ast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
if(! (element instanceof SyntaxTreeNode))return false;
|
||||
return this.getChildren(element).length>0;
|
||||
}
|
||||
}
|
||||
|
||||
class SyntaxTreeLabelProvider extends LabelProvider{
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if(! (element instanceof SyntaxTreeNode))return super.getText(element);
|
||||
TreeNodeDescriptionGenerator generator = new TreeNodeDescriptionGenerator(((SyntaxTreeNode)element));
|
||||
return generator.getDescription();
|
||||
//return "test";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
|
||||
import org.eclipse.jface.text.DefaultTextHover;
|
||||
import org.eclipse.jface.text.IAutoEditStrategy;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextDoubleClickStrategy;
|
||||
import org.eclipse.jface.text.ITextHover;
|
||||
import org.eclipse.jface.text.TextAttribute;
|
||||
import org.eclipse.jface.text.contentassist.CompletionProposal;
|
||||
import org.eclipse.jface.text.contentassist.ContentAssistant;
|
||||
import org.eclipse.jface.text.contentassist.ContextInformation;
|
||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||
import org.eclipse.jface.text.presentation.IPresentationReconciler;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
|
||||
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
|
||||
import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
|
||||
import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
|
||||
import org.eclipse.jface.text.reconciler.IReconciler;
|
||||
import org.eclipse.jface.text.reconciler.MonoReconciler;
|
||||
import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.rules.Token;
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
import org.eclipse.jface.text.source.DefaultAnnotationHover;
|
||||
import org.eclipse.jface.text.source.IAnnotationHover;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import typinferenzplugin.TypeReplaceMarker;
|
||||
|
||||
|
||||
public class JavViewerConfiguration extends SourceViewerConfiguration {
|
||||
|
||||
|
||||
private JavEditor editor;
|
||||
|
||||
public JavViewerConfiguration(JavEditor parentEditor){
|
||||
super();
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Single token scanner.
|
||||
*/
|
||||
static class SingleTokenScanner extends BufferedRuleBasedScanner {
|
||||
public SingleTokenScanner(TextAttribute attribute) {
|
||||
setDefaultReturnToken(new Token(attribute));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
||||
// TODO Auto-generated method stub
|
||||
return new MonoReconciler(new AnnotationProvider(),true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on SourceViewerConfiguration
|
||||
*/
|
||||
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
|
||||
return new String[] { "\t", " " }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on SourceViewerConfiguration
|
||||
|
||||
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
|
||||
|
||||
JavaColorProvider provider= JavaEditorExamplePlugin.getDefault().getJavaColorProvider();
|
||||
PresentationReconciler reconciler= new PresentationReconciler();
|
||||
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
|
||||
|
||||
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaCodeScanner());
|
||||
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
|
||||
|
||||
dr= new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaDocScanner());
|
||||
reconciler.setDamager(dr, JavaPartitionScanner.JAVA_DOC);
|
||||
reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_DOC);
|
||||
|
||||
dr= new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(provider.getColor(JavaColorProvider.MULTI_LINE_COMMENT))));
|
||||
reconciler.setDamager(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
|
||||
reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
|
||||
|
||||
return reconciler;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
||||
return new DefaultAnnotationHover();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on SourceViewerConfiguration
|
||||
*/
|
||||
public int getTabWidth(ISourceViewer sourceViewer) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on SourceViewerConfiguration
|
||||
*/
|
||||
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
|
||||
return new DefaultTextHover(sourceViewer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
|
||||
//Beschreibung: https://stackoverflow.com/questions/8866688/eclipse-pde-custom-quickfix-only-available-in-problems-view
|
||||
QuickAssistAssistant ret = new QuickAssistAssistant();
|
||||
ret.setQuickAssistProcessor(new QuickAssistProcessor(this.editor));
|
||||
ret.setInformationControlCreator(getInformationControlCreator(sourceViewer));
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class QuickAssistProcessor implements IQuickAssistProcessor{
|
||||
|
||||
private JavEditor editor;
|
||||
|
||||
public QuickAssistProcessor(JavEditor editor){
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFix(Annotation annotation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompletionProposal[] computeQuickAssistProposals(
|
||||
IQuickAssistInvocationContext invocationContext) {
|
||||
// TODO Hier eine ICompletionProposal zurückliefern. Dadurch werden Marker "klickbar"
|
||||
ArrayList<ICompletionProposal> ret = new ArrayList<ICompletionProposal>();
|
||||
Vector<TypeReplaceMarker> markers = this.editor.getMarkersAt(invocationContext.getOffset());
|
||||
if(markers != null)for(TypeReplaceMarker m : markers){
|
||||
ret.add(new TypInsertCompletionProposal(m));
|
||||
}
|
||||
ret.add(new TypInsertCompletionProposal(null));
|
||||
return (ICompletionProposal[]) ret.toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TypInsertCompletionProposal implements ICompletionProposal{
|
||||
|
||||
private TypeReplaceMarker marker;
|
||||
|
||||
public TypInsertCompletionProposal(TypeReplaceMarker m) {
|
||||
this.marker = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(IDocument document) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getSelection(IDocument document) {
|
||||
return new Point(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdditionalProposalInfo() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString() {
|
||||
return "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IContextInformation getContextInformation() {
|
||||
// TODO Auto-generated method stub
|
||||
return new ContextInformation("test","test");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
||||
|
||||
public class TreeNodeDescriptionGenerator {
|
||||
|
||||
private final StringBuilder description = new StringBuilder();
|
||||
|
||||
public TreeNodeDescriptionGenerator(SyntaxTreeNode syntaxTreeNode) {
|
||||
syntaxTreeNode.accept(new OutputGenerator(description));
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,327 @@
|
||||
package typinferenzplugin.editor.treeView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Receiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class ASTChildren implements ASTVisitor{
|
||||
|
||||
private final List<SyntaxTreeNode> children = new ArrayList<>();
|
||||
|
||||
public ASTChildren(SyntaxTreeNode ofNode) {
|
||||
ofNode.accept(this);
|
||||
}
|
||||
|
||||
public List<SyntaxTreeNode> getChildren(){
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
children.add(lambdaExpression.params);
|
||||
children.add(lambdaExpression.methodBody);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
children.add(assign.lefSide);
|
||||
children.add(assign.rightSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BinaryExpr binary) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Block block) {
|
||||
for(Statement s : block.statements) {
|
||||
children.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStmt emptyStmt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ForStmt forStmt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewClass methodCall) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewArray newArray) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnVoid aReturn) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StaticClassName staticClassName) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Super aSuper) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
for(ClassOrInterface cl : sourceFile.getClasses()) {
|
||||
children.add(cl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericTypeVar genericTypeVar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FormalParameter formalParameter) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericDeclarationList genericTypeVars) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method field) {
|
||||
children.add(field.getParameterList());
|
||||
//children.add(field.block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ParameterList formalParameters) {
|
||||
for(FormalParameter fp : formalParameters.getFormalparalist()) {
|
||||
children.add(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
for(Field f : classOrInterface.getFieldDecl()) {
|
||||
children.add(f);
|
||||
}
|
||||
for(Method f : classOrInterface.getMethods()) {
|
||||
children.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoStmt whileStmt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToField assignLeftSide) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToLocal assignLeftSide) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperCall superCall) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExpressionReceiver arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Literal arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package typinferenzplugin.editor.treeView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
|
||||
public class SyntaxTreeOperations {
|
||||
public static List<SyntaxTreeNode> getChildren(SyntaxTreeNode ofNode){
|
||||
return new ASTChildren(ofNode).getChildren();
|
||||
}
|
||||
|
||||
public static SyntaxTreeNode getParent(SyntaxTreeNode element, SourceFile syntaxTree) {
|
||||
SyntaxTreeNode ret = getParentRecursive(element, syntaxTree);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
private static SyntaxTreeNode getParentRecursive(SyntaxTreeNode forElement, SyntaxTreeNode possibleParent) {
|
||||
List<SyntaxTreeNode> children = getChildren(possibleParent);
|
||||
if(children.contains(forElement))return possibleParent;
|
||||
else {
|
||||
if(children.size() == 0)return null;
|
||||
for(SyntaxTreeNode child : children) {
|
||||
SyntaxTreeNode parent = getParentRecursive(forElement, child);
|
||||
if(parent != null)return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package typinferenzplugin.error;
|
||||
|
||||
public class ErrorOutput {
|
||||
|
||||
public ErrorOutput(String message){
|
||||
System.out.println("Es ist ein Fehler aufgetreten:\n"+message+"\n");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package typinferenzplugin.marker;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.ui.IMarkerResolution;
|
||||
|
||||
public class QuickFix implements IMarkerResolution {
|
||||
String label;
|
||||
QuickFix(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
public void run(IMarker marker) {
|
||||
MessageDialog.openInformation(null, "QuickFix Demo",
|
||||
"This quick-fix is not yet implemented");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package typinferenzplugin.marker;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.IMarkerResolution;
|
||||
import org.eclipse.ui.IMarkerResolutionGenerator;
|
||||
|
||||
public class QuickFixer implements IMarkerResolutionGenerator {
|
||||
|
||||
public IMarkerResolution[] getResolutions(IMarker mk) {
|
||||
return new IMarkerResolution[] {
|
||||
new QuickFix("Fix #1 for ")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
17
JavaCompilerPlugin/bundles/pom.xml
Normal file
17
JavaCompilerPlugin/bundles/pom.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.bundles</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>JavaCompilerPlugin.Plugin</module>
|
||||
</modules>
|
||||
</project>
|
1
JavaCompilerPlugin/features/JavaCompilerPlugin.Feature/.gitignore
vendored
Normal file
1
JavaCompilerPlugin/features/JavaCompilerPlugin.Feature/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target/
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin.Feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1 @@
|
||||
bin.includes = feature.xml
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="JavaCompilerPlugin.Feature"
|
||||
label="Typinferenz.Feature"
|
||||
version="0.1.0">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
[Enter Feature Description here.]
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="JavaCompilerPlugin.Plugin"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
18
JavaCompilerPlugin/features/pom.xml
Normal file
18
JavaCompilerPlugin/features/pom.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
|
||||
<artifactId>JavaCompilerPlugin.features</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>JavaCompilerPlugin.Feature</module>
|
||||
</modules>
|
||||
</project>
|
19
JavaCompilerPlugin/pom.xml
Normal file
19
JavaCompilerPlugin/pom.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.configuration</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<relativePath>./releng/JavaCompilerPlugin.configuration</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>bundles</module>
|
||||
<module>features</module>
|
||||
<module>releng</module>
|
||||
</modules>
|
||||
</project>
|
11
JavaCompilerPlugin/releng/.project
Normal file
11
JavaCompilerPlugin/releng/.project
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin.Configuraton</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,101 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.configuration</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<tycho.version>1.2.0</tycho.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<eclipse-repo.url>http://download.eclipse.org/releases/oxygen</eclipse-repo.url>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>eclipse-release</id>
|
||||
<url>${eclipse-repo.url}</url>
|
||||
<layout>p2</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerCoreOsgi</artifactId>
|
||||
<version>0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-maven-plugin</artifactId>
|
||||
<version>${tycho.version}</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-p2-repository-plugin</artifactId>
|
||||
<version>${tycho.version}</version>
|
||||
<configuration>
|
||||
<includeAllDependencies>true</includeAllDependencies>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--Enable the replacement of the SNAPSHOT version in the final product
|
||||
configuration -->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-packaging-plugin</artifactId>
|
||||
<version>${tycho.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<id>package-feature</id>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}_${unqualifiedVersion}.${buildQualifier}</finalName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>target-platform-configuration</artifactId>
|
||||
<version>${tycho.version}</version>
|
||||
<configuration>
|
||||
<pomDependencies>consider</pomDependencies>
|
||||
|
||||
<environments>
|
||||
<environment>
|
||||
<os>linux</os>
|
||||
<ws>gtk</ws>
|
||||
<arch>x86</arch>
|
||||
</environment>
|
||||
<environment>
|
||||
<os>linux</os>
|
||||
<ws>gtk</ws>
|
||||
<arch>x86_64</arch>
|
||||
</environment>
|
||||
<environment>
|
||||
<os>win32</os>
|
||||
<ws>win32</ws>
|
||||
<arch>x86</arch>
|
||||
</environment>
|
||||
<environment>
|
||||
<os>win32</os>
|
||||
<ws>win32</ws>
|
||||
<arch>x86_64</arch>
|
||||
</environment>
|
||||
<environment>
|
||||
<os>macosx</os>
|
||||
<ws>cocoa</ws>
|
||||
<arch>x86_64</arch>
|
||||
</environment>
|
||||
</environments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
11
JavaCompilerPlugin/releng/JavaCompilerPlugin.Target/.project
Normal file
11
JavaCompilerPlugin/releng/JavaCompilerPlugin.Target/.project
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin.Target</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde version="3.8"?><target name="JavaCompilerPlugin.Target" sequenceNumber="1">
|
||||
<locations>
|
||||
<location path="/Users/michaeluhl/Developement/horb/typinferenz/JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/target/repository/plugins" type="Directory"/>
|
||||
</locations>
|
||||
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 9.0.4 [9.0.4]"/>
|
||||
</target>
|
13
JavaCompilerPlugin/releng/JavaCompilerPlugin.Target/pom.xml
Normal file
13
JavaCompilerPlugin/releng/JavaCompilerPlugin.Target/pom.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.Target</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<packaging>eclipse-target-definition</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.releng</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</parent>
|
||||
</project>
|
1
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/.gitignore
vendored
Normal file
1
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target/
|
11
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/.project
Normal file
11
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/.project
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JavaCompilerPlugin.Update</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site>
|
||||
<feature url="features/JavaCompilerPlugin.Feature_0.1.0.jar" id="JavaCompilerPlugin.Feature" version="0.1.0">
|
||||
<category name="JavaCompilerPlugin"/>
|
||||
</feature>
|
||||
<category-def name="JavaCompilerPlugin" label="JavaCompilerPlugin"/>
|
||||
</site>
|
14
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/pom.xml
Normal file
14
JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/pom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.releng</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>JavaCompilerPlugin.Update</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>eclipse-repository</packaging>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
|
||||
</project>
|
18
JavaCompilerPlugin/releng/pom.xml
Normal file
18
JavaCompilerPlugin/releng/pom.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin.releng</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaCompilerPlugin</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>JavaCompilerPlugin.Update</module>
|
||||
<module>JavaCompilerPlugin.Target</module>
|
||||
</modules>
|
||||
</project>
|
Loading…
Reference in New Issue
Block a user