Merge pull request #439 from sharwell/cleanup

Cleanup
This commit is contained in:
Sam Harwell 2014-01-23 05:18:53 -08:00
commit ac87089528
9 changed files with 17 additions and 40 deletions

View File

@ -89,7 +89,7 @@ public class BufferedTokenStream implements TokenStream {
*/
protected boolean fetchedEOF;
public BufferedTokenStream(TokenSource tokenSource) {
public BufferedTokenStream(@NotNull TokenSource tokenSource) {
if (tokenSource == null) {
throw new NullPointerException("tokenSource cannot be null");
}
@ -208,6 +208,7 @@ public class BufferedTokenStream implements TokenStream {
return tokens.get(p-k);
}
@NotNull
@Override
public Token LT(int k) {
lazyInit();

View File

@ -71,6 +71,7 @@ public class CommonToken implements WritableToken, Serializable {
* the same source and input stream share a reference to the same
* {@link Pair} containing these values.</p>
*/
@NotNull
protected Pair<TokenSource, CharStream> source;
/**
@ -106,6 +107,7 @@ public class CommonToken implements WritableToken, Serializable {
*/
public CommonToken(int type) {
this.type = type;
this.source = EMPTY_SOURCE;
}
public CommonToken(@NotNull Pair<TokenSource, CharStream> source, int type, int channel, int start, int stop) {
@ -139,7 +141,7 @@ public class CommonToken implements WritableToken, Serializable {
*
* @param oldToken The token to copy.
*/
public CommonToken(Token oldToken) {
public CommonToken(@NotNull Token oldToken) {
text = oldToken.getText();
type = oldToken.getType();
line = oldToken.getLine();

View File

@ -30,6 +30,8 @@
package org.antlr.v4.runtime;
import org.antlr.v4.runtime.misc.NotNull;
/**
* This class extends {@link BufferedTokenStream} with functionality to filter
* token streams to tokens on a particular channel (tokens where
@ -70,7 +72,7 @@ public class CommonTokenStream extends BufferedTokenStream {
*
* @param tokenSource The token source.
*/
public CommonTokenStream(TokenSource tokenSource) {
public CommonTokenStream(@NotNull TokenSource tokenSource) {
super(tokenSource);
}
@ -84,7 +86,7 @@ public class CommonTokenStream extends BufferedTokenStream {
* @param tokenSource The token source.
* @param channel The channel to use for filtering tokens.
*/
public CommonTokenStream(TokenSource tokenSource, int channel) {
public CommonTokenStream(@NotNull TokenSource tokenSource, int channel) {
this(tokenSource);
this.channel = channel;
}

View File

@ -87,7 +87,7 @@ public class DiagnosticErrorListener extends BaseErrorListener {
@Override
public void reportAmbiguity(@NotNull Parser recognizer,
DFA dfa,
@NotNull DFA dfa,
int startIndex,
int stopIndex,
boolean exact,

View File

@ -537,15 +537,16 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
/** Match needs to return the current input symbol, which gets put
* into the label for the associated token ref; e.g., x=ID.
*/
@NotNull
public Token getCurrentToken() {
return _input.LT(1);
}
public final void notifyErrorListeners(String msg) {
public final void notifyErrorListeners(@NotNull String msg) {
notifyErrorListeners(getCurrentToken(), msg, null);
}
public void notifyErrorListeners(Token offendingToken, String msg,
public void notifyErrorListeners(@NotNull Token offendingToken, @NotNull String msg,
@Nullable RecognitionException e)
{
_syntaxErrors++;
@ -743,7 +744,7 @@ public abstract class Parser extends Recognizer<Token, ParserATNSimulator> {
}
@Override
public boolean precpred(RuleContext localctx, int precedence) {
public boolean precpred(@Nullable RuleContext localctx, int precedence) {
return precedence >= _precedenceStack.peek();
}

View File

@ -1671,7 +1671,7 @@ public class ParserATNSimulator extends ATNSimulator {
}
}
protected void reportAttemptingFullContext(DFA dfa, @Nullable BitSet conflictingAlts, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
protected void reportAttemptingFullContext(@NotNull DFA dfa, @Nullable BitSet conflictingAlts, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
if ( debug || retry_debug ) {
Interval interval = Interval.of(startIndex, stopIndex);
System.out.println("reportAttemptingFullContext decision="+dfa.decision+":"+configs+
@ -1680,7 +1680,7 @@ public class ParserATNSimulator extends ATNSimulator {
if ( parser!=null ) parser.getErrorListenerDispatch().reportAttemptingFullContext(parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
}
protected void reportContextSensitivity(DFA dfa, int prediction, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
protected void reportContextSensitivity(@NotNull DFA dfa, int prediction, @NotNull ATNConfigSet configs, int startIndex, int stopIndex) {
if ( debug || retry_debug ) {
Interval interval = Interval.of(startIndex, stopIndex);
System.out.println("reportContextSensitivity decision="+dfa.decision+":"+configs+

View File

@ -38,7 +38,7 @@ import java.util.Map;
* can be used for both lexers and parsers.
*/
public class PredictionContextCache {
protected Map<PredictionContext, PredictionContext> cache =
protected final Map<PredictionContext, PredictionContext> cache =
new HashMap<PredictionContext, PredictionContext>();
/** Add a context to the cache and return it. If the context already exists,

View File

@ -59,8 +59,6 @@ public abstract class SemanticContext {
*/
public static final SemanticContext NONE = new Predicate();
public SemanticContext parent;
/**
* For context independent predicates, we evaluate them without a local
* context (i.e., null context). That way, we can evaluate them without

View File

@ -15,33 +15,6 @@
<name>ANTLR 4 Runtime Annotations</name>
<description>A set of annotations used within the ANTLR 4 Runtime</description>
<profiles>
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>us.bryon</groupId>
<artifactId>graphviz-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>dot</goal>
</goals>
<configuration>
<dot>${dot.path}</dot>
<destdir>${project.build.directory}/apidocs</destdir>
<output>svg</output>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>