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


Java MethodDeclaration.getNameAsString方法代碼示例

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


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

示例1: index

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
public void index(MethodDeclaration methodDeclaration, int typeId) {
    List<Parameter> parameters = methodDeclaration.getParameters();
    String name = methodDeclaration.getNameAsString();
    int methodId = methodDao.save(new Method(name,
            methodDeclaration.isPublic(), methodDeclaration.isStatic(), methodDeclaration.isFinal(), methodDeclaration.isAbstract(), false, typeId));
    for (Parameter parameter : parameters) {
        parameterIndexer.index(parameter, methodId);
    }
}
 
開發者ID:benas,項目名稱:jql,代碼行數:10,代碼來源:MethodIndexer.java

示例2: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
/**
 * Check if method & method variables is in camelCase, not in underscore_case,
 * since in Java we use camelCase naming convention
 *
 * @param declaration
 * @param collector
 */
@Override
public void visit(MethodDeclaration declaration, Collector collector) {

    methodName = declaration.getNameAsString();

    if (Config.METHOD_IN_CAMEL_CASE) {
        if (methodName.contains("_")) {
            collector.addWarning(className, "Method \"" + methodName + "\"  should be in 'camelCase', not in 'underscore_case'");

        } else if (!methodName.matches("^[a-z][a-zA-Z0-9]*$")) {
            collector.addWarning(className, "Method \"" + methodName + "\"  should be in 'camelCase', not in 'underscore_case'");
        }
    }

    if (Config.PARAM_IN_CAMEL_CASE) {
        for (Parameter param: declaration.getParameters()) {

            if (param.getNameAsString().contains("_")) {

                collector.addWarning(className, "Method \"" + methodName + "\" variable \"" + param.getName() +"\" should be in 'camelCase', not in 'underscore_case'");

            }

        }
    }


    super.visit(declaration, collector);

}
 
開發者ID:sakalauskas,項目名稱:Java-Static-Analyzer,代碼行數:38,代碼來源:VariableNamingConventionVisitor.java

示例3: visit

import com.github.javaparser.ast.body.MethodDeclaration; //導入方法依賴的package包/類
/**
 * Before visiting any method, mark the method name, so we could collect it later.
 *
 * @param declaration
 * @param counter
 */
public void visit(MethodDeclaration declaration, ComplexityCounter counter) {

    methodName = declaration.getNameAsString();

    super.visit(declaration, counter);
}
 
開發者ID:sakalauskas,項目名稱:Java-Static-Analyzer,代碼行數:13,代碼來源:ClassComplexityVisitor.java


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