use of com.sun.javadoc.MethodDoc in project RESTdoclet by IG-Group.
the class DocletUtils method getPublicFields.
/**
* Return a list of all fields that have a public getter
*
* @param classDoc class documentation
* @return list of all fields that have a public getter
*/
public static Collection<FieldParameter> getPublicFields(final ClassDoc classDoc) {
ArrayList<FieldParameter> fields = new ArrayList<FieldParameter>();
MethodDoc[] methods = classDoc.methods();
for (FieldDoc fieldDoc : classDoc.fields(false)) {
boolean found = false;
for (MethodDoc md : methods) {
if (md.name().equalsIgnoreCase(GETTER_PREFIX + fieldDoc.name())) {
found = true;
}
}
if (found) {
fields.add(new FieldParameterBuilder().build(new FieldParameter(), fieldDoc));
}
}
return fields;
}
use of com.sun.javadoc.MethodDoc in project Orchid by JavaEden.
the class ClassDocParser method getClassMethods.
public JSONArray getClassMethods(ClassDoc classDoc) {
JSONArray methods = new JSONArray();
for (MethodDoc mDoc : classDoc.methods()) {
JSONObject method = new JSONObject();
method.put("comment", commentParser.getCommentObject(mDoc));
method.put("annotations", annotationParser.getAnnotations(mDoc));
method.put("returns", typeParser.getTypeObject(mDoc.returnType()));
method.put("parameters", parameterParser.getParameters(mDoc));
method.put("name", mDoc.name());
methods.put(method);
}
return methods;
}
use of com.sun.javadoc.MethodDoc in project jdk8u_jdk by JetBrains.
the class RemoteClass method findImplMethod.
/**
* Returns the MethodDoc for the method of this remote
* implementation class that implements the specified remote
* method of a remote interface. Returns null if no matching
* method was found in this remote implementation class.
**/
private MethodDoc findImplMethod(MethodDoc interfaceMethod) {
String name = interfaceMethod.name();
String desc = Util.methodDescriptorOf(interfaceMethod);
for (MethodDoc implMethod : implClass.methods()) {
if (name.equals(implMethod.name()) && desc.equals(Util.methodDescriptorOf(implMethod))) {
return implMethod;
}
}
return null;
}
use of com.sun.javadoc.MethodDoc 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.MethodDoc in project wso2-axis2-transports by wso2.
the class ResourceInfoDoclet method start.
public static boolean start(RootDoc root) throws IOException {
parseOptions(root.options());
ResourceInfo resourceInfo = new ResourceInfo();
for (ClassDoc clazz : root.classes()) {
Resource resource = null;
for (MethodDoc method : clazz.methods()) {
if (getAnnotation(method, "org.apache.axis2.transport.testkit.tests.Setup") != null) {
if (resource == null) {
resource = new Resource(clazz.qualifiedName());
}
ParamTag[] paramTags = method.paramTags();
for (Parameter parameter : method.parameters()) {
Type type = parameter.type();
String name = parameter.name();
String comment = null;
for (ParamTag paramTag : paramTags) {
if (paramTag.parameterName().equals(name)) {
comment = paramTag.parameterComment();
break;
}
}
if (comment == null) {
comment = getFirstSentence(root.classNamed(type.qualifiedTypeName()));
}
resource.addDependency(type.qualifiedTypeName(), type.dimension().equals("[]") ? "0..*" : "1", comment);
}
}
}
if (resource != null) {
resourceInfo.addResource(resource);
}
}
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outFile));
out.writeObject(resourceInfo);
out.close();
return true;
}
Aggregations