當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodDeclaration.getName方法代碼示例

本文整理匯總了Java中com.github.javaparser.ast.body.MethodDeclaration.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodDeclaration.getName方法的具體用法?Java MethodDeclaration.getName怎麽用?Java MethodDeclaration.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.javaparser.ast.body.MethodDeclaration的用法示例。


在下文中一共展示了MethodDeclaration.getName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MethodNode

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
MethodNode( MethodDeclaration metDec)
{
    super();
    this.metDec = metDec;
    type = metDec.getType();
    if(metDec.isPrivate())
        modifier = "- ";
    else if(metDec.isPublic())
        modifier = "+ ";
    else if(metDec.isProtected())
        modifier = "# ";
    else
        modifier = "~ ";
    nodeName =  modifier + metDec.getName() + "(";
    if (metDec.getParameters() != null)
    {
        parameters = new ArrayList<Parameter>(metDec.getParameters());
        for (Parameter p : parameters)
            nodeName = nodeName + " " + p + ", ";
        if (nodeName.lastIndexOf(',') > 0 )
            nodeName = nodeName.substring(0, nodeName.lastIndexOf(','));
    }
    nodeName = nodeName + ") : " + type.toString();
}
 
開發者ID:bufferhe4d,項目名稱:call-IDE,代碼行數:25,代碼來源:MethodNode.java

示例2: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
public void visit(MethodDeclaration n, Object arg) {

			String name = n.getName();

			if (name.startsWith("set") || name.startsWith("get")) {
				String fieldName = ValueUtil.getIndexLowercase(name.substring(3, name.length()), 0);
				Pair<FieldMeta, Integer> pair = fieldMes.get(fieldName);

				if (pair != null) {
					int count = pair.getValue().intValue() + 1;
					Pair<FieldMeta, Integer> createPair = createPair(pair.getKey(), count);
					fieldMes.put(fieldName, createPair);
				}

			}

			super.visit(n, arg);
		}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:19,代碼來源:VoEditorController.java

示例3: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override
public Node visit(MethodDeclaration _n, Object _arg) {
	JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
	List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
	List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
	Type type_ = cloneNodes(_n.getType(), _arg);
	List<Parameter> parameters = visit(_n.getParameters(), _arg);
	List<ReferenceType> throws_ = visit(_n.getThrows(), _arg);
	BlockStmt block = cloneNodes(_n.getBody(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	MethodDeclaration r = new MethodDeclaration(
			_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
			 _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block
	);
	r.setComment(comment);
	return r;
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:19,代碼來源:CloneVisitor.java

示例4: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override
public Node visit(MethodDeclaration _n, Object _arg) {
	JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
	List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
	List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
	Type type_ = cloneNodes(_n.getType(), _arg);
	List<Parameter> parameters = visit(_n.getParameters(), _arg);
	List<NameExpr> throws_ = visit(_n.getThrows(), _arg);
	BlockStmt block = cloneNodes(_n.getBody(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	MethodDeclaration r = new MethodDeclaration(
			_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
			 _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block
	);
	r.setComment(comment);
	return r;
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:19,代碼來源:CloneVisitor.java

示例5: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
public void visit(MethodDeclaration n, Object arg) {

			String name = n.getName();

//			if (name.startsWith("set") || name.startsWith("get")) {
//				String fieldName = ValueUtil.getIndexLowercase(name.substring(3, name.length()), 0);
//				
//			}

			super.visit(n, arg);
		}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:12,代碼來源:VOEditorParser2.java

示例6: callDelegateCode

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
private String callDelegateCode(MethodDeclaration methodDeclaration, String parameters) {
    if (methodDeclaration.getType() instanceof VoidType) {
        return delegateFieldName + "." + methodDeclaration.getName() + "(" + parameters + ");\n";
    } else {
        return "return " + delegateFieldName + "." + methodDeclaration.getName() + "(" + parameters + ");\n";
    }
}
 
開發者ID:theangrydev,項目名稱:fluent-bdd,代碼行數:8,代碼來源:ThenMethodCodeEmitter.java

示例7: parseMethodInfo

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
public static MethodInfo parseMethodInfo(ClassInfo containedClass, SourceInfo sourceInfo, MethodDeclaration methodDecl) {
//        Log.d(TAG, "method name: %s, returnType: %s", methodDecl.name, methodDecl.getReturnType());
        if (containedClass != null && methodDecl.getType() != null) {
            MethodInfo methodInfo = new MethodInfo();
            
            String methodName = methodDecl.getName();
            methodName = containedClass.getQualifiedName() + "." + methodName;
            Type returnType = TypeParser.parseType(sourceInfo, methodDecl.getType(), methodDecl.getType().toString());
            methodInfo.setMethodName(methodName);
            methodInfo.setReturnType(returnType);
            
            if (methodDecl.getModifiers() != 0) {
                methodInfo.addAllModifiers(Modifier.parseModifiersFromFlags(methodDecl.getModifiers()));
            }
            
            Log.d(TAG, "parseMethodInfo, methodName: %s, returnType: %s", methodName, returnType);
            
            // parse parameters
            if (methodDecl.getParameters() != null && methodDecl.getParameters().size() > 0) {
                for (Parameter parameter : methodDecl.getParameters()) {
                    Type paramType = TypeParser.parseType(sourceInfo, parameter.getType(), parameter.getType().toString());
                    methodInfo.addParamType(paramType);
                    Log.d(TAG, "parseMethodInfo, parameter type: %s", paramType);
                }
            }
            
            // parse annotaion
            if (methodDecl.getAnnotations() != null && methodDecl.getAnnotations().size() > 0) {
                for (AnnotationExpr annotation : methodDecl.getAnnotations()) {
                    AnnotationModifier annotationModifier = AnnotationModifierParser.parseAnnotation(sourceInfo, annotation);
                    methodInfo.putAnnotation(annotationModifier);
                }
            }
            
            return methodInfo;
        }
        
        return null;
    }
 
開發者ID:ragnraok,項目名稱:JParserUtil,代碼行數:40,代碼來源:MethodParser.java

示例8: 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();
    }

}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:56,代碼來源:ASTEnhanced.java


注:本文中的com.github.javaparser.ast.body.MethodDeclaration.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。