From 0b34810037c9c8d5b63fda1c7ae28d57900573d9 Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Sat, 20 Apr 2019 17:22:39 +0200 Subject: [PATCH] =?UTF-8?q?Kein=20Compileraufruf=20bei=20Type-Insert=20-?= =?UTF-8?q?=20Code=20aufger=C3=A4umt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../typinferenzplugin/editor/JavEditor.java | 84 +------------------ 1 file changed, 4 insertions(+), 80 deletions(-) diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java index 9fe149c..612611f 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java @@ -3,19 +3,12 @@ package typinferenzplugin.editor; import static org.eclipse.core.runtime.IStatus.ERROR; import static typinferenzplugin.Activator.PLUGIN_ID; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import java.util.TreeSet; import java.util.Vector; import javax.inject.Inject; -import org.antlr.v4.parse.ANTLRParser.element_return; -import org.antlr.v4.runtime.CommonToken; -import org.antlr.v4.runtime.Token; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -40,15 +33,10 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import com.google.common.collect.Lists; -import com.google.common.collect.TreeMultiset; - import de.dhbwstuttgart.exceptions.TypeinferenceException; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; -import de.dhbwstuttgart.typeinference.result.ResultPair; import de.dhbwstuttgart.typeinference.result.ResultPairMap; -import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.unify.UnifyResultEvent; import de.dhbwstuttgart.typeinference.unify.UnifyResultListener; import typinferenzplugin.Activator; @@ -59,8 +47,6 @@ import typinferenzplugin.TypeReplaceMarker; import typinferenzplugin.Typinferenz; import typinferenzplugin.error.ErrorOutput; -import static de.dhbwstuttgart.typeinference.result.ResultPairMap.RESULT_PAIRS; - //Example from: http://help.eclipse.org/indigo/index.jsp /** * Editor f�r .jav-Dateien Anmerkung: Für jede ge�ffntete Datei wird eine @@ -114,6 +100,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { */ protected void initializeEditor() { super.initializeEditor(); + ResultPairMap.RESULT_PAIRS.clear(); setSourceViewerConfiguration(new JavViewerConfiguration(this)); // install the document provider // setDocumentProvider(new JavFileProvider()); @@ -124,6 +111,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { super.doSave(monitor); // Wird aufgerufen, sobald das Dokument gespeichert wird. this.removeMarkers(); + ResultPairMap.RESULT_PAIRS.clear(); this.typeReconstruction(); } @@ -165,7 +153,6 @@ public class JavEditor extends TextEditor implements UnifyResultListener { // 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, rm.getPositionInCode()); @@ -224,6 +211,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { /** * Erzeugt die Outline-View */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class required) { if (IContentOutlinePage.class.equals(required)) { if (outlinePage == null) { @@ -244,12 +232,6 @@ public class JavEditor extends TextEditor implements UnifyResultListener { IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput()); document.set(typeReplaceMarker.insertType(document.get())); - - /* - this.removeMarkers(); - this.typeReconstruction(); - */ - typeReplaceMarkers.removeIf(trm -> trm.getPoint().getPositionInCode() == typeReplaceMarker.getPoint().getPositionInCode()); typeReplaceMarkers.removeIf(trm -> !trm.isConsistent(typeReplaceMarker)); @@ -259,64 +241,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { toCheck.getInsertPoint().point.addExtraOffset(lengthOfInsert); } } - updateGuiWithNewMarkers(typeReplaceMarkers); - - /* - ResultPair resultPairOfCurrentTrm = RESULT_PAIRS.get(typeReplaceMarker.getPoint().offset); - - int curLine = typeReplaceMarker.getInsertPoint().point.getToken().getLine(); - int curPosInLine = typeReplaceMarker.getInsertPoint().point.getToken().getCharPositionInLine(); - */ - //List newResultSets = new ArrayList<>(typeinference.getResultSets());//fakeRun(); - - /* - for (int i = 0; i < newResultSets.size(); i++) { - ResultSet rs = newResultSets.get(i); - if (!rs.contains(resultPairOfCurrentTrm)) { - newResultSets.remove(rs); - i--; - } - } - */ - - //this.removeMarkers(); - - /* - List markers = new ArrayList<>(updateMarkers(new UnifyResultEvent(newResultSets))); - List trms = new ArrayList<>(); - for (JavMarker marker : markers) { - if (marker instanceof TypeReplaceMarker) { - trms.add((TypeReplaceMarker)marker); - } - } - trms.remove(typeReplaceMarker); - /* - - /* - int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length(); - for (int i = 0; i < markers.size(); i++) { - JavMarker toCheck = markers.get(i); - ((TypeReplaceMarker)toCheck).getInsertPoint().point.addExtraOffset(lengthOfInsert);; - } - */ - - /* - Display.getDefault().asyncExec(() -> { - updateGuiWithNewMarkers(new ArrayList(typeReplaceMarkers)); - this.errorMarkers.addAll(new ArrayList(typeReplaceMarkers)); - }); - */ - - /* - * removeVisualMarkers(); - * updateGuiWithNewMarkers(typeReplaceMarkers); - */ - - /* - * this.removeMarkers(); - * this.typeReconstruction(); - */ } private void removeMarkers() { @@ -389,7 +314,6 @@ public class JavEditor extends TextEditor implements UnifyResultListener { return ((FileEditorInput) this.getEditorInput()).getPath(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void onNewTypeResultFound(UnifyResultEvent evt) { Vector markers = updateMarkers(evt); @@ -406,7 +330,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { } private Vector updateMarkers(UnifyResultEvent evt) { - typeinference.updateresultSets(new Vector(evt.getNewTypeResult())); + typeinference.updateresultSets(new Vector<>(evt.getNewTypeResult())); Vector markers = new Vector(); Vector newMarkers = typeinference.updateWithResult(markers, evt.getNewTypeResult());