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

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


    @Requires("ClassName.isBinaryName(className)")
    private void findSuperInfo(String className) {
      if (superClassNames.containsKey(className)) {
        return;
      }
      if (blacklistManager.isIgnored(new ClassName(className)
                                     .getQualifiedName())) {
        findSuperInfoFromClass(className);
      } else {
        findSuperInfoFromClassFile(className);
      }
View Full Code Here


    @Requires("ClassName.isBinaryName(className)")
    private void findSuperInfoFromClass(String className) {
      Class<?> clazz;
      try {
        String qName = new ClassName(className).getQualifiedName();
        clazz = Class.forName(qName, false, loader);
      } catch (ClassNotFoundException e) {
        addDefaultAssignable(className);
        return;
      }
View Full Code Here

          if (newLevel == oldContext) {
            /* End of old expression. */
            String oldExpr = oldBuffer.toString();
            oldParameters.add(
                new VariableModel(ElementKind.PARAMETER, oldName,
                                  new ClassName("java/lang/Object")));
            oldParametersCode.add(oldExpr);
            oldParametersLineNumbers.add(lineNumber);

            /* Pad buffer (for error reporting purposes). */
            buffer.append("(   ");
View Full Code Here

  @Ensures("result != null")
  private static VariableModel getSignalVariable() {
    VariableModel var =
        new VariableModel(ElementKind.PARAMETER, JavaUtils.SIGNAL_VARIABLE,
                          new ClassName("java/lang/Exception"));
    var.addModifier(ElementModifier.FINAL);
    return var;
  }
View Full Code Here

      int pos, int id, String expr, ContractAnnotationModel annotation,
      Long lineNumber) {
    MethodModel helper =
        ContractCreation.createBlankContractHelper(kind, annotation,
                                                   "$" + Integer.toString(pos));
    helper.setReturnType(new ClassName("java/lang/Object"));

    if (helper.getKind() == ElementKind.CONTRACT_METHOD) {
      ContractMethodModel helperContract = (ContractMethodModel) helper;
      if (lineNumber != null) {
        helperContract.setLineNumbers(Collections.singletonList(lineNumber));
      }
      String code = expr;
      if (!annotation.isVirtual()) {
        code = ContractCreation
            .rebaseLocalCalls(expr, JavaUtils.THAT_VARIABLE, null);
      }
      helperContract.addStatement("return " + code + ";");
    }

    ContractMethodModel contract =
        ContractCreation.createBlankContractMethod(kind, annotation, "$" + id);
    contract.setReturnType(new ClassName("java/lang/Object"));
    contract.setId(id);

    contract.addStatement("return "
        + ContractCreation.getHelperCallCode(helper, annotation) + ";");
  }
View Full Code Here

    }

    try {
      BalancedTokenizer tokenizer = new BalancedTokenizer(source);
      String packageName = null;
      ClassName className = null;
      ArrayList<Long> orphanLineNumbers = new ArrayList<Long>();
      while (tokenizer.hasNext()) {
        JavaTokenizer.Token token = tokenizer.next();
        switch (token.kind) {
          case WORD:
            if (tokenizer.getCurrentLevel() == 0) {
              if (token.text.equals("package")) {
                packageName = JavaUtils.parseQualifiedName(tokenizer);
              } else if (token.text.equals("import")) {
                String name = JavaUtils.parseQualifiedName(tokenizer, true);
                if (name.equals("static")) {
                  name += " " + JavaUtils.parseQualifiedName(tokenizer, true);
                }
                importNames.add(name);
              } else if (TYPE_KEYWORDS.contains(token.text)) {
                String name = JavaUtils.parseQualifiedName(tokenizer);
                if (packageName != null) {
                  name = packageName + "." + name;
                }
                className = new ClassName(name.replace('.', '/'));
                contractLineNumbers
                    .put(className, new ArrayList<Long>(orphanLineNumbers));
                orphanLineNumbers.clear();
                JavaUtils.skipPast(tokenizer, "{");
              }
View Full Code Here

  ClassName getClassNameForType(TypeMirror type) {
    DeclaredType tmp = (DeclaredType) type;
    TypeElement element = (TypeElement) tmp.asElement();
    String binaryName = elementUtils.getBinaryName(element)
        .toString().replace('.', '/');
    return new ClassName(binaryName, type.toString());
  }
View Full Code Here

        continue;
      }

      for (Map.Entry<ClassName, List<Long>> entry :
           contractLineNumbers.entrySet()) {
        ClassName className = entry.getKey();
        File outputFileName;
        if (depout == null) {
          outputFileName = new File(dir + className.getSimpleName()
                                    + JavaUtils.SOURCE_DEPENDENCY_EXTENSION);
        } else {
          outputFileName = new File(depout + "/" + className.getBinaryName()
                                    + JavaUtils.SOURCE_DEPENDENCY_EXTENSION);
        }

        outputFileName.getParentFile().mkdirs();
        FileOutputStream out = new FileOutputStream(outputFileName);
View Full Code Here

TOP

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

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.