本文整理汇总了Java中com.intellij.util.containers.ConcurrentFactoryMap类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentFactoryMap类的具体用法?Java ConcurrentFactoryMap怎么用?Java ConcurrentFactoryMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentFactoryMap类属于com.intellij.util.containers包,在下文中一共展示了ConcurrentFactoryMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PsiReferenceRegistrarImpl
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public PsiReferenceRegistrarImpl(final Language language) {
myBindingCache = new ConcurrentFactoryMap<Class, ProviderBinding[]>() {
@Nullable
@Override
protected ProviderBinding[] create(Class key) {
List<ProviderBinding> result = ContainerUtil.newSmartList();
for (Class<?> bindingClass : myBindingsMap.keySet()) {
if (bindingClass.isAssignableFrom(key)) {
result.add(myBindingsMap.get(bindingClass));
}
}
for (Class<?> bindingClass : myNamedBindingsMap.keySet()) {
if (bindingClass.isAssignableFrom(key)) {
result.add(myNamedBindingsMap.get(bindingClass));
}
}
if (language != Language.ANY) {
final PsiReferenceRegistrar anyRegistrar = ReferenceProvidersRegistry.getInstance().getRegistrar(Language.ANY);
Collections.addAll(result, ((PsiReferenceRegistrarImpl)anyRegistrar).myBindingCache.get(key));
}
//noinspection unchecked
return result.toArray(new ProviderBinding[result.size()]);
}
};
}
示例2: ExternalProjectDataService
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public ExternalProjectDataService() {
myExternalRootProjects = new ConcurrentFactoryMap<Pair<ProjectSystemId, File>, ExternalProject>() {
@Override
protected Map<Pair<ProjectSystemId, File>, ExternalProject> createMap() {
return ContainerUtil.newConcurrentMap(ExternalSystemUtil.HASHING_STRATEGY);
}
@Nullable
@Override
protected ExternalProject create(Pair<ProjectSystemId, File> key) {
return new ExternalProjectSerializer().load(key.first, key.second);
}
@Override
public ExternalProject put(Pair<ProjectSystemId, File> key, ExternalProject value) {
new ExternalProjectSerializer().save(value);
return super.put(key, value);
}
};
}
示例3: ResolveScopeManagerImpl
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public ResolveScopeManagerImpl(Project project, ProjectRootManager projectRootManager, PsiManager psiManager) {
myProject = project;
myProjectRootManager = projectRootManager;
myManager = psiManager;
myDefaultResolveScopesCache = ConcurrentFactoryMap.createMap((key) -> {
GlobalSearchScope scope = null;
for (ResolveScopeProvider resolveScopeProvider : ResolveScopeProvider.EP_NAME.getExtensions()) {
scope = resolveScopeProvider.getResolveScope(key, myProject);
if (scope != null) break;
}
if (scope == null) scope = getInherentResolveScope(key);
for (ResolveScopeEnlarger enlarger : ResolveScopeEnlarger.EP_NAME.getExtensions()) {
final SearchScope extra = enlarger.getAdditionalResolveScope(key, myProject);
if (extra != null) {
scope = scope.union(extra);
}
}
return scope;
});
((PsiManagerImpl)psiManager).registerRunnableToRunOnChange(myDefaultResolveScopesCache::clear);
}
示例4: getAnnotationTypesWithChildren
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public static Collection<PsiClass> getAnnotationTypesWithChildren(@NotNull Module module, String annotationName, boolean includeTests)
{
Project project = module.getProject();
Map<Pair<String, Boolean>, Collection<PsiClass>> map = CachedValuesManager.getManager(project).getCachedValue(module, () ->
{
Map<Pair<String, Boolean>, Collection<PsiClass>> factoryMap = ConcurrentFactoryMap.createMap(key ->
{
GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, key.getSecond());
PsiClass annotationClass = JavaPsiFacade.getInstance(project).findClass(key.getFirst(), moduleScope);
if(annotationClass == null || !annotationClass.isAnnotationType())
{
return Collections.emptyList();
}
// limit search to files containing annotations
GlobalSearchScope effectiveSearchScope = getAllAnnotationFilesScope(project).intersectWith(moduleScope);
return getAnnotationTypesWithChildren(annotationClass, effectiveSearchScope);
});
return CachedValueProvider.Result.create(factoryMap, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
});
return map.get(pair(annotationName, includeTests));
}
示例5: findOwnAnnotation
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
private static PsiAnnotation findOwnAnnotation(final PsiModifierListOwner listOwner, Collection<String> annotationNames)
{
Map<Collection<String>, PsiAnnotation> map = CachedValuesManager.getCachedValue(listOwner, () ->
{
Map<Collection<String>, PsiAnnotation> value = ConcurrentFactoryMap.createMap(annotationNames1 ->
{
final PsiModifierList list = listOwner.getModifierList();
if(list == null)
{
return null;
}
for(PsiAnnotation annotation : list.getAnnotations())
{
if(annotationNames1.contains(annotation.getQualifiedName()))
{
return annotation;
}
}
return null;
});
return CachedValueProvider.Result.create(value, PsiModificationTracker.MODIFICATION_COUNT);
});
return map.get(annotationNames);
}
示例6: createContractAnnotation
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public PsiAnnotation createContractAnnotation(String contractValue)
{
Map<String, PsiAnnotation> cache = CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<Map<String, PsiAnnotation>>()
{
@Nullable
@Override
public Result<Map<String, PsiAnnotation>> compute()
{
Map<String, PsiAnnotation> map = new ConcurrentFactoryMap<String, PsiAnnotation>()
{
@Nullable
@Override
protected PsiAnnotation create(String attrs)
{
return createAnnotationFromText("@org.jetbrains.annotations.Contract(" + attrs + ")");
}
};
return CachedValueProvider.Result.create(map, ModificationTracker.NEVER_CHANGED);
}
});
return cache.get(contractValue);
}
示例7: getAnnotationTypesWithChildren
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public static Collection<PsiClass> getAnnotationTypesWithChildren(@NotNull final Module module, final String annotationName, final boolean includeTests)
{
final Project project = module.getProject();
Map<Pair<String, Boolean>, Collection<PsiClass>> map = CachedValuesManager.getManager(project).getCachedValue(module, () ->
{
Map<Pair<String, Boolean>, Collection<PsiClass>> factoryMap = ConcurrentFactoryMap.createMap(key ->
{
GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, key.getSecond());
PsiClass annotationClass = JavaPsiFacade.getInstance(project).findClass(key.getFirst(), moduleScope);
if(annotationClass == null || !annotationClass.isAnnotationType())
{
return Collections.emptyList();
}
// limit search to files containing annotations
GlobalSearchScope effectiveSearchScope = getAllAnnotationFilesScope(project).intersectWith(moduleScope);
return getAnnotationTypesWithChildren(annotationClass, effectiveSearchScope);
});
return CachedValueProvider.Result.create(factoryMap, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
});
return map.get(Pair.create(annotationName, includeTests));
}
示例8: compute
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
@Override
public CachedValueProvider.Result<Map<GlobalSearchScope, MembersMap>> compute(@NotNull final PsiClass myClass) {
final Map<GlobalSearchScope, MembersMap> map = new ConcurrentFactoryMap<GlobalSearchScope, MembersMap>() {
@Nullable
@Override
protected MembersMap create(GlobalSearchScope resolveScope) {
return new MembersMap(myClass, resolveScope);
}
};
return CachedValueProvider.Result.create(map, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
示例9: fun
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
@Override
public FactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>> fun(final PsiClass psiClass) {
return new ConcurrentFactoryMap<String, Map<MethodSignature, HierarchicalMethodSignature>>() {
@Nullable
@Override
protected Map<MethodSignature, HierarchicalMethodSignature> create(String methodName) {
return buildMethodHierarchy(psiClass, methodName, PsiSubstitutor.EMPTY, true, new THashSet<PsiClass>(), false, psiClass.getResolveScope());
}
};
}
示例10: create
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
@Override
protected ConcurrentFactoryMap<Class, Boolean> create(final Class anc) {
return new ConcurrentFactoryMap<Class, Boolean>() {
@Override
protected Boolean create(Class desc) {
return anc.isAssignableFrom(desc);
}
};
}
示例11: create
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
@Override
protected Map<Class, Object> create(final JavaMethod method) {
return new ConcurrentFactoryMap<Class, Object>() {
@Override
protected Object create(Class annoClass) {
return method.getAnnotation(annoClass);
}
};
}
示例12: compute
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
public Result<FactoryMap<File, String>> compute() {
final FactoryMap<File, String> result = new ConcurrentFactoryMap<File, String>() {
@Override
protected String create(File scriptFile) {
return calcClassName(scriptFile);
}
};
return Result.create(result, ProjectRootManager.getInstance(myModule.getProject()));
}
示例13: GdkMethodHolder
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
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;
}
};
}
示例14: GdkMethodHolder
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
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;
}
};
}
示例15: insertDummyIdentifierWithCache
import com.intellij.util.containers.ConcurrentFactoryMap; //导入依赖的package包/类
private static OffsetsInFile insertDummyIdentifierWithCache(PsiFile file, int startOffset, int endOffset, String replacement) {
ProperTextRange editRange = ProperTextRange.create(startOffset, endOffset);
assertRangeWithinDocument(editRange, file.getViewProvider().getDocument());
ConcurrentFactoryMap<Pair<ProperTextRange, String>, OffsetsInFile> map = CachedValuesManager.getCachedValue(file, () ->
CachedValueProvider.Result.create(
ConcurrentFactoryMap.createConcurrentMap(
key -> copyWithDummyIdentifier(new OffsetsInFile(file), key.first.getStartOffset(), key.first.getEndOffset(), key.second)),
file, file.getViewProvider().getDocument()));
return map.get(Pair.create(editRange, replacement));
}