1 18 package org.apache.beehive.controls.runtime.generator.apt; 19 20 import com.sun.mirror.apt.AnnotationProcessorEnvironment; 21 import com.sun.mirror.declaration.Declaration; 22 import com.sun.mirror.declaration.AnnotationValue; 23 import com.sun.mirror.declaration.AnnotationMirror; 24 25 public abstract class Diagnostics 26 { 27 private AnnotationProcessorEnvironment _env; 28 private boolean _hasErrors = false; 29 30 protected Diagnostics( AnnotationProcessorEnvironment env ) 31 { 32 _env = env; 33 } 34 35 public void addError( Declaration decl, String messageKey, Object ... args ) 36 { 37 _env.getMessager().printError( decl.getPosition(), getResourceString( messageKey, args ) ); 38 _hasErrors = true; 39 } 40 41 public void addError( AnnotationMirror ann, String messageKey, Object ... args ) 42 { 43 _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) ); 44 _hasErrors = true; 45 } 46 47 public void addErrorArrayArgs( AnnotationMirror ann, String messageKey, Object [] args ) 48 { 49 _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) ); 50 _hasErrors = true; 51 } 52 53 public void addError( AnnotationValue annVal, String messageKey, Object ... args ) 54 { 55 _env.getMessager().printError( annVal.getPosition(), getResourceString( messageKey, args ) ); 56 _hasErrors = true; 57 } 58 59 public void addWarning( Declaration decl, String messageKey, Object ... args ) 60 { 61 _env.getMessager().printWarning( decl.getPosition(), getResourceString( messageKey, args ) ); 62 } 63 64 public void addWarning( AnnotationMirror ann, String messageKey, Object ... args ) 65 { 66 _env.getMessager().printWarning( ann.getPosition(), getResourceString( messageKey, args ) ); 67 } 68 69 public void addWarning( AnnotationValue annVal, String messageKey, Object ... args ) 70 { 71 _env.getMessager().printWarning( annVal.getPosition(), getResourceString( messageKey, args ) ); 72 } 73 74 public AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() 75 { 76 return _env; 77 } 78 79 protected abstract String getResourceString( String key, Object ... args ); 80 81 public boolean hasErrors() 82 { 83 return _hasErrors; 84 } 85 86 protected void setHasErrors( boolean hadErrors ) 87 { 88 _hasErrors = hadErrors; 89 } 90 } 91 | Popular Tags |