1 18 package org.apache.beehive.netui.compiler; 19 20 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration; 22 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; 23 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 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 ) 36 { 37 addErrorArrayArgs( decl, messageKey, null ); 38 } 39 40 public void addError( Declaration decl, String messageKey, Object arg ) 41 { 42 addErrorArrayArgs( decl, messageKey, new Object []{ arg } ); 43 } 44 45 public void addError( Declaration decl, String messageKey, Object arg1, Object arg2 ) 46 { 47 addErrorArrayArgs( decl, messageKey, new Object []{ arg1, arg2 } ); 48 } 49 50 public void addError( Declaration decl, String messageKey, Object arg1, Object arg2, Object arg3 ) 51 { 52 addErrorArrayArgs( decl, messageKey, new Object []{ arg1, arg2, arg3 } ); 53 } 54 55 public void addErrorArrayArgs( Declaration decl, String messageKey, Object [] args ) 56 { 57 _env.getMessager().printError( decl.getPosition(), getResourceString( messageKey, args ) ); 58 _hasErrors = true; 59 } 60 61 public void addErrorNoPosition( String messageKey, Object [] args ) 62 { 63 _env.getMessager().printError( getResourceString( messageKey, args ) ); 64 } 65 66 public void addError( AnnotationInstance ann, String messageKey ) 67 { 68 addErrorArrayArgs( ann, messageKey, null ); 69 } 70 71 public void addError( AnnotationInstance ann, String messageKey, Object arg ) 72 { 73 addErrorArrayArgs( ann, messageKey, new Object []{ arg } ); 74 } 75 76 public void addError( AnnotationInstance ann, String messageKey, Object arg1, Object arg2 ) 77 { 78 addErrorArrayArgs( ann, messageKey, new Object []{ arg1, arg2 } ); 79 } 80 81 public void addError( AnnotationInstance ann, String messageKey, Object arg1, Object arg2, Object arg3 ) 82 { 83 addErrorArrayArgs( ann, messageKey, new Object []{ arg1, arg2, arg3 } ); 84 } 85 86 public void addErrorArrayArgs( AnnotationInstance ann, String messageKey, Object [] args ) 87 { 88 _env.getMessager().printError( ann.getPosition(), getResourceString( messageKey, args ) ); 89 _hasErrors = true; 90 } 91 92 public void addError( AnnotationValue value, String messageKey ) 93 { 94 addErrorArrayArgs( value, messageKey, null ); 95 } 96 97 public void addError( AnnotationValue value, String messageKey, Object arg ) 98 { 99 addErrorArrayArgs( value, messageKey, new Object []{ arg } ); 100 } 101 102 public void addError( AnnotationValue value, String messageKey, Object arg1, Object arg2 ) 103 { 104 addErrorArrayArgs( value, messageKey, new Object []{ arg1, arg2 } ); 105 } 106 107 public void addError( AnnotationValue value, String messageKey, Object arg1, Object arg2, Object arg3 ) 108 { 109 addErrorArrayArgs( value, messageKey, new Object []{ arg1, arg2, arg3 } ); 110 } 111 112 public void addErrorArrayArgs( AnnotationValue value, String messageKey, Object [] args ) 113 { 114 _env.getMessager().printError( value.getPosition(), getResourceString( messageKey, args ) ); 115 _hasErrors = true; 116 } 117 118 public void addWarning( Declaration decl, String messageKey ) 119 { 120 addWarningArrayArgs( decl, messageKey, null ); 121 } 122 123 public void addWarning( Declaration decl, String messageKey, Object arg ) 124 { 125 addWarningArrayArgs( decl, messageKey, new Object []{ arg } ); 126 } 127 128 public void addWarning( Declaration decl, String messageKey, Object arg1, Object arg2 ) 129 { 130 addWarningArrayArgs( decl, messageKey, new Object []{ arg1, arg2 } ); 131 } 132 133 public void addWarning( Declaration decl, String messageKey, Object arg1, Object arg2, Object arg3 ) 134 { 135 addWarningArrayArgs( decl, messageKey, new Object []{ arg1, arg2, arg3 } ); 136 } 137 138 public void addWarningArrayArgs( Declaration decl, String messageKey, Object [] args ) 139 { 140 _env.getMessager().printWarning( decl.getPosition(), getResourceString( messageKey, args ) ); 141 } 142 143 public void addWarning( AnnotationInstance ann, String messageKey ) 144 { 145 addWarningArrayArgs( ann, messageKey, null ); 146 } 147 148 public void addWarning( AnnotationInstance ann, String messageKey, Object arg ) 149 { 150 addWarningArrayArgs( ann, messageKey, new Object []{ arg } ); 151 } 152 153 public void addWarning( AnnotationInstance ann, String messageKey, Object arg1, Object arg2 ) 154 { 155 addWarningArrayArgs( ann, messageKey, new Object []{ arg1, arg2 } ); 156 } 157 158 public void addWarning( AnnotationInstance ann, String messageKey, Object arg1, Object arg2, Object arg3 ) 159 { 160 addWarningArrayArgs( ann, messageKey, new Object []{ arg1, arg2, arg3 } ); 161 } 162 163 public void addWarningArrayArgs( AnnotationInstance ann, String messageKey, Object [] args ) 164 { 165 _env.getMessager().printWarning( ann.getPosition(), getResourceString( messageKey, args ) ); 166 } 167 168 public void addWarning( AnnotationValue value, String messageKey ) 169 { 170 addWarningArrayArgs( value, messageKey, null ); 171 } 172 173 public void addWarning( AnnotationValue value, String messageKey, Object arg ) 174 { 175 addWarningArrayArgs( value, messageKey, new Object []{ arg } ); 176 } 177 178 public void addWarning( AnnotationValue value, String messageKey, Object arg1, Object arg2 ) 179 { 180 addWarningArrayArgs( value, messageKey, new Object []{ arg1, arg2 } ); 181 } 182 183 public void addWarning( AnnotationValue value, String messageKey, Object arg1, Object arg2, Object arg3 ) 184 { 185 addWarningArrayArgs( value, messageKey, new Object []{ arg1, arg2, arg3 } ); 186 } 187 188 public void addWarningArrayArgs( AnnotationValue value, String messageKey, Object [] args ) 189 { 190 _env.getMessager().printWarning( value.getPosition(), getResourceString( messageKey, args ) ); 191 } 192 193 protected abstract String getResourceString( String key, Object [] args ); 194 195 public boolean hasErrors() 196 { 197 return _hasErrors; 198 } 199 200 protected void setHasErrors( boolean hadErrors ) 201 { 202 _hasErrors = hadErrors; 203 } 204 205 protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() 206 { 207 return _env; 208 } 209 } 210 | Popular Tags |