forked from jasder/antlr
Somehow I missed a bunch of imports for @NotNull. Fixes #815.
This commit is contained in:
parent
0ed80d90da
commit
5e70f94628
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* The interface for defining strategies to deal with syntax errors encountered
|
||||
* during a parse by ANTLR-generated parsers. We distinguish between three
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** A source of characters for an ANTLR lexer. */
|
||||
public interface CharStream extends IntStream {
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.antlr.v4.runtime.atn.ATN;
|
|||
import org.antlr.v4.runtime.atn.ATNState;
|
||||
import org.antlr.v4.runtime.atn.RuleTransition;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,8 +32,6 @@ package org.antlr.v4.runtime;
|
|||
import org.antlr.v4.runtime.atn.ATNState;
|
||||
import org.antlr.v4.runtime.atn.AbstractPredicateTransition;
|
||||
import org.antlr.v4.runtime.atn.PredicateTransition;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.runtime.atn.ATNType;
|
|||
import org.antlr.v4.runtime.atn.LexerATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.PredictionContextCache;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/** Indicates that the parser could not decide which of two or more paths
|
||||
* to take based upon the remaining input. It tracks the starting token
|
||||
|
|
|
@ -31,7 +31,6 @@ package org.antlr.v4.runtime;
|
|||
|
||||
import org.antlr.v4.runtime.atn.DecisionState;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/** The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
|
||||
* 3 kinds of errors: prediction errors, failed predicate errors, and
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.runtime;
|
|||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.atn.ATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.ParseInfo;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This class provides access to the current version of the ANTLR 4 runtime
|
||||
* library as compile-time and runtime constants, along with methods for
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
/** The default mechanism for creating tokens. It's used by default in Lexer and
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* A source of tokens must provide a sequence of tokens via {@link #nextToken()}
|
||||
* and also must reveal it's source of characters; {@link CommonToken}'s text is
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* An {@link IntStream} whose symbols are {@link Token} instances.
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* This interface provides information about the vocabulary used by a
|
||||
* recognizer.
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
*/
|
||||
package org.antlr.v4.runtime;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
|||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
|
|
@ -32,8 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/** A tuple: (ATN state, predicted alt, syntactic, semantic context).
|
||||
* The syntactic context is a graph-structured stack node whose
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sam Harwell
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
|
||||
import java.io.InvalidClassException;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.dfa.DFAState;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** TODO: make all transitions sets? no, should remove set edges */
|
||||
public final class AtomTransition extends Transition {
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public final class EpsilonTransition extends Transition {
|
||||
|
||||
private final int outermostPrecedenceReturn;
|
||||
|
|
|
@ -33,8 +33,6 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.HashSet;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.ObjectEqualityComparator;
|
||||
|
||||
public class LexerATNConfig extends ATNConfig {
|
||||
|
|
|
@ -38,8 +38,6 @@ import org.antlr.v4.runtime.Token;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.dfa.DFAState;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a single action which can be executed following the successful
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.runtime.IntStream;
|
|||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* This implementation of {@link LexerAction} is used for tracking input offsets
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** TODO: this is old comment:
|
||||
* A tree of semantic predicates from the grammar AST if label==SEMPRED.
|
||||
* In the ATN, labels will always be exactly one predicate, but the DFA
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public final class RangeTransition extends Transition {
|
||||
public final int from;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** */
|
||||
public final class RuleTransition extends Transition {
|
||||
/** Ptr to the rule definition object for this rule ref */
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.runtime.atn;
|
|||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.atn;
|
|||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** A transition containing a set of values. */
|
||||
public class SetTransition extends Transition {
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.atn;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public final class WildcardTransition extends Transition {
|
||||
public WildcardTransition(ATNState target) { super(target); }
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ import org.antlr.v4.runtime.VocabularyImpl;
|
|||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.atn.DecisionState;
|
||||
import org.antlr.v4.runtime.atn.StarLoopEntryState;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.dfa;
|
|||
|
||||
import org.antlr.v4.runtime.Vocabulary;
|
||||
import org.antlr.v4.runtime.VocabularyImpl;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
|
@ -38,8 +38,6 @@ import org.antlr.v4.runtime.atn.LexerActionExecutor;
|
|||
import org.antlr.v4.runtime.atn.ParserATNSimulator;
|
||||
import org.antlr.v4.runtime.atn.SemanticContext;
|
||||
import org.antlr.v4.runtime.misc.MurmurHash;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package org.antlr.v4.runtime.dfa;
|
||||
|
||||
import org.antlr.v4.runtime.VocabularyImpl;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
public class LexerDFASerializer extends DFASerializer {
|
||||
public LexerDFASerializer(DFA dfa) {
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* [The "BSD license"]
|
||||
* Copyright (c) 2012 Terence Parr
|
||||
* Copyright (c) 2012 Sam Harwell
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This annotation marks a field, parameter, local variable, or method (return
|
||||
* value) as never being {@code null}. The specific semantics implied by this
|
||||
* annotation depend on the kind of element the annotation is applied to.
|
||||
*
|
||||
* <ul>
|
||||
* <li><strong>Field or Local Variable:</strong> Code reading the field or local
|
||||
* variable may assume that the value is never {@code null}. Code writing to the
|
||||
* field or local variable should ensure that a {@code null} reference is never
|
||||
* written.</li>
|
||||
* <li><strong>Parameter:</strong> Code calling the method should never pass
|
||||
* {@code null} for this parameter. The implementation may assume that the value
|
||||
* is never {@code null}, and the behavior of the method if the parameter is
|
||||
* {@code null} is undefined. Overriding methods may optionally use the
|
||||
* {@link Nullable} annotation instead of this annotation for the parameter,
|
||||
* indicating that the overriding method provides additional code to handle a
|
||||
* {@code null} reference passed for the parameter.</li>
|
||||
* <li><strong>Method (Return Value):</strong> Code calling the method may
|
||||
* assume that the result of the method is never {@code null}. The
|
||||
* implementation of the method should ensure that a {@code null} reference is
|
||||
* never returned.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* The {@link NullUsageProcessor} annotation processor validates certain usage
|
||||
* scenarios for this annotation, with compile-time errors or warnings reported
|
||||
* for misuse. For detailed information about the supported analysis, see the
|
||||
* documentation for {@link NullUsageProcessor}.</p>
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
|
||||
public @interface NotNull {
|
||||
}
|
|
@ -1,331 +0,0 @@
|
|||
/*
|
||||
* [The "BSD license"]
|
||||
* Copyright (c) 2013 Terence Parr
|
||||
* Copyright (c) 2013 Sam Harwell
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.NoType;
|
||||
import javax.lang.model.type.PrimitiveType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A compile-time validator for correct usage of the {@link NotNull} and
|
||||
* {@link Nullable} annotations.
|
||||
*
|
||||
* <p>The validation process checks the following items.</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><strong>Error</strong>: an element is annotated with both {@link NotNull} and {@link Nullable}.</li>
|
||||
* <li><strong>Error</strong>: an method which returns {@code void} is annotated with {@link NotNull} or {@link Nullable}.</li>
|
||||
* <li><strong>Error</strong>: an element with a primitive type is annotated with {@link Nullable}.</li>
|
||||
* <li><strong>Error</strong>: a parameter is annotated with {@link NotNull}, but the method overrides or implements a method where the parameter is annotated {@link Nullable}.</li>
|
||||
* <li><strong>Error</strong>: a method is annotated with {@link Nullable}, but the method overrides or implements a method that is annotated with {@link NotNull}.</li>
|
||||
* <li><strong>Warning</strong>: an element with a primitive type is annotated with {@link NotNull}.</li>
|
||||
* <li><strong>Warning</strong>: a parameter is annotated with {@link NotNull}, but the method overrides or implements a method where the parameter is not annotated.</li>
|
||||
* <li><strong>Warning</strong>: a method is annotated with {@link Nullable}, but the method overrides or implements a method that is not annotated.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>In the future, the validation process may be updated to check the following additional items.</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><strong>Warning</strong>: a parameter is not annotated, but the method overrides or implements a method where the parameter is annotated with {@link NotNull} or {@link Nullable}.</li>
|
||||
* <li><strong>Warning</strong>: a method is not annotated, but the method overrides or implements a method that is annotated with with {@link NotNull} or {@link Nullable}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Sam Harwell
|
||||
*/
|
||||
@SupportedAnnotationTypes({NullUsageProcessor.NotNullClassName, NullUsageProcessor.NullableClassName})
|
||||
public class NullUsageProcessor extends AbstractProcessor {
|
||||
public static final String NotNullClassName = "org.antlr.v4.runtime.misc.NotNull";
|
||||
public static final String NullableClassName = "org.antlr.v4.runtime.misc.Nullable";
|
||||
|
||||
private TypeElement notNullType;
|
||||
private TypeElement nullableType;
|
||||
|
||||
public NullUsageProcessor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
SourceVersion latestSupported = SourceVersion.latestSupported();
|
||||
|
||||
if (latestSupported.ordinal() <= 6) {
|
||||
return SourceVersion.RELEASE_6;
|
||||
}
|
||||
else if (latestSupported.ordinal() <= 8) {
|
||||
return latestSupported;
|
||||
}
|
||||
else {
|
||||
// this annotation processor is tested through Java 8
|
||||
return SourceVersion.values()[8];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if (!checkClassNameConstants()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
notNullType = processingEnv.getElementUtils().getTypeElement(NotNullClassName);
|
||||
nullableType = processingEnv.getElementUtils().getTypeElement(NullableClassName);
|
||||
Set<? extends Element> notNullElements = roundEnv.getElementsAnnotatedWith(notNullType);
|
||||
Set<? extends Element> nullableElements = roundEnv.getElementsAnnotatedWith(nullableType);
|
||||
|
||||
Set<Element> intersection = new HashSet<Element>(notNullElements);
|
||||
intersection.retainAll(nullableElements);
|
||||
for (Element element : intersection) {
|
||||
String error = String.format("%s cannot be annotated with both %s and %s", element.getKind().toString().replace('_', ' ').toLowerCase(), notNullType.getSimpleName(), nullableType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, element);
|
||||
}
|
||||
|
||||
checkVoidMethodAnnotations(notNullElements, notNullType);
|
||||
checkVoidMethodAnnotations(nullableElements, nullableType);
|
||||
|
||||
checkPrimitiveTypeAnnotations(nullableElements, Diagnostic.Kind.ERROR, nullableType);
|
||||
checkPrimitiveTypeAnnotations(notNullElements, Diagnostic.Kind.WARNING, notNullType);
|
||||
|
||||
// method name -> method -> annotated elements of method
|
||||
Map<String, Map<ExecutableElement, List<Element>>> namedMethodMap =
|
||||
new HashMap<String, Map<ExecutableElement, List<Element>>>();
|
||||
addElementsToNamedMethodMap(notNullElements, namedMethodMap);
|
||||
addElementsToNamedMethodMap(nullableElements, namedMethodMap);
|
||||
|
||||
for (Map.Entry<String, Map<ExecutableElement, List<Element>>> entry : namedMethodMap.entrySet()) {
|
||||
for (Map.Entry<ExecutableElement, List<Element>> subentry : entry.getValue().entrySet()) {
|
||||
checkOverriddenMethods(subentry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkClassNameConstants() {
|
||||
boolean success = checkClassNameConstant(NotNullClassName, NotNull.class);
|
||||
success &= checkClassNameConstant(NullableClassName, Nullable.class);
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean checkClassNameConstant(String className, Class<?> clazz) {
|
||||
if (className == null) {
|
||||
throw new NullPointerException("className");
|
||||
}
|
||||
|
||||
if (clazz == null) {
|
||||
throw new NullPointerException("clazz");
|
||||
}
|
||||
|
||||
if (!className.equals(clazz.getCanonicalName())) {
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format("Unable to process null usage annotations due to class name mismatch: %s != %s", className, clazz.getCanonicalName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkVoidMethodAnnotations(Set<? extends Element> elements, TypeElement annotationType) {
|
||||
for (Element element : elements) {
|
||||
if (element.getKind() != ElementKind.METHOD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExecutableElement executableElement = (ExecutableElement)element;
|
||||
TypeMirror returnType = executableElement.getReturnType();
|
||||
if (returnType instanceof NoType && returnType.getKind() == TypeKind.VOID) {
|
||||
String error = String.format("void method cannot be annotated with %s", annotationType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, element, getAnnotationMirror(element, annotationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPrimitiveTypeAnnotations(Set<? extends Element> elements, Diagnostic.Kind kind, TypeElement annotationType) {
|
||||
for (Element element : elements) {
|
||||
TypeMirror typeToCheck;
|
||||
switch (element.getKind()) {
|
||||
case FIELD:
|
||||
case PARAMETER:
|
||||
case LOCAL_VARIABLE:
|
||||
// checking variable type
|
||||
VariableElement variableElement = (VariableElement)element;
|
||||
typeToCheck = variableElement.asType();
|
||||
break;
|
||||
|
||||
case METHOD:
|
||||
// checking return type
|
||||
ExecutableElement executableElement = (ExecutableElement)element;
|
||||
typeToCheck = executableElement.getReturnType();
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeToCheck instanceof PrimitiveType && typeToCheck.getKind().isPrimitive()) {
|
||||
String error = String.format("%s with a primitive type %s be annotated with %s", element.getKind().toString().replace('_', ' ').toLowerCase(), kind == Diagnostic.Kind.ERROR ? "cannot" : "should not", annotationType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(kind, error, element, getAnnotationMirror(element, annotationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addElementsToNamedMethodMap(Set<? extends Element> elements, Map<String, Map<ExecutableElement, List<Element>>> namedMethodMap) {
|
||||
for (Element element : elements) {
|
||||
ExecutableElement method;
|
||||
switch (element.getKind()) {
|
||||
case PARAMETER:
|
||||
method = (ExecutableElement)element.getEnclosingElement();
|
||||
assert method.getKind() == ElementKind.METHOD;
|
||||
break;
|
||||
|
||||
case METHOD:
|
||||
method = (ExecutableElement)element;
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<ExecutableElement, List<Element>> annotatedMethodWithName =
|
||||
namedMethodMap.get(method.getSimpleName().toString());
|
||||
if (annotatedMethodWithName == null) {
|
||||
annotatedMethodWithName = new HashMap<ExecutableElement, List<Element>>();
|
||||
namedMethodMap.put(method.getSimpleName().toString(), annotatedMethodWithName);
|
||||
}
|
||||
|
||||
List<Element> annotatedElementsOfMethod = annotatedMethodWithName.get(method);
|
||||
if (annotatedElementsOfMethod == null) {
|
||||
annotatedElementsOfMethod = new ArrayList<Element>();
|
||||
annotatedMethodWithName.put(method, annotatedElementsOfMethod);
|
||||
}
|
||||
|
||||
annotatedElementsOfMethod.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOverriddenMethods(ExecutableElement method) {
|
||||
TypeElement declaringType = (TypeElement)method.getEnclosingElement();
|
||||
Set<Element> errorElements = new HashSet<Element>();
|
||||
Set<Element> warnedElements = new HashSet<Element>();
|
||||
typeLoop:
|
||||
for (TypeMirror supertypeMirror : getAllSupertypes(processingEnv.getTypeUtils().getDeclaredType(declaringType))) {
|
||||
for (Element element : ((TypeElement)processingEnv.getTypeUtils().asElement(supertypeMirror)).getEnclosedElements()) {
|
||||
if (element instanceof ExecutableElement) {
|
||||
if (processingEnv.getElementUtils().overrides(method, (ExecutableElement)element, declaringType)) {
|
||||
checkOverriddenMethod(method, (ExecutableElement)element, errorElements, warnedElements);
|
||||
continue typeLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<? extends TypeMirror> getAllSupertypes(TypeMirror type) {
|
||||
Set<TypeMirror> supertypes = new HashSet<TypeMirror>();
|
||||
Deque<TypeMirror> worklist = new ArrayDeque<TypeMirror>();
|
||||
worklist.add(type);
|
||||
while (!worklist.isEmpty()) {
|
||||
List<? extends TypeMirror> next = processingEnv.getTypeUtils().directSupertypes(worklist.poll());
|
||||
if (supertypes.addAll(next)) {
|
||||
worklist.addAll(next);
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<TypeMirror>(supertypes);
|
||||
}
|
||||
|
||||
private void checkOverriddenMethod(ExecutableElement overrider, ExecutableElement overridden, Set<Element> errorElements, Set<Element> warnedElements) {
|
||||
// check method annotation
|
||||
if (isNullable(overrider) && isNotNull(overridden) && errorElements.add(overrider)) {
|
||||
String error = String.format("method annotated with %s cannot override or implement a method annotated with %s", nullableType.getSimpleName(), notNullType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, overrider, getNullableAnnotationMirror(overrider));
|
||||
}
|
||||
else if (isNullable(overrider) && !(isNullable(overridden) || isNotNull(overridden)) && !errorElements.contains(overrider) && warnedElements.add(overrider)) {
|
||||
String error = String.format("method annotated with %s overrides a method that is not annotated", nullableType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, error, overrider, getNullableAnnotationMirror(overrider));
|
||||
}
|
||||
|
||||
List<? extends VariableElement> overriderParameters = overrider.getParameters();
|
||||
List<? extends VariableElement> overriddenParameters = overridden.getParameters();
|
||||
for (int i = 0; i < overriderParameters.size(); i++) {
|
||||
if (isNotNull(overriderParameters.get(i)) && isNullable(overriddenParameters.get(i)) && errorElements.add(overriderParameters.get(i))) {
|
||||
String error = String.format("parameter %s annotated with %s cannot override or implement a parameter annotated with %s", overriderParameters.get(i).getSimpleName(), notNullType.getSimpleName(), nullableType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, error, overriderParameters.get(i), getNotNullAnnotationMirror(overriderParameters.get(i)));
|
||||
}
|
||||
else if (isNotNull(overriderParameters.get(i)) && !(isNullable(overriddenParameters.get(i)) || isNotNull(overriddenParameters.get(i))) && !errorElements.contains(overriderParameters.get(i)) && warnedElements.add(overriderParameters.get(i))) {
|
||||
String error = String.format("parameter %s annotated with %s overrides a parameter that is not annotated", overriderParameters.get(i).getSimpleName(), notNullType.getSimpleName());
|
||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, error, overriderParameters.get(i), getNotNullAnnotationMirror(overriderParameters.get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNotNull(Element element) {
|
||||
return getNotNullAnnotationMirror(element) != null;
|
||||
}
|
||||
|
||||
private boolean isNullable(Element element) {
|
||||
return getNullableAnnotationMirror(element) != null;
|
||||
}
|
||||
|
||||
private AnnotationMirror getNotNullAnnotationMirror(Element element) {
|
||||
return getAnnotationMirror(element, notNullType);
|
||||
}
|
||||
|
||||
private AnnotationMirror getNullableAnnotationMirror(Element element) {
|
||||
return getAnnotationMirror(element, nullableType);
|
||||
}
|
||||
|
||||
private AnnotationMirror getAnnotationMirror(Element element, TypeElement annotationType) {
|
||||
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
|
||||
if (annotationMirror.getAnnotationType().asElement() == annotationType) {
|
||||
return annotationMirror;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* [The "BSD license"]
|
||||
* Copyright (c) 2012 Terence Parr
|
||||
* Copyright (c) 2012 Sam Harwell
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.runtime.misc;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This annotation marks a field, parameter, local variable, or method (return
|
||||
* value) as potentially having the value {@code null}. The specific semantics
|
||||
* implied by this annotation depend on the kind of element the annotation is
|
||||
* applied to.
|
||||
*
|
||||
* <ul>
|
||||
* <li><strong>Field or Local Variable:</strong> Code reading the field or local
|
||||
* variable may not assume that the value is never {@code null}.</li>
|
||||
* <li><strong>Parameter:</strong> Code calling the method might pass
|
||||
* {@code null} for this parameter. The documentation for the method should
|
||||
* describe the behavior of the method in the event this parameter is
|
||||
* {@code null}.
|
||||
* </li>
|
||||
* <li><strong>Method (Return Value):</strong> Code calling the method may not
|
||||
* assume that the result of the method is never {@code null}. The documentation
|
||||
* for the method should describe the meaning of a {@code null} reference being
|
||||
* returned. Overriding methods may optionally use the {@link NotNull}
|
||||
* annotation instead of this annotation for the method, indicating that the
|
||||
* overriding method (and any method which overrides it) will never return a
|
||||
* {@code null} reference.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* The {@link NullUsageProcessor} annotation processor validates certain usage
|
||||
* scenarios for this annotation, with compile-time errors or warnings reported
|
||||
* for misuse. For detailed information about the supported analysis, see the
|
||||
* documentation for {@link NullUsageProcessor}.</p>
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
|
||||
public @interface Nullable {
|
||||
}
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.runtime.tree;
|
|||
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/** A tree that knows about an interval in a token stream
|
||||
* is some kind of syntax tree. Subinterfaces distinguish
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.abego.treelayout.TreeLayout;
|
|||
import org.abego.treelayout.util.DefaultConfiguration;
|
||||
import org.antlr.v4.runtime.misc.GraphicsSupport;
|
||||
import org.antlr.v4.runtime.misc.JFileChooserConfirmOverwrite;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.Tree;
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
package org.antlr.v4.runtime.tree.pattern;
|
||||
|
||||
import org.antlr.v4.runtime.misc.MultiMap;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.tree.pattern;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.xpath.XPath;
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ import org.antlr.v4.runtime.RecognitionException;
|
|||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.misc.MultiMap;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.ParseCancellationException;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.RuleNode;
|
||||
|
|
|
@ -33,8 +33,6 @@ package org.antlr.v4.runtime.tree.pattern;
|
|||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenSource;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link Token} object representing an entire subtree matched by a parser
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.tree.pattern;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a placeholder tag in a tree pattern. A tag can have any of the
|
||||
* following forms.
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
package org.antlr.v4.runtime.tree.pattern;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a span of raw text (concrete syntax) between tags in a tree
|
||||
* pattern string.
|
||||
|
|
|
@ -32,8 +32,6 @@ package org.antlr.v4.runtime.tree.pattern;
|
|||
|
||||
import org.antlr.v4.runtime.CommonToken;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link Token} object representing a token of a particular type; e.g.,
|
||||
|
|
|
@ -66,7 +66,6 @@ ListenerFile(file, header) ::= <<
|
|||
package <file.genPackage>;
|
||||
<endif>
|
||||
<header>
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
|
@ -106,7 +105,6 @@ package <file.genPackage>;
|
|||
<header>
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
|
@ -163,7 +161,6 @@ VisitorFile(file, header) ::= <<
|
|||
package <file.genPackage>;
|
||||
<endif>
|
||||
<header>
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
/**
|
||||
|
@ -195,7 +192,6 @@ BaseVisitorFile(file, header) ::= <<
|
|||
package <file.genPackage>;
|
||||
<endif>
|
||||
<header>
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.antlr.v4.parse.ToolANTLRParser;
|
|||
import org.antlr.v4.parse.v3TreeGrammarException;
|
||||
import org.antlr.v4.runtime.RuntimeMetaData;
|
||||
import org.antlr.v4.runtime.misc.LogManager;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.semantics.SemanticPipeline;
|
||||
import org.antlr.v4.tool.ANTLRMessage;
|
||||
import org.antlr.v4.tool.ANTLRToolListener;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.automata;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.atn.ATNState;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
import org.antlr.v4.tool.ast.BlockAST;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.antlr.v4.runtime.atn.SetTransition;
|
|||
import org.antlr.v4.runtime.atn.Transition;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.antlr.v4.tool.Rule;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.automata;
|
|||
|
||||
import org.antlr.v4.runtime.atn.ATNState;
|
||||
import org.antlr.v4.runtime.atn.Transition;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
|
|
@ -58,8 +58,6 @@ import org.antlr.v4.runtime.atn.TokensStartState;
|
|||
import org.antlr.v4.runtime.atn.Transition;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.LexerGrammar;
|
||||
import org.antlr.v4.tool.Rule;
|
||||
|
|
|
@ -68,8 +68,6 @@ import org.antlr.v4.runtime.atn.StarLoopbackState;
|
|||
import org.antlr.v4.runtime.atn.Transition;
|
||||
import org.antlr.v4.runtime.atn.WildcardTransition;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Triple;
|
||||
import org.antlr.v4.semantics.UseDefAnalyzer;
|
||||
import org.antlr.v4.tool.ErrorManager;
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.antlr.v4.runtime.atn.PlusLoopbackState;
|
|||
import org.antlr.v4.runtime.atn.RuleTransition;
|
||||
import org.antlr.v4.runtime.atn.StarLoopbackState;
|
||||
import org.antlr.v4.runtime.atn.Transition;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -30,12 +30,6 @@
|
|||
|
||||
package org.antlr.v4.codegen;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.antlr.runtime.ANTLRStringStream;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.v4.codegen.model.RuleFunction;
|
||||
|
@ -79,6 +73,12 @@ import org.antlr.v4.tool.Grammar;
|
|||
import org.antlr.v4.tool.Rule;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** */
|
||||
public class ActionTranslator implements ActionSplitterListener {
|
||||
public static final Map<String, Class<? extends RulePropertyRef>> thisRulePropToModelMap =
|
||||
|
|
|
@ -33,8 +33,6 @@ package org.antlr.v4.codegen;
|
|||
import org.antlr.v4.Tool;
|
||||
import org.antlr.v4.codegen.model.OutputModelObject;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.stringtemplate.v4.AutoIndentWriter;
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.antlr.v4.codegen.model.RuleFunction;
|
|||
import org.antlr.v4.codegen.model.SrcOp;
|
||||
import org.antlr.v4.codegen.model.decl.CodeBlock;
|
||||
import org.antlr.v4.codegen.model.decl.Decl;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.Alternative;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.antlr.v4.misc.Utils;
|
|||
import org.antlr.v4.parse.ANTLRParser;
|
||||
import org.antlr.v4.runtime.RuntimeMetaData;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.antlr.v4.tool.Rule;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.codegen.model;
|
|||
|
||||
import org.antlr.v4.codegen.OutputModelFactory;
|
||||
import org.antlr.v4.runtime.atn.PlusBlockStartState;
|
||||
import org.antlr.v4.runtime.atn.PlusLoopbackState;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.tool.ast.BlockAST;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
|
|
@ -61,6 +61,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -68,8 +69,6 @@ import java.util.Set;
|
|||
import static org.antlr.v4.parse.ANTLRParser.RULE_REF;
|
||||
import static org.antlr.v4.parse.ANTLRParser.TOKEN_REF;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
/** */
|
||||
public class RuleFunction extends OutputModelObject {
|
||||
public String name;
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.antlr.v4.codegen.CodeGenerator;
|
|||
import org.antlr.v4.codegen.OutputModelFactory;
|
||||
import org.antlr.v4.codegen.model.chunk.ActionChunk;
|
||||
import org.antlr.v4.runtime.atn.AbstractPredicateTransition;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
package org.antlr.v4.misc;
|
||||
|
||||
import org.antlr.v4.runtime.misc.IntegerList;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -32,12 +32,9 @@ package org.antlr.v4.parse;
|
|||
|
||||
import org.antlr.runtime.BaseRecognizer;
|
||||
import org.antlr.runtime.CommonToken;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.tool.Attribute;
|
||||
import org.antlr.v4.tool.AttributeDict;
|
||||
import org.antlr.v4.tool.ErrorManager;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.semantics;
|
|||
import org.antlr.v4.analysis.LeftRecursiveRuleTransformer;
|
||||
import org.antlr.v4.parse.ANTLRParser;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
package org.antlr.v4.semantics;
|
||||
|
||||
import org.antlr.v4.parse.ANTLRParser;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.Alternative;
|
||||
import org.antlr.v4.tool.Attribute;
|
||||
import org.antlr.v4.tool.AttributeDict;
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
package org.antlr.v4.tool;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.stringtemplate.v4.ST;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ANTLRMessage {
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
package org.antlr.v4.tool;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
package org.antlr.v4.tool;
|
||||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.v4.Tool;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
|
|
@ -55,8 +55,6 @@ import org.antlr.v4.runtime.dfa.DFA;
|
|||
import org.antlr.v4.runtime.misc.IntSet;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.IntervalSet;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Nullable;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.tool.ast.ActionAST;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
|
|
@ -32,7 +32,6 @@ package org.antlr.v4.tool.ast;
|
|||
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.v4.misc.CharSupport;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.tool.ast;
|
|||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.TokenStream;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -56,7 +56,6 @@ import org.antlr.v4.runtime.atn.LexerATNSimulator;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.IntegerList;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeLexers extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.antlr.v4.test.tool.ErrorQueue;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeParsers extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestFullContextParsing extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLeftRecursion extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerErrors extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestListeners extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParseTrees extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParserExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalLexer extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalParser extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.antlr.v4.test.rt.java;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSets extends BaseTest {
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ import org.antlr.v4.runtime.atn.LexerATNSimulator;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.IntegerList;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
|
|
|
@ -33,7 +33,6 @@ package org.antlr.v4.test.tool;
|
|||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.misc.IntegerList;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -57,7 +57,6 @@ import org.antlr.v4.runtime.atn.PredictionMode;
|
|||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.dfa.DFAState;
|
||||
import org.antlr.v4.runtime.misc.Interval;
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.ParseCancellationException;
|
||||
import org.antlr.v4.runtime.misc.Utils;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
|
|
Loading…
Reference in New Issue