You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ke...@apache.org on 2005/04/29 00:57:59 UTC
svn commit: r165221 - in
/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator:
./ apt/
Author: kentam
Date: Thu Apr 28 15:57:57 2005
New Revision: 165221
URL: http://svn.apache.org/viewcvs?rev=165221&view=rev
Log:
BEEHIVE-15: Refactor control compilation-time code to use TwoPhaseAnnotationProcessor
wrappers (or equiv) for diagnostics.
The Apt* class heirarchy now passes TwoPhaseAnnotationProcessor through its ctor chain, and uses
the TPAP.printError() helper to emit diagnostics.
All controls build-time diagnostic messages have been externalized into strings.properties for i18n
purposes.
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptClientField.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptContextField.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlField.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEvent.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventHandler.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethod.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptOperation.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptProperty.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptPropertySet.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/Diagnostics.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptClientField.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptClientField.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptClientField.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptClientField.java Thu Apr 28 15:57:57 2005
@@ -32,14 +32,11 @@
* Base constructor, protected so only a custom subclass can invoke
* @param controlImpl the declaring AptControlImplementation
*/
- public AptClientField(AptControlImplementation controlImpl, FieldDeclaration fieldDecl,
- AnnotationProcessorEnvironment env)
+ public AptClientField(AptControlImplementation controlImpl, FieldDeclaration fieldDecl)
{
super(fieldDecl);
_controlImpl = controlImpl;
- _env = env;
};
private AptControlImplementation _controlImpl;
- private AnnotationProcessorEnvironment _env;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptContextField.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptContextField.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptContextField.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptContextField.java Thu Apr 28 15:57:57 2005
@@ -18,12 +18,10 @@
* $Header:$
*/
-import java.util.ArrayList;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.type.InterfaceType;
import com.sun.mirror.type.TypeMirror;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptContextField class contains information about a field referring to a contextual
@@ -36,11 +34,11 @@
* @param controlImpl the declaring ControlImplementation
*/
public AptContextField(AptControlImplementation controlImpl, FieldDeclaration fieldDecl,
- AnnotationProcessorEnvironment env)
+ TwoPhaseAnnotationProcessor ap)
{
super(fieldDecl);
_controlImpl = controlImpl;
- _env = env;
+ _ap = ap;
};
/**
@@ -52,8 +50,7 @@
TypeMirror fieldType = _fieldDecl.getType();
if (! (fieldType instanceof InterfaceType))
{
- _env.getMessager().printError(_fieldDecl.getPosition(),
- "@Context field type must be an interface");
+ _ap.printError( _fieldDecl, "context.field.badinterface" );
return null;
}
@@ -62,9 +59,9 @@
// interface for the contextual service.
//
return new AptControlInterface(((InterfaceType)_fieldDecl.getType()).getDeclaration(),
- _env);
+ _ap);
}
private AptControlImplementation _controlImpl;
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlClient.java Thu Apr 28 15:57:57 2005
@@ -25,13 +25,13 @@
import java.io.IOException;
import java.io.Writer;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.Filer;
import com.sun.mirror.declaration.*;
import com.sun.mirror.type.TypeMirror;
import com.sun.mirror.type.ClassType;
import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptControlClient class contains metadata about a class that contains nested control
@@ -44,13 +44,12 @@
* from APT metadata
* @param decl the annotated declaration
*/
- public AptControlClient(Declaration decl, AnnotationProcessorEnvironment env)
+ public AptControlClient(Declaration decl, TwoPhaseAnnotationProcessor ap)
{
- _env = env;
+ _ap = ap;
if (! (decl instanceof ClassDeclaration))
{
- env.getMessager().printError(decl.getPosition(),
- "The Control annotation may only be used in a Java class");
+ _ap.printError( decl, "control.illegal.usage" );
return;
}
_clientDecl = (ClassDeclaration)decl;
@@ -145,7 +144,7 @@
for (FieldDeclaration fieldDecl : declaredFields)
{
if (fieldDecl.getAnnotation(org.apache.beehive.controls.api.bean.Control.class) != null)
- controls.add(new AptControlField(this, fieldDecl, _env));
+ controls.add(new AptControlField(this, fieldDecl, _ap));
}
return controls;
}
@@ -257,9 +256,8 @@
AptControlInterface controlIntf = eventField.getControlInterface();
AptEventSet eventSet = controlIntf.getEventSet(setName);
if (eventSet == null)
- {
- _env.getMessager().printError(clientMethod.getPosition(),
- "Cannot find EventSet interface: " + setName);
+ {
+ _ap.printError( clientMethod, "eventhandler.eventset.not.found", setName );
continue;
}
@@ -279,7 +277,7 @@
//
boolean found = false;
String eventName = (String)handlerAnnot.getObjectValue("eventName");
- AptMethod handlerMethod = new AptMethod(clientMethod, _env);
+ AptMethod handlerMethod = new AptMethod(clientMethod, _ap);
//
// Will start at the currrent event set and look up through any ones it
@@ -319,12 +317,11 @@
if ( !throwsMatches )
{
- _env.getMessager().printError(clientMethod.getPosition(),
- "Handler method " + handlerMethod.getName() + " throws clause is not a proper subset of the eventset method's throws claus. Handlers may only throw throwables declared by the eventset method.");
+ _ap.printError( clientMethod, "eventhandler.throws.mismatch", handlerMethod.getName() );
}
adaptor.addHandler(controlEvent,
- new AptEventHandler(controlEvent, clientMethod, _env));
+ new AptEventHandler(controlEvent, clientMethod, _ap ));
found = true;
break;
}
@@ -339,15 +336,13 @@
}
if (!found)
{
- _env.getMessager().printError(clientMethod.getPosition(),
- "No event method with matching name and signature found on EventSet: " +
- setName);
+ _ap.printError( clientMethod, "eventhandler.method.not.found", setName );
}
}
}
ClassDeclaration _clientDecl;
- AnnotationProcessorEnvironment _env;
+ TwoPhaseAnnotationProcessor _ap;
ArrayList<AptControlField> _controls;
ClientInitializer _init;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlField.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlField.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlField.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlField.java Thu Apr 28 15:57:57 2005
@@ -19,7 +19,6 @@
import java.util.Collection;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.declaration.InterfaceDeclaration;
@@ -31,6 +30,7 @@
import org.apache.beehive.controls.api.bean.ControlExtension;
import org.apache.beehive.controls.api.bean.ControlInterface;
import org.apache.beehive.controls.api.versioning.VersionRequired;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptControlField class contains information about a field that refers to a nested control.
@@ -42,11 +42,11 @@
* @param controlClient the declaring AptType
*/
public AptControlField(AptType controlClient, FieldDeclaration controlDecl,
- AnnotationProcessorEnvironment env)
+ TwoPhaseAnnotationProcessor ap)
{
super( controlDecl );
_controlClient = controlClient;
- _env = env;
+ _ap = ap;
_controlBean = new ControlBean(getControlInterface());
};
@@ -67,8 +67,7 @@
TypeMirror controlType = _fieldDecl.getType();
if (! (controlType instanceof DeclaredType))
{
- _env.getMessager().printError(_fieldDecl.getPosition(),
- "@Control field type must be a valid ControlBean class or control interface");
+ _ap.printError( _fieldDecl, "control.field.bad.type" );
return null;
}
@@ -89,12 +88,12 @@
{
String className = controlType.toString();
String intfName = className.substring(0, className.length() - 4);
- controlIntf = (InterfaceDeclaration)_env.getTypeDeclaration(intfName);
+ controlIntf = (InterfaceDeclaration)_ap.getAnnotationProcessorEnvironment().getTypeDeclaration(intfName);
if (controlIntf == null)
{
// The specified class name may not be fully qualified. In this case, the
// best we can do is look for a best fit match against the input types
- for (TypeDeclaration td :_env.getSpecifiedTypeDeclarations())
+ for (TypeDeclaration td :_ap.getAnnotationProcessorEnvironment().getSpecifiedTypeDeclarations())
{
if (td instanceof InterfaceDeclaration &&
td.getSimpleName().equals(intfName))
@@ -130,12 +129,11 @@
if (controlIntf == null)
{
- _env.getMessager().printError(_fieldDecl.getPosition(),
- "Unable to identify control type of field");
- return null;
+ _ap.printError( _fieldDecl, "control.field.bad.type.2" );
+ return null;
}
- return new AptControlInterface(controlIntf, _env);
+ return new AptControlInterface(controlIntf, _ap);
}
/**
@@ -143,7 +141,7 @@
*/
public ControlBean getControlBean() { return _controlBean; }
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
private AptType _controlClient;
private ControlBean _controlBean;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlImplementation.java Thu Apr 28 15:57:57 2005
@@ -25,7 +25,6 @@
import java.util.List;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.Filer;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.ClassDeclaration;
@@ -41,6 +40,7 @@
import org.apache.beehive.controls.api.events.EventHandler;
import org.apache.beehive.controls.api.versioning.VersionSupported;
import org.apache.beehive.controls.api.versioning.Version;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptControlImplementation class provides validation and metadata management when
@@ -53,13 +53,12 @@
* from APT metadata
* @param decl the annotated declaration
*/
- public AptControlImplementation(Declaration decl, AnnotationProcessorEnvironment env)
+ public AptControlImplementation(Declaration decl, TwoPhaseAnnotationProcessor ap)
{
- _env = env;
+ _ap = ap;
if (! (decl instanceof ClassDeclaration))
{
- env.getMessager().printError(decl.getPosition(),
- "The ControlImplementation annotation may only be used on a Java class");
+ _ap.printError( decl, "control.implementation.badclass" );
return;
}
_implDecl = (ClassDeclaration)decl;
@@ -95,9 +94,7 @@
if (!isSerializable)
{
- env.getMessager().printError(decl.getPosition(),
- "A ControlImplementation class must implement the java.io.Serializable interface or set the isTransient attribute of @ControlImplementation to true");
-
+ _ap.printError( decl, "control.implementation.unserializable" );
}
}
@@ -108,8 +105,7 @@
if ( getControlInterface() == null )
{
- env.getMessager().printError(decl.getPosition(),
- "Control implementations must implement a control interface");
+ _ap.printError( decl, "control.implementation.missing.interface" );
return;
}
@@ -130,8 +126,8 @@
ClassDeclaration superDecl = _implDecl.getSuperclass().getDeclaration();
if (superDecl != null &&
superDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlImplementation.class) != null)
- {
- return new AptControlImplementation(superDecl, _env);
+ {
+ return new AptControlImplementation(superDecl, _ap);
}
return null;
@@ -156,7 +152,7 @@
for (FieldDeclaration fieldDecl : declaredFields)
{
if (fieldDecl.getAnnotation(org.apache.beehive.controls.api.context.Context.class) != null)
- contexts.add(new AptContextField(this, fieldDecl, _env));
+ contexts.add(new AptContextField(this, fieldDecl, _ap));
}
return contexts;
}
@@ -185,7 +181,7 @@
for (FieldDeclaration fieldDecl : declaredFields)
{
if (fieldDecl.getAnnotation(org.apache.beehive.controls.api.bean.Control.class) != null)
- fields.add(new AptControlField(this, fieldDecl, _env));
+ fields.add(new AptControlField(this, fieldDecl, _ap));
}
return fields;
}
@@ -209,7 +205,7 @@
for (FieldDeclaration fieldDecl : declaredFields)
{
if (fieldDecl.getAnnotation(Client.class) != null)
- clients.add(new AptClientField(this, fieldDecl, _env));
+ clients.add(new AptClientField(this, fieldDecl));
}
return clients;
}
@@ -304,7 +300,7 @@
InterfaceDeclaration intfDecl = intfType.getDeclaration();
if (intfDecl != null &&
intfDecl.getAnnotation(org.apache.beehive.controls.api.bean.ControlInterface.class) != null)
- return new AptControlInterface(intfDecl, _env);
+ return new AptControlInterface(intfDecl, _ap);
}
return null;
@@ -366,8 +362,8 @@
// of this processor (control impls). However, only emit an error message
// if the field isn't on a nested control
if ( getControlField(fieldName) == null )
- _env.getMessager().printError(implMethod.getPosition(),
- "Cannot find event source field: " + fieldName);
+ _ap.printError( implMethod, "eventhandler.field.not.found", fieldName );
+
continue;
}
@@ -382,9 +378,8 @@
AptControlInterface controlIntf = eventField.getControlInterface();
AptEventSet eventSet = controlIntf.getEventSet(setName);
if (eventSet == null)
- {
- _env.getMessager().printError(implMethod.getPosition(),
- "Cannot find EventSet interface: " + setName);
+ {
+ _ap.printError( implMethod, "eventhandler.eventset.not.found", setName );
continue;
}
@@ -404,7 +399,7 @@
//
boolean found = false;
String eventName = (String)handlerAnnot.getObjectValue("eventName");
- AptMethod handlerMethod = new AptMethod(implMethod, _env);
+ AptMethod handlerMethod = new AptMethod(implMethod, _ap);
for (AptEvent controlEvent : eventSet.getEvents())
{
if (controlEvent == null || controlEvent.getName() == null ||
@@ -422,16 +417,14 @@
controlEvent.getArgTypes().equals(handlerMethod.getArgTypes()))
{
adaptor.addHandler(controlEvent,
- new AptEventHandler(controlEvent, implMethod, _env));
+ new AptEventHandler(controlEvent, implMethod, _ap));
found = true;
break;
}
}
if (!found)
{
- _env.getMessager().printError(implMethod.getPosition(),
- "No event method with matching name and signature found on EventSet: " +
- setName);
+ _ap.printError( implMethod, "eventhandler.method.not.found", setName );
}
}
}
@@ -479,16 +472,14 @@
//
// Version requirement failed
//
- _env.getMessager().printError( _implDecl.getPosition(),
- "Control implementation " + _implDecl + " fails version support requirement: " +
- "highest supported interface version is " +
- majorSupported + "." + minorSupported + ", found interface version " +
- majorPresent + "." + minorPresent + "." );
+
+ _ap.printError( _implDecl, "versionsupported.failed", _implDecl.getSimpleName(), majorSupported, minorSupported,
+ majorPresent, minorPresent );
}
}
private ClassDeclaration _implDecl;
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
private AptControlImplementation _superClass;
private ArrayList<AptContextField> _contexts;
private ArrayList<AptClientField> _clients;
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java Thu Apr 28 15:57:57 2005
@@ -23,7 +23,6 @@
import java.net.*;
import java.util.*;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.Filer;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
@@ -46,6 +45,7 @@
import org.apache.beehive.controls.api.properties.PropertySet;
import org.apache.beehive.controls.api.versioning.Version;
import org.apache.beehive.controls.api.versioning.VersionRequired;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptControlInterface provides validation and metadata management for a ControlInterface
@@ -58,11 +58,11 @@
* Constructs a new AptControlInterface instance where interface information is derived
* from an APT interface declaration
* @param decl the annotated Declaration
- * @param env the APT environment
+ * @param ap the top-level annotation processor
*/
- public AptControlInterface(Declaration decl, AnnotationProcessorEnvironment env)
+ public AptControlInterface(Declaration decl, TwoPhaseAnnotationProcessor ap)
{
- _env = env;
+ _ap = ap;
//
// Verify that the @ControlInterface/@ControlExtension annotations are only used on an
@@ -76,8 +76,7 @@
(decl.getAnnotation(ControlExtension.class) != null ||
decl.getAnnotation(ControlInterface.class) != null))
{
- env.getMessager().printError(decl.getPosition(),
- "The ControlInterface or ControlExtension annotation may only be used on a Java interface");
+ _ap.printError(decl, "control.interface.annotation.badlocation" );
return;
}
@@ -167,9 +166,7 @@
// ControlExtension that wasn't actually extending a ControlInterface).
if ( isExtension() )
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "Interfaces annotated with ControlExtension must extend an interface " +
- " annotated with ControlInterface");
+ _ap.printError( _intfDecl, "control.extension.badinterface");
}
return null;
@@ -182,12 +179,11 @@
superDecl.getAnnotation(ControlInterface.class) != null)
{
_superDecl = superDecl;
- AptControlInterface superIntf = new AptControlInterface(_superDecl, _env);
+ AptControlInterface superIntf = new AptControlInterface(_superDecl, _ap);
if (!isExtension() && superIntf.isExtension())
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "An interface annotated with @ControlInterface can only extend another ControlInterface. It is not valid for a ControlInterface to extend a ControlExtension");
+ _ap.printError( _intfDecl, "control.interface.badinterface");
}
return superIntf;
}
@@ -240,7 +236,7 @@
// Add all declared methods, but ignore the mystery <clinit> methods
for (MethodDeclaration methodDecl : intfDecl.getMethods())
if (!methodDecl.toString().equals("<clinit>()"))
- operList.add(new AptOperation(this, methodDecl, _env));
+ operList.add(new AptOperation(this, methodDecl, _ap));
if ( intfDecl.getSuperinterfaces() == null )
continue;
@@ -291,10 +287,10 @@
//
TypeDeclaration basePropsDecl =
- _env.getTypeDeclaration( "org.apache.beehive.controls.api.properties.BaseProperties" );
+ _ap.getAnnotationProcessorEnvironment().getTypeDeclaration( "org.apache.beehive.controls.api.properties.BaseProperties" );
if ( basePropsDecl != null )
{
- propSets.add( new AptPropertySet( null, basePropsDecl, _env ) );
+ propSets.add( new AptPropertySet( null, basePropsDecl, _ap ) );
}
//
@@ -305,8 +301,7 @@
{
if (isExtension())
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "The @ExternalPropertySets annotation should only be used on an interface annotated with @ControlInterface, never @ControlExtension. An extension can only use existing properties, not declare new ones");
+ _ap.printError( _intfDecl, "extpropertyset.illegal.usage" );
}
try
@@ -318,16 +313,15 @@
Collection<String> extProps = mte.getQualifiedNames();
for ( String extPropName : extProps )
{
- TypeDeclaration extPropDecl = _env.getTypeDeclaration( extPropName );
+ TypeDeclaration extPropDecl = _ap.getAnnotationProcessorEnvironment().getTypeDeclaration( extPropName );
if ( extPropDecl != null )
{
- AptPropertySet extPropSet = new AptPropertySet( null, extPropDecl, _env );
+ AptPropertySet extPropSet = new AptPropertySet( null, extPropDecl, _ap );
propSets.add( extPropSet );
}
else
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "Unable to load type declaration for externally referenced PropertySet " + extPropName );
+ _ap.printError( _intfDecl, "extpropertyset.type.not.found", extPropName );
}
}
}
@@ -355,28 +349,26 @@
{
if (! (innerDecl instanceof AnnotationTypeDeclaration))
{
- _env.getMessager().printError(innerDecl.getPosition(),
- "The PropertySet annotation must be on an Annotation type");
+ _ap.printError( innerDecl, "propertyset.not.annotation.type" );
fError = true;
}
Retention ret = innerDecl.getAnnotation(Retention.class);
if (ret == null || ret.value() != RetentionPolicy.RUNTIME)
{
- _env.getMessager().printError(innerDecl.getPosition(),
- "The PropertySet annotation must be used in conjuction with @Retention(RetentionPolicy.RUNTIME)");
+ _ap.printError( innerDecl, "propertyset.missing.retention" );
fError = true;
}
if (isExtension())
{
- _env.getMessager().printError(innerDecl.getPosition(),
- "The @PropertySet annotation should only be used within an interface annotated with @ControlInterface, never @ControlExtension. An extension can only use existing properties, not declare new ones");
+ _ap.printError( innerDecl, "propertyset.illegal.usage.2" );
+ fError = true;
}
if ( !fError )
propSets.add(
- new AptPropertySet(this, (AnnotationTypeDeclaration)innerDecl, _env));
+ new AptPropertySet(this, (AnnotationTypeDeclaration)innerDecl, _ap));
}
}
@@ -401,9 +393,7 @@
if ( propertyNames.contains( propName ) )
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "Duplicate property name " + propName + " found on property set '" + propSet.getShortName() +
- "'. Consider using the PropertySet 'prefix' attribute to disambiguate.");
+ _ap.printError( _intfDecl, "propertyset.duplicate.property.names", propName, propSet.getShortName() );
}
else
{
@@ -517,13 +507,12 @@
if (! (innerDecl instanceof InterfaceDeclaration))
{
- _env.getMessager().printError(innerDecl.getPosition(),
- "The EventSet annotation must be on an interface declaration");
+ _ap.printError( innerDecl, "eventset.illegal.usage" );
}
else
{
eventSets.add(
- new AptEventSet(this, (InterfaceDeclaration)innerDecl, _env));
+ new AptEventSet(this, (InterfaceDeclaration)innerDecl, _ap));
}
}
}
@@ -699,7 +688,7 @@
*/
public ClassLoader getExternalClassLoader()
{
- Map<String,String> opts = _env.getOptions();
+ Map<String,String> opts = _ap.getAnnotationProcessorEnvironment().getOptions();
String classpath = opts.get("-classpath");
if ( classpath != null )
@@ -746,25 +735,21 @@
boolean isValid = true;
if (name.length() == 0)
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "@ManifestAttribute name cannot be a zero-length string");
+ _ap.printError( _intfDecl, "manifestattribute.illegal.name.1" );
isValid = false;
}
else
{
if (alphaNum.indexOf(name.charAt(0)) < 0)
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "@ManifestAttribute name must begin with an alphanumeric character");
+ _ap.printError( _intfDecl, "manifestattribute.illegal.name.2" );
isValid = false;
}
for (int i = 1; i < name.length(); i++)
{
if (headerChar.indexOf(name.charAt(i)) < 0)
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "@ManifestAttribute name contains an invalid character:" +
- name.charAt(i));
+ _ap.printError( _intfDecl, "manifestattribute.illegal.name.3", name.charAt(i) );
isValid = false;
break;
}
@@ -773,8 +758,7 @@
if (value.length() == 0)
{
- _env.getMessager().printError(_intfDecl.getPosition(),
- "@ManifestAttribute value cannot be a zero-length string");
+ _ap.printError( _intfDecl, "manifestattribute.illegal.name.4" );
isValid = false;
}
else
@@ -868,8 +852,7 @@
{
if ( !isExtension() )
{
- _env.getMessager().printError( _intfDecl.getPosition(),
- "Illegal usage of @VersionRequired: not permitted on interfaces annotated with @ControlInterface" );
+ _ap.printError( _intfDecl, "versionrequired.illegal.usage" );
return;
}
@@ -902,10 +885,8 @@
//
// Version requirement failed
//
- _env.getMessager().printError( _intfDecl.getPosition(),
- "Control extension " + _intfDecl + " fails version requirement: requires interface version " +
- majorRequired + "." + minorRequired + ", found interface version " +
- majorPresent + "." + minorPresent + "." );
+ _ap.printError( _intfDecl, "versionrequired.failed", _intfDecl.getSimpleName(),
+ majorRequired, minorRequired, majorPresent, minorPresent );
}
}
@@ -962,9 +943,7 @@
Class checkerClass = loader.loadClass( checkerName );
if ( !ControlChecker.class.isAssignableFrom(checkerClass) )
{
- _env.getMessager().printError( intfDecl.getPosition(),
- "Control interface " + intfDecl + " specifies a checker class " +
- checkerName + " that doesn't implement ControlChecker." );
+ _ap.printError( intfDecl, "control.interface.illegal.checker", intfDecl.getSimpleName(), checkerName );
}
else
{
@@ -972,7 +951,7 @@
Constructor ctor = checkerClass.getConstructor();
ControlChecker checker = (ControlChecker) ctor.newInstance();
- checker.check( _intfDecl, _env );
+ checker.check( _intfDecl, _ap.getAnnotationProcessorEnvironment() );
}
}
catch ( Exception e )
@@ -995,5 +974,5 @@
private VersionRequired _versionRequired;
private InterfaceDeclaration _intfDecl;
private InterfaceDeclaration _superDecl;
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEvent.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEvent.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEvent.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEvent.java Thu Apr 28 15:57:57 2005
@@ -17,14 +17,10 @@
* $Header:$
*/
-import java.util.ArrayList;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.type.VoidType;
-import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptEvent class represents a control Property where the event attributes
@@ -36,12 +32,10 @@
* Constructs a new AptEvent instance from APT metadata
* @param eventSet the declaring EventSet
* @param eventDecl the event annotation type element declaration
- * @param env the annotation processing environment
*/
- public AptEvent(AptEventSet eventSet, MethodDeclaration eventDecl,
- AnnotationProcessorEnvironment env)
+ public AptEvent(AptEventSet eventSet, MethodDeclaration eventDecl, TwoPhaseAnnotationProcessor ap)
{
- super(eventDecl, env);
+ super(eventDecl, ap);
_eventSet = eventSet;
_eventDecl = eventDecl;
@@ -52,8 +46,7 @@
//
if (!eventSet.isUnicast() && !(eventDecl.getReturnType() instanceof VoidType))
{
- env.getMessager().printError(eventDecl.getPosition(),
- "Event methods declared within a multicast EventSet cannot return a value. Change the return type of this method declaration to void, or use the unicast attribute of @EventSet to change to a unicast event set.");
+ ap.printError( eventDecl, "eventset.illegal.multicast" );
}
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventHandler.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventHandler.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventHandler.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventHandler.java Thu Apr 28 15:57:57 2005
@@ -17,13 +17,9 @@
* $Header:$
*/
-import java.util.ArrayList;
-import java.util.Map;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.MethodDeclaration;
-import org.apache.beehive.controls.runtime.generator.AptEvent;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptEventHandler class represents a control EventHandler where the event attributes
@@ -36,12 +32,10 @@
* from APT metadata
* @param event the handled ControlEvent
* @param handlerDecl the handler method declaration
- * @param env the annotation processing environment
*/
- public AptEventHandler(AptEvent event, MethodDeclaration handlerDecl,
- AnnotationProcessorEnvironment env)
+ public AptEventHandler(AptEvent event, MethodDeclaration handlerDecl, TwoPhaseAnnotationProcessor ap)
{
- super(handlerDecl, env);
+ super(handlerDecl, ap);
_event = event;
_handlerDecl = handlerDecl;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java Thu Apr 28 15:57:57 2005
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.HashSet;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.InterfaceDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
@@ -30,7 +29,6 @@
import org.apache.beehive.controls.api.events.EventSet;
import org.apache.beehive.controls.api.packaging.EventSetInfo;
-import org.apache.beehive.controls.api.packaging.FeatureInfo;
import org.apache.beehive.controls.runtime.generator.apt.*;
@@ -44,14 +42,14 @@
* Constructs a new AptEventSet instance from APT metadata
* @param controlIntf the declaring control interface
* @param eventSet the EventSet class
- * @param env the associated AnnotationProcessorEnvironment
+ * @param ap the associated AnnotationProcessor
*/
public AptEventSet(AptControlInterface controlIntf, InterfaceDeclaration eventSet,
- AnnotationProcessorEnvironment env)
+ TwoPhaseAnnotationProcessor ap)
{
_controlIntf = controlIntf;
_eventSet = eventSet;
- _env = env;
+ _ap = ap;
setDeclaration(eventSet);
EventSet eventSetAnnot = eventSet.getAnnotation(EventSet.class);
@@ -87,8 +85,8 @@
// Once this work, the 'break' below can also be removed to present errors
// for multiple invalid parameters
//
- env.getMessager().printError(eventSet.getPosition(),
- "Any EventSet formal type parameters must match ones declared on the associated control type. No new formal type parameters may be introduced.");
+
+ _ap.printError( eventSet, "eventset.formal.parameter.mismatch" );
break;
}
}
@@ -171,7 +169,7 @@
// Add all declared methods, but ignore the mystery <clinit> methods
for (MethodDeclaration methodDecl : intfDecl.getMethods())
if (!methodDecl.toString().equals("<clinit>()"))
- events.add(new AptEvent(this, methodDecl, _env));
+ events.add(new AptEvent(this, methodDecl, _ap));
//
// Add all superinterfaces of the target interface to the list
@@ -320,7 +318,7 @@
return _eventSet;
}
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
private InterfaceDeclaration _eventSet;
private AptEventSet _superEventSet;
private AptControlInterface _controlIntf;
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethod.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethod.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethod.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptMethod.java Thu Apr 28 15:57:57 2005
@@ -19,20 +19,14 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.ParameterDeclaration;
import com.sun.mirror.declaration.TypeParameterDeclaration;
import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ClassType;
import com.sun.mirror.type.DeclaredType;
import com.sun.mirror.type.PrimitiveType;
import com.sun.mirror.type.ReferenceType;
@@ -40,6 +34,7 @@
import com.sun.mirror.type.WildcardType;
import org.apache.beehive.controls.api.packaging.FeatureInfo;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
@@ -82,11 +77,11 @@
/**
* Constructs a new AptMethod instance associated with a specific method declaration
*/
- public AptMethod(MethodDeclaration methodDecl, AnnotationProcessorEnvironment env)
+ public AptMethod(MethodDeclaration methodDecl, TwoPhaseAnnotationProcessor ap )
{
_methodDecl = methodDecl;
- _env = env;
_interceptorServiceNames = initInterceptorServiceNames();
+ _ap = ap;
}
/**
@@ -208,7 +203,7 @@
// Use the erasure here, because we only want the raw type, not the reference
// type
//
- sb.append(_env.getTypeUtils().getErasure(paramType));
+ sb.append(_ap.getAnnotationProcessorEnvironment().getTypeUtils().getErasure(paramType));
sb.append(".class");
}
return sb.toString();
@@ -367,7 +362,7 @@
MethodDeclaration _methodDecl;
int _index = -1;
- AnnotationProcessorEnvironment _env;
+ TwoPhaseAnnotationProcessor _ap;
/**
* Returns the names of interceptor service interfaces associated with this operation
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptOperation.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptOperation.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptOperation.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptOperation.java Thu Apr 28 15:57:57 2005
@@ -17,13 +17,8 @@
* $Header:$
*/
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.DeclaredType;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptOperation class represents a control operation where the operation attributes
@@ -37,13 +32,11 @@
* @param controlIntf the declaring ControlInterface
* @param methodDecl the method associated with the operation
*/
- public AptOperation(AptControlInterface controlIntf, MethodDeclaration methodDecl,
- AnnotationProcessorEnvironment env)
+ public AptOperation(AptControlInterface controlIntf, MethodDeclaration methodDecl, TwoPhaseAnnotationProcessor ap)
{
- super(methodDecl, env);
+ super(methodDecl, ap);
_controlIntf = controlIntf;
_operDecl = methodDecl;
-
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptProperty.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptProperty.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptProperty.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptProperty.java Thu Apr 28 15:57:57 2005
@@ -19,7 +19,6 @@
import java.util.Collection;
import java.util.Map;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationValue;
@@ -28,6 +27,7 @@
import org.apache.beehive.controls.api.packaging.FeatureInfo;
import org.apache.beehive.controls.api.packaging.PropertyInfo;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptProperty class represents a control Property where the property attributes
@@ -42,11 +42,11 @@
* @param propDecl the declration of the property annotation type element
*/
public AptProperty(AptPropertySet propertySet, AnnotationTypeElementDeclaration propDecl,
- AnnotationProcessorEnvironment env)
+ TwoPhaseAnnotationProcessor ap)
{
_propertySet = propertySet;
_propDecl = propDecl;
- _env = env;
+ _ap = ap;
//
// Primitive properties must specify a default value, to provide consistent semantics
@@ -57,8 +57,7 @@
if (propDecl.getReturnType() instanceof PrimitiveType &&
propDecl.getDefaultValue() == null)
{
- env.getMessager().printError(propDecl.getPosition(),
- "Primitive property " + propDecl.getSimpleName() + " must specify a default value");
+ _ap.printError( propDecl, "property.primitive.without.default", propDecl.getSimpleName() );
}
}
@@ -239,5 +238,5 @@
AnnotationTypeElementDeclaration _propDecl;
private AptPropertySet _propertySet;
- AnnotationProcessorEnvironment _env;
+ TwoPhaseAnnotationProcessor _ap;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptPropertySet.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptPropertySet.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptPropertySet.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptPropertySet.java Thu Apr 28 15:57:57 2005
@@ -17,18 +17,16 @@
* $Header:$
*/
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.Declaration;
import org.apache.beehive.controls.api.properties.PropertySet;
+import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
/**
* The AptPropertySet class represents a control PropertySet where the property list
@@ -40,17 +38,17 @@
* Constructs a new AptPropertySet instance from APT metadata
* @param controlIntf the declaring bean interface. May be null (external property set)
* @param propertySet the PropertySet declaration
- * @param env the AnnotationProcessorEnvironment
+ * @param ap the annotation processor
*/
public AptPropertySet(AptControlInterface controlIntf, Declaration propertySet,
- AnnotationProcessorEnvironment env)
+ TwoPhaseAnnotationProcessor ap)
{
+ _ap = ap;
_controlIntf = controlIntf;
if (!(propertySet instanceof AnnotationTypeDeclaration))
{
- env.getMessager().printError(propertySet.getPosition(),
- "The PropertySet annotation may only be used on a Java annotation interface");
+ _ap.printError( propertySet, "propertyset.illegal.usage" );
return;
}
_propertySet = (AnnotationTypeDeclaration)propertySet;
@@ -58,7 +56,6 @@
_isOptional = _propertySet.getAnnotation(PropertySet.class).optional();
_hasSetters = _propertySet.getAnnotation(PropertySet.class).hasSetters();
- _env = env;
_properties = initProperties();
}
@@ -76,7 +73,7 @@
for (MethodDeclaration methodDecl : _propertySet.getMethods())
if (!methodDecl.toString().equals("<clinit>()"))
properties.add(
- new AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_env));
+ new AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_ap));
return properties;
}
@@ -149,7 +146,7 @@
private AnnotationTypeDeclaration _propertySet;
private AptControlInterface _controlIntf; // may be null if an external property set
private ArrayList<AptProperty> _properties;
- private AnnotationProcessorEnvironment _env;
+ private TwoPhaseAnnotationProcessor _ap;
private boolean _isOptional;
private boolean _hasSetters;
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlAnnotationProcessor.java Thu Apr 28 15:57:57 2005
@@ -19,16 +19,10 @@
*/
import java.io.IOException;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.Declaration;
@@ -55,11 +49,11 @@
Generator genClass = null;
if (decl.getAnnotation(ControlInterface.class) != null)
{
- genClass = new AptControlInterface(decl, env);
+ genClass = new AptControlInterface(decl, this);
}
else if (decl.getAnnotation(ControlExtension.class) != null)
{
- genClass = new AptControlInterface(decl, env);
+ genClass = new AptControlInterface(decl, this);
// When a control extension is declared, values may be assigned to
// the properties of the parent controls. The property constraint
@@ -77,14 +71,14 @@
}
else if (decl.getAnnotation(ControlImplementation.class) != null)
{
- genClass = new AptControlImplementation(decl, env);
+ genClass = new AptControlImplementation(decl, this);
}
else if (decl.getAnnotation(PropertySet.class) != null)
{
- new AptPropertySet(null, decl, env);
+ new AptPropertySet(null, decl, this);
}
- if ( genClass != null )
+ if ( genClass != null && !hasErrors() )
{
try
{
@@ -111,15 +105,15 @@
Generator genClass = null;
if (decl.getAnnotation(ControlInterface.class) != null)
{
- genClass = new AptControlInterface(decl, env);
+ genClass = new AptControlInterface(decl, this);
}
if (decl.getAnnotation(ControlExtension.class) != null)
{
- genClass = new AptControlInterface(decl, env);
+ genClass = new AptControlInterface(decl, this);
}
else if (decl.getAnnotation(ControlImplementation.class) != null)
{
- genClass = new AptControlImplementation(decl, env);
+ genClass = new AptControlImplementation(decl, this);
}
if ( genClass != null )
@@ -154,7 +148,6 @@
// Locate the class that wraps the Velocity code generation process
//
AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
- String generatorName = null;
try
{
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java Thu Apr 28 15:57:57 2005
@@ -25,12 +25,11 @@
import com.sun.mirror.declaration.*;
import com.sun.mirror.apt.*;
import com.sun.mirror.type.*;
-import com.sun.tools.corba.se.idl.InvalidArgument;
import java.util.*;
-import org.apache.beehive.controls.runtime.generator.*;
import org.apache.beehive.controls.runtime.bean.ControlBeanContext;
+import org.apache.beehive.controls.runtime.generator.*;
import org.apache.beehive.controls.api.bean.*;
import org.apache.beehive.controls.api.versioning.Version;
import org.apache.beehive.controls.api.versioning.VersionRequired;
@@ -38,7 +37,6 @@
import java.util.Set;
import java.io.File;
import java.io.IOException;
-import java.lang.annotation.Annotation;
public class ControlClientAnnotationProcessor extends TwoPhaseAnnotationProcessor
{
@@ -199,7 +197,7 @@
// Emit initializer
AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
- Generator genClass = new AptControlClient( clientType, env );
+ Generator genClass = new AptControlClient( clientType, this );
if ( genClass != null )
{
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/Diagnostics.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/Diagnostics.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/Diagnostics.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/Diagnostics.java Thu Apr 28 15:57:57 2005
@@ -70,7 +70,12 @@
{
_env.getMessager().printWarning( annVal.getPosition(), getResourceString( messageKey, args ) );
}
-
+
+ public AnnotationProcessorEnvironment getAnnotationProcessorEnvironment()
+ {
+ return _env;
+ }
+
protected abstract String getResourceString( String key, Object ... args );
public boolean hasErrors()
@@ -81,10 +86,5 @@
protected void setHasErrors( boolean hadErrors )
{
_hasErrors = hadErrors;
- }
-
- protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment()
- {
- return _env;
}
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java Thu Apr 28 15:57:57 2005
@@ -154,7 +154,7 @@
* Report an error detected during the "check" phase. The presence of errors
* will suppress execution of the "generate" phase.
*/
- protected void printError( Declaration d, String id, Object... args )
+ public void printError( Declaration d, String id, Object... args )
{
addError( d, id, args );
}
@@ -163,7 +163,7 @@
* Report a warning detected during the "check" phase. The presence of warnings
* will not affect execution of the "generate" phase.
*/
- protected void printWarning( Declaration d, String id, Object... args )
+ public void printWarning( Declaration d, String id, Object... args )
{
addWarning( d, id, args );
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties?rev=165221&r1=165220&r2=165221&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/strings.properties Thu Apr 28 15:57:57 2005
@@ -53,3 +53,127 @@
Types listed in @ControlReferences must be control interfaces (ie, interfaces annotated with @ControlInterface or @ControlExtension). \
Verify the types listed in @ControlReferences are control interface types.
+control.interface.annotation.badlocation=\
+The ControlInterface or ControlExtension annotation may only be used on a Java interface.
+
+control.extension.badinterface=\
+Interfaces annotated with ControlExtension must extend an interface annotated with ControlInterface.
+
+control.interface.badinterface=\
+An interface annotated with @ControlInterface can only extend another ControlInterface. It is not valid for \
+a ControlInterface to extend a ControlExtension.
+
+property.primitive.without.default=\
+Primitive property {0} must specify a default value.
+
+propertyset.illegal.usage=\
+The PropertySet annotation may only be used on a Java annotation interface.
+
+propertyset.illegal.usage.2=\
+The @PropertySet annotation should only be used within an interface annotated with @ControlInterface, \
+never @ControlExtension. An extension can only use existing properties, not declare new ones.
+
+extpropertyset.illegal.usage=\
+The @ExternalPropertySets annotation should only be used on an interface annotated with \
+@ControlInterface, never @ControlExtension. An extension can only use existing properties, not declare new one.
+
+extpropertyset.type.not.found=\
+Unable to load type declaration for externally referenced PropertySet {0}.
+
+propertyset.not.annotation.type=\
+The PropertySet annotation must be on an Annotation type.
+
+propertyset.missing.retention=\
+The PropertySet annotation must be used in conjuction with @Retention(RetentionPolicy.RUNTIME).
+
+propertyset.duplicate.property.names=\
+Duplicate property name {0} found on property set '{1}'. Consider using the PropertySet 'prefix' \
+attribute to disambiguate.
+
+eventset.illegal.usage=\
+The EventSet annotation must be on an interface declaration.
+
+eventset.formal.parameter.mismatch=\
+Any EventSet formal type parameters must match ones declared on the associated control type. \
+No new formal type parameters may be introduced.
+
+eventset.illegal.multicast=\
+Event methods declared within a multicast EventSet cannot return a value. Change the return \
+type of this method declaration to void, or use the unicast attribute of @EventSet to change to a unicast event set.
+
+manifestattribute.illegal.name.1=\
+@ManifestAttribute name cannot be a zero-length string.
+
+manifestattribute.illegal.name.2=\
+@ManifestAttribute name must begin with an alphanumeric character.
+
+manifestattribute.illegal.name.3=\
+@ManifestAttribute name contains an invalid character: {0}.
+
+manifestattribute.illegal.name.4=\
+@ManifestAttribute value cannot be a zero-length string.
+
+versionrequired.illegal.usage=\
+Illegal usage of @VersionRequired: not permitted on interfaces annotated with @ControlInterface.
+
+versionrequired.failed=\
+Control extension {0} fails version requirement: requires interface version {1}.{2}, found interface \
+version {3}.{4}.
+
+control.interface.illegal.checker=\
+Control interface {0} specifies a checker class {1} that doesn't implement ControlChecker.
+
+control.implementation.badclass=\
+The ControlImplementation annotation may only be used on a Java class.
+
+control.implementation.unserializable=\
+A ControlImplementation class must implement the java.io.Serializable interface or set the isTransient \
+attribute of @ControlImplementation to true.
+
+control.implementation.missing.interface=\
+Control implementations must implement a control interface.
+
+eventhandler.field.not.found=\
+Cannot find event source field: {0}.
+
+eventhandler.eventset.not.found=\
+Cannot find EventSet interface: {0}.
+
+eventhandler.method.not.found=\
+No event method with matching name and signature found on EventSet: {0}.
+
+eventhandler.throws.mismatch=\
+Handler method {0} 'throws' clause is not a proper subset of the eventset method's 'throws' claus. \
+Handlers may only throw throwables declared by the eventset method.
+
+versionsupported.failed=\
+Control implementation {0} fails version support requirement: highest supported interface version is \
+{1}.{2}, found interface version {3}.{4}.
+
+control.illegal.usage=\
+The Control annotation may only be used in a Java class.
+
+context.field.badinterface=\
+@Context field type must be an interface.
+
+control.field.bad.type=\
+@Control field type must be a valid ControlBean class or control interface.
+
+control.field.bad.type.2=\
+Unable to identify control type of field.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+