Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenStrutsApp.java Fri Apr 22 00:41:54 2005 @@ -21,11 +21,12 @@ import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.JpfLanguageConstants; import org.apache.beehive.netui.compiler.MergedControllerAnnotation; +import org.apache.beehive.netui.compiler.Diagnostics; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.model.ActionModel; import org.apache.beehive.netui.compiler.model.FormBeanModel; import org.apache.beehive.netui.compiler.model.ForwardModel; import org.apache.beehive.netui.compiler.model.MessageResourcesModel; -import org.apache.beehive.netui.compiler.model.NoWebInfDirectoryException; import org.apache.beehive.netui.compiler.model.StrutsApp; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; @@ -61,12 +62,12 @@ private String _containingPackage; private File _strutsConfigFile; private File _sourceFile; - private File _webappRoot; private AnnotationProcessorEnvironment _env; private FlowControllerInfo _fcInfo; + private Diagnostics _diagnostics; protected void recalculateStrutsConfigFile() - throws XmlException, IOException + throws XmlException, IOException, FatalCompileTimeException { _strutsConfigFile = calculateStrutsConfigFile(); // caching this } @@ -77,18 +78,18 @@ } public GenStrutsApp( File sourceFile, ClassDeclaration jclass, AnnotationProcessorEnvironment env, - FlowControllerInfo fcInfo, boolean checkOnly ) - throws NoWebInfDirectoryException, XmlException, IOException + FlowControllerInfo fcInfo, boolean checkOnly, Diagnostics diagnostics ) + throws XmlException, IOException, FatalCompileTimeException { super( jclass.getQualifiedName() ); _jclass = jclass; _containingPackage = jclass.getPackage().getQualifiedName(); _sourceFile = sourceFile; - _webappRoot = getWebappRootFromSourceFile( sourceFile ).getAbsoluteFile(); _env = env; assert fcInfo != null; _fcInfo = fcInfo; + _diagnostics = diagnostics; recalculateStrutsConfigFile(); @@ -259,14 +260,6 @@ setTilesDefinitionsConfigs( paths ); } - private String getStrutsModulePath() - { - StringBuffer modulePath = new StringBuffer( '/' ); - if ( isSharedFlow() ) modulePath.append( STRUTS_CONFIG_SEPARATOR ); - if ( _containingPackage != null ) modulePath.append( _containingPackage.replace( '.', '/' ) ); - return modulePath.toString(); - } - private void addActionMethods() { MethodDeclaration[] actionMethods = CompilerUtils.getClassMethods( _jclass, ACTION_TAG_NAME ); @@ -328,13 +321,13 @@ } public void writeToFile() - throws NoWebInfDirectoryException, FileNotFoundException, IOException, XmlException + throws FileNotFoundException, IOException, XmlException, FatalCompileTimeException { writeToFile( getMergeFile( getMergeFileName() ) ); } public boolean isStale() - throws NoWebInfDirectoryException + throws FatalCompileTimeException { return isStale( getMergeFile( getMergeFileName() ) ); } @@ -362,9 +355,10 @@ } private File calculateStrutsConfigFile() - throws XmlException, IOException + throws XmlException, IOException, FatalCompileTimeException { - File strutsConfigFile = new File( _webappRoot.getPath() + getStrutsConfigURI() ); + String webappBuildRoot = CompilerUtils.getWebBuildRoot( getEnv() ); + File strutsConfigFile = new File( webappBuildRoot + getStrutsConfigURI() ); // // For the root Controller.jpf and for Global.app, we have to look in web.xml to get the output location. @@ -372,12 +366,8 @@ // if ( isModuleDeclaredInWebXml() ) { - String alternateLocation = getAlternateLocation( strutsConfigFile, _webappRoot ); - - if ( alternateLocation != null ) - { - return new File( _webappRoot.getPath() + alternateLocation ); - } + String alternateLocation = getAlternateLocation( strutsConfigFile ); + if ( alternateLocation != null ) return new File( webappBuildRoot + alternateLocation ); } return strutsConfigFile; @@ -388,7 +378,6 @@ * file times of the source file and the (optional) struts-merge file. */ public boolean isStale( File mergeFile ) - throws NoWebInfDirectoryException { // // We always write the root-level JPF and Global.app, because the struts XML @@ -457,11 +446,11 @@ public void writeToFile( File strutsMergeFile ) - throws FileNotFoundException, IOException, XmlException, NoWebInfDirectoryException + throws FileNotFoundException, IOException, XmlException, FatalCompileTimeException { _strutsConfigFile.getParentFile().mkdirs(); PrintStream out = new PrintStream( new FileOutputStream( _strutsConfigFile ) ); - writeXml( out, strutsMergeFile, _webappRoot ); + writeXml( out, strutsMergeFile, CompilerUtils.getWebBuildRoot( getEnv() ) ); out.close(); } @@ -480,14 +469,15 @@ * web.xml explicitly. If the user is pointing to an alternate (e.g., old) location for these * files, we need to compile to that location. */ - private static String getAlternateLocation( File strutsConfigFile, File webappRoot ) - throws XmlException, IOException + private String getAlternateLocation( File strutsConfigFile ) + throws XmlException, IOException, FatalCompileTimeException { - File webXmlFile = new File( webappRoot.getPath() + '/' + StrutsApp.WEBINF_DIR_NAME + "/web.xml" ); + String webappContentRoot = CompilerUtils.getWebContentRoot( getEnv() ); + File webXmlFile = new File( webappContentRoot + '/' + StrutsApp.WEBINF_DIR_NAME + "/web.xml" ); if ( ! webXmlFile.canRead() ) { - // @TODO log this + _diagnostics.addWarning( _jclass, "warning.could-not-read-web-xml", webappContentRoot ); return null; } @@ -600,24 +590,18 @@ } public File getMergeFile( String mergeFileName ) - throws NoWebInfDirectoryException + throws FatalCompileTimeException { if ( mergeFileName != null ) { - if ( mergeFileName.startsWith( "/" ) ) - { - return new File( _webappRoot.getPath() + mergeFileName ); - } - else - { - return CompilerUtils.getFileRelativeToSourceFile( _jclass, mergeFileName, getEnv() ); - } + return CompilerUtils.getFileRelativeToSourceFile( _jclass, mergeFileName, getEnv() ); } return null; } protected String getHeaderComment( File mergeFile ) + throws FatalCompileTimeException { StringBuffer comment = new StringBuffer( " Generated from " ); comment.append( getWebappRelativePath( _sourceFile ) ); @@ -630,27 +614,40 @@ } private String getWebappRelativePath( File file ) + throws FatalCompileTimeException { - String webappRoot = _webappRoot.toString(); - file = file.getAbsoluteFile(); + String filePath = file.getAbsoluteFile().getPath(); + String[] sourceRoots = CompilerUtils.getWebSourceRoots( _env ); - if ( file.toString().startsWith( webappRoot ) ) + // + // Look through the source roots. + // + for ( int i = 0; i < sourceRoots.length; i++ ) { - return file.toString().substring( webappRoot.length() ).replace( '\\', '/' ); + String sourceRoot = sourceRoots[i]; + + if ( filePath.startsWith( sourceRoot ) ) + { + return file.toString().substring( sourceRoot.length() ).replace( '\\', '/' ); + } } - else + + // + // Look in the web content root. + // + String webContentRoot = CompilerUtils.getWebContentRoot( getEnv() ); + + if ( filePath.startsWith( webContentRoot ) ) { - return file.toString(); + return file.toString().substring( webContentRoot.length() ).replace( '\\', '/' ); } + + assert false : "could not calculate webapp-relative file from " + file; + return file.toString(); } AnnotationProcessorEnvironment getEnv() { return _env; - } - - public File getWebappRoot() - { - return _webappRoot; } }
Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/genmodel/GenValidationModel.java Fri Apr 22 00:41:54 2005 @@ -20,8 +20,9 @@ import org.apache.beehive.netui.compiler.CompilerUtils; import org.apache.beehive.netui.compiler.JpfLanguageConstants; import org.apache.beehive.netui.compiler.MergedControllerAnnotation; +import org.apache.beehive.netui.compiler.Diagnostics; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.model.FormBeanModel; -import org.apache.beehive.netui.compiler.model.NoWebInfDirectoryException; import org.apache.beehive.netui.compiler.model.validation.ValidationModel; import org.apache.beehive.netui.compiler.model.validation.ValidatorConstants; import org.apache.beehive.netui.compiler.model.validation.ValidatorRule; @@ -31,7 +32,11 @@ import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.Modifier; import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration; +import org.apache.beehive.netui.compiler.typesystem.declaration.ParameterDeclaration; import org.apache.beehive.netui.compiler.typesystem.type.DeclaredType; +import org.apache.beehive.netui.compiler.typesystem.type.TypeInstance; +import org.apache.beehive.netui.compiler.typesystem.type.ClassType; +import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; import org.apache.xmlbeans.XmlException; import java.io.File; @@ -55,10 +60,11 @@ private GenStrutsApp _strutsApp; private File _mergeFile; + private AnnotationProcessorEnvironment _env; - public GenValidationModel( ClassDeclaration jclass, GenStrutsApp strutsApp ) - throws NoWebInfDirectoryException + public GenValidationModel( ClassDeclaration jclass, GenStrutsApp strutsApp, AnnotationProcessorEnvironment env ) + throws FatalCompileTimeException { MergedControllerAnnotation mca = strutsApp.getFlowControllerInfo().getMergedControllerAnnotation(); _strutsApp = strutsApp; @@ -68,6 +74,7 @@ addRulesFromClass( mca ); String mergeFileName = mca.getValidatorMerge(); _mergeFile = strutsApp.getMergeFile( mergeFileName ); + _env = env; } private void addRulesFromBeans( ClassDeclaration jclass ) @@ -164,6 +171,18 @@ AnnotationInstance actionAnnotation = CompilerUtils.getAnnotation( method, ACTION_TAG_NAME ); assert actionAnnotation != null; addRulesFromActionAnnotation( actionAnnotation, method.getSimpleName() ); + + ParameterDeclaration[] parameters = method.getParameters(); + if ( parameters.length > 0 ) + { + TypeInstance type = parameters[0].getType(); + + if ( type instanceof ClassType ) + { + ClassDeclaration classDecl = ( ( ClassType ) type ).getClassTypeDeclaration(); + if ( classDecl.getDeclaringType() == null ) addRulesFromBeanClass( classDecl ); + } + } } @@ -404,14 +423,16 @@ } protected String getHeaderComment( File mergeFile ) + throws FatalCompileTimeException { return _strutsApp.getHeaderComment( mergeFile ); } public void writeToFile() - throws FileNotFoundException, XmlException, IOException + throws FileNotFoundException, XmlException, IOException, FatalCompileTimeException { - String outputFile = _strutsApp.getWebappRoot() + _strutsApp.getOutputFileURI( STRUTS_VALIDATION_PREFIX ); + String outputFile = + CompilerUtils.getWebBuildRoot( _env ) + _strutsApp.getOutputFileURI( STRUTS_VALIDATION_PREFIX ); PrintStream printStream = new PrintStream( new FileOutputStream( outputFile ) ); writeXml( printStream, _mergeFile ); printStream.close(); Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ActionGrammar.java Fri Apr 22 00:41:54 2005 @@ -23,6 +23,7 @@ import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.JpfLanguageConstants; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.*; import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; import org.apache.beehive.netui.compiler.typesystem.type.DeclaredType; @@ -63,6 +64,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { // // First check the form bean type. Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/BaseValidationRuleGrammar.java Fri Apr 22 00:41:54 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.compiler.CompilerUtils; import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; @@ -68,6 +69,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { // // Check to make sure that either the parent ValidatableProperty annotation has a displayName property, Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/DelegatingType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/DelegatingType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/DelegatingType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/DelegatingType.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.AnnotationMemberType; import org.apache.beehive.netui.compiler.AnnotationGrammar; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; @@ -41,6 +42,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { return _baseType.onCheck( valueDecl, member, parentAnnotations, classMember, annotationArrayIndex ); } Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/EnumType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/EnumType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/EnumType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/EnumType.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.AnnotationMemberType; import org.apache.beehive.netui.compiler.CompilerUtils; import org.apache.beehive.netui.compiler.AnnotationGrammar; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; @@ -82,6 +83,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue member, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { // // Check deprecated values. Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExceptionHandlerGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExceptionHandlerGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExceptionHandlerGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExceptionHandlerGrammar.java Fri Apr 22 00:41:54 2005 @@ -22,6 +22,7 @@ import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration; @@ -44,6 +45,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { if ( classMember.hasModifier( Modifier.ABSTRACT ) ) { Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExternalPathOrActionType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExternalPathOrActionType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExternalPathOrActionType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ExternalPathOrActionType.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.AnnotationGrammar; import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.CompilerUtils; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; @@ -37,6 +38,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { AnnotationInstance parentAnnotation = parentAnnotations[ parentAnnotations.length - 1 ]; Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ForwardToExternalPathType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ForwardToExternalPathType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ForwardToExternalPathType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ForwardToExternalPathType.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.AnnotationGrammar; import org.apache.beehive.netui.compiler.AnnotationMemberType; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; @@ -40,6 +41,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { String stringValue = ( String ) value.getValue(); Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SharedFlowRefGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SharedFlowRefGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SharedFlowRefGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SharedFlowRefGrammar.java Fri Apr 22 00:41:54 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; import org.apache.beehive.netui.compiler.CompilerUtils; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; @@ -41,6 +42,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { assert classMember instanceof TypeDeclaration : classMember.getClass().getName(); // enforced in Jpf.java Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/SimpleActionGrammar.java Fri Apr 22 00:41:54 2005 @@ -22,6 +22,7 @@ import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; @@ -74,6 +75,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { String name = CompilerUtils.getString( annotation, NAME_ATTR, false ); Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/TilesDefinitionsConfigsType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/TilesDefinitionsConfigsType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/TilesDefinitionsConfigsType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/TilesDefinitionsConfigsType.java Fri Apr 22 00:41:54 2005 @@ -19,6 +19,7 @@ import org.apache.beehive.netui.compiler.AnnotationGrammar; import org.apache.beehive.netui.compiler.FlowControllerInfo; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; @@ -39,6 +40,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { List values = ( List ) value.getValue(); Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidatablePropertyGrammar.java Fri Apr 22 00:41:54 2005 @@ -24,6 +24,7 @@ import org.apache.beehive.netui.compiler.AnnotationMemberType; import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.CompilerUtils; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; public class ValidatablePropertyGrammar @@ -59,6 +60,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { if ( parentAnnotations == null ) return true; Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidateRequiredGrammar.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidateRequiredGrammar.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidateRequiredGrammar.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/ValidateRequiredGrammar.java Fri Apr 22 00:41:54 2005 @@ -25,6 +25,7 @@ import org.apache.beehive.netui.compiler.typesystem.type.PrimitiveType; import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.RuntimeVersionChecker; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; public class ValidateRequiredGrammar @@ -37,6 +38,7 @@ protected boolean onBeginCheck( AnnotationInstance annotation, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember ) + throws FatalCompileTimeException { // // Add a warning when this annotation is on a getter method which returns a primitive type. Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathOrActionType.java Fri Apr 22 00:41:54 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.compiler.FlowControllerInfo; import org.apache.beehive.netui.compiler.AnnotationGrammar; import org.apache.beehive.netui.compiler.MergedControllerAnnotation; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; @@ -47,6 +48,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { String stringValue = ( String ) value.getValue(); checkAction( stringValue, value, classMember ); Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/grammar/WebappPathType.java Fri Apr 22 00:41:54 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.compiler.AnnotationGrammar; import org.apache.beehive.netui.compiler.CompilerUtils; import org.apache.beehive.netui.compiler.FlowControllerInfo; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; import org.apache.beehive.netui.compiler.typesystem.declaration.MemberDeclaration; @@ -65,6 +66,7 @@ public Object onCheck( AnnotationTypeElementDeclaration valueDecl, AnnotationValue value, AnnotationInstance[] parentAnnotations, MemberDeclaration classMember, int annotationArrayIndex ) + throws FatalCompileTimeException { String filePath = ( String ) value.getValue(); @@ -114,10 +116,7 @@ if ( filePath.charAt( 0 ) == '/' ) // relative to webapp root { - if ( _pathMustBeRelative ) - { - addError( value, "error.relative-uri" ); - } + if ( _pathMustBeRelative ) addError( value, "error.relative-uri" ); if ( filePath.endsWith( JPF_FILE_EXTENSION_DOT ) ) { @@ -138,8 +137,7 @@ // if ( jpfSourceFile != null ) { - File webappRoot = CompilerUtils.getWebFilesRoot( jpfSourceFile, true, getEnv() ); - fileToCheck = new File( webappRoot + filePath ); + fileToCheck = CompilerUtils.getWebappRelativeFile( filePath, allowFileInPageFlowSourceDir(), getEnv() ); if ( ! fileToCheck.exists() && ! ( ignoreDirectories() && fileToCheck.isDirectory() ) ) { @@ -184,6 +182,7 @@ public static boolean relativePathExists( String filePath, TypeDeclaration outerClass, AnnotationProcessorEnvironment env ) + throws FatalCompileTimeException { assert filePath.charAt( 0 ) != '/' : filePath + " is not a relative path"; return checkRelativePath( filePath, outerClass, null, true, false, env ); @@ -193,6 +192,8 @@ CompilerUtils.Mutable retFileToCheck, boolean ignoreDirectories, boolean allowFileInPageFlowSourceDir, AnnotationProcessorEnvironment env ) + throws FatalCompileTimeException + { File fileToCheck = null; boolean fileExists = true; @@ -222,12 +223,12 @@ } else { - // Use the package name to infer the relative path (from web files root) to the page flow directory. - File webFilesRoot = CompilerUtils.getWebFilesRoot( jpfSourceFile, true, env ); + // Use the package name to infer the relative path (from web content root) to the page flow directory. + String webContentRoot = CompilerUtils.getWebContentRoot( env ); String jpfParentRelativePath = ""; PackageDeclaration jpfPackage = outerClass.getPackage(); if ( jpfPackage != null ) jpfParentRelativePath = jpfPackage.getQualifiedName().replace( '.', '/' ); - File desiredParentDir = new File( webFilesRoot.getPath(), jpfParentRelativePath ); + File desiredParentDir = new File( webContentRoot, jpfParentRelativePath ); fileToCheck = new File( desiredParentDir, filePath ); } Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/StrutsApp.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.model.schema.struts11.*; import org.apache.beehive.netui.compiler.model.validation.ValidationModel; import org.apache.beehive.netui.compiler.JpfLanguageConstants; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlDocumentProperties; @@ -257,33 +258,6 @@ _formBeans.remove( formBean.getName() ); } - public static File getWebappRootFromSourceFile( File jpf ) - throws NoWebInfDirectoryException - { - File webappRoot = null; - - // TODO: cache the stringValue of getWebappRootFromJpf. It's expensive to calculate. - for ( File dir = jpf.getAbsoluteFile().getParentFile(); dir != null; dir = dir.getParentFile() ) - { - File webinfDir = new File( dir, WEBINF_DIR_NAME ); - - if ( webinfDir.isDirectory() ) - { - webappRoot = dir; - - // If the directory contains a web.xml file, then it is our best match. - if ( new File( webinfDir, "web.xml" ).isFile() ) break; - } - } - - if ( webappRoot == null ) - { - throw new NoWebInfDirectoryException( jpf.getPath() ); - } - - return webappRoot; - } - public String getFormNameForType( String formType, boolean isPageFlowScoped ) { // @@ -443,8 +417,8 @@ } } - public void writeXml( PrintStream outputStream, File mergeFile, File webappRoot ) - throws IOException, XmlException, NoWebInfDirectoryException + public void writeXml( PrintStream outputStream, File mergeFile, String webappBuildRoot ) + throws IOException, XmlException, FatalCompileTimeException { StrutsConfigDocument doc; @@ -911,6 +885,7 @@ } protected String getHeaderComment( File mergeFile ) + throws FatalCompileTimeException { return null; } Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java Fri Apr 22 00:41:54 2005 @@ -20,6 +20,7 @@ import org.apache.beehive.netui.compiler.model.schema.validator11.FormsetDocument; import org.apache.beehive.netui.compiler.model.schema.validator11.FormValidationDocument; import org.apache.beehive.netui.compiler.JpfLanguageConstants; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlDocumentProperties; import org.apache.xmlbeans.XmlCursor; @@ -216,7 +217,7 @@ } public void writeXml( PrintStream outputStream, File mergeFile ) - throws XmlException, IOException + throws XmlException, IOException, FatalCompileTimeException { // // First, if we haven't written the all-locale rules to each locale, do so now. @@ -324,6 +325,7 @@ } protected String getHeaderComment( File mergeFile ) + throws FatalCompileTimeException { return null; } Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/BaseAnnotationProcessor.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/BaseAnnotationProcessor.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/BaseAnnotationProcessor.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/BaseAnnotationProcessor.java Fri Apr 22 00:41:54 2005 @@ -23,6 +23,7 @@ import org.apache.beehive.netui.compiler.Diagnostics; import org.apache.beehive.netui.compiler.JpfLanguageConstants; import org.apache.beehive.netui.compiler.SourceFileInfo; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration; @@ -51,6 +52,7 @@ } public void check( Declaration decl ) + throws FatalCompileTimeException { assert _sourceFileInfo != null; // process() should guarantee this. @@ -86,6 +88,7 @@ } public void generate( Declaration decl ) + throws FatalCompileTimeException { assert _sourceFileInfo != null; // process() should guarantee this. Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/TwoPhaseAnnotationProcessor.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/TwoPhaseAnnotationProcessor.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/TwoPhaseAnnotationProcessor.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/processor/TwoPhaseAnnotationProcessor.java Fri Apr 22 00:41:54 2005 @@ -25,6 +25,7 @@ import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration; import org.apache.beehive.netui.compiler.Diagnostics; +import org.apache.beehive.netui.compiler.FatalCompileTimeException; /** * The TwoPhaseAnnotationProcessor class is an abstract class that implements the APT @@ -80,12 +81,16 @@ */ public void process() { - check(); - - // Do not call generate if check resulted in errors. - if ( !hasErrors() ) + try + { + check(); + + // Do not call generate if check resulted in errors. + if ( ! hasErrors() ) generate(); + } + catch ( FatalCompileTimeException e ) { - generate(); + e.printDiagnostic( this ); } } @@ -94,6 +99,7 @@ * annotations claimed by this AnnotationProcessor. */ public void check() + throws FatalCompileTimeException { HashSet declsToCheck = new HashSet(); @@ -126,17 +132,23 @@ */ public void generate() { - for ( int i = 0; i < _atds.length; i++ ) + try { - AnnotationTypeDeclaration atd = _atds[i]; - Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith( atd ); - - for ( int j = 0; j < decls.length; j++ ) + for ( int i = 0; i < _atds.length; i++ ) { - Declaration decl = decls[j]; - generate( decl ); + AnnotationTypeDeclaration atd = _atds[i]; + Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith( atd ); + + for ( int j = 0; j < decls.length; j++ ) + { + generate( decls[j] ); + } } } + catch ( FatalCompileTimeException e ) + { + e.printDiagnostic( this ); + } } /** @@ -153,13 +165,15 @@ * but rather be kept in memory to be referenced by the check phase of other * Declarations. */ - public abstract void check( Declaration decl ); + public abstract void check( Declaration decl ) + throws FatalCompileTimeException; /** * The generate method is responsible for the generation of any additional artifacts * (source, class, or binary) that are derived from the input Declaration. */ - public abstract void generate( Declaration decl ); + public abstract void generate( Declaration decl ) + throws FatalCompileTimeException; // // Helper functions for handling diagnostics Modified: incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java?rev=164185&r1=164184&r2=164185&view=diff ============================================================================== --- incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java (original) +++ incubator/beehive/trunk/netui/src/compiler-core/org/apache/beehive/netui/compiler/typesystem/env/AnnotationProcessorEnvironment.java Fri Apr 22 00:41:54 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration; import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration; +import org.apache.beehive.netui.compiler.Diagnostics; import java.util.Map; import java.util.Collection;
