Package org.gradle.build.docs.dsl.source.model

Examples of org.gradle.build.docs.dsl.source.model.ClassMetaData


    }

    public DocComment parse(final PropertyMetaData propertyMetaData, final GenerationListener listener) {
        listener.start(String.format("property %s", propertyMetaData));
        try {
            ClassMetaData ownerClass = propertyMetaData.getOwnerClass();
            String rawCommentText = propertyMetaData.getRawCommentText();
            try {
                CommentSource commentSource = new InheritedPropertyCommentSource(propertyMetaData, listener);
                DocCommentImpl docComment = parse(rawCommentText, ownerClass, commentSource, listener);
                adjustGetterComment(docComment);
                return docComment;
            } catch (Exception e) {
                throw new GradleException(String.format("Could not convert javadoc comment to docbook.%nClass: %s%nProperty: %s%nComment: %s", ownerClass.getClassName(), propertyMetaData.getName(), rawCommentText), e);
            }
        } finally {
            listener.finish();
        }
    }
View Full Code Here


    }

    public DocComment parse(final MethodMetaData methodMetaData, final GenerationListener listener) {
        listener.start(String.format("method %s", methodMetaData));
        try {
            ClassMetaData ownerClass = methodMetaData.getOwnerClass();
            String rawCommentText = methodMetaData.getRawCommentText();
            try {
                CommentSource commentSource = new InheritedMethodCommentSource(listener, methodMetaData);
                return parse(rawCommentText, ownerClass, commentSource, listener);
            } catch (Exception e) {
                throw new GradleException(String.format(
                        "Could not convert javadoc comment to docbook.%nClass: %s%nMethod: %s%nComment: %s",
                        ownerClass.getClassName(), methodMetaData.getSignature(), rawCommentText), e);
            }
        } finally {
            listener.finish();
        }
    }
View Full Code Here

        }
        if (matcher.group(2) == null) {
            return linkRenderer.link(new TypeMetaData(className), listener);
        }

        ClassMetaData targetClass;
        if (className != null) {
            targetClass = repository.find(className);
            if (targetClass == null) {
                return null;
            }
        } else {
            targetClass = classMetaData;
        }

        String methodSignature = matcher.group(3);
        if (matcher.group(5) != null) {
            StringBuilder signature = new StringBuilder();
            signature.append(methodSignature);
            signature.append("(");
            if (matcher.group(5).length() > 0) {
                String[] types = PARAM_DELIMITER.split(matcher.group(5));
                for (int i = 0; i < types.length; i++) {
                    String type = types[i];
                    Matcher typeMatcher = TYPE_PATTERN.matcher(type);
                    if (!typeMatcher.matches()) {
                        return null;
                    }
                    if (i > 0) {
                        signature.append(", ");
                    }
                    signature.append(typeNameResolver.resolve(typeMatcher.group(1), classMetaData));
                    String suffix = typeMatcher.group(2);
                    if (suffix.equals("...")) {
                        suffix = "[]";
                    }
                    signature.append(suffix);
                }
            }
            signature.append(")");
            methodSignature = signature.toString();
        }

        if (targetClass.isEnum() && targetClass.getEnumConstant(methodSignature) != null) {
            return linkRenderer.link(targetClass.getEnumConstant(methodSignature), listener);
        }

        MethodMetaData method = findMethod(methodSignature, targetClass);
        if (method == null) {
            return null;
View Full Code Here

    /**
     * Converts a javadoc value link into docbook.
     */
    public Node resolveValue(String fieldName, ClassMetaData classMetaData, GenerationListener listener) {
        String[] parts = fieldName.split("#");
        ClassMetaData targetClass;
        if (parts[0].length() > 0) {
            String targetClassName = typeNameResolver.resolve(parts[0], classMetaData);
            targetClass = repository.find(targetClassName);
            if (targetClass == null) {
                listener.warning(String.format("Could not locate target class '%s' for field value link '%s'", targetClass, fieldName));
                Element element = document.createElement("UNHANDLED-VALUE");
                element.appendChild(document.createTextNode(targetClassName + ":" + parts[1]));
                return element;
            }
        } else {
            targetClass = classMetaData;
        }

        String value = targetClass.getConstants().get(parts[1]);
        if (value == null) {
            listener.warning(String.format("Field '%s' does not have any value", fieldName));
            Element element = document.createElement("NO-VALUE-FOR_FIELD");
            element.appendChild(document.createTextNode(targetClass.getClassName() + ":" + parts[1]));
            return element;
        }

        return createLiteralNode(value);
    }
View Full Code Here

            return name;
        }

        String candidateClassName;
        String[] innerNames = name.split("\\.");
        ClassMetaData pos = classMetaData;
        for (int i = 0; i < innerNames.length; i++) {
            String innerName = innerNames[i];
            candidateClassName = pos.getClassName() + '.' + innerName;
            if (!pos.getInnerClassNames().contains(candidateClassName)) {
                break;
            }
            if (i == innerNames.length - 1) {
                return candidateClassName;
            }
            pos = metaDataRepository.get(candidateClassName);
        }

        String outerClassName = classMetaData.getOuterClassName();
        while (outerClassName != null) {
            if (name.equals(StringUtils.substringAfterLast(outerClassName, "."))) {
                return outerClassName;
            }
            ClassMetaData outerClass = metaDataRepository.get(outerClassName);
            candidateClassName = outerClassName + '.' + name;
            if (outerClass.getInnerClassNames().contains(candidateClassName)) {
                return candidateClassName;
            }
            outerClassName = outerClass.getOuterClassName();
        }

        if (name.contains(".")) {
            return name;
        }
View Full Code Here

    /**
     * Builds and attaches the supertypes of the given class
     */
    void build(ClassDoc classDoc) {
        ClassMetaData classMetaData = classDoc.getClassMetaData();
        String superClassName = classMetaData.getSuperClassName();
        if (superClassName != null) {
            // Assume this is a class and so has implemented all properties and methods somewhere in the superclass hierarchy
            ClassDoc superClass = model.getClassDoc(superClassName);
            classDoc.setSuperClass(superClass);
        }

        List<String> interfaceNames = classMetaData.getInterfaceNames();
        for (String interfaceName : interfaceNames) {
            ClassDoc superInterface = model.findClassDoc(interfaceName);
            if (superInterface != null) {
                classDoc.getInterfaces().add(superInterface);
            }
View Full Code Here

TOP

Related Classes of org.gradle.build.docs.dsl.source.model.ClassMetaData

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.