001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.compiler;
020:
021: import org.apache.beehive.netui.compiler.typesystem.env.CoreAnnotationProcessorEnv;
022: import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration;
023: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue;
024: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
025:
026: public abstract class Diagnostics {
027: private CoreAnnotationProcessorEnv _env;
028: private boolean _hasErrors = false;
029:
030: protected Diagnostics(CoreAnnotationProcessorEnv env) {
031: _env = env;
032: }
033:
034: public void addError(Declaration decl, String messageKey) {
035: addErrorArrayArgs(decl, messageKey, null);
036: }
037:
038: public void addError(Declaration decl, String messageKey, Object arg) {
039: addErrorArrayArgs(decl, messageKey, new Object[] { arg });
040: }
041:
042: public void addError(Declaration decl, String messageKey,
043: Object arg1, Object arg2) {
044: addErrorArrayArgs(decl, messageKey, new Object[] { arg1, arg2 });
045: }
046:
047: public void addError(Declaration decl, String messageKey,
048: Object arg1, Object arg2, Object arg3) {
049: addErrorArrayArgs(decl, messageKey, new Object[] { arg1, arg2,
050: arg3 });
051: }
052:
053: public void addErrorArrayArgs(Declaration decl, String messageKey,
054: Object[] args) {
055: _env.getMessager().printError(decl.getPosition(),
056: getResourceString(messageKey, args));
057: _hasErrors = true;
058: }
059:
060: public void addErrorNoPosition(String messageKey, Object[] args) {
061: _env.getMessager().printError(
062: getResourceString(messageKey, args));
063: }
064:
065: public void addError(AnnotationInstance ann, String messageKey) {
066: addErrorArrayArgs(ann, messageKey, null);
067: }
068:
069: public void addError(AnnotationInstance ann, String messageKey,
070: Object arg) {
071: addErrorArrayArgs(ann, messageKey, new Object[] { arg });
072: }
073:
074: public void addError(AnnotationInstance ann, String messageKey,
075: Object arg1, Object arg2) {
076: addErrorArrayArgs(ann, messageKey, new Object[] { arg1, arg2 });
077: }
078:
079: public void addError(AnnotationInstance ann, String messageKey,
080: Object arg1, Object arg2, Object arg3) {
081: addErrorArrayArgs(ann, messageKey, new Object[] { arg1, arg2,
082: arg3 });
083: }
084:
085: public void addErrorArrayArgs(AnnotationInstance ann,
086: String messageKey, Object[] args) {
087: _env.getMessager().printError(ann.getPosition(),
088: getResourceString(messageKey, args));
089: _hasErrors = true;
090: }
091:
092: public void addError(AnnotationValue value, String messageKey) {
093: addErrorArrayArgs(value, messageKey, null);
094: }
095:
096: public void addError(AnnotationValue value, String messageKey,
097: Object arg) {
098: addErrorArrayArgs(value, messageKey, new Object[] { arg });
099: }
100:
101: public void addError(AnnotationValue value, String messageKey,
102: Object arg1, Object arg2) {
103: addErrorArrayArgs(value, messageKey,
104: new Object[] { arg1, arg2 });
105: }
106:
107: public void addError(AnnotationValue value, String messageKey,
108: Object arg1, Object arg2, Object arg3) {
109: addErrorArrayArgs(value, messageKey, new Object[] { arg1, arg2,
110: arg3 });
111: }
112:
113: public void addErrorArrayArgs(AnnotationValue value,
114: String messageKey, Object[] args) {
115: _env.getMessager().printError(value.getPosition(),
116: getResourceString(messageKey, args));
117: _hasErrors = true;
118: }
119:
120: public void addWarning(Declaration decl, String messageKey) {
121: addWarningArrayArgs(decl, messageKey, null);
122: }
123:
124: public void addWarning(Declaration decl, String messageKey,
125: Object arg) {
126: addWarningArrayArgs(decl, messageKey, new Object[] { arg });
127: }
128:
129: public void addWarning(Declaration decl, String messageKey,
130: Object arg1, Object arg2) {
131: addWarningArrayArgs(decl, messageKey,
132: new Object[] { arg1, arg2 });
133: }
134:
135: public void addWarning(Declaration decl, String messageKey,
136: Object arg1, Object arg2, Object arg3) {
137: addWarningArrayArgs(decl, messageKey, new Object[] { arg1,
138: arg2, arg3 });
139: }
140:
141: public void addWarningArrayArgs(Declaration decl,
142: String messageKey, Object[] args) {
143: _env.getMessager().printWarning(decl.getPosition(),
144: getResourceString(messageKey, args));
145: }
146:
147: public void addWarning(AnnotationInstance ann, String messageKey) {
148: addWarningArrayArgs(ann, messageKey, null);
149: }
150:
151: public void addWarning(AnnotationInstance ann, String messageKey,
152: Object arg) {
153: addWarningArrayArgs(ann, messageKey, new Object[] { arg });
154: }
155:
156: public void addWarning(AnnotationInstance ann, String messageKey,
157: Object arg1, Object arg2) {
158: addWarningArrayArgs(ann, messageKey,
159: new Object[] { arg1, arg2 });
160: }
161:
162: public void addWarning(AnnotationInstance ann, String messageKey,
163: Object arg1, Object arg2, Object arg3) {
164: addWarningArrayArgs(ann, messageKey, new Object[] { arg1, arg2,
165: arg3 });
166: }
167:
168: public void addWarningArrayArgs(AnnotationInstance ann,
169: String messageKey, Object[] args) {
170: _env.getMessager().printWarning(ann.getPosition(),
171: getResourceString(messageKey, args));
172: }
173:
174: public void addWarning(AnnotationValue value, String messageKey) {
175: addWarningArrayArgs(value, messageKey, null);
176: }
177:
178: public void addWarning(AnnotationValue value, String messageKey,
179: Object arg) {
180: addWarningArrayArgs(value, messageKey, new Object[] { arg });
181: }
182:
183: public void addWarning(AnnotationValue value, String messageKey,
184: Object arg1, Object arg2) {
185: addWarningArrayArgs(value, messageKey, new Object[] { arg1,
186: arg2 });
187: }
188:
189: public void addWarning(AnnotationValue value, String messageKey,
190: Object arg1, Object arg2, Object arg3) {
191: addWarningArrayArgs(value, messageKey, new Object[] { arg1,
192: arg2, arg3 });
193: }
194:
195: public void addWarningArrayArgs(AnnotationValue value,
196: String messageKey, Object[] args) {
197: _env.getMessager().printWarning(value.getPosition(),
198: getResourceString(messageKey, args));
199: }
200:
201: protected abstract String getResourceString(String key,
202: Object[] args);
203:
204: public boolean hasErrors() {
205: return _hasErrors;
206: }
207:
208: protected void setHasErrors(boolean hadErrors) {
209: _hasErrors = hadErrors;
210: }
211:
212: protected CoreAnnotationProcessorEnv getAnnotationProcessorEnvironment() {
213: return _env;
214: }
215: }
|