]> source.dussan.org Git - sonarqube.git/commitdiff
Sonar Channel : Slightly improve the readability of the source code in charge to...
authorFreddy Mallet <freddy.mallet@gmail.com>
Fri, 22 Apr 2011 20:56:10 +0000 (22:56 +0200)
committerFreddy Mallet <freddy.mallet@gmail.com>
Fri, 22 Apr 2011 20:56:10 +0000 (22:56 +0200)
sonar-channel/src/main/java/org/sonar/channel/CodeBuffer.java
sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java

index dbb28eb7b0bd2e2d76bb20dfd8c1d55cacbc5653..25ad180b4b3fb2ec1060f6ff884fea8d8f03587e 100644 (file)
@@ -94,11 +94,9 @@ public class CodeBuffer implements CharSequence {
   }
 
   private void updateCursorPosition(int character) {
-    //see Java Language Specification : http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.4
-    if (character == LF || character == CR) {
-      if ((lastChar != LF && lastChar != CR) || lastChar == character || lastChar == LF) {
-        cursor.line++;
-      }
+    // see Java Language Specification : http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.4
+    if (character == LF || (character == CR && peek() != LF)) {
+      cursor.line++;
       cursor.column = 0;
     } else if (character == '\t') {
       cursor.column += tabWidth;
index b028184c7c53bfe8ed4909951024a5af2bdf22c3..e5befb2efcb56b2d3737def7305feb66f21e0981 100644 (file)
@@ -84,8 +84,8 @@ public class CodeBufferTest {
     assertThat(reader.getLinePosition(), is(3));
     assertThat((char) reader.pop(), is('s'));
     reader.pop(); // \r
-    assertThat(reader.getColumnPosition(), is(0));
-    assertThat(reader.getLinePosition(), is(4));
+    assertThat(reader.getColumnPosition(), is(2));
+    assertThat(reader.getLinePosition(), is(3));
     reader.pop(); // \n
     assertThat(reader.getColumnPosition(), is(0));
     assertThat(reader.getLinePosition(), is(4));