1 18 package org.apache.beehive.netui.compiler; 19 20 import org.apache.beehive.netui.compiler.grammar.CommandHandlerGrammar; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; 22 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration; 23 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 24 25 import java.util.HashMap ; 26 import java.util.Map ; 27 28 29 public class FacesBackingChecker 30 extends BaseChecker 31 implements JpfLanguageConstants 32 { 33 public FacesBackingChecker( AnnotationProcessorEnvironment env, FacesBackingInfo fbInfo, Diagnostics diags ) 34 { 35 super( env, fbInfo, diags ); 36 } 37 38 public Map onCheck( ClassDeclaration jclass ) 39 throws FatalCompileTimeException 40 { 41 if ( ! CompilerUtils.isAssignableFrom( FACES_BACKING_BEAN_CLASS, jclass, getEnv() )) 42 { 43 getDiagnostics().addError( jclass, "error.does-not-extend-base", FACES_BACKING_BEAN_CLASS ); 44 return null; 45 } 46 47 ClassDeclaration[] packageClasses = jclass.getPackage().getClasses(); 48 ClassDeclaration jpfClass = null; 49 50 for ( int i = 0; i < packageClasses.length; i++ ) 51 { 52 ClassDeclaration classDecl = packageClasses[i]; 53 if ( CompilerUtils.isPageFlowClass( classDecl, getEnv() ) ) jpfClass = classDecl; 54 } 55 56 FlowControllerInfo fcInfo = new FlowControllerInfo( jpfClass ); 57 fcInfo.startBuild( getEnv(), jpfClass ); 58 59 CommandHandlerGrammar chg = 60 new CommandHandlerGrammar( getEnv(), getDiagnostics(), getRuntimeVersionChecker(), jpfClass, fcInfo ); 61 MethodDeclaration[] methods = CompilerUtils.getClassMethods( jclass, COMMAND_HANDLER_TAG_NAME ); 62 63 for ( int i = 0; i < methods.length; i++ ) 64 { 65 MethodDeclaration method = methods[i]; 66 getFBSourceFileInfo().addCommandHandler( method.getSimpleName() ); 67 chg.check( CompilerUtils.getAnnotation( method, COMMAND_HANDLER_TAG_NAME ), null, method ); 68 } 69 70 Map checkResultMap = new HashMap (); 71 checkResultMap.put( JpfLanguageConstants.ExtraInfoKeys.facesBackingInfo, getSourceFileInfo() ); 72 return checkResultMap; 73 } 74 75 protected FacesBackingInfo getFBSourceFileInfo() 76 { 77 return ( FacesBackingInfo ) super.getSourceFileInfo(); 78 } 79 } 80 | Popular Tags |