Richtiges Einsetzen ohne Speichern.

This commit is contained in:
Michael Uhl 2019-04-19 20:49:28 +02:00
parent 905d9e25a2
commit 23c37a8cc2
3 changed files with 16 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.stream.Collectors;
@ -33,6 +34,10 @@ public class TypeInsertPoint {
this.extraOffset += toAdd;
}
public int getPositionInCode() {
return point.getStartIndex() + extraOffset;
}
/* PL 2018-06-19
* Zwei TypeInsertPoint's sind gleich, wenn ihre point's gleich sind
* eingefuegt damit man TypeReplaceMarker vergleichen kann

View File

@ -5,9 +5,13 @@ import java.util.Map;
import org.antlr.v4.runtime.Token;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
public class ResultPairMap {
private Map<Token, ResultPair<?,?>> indexMap = new HashMap<>();
private Table<Token, String, ResultPair<?,?>> indexMap = HashBasedTable.create();
private Map<Token, ResultPair<?, ?>> inner = new HashMap<>();
public static final ResultPairMap RESULT_PAIRS = new ResultPairMap();
@ -15,11 +19,12 @@ public class ResultPairMap {
// Nothing to do here.
}
public void put(Token tkn, ResultPair<?, ?> resultPair) {
indexMap.put(tkn, resultPair);
public void put(Token tkn, String insertString, ResultPair<?, ?> resultPair) {
indexMap.put(tkn, insertString.trim(), resultPair);
inner.put(tkn, resultPair);
}
public ResultPair<?,?> get(Token tkn) {
return indexMap.get(tkn);
public ResultPair<?,?> get(Token tkn, String insertString) {
return inner.get(tkn);
}
}

View File

@ -65,8 +65,6 @@ class Resolver implements ResultSetVisitor {
resolved = null;
System.out.println(tph.toString());
for(ResultPair<?,?> resultPair : result.results) {
RESULT_PAIRS.put(resultPair.getRight().getOffset(), resultPair);
RESULT_PAIRS.put(resultPair.getLeft().getOffset(), resultPair);
if(resultPair instanceof PairTPHEqualTPH && ((PairTPHEqualTPH) resultPair).getLeft().equals(toResolve)){
return resolve(((PairTPHEqualTPH) resultPair).getRight());
}
@ -95,6 +93,7 @@ class Resolver implements ResultSetVisitor {
public void visit(PairTPHequalRefTypeOrWildcardType p) {
if(p.left.equals(toResolve)){
resolved = p.right;
RESULT_PAIRS.put(p.left.getOffset(), p.right.toString(), p);
RelatedTypeWalker related = new RelatedTypeWalker(null, result);
p.right.accept(related);
additionalTPHs.addAll(related.relatedTPHs);