本文整理汇总了Java中jdk.jshell.MethodSnippet.name方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSnippet.name方法的具体用法?Java MethodSnippet.name怎么用?Java MethodSnippet.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.jshell.MethodSnippet
的用法示例。
在下文中一共展示了MethodSnippet.name方法的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: N
import jdk.jshell.MethodSnippet; //导入方法依赖的package包/类
public N(JShellEnvironment env, SnippetHandle handle) {
super(Children.LEAF,
Lookups.fixed(
env,
handle,
env,
env.getConsoleFile()
)
);
this.snipHandle = handle;
this.env = env;
Snippet.Kind k = handle.getKind();
switch (k) {
case TYPE_DECL:
nodeKind = ElementKind.CLASS;
break;
case METHOD:
nodeKind = ElementKind.METHOD;
break;
case VAR:
nodeKind = ElementKind.FIELD;
break;
default:
throw new IllegalArgumentException();
}
Snippet s = handle.getSnippet();
String dispName = null;
switch (s.kind()) {
case TYPE_DECL:
dispName = handle.text();
break;
case METHOD: {
MethodSnippet m = (MethodSnippet)s;
dispName = m.name() + "(" + m.parameterTypes() + ")"; // NOI18N
htmlDisplayName = m.name() + "(<font color=\"" +
getHtmlColor(typeColor, DEFAULT_TYPE_COLOR) + "\">"+
m.parameterTypes() +
"</font>)";
break;
}
case VAR: {
VarSnippet v = (VarSnippet)s;
dispName = v.name() + " : " + v.typeName(); // NOI18N
htmlDisplayName = v.name() + " : <font color=\"" +
getHtmlColor(typeColor, DEFAULT_TYPE_COLOR) + "\">"+
v.typeName() +
"</font>";
dispName = handle.text();
break;
}
default:
throw new AssertionError(s.kind().name());
}
if (htmlDisplayName == null) {
htmlDisplayName = dispName;
}
setDisplayName(dispName);
}