Java 类com.intellij.openapi.util.VolatileNotNullLazyValue 实例源码

项目:intellij-ce-playground    文件:GdkMethodDslProvider.java   
private static void processCategoryMethods(final String className, final GdslMembersHolderConsumer consumer, final boolean isStatic) {
  final GlobalSearchScope scope = consumer.getResolveScope();
  final PsiClass categoryClass = GroovyPsiManager.getInstance(consumer.getProject()).findClassWithCache(className, scope);
  if (categoryClass == null) {
    return;
  }

  final VolatileNotNullLazyValue<GdkMethodHolder> methodsMap = new VolatileNotNullLazyValue<GdkMethodHolder>() {
    @NotNull
    @Override
    protected GdkMethodHolder compute() {
      return GdkMethodHolder.getHolderForClass(categoryClass, isStatic, scope);
    }
  };

  consumer.addMemberHolder(new CustomMembersHolder() {

    @Override
    public boolean processMembers(GroovyClassDescriptor descriptor, PsiScopeProcessor processor, ResolveState state) {
      return methodsMap.getValue().processMethods(processor, state, descriptor.getPsiType(), descriptor.getProject());
    }
  });
}
项目:tools-idea    文件:GdkMethodDslProvider.java   
private static void processCategoryMethods(final String className, final GdslMembersHolderConsumer consumer, final boolean isStatic) {
  final GlobalSearchScope scope = consumer.getResolveScope();
  final PsiClass categoryClass = GroovyPsiManager.getInstance(consumer.getProject()).findClassWithCache(className, scope);
  if (categoryClass == null) {
    return;
  }

  final VolatileNotNullLazyValue<GdkMethodHolder> methodsMap = new VolatileNotNullLazyValue<GdkMethodHolder>() {
    @NotNull
    @Override
    protected GdkMethodHolder compute() {
      return GdkMethodHolder.getHolderForClass(categoryClass, isStatic, scope);
    }
  };

  consumer.addMemberHolder(new CustomMembersHolder() {

    @Override
    public boolean processMembers(GroovyClassDescriptor descriptor, PsiScopeProcessor processor, ResolveState state) {
      return methodsMap.getValue().processMethods(processor, state, descriptor.getPsiType(), descriptor.getProject());
    }
  });
}
项目:intellij-ce-playground    文件:GdkMethodHolder.java   
private GdkMethodHolder(final PsiClass categoryClass, final boolean isStatic, final GlobalSearchScope scope) {
  myStatic = isStatic;
  myScope = scope;
  final MultiMap<String, PsiMethod> byName = new MultiMap<String, PsiMethod>();
  myPsiManager = categoryClass.getManager();
  for (PsiMethod m : categoryClass.getMethods()) {
    final PsiParameter[] params = m.getParameterList().getParameters();
    if (params.length == 0) continue;
    if (PsiUtil.isDGMMethod(m) && (PsiImplUtil.isDeprecatedByAnnotation(m) || PsiImplUtil.isDeprecatedByDocTag(m))) {
      continue;
    }
    byName.putValue(m.getName(), m);
  }
  this.myOriginalMethodByType = new VolatileNotNullLazyValue<MultiMap<String, PsiMethod>>() {
    @NotNull
    @Override
    protected MultiMap<String, PsiMethod> compute() {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.values()) {
        if (!method.hasModifierProperty(PsiModifier.PUBLIC)) continue;
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };

  myOriginalMethodsByNameAndType = new ConcurrentFactoryMap<String, MultiMap<String, PsiMethod>>() {
    @Override
    protected MultiMap<String, PsiMethod> create(String name) {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.get(name)) {
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };
}
项目:tools-idea    文件:GdkMethodHolder.java   
private GdkMethodHolder(final PsiClass categoryClass, final boolean isStatic, final GlobalSearchScope scope) {
  myStatic = isStatic;
  myScope = scope;
  final MultiMap<String, PsiMethod> byName = new MultiMap<String, PsiMethod>();
  myPsiManager = categoryClass.getManager();
  for (PsiMethod m : categoryClass.getMethods()) {
    final PsiParameter[] params = m.getParameterList().getParameters();
    if (params.length == 0) continue;

    byName.putValue(m.getName(), m);
  }
  this.myOriginalMethodByType = new VolatileNotNullLazyValue<MultiMap<String, PsiMethod>>() {
    @NotNull
    @Override
    protected MultiMap<String, PsiMethod> compute() {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.values()) {
        if (!method.hasModifierProperty(PsiModifier.PUBLIC)) continue;
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };

  myOriginalMethodsByNameAndType = new ConcurrentFactoryMap<String, MultiMap<String, PsiMethod>>() {
    @Override
    protected MultiMap<String, PsiMethod> create(String name) {
      MultiMap<String, PsiMethod> map = new MultiMap<String, PsiMethod>();
      for (PsiMethod method : byName.get(name)) {
        map.putValue(getCategoryTargetType(method).getCanonicalText(), method);
      }
      return map;
    }
  };
}