1 18 package org.apache.beehive.netui.compiler.grammar; 19 20 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 22 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; 23 import org.apache.beehive.netui.compiler.RuntimeVersionChecker; 24 import org.apache.beehive.netui.compiler.AnnotationMemberType; 25 import org.apache.beehive.netui.compiler.Diagnostics; 26 import org.apache.beehive.netui.compiler.CompilerUtils; 27 import org.apache.beehive.netui.compiler.FatalCompileTimeException; 28 29 30 public class ValidatablePropertyGrammar 31 extends ValidationRulesContainerGrammar 32 { 33 private static String [][] REQUIRED_ATTRS = { { PROPERTY_NAME_ATTR } }; 34 private static String [][] MUTUALLY_EXCLUSIVE_ATTRS = { { DISPLAY_NAME_ATTR, DISPLAY_NAME_KEY_ATTR } }; 35 36 37 public ValidatablePropertyGrammar( AnnotationProcessorEnvironment env, Diagnostics diags, RuntimeVersionChecker rvc ) 38 { 39 super( env, diags, rvc ); 40 41 addMemberType( PROPERTY_NAME_ATTR, new AnnotationMemberType( null, this ) ); 42 addMemberType( DISPLAY_NAME_ATTR, new AnnotationMemberType( null, this ) ); 43 addMemberType( DISPLAY_NAME_KEY_ATTR, new AnnotationMemberType( null, this ) ); 44 addMemberArrayGrammar( LOCALE_RULES_ATTR, new LocaleRulesGrammar( env, diags, rvc ) ); 45 } 46 47 51 public String [][] getRequiredAttrs() 52 { 53 return REQUIRED_ATTRS; 54 } 55 56 public String [][] getMutuallyExclusiveAttrs() 57 { 58 return MUTUALLY_EXCLUSIVE_ATTRS; 59 } 60 61 protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, 62 MemberDeclaration classMember ) 63 throws FatalCompileTimeException 64 { 65 if ( parentAnnotations == null ) return true; 66 67 for ( int i = parentAnnotations.length - 1; i >= 0; --i ) 72 { 73 AnnotationInstance ann = parentAnnotations[i]; 74 75 if ( CompilerUtils.isJpfAnnotation( ann, ACTION_TAG_NAME ) 76 || CompilerUtils.isJpfAnnotation( ann, SIMPLE_ACTION_TAG_NAME ) ) 77 { 78 if ( CompilerUtils.getAnnotationValue( ann, VALIDATION_ERROR_FORWARD_ATTR, true ) == null ) 82 { 83 Boolean doValidation = CompilerUtils.getBoolean( ann, DO_VALIDATION_ATTR, true ); 84 85 if ( doValidation == null || doValidation.booleanValue() ) 86 { 87 addWarning( annotation, "warning.validation-annotations-no-forward", 88 ANNOTATION_INTERFACE_PREFIX + ann.getAnnotationType().getDeclaration().getSimpleName(), 89 VALIDATION_ERROR_FORWARD_ATTR ); 90 } 91 } 92 } 93 } 94 95 return true; 96 } 97 } 98 | Popular Tags |