mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
[eclipse/xtext#1455] Resolve windows test failure in DocumentTest.
Also fixes SemanticHighlightingTest. Document#getLineContent returns the '\r' of '\r\n' on windows. This leads to a failing test. But the line content should explicitly NOT return the newline marker. Hence fixing the implementation to fix the test. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
This commit is contained in:
parent
705ce6ee0d
commit
44aafdae13
2 changed files with 6 additions and 4 deletions
|
@ -84,7 +84,7 @@ import org.eclipse.lsp4j.TextDocumentContentChangeEvent
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns with the text for a certain line without the trailing LF. Throws an {@link IndexOutOfBoundsException} if the zero-based {@code lineNumber}
|
||||
* Returns with the text for a certain line without the trailing end line marker. Throws an {@link IndexOutOfBoundsException} if the zero-based {@code lineNumber}
|
||||
* argument is negative or exceeds the number of lines in the document.
|
||||
*/
|
||||
def String getLineContent(int lineNumber) throws IndexOutOfBoundsException {
|
||||
|
@ -92,6 +92,7 @@ import org.eclipse.lsp4j.TextDocumentContentChangeEvent
|
|||
throw new IndexOutOfBoundsException(lineNumber + if (printSourceOnError) "" else (" text was : " + contents));
|
||||
}
|
||||
val char NL = '\n';
|
||||
val char LF = '\r';
|
||||
val l = contents.length;
|
||||
val lineContent = new StringBuilder;
|
||||
var line = 0;
|
||||
|
@ -100,7 +101,7 @@ import org.eclipse.lsp4j.TextDocumentContentChangeEvent
|
|||
return lineContent.toString;
|
||||
}
|
||||
val ch = contents.charAt(i);
|
||||
if (line === lineNumber && ch !== NL) {
|
||||
if (line === lineNumber && ch !== NL && ch !== LF) {
|
||||
lineContent.append(ch);
|
||||
}
|
||||
if (ch === NL) {
|
||||
|
|
|
@ -108,7 +108,7 @@ public class Document {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns with the text for a certain line without the trailing LF. Throws an {@link IndexOutOfBoundsException} if the zero-based {@code lineNumber}
|
||||
* Returns with the text for a certain line without the trailing end line marker. Throws an {@link IndexOutOfBoundsException} if the zero-based {@code lineNumber}
|
||||
* argument is negative or exceeds the number of lines in the document.
|
||||
*/
|
||||
public String getLineContent(final int lineNumber) throws IndexOutOfBoundsException {
|
||||
|
@ -123,6 +123,7 @@ public class Document {
|
|||
throw new IndexOutOfBoundsException(_plus);
|
||||
}
|
||||
final char NL = '\n';
|
||||
final char LF = '\r';
|
||||
final int l = this.contents.length();
|
||||
final StringBuilder lineContent = new StringBuilder();
|
||||
int line = 0;
|
||||
|
@ -132,7 +133,7 @@ public class Document {
|
|||
return lineContent.toString();
|
||||
}
|
||||
final char ch = this.contents.charAt(i);
|
||||
if (((line == lineNumber) && (ch != NL))) {
|
||||
if ((((line == lineNumber) && (ch != NL)) && (ch != LF))) {
|
||||
lineContent.append(ch);
|
||||
}
|
||||
if ((ch == NL)) {
|
||||
|
|
Loading…
Reference in a new issue