From 82efea69b6979201e7d1bcd74f6266acac2f4326 Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Wed, 27 Nov 2019 21:39:00 +0100 Subject: [PATCH] Saved Position in variable before doing adjustments. --- .../src/typinferenzplugin/editor/JavEditor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java index 5961660..676dab5 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java @@ -246,35 +246,38 @@ public class JavEditor extends TextEditor implements UnifyResultListener { typeReplaceMarkers.removeIf(trm -> !trm.isConsistent(typeReplaceMarker)); int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length(); + int postitionOfInsert = typeReplaceMarker.getPositionInCode(); for (TypeReplaceMarker toCheck : typeReplaceMarkers) { - if (toCheck.getPoint().getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) { + if (toCheck.getPoint().getPositionInCode() > postitionOfInsert) { toCheck.getInsertPoint().point.addExtraOffset(lengthOfInsert); } // 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) { + if (additionalIdentityElimination.add(additionalPoint) && postitionOfInsert > positionAdditionalInsert) { 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()) { + if (toCheck.getPoint().getPositionInCode() > postitionOfInsert - tip.getInsertString().length()) { toCheck.getInsertPoint().point.addExtraOffset(tip.getInsertString().length()); } } for (TypeInsertPoint toCheckAddi : toCheck.getInsertPoint().getAdditionalPointsUnsorted()) { - if (toCheckAddi.getPositionInCode() > typeReplaceMarker.getPoint().getPositionInCode() + lengthOfInsert) { + if (toCheckAddi.getPositionInCode() > postitionOfInsert) { toCheckAddi.addExtraOffset(lengthOfInsert); }