use of com.sun.javadoc.Type in project Orchid by JavaEden.
the class TypeParser method getTypeObject.
public JSONObject getTypeObject(Type type) {
if (type == null) {
return null;
}
JSONObject typeObject = new JSONObject();
typeObject.put("name", type.typeName());
typeObject.put("qualifiedName", type.qualifiedTypeName());
typeObject.put("dimension", type.dimension());
if (type.asClassDoc() != null && type.asClassDoc().containingPackage() != null) {
typeObject.put("package", type.asClassDoc().containingPackage().name());
}
if (type.asParameterizedType() != null) {
typeObject.put("typeParameters", new JSONArray());
for (Type typeParameter : type.asParameterizedType().typeArguments()) {
JSONObject nestedType = getTypeObject(typeParameter);
typeObject.getJSONArray("typeParameters").put(nestedType);
}
}
if (type.asWildcardType() != null) {
typeObject.put("wildcardType", new JSONObject());
if (type.asWildcardType().extendsBounds().length > 0) {
typeObject.getJSONObject("wildcardType").put("extends", new JSONArray());
for (Type typeParameter : type.asWildcardType().extendsBounds()) {
JSONObject nestedType = getTypeObject(typeParameter);
typeObject.getJSONObject("wildcardType").getJSONArray("extends").put(nestedType);
}
}
if (type.asWildcardType().superBounds().length > 0) {
typeObject.getJSONObject("wildcardType").put("super", new JSONArray());
for (Type typeParameter : type.asWildcardType().superBounds()) {
JSONObject nestedType = getTypeObject(typeParameter);
typeObject.getJSONObject("wildcardType").getJSONArray("super").put(nestedType);
}
}
}
return typeObject;
}
use of com.sun.javadoc.Type in project jdk8u_jdk by JetBrains.
the class StubSkeletonWriter method writeSkeletonDispatchCase.
/**
* Writes the case block for the skeleton's dispatch method for
* the remote method with the given "opnum".
**/
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum) throws IOException {
RemoteClass.Method method = remoteMethods[opnum];
MethodDoc methodDoc = method.methodDoc();
String methodName = methodDoc.name();
Type[] paramTypes = method.parameterTypes();
String[] paramNames = nameParameters(paramTypes);
Type returnType = methodDoc.returnType();
p.pOlnI("case " + opnum + ": // " + Util.getFriendlyUnqualifiedSignature(methodDoc));
/*
* Use nested block statement inside case to provide an independent
* namespace for local variables used to unmarshal parameters for
* this remote method.
*/
p.pOlnI("{");
if (paramTypes.length > 0) {
/*
* Declare local variables to hold arguments.
*/
for (int i = 0; i < paramTypes.length; i++) {
p.pln(paramTypes[i].toString() + " " + paramNames[i] + ";");
}
/*
* Unmarshal arguments from call stream.
*/
p.plnI("try {");
p.pln("java.io.ObjectInput in = call.getInputStream();");
boolean objectsRead = writeUnmarshalArguments(p, "in", paramTypes, paramNames);
p.pOlnI("} catch (java.io.IOException e) {");
p.pln("throw new " + UNMARSHAL_EXCEPTION + "(\"error unmarshalling arguments\", e);");
/*
* If any only if readObject has been invoked, we must catch
* ClassNotFoundException as well as IOException.
*/
if (objectsRead) {
p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
p.pln("throw new " + UNMARSHAL_EXCEPTION + "(\"error unmarshalling arguments\", e);");
}
p.pOlnI("} finally {");
p.pln("call.releaseInputStream();");
p.pOln("}");
} else {
p.pln("call.releaseInputStream();");
}
if (!Util.isVoid(returnType)) {
/*
* Declare variable to hold return type, if not void.
*/
p.p(returnType.toString() + " $result = ");
// REMIND: why $?
}
/*
* Invoke the method on the server object. If the remote
* implementation class is private, then we don't have a
* reference cast to it, and so we try to cast to the remote
* object reference to the method's declaring interface here.
*/
String target = remoteClass.classDoc().isPrivate() ? "((" + methodDoc.containingClass().qualifiedName() + ") obj)" : "server";
p.p(target + "." + methodName + "(");
for (int i = 0; i < paramNames.length; i++) {
if (i > 0)
p.p(", ");
p.p(paramNames[i]);
}
p.pln(");");
/*
* Always invoke getResultStream(true) on the call object to send
* the indication of a successful invocation to the caller. If
* the return type is not void, keep the result stream and marshal
* the return value.
*/
p.plnI("try {");
if (!Util.isVoid(returnType)) {
p.p("java.io.ObjectOutput out = ");
}
p.pln("call.getResultStream(true);");
if (!Util.isVoid(returnType)) {
writeMarshalArgument(p, "out", returnType, "$result");
p.pln(";");
}
p.pOlnI("} catch (java.io.IOException e) {");
p.pln("throw new " + MARSHAL_EXCEPTION + "(\"error marshalling return\", e);");
p.pOln("}");
// break from switch statement
p.pln("break;");
// end nested block statement
p.pOlnI("}");
p.pln();
}
use of com.sun.javadoc.Type in project jdk8u_jdk by JetBrains.
the class Util method getFriendlyUnqualifiedSignature.
/**
* Returns a reader-friendly string representation of the
* specified method's signature. Names of reference types are not
* package-qualified.
**/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
String sig = method.name() + "(";
Parameter[] parameters = method.parameters();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) {
sig += ", ";
}
Type paramType = parameters[i].type();
sig += paramType.typeName() + paramType.dimension();
}
sig += ")";
return sig;
}
use of com.sun.javadoc.Type in project h2database by h2database.
the class Doclet method skipMethod.
private boolean skipMethod(ExecutableMemberDoc method) {
ClassDoc clazz = method.containingClass();
boolean isAbstract = method instanceof MethodDoc && ((MethodDoc) method).isAbstract();
boolean isInterface = clazz.isInterface() || (clazz.isAbstract() && isAbstract);
if (INTERFACES_ONLY && !isInterface) {
return true;
}
String name = method.name();
if (method.isPrivate() || name.equals("finalize")) {
return true;
}
if (method.isConstructor() && method.getRawCommentText().trim().length() == 0) {
return true;
}
if (method.getRawCommentText().trim().startsWith("@deprecated INTERNAL")) {
return true;
}
String firstSentence = getFirstSentence(method.firstSentenceTags());
String raw = method.getRawCommentText();
if (firstSentence != null && firstSentence.startsWith("INTERNAL")) {
return true;
}
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");
boolean enumValueMethod = name.equals("values") || name.equals("valueOf");
if (!setterOrGetter && !enumValueMethod) {
addError("Undocumented method " + " (" + getLink(clazz, method.position().line()) + ") " + clazz + "." + name + " " + raw);
return true;
}
}
}
return false;
}
use of com.sun.javadoc.Type in project com.revolsys.open by revolsys.
the class BaseDoclet method getMemberId.
protected String getMemberId(final ExecutableMemberDoc member) {
final StringBuilder id = new StringBuilder();
final ClassDoc classDoc = member.containingClass();
final String classId = getClassId(classDoc);
id.append(classId);
id.append(".");
final String memberName = member.name();
id.append(memberName);
final Parameter[] parameters = member.parameters();
for (final Parameter parameter : parameters) {
id.append("-");
final Type type = parameter.type();
String typeName = type.qualifiedTypeName();
typeName = typeName.replaceAll("^java.lang.", "");
typeName = typeName.replaceAll("^java.io.", "");
typeName = typeName.replaceAll("^java.util.", "");
id.append(typeName);
id.append(type.dimension());
}
return id.toString().replaceAll("[^A-Za-z0-9\\-_.]", "_");
}
Aggregations