Package com.google.java.contract.core.model

Examples of com.google.java.contract.core.model.ContractAnnotationModel


            returnType = utils.getTypeNameForType(
                utils.typeUtils.erasure(method.getReturnType()));
        }
    }

    return new ContractAnnotationModel(kind, primary, virtual,
                                       owner, returnType);
  }
View Full Code Here


    "owner != null",
    "utils.isContractAnnotation(annotation)"
  })
  protected ContractAnnotationModel createContractModel(Element parent,
      AnnotationMirror annotation, boolean primary, ClassName owner) {
    ContractAnnotationModel model = createBlankContractModel(
        parent, annotation, primary, owner);
    List<Long> lineNumbers = null;
    if (rootLineNumberIterator == null) {
      lineNumbers = getLineNumbers(parent, annotation);
    }

    AnnotationValue lastAnnotationValue = null;
    for (AnnotationValue annotationValue :
         annotation.getElementValues().values()) {
      @SuppressWarnings("unchecked")
      List<? extends AnnotationValue> values =
          (List<? extends AnnotationValue>) annotationValue.getValue();

      Iterator<? extends AnnotationValue> iterValue = values.iterator();
      Iterator<Long> iterLineNumber;
      if (rootLineNumberIterator != null) {
        iterLineNumber = rootLineNumberIterator;
      } else {
        iterLineNumber = lineNumbers.iterator();
      }
      while (iterValue.hasNext()) {
        String value = (String) iterValue.next().getValue();
        Long lineNumber =
            iterLineNumber.hasNext() ? iterLineNumber.next() : null;
        model.addValue(value, lineNumber);
      }
      lastAnnotationValue = annotationValue;
    }
    if (model.getValues().isEmpty()) {
      diagnosticManager.warning("No contracts specified in annotation.",
                                null, 0, 0, 0,
                                parent, annotation, lastAnnotationValue);
      return null;
    }
    AnnotationSourceInfo sourceInfo =
        new AnnotationSourceInfo(parent, annotation, lastAnnotationValue,
                                 model.getValues());
    model.setSourceInfo(sourceInfo);
    return model;
  }
View Full Code Here

  })
  protected void visitAnnotation(
      Element parent, AnnotationMirror annotation,
      boolean primary, ClassName owner, ElementModel p) {
    if (utils.isContractAnnotation(annotation)) {
      ContractAnnotationModel model =
          createContractModel(parent, annotation, primary, owner);
      if (model != null) {
        p.addEnclosedElement(model);
      }
    }
View Full Code Here

  @Override
  protected void visitAnnotation(Element parent, AnnotationMirror annotation,
                                 boolean primary, ClassName owner,
                                 ElementModel p) {
    if (utils.isContractAnnotation(annotation)) {
      ContractAnnotationModel model =
          createContractModel(parent, annotation, primary, owner);
      if (model == null) {
        return;
      }
      if (type.getKind() == ElementKind.ANNOTATION_TYPE) {
        AnnotationSourceInfo asi = (AnnotationSourceInfo) model.getSourceInfo();
        /* Do not add contracts to annotations. Warn the user instead. */
        diagnosticManager.warning("Contracts can't be applied to annotations. "
                                  + "The following annotation will not "
                                  + "perform any contract check: " +
                                  type.toString(),
View Full Code Here

TOP

Related Classes of com.google.java.contract.core.model.ContractAnnotationModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.