Fix getSourceName returning null (fixes #667)

This commit is contained in:
Sam Harwell 2014-09-28 12:11:35 -05:00
parent f143495ab2
commit 90071c69b8
4 changed files with 12 additions and 3 deletions

View File

@ -238,6 +238,10 @@ public class ANTLRInputStream implements CharStream {
@Override
public String getSourceName() {
if (name == null || name.isEmpty()) {
return UNKNOWN_SOURCE_NAME;
}
return name;
}

View File

@ -297,6 +297,10 @@ public class UnbufferedCharStream implements CharStream {
@Override
public String getSourceName() {
if (name == null || name.isEmpty()) {
return UNKNOWN_SOURCE_NAME;
}
return name;
}

View File

@ -1269,7 +1269,7 @@ public abstract class BaseTest {
@Override
public String getSourceName() {
return null;
return UNKNOWN_SOURCE_NAME;
}
@Override

View File

@ -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