Search in sources :

Example 1 with MethodParameter

use of meghanada.reflect.MethodParameter in project meghanada-server by mopemope.

the class MethodAnalyzeVisitor method toMemberDescriptor.

private void toMemberDescriptor() {
    String modifier = ASMReflector.toModifier(this.access, this.hasDefault);
    if (this.interfaceMethod) {
        modifier = ClassNameUtils.replace(modifier, "abstract", "").trim();
    }
    final CandidateUnit.MemberType memberType = name.equals("<init>") ? CandidateUnit.MemberType.CONSTRUCTOR : CandidateUnit.MemberType.METHOD;
    final String methodName = memberType == CandidateUnit.MemberType.CONSTRUCTOR ? this.classAnalyzeVisitor.className : this.name;
    final EntryMessage message = log.traceEntry("className={} memberType={} methodName={} returnType={}", this.classAnalyzeVisitor.className, methodName, memberType, this.returnType);
    if (methodName.startsWith("lambda$")) {
        // skip
        log.traceExit(message);
        return;
    }
    if (memberType == CandidateUnit.MemberType.CONSTRUCTOR && methodName.equals(ClassNameUtils.OBJECT_CLASS)) {
        // skip
        log.traceExit(message);
        return;
    }
    final String returnFQCN = memberType == CandidateUnit.MemberType.CONSTRUCTOR ? methodName : this.returnType.getFQCN();
    final List<MethodParameter> methodParameters = this.parameterTypes.stream().map(typeInfo -> new MethodParameter(typeInfo.getFQCN(), typeInfo.paramName)).collect(Collectors.toList());
    final MethodDescriptor descriptor = new MethodDescriptor(this.classAnalyzeVisitor.className, methodName, modifier, methodParameters, this.exceptions, returnFQCN, this.hasDefault, memberType);
    descriptor.setTypeParameters(this.typeParameters);
    log.trace("formalType={}", this.formalType);
    if (this.formalType != null) {
        descriptor.formalType = this.formalType.toString();
    }
    this.classAnalyzeVisitor.members.add(descriptor);
    log.traceExit(message);
}
Also used : AnnotationVisitor(org.objectweb.asm.AnnotationVisitor) MethodVisitor(org.objectweb.asm.MethodVisitor) Label(org.objectweb.asm.Label) Type(org.objectweb.asm.Type) ParameterName(meghanada.reflect.names.ParameterName) ArrayList(java.util.ArrayList) Serializer(meghanada.store.Serializer) Map(java.util.Map) CandidateUnit(meghanada.reflect.CandidateUnit) Attribute(org.objectweb.asm.Attribute) Opcodes(org.objectweb.asm.Opcodes) MethodDescriptor(meghanada.reflect.MethodDescriptor) MoreObjects(com.google.common.base.MoreObjects) Set(java.util.Set) SignatureReader(org.objectweb.asm.signature.SignatureReader) Collectors(java.util.stream.Collectors) EntryMessage(org.apache.logging.log4j.message.EntryMessage) MethodParameter(meghanada.reflect.MethodParameter) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TypePath(org.objectweb.asm.TypePath) ClassNameUtils(meghanada.utils.ClassNameUtils) LogManager(org.apache.logging.log4j.LogManager) InputStream(java.io.InputStream) MethodParameterNames(meghanada.reflect.names.MethodParameterNames) CandidateUnit(meghanada.reflect.CandidateUnit) MethodParameter(meghanada.reflect.MethodParameter) EntryMessage(org.apache.logging.log4j.message.EntryMessage) MethodDescriptor(meghanada.reflect.MethodDescriptor)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CandidateUnit (meghanada.reflect.CandidateUnit)1 MethodDescriptor (meghanada.reflect.MethodDescriptor)1 MethodParameter (meghanada.reflect.MethodParameter)1 MethodParameterNames (meghanada.reflect.names.MethodParameterNames)1 ParameterName (meghanada.reflect.names.ParameterName)1 Serializer (meghanada.store.Serializer)1 ClassNameUtils (meghanada.utils.ClassNameUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 EntryMessage (org.apache.logging.log4j.message.EntryMessage)1 AnnotationVisitor (org.objectweb.asm.AnnotationVisitor)1 Attribute (org.objectweb.asm.Attribute)1 Label (org.objectweb.asm.Label)1