Logger comes from plugin now.
This commit is contained in:
parent
035c68c027
commit
f27ad61a8b
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -16,6 +17,7 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import org.apache.commons.io.output.NullOutputStream;
|
||||||
import org.eclipse.core.runtime.ILog;
|
import org.eclipse.core.runtime.ILog;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ public class Typinferenz {
|
|||||||
compiler = new JavaTXCompiler(editor.getFilePath().toFile(), false);
|
compiler = new JavaTXCompiler(editor.getFilePath().toFile(), false);
|
||||||
this.parsedSource = compiler.sourceFiles.get(editor.getFilePath().toFile());
|
this.parsedSource = compiler.sourceFiles.get(editor.getFilePath().toFile());
|
||||||
|
|
||||||
return compiler.typeInferenceAsync(resultListener);
|
return compiler.typeInferenceAsync(resultListener, new OutputStreamWriter(new NullOutputStream()));
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
LOG.log(new Status(ERROR, PLUGIN_ID, e.getMessage(), e));
|
LOG.log(new Status(ERROR, PLUGIN_ID, e.getMessage(), e));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -79,12 +79,12 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
|
|
||||||
private JavOutline outlinePage;
|
private JavOutline outlinePage;
|
||||||
/**
|
/**
|
||||||
* Der SyntaxBaum f<EFBFBD>r das aktuell ge<EFBFBD>ffnete Dokument.
|
* Der SyntaxBaum f<EFBFBD>r das aktuell geöffnete Dokument.
|
||||||
*/
|
*/
|
||||||
private SourceFile sourceFile;
|
private SourceFile sourceFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Die TypeReplaceMarker f<EFBFBD>r das aktuell geöffnete Dokument
|
* Die TypeReplaceMarker für das aktuell geöffnete Dokument
|
||||||
*/
|
*/
|
||||||
private Vector<JavMarker> errorMarkers = new Vector<JavMarker>();
|
private Vector<JavMarker> errorMarkers = new Vector<JavMarker>();
|
||||||
|
|
||||||
@ -104,6 +104,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
@Override
|
@Override
|
||||||
protected void doSetInput(IEditorInput input) throws CoreException {
|
protected void doSetInput(IEditorInput input) throws CoreException {
|
||||||
super.doSetInput(input);
|
super.doSetInput(input);
|
||||||
|
this.removeMarkers();
|
||||||
this.typeReconstruction(); // Marker generieren
|
this.typeReconstruction(); // Marker generieren
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
return ((IFileEditorInput) input).getFile();
|
return ((IFileEditorInput) input).getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeMarkers(IResource inDocument, Vector<? extends JavMarker> markers) {
|
private void placeMarkers(IResource inDocument, Collection<? extends JavMarker> markers) {
|
||||||
// Marker Tut:
|
// Marker Tut:
|
||||||
// http://wiki.eclipse.org/FAQ_How_do_I_create_my_own_tasks,_problems,_bookmarks,_and_so_on%3F
|
// http://wiki.eclipse.org/FAQ_How_do_I_create_my_own_tasks,_problems,_bookmarks,_and_so_on%3F
|
||||||
// ResourceMarkerAnnotationModel model = new
|
// ResourceMarkerAnnotationModel model = new
|
||||||
@ -241,11 +242,26 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) {
|
public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) {
|
||||||
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
|
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
|
||||||
document.set(typeReplaceMarker.insertType(document.get()));
|
document.set(typeReplaceMarker.insertType(document.get()));
|
||||||
// this.removeMarkers();
|
|
||||||
|
typeReplaceMarkers.remove(typeReplaceMarker);
|
||||||
|
|
||||||
|
removeVisualMarkers();
|
||||||
|
updateGuiWithNewMarkers(typeReplaceMarkers);
|
||||||
|
/*
|
||||||
|
this.removeMarkers();
|
||||||
this.typeReconstruction();
|
this.typeReconstruction();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeMarkers() {
|
private void removeMarkers() {
|
||||||
|
removeVisualMarkers();
|
||||||
|
|
||||||
|
this.errorMarkers.removeAllElements();
|
||||||
|
this.typeReplaceMarkers.removeAllElements();
|
||||||
|
this.updateOutlinePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeVisualMarkers() {
|
||||||
IResource document = this.extractResource();
|
IResource document = this.extractResource();
|
||||||
try {
|
try {
|
||||||
document.deleteMarkers(Activator.TYPINFERENZMARKER_NAME, true, IProject.DEPTH_INFINITE);
|
document.deleteMarkers(Activator.TYPINFERENZMARKER_NAME, true, IProject.DEPTH_INFINITE);
|
||||||
@ -256,10 +272,6 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
this.deleteAnnotation(jm);
|
this.deleteAnnotation(jm);
|
||||||
for (JavMarker jm : typeReplaceMarkers)
|
for (JavMarker jm : typeReplaceMarkers)
|
||||||
this.deleteAnnotation(jm);
|
this.deleteAnnotation(jm);
|
||||||
this.errorMarkers.removeAllElements();
|
|
||||||
this.typeReplaceMarkers.removeAllElements();
|
|
||||||
this.updateOutlinePage();
|
|
||||||
// this.outlinePage.update(sourceFile, markers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,21 +337,23 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
// Anschließend die TypeReplaceMarker im Quellcode anzeigen:
|
// Anschließend die TypeReplaceMarker im Quellcode anzeigen:
|
||||||
// https://stackoverflow.com/questions/8945371/how-to-implement-quick-fix-quick-assist-for-custom-eclipse-editor
|
// https://stackoverflow.com/questions/8945371/how-to-implement-quick-fix-quick-assist-for-custom-eclipse-editor
|
||||||
//LOG.log(new Status(INFO, PLUGIN_ID, "Typinferez durchgeführt. Berechnete Marker:\n" + markers));
|
//LOG.log(new Status(INFO, PLUGIN_ID, "Typinferez durchgeführt. Berechnete Marker:\n" + markers));
|
||||||
|
|
||||||
Display.getDefault().asyncExec(() -> {
|
Display.getDefault().asyncExec(() -> {
|
||||||
// do something in the user interface
|
updateGuiWithNewMarkers(markers);
|
||||||
IResource activeDocument = extractResource();
|
|
||||||
if (activeDocument == null) {
|
|
||||||
LOG.log(new Status(ERROR, PLUGIN_ID, "Kann das aktive Dokument nicht ermitteln"));
|
|
||||||
} else {
|
|
||||||
this.placeMarkers(activeDocument, new Vector(markers));
|
|
||||||
}
|
|
||||||
this.sourceFile = typeinference.getSourceFile();
|
|
||||||
this.errorMarkers.addAll(markers);
|
this.errorMarkers.addAll(markers);
|
||||||
this.updateOutlinePage();
|
|
||||||
// this.outlinePage.update(this.sourceFile,this.markers);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateGuiWithNewMarkers(Collection<? extends JavMarker> markers) {
|
||||||
|
IResource activeDocument = extractResource();
|
||||||
|
if (activeDocument == null) {
|
||||||
|
LOG.log(new Status(ERROR, PLUGIN_ID, "Kann das aktive Dokument nicht ermitteln"));
|
||||||
|
} else {
|
||||||
|
this.placeMarkers(activeDocument, markers);
|
||||||
|
}
|
||||||
|
this.sourceFile = typeinference.getSourceFile();
|
||||||
|
|
||||||
|
this.updateOutlinePage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user