use of org.gradle.build.docs.dsl.source.model.ClassMetaData in project gradle by gradle.
the class JavadocConverter method parse.
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();
}
}
use of org.gradle.build.docs.dsl.source.model.ClassMetaData in project gradle by gradle.
the class TypeNameResolver method resolve.
/**
* Resolves a source type name into a fully qualified type name.
*/
public String resolve(String name, ClassMetaData classMetaData) {
if (primitiveTypes.contains(name)) {
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;
}
for (String importedClass : classMetaData.getImports()) {
String baseName = StringUtils.substringAfterLast(importedClass, ".");
if (baseName.equals("*")) {
candidateClassName = StringUtils.substringBeforeLast(importedClass, ".") + "." + name;
if (metaDataRepository.find(candidateClassName) != null) {
return candidateClassName;
}
if (importedClass.startsWith("java.") && isVisibleSystemClass(candidateClassName)) {
return candidateClassName;
}
} else if (name.equals(baseName)) {
return importedClass;
}
}
candidateClassName = classMetaData.getPackageName() + "." + name;
if (metaDataRepository.find(candidateClassName) != null) {
return candidateClassName;
}
candidateClassName = "java.lang." + name;
if (isVisibleSystemClass(candidateClassName)) {
return candidateClassName;
}
if (classMetaData.isGroovy()) {
candidateClassName = "java.math." + name;
if (groovyImplicitTypes.contains(candidateClassName)) {
return candidateClassName;
}
for (String prefix : groovyImplicitImportPackages) {
candidateClassName = prefix + name;
if (isVisibleSystemClass(candidateClassName)) {
return candidateClassName;
}
}
}
return name;
}
Aggregations