1 18 package org.apache.beehive.netui.compiler; 19 20 import org.apache.beehive.netui.compiler.genmodel.GenSharedFlowStrutsApp; 21 import org.apache.beehive.netui.compiler.genmodel.GenStrutsApp; 22 import org.apache.beehive.netui.compiler.grammar.ControllerGrammar; 23 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; 24 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 25 import org.apache.xmlbeans.XmlException; 26 27 import java.io.File ; 28 import java.io.IOException ; 29 30 31 public class SharedFlowChecker 32 extends FlowControllerChecker 33 { 34 public SharedFlowChecker( AnnotationProcessorEnvironment env, FlowControllerInfo fcInfo, Diagnostics diagnostics ) 35 { 36 super( env, fcInfo, diagnostics ); 37 } 38 39 protected void doAdditionalClassChecks( ClassDeclaration jclass ) 40 { 41 checkForOverlappingClasses( jclass, SHARED_FLOW_BASE_CLASS, SHARED_FLOW_FILE_EXTENSION_DOT, 43 "error.overlapping-sharedflows" ); 44 45 String pkg = jclass.getPackage().getQualifiedName(); 46 47 if ( CompilerUtils.isAssignableFrom( GLOBALAPP_BASE_CLASS, jclass, getEnv() ) ) 51 { 52 if ( ! pkg.equals( GLOBALAPP_PACKAGE ) ) 53 { 54 getDiagnostics().addError( jclass, "error.wrong-package", GLOBALAPP_PACKAGE ); 55 } 56 57 if ( ! jclass.getPosition().file().getParentFile().getName().endsWith( GLOBALAPP_PACKAGE ) ) 58 { 59 getDiagnostics().addError( jclass, "error.global-app-wrong-dir", 60 GLOBALAPP_SOURCE_NAME, GLOBALAPP_PARENT_PATH ); 61 } 62 } 63 } 64 65 protected String getDesiredBaseClass( ClassDeclaration jclass ) 66 { 67 File sourceFile = CompilerUtils.getSourceFile( jclass, true ); 68 if ( sourceFile.getName().endsWith( GLOBALAPP_FILE_EXTENSION_DOT ) ) return GLOBALAPP_BASE_CLASS; 69 if ( sourceFile.getName().endsWith( SHARED_FLOW_FILE_EXTENSION_DOT ) ) return SHARED_FLOW_BASE_CLASS; 70 return null; 71 } 72 73 protected GenStrutsApp createStrutsApp( ClassDeclaration jclass ) 74 throws XmlException, IOException , FatalCompileTimeException 75 { 76 File sourceFile = CompilerUtils.getSourceFile( jclass, true ); 77 return new GenSharedFlowStrutsApp( sourceFile, jclass, getEnv(), getFCSourceFileInfo(), true, getDiagnostics() ); 78 } 79 80 protected AnnotationGrammar getControllerGrammar() 81 { 82 return new ControllerGrammar( getEnv(), getDiagnostics(), getRuntimeVersionChecker(), getFCSourceFileInfo() ); 83 } 84 } 85 | Popular Tags |