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

项目:intellij-ce-playground    文件:ThreesideTextDiffViewerEx.java   
public void install(@Nullable List<MergeLineFragment> fragments,
                    @NotNull UserDataHolder context,
                    @NotNull FoldingModelSupport.Settings settings) {
  Iterator<int[]> it = map(fragments, new Function<MergeLineFragment, int[]>() {
    @Override
    public int[] fun(MergeLineFragment fragment) {
      return new int[]{
        fragment.getStartLine(ThreeSide.LEFT),
        fragment.getEndLine(ThreeSide.LEFT),
        fragment.getStartLine(ThreeSide.BASE),
        fragment.getEndLine(ThreeSide.BASE),
        fragment.getStartLine(ThreeSide.RIGHT),
        fragment.getEndLine(ThreeSide.RIGHT)};
    }
  });
  install(it, context, settings);
}
项目:intellij-ce-playground    文件:FoldingModelSupport.java   
protected void install(@Nullable final Iterator<int[]> changedLines,
                       @NotNull final UserDataHolder context,
                       @NotNull final Settings settings) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  if (changedLines == null) return;
  if (settings.range == -1) return;

  runBatchOperation(new Runnable() {
    @Override
    public void run() {
      FoldingBuilder builder = new FoldingBuilder(context, settings);
      builder.build(changedLines);
    }
  });

  updateLineNumbers(true);
}
项目: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    文件:CachedValueChecker.java   
static void checkProvider(CachedValueProvider provider, UserDataHolder userDataHolder) {
  if (!DO_CHECKS) return;

  Class<? extends CachedValueProvider> providerClass = provider.getClass();
  if (!ourCheckedClasses.add(providerClass)) return;

  for (Field field : providerClass.getDeclaredFields()) {
    try {
      field.setAccessible(true);
      Object o = field.get(provider);
      if (o instanceof PsiElement && o != userDataHolder) {
        LOG.error("Incorrect CachedValue use. Provider references PSI, causing memory leaks and possible invalid element access: field " + field.getName() + " of " + provider);
        return;
      }
    }
    catch (IllegalAccessException e) {
      LOG.error(e);
    }
  }
}
项目:intellij-ce-playground    文件:BinaryFilePatchInProgress.java   
@NotNull
@Override
public DiffRequestProducer getDiffRequestProducers(final Project project, final PatchReader baseContents) {
  final ShelvedBinaryFile file = getPatch().getShelvedBinaryFile();
  return new DiffRequestProducer() {
    @NotNull
    @Override
    public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
      throws DiffRequestProducerException, ProcessCanceledException {
      Change change = file.createChange(project);
      return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
    }

    @NotNull
    @Override
    public String getName() {
      final File file1 = new File(VfsUtilCore.virtualToIoFile(getBase()),
                                  file.AFTER_PATH == null ? file.BEFORE_PATH : file.AFTER_PATH);
      return FileUtil.toSystemDependentName(file1.getPath());
    }
  };
}
项目:intellij-ce-playground    文件:DiffShelvedChangesAction.java   
private static void processBinaryFiles(@NotNull final Project project,
                                       @NotNull List<ShelvedBinaryFile> files,
                                       @NotNull List<MyDiffRequestProducer> diffRequestProducers) {
  final String base = project.getBaseDir().getPath();
  for (final ShelvedBinaryFile shelvedChange : files) {
    diffRequestProducers.add(new MyDiffRequestProducer(shelvedChange) {
      @NotNull
      @Override
      public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
        throws DiffRequestProducerException, ProcessCanceledException {
        Change change = shelvedChange.createChange(project);
        return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
      }

      @NotNull
      @Override
      public FilePath getFilePath() {
        final File file = new File(base, shelvedChange.AFTER_PATH == null ? shelvedChange.BEFORE_PATH : shelvedChange.AFTER_PATH);
        return VcsUtil.getFilePath(file);
      }
    });
  }
}
项目:intellij-ce-playground    文件:PyTypeUtil.java   
/**
 * Search for data in dataholder or members of union recursively
 * @param type start point
 * @param key key to search
 * @param <T> result tyoe
 * @return data or null if not found
 */
