当前位置: 首页>>代码示例>>Java>>正文


Java MethodSnippet.name方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SnippetRegistry.java

示例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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:KullaTesting.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:62,代码来源:SnippetNodes.java


注:本文中的jdk.jshell.MethodSnippet.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。