本文整理匯總了Java中com.github.javaparser.ast.body.MethodDeclaration.getComment方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodDeclaration.getComment方法的具體用法?Java MethodDeclaration.getComment怎麽用?Java MethodDeclaration.getComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.javaparser.ast.body.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.getComment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override
public void visit(MethodDeclaration n, String arg) {
// here you can access the attributes of the method.
// this method will be called for all methods in this
// CompilationUnit, including inner class methods
int parameterCount;
if (n.getParameters() != null) {
parameterCount = n.getParameters().size();
} else {
parameterCount = 0;
}
String javaDocContent = "";
if (n.getComment() != null && n.getComment().getContent() != null) {
javaDocContent = n.getComment().getContent().replaceAll("\\n *\\* *", "\n ");
}
if (StringUtils.hasText(javaDocContent)) {
javaDoc.setJavaDoc(n.getName(), parameterCount, javaDocContent);
}
}
示例2: visit
import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override
public void visit(final MethodDeclaration n, final Void arg) {
final String signature = n.getDeclarationAsString(false, false);
methods.add(signature);
final Comment c = n.getComment();
if (c instanceof JavadocComment) {
methodJavadoc.put(signature, c.toString());
}
super.visit(n, arg);
}
示例3: buildMethodAST
import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
/**
* The standard factory method to get an enhanced AST from a method
* @param methodDec Method declaration object as per javaparser
* @return An enhanced AST, which can be converted to a JSON
*/
public void buildMethodAST(MethodDeclaration methodDec){
try{
this.text = printAndExtractText(methodDec);
// Get all thrown Exceptions
for(ReferenceType type: methodDec.getThrows()){
this.exceptions.add(type.toString());
}
this.name = methodDec.getName();
Node parent = methodDec.getParentNode();
if (parent instanceof ClassOrInterfaceDeclaration){
this.className = ((ClassOrInterfaceDeclaration) parent).getName();
}
this.modifier = methodDec.getModifiers();
this.returnType = methodDec.getType().toString();
this.paramTypes = getParamTypes(methodDec);
// Get Annotations
for(AnnotationExpr annotExpr: methodDec.getAnnotations()){
this.annotations.add(annotExpr.getName().toString());
}
// If JavaDocs present, extract them
if (methodDec.getJavaDoc() != null){
this.javaDoc = cleanDocumentation(methodDec.getJavaDoc().getContent());
}
this.comments = extractContainedComments(methodDec);
// These are in-line comments just before the method definitition
if (methodDec.getComment() != null){
if (this.comments == null){
this.comments = "";
}
this.comments += methodDec.getComment().getContent();
}
// Recursively loop through child nodes and make a dictionary
this.parseBody(methodDec.getBody());
this.extractHighLevelConcepts();
} catch (Exception ex){
ex.printStackTrace();
}
}