Vor Fertigstelltung Ersetzung Generics
This commit is contained in:
parent
f40c1029f0
commit
a208e077ad
@ -187,7 +187,7 @@ public class Typinferenz {
|
||||
|
||||
public void cancel() {
|
||||
try {
|
||||
compiler.usedTasks.cancel();
|
||||
// compiler.usedTasks.cancel();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -5,14 +5,20 @@ import static java.util.stream.Collectors.toCollection;
|
||||
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.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.antlr.v4.parse.BlockSetTransformer.topdown_return;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
@ -24,7 +30,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.e4.ui.di.UISynchronize;
|
||||
import org.eclipse.jdt.internal.corext.refactoring.reorg.ParentChecker;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.text.source.Annotation;
|
||||
@ -32,9 +37,8 @@ import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.editors.text.TextEditor;
|
||||
import org.eclipse.ui.internal.ide.TipsAndTricksAction;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
|
||||
@ -44,6 +48,7 @@ import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertPoint;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultEvent;
|
||||
@ -242,20 +247,53 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
|
||||
document.set(typeReplaceMarker.insertType(document.get()));
|
||||
|
||||
Collection<TypeInsertPoint> additionalIdentityElimination = new HashSet<>();
|
||||
|
||||
typeReplaceMarkers.removeIf(trm -> trm.getPoint().getPositionInCode() == typeReplaceMarker.getPoint().getPositionInCode());
|
||||
typeReplaceMarkers.removeIf(trm -> !trm.isConsistent(typeReplaceMarker));
|
||||
|
||||
int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length();
|
||||
|
||||
for (TypeReplaceMarker toCheck : typeReplaceMarkers) {
|
||||
if (toCheck.getPoint().getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode()) {
|
||||
if (toCheck.getPoint().getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) {
|
||||
toCheck.getInsertPoint().point.addExtraOffset(lengthOfInsert);
|
||||
}
|
||||
for (TypeInsertPoint tip : typeReplaceMarker.getInsertPoint().getAdditionalPoints()) {
|
||||
if (toCheck.getPoint().getPositionInCode() > tip.getPositionInCode()) {
|
||||
|
||||
// Add extra offset for the additional insert points of "typeReplaceMarker"
|
||||
// to "toCheck"
|
||||
// ...
|
||||
for (TypeInsertPoint additionalPoint : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) {
|
||||
int lengthAdditionalInsert = additionalPoint.getInsertString().length();
|
||||
int positionAdditionalInsert = additionalPoint.getPositionInCode();
|
||||
|
||||
if (additionalIdentityElimination.add(additionalPoint) && toCheck.getPositionInCode() > positionAdditionalInsert + lengthAdditionalInsert) {
|
||||
toCheck.getInsertPoint().point.addExtraOffset(lengthAdditionalInsert);
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeInsertPoint tip : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) {
|
||||
// Add to all other type replace markers the extra offsets of the additional
|
||||
// points of this type replace marker.
|
||||
// ...
|
||||
if (toCheck.getPoint().getPositionInCode() > tip.getPositionInCode() - tip.getInsertString().length()) {
|
||||
toCheck.getInsertPoint().point.addExtraOffset(tip.getInsertString().length());
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeInsertPoint toCheckAddi : toCheck.getInsertPoint().getAdditionalPointsUnsorted()) {
|
||||
if (toCheckAddi.getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) {
|
||||
toCheckAddi.addExtraOffset(lengthOfInsert);
|
||||
}
|
||||
|
||||
for (TypeInsertPoint additionalPoint : typeReplaceMarker.getInsertPoint().getAdditionalPointsUnsorted()) {
|
||||
int lengthAdditionalInsert = additionalPoint.getInsertString().length();
|
||||
int positionAdditionalInsert = additionalPoint.getPositionInCode();
|
||||
|
||||
if (positionAdditionalInsert + lengthAdditionalInsert < toCheckAddi.getPositionInCode() ) {
|
||||
toCheckAddi.addExtraOffset(lengthAdditionalInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove resultsets if not consistent.
|
||||
@ -264,7 +302,35 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
}
|
||||
updateGuiWithNewMarkers(typeReplaceMarkers);
|
||||
|
||||
boolean actualHasGenericClassInserts = typeReplaceMarker.getInsertPoint().getAdditionalPoints().stream().anyMatch(tip -> tip.isGenericClassInsertPoint());
|
||||
if (actualHasGenericClassInserts) {
|
||||
for (TypeReplaceMarker marker : typeReplaceMarkers) {
|
||||
Iterator<TypeInsertPoint> addiPoints = marker.getInsertPoint().getAdditionalPointsUnsorted().iterator();
|
||||
while (addiPoints.hasNext()) {
|
||||
if (addiPoints.next().isGenericClassInsertPoint()) {
|
||||
addiPoints.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeInsertPoint additionalPoint : typeReplaceMarker.getInsertPoint().getAdditionalPoints()) {
|
||||
for (TypeReplaceMarker other : this.typeReplaceMarkers) {
|
||||
other.getInsertPoint().getAdditionalPointsUnsorted().remove(additionalPoint);
|
||||
}
|
||||
}
|
||||
|
||||
Collection<ResultSet> newResultSets = typeReplaceMarkers.stream().map(trm -> trm.getResultSets()).flatMap(rs -> rs.stream()).collect(Collectors.toSet());
|
||||
|
||||
/**
|
||||
Vector<JavMarker> markers = new Vector<JavMarker>();
|
||||
Vector<JavMarker> newMarkers = typeinference.updateWithResult(markers, new Vector<>(newResultSets));
|
||||
|
||||
updateGuiWithNewMarkersSynchron(newMarkers);
|
||||
this.errorMarkers.addAll(newMarkers);
|
||||
**/
|
||||
|
||||
|
||||
HashMap<String, byte[]> bytecode = typeinference.getBytecode(typeinference.getSourceFile(), newResultSets, typeinference.getOutputDirectory());
|
||||
typeinference.writeClassFile(typeinference.getOutputDirectory(), bytecode);
|
||||
}
|
||||
@ -401,4 +467,15 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
this.updateOutlinePage();
|
||||
}
|
||||
|
||||
private void updateGuiWithNewMarkersSynchron(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.updateOutlinePage();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user