Search in sources :

Example 1 with ASMReflector

use of meghanada.reflect.asm.ASMReflector in project meghanada-server by mopemope.

the class MemberCacheLoader method loadFromReflector.

private List<MemberDescriptor> loadFromReflector(String fqcn) {
    final String initName = ClassNameUtils.getSimpleName(fqcn);
    final ASMReflector asmReflector = ASMReflector.getInstance();
    Map<String, ClassIndex> index = CachedASMReflector.getInstance().getGlobalClassIndex();
    final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
    final List<MemberDescriptor> result = asmReflector.reflectAll(info);
    return result.stream().filter(md -> {
        if (md.matchType(CandidateUnit.MemberType.CONSTRUCTOR)) {
            final String name = ClassNameUtils.getSimpleName(md.getName());
            return name.equals(initName);
        }
        return true;
    }).collect(Collectors.toList());
}
Also used : ClassName(meghanada.utils.ClassName) Stopwatch(com.google.common.base.Stopwatch) FunctionUtils.wrapIOConsumer(meghanada.utils.FunctionUtils.wrapIOConsumer) InheritanceInfo(meghanada.reflect.asm.InheritanceInfo) Map(java.util.Map) CandidateUnit(meghanada.reflect.CandidateUnit) Objects.isNull(java.util.Objects.isNull) FunctionUtils.wrapIO(meghanada.utils.FunctionUtils.wrapIO) RemovalNotification(com.google.common.cache.RemovalNotification) ClassIndex(meghanada.reflect.ClassIndex) IOException(java.io.IOException) ProjectDatabaseHelper(meghanada.store.ProjectDatabaseHelper) CachedASMReflector(meghanada.reflect.asm.CachedASMReflector) Collectors(java.util.stream.Collectors) File(java.io.File) CacheLoader(com.google.common.cache.CacheLoader) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Logger(org.apache.logging.log4j.Logger) RemovalCause(com.google.common.cache.RemovalCause) ClassNameUtils(meghanada.utils.ClassNameUtils) Optional(java.util.Optional) RemovalListener(com.google.common.cache.RemovalListener) ASMReflector(meghanada.reflect.asm.ASMReflector) Objects.nonNull(java.util.Objects.nonNull) Collections(java.util.Collections) Config(meghanada.config.Config) LogManager(org.apache.logging.log4j.LogManager) ClassIndex(meghanada.reflect.ClassIndex) InheritanceInfo(meghanada.reflect.asm.InheritanceInfo) MemberDescriptor(meghanada.reflect.MemberDescriptor) CachedASMReflector(meghanada.reflect.asm.CachedASMReflector) ASMReflector(meghanada.reflect.asm.ASMReflector)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 CacheLoader (com.google.common.cache.CacheLoader)1 RemovalCause (com.google.common.cache.RemovalCause)1 RemovalListener (com.google.common.cache.RemovalListener)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 File (java.io.File)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects.isNull (java.util.Objects.isNull)1 Objects.nonNull (java.util.Objects.nonNull)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Config (meghanada.config.Config)1 CandidateUnit (meghanada.reflect.CandidateUnit)1 ClassIndex (meghanada.reflect.ClassIndex)1 MemberDescriptor (meghanada.reflect.MemberDescriptor)1 ASMReflector (meghanada.reflect.asm.ASMReflector)1 CachedASMReflector (meghanada.reflect.asm.CachedASMReflector)1