Logger comes from plugin now.

This commit is contained in:
Michael Uhl 2019-03-18 09:34:16 +01:00
parent 035c68c027
commit f27ad61a8b
2 changed files with 38 additions and 22 deletions

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -16,6 +17,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.io.output.NullOutputStream;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Status;
@ -62,7 +64,7 @@ public class Typinferenz {
compiler = new JavaTXCompiler(editor.getFilePath().toFile(), false);
this.parsedSource = compiler.sourceFiles.get(editor.getFilePath().toFile());
return compiler.typeInferenceAsync(resultListener);
return compiler.typeInferenceAsync(resultListener, new OutputStreamWriter(new NullOutputStream()));
} catch (ClassNotFoundException e) {
LOG.log(new Status(ERROR, PLUGIN_ID, e.getMessage(), e));
} catch (IOException e) {

View File

@ -79,12 +79,12 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
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;
/**
* 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>();
@ -104,6 +104,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
super.doSetInput(input);
this.removeMarkers();
this.typeReconstruction(); // Marker generieren
}
@ -157,7 +158,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
return ((IFileEditorInput) input).getFile();
}
private void placeMarkers(IResource inDocument, Vector<? extends JavMarker> markers) {
private void placeMarkers(IResource inDocument, Collection<? 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
@ -241,11 +242,26 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) {
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
document.set(typeReplaceMarker.insertType(document.get()));
// this.removeMarkers();
this.typeReconstruction();
typeReplaceMarkers.remove(typeReplaceMarker);
removeVisualMarkers();
updateGuiWithNewMarkers(typeReplaceMarkers);
/*
this.removeMarkers();
this.typeReconstruction();
*/
}
private void removeMarkers() {
removeVisualMarkers();
this.errorMarkers.removeAllElements();
this.typeReplaceMarkers.removeAllElements();
this.updateOutlinePage();
}
private void removeVisualMarkers() {
IResource document = this.extractResource();
try {
document.deleteMarkers(Activator.TYPINFERENZMARKER_NAME, true, IProject.DEPTH_INFINITE);
@ -256,12 +272,8 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
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 <EFBFBD>nderungen an
* markers aufgerufen werden.
@ -325,21 +337,23 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
// Anschließend die TypeReplaceMarker im Quellcode anzeigen:
// 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));
Display.getDefault().asyncExec(() -> {
// do something in the user interface
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();
updateGuiWithNewMarkers(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();
}
}