@Nullable
public static <T> T findData(@NotNull final PyType type, @NotNull final Key<T> key) {
  if (type instanceof UserDataHolder) {
    return ((UserDataHolder)type).getUserData(key);
  }
  if (type instanceof PyUnionType) {
    for (final PyType memberType : ((PyUnionType)type).getMembers()) {
      if (memberType == null) {
        continue;
      }
      final T result = findData(memberType, key);
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}
项目:consulo    文件:ThreesideTextDiffViewerEx.java   
public void install(@Nullable List<MergeLineFragment> fragments,
                    @Nonnull UserDataHolder context,
                    @Nonnull FoldingModelSupport.Settings settings) {
  Iterator<int[]> it = map(fragments, new Function<MergeLineFragment, int[]>() {
    @Override
    public int[] fun(MergeLineFragment fragment) {
      return new int[]{
              fragment.getStartLine(ThreeSide.LEFT),
              fragment.getEndLine(ThreeSide.LEFT),
              fragment.getStartLine(ThreeSide.BASE),
              fragment.getEndLine(ThreeSide.BASE),
              fragment.getStartLine(ThreeSide.RIGHT),
              fragment.getEndLine(ThreeSide.RIGHT)};
    }
  });
  install(it, context, settings);
}
项目:consulo    文件:FoldingModelSupport.java   
protected void install(@javax.annotation.Nullable final Iterator<int[]> changedLines,
                       @Nonnull final UserDataHolder context,
                       @Nonnull final Settings settings) {
  ApplicationManager.getApplication().assertIsDispatchThread();

  if (changedLines == null) return;
  if (settings.range == -1) return;

  runBatchOperation(new Runnable() {
    @Override
    public void run() {
      FoldingBuilder builder = new FoldingBuilder(context, settings);
      builder.build(changedLines);
    }
  });

  updateLineNumbers(true);
}
项目: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    文件:AttachToLocalProcessAction.java   
public AttachItem(@Nonnull XLocalAttachGroup group,
                  boolean isFirstInGroup,
                  @Nonnull String groupName,
                  @Nonnull ProcessInfo info,
                  @Nonnull List<XLocalAttachDebugger> debuggers,
                  int selectedDebugger,
                  @Nonnull UserDataHolder dataHolder) {
  myGroupName = groupName;
  myDataHolder = dataHolder;
  assert !debuggers.isEmpty() : "debugger list should not be empty";
  assert selectedDebugger >= 0 && selectedDebugger < debuggers.size() : "wrong selected debugger index";

  myGroup = group;
  myIsFirstInGroup = isFirstInGroup;
  myProcessInfo = info;
  myDebuggers = debuggers;
  mySelectedDebugger = selectedDebugger;

  if (debuggers.size() > 1) {
    mySubItems = ContainerUtil.map(debuggers, debugger -> new AttachItem(myGroup, false, myProcessInfo, Collections.singletonList(debugger), dataHolder));
  }
  else {
    mySubItems = Collections.emptyList();
  }
}
项目:consulo    文件:BinaryFilePatchInProgress.java   
@Nonnull
@Override
public DiffRequestProducer getDiffRequestProducers(final Project project, final PatchReader baseContents) {
  final ShelvedBinaryFile file = getPatch().getShelvedBinaryFile();
  return new DiffRequestProducer() {
    @Nonnull
    @Override
    public DiffRequest process(@Nonnull UserDataHolder context, @Nonnull ProgressIndicator indicator)
            throws DiffRequestProducerException, ProcessCanceledException {
      Change change = file.createChange(project);
      return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
    }

    @Nonnull
    @Override
    public String getName() {
      final File file1 = new File(VfsUtilCore.virtualToIoFile(getBase()),
                                  file.AFTER_PATH == null ? file.BEFORE_PATH : file.AFTER_PATH);
      return FileUtil.toSystemDependentName(file1.getPath());
    }
  };
}
项目:consulo    文件:DiffShelvedChangesAction.java   
private static void processBinaryFiles(@Nonnull final Project project,
                                       @Nonnull List<ShelvedBinaryFile> files,
                                       @Nonnull List<MyDiffRequestProducer> diffRequestProducers) {
  final String base = project.getBaseDir().getPath();
  for (final ShelvedBinaryFile shelvedChange : files) {
    final File file = new File(base, shelvedChange.AFTER_PATH == null ? shelvedChange.BEFORE_PATH : shelvedChange.AFTER_PATH);
    final FilePath filePath = VcsUtil.getFilePath(file);
    diffRequestProducers.add(new MyDiffRequestProducer(shelvedChange, filePath) {
      @Nonnull
      @Override
      public DiffRequest process(@Nonnull UserDataHolder context, @Nonnull ProgressIndicator indicator)
              throws DiffRequestProducerException, ProcessCanceledException {
        Change change = shelvedChange.createChange(project);
        return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
      }
    });
  }
}
项目:consulo-java    文件:PsiClassImpl.java   
private void addTrace(@Nullable PsiClassStub stub)
{
    if(ourTraceStubAstBinding)
    {
        String creationTrace = "Creation thread: " + Thread.currentThread() + "\n" + DebugUtil.currentStackTrace();
        if(stub != null)
        {
            creationTrace += "\nfrom stub " + stub + "@" + System.identityHashCode(stub) + "\n";
            if(stub instanceof UserDataHolder)
            {
                String stubTrace = ((UserDataHolder) stub).getUserData(CREATION_TRACE);
                if(stubTrace != null)
                {
                    creationTrace += stubTrace;
                }
            }
        }
        putUserData(CREATION_TRACE, creationTrace);
    }
}
项目:intellij-ce-playground    文件:PsiClassImpl.java   
private void addTrace(@Nullable PsiClassStub stub) {
  if (ourTraceStubAstBinding) {
    String creationTrace = "Creation thread: " + Thread.currentThread() + "\n" + DebugUtil.currentStackTrace();
    if (stub != null) {
      creationTrace += "\nfrom stub " + stub + "@" + System.identityHashCode(stub) + "\n";
      if (stub instanceof UserDataHolder) {
        String stubTrace = ((UserDataHolder)stub).getUserData(CREATION_TRACE);
        if (stubTrace != null) {
          creationTrace += stubTrace;
        }
      }
    }
    putUserData(CREATION_TRACE, creationTrace);
  }
}
项目:intellij-ce-playground    文件:ProjectConfigurableContext.java   
public ProjectConfigurableContext(final @NotNull Facet facet, final boolean isNewFacet,
                                  @Nullable FacetEditorContext parentContext,
                                  final ModuleConfigurationState state, final UserDataHolder sharedModuleData,
                                  final UserDataHolder sharedProjectData) {
  super(facet, parentContext, state.getFacetsProvider(), state.getModulesProvider(), sharedModuleData, sharedProjectData);
  myModuleConfigurationState = state;
  myNewFacet = isNewFacet;
  myModule = facet.getModule();
}
项目:intellij-ce-playground    文件:FacetEditorContextBase.java   
public FacetEditorContextBase(@NotNull Facet facet, final @Nullable FacetEditorContext parentContext, final @Nullable FacetsProvider facetsProvider,
                              final @NotNull ModulesProvider modulesProvider,
                              final UserDataHolder sharedModuleData,
                              final UserDataHolder sharedProjectData) {
  myFacet = facet;
  mySharedProjectData = sharedProjectData;
  mySharedModuleData = sharedModuleData;
  myParentContext = parentContext;
  myModulesProvider = modulesProvider;
  myFacetsProvider = facetsProvider != null ? facetsProvider : DefaultFacetsProvider.INSTANCE;
}
项目:intellij-ce-playground    文件:ChainCompletionContext.java   
public Collection<?> getContextRefElements(final String typeQName) {
  final Collection<PsiVariable> variables = getVariables(typeQName);
  final Collection<PsiMethod> containingClassMethods = getContainingClassMethods(typeQName);
  final Collection<UserDataHolder> refElements = new ArrayList<UserDataHolder>(variables.size() + containingClassMethods.size());
  refElements.addAll(variables);
  refElements.addAll(containingClassMethods);
  for (final ContextRelevantVariableGetter contextRelevantVariableGetter : getRelevantVariablesGetters(typeQName)) {
    refElements.add(contextRelevantVariableGetter.createLookupElement());
  }
  return refElements;
}
项目:intellij-ce-playground    文件:UnifiedDiffViewer.java   
public void install(@Nullable List<LineRange> changedLines,
                    @NotNull UserDataHolder context,
                    @NotNull FoldingModelSupport.Settings settings) {
  Iterator<int[]> it = map(changedLines, new Function<LineRange, int[]>() {
    @Override
    public int[] fun(LineRange line) {
      return new int[]{
        line.start,
        line.end};
    }
  });
  install(it, context, settings);
}
项目:intellij-ce-playground    文件:SimpleDiffViewer.java   
public void install(@Nullable final List<LineFragment> fragments,
                    @NotNull UserDataHolder context,
                    @NotNull FoldingModelSupport.Settings settings) {
  Iterator<int[]> it = map(fragments, new Function<LineFragment, int[]>() {
    @Override
    public int[] fun(LineFragment fragment) {
      return new int[]{
        fragment.getStartLine1(),
        fragment.getEndLine1(),
        fragment.getStartLine2(),
        fragment.getEndLine2()};
    }
  });
  install(it, context, settings);
}
项目:intellij-ce-playground    文件:FoldingModelSupport.java   
public FoldingBuilder(@NotNull UserDataHolder context,
                      @NotNull Settings settings) {
  myExpandSuggester = new ExpandSuggester(context.getUserData(CACHE_KEY), settings.defaultExpanded);
  mySettings = settings;

  myLineCount = new int[myCount];
  for (int i = 0; i < myCount; i++) {
    myLineCount[i] = myEditors[i].getDocument().getLineCount();
  }
}
项目:intellij-ce-playground    文件:LeakHunter.java   
/**
 * Checks if there is a memory leak if an object of type {@code suspectClass} is strongly accessible via references from the {@code root} object.
 */
@TestOnly
public static <T> void checkLeak(@NotNull Collection<Object> roots, @NotNull Class<T> suspectClass, @Nullable final Processor<? super T> isReallyLeak) throws AssertionError {
  if (SwingUtilities.isEventDispatchThread()) {
    UIUtil.dispatchAllInvocationEvents();
  }
  else {
    UIUtil.pump();
  }
  PersistentEnumeratorBase.clearCacheForTests();
  walkObjects(suspectClass, roots, new Processor<BackLink>() {
    @Override
    public boolean process(BackLink backLink) {
      UserDataHolder leaked = (UserDataHolder)backLink.value;
      if (((UserDataHolderBase)leaked).replace(REPORTED_LEAKED, null, Boolean.TRUE) &&
          (isReallyLeak == null || isReallyLeak.process((T)leaked))) {
        String place = leaked instanceof Project ? PlatformTestCase.getCreationPlace((Project)leaked) : "";
        System.out.println("Leaked object found:" + leaked +
                           "; hash: " + System.identityHashCode(leaked) + "; place: " + place);
        while (backLink != null) {
          String valueStr;
          try {
            valueStr = backLink.value instanceof FList ? "FList" : backLink.value instanceof Collection ? "Collection" : String.valueOf(backLink.value);
          }
          catch (Throwable e) {
            valueStr = "(" + e.getMessage() + " while computing .toString())";
          }
          System.out.println("-->" + backLink.field + "; Value: " + valueStr + "; " + backLink.value.getClass());
          backLink = backLink.backLink;
        }
        System.out.println(";-----");

        throw new AssertionError();
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:UndoRedoStacksHolder.java   
private <T extends UserDataHolder> LinkedList<UndoableGroup> addWeaklyTrackedEmptyStack(T holder, WeakList<T> allHolders) {
  LinkedList<UndoableGroup> result;
  result = holder.getUserData(STACK_IN_DOCUMENT_KEY);
  if (result == null) {
    holder.putUserData(STACK_IN_DOCUMENT_KEY, result = new LinkedList<UndoableGroup>());
    allHolders.add(holder);
  }
  return result;
}
项目:intellij-ce-playground    文件:UndoRedoStacksHolder.java   
private <T extends UserDataHolder> void cleanWeaklyTrackedEmptyStacks(WeakList<T> stackHolders) {
  Set<T> holdersToDrop = new THashSet<T>();
  for (T holder : stackHolders) {
    LinkedList<UndoableGroup> stack = holder.getUserData(STACK_IN_DOCUMENT_KEY);
    if (stack != null && stack.isEmpty()) {
      holder.putUserData(STACK_IN_DOCUMENT_KEY, null);
      holdersToDrop.add(holder);
    }
  }
  stackHolders.removeAll(holdersToDrop);
}
项目:intellij-ce-playground    文件:EditSourceUtil.java   
public static void navigate(@NotNull NavigationItem item, boolean requestFocus, boolean useCurrentWindow) {
  if (item instanceof UserDataHolder) {
    ((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, useCurrentWindow);
  }
  item.navigate(requestFocus);
  if (item instanceof UserDataHolder) {
    ((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  }
}
项目:intellij-ce-playground    文件:TooManyUsagesStatus.java   
public static TooManyUsagesStatus createFor(@NotNull ProgressIndicator indicator) {
  TooManyUsagesStatus data = null;
  if (indicator instanceof UserDataHolder) {
    data = new TooManyUsagesStatus(indicator);
    ((UserDataHolder)indicator).putUserData(KEY, data);
  }
  return data;
}
项目: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    文件:ShowUpdatedDiffAction.java   
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
  throws DiffRequestProducerException, ProcessCanceledException {
  try {
    DiffContent content1;
    DiffContent content2;

    if (FileStatus.ADDED.equals(myFileStatus)) {
      content1 = DiffContentFactory.getInstance().createEmpty();
    }
    else {
      byte[] bytes1 = loadContent(myFilePointer, myBefore);
      content1 = DiffContentFactoryImpl.getInstanceImpl().createFromBytes(myProject, myFilePath, bytes1);
    }

    if (FileStatus.DELETED.equals(myFileStatus)) {
      content2 = DiffContentFactory.getInstance().createEmpty();
    }
    else {
      byte[] bytes2 = loadContent(myFilePointer, myAfter);
      content2 = DiffContentFactoryImpl.getInstanceImpl().createFromBytes(myProject, myFilePath, bytes2);
    }

    String title = DiffRequestFactoryImpl.getContentTitle(myFilePath);
    return new SimpleDiffRequest(title, content1, content2, "Before update", "After update");
  }
  catch (IOException e) {
    throw new DiffRequestProducerException("Can't load content", e);
  }
}
项目:intellij-ce-playground    文件:PatchDiffRequestFactory.java   
@NotNull
public static DiffRequest createDiffRequest(@Nullable Project project,
                                            @NotNull Change change,
                                            @NotNull String name,
                                            @NotNull UserDataHolder context,
                                            @NotNull ProgressIndicator indicator)
  throws DiffRequestProducerException {
  ChangeDiffRequestProducer proxyProducer = ChangeDiffRequestProducer.create(project, change);
  if (proxyProducer == null) throw new DiffRequestProducerException("Can't show diff for '" + name + "'");
  return proxyProducer.process(context, indicator);
}
项目:intellij-ce-playground    文件:ChangeDiffRequestProducer.java   
public static void checkContentRevision(@Nullable Project project,
                                        @NotNull ContentRevision rev,
                                        @NotNull UserDataHolder context,
                                        @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
  if (rev.getFile().isDirectory()) {
    throw new DiffRequestProducerException("Can't show diff for directory");
  }
}
项目:intellij-ce-playground    文件:MigrateToNewDiffUtil.java   
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
  throws DiffRequestProducerException, ProcessCanceledException {
  com.intellij.openapi.diff.DiffRequest oldRequest =
    UIUtil.invokeAndWaitIfNeeded(new Computable<com.intellij.openapi.diff.DiffRequest>() {
      @Override
      public com.intellij.openapi.diff.DiffRequest compute() {
        return myChain.moveTo(myPresentable);
      }
    });
  if (oldRequest == null) return new ErrorDiffRequest(this, "Can't build old-style request");
  return convertRequest(oldRequest);
}
项目:intellij-ce-playground    文件:MigrateToNewDiffUtil.java   
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
  throws DiffRequestProducerException, ProcessCanceledException {
  ErrorDiffRequest errorRequest = new ErrorDiffRequest(this, "Can't convert from old-style request");
  errorRequest.putUserData(DiffUserDataKeys.CONTEXT_ACTIONS, Collections.<AnAction>singletonList(new MyShowDiffAction(myRequest)));
  return errorRequest;
}
项目:intellij-ce-playground    文件:CodeFormatterFacade.java   
DelegatingDataContext(DataContext delegate) {
  myDataContextDelegate = delegate;
  if (delegate instanceof UserDataHolder) {
    myDataHolderDelegate = (UserDataHolder)delegate;
  }
  else {
    myDataHolderDelegate = null;
  }
}
项目:intellij-ce-playground    文件:SvnPhantomChangeDiffRequestProvider.java   
@NotNull
@Override
public DiffRequest process(@NotNull ChangeDiffRequestProducer presentable,
                           @NotNull UserDataHolder context,
                           @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
  indicator.checkCanceled();
  return new SvnPhantomDiffRequest(presentable.getChange());
}
项目:intellij-ce-playground    文件:SvnTreeConflictDiffRequestProvider.java   
@NotNull
@Override
public DiffRequest process(@NotNull ChangeDiffRequestProducer presentable,
                           @NotNull UserDataHolder context,
                           @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
  return new SvnTreeConflictDiffRequest(((ConflictedSvnChange)presentable.getChange()));
}
项目:intellij-ce-playground    文件:SvnChangeDiffViewerProvider.java   
@NotNull
@Override
public DiffViewerWrapper process(@NotNull ChangeDiffRequestProducer presentable,
                                 @NotNull UserDataHolder context,
                                 @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
  // TODO: support properties conflict for three-way-diff

  DiffRequest propertyRequest = createPropertyRequest(presentable.getChange(), indicator);
  return new SvnDiffViewerWrapper(propertyRequest);
}
项目:intellij-ce-playground    文件:FactorTree.java   
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 = ContainerUtil.newConcurrentMap());
    }
    current = next;
  }

  if (current == null) current = myTopLevelCache.getValue();
  //noinspection unchecked
  current.put(myExecutor, holder);
}
项目:intellij-ce-playground    文件:FactorTree.java   
private static Map getFromMapOrUserData(UserDataHolder holder, Map map, boolean fromUserData) {
  if (fromUserData) {
    CachedValue<Map> cache = holder.getUserData(GDSL_MEMBER_CACHE);
    return cache != null && cache.hasUpToDateValue() ? cache.getValue() : null;
  }
  return (Map)map.get(holder);
}
项目:tools-idea    文件:PsiClassImpl.java   
private void addTrace(@Nullable PsiClassStub stub) {
  if (ourTraceStubAstBinding) {
    String creationTrace = "Creation thread: " + Thread.currentThread() + "\n" + DebugUtil.currentStackTrace();
    if (stub != null) {
      creationTrace += "\nfrom stub " + stub + "@" + System.identityHashCode(stub) + "\n";
      if (stub instanceof UserDataHolder) {
        String stubTrace = ((UserDataHolder)stub).getUserData(CREATION_TRACE);
        if (stubTrace != null) {
          creationTrace += stubTrace;
        }
      }
    }
    putUserData(CREATION_TRACE, creationTrace);
  }
}
项目:tools-idea    文件:ChainCompletionContext.java   
public Collection<?> getContextRefElements(final String typeQName) {
  final Collection<PsiVariable> variables = getVariables(typeQName);
  final Collection<PsiMethod> containingClassMethods = getContainingClassMethods(typeQName);
  final Collection<UserDataHolder> refElements = new ArrayList<UserDataHolder>(variables.size() + containingClassMethods.size());
  refElements.addAll(variables);
  refElements.addAll(containingClassMethods);
  for (final ContextRelevantVariableGetter contextRelevantVariableGetter : getRelevantVariablesGetters(typeQName)) {
    refElements.add(contextRelevantVariableGetter.createLookupElement());
  }
  return refElements;
}