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


Java SearchScope类代码示例

本文整理汇总了Java中com.intellij.psi.search.SearchScope的典型用法代码示例。如果您正苦于以下问题:Java SearchScope类的具体用法?Java SearchScope怎么用?Java SearchScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processImplementations

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
public static boolean processImplementations(final PsiClass psiClass, final Processor<PsiElement> processor, SearchScope scope) {
  if (!FunctionalExpressionSearch.search(psiClass, scope).forEach(new Processor<PsiFunctionalExpression>() {
    @Override
    public boolean process(PsiFunctionalExpression expression) {
      return processor.process(expression);
    }
  })) {
    return false;
  }

  final boolean showInterfaces = Registry.is("ide.goto.implementation.show.interfaces");
  return ClassInheritorsSearch.search(psiClass, scope, true).forEach(new PsiElementProcessorAdapter<PsiClass>(new PsiElementProcessor<PsiClass>() {
    public boolean execute(@NotNull PsiClass element) {
      if (!showInterfaces && element.isInterface()) {
        return true;
      }
      return processor.process(element);
    }
  }));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ClassImplementationsSearch.java

示例2: findReferencesToHighlight

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@NotNull
@Override
public Collection<PsiReference> findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) {
  if (target instanceof PyImportedModule) {
    target = ((PyImportedModule) target).resolve();
  }
  if (target instanceof PyFile && PyNames.INIT_DOT_PY.equals(((PyFile)target).getName())) {
    List<PsiReference> result = new ArrayList<PsiReference>();
    result.addAll(super.findReferencesToHighlight(target, searchScope));
    PsiElement targetDir = PyUtil.turnInitIntoDir(target);
    if (targetDir != null) {
      result.addAll(ReferencesSearch.search(targetDir, searchScope, false).findAll());
    }
    return result;
  }
  return super.findReferencesToHighlight(target, searchScope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyModuleFindUsagesHandler.java

示例3: processQuery

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
public void processQuery(@NotNull final ReferencesSearch.SearchParameters params,
                         @NotNull final Processor<PsiReference> consumer) {
  final PsiElement element = params.getElementToSearch();
  if (!(element instanceof PyElement) && !(element instanceof PsiDirectory)) {
    return;
  }

  SearchScope searchScope = params.getEffectiveSearchScope();
  if (searchScope instanceof GlobalSearchScope) {
    searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, PythonFileType.INSTANCE);
  }

  String name = PyUtil.computeElementNameForStringSearch(element);

  if (StringUtil.isEmpty(name)) {
    return;
  }
  params.getOptimizer().searchWord(name, searchScope, UsageSearchContext.IN_STRINGS, true, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PyStringReferenceSearch.java

示例4: SearchForUsagesRunnable

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
SearchForUsagesRunnable(@NotNull UsageViewManagerImpl usageViewManager,
                        @NotNull Project project,
                        @NotNull AtomicReference<UsageViewImpl> usageViewRef,
                        @NotNull UsageViewPresentation presentation,
                        @NotNull UsageTarget[] searchFor,
                        @NotNull Factory<UsageSearcher> searcherFactory,
                        @NotNull FindUsagesProcessPresentation processPresentation,
                        @NotNull SearchScope searchScopeToWarnOfFallingOutOf,
                        @Nullable UsageViewManager.UsageViewStateListener listener) {
  myProject = project;
  myUsageViewRef = usageViewRef;
  myPresentation = presentation;
  mySearchFor = searchFor;
  mySearcherFactory = searcherFactory;
  myProcessPresentation = processPresentation;
  mySearchScopeToWarnOfFallingOutOf = searchScopeToWarnOfFallingOutOf;
  myListener = listener;
  myUsageViewManager = usageViewManager;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SearchForUsagesRunnable.java

示例5: processQuery

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@Override
public void processQuery(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
  new ReadAction() {
    @Override
    protected void run(@NotNull final Result result) throws Throwable {
      final PsiElement refElement = queryParameters.getElementToSearch();
      if (PyMagicLiteralTools.isMagicLiteral(refElement)) {
        final String refText = ((StringLiteralExpression)refElement).getStringValue();
        if (!StringUtil.isEmpty(refText)) {
          final SearchScope searchScope = queryParameters.getEffectiveSearchScope();
          queryParameters.getOptimizer().searchWord(refText, searchScope, true, refElement);
        }
      }
    }
  }.execute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PyMagicLiteralReferenceSearcher.java

示例6: getLocalUseScope

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@NotNull
@Override
public SearchScope getLocalUseScope() {
    final XmlTag tag = getTag();
    if (!tag.isValid()) {
        return getDefaultUseScope();
    }
    final XsltTemplate template = getTemplate();
    if (template == null) {
        return getDefaultUseScope();
    }
    if (template.getName() == null) {
        return getDefaultUseScope();
    }
    final XmlFile file = (XmlFile)tag.getContainingFile();
    if (!XsltIncludeIndex.processBackwardDependencies(file, new CommonProcessors.FindFirstProcessor<XmlFile>())) {
        // processor found something
        return getDefaultUseScope();
    }
    return new LocalSearchScope(file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XsltParameterImpl.java

示例7: getAdditionalUseScope

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
  if (element instanceof PomTargetPsiElement) {
    PomTarget target = ((PomTargetPsiElement)element).getTarget();
    if (target instanceof DomTarget) {
      DomElement domElement = ((DomTarget)target).getDomElement();
      if (domElement instanceof ExtensionPoint) {
        return createProjectXmlFilesScope(element);
      }
    }
  }

  if (element instanceof PsiClass &&
      PsiUtil.isIdeaProject(element.getProject()) &&
      ((PsiClass)element).hasModifierProperty(PsiModifier.PUBLIC)) {
    return createProjectXmlFilesScope(element);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:DevKitUseScopeEnlarger.java

示例8: satisfiedBy

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiClass)) {
    return false;
  }
  final PsiClass aClass = (PsiClass)parent;
  if (!aClass.isInterface() || aClass.isAnnotationType()) {
    return false;
  }
  final PsiElement leftBrace = aClass.getLBrace();
  final int offsetInParent = element.getStartOffsetInParent();
  if (leftBrace == null ||
      offsetInParent >= leftBrace.getStartOffsetInParent()) {
    return false;
  }
  final SearchScope useScope = aClass.getUseScope();
  for (PsiClass inheritor :
    ClassInheritorsSearch.search(aClass, useScope, true)) {
    if (inheritor.isInterface()) {
      return false;
    }
  }
  return !AnnotationUtil.isAnnotated(aClass, CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE, false, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ConvertInterfaceToClassPredicate.java

示例9: getUseScope

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@Override
@NotNull
public SearchScope getUseScope() {
  if (!isPhysical()) {
    final PsiFile file = getContainingFile();
    final PsiElement context = file.getContext();
    if (context != null) return new LocalSearchScope(context);
    return super.getUseScope();
  }

  final PsiElement scope = getDeclarationScope();
  if (scope instanceof GrDocCommentOwner) {
    GrDocCommentOwner owner = (GrDocCommentOwner)scope;
    final GrDocComment comment = owner.getDocComment();
    if (comment != null) {
      return new LocalSearchScope(new PsiElement[]{scope, comment});
    }
  }

  return new LocalSearchScope(scope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GrParameterImpl.java

示例10: searchStringExpressions

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@NotNull
public static Set<Pair<PsiElement, String>> searchStringExpressions(@NotNull final PsiMethod psiMethod,
                                                                    @NotNull SearchScope searchScope,
                                                                    int expNum) {
  Set<Pair<PsiElement, String>> pairs = new com.intellij.util.containers.HashSet<Pair<PsiElement, String>>();
  for (PsiMethodCallExpression methodCallExpression : searchMethodCalls(psiMethod, searchScope)) {
    final PsiExpression[] expressions = methodCallExpression.getArgumentList().getExpressions();
    if (expressions.length > expNum) {
      final PsiExpression expression = expressions[expNum];
      Pair<PsiElement, String> pair = evaluateExpression(expression);
      if (pair != null) {
        pairs.add(pair);
      }
    }
  }

  return pairs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:StringExpressionHelper.java

示例11: searchMethodCalls

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@NotNull
public static Set<PsiMethodCallExpression> searchMethodCalls(@NotNull final PsiMethod psiMethod, @NotNull SearchScope searchScope) {
  final Set<PsiMethodCallExpression> callExpressions = new com.intellij.util.containers.HashSet<PsiMethodCallExpression>();
  final CommonProcessors.CollectUniquesProcessor<PsiReference> consumer = new CommonProcessors.CollectUniquesProcessor<PsiReference>();

  MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(consumer);

  for (PsiReference psiReference : consumer.getResults()) {
    final PsiMethodCallExpression methodCallExpression =
      PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class);

    if (methodCallExpression != null) {
      callExpressions.add(methodCallExpression);
    }
  }


  return callExpressions;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StringExpressionHelper.java

示例12: processQuery

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
  final PsiMethod method = p.getMethod();
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) return;

  final String name = method.getName();
  if (StringUtil.isEmpty(name)) return;

  final boolean strictSignatureSearch = p.isStrictSignatureSearch();
  final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(name, false);

  SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods);
  final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getEffectiveSearchScope(), accessScope);

  final String textToSearch = findLongestWord(name);

  p.getOptimizer().searchWord(textToSearch, restrictedByAccess, UsageSearchContext.IN_STRINGS, true, method,
                              new MethodTextOccurrenceProcessor(aClass, strictSignatureSearch, methods));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GrLiteralMethodSearcher.java

示例13: getAdditionalResolveScope

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
  ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
  if (index.isInLibraryClasses(file) || index.isInContent(file)) {
    return null;
  }

  String fileExtension = file.getExtension();
  if ("class".equals(fileExtension) || JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
    for (PsiElementFinder finder : Extensions.getExtensions(PsiElementFinder.EP_NAME, project)) {
      if (finder instanceof NonClasspathClassFinder) {
        final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots();
        for (VirtualFile root : roots) {
          if (VfsUtilCore.isAncestor(root, file, true)) {
            return NonClasspathDirectoriesScope.compose(roots);
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:NonClasspathResolveScopeEnlarger.java

示例14: findReferencesToHighlight

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
@NotNull
@Override
public Collection<PsiReference> findReferencesToHighlight(@NotNull final PsiElement target, @NotNull final SearchScope searchScope) {
  if (target instanceof PsiMethod) {
    final PsiMethod[] superMethods = ((PsiMethod)target).findDeepestSuperMethods();
    if (superMethods.length == 0) {
      return MethodReferencesSearch.search((PsiMethod)target, searchScope, true).findAll();
    }
    final Collection<PsiReference> result = new ArrayList<PsiReference>();
    for (PsiMethod superMethod : superMethods) {
      result.addAll(MethodReferencesSearch.search(superMethod, searchScope, true).findAll());
    }
    return result;
  }
  return super.findReferencesToHighlight(target, searchScope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaFindUsagesHandler.java

示例15: findReferences

import com.intellij.psi.search.SearchScope; //导入依赖的package包/类
public List<PsiReference> findReferences(PsiField field, int maxNumberOfResults) {
    PsiClass fieldClass = PsiTypesUtil.getPsiClass(field.getType());
    if (fieldClass == null) {
        return Collections.emptyList();
    }
    Project project = field.getProject();
    PsiManager manager = PsiManager.getInstance(project);
    JGivenUsageProvider usageProvider = new JGivenUsageProvider(scenarioStateProvider, resolutionHandler, new ReferenceFactory(manager));
    StateReferenceProcessor processor = new StateReferenceProcessor(field, maxNumberOfResults, usageProvider);

    SearchScope scope = GlobalSearchScope.everythingScope(project).intersectWith(javaFilesScope(project));

    findPsiFields(project, (GlobalSearchScope) scope, processor);
    return processor.getResults();
}
 
开发者ID:TNG,项目名称:jgiven-intellij-plugin,代码行数:16,代码来源:ScenarioStateReferenceProvider.java


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