Error out the correct way with nice messages in ConvertDeclaration and ConvertTypeMirror
This commit is contained in:
parent
c3e22f44cf
commit
b02e035344
@ -70,6 +70,7 @@ public class ConvertAnnotationProcessorEnvironment implements AnnotationProcesso
|
|||||||
elements = internal.getElementUtils();
|
elements = internal.getElementUtils();
|
||||||
ConvertDeclaration.elements = elements;
|
ConvertDeclaration.elements = elements;
|
||||||
ConvertTypeMirror.types = internal.getTypeUtils();
|
ConvertTypeMirror.types = internal.getTypeUtils();
|
||||||
|
ConvertDeclaration.messager = ConvertTypeMirror.messager = internal.getMessager();
|
||||||
|
|
||||||
// now calculate options once, since they are sort-of expensive
|
// now calculate options once, since they are sort-of expensive
|
||||||
// real apt passes them back like so:
|
// real apt passes them back like so:
|
||||||
|
@ -26,13 +26,16 @@ import com.sun.mirror.util.DeclarationVisitor;
|
|||||||
import com.sun.mirror.util.SourcePosition;
|
import com.sun.mirror.util.SourcePosition;
|
||||||
import com.moparisthebest.mirror.log.Debug;
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.annotation.processing.Messager;
|
||||||
import javax.lang.model.element.*;
|
import javax.lang.model.element.*;
|
||||||
import javax.lang.model.util.Elements;
|
import javax.lang.model.util.Elements;
|
||||||
|
import javax.tools.Diagnostic;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ConvertDeclaration extends Convertable<Element, Declaration> implements com.sun.mirror.declaration.Declaration {
|
public class ConvertDeclaration extends Convertable<Element, Declaration> implements com.sun.mirror.declaration.Declaration {
|
||||||
|
|
||||||
|
public static Messager messager = null;
|
||||||
public static Elements elements = null;
|
public static Elements elements = null;
|
||||||
protected final javax.lang.model.element.Element internalElement;
|
protected final javax.lang.model.element.Element internalElement;
|
||||||
|
|
||||||
@ -106,12 +109,9 @@ public class ConvertDeclaration extends Convertable<Element, Declaration> implem
|
|||||||
return (T) new ConvertParameterDeclaration((VariableElement) from);
|
return (T) new ConvertParameterDeclaration((VariableElement) from);
|
||||||
case FIELD:
|
case FIELD:
|
||||||
return (T) new ConvertFieldDeclaration((VariableElement) from);
|
return (T) new ConvertFieldDeclaration((VariableElement) from);
|
||||||
default:
|
|
||||||
System.err.println("FATAL ERROR, REACHED DEFAULT!");
|
|
||||||
System.exit(1);
|
|
||||||
//throw new RuntimeException("FATAL ERROR, REACHED DEFAULT!");
|
|
||||||
}
|
}
|
||||||
// shouldn't ever get here
|
// shouldn't ever get here
|
||||||
|
messager.printMessage(Diagnostic.Kind.ERROR, "ConvertDeclaration reached default for kind: " + from.getKind(), from);
|
||||||
return (T) new ConvertDeclaration(from);
|
return (T) new ConvertDeclaration(from);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,15 @@ import com.moparisthebest.mirror.convert.Convertable;
|
|||||||
import com.sun.mirror.util.TypeVisitor;
|
import com.sun.mirror.util.TypeVisitor;
|
||||||
import com.moparisthebest.mirror.log.Debug;
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.annotation.processing.Messager;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.util.Types;
|
import javax.lang.model.util.Types;
|
||||||
|
import javax.tools.Diagnostic;
|
||||||
|
|
||||||
public class ConvertTypeMirror extends Convertable<TypeMirror, com.sun.mirror.type.TypeMirror> implements com.sun.mirror.type.TypeMirror {
|
public class ConvertTypeMirror extends Convertable<TypeMirror, com.sun.mirror.type.TypeMirror> implements com.sun.mirror.type.TypeMirror {
|
||||||
protected final javax.lang.model.type.TypeMirror internalTypeMirror;
|
protected final javax.lang.model.type.TypeMirror internalTypeMirror;
|
||||||
|
|
||||||
|
public static Messager messager = null;
|
||||||
public static Types types = null;
|
public static Types types = null;
|
||||||
|
|
||||||
protected ConvertTypeMirror(javax.lang.model.type.TypeMirror internalTypeMirror) {
|
protected ConvertTypeMirror(javax.lang.model.type.TypeMirror internalTypeMirror) {
|
||||||
@ -100,17 +103,15 @@ public class ConvertTypeMirror extends Convertable<TypeMirror, com.sun.mirror.ty
|
|||||||
case ANNOTATION_TYPE:
|
case ANNOTATION_TYPE:
|
||||||
return (T) new ConvertAnnotationType(dt);
|
return (T) new ConvertAnnotationType(dt);
|
||||||
}
|
}
|
||||||
|
//case ERROR:
|
||||||
|
// return (T) new ConvertDeclaredType((javax.lang.model.type.ErrorType)from);
|
||||||
case NONE:
|
case NONE:
|
||||||
case NULL:
|
case NULL:
|
||||||
return null;
|
return null;
|
||||||
default:
|
|
||||||
System.err.println("FATAL ERROR, REACHED DEFAULT!");
|
|
||||||
System.exit(1);
|
|
||||||
//throw new RuntimeException("FATAL ERROR, REACHED DEFAULT!");
|
|
||||||
}
|
}
|
||||||
// shouldn't ever get here
|
// shouldn't ever get here
|
||||||
|
messager.printMessage(Diagnostic.Kind.ERROR, "ConvertTypeMirror reached default for kind: " + from.getKind(), types.asElement(from));
|
||||||
return (T) new ConvertTypeMirror(from);
|
return (T) new ConvertTypeMirror(from);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user