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


Java ExecutableElement.getKind方法代码示例

本文整理汇总了Java中javax.lang.model.element.ExecutableElement.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableElement.getKind方法的具体用法?Java ExecutableElement.getKind怎么用?Java ExecutableElement.getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.element.ExecutableElement的用法示例。


在下文中一共展示了ExecutableElement.getKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBinaryName

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public static String getBinaryName(ExecutableElement method, CompilationInfo ci) {
    try {
        switch (method.getKind()) {
            case METHOD:
            case CONSTRUCTOR:
            case STATIC_INIT:

                //case INSTANCE_INIT: // not supported
                String paramsVMSignature = getParamsSignature(method.getParameters(), ci);
                String retTypeVMSignature = VMUtils.typeToVMSignature(getRealTypeName(method.getReturnType(), ci));

                return "(" + paramsVMSignature + ")" + retTypeVMSignature; //NOI18N
            default:
                return null;
        }

    } catch (IllegalArgumentException e) {
        ProfilerLogger.warning(e.getMessage());
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ElementUtilitiesEx.java

示例2: methodNameMatch

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
     * Compares the desired textual method name with a name of particualt executable element (method, constructor ...)
     * @param vmName The name to match against. Can be a real method name, "<init>" or "<cinit>"
     * @param ee The executable element to use in matching
     * @return Returns true if the given textual name matches the name of the executable element
     */
    private static boolean methodNameMatch(final String vmName,
            final ExecutableElement ee) {
        switch (ee.getKind()) {
            // for method use textual name matching
            case METHOD:
                return ee.getSimpleName().contentEquals(vmName);

            // for constructor use the special <init> name
            case CONSTRUCTOR:
                return vmName.equals(VM_CONSTRUCTUR_SIG);

            // for initializer use the special <cinit> name
            case STATIC_INIT:
            case INSTANCE_INIT:
                return vmName.equals(VM_INITIALIZER_SIG);
        }

// default fail-over
        return false;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ElementUtilitiesEx.java

示例3: getMethodColoring

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private Collection<ColoringAttributes> getMethodColoring(ExecutableElement mdecl, boolean nct) {
    Collection<ColoringAttributes> c = new ArrayList<ColoringAttributes>();
    
    addModifiers(mdecl, c);
    
    if (mdecl.getKind() == ElementKind.CONSTRUCTOR) {
        c.add(ColoringAttributes.CONSTRUCTOR);

        //#146820:
        if (nct && mdecl.getEnclosingElement() != null && info.getElements().isDeprecated(mdecl.getEnclosingElement())) {
            c.add(ColoringAttributes.DEPRECATED);
        }
    } else
        c.add(ColoringAttributes.METHOD);
    
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SemanticHighlighterBase.java

示例4: isLambdaAnAmbiguousArgument

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private boolean isLambdaAnAmbiguousArgument(ExecutableElement invokingElement, int indexOfLambdaInArgs) {
    
    Element classOfInvokingElement = invokingElement.getEnclosingElement();
    for (Element possibleMatchingElement : info.getElementUtilities().getMembers(classOfInvokingElement.asType(), null)) {

        //ignore invoking element
        if (possibleMatchingElement == invokingElement) {
            continue;
        }

        if (possibleMatchingElement.getKind() != invokingElement.getKind()) {
            continue;
        }

        if (doesInvokingElementMatchFound(invokingElement,
                (ExecutableElement) possibleMatchingElement, indexOfLambdaInArgs)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ConvertToLambdaPreconditionChecker.java

示例5: JavadocExecutableItem

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public JavadocExecutableItem(CompletionItem jmethod,
        ExecutableElement ee, int substitutionOffset) {
    
    this.delegate = jmethod;
    this.substitutionOffset = substitutionOffset;
    
    this.name = ee.getKind() == ElementKind.METHOD
            ? ee.getSimpleName()
            : ee.getEnclosingElement().getSimpleName();
    
    List<? extends VariableElement> params = ee.getParameters();
    this.paramTypes = new String[params.size()];
    int i = 0;
    for (VariableElement p : params) {
        TypeMirror asType = p.asType();
        this.paramTypes[i++] = resolveTypeName(asType, ee.isVarArgs()).toString();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavadocCompletionItem.java

示例6: findExecutableMember

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private ExecutableElement findExecutableMember(TypeElement clazz, String methodName, List<TypeMirror> paramTypes, Types types) {
    List<ExecutableElement> members = methodName.contentEquals(clazz.getSimpleName())
            ? ElementFilter.constructorsIn(clazz.getEnclosedElements())
            : ElementFilter.methodsIn(clazz.getEnclosedElements());
    outer: for (ExecutableElement ee : members) {
        if (ee.getKind() == ElementKind.CONSTRUCTOR || methodName.contentEquals(ee.getSimpleName())) {
            List<? extends TypeMirror> memberParamTypes = ((ExecutableType) ee.asType()).getParameterTypes();
            if (memberParamTypes.size() == paramTypes.size()) {
                Iterator<TypeMirror> it = paramTypes.iterator();
                for (TypeMirror memberParamType : memberParamTypes) {
                    TypeMirror type = it.next();
                    if (types.isSameType(type, memberParamType)) {
                        continue outer;
                    }
                }
                return ee;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaReference.java

示例7: isDefaultConstructor

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
 * Helper method to determine if the given {@link ExecutableElement} refers
 * to a default constructor.
 * 
 * @param element
 * @param trees
 * @return
 */
static boolean isDefaultConstructor(final ExecutableElement element, final Trees trees) {
	// Front-load the cheapest checks to fail quickly

	// Default constructor: no parameters and one statement consisting only of "super();"
	if (element.getKind() != ElementKind.CONSTRUCTOR) {
		return false;
	}

	if (!element.getParameters().isEmpty()) {
		return false;
	}

	final List<? extends StatementTree> statements = trees.getTree(element).getBody().getStatements();
	if (statements.size() != 1) {
		return false;
	}

	return DEFAULT_CTOR_METHOD_BODY_PATTERN.matcher(statements.get(0).toString()).matches();
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:28,代码来源:Util.java

示例8: isTestableMethod

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
 */
private boolean isTestableMethod(ExecutableElement method) {
    if (method.getKind() != ElementKind.METHOD) {
        throw new IllegalArgumentException();
    }

    return setup.isMethodTestable(method);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AbstractTestGenerator.java

示例9: visitExecutable

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Override
public ImmutableSet.Builder<MethodSignature> visitExecutable(final ExecutableElement element, final ImmutableSet.Builder<MethodSignature> builder) {
	if (element.getKind() == ElementKind.METHOD) {
		builder.add(MethodSignature.fromExecutableElementWithSubstitutor(element, Inventory.this::applyTypeSubstitution));
	}
	return builder;
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:8,代码来源:Inventory.java

示例10: createHtmlHeader

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static String createHtmlHeader(boolean deprecated, ExecutableElement e) {
    StringBuilder sb = new StringBuilder();
    sb.append("<html>");
    if (deprecated) sb.append("<s>");
    if (e.getKind() == ElementKind.CONSTRUCTOR) {
        sb.append(e.getEnclosingElement().getSimpleName());
    } else {
        sb.append(e.getSimpleName());
    }
    if (deprecated) sb.append("</s>");
    sb.append("("); // NOI18N
    for(Iterator<? extends VariableElement> it = e.getParameters().iterator(); it.hasNext(); ) {
        VariableElement param = it.next();
        if (!it.hasNext() && e.isVarArgs() && param.asType().getKind() == TypeKind.ARRAY) {
            sb.append(translateToHTML(print(((ArrayType) param.asType()).getComponentType())));
            sb.append("...");
        } else {
            sb.append(translateToHTML(print(param.asType())));
        }
        sb.append(" "); // NOI18N
        sb.append(param.getSimpleName());
        if (it.hasNext()) {
            sb.append(", "); // NOI18N
        }
    }
    sb.append(")"); // NOI18N
    if ( e.getKind() != ElementKind.CONSTRUCTOR ) {
        TypeMirror rt = e.getReturnType();
        if ( rt.getKind() != TypeKind.VOID ) {
            sb.append(" : "); // NOI18N
            sb.append(translateToHTML(print(e.getReturnType())));
        }
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ElementNode.java

示例11: printExecutable

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
Void printExecutable(ExecutableElement e, DeclaredType dt, Boolean highlightName) {
    switch (e.getKind()) {
        case CONSTRUCTOR:
            modifier(e.getModifiers());
            dumpTypeArguments(e.getTypeParameters());
            result.append(' ');
            boldStartCheck(highlightName);
            result.append(e.getEnclosingElement().getSimpleName());
            boldStopCheck(highlightName);
            TypeMirror memberType = null;
            if (dt != null) {
                dumpRealTypeArguments(dt.getTypeArguments());
                try {
                    memberType = info.getTypes().asMemberOf(dt, e);
                } catch (IllegalStateException ise) {}
            }
            if (memberType instanceof ExecutableType) {
                dumpArguments(e.getParameters(), ((ExecutableType) memberType).getParameterTypes());
            } else {
                dumpArguments(e.getParameters(), null);
            }
            dumpThrows(e.getThrownTypes());
            break;
        case METHOD:
            modifier(e.getModifiers());
            dumpTypeArguments(e.getTypeParameters());
            result.append(getTypeName(info, e.getReturnType(), true));
            result.append(' ');
            boldStartCheck(highlightName);
            result.append(e.getSimpleName());
            boldStopCheck(highlightName);
            dumpArguments(e.getParameters(), null);
            dumpThrows(e.getThrownTypes());
            break;
        case INSTANCE_INIT:
        case STATIC_INIT:
            //these two cannot be referenced anyway...
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:GoToSupport.java

示例12: suitableForBuilderConstructor

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
static boolean suitableForBuilderConstructor(ExecutableElement element) {
  return element.getKind() == ElementKind.CONSTRUCTOR
      && !element.getModifiers().contains(Modifier.PRIVATE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:Proto.java

示例13: suitableForBuilderFactory

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
static boolean suitableForBuilderFactory(ExecutableElement element) {
  return element.getKind() == ElementKind.METHOD
      && element.getReturnType().getKind() != TypeKind.VOID
      && !element.getModifiers().contains(Modifier.PRIVATE)
      && element.getModifiers().contains(Modifier.STATIC);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:Proto.java

示例14: getAttributeBuilderDescriptor

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Nullable
@Override
@Derived
public AttributeBuilderDescriptor getAttributeBuilderDescriptor() {
  if (!isAttributeBuilder()) {
    return null;
  }

  ValueToBuilderTarget target;
  ExecutableElement copyMethod = builderModel().copyMethod();
  ExecutableElement builderMethod = builderModel().builderMethod();
  ExecutableElement buildMethod = builderModel().buildMethod();
  TypeElement attributeBuilderType = builderModel().builderType();

  if (copyMethod.getKind() == ElementKind.CONSTRUCTOR) {
    target = ValueToBuilderTarget.BUILDER_CONSTRUCTOR;
  } else if (copyMethod.getModifiers().contains(Modifier.STATIC)) {
    if (copyMethod.getEnclosingElement().equals(attributeValueType())) {
      target = ValueToBuilderTarget.VALUE_TYPE;
    } else {
      target = ValueToBuilderTarget.BUILDER_TYPE;
    }
  } else {
    if (copyMethod.getEnclosingElement().equals(attributeValueType())) {
      target = ValueToBuilderTarget.VALUE_INSTANCE;
    } else {
      target = ValueToBuilderTarget.BUILDER_INSTANCE;
    }
  }

  String qualifiedBuilderConstructorMethod;
  if (builderMethod.getEnclosingElement().equals(attributeValueType())) {
    qualifiedBuilderConstructorMethod = String.format("%s.%s",
        attributeValueType().getQualifiedName(),
        builderMethod.getSimpleName());
  } else {
    if (builderMethod.getKind() == ElementKind.CONSTRUCTOR) {
      qualifiedBuilderConstructorMethod = String.format("new %s",
          attributeBuilderType.getQualifiedName());
    } else {
      qualifiedBuilderConstructorMethod = String.format("%s.%s",
          attributeBuilderType.getQualifiedName(),
          builderMethod.getSimpleName());
    }
  }

  return ImmutableAttributeBuilderDescriptor.builder()
      .valueToBuilderTarget(target)
      .valueToBuilderMethod(copyMethod.getSimpleName().toString())
      .buildMethod(buildMethod.getSimpleName().toString())
      .qualifiedValueTypeName(attributeValueType().getQualifiedName().toString())
      .qualifiedBuilderTypeName(attributeBuilderType.getQualifiedName().toString())
      .qualifiedBuilderConstructorMethod(qualifiedBuilderConstructorMethod)
      .build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:AttributeBuilderReflection.java

示例15: createHtmlHeader

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/** Creates HTML display name of the Executable element */
private String createHtmlHeader(CompilationInfo info, ExecutableElement e, boolean isDeprecated,boolean isInherited, boolean fqn, TypeElement overridenFrom) {

    StringBuilder sb = new StringBuilder();
    if ( isDeprecated ) {
        sb.append("<s>"); // NOI18N
    }
    if( isInherited ) {
        sb.append( "<font color=" + ui.getInheritedColor() + ">" ); // NOI18N
    }
    Name name = e.getKind() == ElementKind.CONSTRUCTOR ? e.getEnclosingElement().getSimpleName() : e.getSimpleName();
    sb.append(Utils.escape(name.toString()));        
    if ( isDeprecated ) {
        sb.append("</s>"); // NOI18N
    }

    sb.append("("); // NOI18N

    List<? extends VariableElement> params = e.getParameters();
    for( Iterator<? extends VariableElement> it = params.iterator(); it.hasNext(); ) {
        VariableElement param = it.next(); 
        sb.append( "<font color=" + ui.getTypeColor() + ">" ); // NOI18N
        final boolean vararg = !it.hasNext() && e.isVarArgs();
        sb.append(printArg(info, param.asType(),vararg, fqn));
        sb.append("</font>"); // NOI18N
        sb.append(" "); // NOI18N
        sb.append(Utils.escape(param.getSimpleName().toString()));
        if ( it.hasNext() ) {
            sb.append(", "); // NOI18N
        }
    }


    sb.append(")"); // NOI18N

    if ( e.getKind() != ElementKind.CONSTRUCTOR ) {
        TypeMirror rt = e.getReturnType();
        if ( rt.getKind() != TypeKind.VOID ) {
            sb.append(" : "); // NOI18N
            sb.append( "<font color=" + ui.getTypeColor() + ">" ); // NOI18N
            sb.append(print(info, e.getReturnType(), fqn));
            sb.append("</font>"); // NOI18N
        }
    }

    if (!isInherited && overridenFrom != null) {
        sb.append(" ↑ ");   //NOI18N
        sb.append(print(info, overridenFrom.asType(), fqn));
    }

    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:ElementScanningTask.java


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