use of org.eclipse.jdt.core.dom.MemberRef in project che by eclipse.
the class JavadocContentAccess2 method handleLink.
private void handleLink(List<? extends ASTNode> fragments) {
//TODO: Javadoc shortens type names to minimal length according to context
int fs = fragments.size();
if (fs > 0) {
Object first = fragments.get(0);
String refTypeName = null;
String refMemberName = null;
String[] refMethodParamTypes = null;
String[] refMethodParamNames = null;
if (first instanceof Name) {
Name name = (Name) first;
refTypeName = name.getFullyQualifiedName();
} else if (first instanceof MemberRef) {
MemberRef memberRef = (MemberRef) first;
Name qualifier = memberRef.getQualifier();
//$NON-NLS-1$
refTypeName = qualifier == null ? "" : qualifier.getFullyQualifiedName();
refMemberName = memberRef.getName().getIdentifier();
} else if (first instanceof MethodRef) {
MethodRef methodRef = (MethodRef) first;
Name qualifier = methodRef.getQualifier();
//$NON-NLS-1$
refTypeName = qualifier == null ? "" : qualifier.getFullyQualifiedName();
refMemberName = methodRef.getName().getIdentifier();
List<MethodRefParameter> params = methodRef.parameters();
int ps = params.size();
refMethodParamTypes = new String[ps];
refMethodParamNames = new String[ps];
for (int i = 0; i < ps; i++) {
MethodRefParameter param = params.get(i);
refMethodParamTypes[i] = ASTNodes.asString(param.getType());
SimpleName paramName = param.getName();
if (paramName != null)
refMethodParamNames[i] = paramName.getIdentifier();
}
}
if (refTypeName != null) {
//$NON-NLS-1$
fBuf.append("<a href='");
try {
String scheme = urlPrefix;
String uri = JavaElementLinks.createURI(scheme, fElement, refTypeName, refMemberName, refMethodParamTypes);
fBuf.append(uri);
} catch (URISyntaxException e) {
LOG.error(e.getMessage(), e);
}
//$NON-NLS-1$
fBuf.append("'>");
if (fs > 1 && !(fs == 2 && isWhitespaceTextElement(fragments.get(1)))) {
handleContentElements(fragments.subList(1, fs), true);
} else {
fBuf.append(refTypeName);
if (refMemberName != null) {
if (refTypeName.length() > 0) {
fBuf.append('.');
}
fBuf.append(refMemberName);
if (refMethodParamTypes != null) {
fBuf.append('(');
for (int i = 0; i < refMethodParamTypes.length; i++) {
String pType = refMethodParamTypes[i];
fBuf.append(pType);
String pName = refMethodParamNames[i];
if (pName != null) {
fBuf.append(' ').append(pName);
}
if (i < refMethodParamTypes.length - 1) {
//$NON-NLS-1$
fBuf.append(", ");
}
}
fBuf.append(')');
}
}
}
//$NON-NLS-1$
fBuf.append("</a>");
} else {
handleContentElements(fragments);
}
}
}
use of org.eclipse.jdt.core.dom.MemberRef in project che by eclipse.
the class DelegateFieldCreator method createDocReference.
@Override
protected ASTNode createDocReference(BodyDeclaration declaration) {
MemberRef ref = getAst().newMemberRef();
ref.setName(getAst().newSimpleName(getNewElementName()));
if (isMoveToAnotherFile())
ref.setQualifier(createDestinationTypeName());
return ref;
}
Aggregations