本文整理汇总了Java中jdk.jshell.MethodSnippet.signature方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSnippet.signature方法的具体用法?Java MethodSnippet.signature怎么用?Java MethodSnippet.signature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.jshell.MethodSnippet
的用法示例。
在下文中一共展示了MethodSnippet.signature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import jdk.jshell.MethodSnippet; //导入方法依赖的package包/类
public static Key create(Snippet snip) {
switch (snip.kind()) {
case IMPORT:
ImportSnippet imp = ((ImportSnippet)snip);
return new Key("I_" + imp.fullname() + (imp.isStatic() ? "*" : ""));
case TYPE_DECL:
TypeDeclSnippet tdecl = ((TypeDeclSnippet)snip);
return new Key("T_" + tdecl.name());
case METHOD:
MethodSnippet method = ((MethodSnippet)snip);
return new Key("M_" + method.name() + ":" + method.signature());
case VAR:
VarSnippet var = (VarSnippet)snip;
return new Key("V_" + var.name() + ":" + var.typeName());
case EXPRESSION:
ExpressionSnippet expr = (ExpressionSnippet)snip;
return new Key("E_" + (expr.name()) + ":" + (expr.typeName()));
case STATEMENT:
case ERRONEOUS:
return new Key("C_" + snip.source());
default:
throw new AssertionError(snip.kind().name());
}
}
示例2: getMemberInfo
import jdk.jshell.MethodSnippet; //导入方法依赖的package包/类
public MemberInfo getMemberInfo(Snippet key) {
SubKind subkind = key.subKind();
switch (subkind) {
case CLASS_SUBKIND:
case INTERFACE_SUBKIND:
case ENUM_SUBKIND:
case ANNOTATION_TYPE_SUBKIND:
return new MemberInfo(subkind.name(), ((DeclarationSnippet) key).name());
case METHOD_SUBKIND:
MethodSnippet method = (MethodSnippet) key;
return new MemberInfo(method.signature(), method.name());
case VAR_DECLARATION_SUBKIND:
case VAR_DECLARATION_WITH_INITIALIZER_SUBKIND:
case TEMP_VAR_EXPRESSION_SUBKIND:
VarSnippet var = (VarSnippet) key;
return new MemberInfo(var.typeName(), var.name());
default:
throw new AssertionError("Unknown snippet : " + key.kind() + " in expression " + key.toString());
}
}
示例3: assertMethodDeclSnippet
import jdk.jshell.MethodSnippet; //导入方法依赖的package包/类
public void assertMethodDeclSnippet(MethodSnippet method,
String expectedName, String expectedSignature,
Status expectedStatus, int unressz, int othersz) {
assertDeclarationSnippet(method, expectedName, expectedStatus,
METHOD_SUBKIND, unressz, othersz);
String signature = method.signature();
assertEquals(signature, expectedSignature,
"Expected " + method.source() + " to have the name: " +
expectedSignature + ", got: " + signature);
}