Merge pull request #715 from sharwell/fix-487

NullUsageProcessor supports Java 6 through 8
This commit is contained in:
Terence Parr 2014-09-26 14:31:41 -07:00
commit e3f2e5a7d0
1 changed files with 16 additions and 2 deletions

View File

@ -33,7 +33,6 @@ package org.antlr.v4.runtime.misc;
import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
@ -83,7 +82,6 @@ import java.util.Set;
* @author Sam Harwell * @author Sam Harwell
*/ */
@SupportedAnnotationTypes({NullUsageProcessor.NotNullClassName, NullUsageProcessor.NullableClassName}) @SupportedAnnotationTypes({NullUsageProcessor.NotNullClassName, NullUsageProcessor.NullableClassName})
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class NullUsageProcessor extends AbstractProcessor { public class NullUsageProcessor extends AbstractProcessor {
public static final String NotNullClassName = "org.antlr.v4.runtime.misc.NotNull"; public static final String NotNullClassName = "org.antlr.v4.runtime.misc.NotNull";
public static final String NullableClassName = "org.antlr.v4.runtime.misc.Nullable"; public static final String NullableClassName = "org.antlr.v4.runtime.misc.Nullable";
@ -94,6 +92,22 @@ public class NullUsageProcessor extends AbstractProcessor {
public NullUsageProcessor() { 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 @Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!checkClassNameConstants()) { if (!checkClassNameConstants()) {