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


Java PsiUtilCore.getProjectInReadAction方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiUtilCore.getProjectInReadAction方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtilCore.getProjectInReadAction方法的具体用法?Java PsiUtilCore.getProjectInReadAction怎么用?Java PsiUtilCore.getProjectInReadAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PsiUtilCore的用法示例。


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

示例1: SearchParameters

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public SearchParameters(@NotNull PsiMethod method, @NotNull SearchScope scope, boolean strictSignatureSearch, @Nullable SearchRequestCollector optimizer) {
  myMethod = method;
  myScope = scope;
  myStrictSignatureSearch = strictSignatureSearch;
  isSharedOptimizer = optimizer != null;
  myOptimizer = optimizer != null ? optimizer : new SearchRequestCollector(new SearchSession());
  myProject = PsiUtilCore.getProjectInReadAction(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MethodReferencesSearch.java

示例2: search

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static Query<PsiReference> search(final SearchParameters parameters) {
  final Query<PsiReference> result = INSTANCE.createQuery(parameters);
  if (parameters.isSharedOptimizer) {
    return uniqueResults(result);
  }

  final SearchRequestCollector requests = parameters.getOptimizer();

  Project project = PsiUtilCore.getProjectInReadAction(parameters.getMethod());
  return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(project, requests)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MethodReferencesSearch.java

示例3: SearchParameters

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public SearchParameters(@NotNull PsiElement elementToSearch, @NotNull SearchScope scope, boolean ignoreAccessScope, @Nullable SearchRequestCollector optimizer) {
  myElementToSearch = elementToSearch;
  myScope = scope;
  myIgnoreAccessScope = ignoreAccessScope;
  isSharedOptimizer = optimizer != null;
  myOptimizer = optimizer == null ? new SearchRequestCollector(new SearchSession()) : optimizer;
  myProject = PsiUtilCore.getProjectInReadAction(elementToSearch);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ReferencesSearch.java

示例4: processInheritors

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static void processInheritors(@NotNull final Processor<PsiClass> consumer,
                                         @NotNull final PsiClass baseClass,
                                         @NotNull final SearchScope searchScope,
                                         @NotNull final ClassInheritorsSearch.SearchParameters parameters) {
  if (baseClass instanceof PsiAnonymousClass || isFinal(baseClass)) return;

  Project project = PsiUtilCore.getProjectInReadAction(baseClass);
  if (isJavaLangObject(baseClass)) {
    AllClassesSearch.search(searchScope, project, parameters.getNameCondition()).forEach(new Processor<PsiClass>() {
      @Override
      public boolean process(final PsiClass aClass) {
        ProgressManager.checkCanceled();
        return isJavaLangObject(aClass) || consumer.process(aClass);
      }
    });
    return;
  }

  final Ref<PsiClass> currentBase = Ref.create(null);
  final Stack<PsiAnchor> stack = new Stack<PsiAnchor>();
  final Set<PsiAnchor> processed = ContainerUtil.newTroveSet();

  final Processor<PsiClass> processor = new ReadActionProcessor<PsiClass>() {
    @Override
    public boolean processInReadAction(PsiClass candidate) {
      ProgressManager.checkCanceled();

      if (parameters.isCheckInheritance() || parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass)) {
        if (!candidate.isInheritor(currentBase.get(), false)) {
          return true;
        }
      }

      if (PsiSearchScopeUtil.isInScope(searchScope, candidate)) {
        if (candidate instanceof PsiAnonymousClass) {
          return consumer.process(candidate);
        }
        
        final String name = candidate.getName();
        if (name != null && parameters.getNameCondition().value(name) && !consumer.process(candidate)) {
          return false;
        }
      }

      if (parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass) && !isFinal(candidate)) {
        stack.push(PsiAnchor.create(candidate));
      }
      return true;
    }
  };
  
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      stack.push(PsiAnchor.create(baseClass));
    }
  });
  final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project);
  
  while (!stack.isEmpty()) {
    ProgressManager.checkCanceled();

    final PsiAnchor anchor = stack.pop();
    if (!processed.add(anchor)) continue;

    PsiClass psiClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
        @Override
        public PsiClass compute() {
          return (PsiClass)anchor.retrieve();
        }
      });
    if (psiClass == null) continue;

    currentBase.set(psiClass);
    if (!DirectClassInheritorsSearch.search(psiClass, projectScope, parameters.isIncludeAnonymous(), false).forEach(processor)) return;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:JavaClassInheritorsSearcher.java

示例5: execute

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
  final PsiElement elementToSearch = queryParameters.getElementToSearch();
  if (elementToSearch instanceof PsiField) {
    final PsiField field = (PsiField)elementToSearch;
    final PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
      @Override
      public PsiClass compute() {
        return field.getContainingClass();
      }
    });
    if (containingClass != null) {
      final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
        @Override
        public String compute() {
          return containingClass.getQualifiedName(); 
        }
      });
      if (qualifiedName != null) {
        Project project = PsiUtilCore.getProjectInReadAction(containingClass);
        final List<PsiFile> fxmlWithController =
          JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName);
        for (final PsiFile file : fxmlWithController) {
          ApplicationManager.getApplication().runReadAction(new Runnable() {
            @Override
            public void run() {
              final String fieldName = field.getName();
              final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
              final SearchScope searchScope = queryParameters.getEffectiveSearchScope();
              boolean contains = searchScope instanceof LocalSearchScope ? ((LocalSearchScope)searchScope).isInScope(virtualFile) :
                                 ((GlobalSearchScope)searchScope).contains(virtualFile);
              if (contains) {
                file.accept(new XmlRecursiveElementVisitor() {
                  @Override
                  public void visitXmlAttributeValue(final XmlAttributeValue value) {
                    final PsiReference reference = value.getReference();
                    if (reference != null) {
                      final PsiElement resolve = reference.resolve();
                      if (resolve instanceof XmlAttributeValue) {
                        final PsiElement parent = resolve.getParent();
                        if (parent instanceof XmlAttribute) {
                          final XmlAttribute attribute = (XmlAttribute)parent;
                          if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) {
                            consumer.process(reference);
                          }
                        }
                      }
                    }
                  }
                });
              }
            }
          });
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:JavaFxControllerFieldSearcher.java

