Kein Compileraufruf bei Type-Insert

- Code aufgeräumt.
This commit is contained in:
Michael Uhl 2019-04-20 17:22:39 +02:00
parent 0252781d13
commit 0b34810037

View File

@ -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<EFBFBD>r .jav-Dateien Anmerkung: Für jede ge<EFBFBD>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<ResultSet> 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<JavMarker> markers = new ArrayList<>(updateMarkers(new UnifyResultEvent(newResultSets)));
List<TypeReplaceMarker> 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<TypeReplaceMarker>(typeReplaceMarkers));
this.errorMarkers.addAll(new ArrayList<TypeReplaceMarker>(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<TypeReplaceMarker> markers = updateMarkers(evt);
@ -406,7 +330,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
}
private Vector<TypeReplaceMarker> updateMarkers(UnifyResultEvent evt) {
typeinference.updateresultSets(new Vector(evt.getNewTypeResult()));
typeinference.updateresultSets(new Vector<>(evt.getNewTypeResult()));
Vector<TypeReplaceMarker> markers = new Vector<TypeReplaceMarker>();
Vector<TypeReplaceMarker> newMarkers = typeinference.updateWithResult(markers, evt.getNewTypeResult());