diff --git a/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java index 9311f6665..0ad83df69 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/BufferedTokenStream.java @@ -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(); diff --git a/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java b/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java index bb85753f3..050255caf 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java +++ b/runtime/Java/src/org/antlr/v4/runtime/CommonToken.java @@ -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.

*/ + @NotNull protected Pair 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 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(); diff --git a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java index ea85afcd7..5b7650222 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/CommonTokenStream.java @@ -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; } diff --git a/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java b/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java index 79c84549f..e6f653463 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java +++ b/runtime/Java/src/org/antlr/v4/runtime/DiagnosticErrorListener.java @@ -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, diff --git a/runtime/Java/src/org/antlr/v4/runtime/Parser.java b/runtime/Java/src/org/antlr/v4/runtime/Parser.java index 7c2c11061..79f781c87 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/Parser.java +++ b/runtime/Java/src/org/antlr/v4/runtime/Parser.java @@ -537,15 +537,16 @@ public abstract class Parser extends Recognizer { /** 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 { } @Override - public boolean precpred(RuleContext localctx, int precedence) { + public boolean precpred(@Nullable RuleContext localctx, int precedence) { return precedence >= _precedenceStack.peek(); } diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java index a47180575..5467d37ab 100755 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java @@ -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+ diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java index 55af6c8ce..b9d12e4fc 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/PredictionContextCache.java @@ -38,7 +38,7 @@ import java.util.Map; * can be used for both lexers and parsers. */ public class PredictionContextCache { - protected Map cache = + protected final Map cache = new HashMap(); /** Add a context to the cache and return it. If the context already exists, diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java index 4c3613773..62376271a 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/SemanticContext.java @@ -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 diff --git a/runtime/JavaAnnotations/pom.xml b/runtime/JavaAnnotations/pom.xml index 26ef7fa78..f648f7036 100644 --- a/runtime/JavaAnnotations/pom.xml +++ b/runtime/JavaAnnotations/pom.xml @@ -15,33 +15,6 @@ ANTLR 4 Runtime Annotations A set of annotations used within the ANTLR 4 Runtime - - - sonatype-oss-release - - - - us.bryon - graphviz-maven-plugin - 1.0 - - - - dot - - - ${dot.path} - ${project.build.directory}/apidocs - svg - - - - - - - - - src