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


Java MethodDeclaration.setName方法代碼示例

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


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

示例1: doMerge

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override public MethodDeclaration doMerge(MethodDeclaration first, MethodDeclaration second) {

    MethodDeclaration md = new MethodDeclaration();
    md.setName(first.getName());
    md.setType(mergeSingle(first.getType(), second.getType()));
    md.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc()));
    md.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers()));

    md.setDefault(first.isDefault() || second.isDefault());
    md.setArrayCount(Math.max(first.getArrayCount(), second.getArrayCount()));

    md.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));

    md.setThrows(mergeListNoDuplicate(first.getThrows(), second.getThrows(), false));
    md.setParameters(mergeCollectionsInOrder(first.getParameters(), second.getParameters()));
    md.setTypeParameters(mergeCollectionsInOrder(first.getTypeParameters(), second.getTypeParameters()));

    md.setBody(mergeSingle(first.getBody(), second.getBody()));

    return md;
  }
 
開發者ID:beihaifeiwu,項目名稱:dolphin,代碼行數:22,代碼來源:MethodDeclarationMerger.java

示例2: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
@Override
public void visit(MethodDeclaration n, Object arg) {
    // change the name of the method to upper case
    n.setName(n.getName().toUpperCase());

    // create the new parameter
    Parameter newArg = ASTHelper.createParameter(ASTHelper.INT_TYPE, "value");

    // add the parameter to the method
    ASTHelper.addParameter(n, newArg);
}
 
開發者ID:bingoohuang,項目名稱:javacode-demo,代碼行數:12,代碼來源:MethodChanger.java

示例3: changeMethod

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
private static void changeMethod(MethodDeclaration n) {
    // change the name of the method to upper case
    n.setName(n.getName().toUpperCase());

    // create the new parameter
    Parameter newArg = ASTHelper.createParameter(ASTHelper.INT_TYPE, "value");

    // add the parameter to the method
    ASTHelper.addParameter(n, newArg);
}
 
開發者ID:bingoohuang,項目名稱:javacode-demo,代碼行數:11,代碼來源:MethodChangerWithoutVisitor.java

示例4: addMethod

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
/**
 * Adds a methods with void return by default to this
 *
 * @param methodName the method name
 * @param modifiers the modifiers like {@link Modifier#PUBLIC}
 * @return the {@link MethodDeclaration} created
 */
default MethodDeclaration addMethod(String methodName, Modifier... modifiers) {
    MethodDeclaration methodDeclaration = new MethodDeclaration();
    methodDeclaration.setName(methodName);
    methodDeclaration.setType(VOID_TYPE);
    methodDeclaration.setModifiers(Arrays.stream(modifiers)
            .collect(toCollection(() -> EnumSet.noneOf(Modifier.class))));
    getMembers().add(methodDeclaration);
    methodDeclaration.setParentNode((Node) this);
    return methodDeclaration;
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:18,代碼來源:NodeWithMembers.java


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