Fix getSourceName returning null (fixes #667)
This commit is contained in:
parent
f143495ab2
commit
90071c69b8
|
@ -238,6 +238,10 @@ public class ANTLRInputStream implements CharStream {
|
|||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return UNKNOWN_SOURCE_NAME;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,10 @@ public class UnbufferedCharStream implements CharStream {
|
|||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return UNKNOWN_SOURCE_NAME;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1269,7 +1269,7 @@ public abstract class BaseTest {
|
|||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return null;
|
||||
return UNKNOWN_SOURCE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,6 +33,7 @@ package org.antlr.v4.test;
|
|||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CommonToken;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.IntStream;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenFactory;
|
||||
|
@ -235,7 +236,7 @@ public class TestCommonTokenStream extends TestBufferedTokenStream {
|
|||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return null;
|
||||
return IntStream.UNKNOWN_SOURCE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,7 +284,7 @@ public class TestCommonTokenStream extends TestBufferedTokenStream {
|
|||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return null;
|
||||
return IntStream.UNKNOWN_SOURCE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue