You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/04/30 04:02:09 UTC
svn commit: r165371 -
/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
Author: rich
Date: Fri Apr 29 19:02:08 2005
New Revision: 165371
URL: http://svn.apache.org/viewcvs?rev=165371&view=rev
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-589 : Control fields cannot be inherited in page flows
This change causes control client initializers to be generated for any class that can *inherit* an annotated control field. It fixes the InheritControls BVT in netui.
tests: drt in trunk, bvt in netui (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
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=165371&r1=165370&r2=165371&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 Fri Apr 29 19:02:08 2005
@@ -73,6 +73,20 @@
}
}
+ private static void addControlType(Map<TypeDeclaration,Set<TypeMirror>> clientsMap, TypeDeclaration clientType,
+ TypeMirror controlFieldType)
+ {
+ Set<TypeMirror> controlTypes = clientsMap.get( clientType );
+
+ if ( controlTypes == null )
+ {
+ controlTypes = new HashSet<TypeMirror>();
+ clientsMap.put( clientType, controlTypes );
+ }
+
+ controlTypes.add( controlFieldType );
+ }
+
/**
* Each control client requires a manifest that documents the controls that it references.
*
@@ -92,21 +106,43 @@
{
if (atd.getSimpleName().equals("Control") )
{
- Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
+ AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
+ Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd);
for (Declaration decl : decls)
{
if ( decl instanceof FieldDeclaration )
{
FieldDeclaration fd = (FieldDeclaration)decl;
TypeDeclaration clientType = fd.getDeclaringType();
- Set<TypeMirror> controlTypes = clientsMap.get( clientType );
- if ( controlTypes == null )
+ TypeMirror controlFieldType = fd.getType();
+ addControlType( clientsMap, clientType, controlFieldType );
+
+ //
+ // If this field is public or protected, add the control type to any derived class.
+ //
+ Collection<Modifier> modifiers = fd.getModifiers();
+ if ( modifiers.contains( Modifier.PUBLIC ) || modifiers.contains( Modifier.PROTECTED ) )
{
- controlTypes = new HashSet<TypeMirror>();
- clientsMap.put( clientType, controlTypes );
+ Collection<TypeDeclaration> specifiedTypeDeclartions = env.getSpecifiedTypeDeclarations();
+ for (TypeDeclaration td : specifiedTypeDeclartions)
+ {
+ if ( td instanceof ClassDeclaration )
+ {
+ ClassType superclass = ( ( ClassDeclaration ) td ).getSuperclass();
+
+ while ( superclass != null )
+ {
+ if ( superclass.getDeclaration().equals( clientType ) )
+ {
+ addControlType( clientsMap, td, controlFieldType );
+ break;
+ }
+
+ superclass = superclass.getSuperclass();
+ }
+ }
+ }
}
-
- controlTypes.add( fd.getType() );
}
}
}