Browse files

restructuring packages, according to new pluggable infrastructure

  • Loading branch information...
1 parent f132beb commit b014955dd03d7bf20df91e14eafe54472a38240a @andresteingress committed Feb 25, 2011
Showing with 56 additions and 13 deletions.
  1. +3 −2 META-INF/services/org.gcontracts.common.spi.Lifecycle
  2. +1 −0 gcontracts-core/src/main/java/org/gcontracts/ast/GContractsASTTransformation.java
  3. +1 −1 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/ContractsErasingVisitor.java
  4. +2 −2 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/ContractsVisitor.java
  5. +1 −1 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/DynamicSetterInjectionVisitor.java
  6. +1 −1 .../src/main/java/org/gcontracts/common/{impl → base}/BaseAnnotationProcessingASTTransformation.java
  7. +1 −1 gcontracts-core/src/main/java/org/gcontracts/common/{impl → base}/BaseLifecycle.java
  8. +1 −0 gcontracts-core/src/main/java/org/gcontracts/common/impl/ClassInvariantAnnotationProcessor.java
  9. +1 −0 gcontracts-core/src/main/java/org/gcontracts/common/impl/EnsuresAnnotationProcessor.java
  10. +2 −1 gcontracts-core/src/main/java/org/gcontracts/common/impl/NotNullAnnotationProcessor.java
  11. +1 −0 gcontracts-core/src/main/java/org/gcontracts/common/impl/RequiresAnnotationProcessor.java
  12. +34 −0 gcontracts-core/src/main/java/org/gcontracts/common/impl/lc/ClassInvariantLifecycle.java
  13. +2 −1 gcontracts-core/src/main/java/org/gcontracts/common/impl/{ → lc}/PostconditionLifecycle.java
  14. +2 −1 gcontracts-core/src/main/java/org/gcontracts/common/impl/{ → lc}/PreconditionLifecycle.java
  15. +3 −2 gcontracts-core/src/main/resources/META-INF/services/org.gcontracts.common.spi.Lifecycle