示例6: execute

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull SearchParameters queryParameters, @NotNull Processor<SchemaTypeDef> consumer) {

  final SchemaTypeDef target = queryParameters.schemaTypeDef;
  final Project project = PsiUtilCore.getProjectInReadAction(target);
  Application application = ApplicationManager.getApplication();

  List<SchemaTypeDef> candidates = application.runReadAction(
      (Computable<List<SchemaTypeDef>>) () -> SchemaIndexUtil.findTypeDefs(project, null, null, SchemaSearchScopeUtil.getSearchScope(target))
  );

  final List<SchemaTypeDef> children = new ArrayList<>();

  for (SchemaTypeDef candidate : candidates) {
    ProgressManager.checkCanceled();

    application.runReadAction(() -> {
      List<SchemaTypeDef> candidateParents = candidate.extendsParents();
      children.addAll(
          candidateParents.stream()
              .filter(target::equals)
              .map(candidateParent -> candidate)
              .collect(Collectors.toList()));
    });

  }

  // -- process 'supplements'

  if (target instanceof SchemaRecordTypeDef) {
    SchemaRecordTypeDef recordTypeDef = (SchemaRecordTypeDef) target;
    children.addAll(application.runReadAction((Computable<List<SchemaTypeDef>>) recordTypeDef::supplemented));
  } else if (target instanceof SchemaEntityTypeDef) {
    SchemaEntityTypeDef entityTypeDef = (SchemaEntityTypeDef) target;
    children.addAll(application.runReadAction((Computable<List<SchemaTypeDef>>) entityTypeDef::supplemented));
  }

  // -- process 'supplement x with y'

  application.runReadAction(() -> {
    List<SchemaSupplementDef> supplements = SchemaIndexUtil.findSupplementsBySource(project, target);
    for (SchemaSupplementDef supplement : supplements) {
      children.addAll(supplement.supplemented());
    }
  });

  children.forEach(consumer::process);

  return true;
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:51,代码来源:SchemaDirectTypeInheritorsSearcher.java

示例7: execute

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
  public boolean execute(@NotNull SearchParameters queryParameters, @NotNull Processor<SchemaTypeDef> consumer) {

    final SchemaTypeDef target = queryParameters.schemaTypeDef;
    final Project project = PsiUtilCore.getProjectInReadAction(target);
    final VirtualFile targetVirtualFile = VirtualFileUtil.getOriginalVirtualFile(target.getContainingFile());
    if (targetVirtualFile == null) return true;

    final Application application = ApplicationManager.getApplication();

    final List<SchemaTypeDef> parents = new ArrayList<>();

    if (queryParameters.includeExtends) {
      application.runReadAction(() -> {
        parents.addAll(target.extendsParents());
      });
    }

    // -- process 'supplements'

    if (queryParameters.includeSupplements) {

      List<SchemaTypeDef> candidates = application.runReadAction(
          (Computable<List<SchemaTypeDef>>) () -> SchemaIndexUtil.findTypeDefs(project, null, null, GlobalSearchScope.allScope(project))
      );

      for (SchemaTypeDef candidate : candidates) {
        ProgressManager.checkCanceled();

        application.runReadAction(() -> {

          // supplemented type must be in the candidate's search scope
          final GlobalSearchScope candidateScope = SchemaSearchScopeUtil.getSearchScope(candidate);
          if (candidateScope.contains(targetVirtualFile)) {

            List<SchemaTypeDef> supplementedList = null;
            if (candidate instanceof SchemaRecordTypeDef) {
              SchemaRecordTypeDef recordTypeDef = (SchemaRecordTypeDef) candidate;
              supplementedList = recordTypeDef.supplemented();
            } else if (candidate instanceof SchemaEntityTypeDef) {
              SchemaEntityTypeDef entityTypeDef = (SchemaEntityTypeDef) candidate;
              supplementedList = entityTypeDef.supplemented();
            }

            if (supplementedList != null && supplementedList.stream().anyMatch(target::equals))
              parents.add(candidate);

//            parents.addAll(
//                supplementedList.stream()
//                    .filter(target::equals)
//                    .map(candidateChild -> candidate)
//                    .collect(Collectors.toList()));
          }
        });
      }
    }

    // -- process 'supplement x with y'

    if (queryParameters.includeStandaloneSupplements) {
      application.runReadAction(() -> {
        List<SchemaSupplementDef> supplements = SchemaIndexUtil.findSupplementsBySupplemented(project, target);
        parents.addAll(supplements.stream()
            .map(SchemaSupplementDef::source)
            .filter(Objects::nonNull)
            .collect(Collectors.toList()));
      });
    }

    parents.forEach(consumer::process);

    return true;
  }
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:74,代码来源:SchemaDirectTypeParentsSearcher.java


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