KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > apt > dispatch > BatchMessagerImpl


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * wharley@bea.com - initial API and implementation
10  *
11  *******************************************************************************/

12
13 package org.eclipse.jdt.internal.compiler.apt.dispatch;
14
15 import javax.annotation.processing.Messager;
16 import javax.lang.model.element.AnnotationMirror;
17 import javax.lang.model.element.AnnotationValue;
18 import javax.lang.model.element.Element;
19 import javax.tools.Diagnostic.Kind;
20
21 import org.eclipse.jdt.core.compiler.CategorizedProblem;
22 import org.eclipse.jdt.internal.compiler.batch.Main;
23
24 /**
25  * An implementation of Messager that reports messages via the Compiler
26  */

27 public class BatchMessagerImpl extends BaseMessagerImpl implements Messager {
28
29     private final Main _compiler;
30     private final BaseProcessingEnvImpl _processingEnv;
31
32     public BatchMessagerImpl(BaseProcessingEnvImpl processingEnv, Main compiler) {
33         _compiler = compiler;
34         _processingEnv = processingEnv;
35     }
36
37     /* (non-Javadoc)
38      * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence)
39      */

40     @Override JavaDoc
41     public void printMessage(Kind kind, CharSequence JavaDoc msg) {
42         printMessage(kind, msg, null, null, null);
43     }
44
45     /* (non-Javadoc)
46      * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element)
47      */

48     @Override JavaDoc
49     public void printMessage(Kind kind, CharSequence JavaDoc msg, Element e) {
50         printMessage(kind, msg, e, null, null);
51     }
52
53     /* (non-Javadoc)
54      * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror)
55      */

56     @Override JavaDoc
57     public void printMessage(Kind kind, CharSequence JavaDoc msg, Element e,
58             AnnotationMirror a) {
59         printMessage(kind, msg, e, a, null);
60
61     }
62
63     /* (non-Javadoc)
64      * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationValue)
65      */

66     @Override JavaDoc
67     public void printMessage(Kind kind, CharSequence JavaDoc msg, Element e,
68             AnnotationMirror a, AnnotationValue v) {
69         //TODO: we are currently ignoring 'a' and 'v'
70
if (kind == Kind.ERROR) {
71             _processingEnv.setErrorRaised(true);
72         }
73         CategorizedProblem problem = createProblem(kind, msg, e);
74         if (problem != null) {
75             this._compiler.addExtraProblems(problem);
76         }
77     }
78 }
79
Popular Tags