You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ke...@apache.org on 2004/10/07 03:29:22 UTC
svn commit: rev 53927 - incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt
Author: kentam
Date: Wed Oct 6 18:29:21 2004
New Revision: 53927
Modified:
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java
Log:
Fine-tune some asserts, clarify contract in TwoPhaseAnnotationProcessor to define when generate() gets called.
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/AptControlImplementation.java Wed Oct 6 18:29:21 2004
@@ -135,7 +135,8 @@
if ( _implDecl == null )
return null;
- assert _implDecl.getQualifiedName().equals( getPackage() + "." + getShortName() );
+ assert ( getPackage().equals("") ? _implDecl.getQualifiedName().equals( getShortName() ) :
+ _implDecl.getQualifiedName().equals( getPackage() + "." + getShortName() ) );
return _implDecl.getQualifiedName();
}
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java Wed Oct 6 18:29:21 2004
@@ -126,6 +126,8 @@
InterfaceType controlIntfOrExt = getControlInterfaceOrExtension(controlType);
InterfaceType controlIntf = getMostDerivedControlInterface( controlIntfOrExt );
+ assert controlIntf != null : "Can't find most derived control intf for=" + controlIntfOrExt;
+
ControlInterface annot = controlIntf.getDeclaration().getAnnotation(ControlInterface.class);
String defBinding = annot.defaultBinding();
Modified: incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/TwoPhaseAnnotationProcessor.java Wed Oct 6 18:29:21 2004
@@ -71,6 +71,7 @@
public TwoPhaseAnnotationProcessor(Set<AnnotationTypeDeclaration> atds,
AnnotationProcessorEnvironment env)
{
+ _numErrors = 0;
_atds = atds;
_env = env;
_locale = Locale.getDefault();
@@ -78,11 +79,15 @@
/**
* Implements AnnotationProcessor.process() as two phases, "check" and "generate".
+ * "generate" will not be called if "check" emitted any errors (via printError()).
*/
public void process()
{
check();
- generate();
+
+ // Do not call generate if check resulted in errors.
+ if ( !hasErrors() )
+ generate();
}
/**
@@ -120,9 +125,10 @@
/**
* The check method is responsible for all semantic validation of the input Declaration.
* <p>
- * All semantic warnings/errors associated with the input Declaration should
- * be output during check via a Messager obtained from the
- * AnnotationProcessorEnvironment.
+ * All semantic errors/warnings associated with the input Declaration should
+ * be output during check via the {@link #printError(Declaration, String, Object...)} and
+ * {@link #printWarning(Declaration,String,Object...)} methods. If an implementation
+ * bypasses printError, it must override {@link #hasErrors()} to ensure correct behaviour.
* <p>
* If the presence of the input Declaration implies the need to add new files,
* and those files need to be visible during the check phase for
@@ -146,15 +152,24 @@
}
//
- // Helper functions for localizing diagnostics
+ // Helper functions for handling diagnostics
//
+ /**
+ * Report an error detected during the "check" phase. The presence of errors
+ * will suppress execution of the "generate" phase.
+ */
protected void printError( Declaration d, String id, Object... args )
{
String message = getResourceString(id, args);
getMessager().printError(d.getPosition(), message);
+ _numErrors++;
}
+ /**
+ * Report a warning detected during the "check" phase. The presence of warnings
+ * will not affect execution of the "generate" phase.
+ */
protected void printWarning( Declaration d, String id, Object... args )
{
String message = getResourceString(id, args);
@@ -175,11 +190,22 @@
return MessageFormat.format(pattern, args);
}
+ /**
+ * Reports whether this processor has encountered errors during the "check" phase.
+ * Implementations must override this if they report errors via a mechanism other than
+ * {@link #printError(Declaration,String,Object...)}.
+ */
+ protected boolean hasErrors()
+ {
+ return _numErrors != 0;
+ }
+
private final Messager getMessager()
{
return getAnnotationProcessorEnvironment().getMessager();
}
+ int _numErrors;
Set<AnnotationTypeDeclaration> _atds;
AnnotationProcessorEnvironment _env;
Locale _locale;