Package com.sun.javadoc

Examples of com.sun.javadoc.Type


                writer.println("<div class=\"itemTitle\">Parameters:</div>");
            }
            writer.println("<div class=\"item\">" + p + "</div>");
        }
        Tag[] returnTags = method.tags("return");
        Type returnType = getReturnType(method);
        if (returnTags != null && returnTags.length > 0) {
            writer.println("<div class=\"itemTitle\">Returns:</div>");
            String returnComment = returnTags[0].text();
            if (returnComment.trim().length() == 0) {
                addError("Undocumented return value (" +
                        clazz.name() + ".java:" + method.position().line() + ") " + name);
            }
            writer.println("<div class=\"item\">" + returnComment + "</div>");
        } else if (returnType != null && !returnType.toString().equals("void")) {
            if (hasComment && !method.commentText().startsWith("[") && !hasThrowsTag) {
                // [Not supported] and such are not problematic
                // also not problematic are methods that always throw an exception
                addError("Undocumented return value (" +
                        clazz.name() + ".java:" + method.position().line() + ") " + name + " " + getReturnType(method));
View Full Code Here


        }
        if ((firstSentence == null || firstSentence.trim().length() == 0) && raw.indexOf("{@inheritDoc}") < 0) {
            if (!doesOverride(method)) {
                boolean setterOrGetter = name.startsWith("set") && method.parameters().length == 1;
                setterOrGetter |= name.startsWith("get") && method.parameters().length == 0;
                Type returnType = getReturnType(method);
                setterOrGetter |= name.startsWith("is") &&
                        method.parameters().length == 0 &&
                        returnType != null &&
                        returnType.toString().equals("boolean");
                if (!setterOrGetter) {
                    addError("Undocumented method " +
                            " (" + clazz.name() + ".java:" + method.position().line() +") " +
                            clazz + "." + name + " " + raw);
                    return true;
View Full Code Here

  }
 
  private String getParameterString(Parameter[] ps) {
    String result = "";
    for (int i = 0; i < ps.length; i++) {
      Type type = ps[i].type();
      String ename = getExportedName(type, true);
      String pname =  ename.contains("function") ? "{}" : ps[i].name();
      result += "<span class=jsdocParameterType>" + ename
          + "</span> <span class=jsdocParameterName>" + pname
          + "</span>";
View Full Code Here

                                  SourcePosition sp) {
    if (sp != null) JavadocClassBuilder.addSourcePosition(dest,sp);
    {
      AnnotationDesc.ElementValuePair[] mvps = src.elementValues();
      for(int i=0; i<mvps.length; i++) {
        Type jmt = mvps[i].element().returnType();
        String name = mvps[i].element().name();
        AnnotationValue aval = mvps[i].value();
        setAnnotationValue(name,jmt,aval,dest,sp);
      }
    }
View Full Code Here

              continue;
            }

            if (name != null && !elements.containsKey(name)) {

              Type fieldType = getModelType(field.type(), nested);

              String description = getFieldDescription(field, true);
              String min = getFieldMin(field);
              String max = getFieldMax(field);
              Boolean required = getFieldRequired(field);
              String defaultValue = getFieldDefaultValue(field);

              String paramCategory = this.composite ? ParserHelper.paramTypeOf(false, this.consumesMultipart, field, fieldType, this.options)
                  : null;

              elements.put(field.name(), new TypeRef(field.name(), paramCategory, " field: " + field.name(), fieldType, description, min, max,
                  defaultValue, required));
            }
          }
        }
      }

      // add methods
      if (!"javax.xml.bind.annotation.XmlAccessType.FIELD".equals(xmlAccessorType)) {
        MethodDoc[] methodDocs = classDoc.methods();
        if (methodDocs != null) {
          for (MethodDoc method : methodDocs) {

            // ignore static methods and private methods
            if (method.isStatic() || method.isPrivate() || method.name().charAt(0) == '_') {
              continue;
            }

            // we tie getters and their corresponding methods together via this rawFieldName
            String rawFieldName = nameTranslator.methodName(method).value();

            String translatedNameViaMethod = this.translator.methodName(method).value();

            if (translatedNameViaMethod != null) {

              boolean isFieldMethod = rawFieldName != null && (elements.containsKey(rawFieldName) || excludeFields.contains(rawFieldName));

              boolean isFieldGetter = isFieldMethod && method.name().startsWith("get");
              boolean isFieldSetter = isFieldMethod && method.name().startsWith("set");

              boolean excludeMethod = false;

              // ignore deprecated methods
              excludeMethod = this.options.isExcludeDeprecatedFields() && ParserHelper.isDeprecated(method);

              // ignore methods we are to explicitly exclude
              if (ParserHelper.hasTag(method, this.options.getExcludeFieldTags())) {
                excludeMethod = true;
              }

              // ignore methods that are for a different json view
              ClassDoc[] jsonViews = ParserHelper.getJsonViews(method);
              if (!ParserHelper.isItemPartOfView(this.viewClasses, jsonViews)) {
                excludeMethod = true;
              }

              if (isFieldGetter || isFieldSetter) {

                // skip if the field has already been excluded
                if (excludeFields.contains(rawFieldName)) {
                  continue;
                }

                // skip if this method is to be excluded but also remove the field from the elements
                // so it doesnt appear in the model
                if (excludeMethod) {
                  elements.remove(rawFieldName);
                  excludeFields.add(rawFieldName);
                  continue;
                }

                // see if the field name should be overwritten via annotations on the getter/setter
                // note if the field has its own customizing annotation then that takes precedence
                String nameViaField = rawToTranslatedFields.get(rawFieldName);
                if (!customizedFieldNames.contains(rawFieldName) && !translatedNameViaMethod.equals(nameViaField)) {
                  rawToTranslatedFields.put(rawFieldName, translatedNameViaMethod);
                  customizedFieldNames.add(rawFieldName);
                }

                TypeRef typeRef = elements.get(rawFieldName);

                // the field was already found e.g. class had a field and this is the getter
                // check if there are tags on the getter we can use to fill in description, min and max
                if (typeRef.description == null) {
                  typeRef.description = getFieldDescription(method, isFieldGetter);
                }
                if (typeRef.min == null) {
                  typeRef.min = getFieldMin(method);
                }
                if (typeRef.max == null) {
                  typeRef.max = getFieldMax(method);
                }
                if (typeRef.defaultValue == null) {
                  typeRef.defaultValue = getFieldDefaultValue(method);
                }
                if (typeRef.required == null) {
                  typeRef.required = getFieldRequired(method);
                }
                if (this.composite && typeRef.paramCategory == null) {
                  typeRef.paramCategory = ParserHelper.paramTypeOf(false, this.consumesMultipart, method, typeRef.type, this.options);
                }

                typeRef.sourceDesc = " method: " + method.name();

              } else {

                // skip if this method is to be excluded
                if (excludeMethod) {
                  continue;
                }

                // this is a getter or other method where there wasn't a specific field
                String description = getFieldDescription(method, true);
                String min = getFieldMin(method);
                String max = getFieldMax(method);
                String defaultValue = getFieldDefaultValue(method);
                Boolean required = getFieldRequired(method);

                Type returnType = getModelType(method.returnType(), nested);

                String paramCategory = ParserHelper.paramTypeOf(false, this.consumesMultipart, method, returnType, this.options);

                elements.put(translatedNameViaMethod, new TypeRef(rawFieldName, paramCategory, " method: " + method.name(), returnType,
                    description, min, max, defaultValue, required));
View Full Code Here

  private Map<String, Property> findReferencedElements(ClassDoc classDoc, Map<String, TypeRef> types, boolean nested) {
    Map<String, Property> elements = new HashMap<String, Property>();
    for (Map.Entry<String, TypeRef> entry : types.entrySet()) {
      String typeName = entry.getKey();
      TypeRef typeRef = entry.getValue();
      Type type = typeRef.type;
      ClassDoc typeClassDoc = type.asClassDoc();

      OptionalName propertyTypeFormat = this.translator.typeName(type);
      String propertyType = propertyTypeFormat.value();

      // set enum values
      List<String> allowableValues = ParserHelper.getAllowableValues(typeClassDoc);
      if (allowableValues != null) {
        propertyType = "string";
      }

      Type containerOf = ParserHelper.getContainerType(type, this.varsToTypes);
      String itemsRef = null;
      String itemsType = null;
      String containerTypeOf = containerOf == null ? null : this.translator.typeName(containerOf).value();
      if (containerOf != null) {
        if (ParserHelper.isPrimitive(containerOf, this.options)) {
View Full Code Here

          }
          // TODO what about maps?
        }
      }
      // if its a ref to a param type replace with the type impl
      Type paramType = ParserHelper.getVarType(type.asTypeVariable(), this.varsToTypes);
      if (paramType != null) {
        return paramType;
      }
    }
    return type;
View Full Code Here

    ClassDoc currentClassDoc = this.classDoc;
    while (currentClassDoc != null) {

      // read default error type for class
      String defaultErrorTypeClass = ParserHelper.getTagValue(currentClassDoc, this.options.getDefaultErrorTypeTags());
      Type defaultErrorType = ParserHelper.findModel(this.classes, defaultErrorTypeClass);

      Set<Model> classModels = new HashSet<Model>();
      if (this.options.isParseModels() && defaultErrorType != null) {
        classModels.addAll(new ApiModelParser(this.options, this.options.getTranslator(), defaultErrorType).parse());
      }
View Full Code Here

   * @param varsToTypes A map of variables to types for parameterized types, optional if null parameterized types
   *            will not be handled
   * @return The container type or null if not a collection
   */
  public static Type getContainerType(Type type, Map<String, Type> varsToTypes) {
    Type result = null;
    ParameterizedType pt = type.asParameterizedType();
    if (pt != null && ParserHelper.isCollection(type.qualifiedTypeName())) {
      Type[] typeArgs = pt.typeArguments();
      if (typeArgs != null && typeArgs.length > 0) {
        result = typeArgs[0];
      }
    }
    // if its a ref to a param type replace with the type impl
    if (result != null) {
      Type paramType = getVarType(result.asTypeVariable(), varsToTypes);
      if (paramType != null) {
        return paramType;
      }
    }
    return result;
View Full Code Here

   * @param var The variable type to find
   * @param varsToTypes The map of variables to types
   * @return The result.
   */
  public static Type getVarType(TypeVariable var, Map<String, Type> varsToTypes) {
    Type res = null;
    if (var != null && varsToTypes != null) {
      Type type = varsToTypes.get(var.qualifiedTypeName());
      while (type != null) {
        res = type;
        type = varsToTypes.get(type.qualifiedTypeName());
      }
    }
    return res;
  }
View Full Code Here

TOP

Related Classes of com.sun.javadoc.Type

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.