本文整理匯總了Java中com.sun.source.tree.MethodTree.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodTree.getName方法的具體用法?Java MethodTree.getName怎麽用?Java MethodTree.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.source.tree.MethodTree
的用法示例。
在下文中一共展示了MethodTree.getName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import com.sun.source.tree.MethodTree; //導入方法依賴的package包/類
@Override
public List<Fix> run(CompilationInfo compilationInfo, String diagnosticKey, int offset, TreePath treePath, Data<Void> data) {
if (treePath.getLeaf().getKind() == Kind.METHOD) {
MethodTree mt = (MethodTree) treePath.getLeaf();
TreePath parentPath = treePath.getParentPath();
ClassTree ct = (ClassTree) parentPath.getLeaf();
Trees trees = compilationInfo.getTrees();
Types types = compilationInfo.getTypes();
TreeUtilities tu = compilationInfo.getTreeUtilities();
TypeMirror type = types.erasure(trees.getTypeMirror(treePath));
if (!Utilities.isValidType(type)) {
return null;
}
for (Tree member : ct.getMembers()) {
TreePath memberPath = new TreePath(parentPath, member);
if (member.getKind() == Kind.METHOD && "<init>".contentEquals(((MethodTree)member).getName()) //NOI18N
&& !tu.isSynthetic(memberPath) && types.isSameType(types.erasure(trees.getTypeMirror(memberPath)), type)) {
return null;
}
}
RenameConstructorFix fix = new RenameConstructorFix(compilationInfo.getSnapshot().getSource(), TreePathHandle.create(treePath, compilationInfo), offset, mt.getName(), ct.getSimpleName());
return Collections.<Fix>singletonList(fix);
}
return null;
}
示例2: createMethodSignature
import com.sun.source.tree.MethodTree; //導入方法依賴的package包/類
public static String createMethodSignature(MethodTree m, boolean skipName) {
String sign = "";
if (!skipName) {
sign += m.getName();
}
sign += "(";
if (m.getParameters() != null) {
for (VariableTree p : m.getParameters()) {
sign += getShortTypeName(p.getType()) + ",";
}
if (m.getParameters().size() > 0) {
sign = sign.substring(0, sign.length() - 1);
}
}
sign += ")";
return sign;
}