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

项目:intellij-ce-playground    文件:RefCountHolder.java   
@NotNull
static RefCountHolder get(@NotNull PsiFile file) {
  Reference<RefCountHolder> ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
  RefCountHolder holder = com.intellij.reference.SoftReference.dereference(ref);
  if (holder == null) {
    holder = new RefCountHolder(file);
    Reference<RefCountHolder> newRef = new SoftReference<RefCountHolder>(holder);
    while (true) {
      boolean replaced = ((UserDataHolderEx)file).replace(REF_COUNT_HOLDER_IN_FILE_KEY, ref, newRef);
      if (replaced) {
        break;
      }
      ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
      RefCountHolder newHolder = com.intellij.reference.SoftReference.dereference(ref);
      if (newHolder != null) {
        holder = newHolder;
        break;
      }
    }
  }
  return holder;
}
项目:intellij-ce-playground    文件:TreeViewUtil.java   
private static boolean shouldAbbreviateName(PsiPackage aPackage) {
  final Project project = aPackage.getProject();
  ConcurrentMap<PsiPackage, Boolean> map = project.getUserData(SHOULD_ABBREV_PACK_KEY);
  if (map == null) {
    final ConcurrentMap<PsiPackage, Boolean> newMap = ContainerUtil.createConcurrentWeakMap();
    map = ((UserDataHolderEx)project).putUserDataIfAbsent(SHOULD_ABBREV_PACK_KEY, newMap);
    if (map == newMap) {
      ((PsiManagerEx)PsiManager.getInstance(project)).registerRunnableToRunOnChange(new Runnable() {
        @Override
        public void run() {
          newMap.clear();
        }
      });
    }
  }

  Boolean ret = map.get(aPackage);
  if (ret != null) return ret;
  ret = scanPackages(aPackage, 1);
  map.put(aPackage, ret);
  return ret;
}
项目:intellij-ce-playground    文件:CachedValuesManager.java   
public <T, D extends UserDataHolder, P> T getParameterizedCachedValue(@NotNull D dataHolder,
                            @NotNull Key<ParameterizedCachedValue<T,P>> key,
                            @NotNull ParameterizedCachedValueProvider<T, P> provider,
                            boolean trackValue,
                            P parameter) {
  ParameterizedCachedValue<T,P> value;

  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value == null) {
      value = createParameterizedCachedValue(provider, trackValue);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value == null) {
        value = createParameterizedCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue(parameter);
}
项目:intellij-ce-playground    文件:PerIndexDocumentVersionMap.java   
public long set(@NotNull Document document, @NotNull ID<?, ?> indexId, long value) {
  List<IdVersionInfo> list = document.getUserData(KEY);
  if (list == null) {
    list = ((UserDataHolderEx)document).putUserDataIfAbsent(KEY, new ArrayList<IdVersionInfo>());
  }

  synchronized (list) {
    for (IdVersionInfo info : list) {
      if (info.id == indexId) {
        long old = info.docVersion;
        if (info.mapVersion != mapVersion) {
          old = INVALID_STAMP;
          info.mapVersion = mapVersion;
        }
        info.docVersion = value;
        return old;
      }
    }
    list.add(new IdVersionInfo(indexId, value, mapVersion));
    return INVALID_STAMP;
  }
}
项目:intellij-ce-playground    文件:SwingBuilderNonCodeMemberContributor.java   
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
                                   PsiClass aClass,
                                   @NotNull PsiScopeProcessor processor,
                                   @NotNull PsiElement place,
                                   @NotNull ResolveState state) {
  ClassHint classHint = processor.getHint(ClassHint.KEY);
  if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return;

  MultiMap<String, PsiMethod> methodMap = aClass.getUserData(KEY);
  if (methodMap == null) {
    MyBuilder builder = new MyBuilder(aClass);
    builder.generateMethods();
    methodMap = ((UserDataHolderEx)aClass).putUserDataIfAbsent(KEY, builder.myResult);
  }

  String nameHint = ResolveUtil.getNameHint(processor);

  Collection<? extends PsiMethod> methods = nameHint == null ? methodMap.values() : methodMap.get(nameHint);

  for (PsiMethod method : methods) {
    if (!processor.execute(method, state)) return;
  }
}
项目:tools-idea    文件:TreeViewUtil.java   
private static boolean shouldAbbreviateName(PsiPackage aPackage) {
  final Project project = aPackage.getProject();
  ConcurrentMap<PsiPackage, Boolean> map = project.getUserData(SHOULD_ABBREV_PACK_KEY);
  if (map == null) {
    final ConcurrentWeakHashMap<PsiPackage, Boolean> newMap = new ConcurrentWeakHashMap<PsiPackage, Boolean>();
    map = ((UserDataHolderEx)project).putUserDataIfAbsent(SHOULD_ABBREV_PACK_KEY, newMap);
    if (map == newMap) {
      ((PsiManagerEx)PsiManager.getInstance(project)).registerRunnableToRunOnChange(new Runnable() {
        @Override
        public void run() {
          newMap.clear();
        }
      });
    }
  }

  Boolean ret = map.get(aPackage);
  if (ret != null) return ret;
  ret = scanPackages(aPackage, 1);
  map.put(aPackage, ret);
  return ret;
}
项目:tools-idea    文件:PerIndexDocumentVersionMap.java   
public long getAndSet(@NotNull Document document, @NotNull ID<?, ?> indexId, long value) {
  List<IdVersionInfo> list = document.getUserData(KEY);
  if (list == null) {
    list = ((UserDataHolderEx)document).putUserDataIfAbsent(KEY, new ArrayList<IdVersionInfo>());
  }

  synchronized (list) {
    for (IdVersionInfo info : list) {
      if (info.id == indexId) {
        long old = info.docVersion;
        if (info.mapVersion != mapVersion) {
          old = 0;
          info.mapVersion = mapVersion;
        }
        info.docVersion = value;
        return old;
      }
    }
    list.add(new IdVersionInfo(indexId, value, mapVersion));
    return 0;
  }
}
项目:tools-idea    文件:SwingBuilderNonCodeMemberContributor.java   
@Override
public void processDynamicElements(@NotNull PsiType qualifierType,
                                   PsiClass aClass,
                                   PsiScopeProcessor processor,
                                   PsiElement place,
                                   ResolveState state) {
  ClassHint classHint = processor.getHint(ClassHint.KEY);
  if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return;

  MultiMap<String, PsiMethod> methodMap = aClass.getUserData(KEY);
  if (methodMap == null) {
    MyBuilder builder = new MyBuilder(aClass);
    builder.generateMethods();
    methodMap = ((UserDataHolderEx)aClass).putUserDataIfAbsent(KEY, builder.myResult);
  }

  String nameHint = ResolveUtil.getNameHint(processor);

  Collection<? extends PsiMethod> methods = nameHint == null ? methodMap.values() : methodMap.get(nameHint);

  for (PsiMethod method : methods) {
    if (!processor.execute(method, state)) return;
  }
}
项目:consulo-dotnet    文件:DotNetTypeRefCacheUtil.java   
@Exported
@NotNull
@RequiredReadAction
private static <E extends PsiElement> DotNetTypeRef getResultCacheResultImpl(@NotNull Key<CachedValue<DotNetTypeRef>> cachedValueKey,
        @NotNull E element,
        @NotNull Key dropKey,
        @NotNull final NotNullFunction<E, DotNetTypeRef> resolver)
{
    Class<? extends NotNullFunction> aClass = resolver.getClass();
    if(!BitUtil.isSet(aClass.getModifiers(), Modifier.STATIC))
    {
        throw new IllegalArgumentException("Accepted only static resolver");
    }

    CachedValue<DotNetTypeRef> cachedValue = element.getUserData(cachedValueKey);
    if(cachedValue == null)
    {
        DotNetTypeRefCachedValueProvider<E> provider = new DotNetTypeRefCachedValueProvider<>(dropKey, element, resolver);

        cachedValue = ((UserDataHolderEx) element).putUserDataIfAbsent(cachedValueKey, CachedValuesManager.getManager(element.getProject()).createCachedValue(provider, false));

        return cachedValue.getValue();
    }
    return cachedValue.getValue();
}
项目:consulo    文件:CachedValuesManager.java   
public <T, D extends UserDataHolder, P> T getParameterizedCachedValue(@Nonnull D dataHolder,
                                                                      @Nonnull Key<ParameterizedCachedValue<T, P>> key,
                                                                      @Nonnull ParameterizedCachedValueProvider<T, P> provider,
                                                                      boolean trackValue,
                                                                      P parameter) {
  ParameterizedCachedValue<T, P> value;

  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value == null) {
      value = createParameterizedCachedValue(provider, trackValue);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value == null) {
        value = createParameterizedCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue(parameter);
}
项目:consulo    文件:PerIndexDocumentVersionMap.java   
public long set(@Nonnull Document document, @Nonnull ID<?, ?> indexId, long value) {
  List<IdVersionInfo> list = document.getUserData(KEY);
  if (list == null) {
    list = ((UserDataHolderEx)document).putUserDataIfAbsent(KEY, new ArrayList<>());
  }

  synchronized (list) {
    for (IdVersionInfo info : list) {
      if (info.id == indexId) {
        long old = info.docVersion;
        if (info.mapVersion != mapVersion) {
          old = INVALID_STAMP;
          info.mapVersion = mapVersion;
        }
        info.docVersion = value;
        return old;
      }
    }
    list.add(new IdVersionInfo(indexId, value, mapVersion));
    return INVALID_STAMP;
  }
}
项目:consulo    文件:TreeViewUtil.java   
private static boolean shouldAbbreviateName(PsiPackage aPackage) {
  final Project project = aPackage.getProject();
  ConcurrentMap<PsiPackage, Boolean> map = project.getUserData(SHOULD_ABBREV_PACK_KEY);
  if (map == null) {
    final ConcurrentWeakHashMap<PsiPackage, Boolean> newMap = new ConcurrentWeakHashMap<PsiPackage, Boolean>();
    map = ((UserDataHolderEx)project).putUserDataIfAbsent(SHOULD_ABBREV_PACK_KEY, newMap);
    if (map == newMap) {
      ((PsiManagerEx)PsiManager.getInstance(project)).registerRunnableToRunOnChange(new Runnable() {
        @Override
        public void run() {
          newMap.clear();
        }
      });
    }
  }

  Boolean ret = map.get(aPackage);
  if (ret != null) return ret;
  ret = scanPackages(aPackage, 1);
  map.put(aPackage, ret);
  return ret;
}
项目:intellij-ce-playground    文件:DocumentMarkupModel.java   
private static ConcurrentMap<Project, MarkupModelImpl> getMarkupModelMap(@NotNull Document document) {
  ConcurrentMap<Project, MarkupModelImpl> markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY);
  if (markupModelMap == null) {
    ConcurrentMap<Project, MarkupModelImpl> newMap = ContainerUtil.newConcurrentMap();
    markupModelMap = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_MAP_KEY, newMap);
  }
  return markupModelMap;
}
项目:intellij-ce-playground    文件:CachedValuesManagerImpl.java   
@Override
@Nullable
public <T, D extends UserDataHolder> T getCachedValue(@NotNull D dataHolder,
                                                      @NotNull Key<CachedValue<T>> key,
                                                      @NotNull CachedValueProvider<T> provider,
                                                      boolean trackValue) {
  CachedValueChecker.checkProvider(provider, dataHolder);
  CachedValue<T> value;
  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
      value = null;
      dh.putUserData(key, null);
    }
    if (value == null) {
      value = createCachedValue(provider, trackValue);
      assert ((CachedValueBase)value).isFromMyProject(myProject);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
        value = null;
      }
      if (value == null) {
        value = createCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue();
}
项目:intellij-ce-playground    文件:VetoSavingCommittingDocumentsAdapter.java   
private static void updateSaveability(Map<Document, Project> documentsToWarn, boolean allowSave) {
  Object newValue = allowSave ? null : SAVE_DENIED;
  for (Document document : documentsToWarn.keySet()) {
    Project oldData = documentsToWarn.get(document);
    //the committing thread could have finished already and file is not being committed anymore
    ((UserDataHolderEx)document).replace(CommitHelper.DOCUMENT_BEING_COMMITTED_KEY, oldData, newValue);
  }
}
项目:intellij-ce-playground    文件:HighlightManagerImpl.java   
@Nullable
public Map<RangeHighlighter, HighlightInfo> getHighlightInfoMap(@NotNull Editor editor, boolean toCreate) {
  if (editor instanceof EditorWindow) return getHighlightInfoMap(((EditorWindow)editor).getDelegate(), toCreate);
  Map<RangeHighlighter, HighlightInfo> map = editor.getUserData(HIGHLIGHT_INFO_MAP_KEY);
  if (map == null && toCreate) {
    map = ((UserDataHolderEx)editor).putUserDataIfAbsent(HIGHLIGHT_INFO_MAP_KEY, new HashMap<RangeHighlighter, HighlightInfo>());
  }
  return map;
}
项目:intellij-ce-playground    文件:MvcTargetDialogCompletionUtils.java   
public static Set<String> getAllTargetNames(@NotNull final Module module) {
  CachedValue<Set<String>> cachedTargets = module.getUserData(ALL_TARGET_KEY);
  if (cachedTargets == null) {
    cachedTargets = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider<Set<String>>() {
        @Override
        public Result<Set<String>> compute() {
          return Result.create(getAllTargetNamesInternal(module), PsiModificationTracker.MODIFICATION_COUNT);
        }
      }, false);

    cachedTargets = ((UserDataHolderEx)module).putUserDataIfAbsent(ALL_TARGET_KEY, cachedTargets);
  }

  return cachedTargets.getValue();
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLNamedPsiElement.java   
@NotNull
@Override
public SearchScope getUseScope() {
    // For find usages, we want GraphQL PSI elements to be considered project-wide.
    // This enables find usages in modules that live outside the project base dir
    // but we only want to find usages in relevant file types, e.g. GraphQL, JS and TypeScript
    final Project project = getProject();
    final GlobalSearchScope cached = project.getUserData(USE_SCOPE);
    return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(USE_SCOPE, createFileTypeRestrictedUsageScope(project));
}
项目:tools-idea    文件:RefCountHolder.java   
private static RefCountHolder getInstance(@NotNull PsiFile file, @NotNull ProgressIndicator indicator, boolean acquire) {
  HolderReference ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
  RefCountHolder holder = ref == null ? null : ref.get();
  if (holder == null && acquire) {
    holder = new RefCountHolder(file);
    HolderReference newRef = new HolderReference(holder);
    while (true) {
      boolean replaced = ((UserDataHolderEx)file).replace(REF_COUNT_HOLDER_IN_FILE_KEY, ref, newRef);
      if (replaced) {
        ref = newRef;
        break;
      }
      ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
      RefCountHolder newHolder = ref == null ? null : ref.get();
      if (newHolder != null) {
        holder = newHolder;
        break;
      }
    }
  }
  if (ref != null) {
    if (acquire) {
      ref.acquire(indicator);
    }
    else {
      ref.release(indicator);
    }
  }
  return holder;
}
项目:tools-idea    文件:CachedValuesManager.java   
public <T, D extends UserDataHolder, P> T getParameterizedCachedValue(@NotNull D dataHolder,
                            @NotNull Key<ParameterizedCachedValue<T,P>> key,
                            @NotNull ParameterizedCachedValueProvider<T, P> provider,
                            boolean trackValue,
                            P parameter) {

  ParameterizedCachedValue<T,P> value;

  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value == null) {
      value = createParameterizedCachedValue(provider, trackValue);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value == null) {
        value = createParameterizedCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue(parameter);
}
项目:tools-idea    文件:TextBlock.java   
@NotNull
public static TextBlock get(@NotNull PsiFile file) {
  TextBlock textBlock = file.getUserData(KEY_TEXT_BLOCK);
  if (textBlock == null){
    textBlock = ((UserDataHolderEx)file).putUserDataIfAbsent(KEY_TEXT_BLOCK, new TextBlock());
  }

  return textBlock;
}
项目:tools-idea    文件:CachedValuesManagerImpl.java   
@Override
@Nullable
public <T, D extends UserDataHolder> T getCachedValue(@NotNull D dataHolder,
                                                      @NotNull Key<CachedValue<T>> key,
                                                      @NotNull CachedValueProvider<T> provider,
                                                      boolean trackValue) {
  CachedValue<T> value;
  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
      value = null;
      dh.putUserData(key, null);
    }
    if (value == null) {
      value = createCachedValue(provider, trackValue);
      assert ((CachedValueBase)value).isFromMyProject(myProject);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
        value = null;
      }
      if (value == null) {
        value = createCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue();
}
项目:tools-idea    文件:VetoSavingCommittingDocumentsAdapter.java   
private static void updateSaveability(Map<Document, Project> documentsToWarn, boolean allowSave) {
  Object newValue = allowSave ? null : SAVE_DENIED;
  for (Document document : documentsToWarn.keySet()) {
    Project oldData = documentsToWarn.get(document);
    //the committing thread could have finished already and file is not being committed anymore
    ((UserDataHolderEx)document).replace(CommitHelper.DOCUMENT_BEING_COMMITTED_KEY, oldData, newValue);
  }
}
项目:tools-idea    文件:HighlightManagerImpl.java   
@Nullable
public Map<RangeHighlighter, HighlightInfo> getHighlightInfoMap(@NotNull Editor editor, boolean toCreate) {
  if (editor instanceof EditorWindow) return getHighlightInfoMap(((EditorWindow)editor).getDelegate(), toCreate);
  Map<RangeHighlighter, HighlightInfo> map = editor.getUserData(HIGHLIGHT_INFO_MAP_KEY);
  if (map == null && toCreate) {
    map = ((UserDataHolderEx)editor).putUserDataIfAbsent(HIGHLIGHT_INFO_MAP_KEY, new HashMap<RangeHighlighter, HighlightInfo>());
  }
  return map;
}
项目:tools-idea    文件:CodeFoldingManagerImpl.java   
@NotNull
private DocumentFoldingInfo getDocumentFoldingInfo(@NotNull Document document) {
  DocumentFoldingInfo info = document.getUserData(myFoldingInfoInDocumentKey);
  if (info == null) {
    info = new DocumentFoldingInfo(myProject, document);
    DocumentFoldingInfo written = ((UserDataHolderEx)document).putUserDataIfAbsent(myFoldingInfoInDocumentKey, info);
    if (written == info) {
      myDocumentsWithFoldingInfo.add(document);
    }
    else {
      info = written;
    }
  }
  return info;
}
项目:tools-idea    文件:MvcTargetDialogCompletionUtils.java   
public static Set<String> getAllTargetNames(@NotNull final Module module) {
  CachedValue<Set<String>> cachedTargets = module.getUserData(ALL_TARGET_KEY);
  if (cachedTargets == null) {
    cachedTargets = CachedValuesManager.getManager(module.getProject()).createCachedValue(new CachedValueProvider<Set<String>>() {
        public Result<Set<String>> compute() {
          return Result.create(getAllTargetNamesInternal(module), PsiModificationTracker.MODIFICATION_COUNT);
        }
      }, false);

    cachedTargets = ((UserDataHolderEx)module).putUserDataIfAbsent(ALL_TARGET_KEY, cachedTargets);
  }

  return cachedTargets.getValue();
}
项目:consulo    文件:DocumentMarkupModel.java   
private static ConcurrentMap<Project, MarkupModelImpl> getMarkupModelMap(@Nonnull Document document) {
  ConcurrentMap<Project, MarkupModelImpl> markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY);
  if (markupModelMap == null) {
    ConcurrentMap<Project, MarkupModelImpl> newMap = ContainerUtil.newConcurrentMap();
    markupModelMap = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_MAP_KEY, newMap);
  }
  return markupModelMap;
}
项目:consulo    文件:RainbowVisitor.java   
protected HighlightInfo getInfo(@Nonnull final PsiElement context,
                                @Nonnull final PsiElement rainbowElement,
                                @Nonnull final String name,
                                @Nullable final TextAttributesKey colorKey) {
  int colorIndex = UsedColors.getOrAddColorIndex((UserDataHolderEx)context, name, getHighlighter().getColorsCount());
  return getHighlighter().getInfo(colorIndex, rainbowElement, colorKey);
}
项目:consulo    文件:CachedValuesManagerImpl.java   
@Override
@Nullable
public <T, D extends UserDataHolder> T getCachedValue(@Nonnull D dataHolder,
                                                      @Nonnull Key<CachedValue<T>> key,
                                                      @Nonnull CachedValueProvider<T> provider,
                                                      boolean trackValue) {
  CachedValue<T> value;
  if (dataHolder instanceof UserDataHolderEx) {
    UserDataHolderEx dh = (UserDataHolderEx)dataHolder;
    value = dh.getUserData(key);
    if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
      value = null;
      dh.putUserData(key, null);
    }
    if (value == null) {
      value = createCachedValue(provider, trackValue);
      assert ((CachedValueBase)value).isFromMyProject(myProject);
      value = dh.putUserDataIfAbsent(key, value);
    }
  }
  else {
    synchronized (dataHolder) {
      value = dataHolder.getUserData(key);
      if (value instanceof CachedValueBase && !((CachedValueBase)value).isFromMyProject(myProject)) {
        value = null;
      }
      if (value == null) {
        value = createCachedValue(provider, trackValue);
        dataHolder.putUserData(key, value);
      }
    }
  }
  return value.getValue();
}
项目:consulo    文件:VetoSavingCommittingDocumentsAdapter.java   
private static void updateSaveability(Map<Document, Project> documentsToWarn, boolean allowSave) {
  Object newValue = allowSave ? null : SAVE_DENIED;
  for (Document document : documentsToWarn.keySet()) {
    Project oldData = documentsToWarn.get(document);
    //the committing thread could have finished already and file is not being committed anymore
    ((UserDataHolderEx)document).replace(CommitHelper.DOCUMENT_BEING_COMMITTED_KEY, oldData, newValue);
  }
}
项目:consulo    文件:HighlightManagerImpl.java   
@Nullable
public Map<RangeHighlighter, HighlightInfo> getHighlightInfoMap(@Nonnull Editor editor, boolean toCreate) {
  if (editor instanceof EditorWindow) return getHighlightInfoMap(((EditorWindow)editor).getDelegate(), toCreate);
  Map<RangeHighlighter, HighlightInfo> map = editor.getUserData(HIGHLIGHT_INFO_MAP_KEY);
  if (map == null && toCreate) {
    map = ((UserDataHolderEx)editor).putUserDataIfAbsent(HIGHLIGHT_INFO_MAP_KEY, new HashMap<RangeHighlighter, HighlightInfo>());
  }
  return map;
}
项目:consulo    文件:CodeFoldingManagerImpl.java   
@Nonnull
private DocumentFoldingInfo getDocumentFoldingInfo(@Nonnull Document document) {
  DocumentFoldingInfo info = document.getUserData(myFoldingInfoInDocumentKey);
  if (info == null) {
    info = new DocumentFoldingInfo(myProject, document);
    DocumentFoldingInfo written = ((UserDataHolderEx)document).putUserDataIfAbsent(myFoldingInfoInDocumentKey, info);
    if (written == info) {
      myDocumentsWithFoldingInfo.add(document);
    }
    else {
      info = written;
    }
  }
  return info;
}
项目:consulo-java    文件:PsiClassImplUtil.java   
@NotNull
private static ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> getValues(@NotNull PsiClass aClass)
{
    ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass> value = aClass.getUserData(MAP_IN_CLASS_KEY);
    if(value == null)
    {
        value = CachedValuesManager.getManager(aClass.getProject()).createParameterizedCachedValue(ByNameCachedValueProvider.INSTANCE, false);
        //Do not cache for nonphysical elements
        if(aClass.isPhysical())
        {
            value = ((UserDataHolderEx) aClass).putUserDataIfAbsent(MAP_IN_CLASS_KEY, value);
        }
    }
    return value;
}
项目:consulo-java    文件:RefCountHolder.java   
@NotNull
static RefCountHolder get(@NotNull PsiFile file)
{
    Reference<RefCountHolder> ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
    RefCountHolder holder = com.intellij.reference.SoftReference.dereference(ref);
    if(holder == null)
    {
        holder = new RefCountHolder(file);
        Reference<RefCountHolder> newRef = new SoftReference<RefCountHolder>(holder);
        while(true)
        {
            boolean replaced = ((UserDataHolderEx) file).replace(REF_COUNT_HOLDER_IN_FILE_KEY, ref, newRef);
            if(replaced)
            {
                break;
            }
            ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
            RefCountHolder newHolder = com.intellij.reference.SoftReference.dereference(ref);
            if(newHolder != null)
            {
                holder = newHolder;
                break;
            }
        }
    }
    return holder;
}
项目:intellij-ce-playground    文件:ProjectScope.java   
@NotNull
public static GlobalSearchScope getAllScope(@NotNull Project project) {
  GlobalSearchScope cached = project.getUserData(ALL_SCOPE_KEY);
  return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(ALL_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildAllScope());
}
项目:intellij-ce-playground    文件:ProjectScope.java   
@NotNull
public static GlobalSearchScope getProjectScope(@NotNull Project project) {
  GlobalSearchScope cached = project.getUserData(PROJECT_SCOPE_KEY);
  return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(PROJECT_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildProjectScope());
}
项目:intellij-ce-playground    文件:ProjectScope.java   
@NotNull
public static GlobalSearchScope getLibrariesScope(@NotNull Project project) {
  GlobalSearchScope cached = project.getUserData(LIBRARIES_SCOPE_KEY);
  return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(LIBRARIES_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildLibrariesScope());
}
项目:intellij-ce-playground    文件:ProjectScope.java   
@NotNull
public static GlobalSearchScope getContentScope(@NotNull Project project) {
  GlobalSearchScope cached = project.getUserData(CONTENT_SCOPE_KEY);
  return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(CONTENT_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildContentScope());
}
项目:intellij-ce-playground    文件:DaemonListeners.java   
@Override
public void dispose() {
  stopDaemonAndRestartAllFiles("Project closed");
  boolean replaced = ((UserDataHolderEx)myProject).replace(DAEMON_INITIALIZED, Boolean.TRUE, Boolean.FALSE);
  LOG.assertTrue(replaced, "Daemon listeners already disposed for the project "+myProject);
}
项目:tools-idea    文件:ProjectScope.java   
@NotNull
public static GlobalSearchScope getAllScope(@NotNull Project project) {
  GlobalSearchScope cached = project.getUserData(ALL_SCOPE_KEY);
  return cached != null ? cached : ((UserDataHolderEx)project).putUserDataIfAbsent(ALL_SCOPE_KEY, ProjectScopeBuilder.getInstance(project).buildAllScope());
}