Java 类com.intellij.psi.impl.PsiCachedValueImpl 实例源码

项目:intellij-ce-playground    文件:XmlDocumentImpl.java   
@Override
public XmlNSDescriptor getDefaultNSDescriptor(final String namespace, final boolean strict) {
  long curExtResourcesModCount = ExternalResourceManagerEx.getInstanceEx().getModificationCount(getProject());
  if (myExtResourcesModCount != curExtResourcesModCount) {
    myDefaultDescriptorsCacheNotStrict.clear();
    myDefaultDescriptorsCacheStrict.clear();
    myExtResourcesModCount = curExtResourcesModCount;
  }

  final ConcurrentMap<String, CachedValue<XmlNSDescriptor>> defaultDescriptorsCache;
  if (strict) {
    defaultDescriptorsCache = myDefaultDescriptorsCacheStrict;
  }
  else {
    defaultDescriptorsCache = myDefaultDescriptorsCacheNotStrict;
  }

  CachedValue<XmlNSDescriptor> cachedValue = defaultDescriptorsCache.get(namespace);
  if (cachedValue == null) {
    defaultDescriptorsCache.put(namespace, cachedValue = new PsiCachedValueImpl<XmlNSDescriptor>(getManager(), new CachedValueProvider<XmlNSDescriptor>() {
      @Override
      public Result<XmlNSDescriptor> compute() {
        final XmlNSDescriptor defaultNSDescriptorInner = getDefaultNSDescriptorInner(namespace, strict);

        if (isGeneratedFromDtd(defaultNSDescriptorInner)) {
          return new Result<XmlNSDescriptor>(defaultNSDescriptorInner, XmlDocumentImpl.this, ExternalResourceManager.getInstance());
        }

        return new Result<XmlNSDescriptor>(defaultNSDescriptorInner, defaultNSDescriptorInner != null
                                                                     ? defaultNSDescriptorInner.getDependences()
                                                                     : ExternalResourceManager.getInstance());
      }
    }));
  }
  return cachedValue.getValue();
}
项目:intellij-ce-playground    文件:AntBuildModelImpl.java   
public AntBuildModelImpl(final AntBuildFile buildFile) {
  myFile = buildFile;
  final Project project = myFile.getProject();

  myTargets = new PsiCachedValueImpl<List<AntBuildTargetBase>>(PsiManager.getInstance(project), new CachedValueProvider<List<AntBuildTargetBase>>() {
    public Result<List<AntBuildTargetBase>> compute() {
      final Pair<List<AntBuildTargetBase>, Collection<Object>> result = getTargetListImpl(AntBuildModelImpl.this);
      final Collection<Object> deps = result.getSecond();
      return Result.create(result.getFirst(), ArrayUtil.toObjectArray(deps));
    }
  });    
}
项目:tools-idea    文件:XmlDocumentImpl.java   
public XmlNSDescriptor getDefaultNSDescriptor(final String namespace, final boolean strict) {
  long curExtResourcesModCount = ExternalResourceManagerEx.getInstanceEx().getModificationCount(getProject());
  if (myExtResourcesModCount != curExtResourcesModCount) {
    myDefaultDescriptorsCacheNotStrict.clear();
    myDefaultDescriptorsCacheStrict.clear();
    myExtResourcesModCount = curExtResourcesModCount;
  }

  final ConcurrentHashMap<String, CachedValue<XmlNSDescriptor>> defaultDescriptorsCache;
  if (strict) {
    defaultDescriptorsCache = myDefaultDescriptorsCacheStrict;
  }
  else {
    defaultDescriptorsCache = myDefaultDescriptorsCacheNotStrict;
  }

  CachedValue<XmlNSDescriptor> cachedValue = defaultDescriptorsCache.get(namespace);
  if (cachedValue == null) {
    defaultDescriptorsCache.put(namespace, cachedValue = new PsiCachedValueImpl<XmlNSDescriptor>(getManager(), new CachedValueProvider<XmlNSDescriptor>() {
      public Result<XmlNSDescriptor> compute() {
        final XmlNSDescriptor defaultNSDescriptorInner = getDefaultNSDescriptorInner(namespace, strict);

        if (isGeneratedFromDtd(defaultNSDescriptorInner)) {
          return new Result<XmlNSDescriptor>(defaultNSDescriptorInner, XmlDocumentImpl.this, ExternalResourceManager.getInstance());
        }

        return new Result<XmlNSDescriptor>(defaultNSDescriptorInner, defaultNSDescriptorInner != null
                                                                     ? defaultNSDescriptorInner.getDependences()
                                                                     : ExternalResourceManager.getInstance());
      }
    }));
  }
  return cachedValue.getValue();
}
项目:tools-idea    文件:AntBuildModelImpl.java   
public AntBuildModelImpl(final AntBuildFile buildFile) {
  myFile = buildFile;
  final Project project = myFile.getProject();

  myTargets = new PsiCachedValueImpl<List<AntBuildTargetBase>>(PsiManager.getInstance(project), new CachedValueProvider<List<AntBuildTargetBase>>() {
    public Result<List<AntBuildTargetBase>> compute() {
      final Pair<List<AntBuildTargetBase>, Collection<PsiFile>> result = getTargetListImpl(AntBuildModelImpl.this);
      final Collection<PsiFile> deps = result.getSecond();
      return Result.create(result.getFirst(), PsiUtilCore.toPsiFileArray(deps));
    }
  });    
}
项目:consulo-apache-ant    文件:AntBuildModelImpl.java   
public AntBuildModelImpl(final AntBuildFile buildFile) {
  myFile = buildFile;
  final Project project = myFile.getProject();

  myTargets = new PsiCachedValueImpl<List<AntBuildTargetBase>>(PsiManager.getInstance(project), new CachedValueProvider<List<AntBuildTargetBase>>() {
    public Result<List<AntBuildTargetBase>> compute() {
      final Pair<List<AntBuildTargetBase>, Collection<PsiFile>> result = getTargetListImpl(AntBuildModelImpl.this);
      final Collection<PsiFile> deps = result.getSecond();
      return Result.create(result.getFirst(), PsiUtilCore.toPsiFileArray(deps));
    }
  });    
}
项目:consulo-xml    文件:XmlDocumentImpl.java   
@Override
public XmlNSDescriptor getDefaultNSDescriptor(final String namespace, final boolean strict)
{
    long curExtResourcesModCount = ExternalResourceManagerEx.getInstanceEx().getModificationCount(getProject());
    if(myExtResourcesModCount != curExtResourcesModCount)
    {
        myDefaultDescriptorsCacheNotStrict.clear();
        myDefaultDescriptorsCacheStrict.clear();
        myExtResourcesModCount = curExtResourcesModCount;
    }

    final ConcurrentMap<String, CachedValue<XmlNSDescriptor>> defaultDescriptorsCache;
    if(strict)
    {
        defaultDescriptorsCache = myDefaultDescriptorsCacheStrict;
    }
    else
    {
        defaultDescriptorsCache = myDefaultDescriptorsCacheNotStrict;
    }

    CachedValue<XmlNSDescriptor> cachedValue = defaultDescriptorsCache.get(namespace);
    if(cachedValue == null)
    {
        defaultDescriptorsCache.put(namespace, cachedValue = new PsiCachedValueImpl<>(getManager(), () ->
        {
            final XmlNSDescriptor defaultNSDescriptorInner = getDefaultNSDescriptorInner(namespace, strict);

            if(isGeneratedFromDtd(defaultNSDescriptorInner))
            {
                return new CachedValueProvider.Result<>(defaultNSDescriptorInner, this, ExternalResourceManager.getInstance());
            }

            return new CachedValueProvider.Result<>(defaultNSDescriptorInner, defaultNSDescriptorInner != null ? defaultNSDescriptorInner.getDependences() : ExternalResourceManager.getInstance
                    ());
        }));
    }
    return cachedValue.getValue();
}