1 18 package org.apache.beehive.netui.compiler.grammar; 19 20 import org.apache.beehive.netui.compiler.AnnotationGrammar; 21 import org.apache.beehive.netui.compiler.CompilerUtils; 22 import org.apache.beehive.netui.compiler.Diagnostics; 23 import org.apache.beehive.netui.compiler.RuntimeVersionChecker; 24 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 25 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 26 import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; 27 28 import java.util.Map ; 29 30 31 public class ValidationMessageArgsGrammar 32 extends AnnotationGrammar 33 { 34 private static final String [][] MUTUALLY_EXCLUSIVE_ATTRS = 35 { 36 { ARG_KEY_ATTR, ARG_ATTR } 37 }; 38 39 private static final String [][] REQUIRED_ATTRS = 40 { 41 { ARG_KEY_ATTR, ARG_ATTR }, 42 }; 43 44 private static final String [][] ATTR_DEPENDENCIES = 45 { 46 { BUNDLE_NAME_ATTR, ARG_KEY_ATTR } 47 }; 48 49 50 public ValidationMessageArgsGrammar( AnnotationProcessorEnvironment env, Diagnostics diags, 51 RuntimeVersionChecker rvc ) 52 { 53 super( env, diags, VERSION_9_0_STRING, rvc ); 54 55 addMemberType( POSITION_ATTR, new UniqueValueType( MESSAGE_ARGS_ATTR, false, true, null, this ) ); 57 addMemberType( BUNDLE_NAME_ATTR, new BundleNameType( null, this ) ); 58 } 59 60 61 public String [][] getMutuallyExclusiveAttrs() 62 { 63 return MUTUALLY_EXCLUSIVE_ATTRS; 64 } 65 66 67 public String [][] getRequiredAttrs() 68 { 69 return REQUIRED_ATTRS; 70 } 71 72 73 public String [][] getAttrDependencies() 74 { 75 return ATTR_DEPENDENCIES; 76 } 77 78 79 protected Object onEndCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, 80 MemberDeclaration classMember, Map checkResults ) 81 { 82 Integer position = CompilerUtils.getInteger( annotation, POSITION_ATTR, true ); 83 84 if ( position == null ) 85 { 86 } 91 else if ( position.intValue() < 0 || position.intValue() > 3 ) 92 { 93 addError( annotation, "error.integer-attribute-not-in-range", POSITION_ATTR, 94 new Integer ( 0 ), new Integer ( 3 ) ); 95 } 96 97 return null; 98 } 99 } 100 | Popular Tags |