View
5 META-INF/services/org.gcontracts.common.spi.Lifecycle
@@ -1,2 +1,3 @@
-org.gcontracts.common.impl.PreconditionLifecycle
-org.gcontracts.common.impl.PostconditionLifecycle
+org.gcontracts.common.impl.lc.PreconditionLifecycle
+org.gcontracts.common.impl.lc.PostconditionLifecycle
+org.gcontracts.common.impl.lc.ClassInvariantLifecycle
View
1 gcontracts-core/src/main/java/org/gcontracts/ast/GContractsASTTransformation.java
@@ -30,6 +30,7 @@
import org.codehaus.groovy.control.io.ReaderSource;
import org.codehaus.groovy.transform.GroovyASTTransformation;
import org.gcontracts.ast.visitor.*;
+import org.gcontracts.ast.visitor.AnnotationProcessingASTTransformationsVisitor;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.CandidateChecks;
View
2 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/ContractsErasingVisitor.java
@@ -42,7 +42,7 @@
* @see org.gcontracts.annotations.Ensures
* @see org.gcontracts.annotations.Invariant
*
- * @see org.gcontracts.ast.visitor.BaseVisitor
+ * @see BaseVisitor
*
* @author andre.steingress@gmail.com
*/
View
4 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/ContractsVisitor.java
@@ -38,11 +38,11 @@
/**
* <p>
- * Main visitor in GContracts extending {@link org.gcontracts.ast.visitor.BaseVisitor}. At runtime visitors of
+ * Main visitor in GContracts extending {@link BaseVisitor}. At runtime visitors of
* this class are used to generate and add class invariants, pre- and postconditions to annotated classes and methods.
* </p>
*
- * @see org.gcontracts.ast.visitor.BaseVisitor
+ * @see BaseVisitor
*
* @author andre.steingress@gmail.com
*/
View
2 gcontracts-core/src/main/java/org/gcontracts/ast/visitor/DynamicSetterInjectionVisitor.java
@@ -47,7 +47,7 @@
* Implements contract support for setter methods in Groovy properties and public default constructors.
* </p>
*
- * @see org.gcontracts.ast.visitor.BaseVisitor
+ * @see BaseVisitor
*
* @author andre.steingress@gmail.com
*/
View
2 ...nnotationProcessingASTTransformation.java → ...nnotationProcessingASTTransformation.java
@@ -20,7 +20,7 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-package org.gcontracts.common.impl;
+package org.gcontracts.common.base;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.ClassNode;
View
2 ...gcontracts/common/impl/BaseLifecycle.java → ...gcontracts/common/base/BaseLifecycle.java
@@ -1,4 +1,4 @@
-package org.gcontracts.common.impl;
+package org.gcontracts.common.base;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
View
1 ...acts-core/src/main/java/org/gcontracts/common/impl/ClassInvariantAnnotationProcessor.java
@@ -5,6 +5,7 @@
import org.codehaus.groovy.ast.expr.ClosureExpression;
import org.codehaus.groovy.control.io.ReaderSource;
import org.gcontracts.annotations.Invariant;
+import org.gcontracts.common.base.BaseAnnotationProcessingASTTransformation;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.ClassInvariantGenerator;
import org.gcontracts.util.Validate;
View
1 gcontracts-core/src/main/java/org/gcontracts/common/impl/EnsuresAnnotationProcessor.java
@@ -6,6 +6,7 @@
import org.codehaus.groovy.ast.expr.ClosureExpression;
import org.codehaus.groovy.control.io.ReaderSource;
import org.gcontracts.annotations.Ensures;
+import org.gcontracts.common.base.BaseAnnotationProcessingASTTransformation;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.CandidateChecks;
import org.gcontracts.generation.PostconditionGenerator;
View
3 gcontracts-core/src/main/java/org/gcontracts/common/impl/NotNullAnnotationProcessor.java
@@ -33,6 +33,7 @@
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.syntax.Token;
import org.codehaus.groovy.syntax.Types;
+import org.gcontracts.common.base.BaseAnnotationProcessingASTTransformation;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.util.Validate;
@@ -41,7 +42,7 @@
* {@link Parameter} instances for null values when {@link org.gcontracts.annotations.common.NotNull} is
* specified on them.
*
- * @see BaseAnnotationProcessingASTTransformation
+ * @see org.gcontracts.common.base.BaseAnnotationProcessingASTTransformation
*
* @author andre.steingress@gmail.com
*/
View
1 gcontracts-core/src/main/java/org/gcontracts/common/impl/RequiresAnnotationProcessor.java
@@ -6,6 +6,7 @@
import org.codehaus.groovy.ast.expr.ClosureExpression;
import org.codehaus.groovy.control.io.ReaderSource;
import org.gcontracts.annotations.Requires;
+import org.gcontracts.common.base.BaseAnnotationProcessingASTTransformation;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.CandidateChecks;
import org.gcontracts.generation.PreconditionGenerator;
View
34 gcontracts-core/src/main/java/org/gcontracts/common/impl/lc/ClassInvariantLifecycle.java
@@ -0,0 +1,34 @@
+package org.gcontracts.common.impl.lc;
+
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.MethodNode;
+import org.gcontracts.common.base.BaseLifecycle;
+import org.gcontracts.common.spi.ProcessingContextInformation;
+import org.gcontracts.generation.CandidateChecks;
+import org.gcontracts.generation.ClassInvariantGenerator;
+
+/**
+ * @author andre.steingress@gmail.com
+ */
+public class ClassInvariantLifecycle extends BaseLifecycle {
+
+ @Override
+ public void afterProcessingClassNode(ProcessingContextInformation processingContextInformation, ClassNode classNode) {
+ if (!processingContextInformation.isClassInvariantsEnabled()) return;
+ if (!CandidateChecks.isContractsCandidate(classNode)) return;
+
+ final ClassInvariantGenerator classInvariantGenerator = new ClassInvariantGenerator(processingContextInformation.readerSource());
+ if (processingContextInformation.classInvariantClassNodes().isEmpty()) {
+ classInvariantGenerator.generateDefaultInvariantAssertionMethod(classNode);
+ }
+ }
+
+ @Override
+ public void afterProcessingMethodNode(ProcessingContextInformation processingContextInformation, ClassNode classNode, MethodNode methodNode) {
+ if (!CandidateChecks.isPreOrPostconditionCandidate(classNode, methodNode)) return;
+ if (processingContextInformation.classInvariantClassNodes().isEmpty()) return;
+
+ final ClassInvariantGenerator classInvariantGenerator = new ClassInvariantGenerator(processingContextInformation.readerSource());
+ classInvariantGenerator.addInvariantAssertionStatement(classNode, methodNode);
+ }
+}
View
3 ...s/common/impl/PostconditionLifecycle.java → ...ommon/impl/lc/PostconditionLifecycle.java
@@ -1,7 +1,8 @@
-package org.gcontracts.common.impl;
+package org.gcontracts.common.impl.lc;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
+import org.gcontracts.common.base.BaseLifecycle;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.CandidateChecks;
import org.gcontracts.generation.PostconditionGenerator;
View
3 ...ts/common/impl/PreconditionLifecycle.java → ...common/impl/lc/PreconditionLifecycle.java
@@ -1,7 +1,8 @@
-package org.gcontracts.common.impl;
+package org.gcontracts.common.impl.lc;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
+import org.gcontracts.common.base.BaseLifecycle;
import org.gcontracts.common.spi.ProcessingContextInformation;
import org.gcontracts.generation.CandidateChecks;
import org.gcontracts.generation.PreconditionGenerator;
View
5 gcontracts-core/src/main/resources/META-INF/services/org.gcontracts.common.spi.Lifecycle
@@ -1,2 +1,3 @@
-org.gcontracts.common.impl.PreconditionLifecycle
-org.gcontracts.common.impl.PostconditionLifecycle
+org.gcontracts.common.impl.lc.PreconditionLifecycle
+org.gcontracts.common.impl.lc.PostconditionLifecycle
+org.gcontracts.common.impl.lc.ClassInvariantLifecycle

0 comments on commit b014955

Please sign in to comment.