diff options
author | Sergey Prigogin | 2012-04-02 03:38:10 +0000 |
---|---|---|
committer | Sergey Prigogin | 2012-04-05 00:24:41 +0000 |
commit | ffc583c84dff1622b5a42b1efddb7ae6be224431 (patch) | |
tree | abc9e376b2db6c1a45a99e9edca0c63fda5ba890 | |
parent | 309010c45281bca4be7aefedacb363457ba04930 (diff) | |
download | org.eclipse.cdt-ffc583c84dff1622b5a42b1efddb7ae6be224431.tar.gz org.eclipse.cdt-ffc583c84dff1622b5a42b1efddb7ae6be224431.tar.xz org.eclipse.cdt-ffc583c84dff1622b5a42b1efddb7ae6be224431.zip |
Code simplification.
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java index 571a404421d..1cb1d0ffee2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java @@ -128,7 +128,7 @@ public class Scribe { indentationLevel= preferences.initial_indentation_level * indentationSize; preserveNewLines = false; textRegionStart= offset; - textRegionEnd= offset + length - 1; + textRegionEnd= offset + length; reset(); } @@ -574,12 +574,12 @@ public class Scribe { public TextEdit getRootEdit() { MultiTextEdit edit= null; - int length= textRegionEnd - textRegionStart + 1; + int length= textRegionEnd - textRegionStart; if (textRegionStart <= 0) { if (length <= 0) { edit= new MultiTextEdit(0, 0); } else { - edit= new MultiTextEdit(0, textRegionEnd + 1); + edit= new MultiTextEdit(0, textRegionEnd); } } else { edit= new MultiTextEdit(textRegionStart, length); @@ -595,7 +595,7 @@ public class Scribe { } public void handleLineTooLong() { - // Search for closest breakable alignment, using tie break rules. + // Search for closest breakable alignment, using tie-breaking rules. // Look for innermost breakable one. int relativeDepth= 0; Alignment targetAlignment= currentAlignment; @@ -621,6 +621,7 @@ public class Scribe { if (outerMostDepth >= 0) { throwAlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth); } + // Look for innermost breakable one but don't stop if we encounter a R_OUTERMOST // tie-breaking rule. relativeDepth= 0; @@ -710,7 +711,7 @@ public class Scribe { final int editReplacementLength= edit.replacement.length(); final int editOffset= edit.offset; if (editLength != 0) { - if (textRegionStart <= editOffset && (editOffset + editLength - 1) <= textRegionEnd) { + if (textRegionStart <= editOffset && editOffset + editLength <= textRegionEnd) { if (editReplacementLength != 0 && editLength == editReplacementLength) { for (int i= editOffset, max= editOffset + editLength; i < max; i++) { if (scanner.source[i] != edit.replacement.charAt(i - editOffset)) { @@ -737,9 +738,9 @@ public class Scribe { return true; } } - } else if (textRegionStart <= editOffset && editOffset <= textRegionEnd) { + } else if (textRegionStart <= editOffset && editOffset < textRegionEnd) { return true; - } else if (editOffset == scannerEndPosition && editOffset == textRegionEnd + 1) { + } else if (editOffset == scannerEndPosition && editOffset == textRegionEnd) { return true; } return false; |