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

项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
@Override
public synchronized TSMetaModel getTypeSystemMeta(@Nullable final PsiFile contextFile) {
    if (contextFile == null || !TSMetaModelBuilder.isTsFile(contextFile)) {
        return myCachedValue.getValue();
    }
    final TSMetaModelImpl externalModel = doGetExternalModel(contextFile);
    final Project project = contextFile.getProject();
    CachedValue<TSMetaModelImpl> fileModelCache = contextFile.getUserData(FILE_MODEL_CACHE_KEY);

    if (fileModelCache == null) {
        fileModelCache = CachedValuesManager.getManager(project).createCachedValue(
            () -> ApplicationManager.getApplication().runReadAction(
                (Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {

                    final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
                    final TSMetaModelImpl modelForFile = builder.buildModelForFile(contextFile);
                    return CachedValueProvider.Result.create(modelForFile, contextFile);

                }), false);
        contextFile.putUserData(FILE_MODEL_CACHE_KEY, fileModelCache);
    }
    final TSMetaModelImpl fileModel = fileModelCache.getValue();
    return new TSMetaModelImpl(Arrays.asList(externalModel, fileModel));
}
项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
    final PsiFile originalFile = contextFile.getOriginalFile();
    final VirtualFile vFile = originalFile.getVirtualFile();
    final Project project = originalFile.getProject();
    CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);

    if (externalModelCache == null) {

        externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
            () -> ApplicationManager.getApplication().runReadAction(
                (Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {

                    final List<VirtualFile> excludes = vFile == null
                        ? Collections.emptyList()
                        : Collections.singletonList(vFile);

                    final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
                    final TSMetaModelImpl model = builder.buildModel();
                    return CachedValueProvider.Result.create(model, builder.getFiles());

                }), false);
        originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
    }
    return externalModelCache.getValue();
}
项目:processing-idea    文件:SketchClassFilter.java   
@Override
public boolean isAccepted(PsiClass klass) {
    return ApplicationManager.getApplication().runReadAction((Computable<Boolean>) () -> {
        if (isSketchClass(klass)) {
            final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project);
            final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(klass);

            if (virtualFile == null) {
                return false;
            }

            return ! compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
                    ! ProjectRootManager.getInstance(project)
                            .getFileIndex()
                            .isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES);
        }

        return false;
    });
}
项目:intellij-ce-playground    文件:ManifestInfo.java   
private <T> List<T> getApplicationComponents(final Function<Application, List<T>> accessor) {
  final List<Manifest> manifests = getManifests();
  if (manifests.isEmpty()) {
    Logger.getInstance(ManifestInfo.class).warn("List of manifests is empty, possibly needs a gradle sync.");
  }

  return ApplicationManager.getApplication().runReadAction(new Computable<List<T>>() {
    @Override
    public List<T> compute() {
      List<T> components = Lists.newArrayList();

      for (Manifest m : manifests) {
        Application application = m.getApplication();
        if (application != null) {
          components.addAll(accessor.fun(application));
        }
      }

      return components;
    }
  });
}
项目:lua-for-idea    文件:AbstractInspection.java   
@Nullable
public PsiElement getElementToolSuppressedIn(
    @NotNull
final PsiElement place, final String toolId) {
    return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
            @Nullable
            public PsiElement compute() {
                final PsiElement statement = getStatementToolSuppressedIn(place,
                        toolId, LuaStatementElement.class);

                if (statement != null) {
                    return statement;
                }

                return null;
            }
        });
}
项目:intellij-ce-playground    文件:PsiProximityComparator.java   
@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
  PsiElement element = elementComputable.compute();
  if (element == null) return null;
  if (element instanceof MetadataPsiElementBase) return null;
  if (context == null) return null;
  Module contextModule = processingContext.get(MODULE_BY_LOCATION);
  if (contextModule == null) {
    contextModule = ModuleUtilCore.findModuleForPsiElement(context);
    processingContext.put(MODULE_BY_LOCATION, contextModule);
  }

  if (contextModule == null) return null;

  return new WeighingComparable<PsiElement,ProximityLocation>(elementComputable,
                                                              new ProximityLocation(context, contextModule, processingContext),
                                                              PROXIMITY_WEIGHERS);
}
项目:intellij-ce-playground    文件:ProjectFileIndexImpl.java   
@Override
public boolean accept(@NotNull final VirtualFile file) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      DirectoryInfo info = getInfoForFileOrDirectory(file);
      if (!info.isInProject() || info.getModule() == null) return false;

      if (file.isDirectory()) {
        return true;
      }
      else {
        return !myFileTypeRegistry.isFileIgnored(file);
      }
    }
  });
}
项目:intellij-ce-playground    文件:AllClassesSearchExecutor.java   
public static boolean processClassesByNames(Project project,
                                            final GlobalSearchScope scope,
                                            Collection<String> names,
                                            Processor<PsiClass> processor) {
  final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
  for (final String name : names) {
    ProgressIndicatorProvider.checkCanceled();
    final PsiClass[] classes = MethodUsagesSearcher.resolveInReadAction(project, new Computable<PsiClass[]>() {
      @Override
      public PsiClass[] compute() {
        return cache.getClassesByName(name, scope);
      }
    });
    for (PsiClass psiClass : classes) {
      ProgressIndicatorProvider.checkCanceled();
      if (!processor.process(psiClass)) {
        return false;
      }
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:GitImpl.java   
@Override
@NotNull
public GitCommandResult clone(@NotNull final Project project, @NotNull final File parentDirectory, @NotNull final String url,
                              @NotNull final String clonedDirectoryName, @NotNull final GitLineHandlerListener... listeners) {
  return run(new Computable<GitLineHandler>() {
    @Override
    public GitLineHandler compute() {
      GitLineHandler handler = new GitLineHandler(project, parentDirectory, GitCommand.CLONE);
      handler.setStdoutSuppressed(false);
      handler.setUrl(url);
      handler.addParameters("--progress");
      handler.addParameters(url);
      handler.endOptions();
      handler.addParameters(clonedDirectoryName);
      addListeners(handler, listeners);
      return handler;
    }
  });
}
项目:intellij-ce-playground    文件:VcsContentAnnotationExceptionFilter.java   
private static List<TextRange> findMethodRange(final ExceptionWorker worker,
                                               final Document document,
                                               final Trinity<PsiClass, PsiFile, String> previousLineResult) {
  return ApplicationManager.getApplication().runReadAction(new Computable<List<TextRange>>() {
    @Override
    public List<TextRange> compute() {
      List<TextRange> ranges = getTextRangeForMethod(worker, previousLineResult);
      if (ranges == null) return null;
      final List<TextRange> result = new ArrayList<TextRange>();
      for (TextRange range : ranges) {
        result.add(new TextRange(document.getLineNumber(range.getStartOffset()),
                                     document.getLineNumber(range.getEndOffset())));
      }
      return result;
    }
  });
}
项目:intellij-ce-playground    文件:TestClassFilter.java   
public boolean isAccepted(final PsiClass aClass) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      if (aClass.getQualifiedName() != null && ConfigurationUtil.PUBLIC_INSTANTIATABLE_CLASS.value(aClass) &&
          (aClass.isInheritor(myBase, true) || JUnitUtil.isTestClass(aClass))) {
        final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(getProject());
        final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(aClass);
        if (virtualFile == null) return false;
        return !compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
               !ProjectRootManager.getInstance(myProject).getFileIndex().isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES);
      }
      return false;
    }
  });
}
项目:intellij-ce-playground    文件:AndroidUtils.java   
@Nullable
public static <T extends DomElement> T loadDomElement(@NotNull final Project project,
                                                      @NotNull final VirtualFile file,
                                                      @NotNull final Class<T> aClass) {
  return ApplicationManager.getApplication().runReadAction(new Computable<T>() {
    @Override
    @Nullable
    public T compute() {
      if (project.isDisposed()) return null;
      PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
      if (psiFile instanceof XmlFile) {
        return loadDomElementWithReadPermission(project, (XmlFile)psiFile, aClass);
      }
      else {
        return null;
      }
    }
  });
}
项目:intellij-ce-playground    文件:IncludeReference.java   
@Nullable
public static String getIncludingLayout(@NotNull final XmlFile file) {
  if (!ApplicationManager.getApplication().isReadAccessAllowed()) {
    return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
      @Nullable
      @Override
      public String compute() {
        return getIncludingLayout(file);
      }
    });
  }
  XmlTag rootTag = file.getRootTag();
  if (rootTag != null && rootTag.isValid()) {
    return rootTag.getAttributeValue(ATTR_RENDER_IN, TOOLS_URI);
  }

  return null;
}
项目:intellij-ce-playground    文件:HeavyIdeaTestFixtureImpl.java   
@Override
public PsiFile addFileToProject(@NotNull @NonNls String rootPath, @NotNull @NonNls final String relativePath, @NotNull @NonNls final String fileText) throws IOException {
  final VirtualFile dir = VfsUtil.createDirectories(rootPath + "/" + PathUtil.getParentPath(relativePath));

  final VirtualFile[] virtualFile = new VirtualFile[1];
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      virtualFile[0] = dir.createChildData(this, StringUtil.getShortName(relativePath, '/'));
      VfsUtil.saveText(virtualFile[0], fileText);
      PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    }
  }.execute();
  return ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
          @Override
          public PsiFile compute() {
            return PsiManager.getInstance(getProject()).findFile(virtualFile[0]);
          }
        });
}
项目:intellij-ce-playground    文件:PyExceptionBreakpointType.java   
@Override
public boolean isAccepted(@NotNull final PyClass pyClass) {
  final VirtualFile virtualFile = pyClass.getContainingFile().getVirtualFile();
  if (virtualFile == null) {
    return false;
  }

  final int key = pyClass.hashCode();
  final Pair<WeakReference<PyClass>, Boolean> pair = processedElements.get(key);
  boolean isException;
  if (pair == null || pair.first.get() != pyClass) {
    isException = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
      @Override
      public Boolean compute() {
        return PyUtil.isExceptionClass(pyClass);
      }
    });
    processedElements.put(key, Pair.create(new WeakReference<PyClass>(pyClass), isException));
  }
  else {
    isException = pair.second;
  }
  return isException;
}
项目:intellij-ce-playground    文件:GrReferenceExpressionImpl.java   
@Override
public GroovyResolveResult[] resolveByShape() {
  final InferenceContext context = TypeInferenceHelper.getCurrentContext();
  return context.getCachedValue(this, new Computable<GroovyResolveResult[]>() {
    @Override
    public GroovyResolveResult[] compute() {
      Pair<GrReferenceExpressionImpl, InferenceContext> key = Pair.create(GrReferenceExpressionImpl.this, context);
      GroovyResolveResult[] value = RecursionManager.doPreventingRecursion(key, true, new Computable<GroovyResolveResult[]>() {
        @Override
        public GroovyResolveResult[] compute() {
          return doPolyResolve(false, false);
        }
      });
      return value == null ? GroovyResolveResult.EMPTY_ARRAY : value;
    }
  });
}
项目:intellij-ce-playground    文件:CachedEvaluator.java   
protected ExpressionEvaluator getEvaluator(final Project project) throws EvaluateException {
  Cache cache = myCache.get();
  if(cache == null) {
    cache = PsiDocumentManager.getInstance(project).commitAndRunReadAction(new Computable<Cache>() {
      public Cache compute() {
        return initEvaluatorAndChildrenExpression(project);
      }
    });
  }

  if(cache.myException != null) {
    throw cache.myException;
  }

  return cache.myEvaluator;
}
项目:intellij-ce-playground    文件:AndroidModuleBuilder.java   
@Nullable
private static PsiDirectory createPackageIfPossible(final PsiDirectory sourceDir, String packageName) {
  if (sourceDir != null) {
    final String[] ids = packageName.split("\\.");
    return ApplicationManager.getApplication().runWriteAction(new Computable<PsiDirectory>() {
      @Override
      public PsiDirectory compute() {
        PsiDirectory dir = sourceDir;
        for (String id : ids) {
          PsiDirectory child = dir.findSubdirectory(id);
          dir = child == null ? dir.createSubdirectory(id) : child;
        }
        return dir;
      }
    });
  }
  return null;
}
项目:intellij-ce-playground    文件:AbstractDataGetter.java   
private void runLoadAroundCommitData(int row, @NotNull GraphTableModel tableModel) {
  long taskNumber = myCurrentTaskIndex++;
  MultiMap<VirtualFile, Integer> commits = getCommitsAround(row, tableModel, UP_PRELOAD_COUNT, DOWN_PRELOAD_COUNT);
  for (Map.Entry<VirtualFile, Collection<Integer>> hashesByRoots : commits.entrySet()) {
    VirtualFile root = hashesByRoots.getKey();
    Collection<Integer> hashes = hashesByRoots.getValue();

    // fill the cache with temporary "Loading" values to avoid producing queries for each commit that has not been cached yet,
    // even if it will be loaded within a previous query
    for (final int commitId : hashes) {
      if (!myCache.isKeyCached(commitId)) {
        myCache.put(commitId, (T)new LoadingDetails(new Computable<Hash>(){

          @Override
          public Hash compute() {
            return myHashMap.getHash(commitId);
          }
        }, taskNumber, root));
      }
    }
  }

  TaskDescriptor task = new TaskDescriptor(commits);
  myLoader.queue(task);
}
项目:intellij-ce-playground    文件:JavaBreakpointTypeBase.java   
@Nullable
@Override
public XSourcePosition getSourcePosition(@NotNull XBreakpoint<T> breakpoint) {
  Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
  if (javaBreakpoint != null) {
    final PsiClass aClass = javaBreakpoint.getPsiClass();
    if (aClass != null) {
      return ApplicationManager.getApplication().runReadAction(new Computable<XSourcePosition>() {
        @Override
        public XSourcePosition compute() {
          PsiFile containingFile = aClass.getContainingFile();
          if (containingFile != null && aClass.getTextOffset() >= 0) {
            return XDebuggerUtil.getInstance().createPositionByOffset(containingFile.getVirtualFile(), aClass.getTextOffset());
          }
          return null;
        }
      });
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ExceptionBreakpoint.java   
public void createRequest(final DebugProcessImpl debugProcess) {
  DebuggerManagerThreadImpl.assertIsManagerThread();
  if (!shouldCreateRequest(debugProcess)) {
    return;
  }

  SourcePosition classPosition = ApplicationManager.getApplication().runReadAction(new Computable<SourcePosition>() {
    public SourcePosition compute() {
      PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());

      return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
    }
  });

  if(classPosition == null) {
    createOrWaitPrepare(debugProcess, getQualifiedName());
  }
  else {
    createOrWaitPrepare(debugProcess, classPosition);
  }
}
项目:intellij-ce-playground    文件:JavaCoverageViewExtension.java   
private void processSubPackage(final PsiPackage aPackage, List<AbstractTreeNode> children) {
  if (ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    public Boolean compute() {
      return isInCoverageScope(aPackage);
    }
  })) {
    final CoverageListNode node = new CoverageListNode(aPackage.getProject(), aPackage, mySuitesBundle, myStateBean);
    children.add(node);
  }
  else if (!myStateBean.myFlattenPackages) {
    collectSubPackages(children, aPackage);
  }
  if (myStateBean.myFlattenPackages) {
    collectSubPackages(children, aPackage);
  }
}
项目:intellij-ce-playground    文件:GradleSyncTest.java   
@Test @IdeGuiTest
public void testSyncWithUnresolvedDependenciesWithAndroidGradlePluginOneDotZero() throws IOException {
  IdeFrameFixture projectFrame = importSimpleApplication();

  VirtualFile projectBuildFile = projectFrame.findFileByRelativePath("build.gradle", true);
  Document document = getDocument(projectBuildFile);
  assertNotNull(document);

  updateGradleDependencyVersion(projectFrame.getProject(), document, GRADLE_PLUGIN_NAME, new Computable<String>() {
    @Override
    public String compute() {
      return "1.0.0";
    }
  });

  testSyncWithUnresolvedAppCompat(projectFrame);
}
项目:intellij-ce-playground    文件:CommittedChangesCache.java   
private static List<CommittedChangeList> writeChangesInReadAction(final ChangesCacheFile cacheFile,
                                                                  final List<CommittedChangeList> newChanges) throws IOException {
  // ensure that changes are loaded before taking read action, to avoid stalling UI
  for(CommittedChangeList changeList: newChanges) {
    changeList.getChanges();
  }
  final Ref<IOException> ref = new Ref<IOException>();
  final List<CommittedChangeList> savedChanges = ApplicationManager.getApplication().runReadAction(new Computable<List<CommittedChangeList>>() {
    @Override
    public List<CommittedChangeList> compute() {
      try {
        return cacheFile.writeChanges(newChanges);    // skip duplicates;
      }
      catch (IOException e) {
        ref.set(e);
        return null;
      }
    }
  });
  if (!ref.isNull()) {
    throw ref.get();
  }
  return savedChanges;
}
项目:intellij-ce-playground    文件:PurityInference.java   
public static boolean inferPurity(@NotNull final PsiMethod method) {
  if (!InferenceFromSourceUtil.shouldInferFromSource(method) ||
      method.getReturnType() == PsiType.VOID ||
      method.getBody() == null ||
      method.isConstructor() || 
      PropertyUtil.isSimpleGetter(method)) {
    return false;
  }

  return CachedValuesManager.getCachedValue(method, new CachedValueProvider<Boolean>() {
    @Nullable
    @Override
    public Result<Boolean> compute() {
      boolean pure = RecursionManager.doPreventingRecursion(method, true, new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          return doInferPurity(method);
        }
      }) == Boolean.TRUE;
      return Result.create(pure, method);
    }
  });
}
项目:intellij-ce-playground    文件:TestNGTestObject.java   
public static void collectTestMethods(Map<PsiClass, Map<PsiMethod, List<String>>> classes,
                                      final PsiClass psiClass,
                                      final String methodName,
                                      final GlobalSearchScope searchScope) {
  final PsiMethod[] methods = ApplicationManager.getApplication().runReadAction(
    new Computable<PsiMethod[]>() {
      public PsiMethod[] compute() {
        return psiClass.findMethodsByName(methodName, true);
      }
    }
  );
  calculateDependencies(methods, classes, searchScope, psiClass);
  Map<PsiMethod, List<String>> psiMethods = classes.get(psiClass);
  if (psiMethods == null) {
    psiMethods = new LinkedHashMap<PsiMethod, List<String>>();
    classes.put(psiClass, psiMethods);
  }
  for (PsiMethod method : methods) {
    if (!psiMethods.containsKey(method)) {
      psiMethods.put(method, Collections.<String>emptyList());
    }
  }
}
项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
public TSMetaModelAccessImpl(@NotNull final Project project) {
    myCachedValue = CachedValuesManager.getManager(project).createCachedValue(
        () -> ApplicationManager.getApplication().runReadAction(
            (Computable<CachedValueProvider.Result<TSMetaModel>>) () -> {

                final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
                final TSMetaModelImpl model = builder.buildModel();
                return CachedValueProvider.Result.create(model, builder.getFiles());

            }), false);
}
项目:intellij-ce-playground    文件:RefManagerImpl.java   
@NotNull
private static PsiAnchor createAnchor(@NotNull final PsiElement element) {
  return ApplicationManager.getApplication().runReadAction(
    new Computable<PsiAnchor>() {
      @Override
      public PsiAnchor compute() {
        return PsiAnchor.create(element);
      }
    }
  );
}
项目:intellij-ce-playground    文件:SchemaDefinitionsSearch.java   
private String getDefaultNs(final XmlFile file) {
  return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      String nsUri;
      final XmlTag tag = file.getDocument().getRootTag();
      XmlAttribute xmlns = tag.getAttribute("xmlns", XmlUtil.XML_SCHEMA_URI);
      xmlns = xmlns == null ? tag.getAttribute("xmlns") : xmlns;
      nsUri = xmlns == null ? null : xmlns.getValue();
      return nsUri;
    }
  });
}
项目:intellij-ce-playground    文件:AgentTaskExecutor.java   
public <T> T execute(Computable<T> task) throws ServerRuntimeException {
  clear();
  T result = task.compute();
  if (myErrorMessage == null) {
    return result;
  }
  else {
    throw new ServerRuntimeException(myErrorMessage);
  }
}
项目:intellij-ce-playground    文件:HighlightDisplayKey.java   
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull final String name,
                                           @NotNull final Computable<String> displayName,
                                           @NotNull @NonNls final String id) {
  if (find(name) != null) {
    LOG.info("Key with name \'" + name + "\' already registered");
    return null;
  }
  HighlightDisplayKey highlightDisplayKey = new HighlightDisplayKey(name, id);
  ourKeyToDisplayNameMap.put(highlightDisplayKey, displayName);
  return highlightDisplayKey;
}
项目:intellij-ce-playground    文件:WeighingComparable.java   
public WeighingComparable(final Computable<T> element,
                          @Nullable final Loc location,
                          final Weigher<T,Loc>[] weighers) {
  myElement = element;
  myLocation = location;
  myWeighers = weighers;
  myComputedWeighs = new Comparable[weighers.length];
}
项目:PackageTemplates    文件:CreateDirectoryAction.java   
private void createSubDir(PsiDirectory psiParent, String name) {
    ApplicationManager.getApplication().invokeAndWait(() -> {
                Runnable runnable = () ->
                        psiDirectoryResult = ApplicationManager.getApplication().runWriteAction(
                                (Computable<PsiDirectory>) () -> psiParent.createSubdirectory(name));

                CommandProcessor.getInstance().executeCommand(project, runnable, "testId", "testId");
            }
    , ModalityState.defaultModalityState());
}
项目:intellij-ce-playground    文件:SliceLeafAnalyzer.java   
@Override
public boolean equals(final PsiElement o1, final PsiElement o2) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      return o1 != null && o2 != null && PsiEquivalenceUtil.areElementsEquivalent(o1, o2);
    }
  });
}
项目:intellij-ce-playground    文件:DefinitionsScopedSearch.java   
@NotNull
public SearchScope getScope() {
  return ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
    @Override
    public SearchScope compute() {
      return myScope.intersectWith(PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(myElement));
    }
  });
}
项目:intellij-ce-playground    文件:AntBuildModelImpl.java   
@Nullable
public AntBuildTargetBase findTarget(final String name) {
  return ApplicationManager.getApplication().runReadAction(new Computable<AntBuildTargetBase>() {
    @Nullable
    public AntBuildTargetBase compute() {
      return findTargetImpl(name, AntBuildModelImpl.this);
    }
  });
}
项目:intellij-ce-playground    文件:JavaFxControllerClassIndex.java   
public static <T> List<T> findFxmlWithController(final Project project,
                                                   @NotNull final String className,
                                                   final Function<VirtualFile, T> f,
                                                   final GlobalSearchScope scope) {
  return ApplicationManager.getApplication().runReadAction(new Computable<List<T>>() {
    @Override
    public List<T> compute() {
      final Collection<VirtualFile> files;
      try {
        files = FileBasedIndex.getInstance().getContainingFiles(NAME, className,
                                                                GlobalSearchScope.projectScope(project).intersectWith(scope));
      }
      catch (IndexNotReadyException e) {
        return Collections.emptyList();
      }
      if (files.isEmpty()) return Collections.emptyList();
      List<T> result = new ArrayList<T>();
      for (VirtualFile file : files) {
        if (!file.isValid()) continue;
        final T fFile = f.fun(file);
        if (fFile != null) { 
          result.add(fFile);
        }
      }
      return result;
    }
  });
}
项目:intellij-ce-playground    文件:HighlightDisplayKey.java   
/**
 * @see #register(String, com.intellij.openapi.util.Computable, String)
 */
@Nullable
public static HighlightDisplayKey register(@NonNls @NotNull final String name,
                                           @NotNull final String displayName,
                                           @NotNull @NonNls final String id) {
  return register(name, new Computable.PredefinedValueComputable<String>(displayName), id);
}
项目:intellij-ce-playground    文件:JavaClassInheritorsSearcher.java   
private static boolean isFinal(@NotNull final PsiClass baseClass) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      return Boolean.valueOf(baseClass.hasModifierProperty(PsiModifier.FINAL));
    }
  }).booleanValue();
}
项目:intellij-ce-playground    文件:AbstractProjectDataService.java   
@Override
public void removeData(@NotNull Computable<Collection<I>> toRemoveComputable,
                       @NotNull Collection<DataNode<E>> toIgnore,
                       @NotNull ProjectData projectData,
                       @NotNull Project project,
                       @NotNull IdeModifiableModelsProvider modelsProvider) {
}