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


Java ConcurrentHashMap类代码示例

本文整理汇总了Java中com.intellij.util.containers.ConcurrentHashMap的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentHashMap类的具体用法?Java ConcurrentHashMap怎么用?Java ConcurrentHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: findPackage

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
@Override
public PsiPackage findPackage(@NotNull String qualifiedName) {
  SoftReference<ConcurrentMap<String, PsiPackage>> ref = myPackageCache;
  ConcurrentMap<String, PsiPackage> cache = ref == null ? null : ref.get();
  if (cache == null) {
    myPackageCache = new SoftReference<ConcurrentMap<String, PsiPackage>>(cache = new ConcurrentHashMap<String, PsiPackage>());
  }

  PsiPackage aPackage = cache.get(qualifiedName);
  if (aPackage != null) {
    return aPackage;
  }

  for (PsiElementFinder finder : filteredFinders()) {
    aPackage = finder.findPackage(qualifiedName);
    if (aPackage != null) {
      return ConcurrencyUtil.cacheOrGet(cache, qualifiedName, aPackage);
    }
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:JavaPsiFacadeImpl.java

示例2: findClassWithCache

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
@Nullable
public PsiClass findClassWithCache(@NotNull String fqName, @NotNull GlobalSearchScope resolveScope) {
  SoftReference<Map<GlobalSearchScope, PsiClass>> reference = myClassCache.get(fqName);
  Map<GlobalSearchScope, PsiClass> map = reference == null ? null : reference.get();
  if (map == null) {
    map = new ConcurrentHashMap<GlobalSearchScope, PsiClass>();
    myClassCache.put(fqName, new SoftReference<Map<GlobalSearchScope, PsiClass>>(map));
  }
  PsiClass cached = map.get(resolveScope);
  if (cached != null) {
    return cached;
  }

  PsiClass result = JavaPsiFacade.getInstance(myProject).findClass(fqName, resolveScope);
  if (result != null) {
    map.put(resolveScope, result);
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GroovyPsiManager.java

示例3: BuildTargetTypeState

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public BuildTargetTypeState(BuildTargetType<?> targetType, BuildTargetsState state) {
  myTargetType = targetType;
  myTargetsState = state;
  myTargetsFile = new File(state.getDataPaths().getTargetTypeDataRoot(targetType), "targets.dat");
  myConfigurations = new ConcurrentHashMap<BuildTarget<?>, BuildTargetConfiguration>();
  myTargetIds = new HashMap<BuildTarget<?>, Integer>();
  load();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:BuildTargetTypeState.java

示例4: BuildRootIndexImpl

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public BuildRootIndexImpl(BuildTargetIndex targetIndex, JpsModel model, ModuleExcludeIndex index,
                          BuildDataPaths dataPaths, final IgnoredFileIndex ignoredFileIndex) {
  myIgnoredFileIndex = ignoredFileIndex;
  myRootsByTarget = new HashMap<BuildTarget<?>, List<? extends BuildRootDescriptor>>();
  myRootToDescriptors = new THashMap<File, List<BuildRootDescriptor>>(FileUtil.FILE_HASHING_STRATEGY);
  myFileFilters = new ConcurrentHashMap<BuildRootDescriptor, FileFilter>();
  final Iterable<AdditionalRootsProviderService> rootsProviders = JpsServiceManager.getInstance().getExtensions(AdditionalRootsProviderService.class);
  for (BuildTargetType<?> targetType : TargetTypeRegistry.getInstance().getTargetTypes()) {
    for (BuildTarget<?> target : targetIndex.getAllTargets(targetType)) {
      addRoots(dataPaths, rootsProviders, target, model, index, ignoredFileIndex);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:BuildRootIndexImpl.java

示例5: createMap

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public static Map<SliceNode, Collection<PsiElement>> createMap() {
  return new FactoryMap<SliceNode, Collection<PsiElement>>() {
    @Override
    protected Map<SliceNode, Collection<PsiElement>> createMap() {
      return new ConcurrentHashMap<SliceNode, Collection<PsiElement>>(ContainerUtil.<SliceNode>identityStrategy());
    }

    @Override
    protected Collection<PsiElement> create(SliceNode key) {
      return new ConcurrentHashSet<PsiElement>(SliceLeafAnalyzer.LEAF_ELEMENT_EQUALITY);
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:SliceLeafAnalyzer.java

示例6: getMarkupModelMap

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
private static ConcurrentMap<Project, MarkupModelImpl> getMarkupModelMap(@NotNull Document document) {
  ConcurrentMap<Project, MarkupModelImpl> markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY);
  if (markupModelMap == null) {
    synchronized (lock) {
      markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY);
      if (markupModelMap == null) {
        markupModelMap = new ConcurrentHashMap<Project, MarkupModelImpl>();
        document.putUserData(MARKUP_MODEL_MAP_KEY, markupModelMap);
      }
      
    }
  }
  return markupModelMap;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:DocumentMarkupModel.java

示例7: getResourceBundle

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public static ResourceBundle getResourceBundle(@NotNull String pathToBundle, @NotNull ClassLoader loader) {
  ConcurrentHashMap<String, SoftReference<ResourceBundle>> map = ourCache.get(loader);
  SoftReference<ResourceBundle> reference = map.get(pathToBundle);
  ResourceBundle result = reference == null ? null : reference.get();
  if (result == null) {
    map.put(pathToBundle, new SoftReference<ResourceBundle>(result = ResourceBundle.getBundle(pathToBundle, Locale.getDefault(), loader)));
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:AbstractBundle.java

示例8: getCachedValue

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public V getCachedValue(T key) {
  SofterReference<ConcurrentMap<T, V>> ref = myCache;
  ConcurrentMap<T, V> map = ref == null ? null : ref.get();
  if (map == null) {
    myCache = new SofterReference<ConcurrentMap<T, V>>(map = new ConcurrentHashMap<T, V>());
  }
  V value = map.get(key);
  if (value == null) {
    map.put(key, value = myValueProvider.fun(key));
  }
  return value;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:SofterCache.java

示例9: internChildrenHolder

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
private static <T extends DomChildDescriptionImpl> ChildrenDescriptionsHolder<T> internChildrenHolder(XmlFile file, ChildrenDescriptionsHolder<T> holder) {
  SoftReference<ConcurrentHashMap<ChildrenDescriptionsHolder, ChildrenDescriptionsHolder>> ref = file.getUserData(HOLDERS_CACHE);
  ConcurrentHashMap<ChildrenDescriptionsHolder, ChildrenDescriptionsHolder> cache = ref == null ? null : ref.get();
  if (cache == null) {
    cache = new ConcurrentHashMap<ChildrenDescriptionsHolder, ChildrenDescriptionsHolder>();
    file.putUserData(HOLDERS_CACHE, new SoftReference<ConcurrentHashMap<ChildrenDescriptionsHolder, ChildrenDescriptionsHolder>>(cache));
  }
  ChildrenDescriptionsHolder existing = cache.get(holder);
  if (existing != null) {
    //noinspection unchecked
    return existing;
  }
  cache.put(holder, holder);
  return holder;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:DynamicGenericInfo.java

示例10: getDefaultNSDescriptor

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:XmlDocumentImpl.java

示例11: FactorTree

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public FactorTree(final Project project, GroovyDslExecutor executor) {
  myExecutor = executor;
  myProvider = new CachedValueProvider<Map>() {
    @Nullable
    @Override
    public Result<Map> compute() {
      return new Result<Map>(new ConcurrentHashMap(), PsiModificationTracker.MODIFICATION_COUNT, ProjectRootManager.getInstance(project));
    }
  };
  myTopLevelCache = CachedValuesManager.getManager(project).createCachedValue(myProvider, false);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:FactorTree.java

示例12: cache

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public void cache(GroovyClassDescriptor descriptor, CustomMembersHolder holder) {
  Map current = null;
  for (Factor factor : descriptor.affectingFactors) {
    Object key;
    switch (factor) {
      case placeElement: key = descriptor.getPlace(); break;
      case placeFile: key = descriptor.getPlaceFile(); break;
      case qualifierType: key = descriptor.getTypeText(); break;
      default: throw new IllegalStateException("Unknown variant: "+ factor);
    }
    if (current == null) {
      if (key instanceof UserDataHolder) {
        final Project project = descriptor.getProject();
        current = CachedValuesManager.getManager(project).getCachedValue((UserDataHolder)key, GDSL_MEMBER_CACHE, myProvider, false);
        continue;
      }

      current = myTopLevelCache.getValue();
    }
    Map next = (Map)current.get(key);
    if (next == null) {
      //noinspection unchecked
      current.put(key, next = new ConcurrentHashMap());
    }
    current = next;
  }

  if (current == null) current = myTopLevelCache.getValue();
  //noinspection unchecked
  current.put(myExecutor, holder);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:FactorTree.java

示例13: getCachedType

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
public static PsiType getCachedType(String typeText, PsiFile context) {
  Map<String, PsiType> map = context.getUserData(CACHED_TYPES);
  if (map == null) {
    map = new ConcurrentHashMap<String, PsiType>();
    context.putUserData(CACHED_TYPES, map);
  }
  PsiType type = map.get(typeText);
  if (type == null || !type.isValid()) {
    type = JavaPsiFacade.getElementFactory(context.getProject()).createTypeFromText(typeText, context);
    map.put(typeText, type);
  }
  return type;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:ClassContextFilter.java

示例14: compute

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
@Override
protected CachedValue<Map<String, JSImportedElementResolveResult>> compute(final PsiElement psiElement, final Object p)
{
	return CachedValuesManager.getManager(psiElement.getProject()).createCachedValue(new CachedValueProvider<Map<String, JSImportedElementResolveResult>>()
	{
		@Override
		public Result<Map<String, JSImportedElementResolveResult>> compute()
		{
			return new Result<Map<String, JSImportedElementResolveResult>>(new ConcurrentHashMap<String, JSImportedElementResolveResult>(), PsiModificationTracker.MODIFICATION_COUNT);
		}
	}, false);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:13,代码来源:JSImportHandlingUtil.java

示例15: create

import com.intellij.util.containers.ConcurrentHashMap; //导入依赖的package包/类
@Override
protected ConcurrentHashMap<String, SoftReference<ResourceBundle>> create(ClassLoader key) {
  return new ConcurrentHashMap<String, SoftReference<ResourceBundle>>();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:AbstractBundle.java


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