本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例12: suitableForBuilderConstructor
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
static boolean suitableForBuilderConstructor(ExecutableElement element) {
return element.getKind() == ElementKind.CONSTRUCTOR
&& !element.getModifiers().contains(Modifier.PRIVATE);
}
示例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);
}
示例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();
}
示例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();
}