Bug 578948 - [18][javadoc] incorrect handling of overlapping multiple
annotations within @snippet
Change-Id: I894a0b96877dfb3763c5f2ef43abf017acbe643e
Signed-off-by: Kalyan Prasad Tatavarthi <kalyan_prasad@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/191889
Tested-by: JDT Bot <jdt-bot@eclipse.org>
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocSnippetStringEvaluator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocSnippetStringEvaluator.java
index 1c9f393..2635c54 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocSnippetStringEvaluator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocSnippetStringEvaluator.java
@@ -230,7 +230,6 @@
while (iterator.hasNext()) {
ActionElement elem= iterator.next();
ReplacementStringIntervalStatus intervalStatus= elem.getIntervalStatus(replacementIntervalStart, relacementIntervalEnd);
- int endDiff = relacementIntervalEnd - elem.end;
switch(intervalStatus) {
case AFTER:
//do nothing., nothing needs to be done here
@@ -254,10 +253,10 @@
case WITHIN:
// modify the old ActionElement to end before the replacement string start
// Create a new Element element to start from the replacement string end
- int oldEnd = elem.end;
+ int newEnd = elem.end + diff;
elem.end= replacementIntervalStart;
- int newStart = oldEnd + endDiff + diff;
- ActionElement newElem= new ActionElement(newStart, oldEnd, elem.startTag, elem.endTag);
+ int newStart = relacementIntervalEnd + diff;
+ ActionElement newElem= new ActionElement(newStart, newEnd, elem.startTag, elem.endTag);
iterator.add(newElem);
break;
case DEFAULT: