You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2018/06/18 04:39:04 UTC
[incubator-netbeans] 12/20: [NETBEANS-481] JDK10-LVTI: Refactored
CasualDiff to handle any tokensequence overshoot scenario
This is an automated email from the ASF dual-hosted git repository.
jlahoda pushed a commit to branch release90
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
commit a1e1ff5608ea69d3fde5f3dd2e89eddef5907534
Author: Arunava Sinha <ar...@oracle.com>
AuthorDate: Thu May 10 23:48:00 2018 +0530
[NETBEANS-481] JDK10-LVTI: Refactored CasualDiff to handle any tokensequence overshoot scenario
---
.../modules/java/source/save/CasualDiff.java | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index 9a41714..b5cb6bf 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -1482,27 +1482,26 @@ public class CasualDiff {
int modsUpperBound = getCommentCorrectedEndPos(oldT.mods);
if (modsUpperBound > -1) {
tokenSequence.move(modsUpperBound);
- tokenSequence.moveNext();
// copying modifiers from oldTree
- if (JavaTokenId.WHITESPACE == tokenSequence.token().id()) {
- int offset = tokenSequence.offset();
- copyTo(localPointer, localPointer = offset);
- } else {
+ if (tokenSequence.moveNext()) {
copyTo(localPointer, localPointer = modsUpperBound);
}
- }
+ }
+ int offset = localPointer;
+ JavaTokenId tokenId = null;
tokenSequence.move(localPointer);
- tokenSequence.moveNext();
- int offset = tokenSequence.offset();
- JavaTokenId tokenId = tokenSequence.token().id();
//adding back all whitespaces/block-comment/javadoc-comments present in OldTree before variable type token.
- while ((tokenId == JavaTokenId.WHITESPACE || tokenId == JavaTokenId.BLOCK_COMMENT || tokenId == JavaTokenId.JAVADOC_COMMENT) && offset < oldT.sym.pos) {
- tokenSequence.moveNext();
+ while (tokenSequence.moveNext()) {
offset = tokenSequence.offset();
tokenId = tokenSequence.token().id();
+
+ if (!((tokenId == JavaTokenId.WHITESPACE || tokenId == JavaTokenId.BLOCK_COMMENT || tokenId == JavaTokenId.JAVADOC_COMMENT) && offset < oldT.sym.pos)) {
+ break;
+ }
+
}
copyTo(localPointer, localPointer = offset);
@@ -1526,17 +1525,16 @@ public class CasualDiff {
* first token.
*/
if (oldT.type.getKind() == TypeKind.ERROR && localPointer == -1) {
-
// moving to variable type token
tokenSequence.move(vartypeBounds[0]);
tokenSequence.moveNext();
//moving to first token after variable type token.
- tokenSequence.moveNext();
-
- // copying tokens from vartype bounds after excluding variable type token.
- int offset = tokenSequence.offset();
- copyTo(offset, localPointer = vartypeBounds[1]);
+ if (tokenSequence.moveNext()) {
+ // copying tokens from vartype bounds after excluding variable type token.
+ int offset = tokenSequence.offset();
+ copyTo(offset, localPointer = vartypeBounds[1]);
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
jlahoda@apache.org.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists