本文整理匯總了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);
}
}
示例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);
}
示例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);
}