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


Java ExecutableElement.getSimpleName方法代码示例

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


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

示例1: isMethodDeclaredByInterface

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
 * Checks whether the interface declare given method
 *
 * @param trgInterface interface to be declaring the method
 * @param srcMethod method to be declared
 * @return {@code true} if the method is declared by the interface, {@code false} otherwise
 */
private static boolean isMethodDeclaredByInterface(TypeElement trgInterface, ExecutableElement srcMethod) {
    List<? extends Element> enclosedElements = trgInterface.getEnclosedElements();
    List<? extends VariableElement> methodParameters = srcMethod.getParameters();
    for (Element enclosedElement : enclosedElements) {
        if (enclosedElement instanceof ExecutableElement) {
            ExecutableElement exElement = (ExecutableElement) enclosedElement;
            List<? extends VariableElement> elementParameters = exElement.getParameters();
            if (srcMethod.getSimpleName() != exElement.getSimpleName()
                    || (methodParameters.size() != elementParameters.size())) {
                continue;
            }
            for (int i = 0; i < methodParameters.size(); i++) {
                if (!((VariableElement) methodParameters.get(i)).asType().toString().equals(
                        ((VariableElement) elementParameters.get(i)).asType().toString())) {
                    continue;
                }
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:AbstractTestGenerator.java

示例2: isMethodDeclaredByInterface

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
 * Checks whether the interface declare given method
 *
 * @param trgInterface interface to be declaring the method
 * @param srcMethod method to be declared
 * @return {@literal true} if the method is declared by the interface, {@literal false} otherwise
 */
private static boolean isMethodDeclaredByInterface(TypeElement trgInterface, ExecutableElement srcMethod) {
    List<? extends Element> enclosedElements = trgInterface.getEnclosedElements();
    List<? extends VariableElement> methodParameters = srcMethod.getParameters();
    for (Element enclosedElement : enclosedElements) {
        if (enclosedElement instanceof ExecutableElement) {
            ExecutableElement exElement = (ExecutableElement) enclosedElement;
            List<? extends VariableElement> elementParameters = exElement.getParameters();
            if (srcMethod.getSimpleName() != exElement.getSimpleName()
                    || (methodParameters.size() != elementParameters.size())) {
                continue;
            }
            for (int i = 0; i < methodParameters.size(); i++) {
                if (!((VariableElement) methodParameters.get(i)).asType().toString().equals(
                        ((VariableElement) elementParameters.get(i)).asType().toString())) {
                    continue;
                }
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:AbstractTestGenerator.java

示例3: isSystemExit

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
 * Determines if the element corresponds to never-returning, terminating method.
 * System.exit, Runtime.exit, Runtime.halt are checked. The passed element is
 * usually a result of {@code CompilationInfo.getTrees().getElement(path)}.
 * 
 * @param info context
 * @param e element to check
 * @return true, if the element corrresponds to a VM-exiting method
 */
public static boolean isSystemExit(CompilationInfo info, Element e) {
    if (e == null || e.getKind() != ElementKind.METHOD) {
        return false;
    }
    ExecutableElement ee = (ExecutableElement)e;
    Name n = ee.getSimpleName();
    if (n.contentEquals("exit") || n.contentEquals("halt")) { // NOI18N
        TypeElement tel = info.getElementUtilities().enclosingTypeElement(e);
        if (tel == null) {
            return false;
        }
        Name ofqn = tel.getQualifiedName();
        if (ofqn.contentEquals("java.lang.System") || ofqn.contentEquals("java.lang.Runtime")) { // NOI18N
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:Utilities.java

示例4: 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

示例5: TimedMethodModel

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
TimedMethodModel(ModelContext ctx, ExecutableElement method, TimeThis annotation) throws ModelException {
	this.annotation = annotation;
	this.method = method;
	this.scope = getScope(method);
	String msg = "method " + method.getSimpleName() + " in " + method.getEnclosingElement();
	List<? extends VariableElement> params = method.getParameters();
	if (params.isEmpty()) {
		throw new ModelException(msg + ": expected at least one " + ProcessingContext.class.getCanonicalName() + " parameter");
	}
	boolean first = true;
	for (VariableElement param : params) {
		TypeMirror paramType = param.asType();
		if (first) {
			if (!ctx.isProcessingContext(paramType)) {
				throw new ModelException(msg + ": first parameter must be of type " + ProcessingContext.class.getCanonicalName());
			}
			first = false;
			continue;
		}
		checkPublicType(ctx, paramType, method, false, msg);
	}
	TypeMirror returnType = method.getReturnType();
	checkPublicType(ctx, returnType, method, true, msg);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:25,代码来源:TimedMethodModel.java

示例6: makeOverrideMethod

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private MethodSpec makeOverrideMethod(ExecutableElement method) {
    TypeName requestTypeName = getRequestClassName(method);
    DeclaredType responseReturnType = (DeclaredType) method.getReturnType();
    TypeMirror responseBean = responseReturnType.getTypeArguments().get(0);


    MethodSpec.Builder request = MethodSpec.methodBuilder(method.getSimpleName().toString())
            .returns(ParameterizedTypeName.get(ClassName.get(Response.class), ClassName.get(responseBean)))
            .addModifiers(Modifier.PUBLIC)
            .addAnnotation(Override.class);

    String initializeStatement = "return new " + processorElement.simpleName() + "_" + method.getSimpleName();
    if (!method.getParameters().isEmpty()) {
        request.addParameter(requestTypeName, "request");
        request.addStatement(initializeStatement + "(request)");
    } else
        request.addStatement(initializeStatement + "($T.VOID_REQUEST)", RequestBean.class);


    return request.build();
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:22,代码来源:RequestFactorySourceWriter.java

示例7: jniMethodName

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected final String jniMethodName(ExecutableElement method, String cname,
                                     boolean longName)
            throws TypeSignature.SignatureException {
    String res = "Java_" + cname + "_" + method.getSimpleName();

    if (longName) {
        TypeMirror mType =  types.erasure(method.getReturnType());
        List<? extends VariableElement> params = method.getParameters();
        List<TypeMirror> argTypes = new ArrayList<>();
        for (VariableElement param: params) {
            argTypes.add(types.erasure(param.asType()));
        }

        res = res + "__";
        for (TypeMirror t: argTypes) {
            String tname = t.toString();
            TypeSignature newTypeSig = new TypeSignature(elems);
            String sig = newTypeSig.getTypeSignature(tname);
            res = res + nameToIdentifier(sig);
        }
    }
    return res;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:LLNI.java

示例8: toException

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Nonnull
private ArezProcessorException toException( @Nonnull final String name,
                                            @Nonnull final String sourceAnnotationName,
                                            @Nonnull final ExecutableElement sourceMethod,
                                            @Nonnull final String targetAnnotationName,
                                            @Nonnull final ExecutableElement targetElement )
{
  return new ArezProcessorException( "Method annotated with @" + ProcessorUtil.toSimpleName( sourceAnnotationName ) +
                                     " specified name " + name + " that duplicates @" +
                                     ProcessorUtil.toSimpleName( targetAnnotationName ) + " defined by method " +
                                     targetElement.getSimpleName(), sourceMethod );
}
 
开发者ID:arez,项目名称:arez,代码行数:13,代码来源:ComponentDescriptor.java

示例9: OnClickMethod

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public OnClickMethod(Element element) throws IllegalArgumentException {
    // 判断是否是方法
    if (element.getKind() != ElementKind.METHOD) {
        throw new IllegalArgumentException(String.format("Only method can be annotated with @%s", onClickClassName));
    }
    ExecutableElement methodElement = (ExecutableElement) element;
    // 获取方法名
    onClickMethodName = methodElement.getSimpleName();
    mParamsList = methodElement.getParameters();
    // 获取注解的值
    mResIds = new ArrayList<>();
    for (int mResId : methodElement.getAnnotation(OnClick.class).value()) {
        mResIds.add(mResId);
    }
}
 
开发者ID:wangzailfm,项目名称:ImitateButterKnife,代码行数:16,代码来源:OnClickMethod.java

示例10: twoParameterBody

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private String twoParameterBody(ExecutableElement element, String className) {
    Name methodName = element.getSimpleName();
    String typeCastOne = element.getParameters().get(0).asType().toString();
    String typeCastTwo = element.getParameters().get(1).asType().toString();
    return bodyPrefix(methodName, className)
            + "((" + typeCastOne + ")o1, (" + typeCastTwo + ")o2)" + END_LINE +
            bodyPostfix(methodName, className);
}
 
开发者ID:Ahmed-Adel-Ismail,项目名称:CommandsMap,代码行数:9,代码来源:CommandMapGenerator.java

示例11: needLongName

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected final boolean needLongName(ExecutableElement method,
                                     TypeElement clazz) {
    Name methodName = method.getSimpleName();
    for (ExecutableElement memberMethod: methods) {
        if ((memberMethod != method) &&
            memberMethod.getModifiers().contains(Modifier.NATIVE) &&
                (methodName.equals(memberMethod.getSimpleName())))
            return true;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:LLNI.java

示例12: write

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public void write(OutputStream o, TypeElement clazz) throws Util.Exit {
    try {
        String cname = mangler.mangle(clazz.getQualifiedName(), Mangle.Type.CLASS);
        PrintWriter pw = wrapWriter(o);
        pw.println(guardBegin(cname));
        pw.println(cppGuardBegin());

        /* Write statics. */
        List<VariableElement> classfields = getAllFields(clazz);

        for (VariableElement v: classfields) {
            if (!v.getModifiers().contains(Modifier.STATIC))
                continue;
            String s = null;
            s = defineForStatic(clazz, v);
            if (s != null) {
                pw.println(s);
            }
        }

        /* Write methods. */
        List<ExecutableElement> classmethods = ElementFilter.methodsIn(clazz.getEnclosedElements());
        for (ExecutableElement md: classmethods) {
            if(md.getModifiers().contains(Modifier.NATIVE)){
                TypeMirror mtr = types.erasure(md.getReturnType());
                String sig = signature(md);
                TypeSignature newtypesig = new TypeSignature(elems);
                CharSequence methodName = md.getSimpleName();
                boolean longName = false;
                for (ExecutableElement md2: classmethods) {
                    if ((md2 != md)
                        && (methodName.equals(md2.getSimpleName()))
                        && (md2.getModifiers().contains(Modifier.NATIVE)))
                        longName = true;

                }
                pw.println("/*");
                pw.println(" * Class:     " + cname);
                pw.println(" * Method:    " +
                           mangler.mangle(methodName, Mangle.Type.FIELDSTUB));
                pw.println(" * Signature: " + newtypesig.getTypeSignature(sig, mtr));
                pw.println(" */");
                pw.println("JNIEXPORT " + jniType(mtr) +
                           " JNICALL " +
                           mangler.mangleMethod(md, clazz,
                                               (longName) ?
                                               Mangle.Type.METHOD_JNI_LONG :
                                               Mangle.Type.METHOD_JNI_SHORT));
                pw.print("  (JNIEnv *, ");
                List<? extends VariableElement> paramargs = md.getParameters();
                List<TypeMirror> args = new ArrayList<TypeMirror>();
                for (VariableElement p: paramargs) {
                    args.add(types.erasure(p.asType()));
                }
                if (md.getModifiers().contains(Modifier.STATIC))
                    pw.print("jclass");
                else
                    pw.print("jobject");

                for (TypeMirror arg: args) {
                    pw.print(", ");
                    pw.print(jniType(arg));
                }
                pw.println(");" + lineSep);
            }
        }
        pw.println(cppGuardEnd());
        pw.println(guardEnd(cname));
    } catch (TypeSignature.SignatureException e) {
        util.error("jni.sigerror", e.getMessage());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:73,代码来源:JNI.java

示例13: writeMethods

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected void writeMethods(Writer out, ClassSymbol sym, String cname)
        throws IOException, TypeSignature.SignatureException {
    List<ExecutableElement> classmethods = ElementFilter.methodsIn(sym.getEnclosedElements());
    for (ExecutableElement md: classmethods) {
        if(md.getModifiers().contains(Modifier.NATIVE)){
            TypeMirror mtr = types.erasure(md.getReturnType());
            String sig = signature(md);
            TypeSignature newtypesig = new TypeSignature(elements);
            CharSequence methodName = md.getSimpleName();
            boolean longName = false;
            for (ExecutableElement md2: classmethods) {
                if ((md2 != md)
                    && (methodName.equals(md2.getSimpleName()))
                    && (md2.getModifiers().contains(Modifier.NATIVE)))
                    longName = true;

            }
            println(out, "/*");
            println(out, " * Class:     " + cname);
            println(out, " * Method:    " +
                       mangler.mangle(methodName, Mangle.Type.FIELDSTUB));
            println(out, " * Signature: " + newtypesig.getTypeSignature(sig, mtr));
            println(out, " */");
            println(out, "JNIEXPORT " + jniType(mtr) +
                       " JNICALL " +
                       mangler.mangleMethod(md, sym,
                                           (longName) ?
                                           Mangle.Type.METHOD_JNI_LONG :
                                           Mangle.Type.METHOD_JNI_SHORT));
            print(out, "  (JNIEnv *, ");
            List<? extends VariableElement> paramargs = md.getParameters();
            List<TypeMirror> args = new ArrayList<TypeMirror>();
            for (VariableElement p: paramargs) {
                args.add(types.erasure(p.asType()));
            }
            if (md.getModifiers().contains(Modifier.STATIC))
                print(out, "jclass");
            else
                print(out, "jobject");

            for (TypeMirror arg: args) {
                print(out, ", ");
                print(out, jniType(arg));
            }
            println(out, ");"
                    + lineSep);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:JNIWriter.java

示例14: methodToString

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public String methodToString(ExecutableElement method) {
    StringBuilder buf = new StringBuilder(method.getSimpleName());
    for (VariableElement param : method.getParameters())
        buf.append(';').append(param.asType());
    return buf.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:AnnotationProcessorContext.java

示例15: processUtilityCandidateMethod

import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private void processUtilityCandidateMethod(ExecutableElement utilityMethodCandidate, TypeElement originalType) {
  Name name = utilityMethodCandidate.getSimpleName();
  List<? extends VariableElement> parameters = utilityMethodCandidate.getParameters();

  TypeElement definingType = (TypeElement) utilityMethodCandidate.getEnclosingElement();
  boolean nonFinal = !utilityMethodCandidate.getModifiers().contains(Modifier.FINAL);
  boolean nonAbstract = !utilityMethodCandidate.getModifiers().contains(Modifier.ABSTRACT);

  if (definingType.getQualifiedName().contentEquals(Object.class.getName())) {
    // We ignore methods of java.lang.Object
    return;
  }

  if (name.contentEquals(EQUALS_METHOD)
      && parameters.size() == 1
      && parameters.get(0).asType().toString().equals(Object.class.getName())) {

    if (nonAbstract) {
      type.isEqualToDefined = true;

      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits overriden 'equals' method but have some non-inherited attributes."
                + " Please override 'equals' with abstract method to have it generate. Otherwise override"
                + " with calling super implemtation to use custom implementation");
      }
    }
    return;
  }

  if (name.contentEquals(HASH_CODE_METHOD)
      && parameters.isEmpty()) {
    if (nonAbstract) {
      type.isHashCodeDefined = true;

      // inherited non-abstract implementation
      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits non-default 'hashCode' method but have some non-inherited attributes."
                + " Please override 'hashCode' with abstract method to have it generated. Otherwise override"
                + " with calling super implemtation to use custom implementation");
      }
    }
    return;
  }

  if (name.contentEquals(TO_STRING_METHOD)
      && parameters.isEmpty()) {
    if (nonAbstract) {
      type.isToStringDefined = true;

      // inherited non-abstract implementation
      if (!definingType.equals(originalType) && hasNonInheritedAttributes && nonFinal) {
        report(originalType)
            .warning("Type inherits non-default 'toString' method but have some non-inherited attributes."
                + " Please override 'toString' with abstract method to have generate it. Otherwise override"
                + " with calling super implementation to use custom implementation");
      }
    }
    return;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:63,代码来源:AccessorAttributesCollector.java


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