1 18 package org.apache.beehive.netui.compiler.grammar; 19 20 import org.apache.beehive.netui.compiler.AnnotationMemberType; 21 import org.apache.beehive.netui.compiler.CompilerUtils; 22 import org.apache.beehive.netui.compiler.Diagnostics; 23 import org.apache.beehive.netui.compiler.FlowControllerInfo; 24 import org.apache.beehive.netui.compiler.RuntimeVersionChecker; 25 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 26 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; 27 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; 28 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; 29 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; 30 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 31 32 33 public class RaiseActionGrammar 34 extends BaseFlowControllerGrammar 35 { 36 private static final String [][] REQUIRED_ATTRS = { { ACTION_ATTR } }; 37 38 public RaiseActionGrammar( AnnotationProcessorEnvironment env, Diagnostics diags, String requiredRuntimeVersion, 39 RuntimeVersionChecker runtimeVersionChecker, ClassDeclaration jpfClass, 40 FlowControllerInfo fcInfo ) 41 { 42 super( env, diags, requiredRuntimeVersion, runtimeVersionChecker, fcInfo ); 43 addMemberType( ACTION_ATTR, new PageFlowActionType( jpfClass ) ); 44 addMemberType( OUTPUT_FORM_BEAN_ATTR, new MemberFieldType( null , null, this ) ); 45 } 46 47 private class PageFlowActionType 48 extends AnnotationMemberType 49 { 50 private ClassDeclaration _jpfClass; 51 52 public PageFlowActionType( ClassDeclaration jpfClass ) 53 { 54 super( RaiseActionGrammar.this.getRequiredRuntimeVersion(), RaiseActionGrammar.this ); 55 _jpfClass = jpfClass; 56 } 57 58 59 public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member, 60 AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, 61 int annotationArrayIndex ) 62 { 63 String action = ( String ) member.getValue(); 64 65 if ( _jpfClass != null 66 && ! WebappPathOrActionType.actionExists( action, _jpfClass, null, getEnv(), getFlowControllerInfo(), true ) ) 67 { 68 getDiagnostics().addWarning( member, "warning.no-such-action", action, 69 CompilerUtils.getSourceFile( _jpfClass, true ) ); 70 } 71 72 return null; 73 } 74 } 75 76 public String [][] getRequiredAttrs() 77 { 78 return REQUIRED_ATTRS; 79 } 80 } 81 | Popular Tags |