Author: rich
Date: Sat Feb 19 23:37:20 2005
New Revision: 154484
URL: http://svn.apache.org/viewcvs?view=rev&rev=154484
Log:
Fix for http://issues.apache.org/jira/browse/BEEHIVE-252 : Forward with a
returnAction set still required for an nested pageflow to compile even it
presents in its parent class
Also, fixed to avoid trying to generate Struts config files for page flows
whose base classes contain errors.
DRT/BVT: netui (WinXP)
BB: self (linux)
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/Diagnostics.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/apt/BaseAnnotationProcessor.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/CompilerUtils.java
Sat Feb 19 23:37:20 2005
@@ -180,6 +180,7 @@
public static DeclaredType getDeclaredType( AnnotationMirror annotation,
String memberName, boolean defaultIsNull )
{
AnnotationValue value = getAnnotationValue( annotation, memberName,
defaultIsNull );
+ assert value == null || value.getValue() instanceof DeclaredType :
value.getValue().getClass().getName();
return value != null ? ( DeclaredType ) value.getValue() : null;
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/Diagnostics.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/Diagnostics.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/Diagnostics.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/Diagnostics.java
Sat Feb 19 23:37:20 2005
@@ -86,4 +86,9 @@
{
return _hadErrors;
}
+
+ protected void setHadErrors( boolean hadErrors )
+ {
+ _hadErrors = hadErrors;
+ }
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/FlowControllerInfo.java
Sat Feb 19 23:37:20 2005
@@ -20,6 +20,7 @@
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.type.TypeMirror;
import com.sun.mirror.type.DeclaredType;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
@@ -193,11 +194,7 @@
public void addReturnAction( String returnActionName, String formBeanType )
{
- if ( _returnActions == null )
- {
- _returnActions = new HashSet();
- }
-
+ if ( _returnActions == null ) _returnActions = new HashSet();
_returnActions.add( new ActionInfo( returnActionName, formBeanType ) );
}
@@ -345,5 +342,32 @@
public boolean isNavigateToPageEnabled()
{
return _navigateToPageEnabled;
+ }
+
+ /**
+ * Add a return-action from an annotation.
+ * @return the form bean type, or <code>null</code> if there is no form
bean.
+ */
+ public TypeMirror addReturnAction( String returnActionName,
AnnotationMirror annotation, TypeDeclaration outerType )
+ {
+ TypeMirror formBeanType = CompilerUtils.getTypeMirror( annotation,
OUTPUT_FORM_BEAN_TYPE_ATTR, true );
+
+ if ( formBeanType == null )
+ {
+ String memberFieldName = CompilerUtils.getString( annotation,
OUTPUT_FORM_BEAN_ATTR, true );
+
+ if ( memberFieldName != null )
+ {
+ FieldDeclaration field = CompilerUtils.findField( outerType,
memberFieldName );
+ if ( field != null ) formBeanType = field.getType();
+ }
+ }
+
+ String formTypeName =
+ formBeanType != null && formBeanType instanceof DeclaredType
+ ? CompilerUtils.getDeclaration( ( DeclaredType ) formBeanType
).getQualifiedName()
+ : null;
+ addReturnAction( returnActionName, formTypeName );
+ return formBeanType;
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/PageFlowChecker.java
Sat Feb 19 23:37:20 2005
@@ -155,25 +155,47 @@
// Make sure every .jpf has a begin action if the class isn't abstract.
//
boolean isAbstract = CompilerUtils.hasModifier( jpfClass,
Modifier.ABSTRACT );
+ FlowControllerInfo fcInfo = getFlowControllerInfo();
- if ( ! WebappPathOrActionType.actionExists( BEGIN_ACTION_NAME,
jpfClass, null, getEnv(), getFlowControllerInfo(), true )
+ if ( ! WebappPathOrActionType.actionExists( BEGIN_ACTION_NAME,
jpfClass, null, getEnv(), fcInfo, true )
&& ! isAbstract )
{
getDiagnostics().addError( jpfClass, "error.no-begin-action" );
}
//
- // Make sure every nested pageflow has a returnAction.
+ // Make sure every nested pageflow has a returnAction. Return actions
are added by ForwardGrammar, but
+ // here we also need to add them for inherited Forwards and
SimpleActions.
//
- if ( getFlowControllerInfo().isNested() )
+ if ( fcInfo.isNested() )
{
- if ( ! isAbstract && getFlowControllerInfo().countReturnActions()
== 0 )
+ MergedControllerAnnotation mca =
fcInfo.getMergedControllerAnnotation();
+ addReturnActions( mca.getSimpleActions(), fcInfo, jpfClass,
CONDITIONAL_FORWARDS_ATTR );
+ addReturnActions( mca.getForwards(), fcInfo, jpfClass, null );
+
+ if ( ! isAbstract && fcInfo.countReturnActions() == 0 )
{
getDiagnostics().addError( jpfClass, "error.no-return-action",
ANNOTATION_INTERFACE_PREFIX +
FORWARD_TAG_NAME,
RETURN_ACTION_ATTR );
}
}
+ }
+
+ private void addReturnActions( Collection< AnnotationMirror >
forwardAnnotations, FlowControllerInfo fcInfo,
+ TypeDeclaration outerType, String
childArrayAttr )
+ {
+ for ( AnnotationMirror ann : forwardAnnotations )
+ {
+ String returnAction = CompilerUtils.getString( ann,
RETURN_ACTION_ATTR, true );
+ if ( returnAction != null ) fcInfo.addReturnAction( returnAction,
ann, outerType );
+
+ if ( childArrayAttr != null )
+ {
+ Collection< AnnotationMirror > children =
CompilerUtils.getAnnotationArray( ann, childArrayAttr, true );
+ if ( children != null ) addReturnActions( children, fcInfo,
outerType, null );
+ }
+ }
}
protected String getDesiredBaseClass( ClassDeclaration jclass )
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/apt/BaseAnnotationProcessor.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/apt/BaseAnnotationProcessor.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/apt/BaseAnnotationProcessor.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/apt/BaseAnnotationProcessor.java
Sat Feb 19 23:37:20 2005
@@ -22,11 +22,15 @@
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationValue;
import com.sun.mirror.util.SimpleDeclarationVisitor;
import com.sun.mirror.type.ClassType;
import org.apache.beehive.netui.compiler.Diagnostics;
import org.apache.beehive.netui.compiler.BaseChecker;
import org.apache.beehive.netui.compiler.BaseGenerator;
+import org.apache.beehive.netui.compiler.CompilerUtils;
import java.util.Collection;
@@ -64,7 +68,24 @@
if ( checker != null )
{
checker.check( classDecl );
- if ( ! diagnostics.hadErrors() )
+
+ //
+ // Also do a silent check on all base classes. We don't
want to generate if there were errors
+ // in the base class.
+ //
+ SilentDiagnostics silentDiagnostics = new
SilentDiagnostics();
+ for ( ClassType i = classDecl.getSuperclass(); i != null;
i = i.getSuperclass() )
+ {
+ ClassDeclaration baseDecl = i.getDeclaration();
+
+ if ( CompilerUtils.getSourceFile( baseDecl, false ) !=
null )
+ {
+ BaseChecker silentChecker = getChecker( baseDecl,
silentDiagnostics );
+ if ( silentChecker != null ) silentChecker.check(
baseDecl );
+ }
+ }
+
+ if ( ! diagnostics.hadErrors() && !
silentDiagnostics.hadErrors() )
{
BaseGenerator generator = checker.getGenerator();
if ( generator != null ) generator.generate( classDecl
);
@@ -74,6 +95,46 @@
}
}
+ private static class SilentDiagnostics extends Diagnostics
+ {
+ public SilentDiagnostics()
+ {
+ super( null );
+ }
+
+ public void addError( Declaration decl, String messageKey, Object...
args )
+ {
+ setHadErrors( true );
+ }
+
+ public void addError( AnnotationMirror ann, String messageKey,
Object... args )
+ {
+ setHadErrors( true );
+ }
+
+ public void addErrorArrayArgs( AnnotationMirror ann, String
messageKey, Object[] args )
+ {
+ setHadErrors( true );
+ }
+
+ public void addError( AnnotationValue annVal, String messageKey,
Object... args )
+ {
+ setHadErrors( true );
+ }
+
+ public void addWarning( Declaration decl, String messageKey, Object...
args )
+ {
+ }
+
+ public void addWarning( AnnotationMirror ann, String messageKey,
Object... args )
+ {
+ }
+
+ public void addWarning( AnnotationValue annVal, String messageKey,
Object... args )
+ {
+ }
+ }
+
protected abstract BaseChecker getChecker( ClassDeclaration decl,
Diagnostics diagnostics );
protected AnnotationProcessorEnvironment getEnv()
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/diagnostics.properties
Sat Feb 19 23:37:20 2005
@@ -30,7 +30,7 @@
error.only-valid-in-nested = Attribute "{0}" is only valid in a nested
PageFlowController.
error.action-method-wrong-arg = Expected a single argument.
error.action-form-bean-no-default-constructor = Argument type {0} has no
default constructor defined.
-error.action-invalid-form-bean-type = This type is not valid as the form bean
for an action.
+error.action-invalid-form-bean-type = Type {0} is not valid as the form bean
for an action.
error.action-form-bean-not-public = Argument type {0} is not public.
error.action-form-bean-not-static = Argument type {0} is a non-static inner
class.
error.method-wrong-return-type = Expected a return type of {0}.
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java
Sat Feb 19 23:37:20 2005
@@ -76,7 +76,7 @@
{
if ( argType != null )
{
- getDiagnostics().addError( annotation,
"error.action-invalid-form-bean-type" );
+ getDiagnostics().addError( annotation,
"error.action-invalid-form-bean-type", argType.toString() );
argType = null;
}
}
Modified:
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java?view=diff&r1=154483&r2=154484
==============================================================================
---
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
(original)
+++
incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/grammar/ForwardGrammar.java
Sat Feb 19 23:37:20 2005
@@ -27,7 +27,6 @@
import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationValue;
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.type.TypeMirror;
@@ -147,43 +146,18 @@
}
//
- // If this is a return-action, store its info in the
FlowControllerInfo (which is eventually provided to tools.
+ // If this is a return-action, store its info in the
FlowControllerInfo (which is eventually provided to tools).
//
if ( isReturnAction )
{
- DeclaredType formBeanType = CompilerUtils.getDeclaredType(
annotation, OUTPUT_FORM_BEAN_TYPE_ATTR, true );
+ TypeDeclaration outerType = CompilerUtils.getOuterClass(
classMember );
+ TypeMirror formBeanType =
+ getFlowControllerInfo().addReturnAction( ( String )
value.getValue(), annotation, outerType );
- if ( formBeanType == null )
+ if ( formBeanType != null && ! ( formBeanType instanceof
DeclaredType ) )
{
- String memberFieldName = CompilerUtils.getString( annotation,
OUTPUT_FORM_BEAN_ATTR, true );
-
- if ( memberFieldName != null )
- {
- FieldDeclaration field =
- CompilerUtils.findField(
CompilerUtils.getOuterClass( classMember ), memberFieldName );
-
- if ( field != null )
- {
- TypeMirror fieldType = field.getType();
-
- if ( ! ( fieldType instanceof DeclaredType ) )
- {
- addError( annotation,
"error.invalid-form-member-type", field.getSimpleName() );
- }
- else
- {
- formBeanType = ( DeclaredType ) fieldType;
- }
- }
- }
+ addError( annotation, "error.action-invalid-form-bean-type",
formBeanType.toString() );
}
-
- String actionName = ( String ) value.getValue();
- String formTypeName =
- formBeanType != null
- ? CompilerUtils.getDeclaration( formBeanType
).getQualifiedName()
- : null;
- getFlowControllerInfo().addReturnAction( actionName, formTypeName
);
}
}