Java 类com.intellij.psi.search.SearchScope 实例源码

项目:intellij-ce-playground    文件:ClassImplementationsSearch.java   
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);
    }
  }));
}
项目:intellij-ce-playground    文件:PyModuleFindUsagesHandler.java   
@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);
}
项目:intellij-ce-playground    文件:PyStringReferenceSearch.java   
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);
}
项目:intellij-ce-playground    文件:SearchForUsagesRunnable.java   
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;
}
项目:intellij-ce-playground    文件:PyMagicLiteralReferenceSearcher.java   
@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();
}
项目:intellij-ce-playground    文件:XsltParameterImpl.java   
@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);
}
项目:intellij-ce-playground    文件:DevKitUseScopeEnlarger.java   
@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;
}
项目:intellij-ce-playground    文件:ConvertInterfaceToClassPredicate.java   
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);
}
项目:intellij-ce-playground    文件:GrParameterImpl.java   
@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);
}
项目:intellij-ce-playground    文件:StringExpressionHelper.java   
@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;
}
项目:intellij-ce-playground    文件:StringExpressionHelper.java   
@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;
}
项目:intellij-ce-playground    文件:GrLiteralMethodSearcher.java   
@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));
}
项目:intellij-ce-playground    文件:NonClasspathResolveScopeEnlarger.java   
@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;
}
项目:intellij-ce-playground    文件:JavaFindUsagesHandler.java   
@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);
}
项目:jgiven-intellij-plugin    文件:ScenarioStateReferenceProvider.java   
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();
}
项目:jgiven-intellij-plugin    文件:JGivenUseScopeEnlarger.java   
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
    return scenarioStateAnnotationProvider.isJGivenScenarioState(element)
            ? GlobalSearchScope.everythingScope(element.getProject())
            : null;
}
项目:jgiven-intellij-plugin    文件:ReferenceProvider.java   
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
    final PsiElement element = queryParameters.getElementToSearch();

    ApplicationManager.getApplication().runReadAction(() -> {
        SearchScope scope = queryParameters.getEffectiveSearchScope();
        if (!scenarioStateProvider.isJGivenScenarioState(element)
                || !(scope instanceof GlobalSearchScope)) {
            return;
        }
        PsiField field = (PsiField) element;
        scenarioStateReferenceProvider.findReferences(field).forEach(consumer::process);
    });
}
项目:magento2-phpstorm-plugin    文件:LineMarkerXmlTagDecorator.java   
@Override
@NotNull
@Contract(
        pure = true
)
public SearchScope getUseScope() {
    return xmlTag.getUseScope();
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexReferenceSearcher.java   
@Override
public void processQuery(
    @NotNull final ReferencesSearch.SearchParameters queryParameters,
    @NotNull final Processor<PsiReference> consumer
) {
    final PsiElement elementToSearch = queryParameters.getElementToSearch();
    if (!elementToSearch.isValid()) {
        return;
    }

    final SearchScope scope = queryParameters.getEffectiveSearchScope();
    if (!(scope instanceof GlobalSearchScope)) {
        return;
    }

    // search macros usage references
    if (isMacroUsage(elementToSearch) || isMacroNameDeclaration(elementToSearch)) {
        final PsiFile file = elementToSearch.getContainingFile();
        final PsiElement[] results = PsiTreeUtil.collectElements(
            file,
            element -> isMacroUsage(element) && element.textMatches(elementToSearch)
        );
        stream(results)
            .map(ImpexMacrosReferenceBase::new)
            .forEach(consumer::process);
    }
}
项目:intellij-ce-playground    文件:MethodImplementationsSearch.java   
@SuppressWarnings("UnusedDeclaration")
@Deprecated
public static PsiMethod[] getMethodImplementations(final PsiMethod method, SearchScope scope) {
  List<PsiMethod> result = new ArrayList<PsiMethod>();

  getOverridingMethods(method, result, scope);
  return result.toArray(new PsiMethod[result.size()]);
}
项目:intellij-ce-playground    文件:SimpleAccessorReferenceSearcher.java   
static void addPropertyAccessUsages(PsiMethod method, SearchScope scope, SearchRequestCollector collector) {
  final String propertyName = PropertyUtil.getPropertyName(method);
  if (StringUtil.isNotEmpty(propertyName)) {
    SearchScope additional = GlobalSearchScope.EMPTY_SCOPE;
    for (CustomPropertyScopeProvider provider : Extensions.getExtensions(CustomPropertyScopeProvider.EP_NAME)) {
      additional = additional.union(provider.getScope(method.getProject()));
    }
    final SearchScope propScope = scope.intersectWith(method.getUseScope()).intersectWith(additional);
    collector.searchWord(propertyName, propScope, UsageSearchContext.IN_FOREIGN_LANGUAGES, true, method);
  }
}
项目:intellij-ce-playground    文件:ScopeChooserCombo.java   
public void init(final Project project,
                 final boolean suggestSearchInLibs,
                 final boolean prevSearchWholeFiles,
                 final String preselect,
                 @Nullable Condition<ScopeDescriptor> scopeFilter) {
  mySuggestSearchInLibs = suggestSearchInLibs;
  myPrevSearchFiles = prevSearchWholeFiles;
  myProject = project;
  myScopeListener = new NamedScopesHolder.ScopeListener() {
    @Override
    public void scopesChanged() {
      final SearchScope selectedScope = getSelectedScope();
      rebuildModel();
      if (selectedScope != null) {
        selectScope(selectedScope.getDisplayName());
      }
    }
  };
  myScopeFilter = scopeFilter;
  myNamedScopeManager = NamedScopeManager.getInstance(project);
  myNamedScopeManager.addScopeListener(myScopeListener);
  myValidationManager = DependencyValidationManager.getInstance(project);
  myValidationManager.addScopeListener(myScopeListener);
  addActionListener(createScopeChooserListener());

  final JComboBox combo = getComboBox();
  combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer());

  rebuildModel();

  selectScope(preselect);
}
项目:intellij-ce-playground    文件:ConstructorReferencesSearchHelper.java   
private static boolean process18MethodPointers(@NotNull final Processor<PsiReference> processor,
                                               @NotNull final PsiMethod constructor,
                                               @NotNull final Project project,
                                               @NotNull PsiClass aClass, SearchScope searchScope) {
  return ReferencesSearch.search(aClass, searchScope).forEach(new Processor<PsiReference>() {
    @Override
    public boolean process(PsiReference reference) {
      final PsiElement element = reference.getElement();
      if (element != null) {
        return MethodUsagesSearcher.resolveInReadAction(project, new Computable<Boolean>() {
          @Override
          public Boolean compute() {
            final PsiElement parent = element.getParent();
            if (parent instanceof PsiMethodReferenceExpression &&
                ((PsiMethodReferenceExpression)parent).getReferenceNameElement() instanceof PsiKeyword) {
              if (((PsiMethodReferenceExpression)parent).isReferenceTo(constructor)) {
                if (!processor.process((PsiReference)parent)) return false;
              }
            }
            return true;
          }
        });
      }
      return true;
    }
  });
}
项目: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    文件:FindUsagesHandler.java   
public boolean processElementUsages(@NotNull final PsiElement element,
                                    @NotNull final Processor<UsageInfo> processor,
                                    @NotNull final FindUsagesOptions options) {
  final ReadActionProcessor<PsiReference> refProcessor = new ReadActionProcessor<PsiReference>() {
    @Override
    public boolean processInReadAction(final PsiReference ref) {
      TextRange rangeInElement = ref.getRangeInElement();
      return processor.process(new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false));
    }
  };

  final SearchScope scope = options.searchScope;

  final boolean searchText = options.isSearchForTextOccurrences && scope instanceof GlobalSearchScope;

  if (options.isUsages) {
    boolean success =
      ReferencesSearch.search(new ReferencesSearch.SearchParameters(element, scope, false, options.fastTrack)).forEach(refProcessor);
    if (!success) return false;
  }

  if (searchText) {
    if (options.fastTrack != null) {
      options.fastTrack.searchCustom(new Processor<Processor<PsiReference>>() {
        @Override
        public boolean process(Processor<PsiReference> consumer) {
          return processUsagesInText(element, processor, (GlobalSearchScope)scope);
        }
      });
    }
    else {
      return processUsagesInText(element, processor, (GlobalSearchScope)scope);
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:ClassesWithAnnotatedMembersSearcher.java   
@Override
public void processQuery(@NotNull ClassesWithAnnotatedMembersSearch.Parameters queryParameters,
                         @NotNull final Processor<PsiClass> consumer) {
  SearchScope scope = queryParameters.getScope();
  for (QueryExecutor executor : Extensions.getExtensions(ClassesWithAnnotatedMembersSearch.EP_NAME)) {
    if (executor instanceof ScopedQueryExecutor) {
      scope = scope.intersectWith(GlobalSearchScope.notScope(((ScopedQueryExecutor) executor).getScope(queryParameters)));
    }
  }

  final Set<PsiClass> processed = new HashSet<PsiClass>();
  AnnotatedElementsSearch.searchPsiMembers(queryParameters.getAnnotationClass(), scope).forEach(new Processor<PsiMember>() {
    @Override
    public boolean process(PsiMember member) {
      PsiClass psiClass;
      AccessToken token = ReadAction.start();
      try {
        psiClass = member instanceof PsiClass ? (PsiClass)member : member.getContainingClass();
      }
      finally {
        token.finish();
      }

      if (psiClass != null && processed.add(psiClass)) {
        consumer.process(psiClass);
      }

      return true;
    }
  });
}
项目:intellij-ce-playground    文件:ImplementationSearcher.java   
protected static SearchScope getSearchScope(final PsiElement element, final Editor editor) {
  return ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
    @Override
    public SearchScope compute() {
      return TargetElementUtil.getInstance().getSearchScope(editor, element);
    }
  });
}
项目:intellij-ce-playground    文件:DeclareCollectionAsInterfaceInspection.java   
private boolean isCheapEnoughToSearch(PsiNamedElement element) {
  final String name = element.getName();
  if (name == null) {
    return false;
  }
  final ProgressManager progressManager =
    ProgressManager.getInstance();
  final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
  final SearchScope useScope = element.getUseScope();
  if (useScope instanceof GlobalSearchScope) {
    return searchHelper.isCheapEnoughToSearch(name, (GlobalSearchScope)useScope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
  }
  return true;
}
项目:intellij-ce-playground    文件:PsiLocalVariableImpl.java   
@Override
@NotNull
public SearchScope getUseScope() {
  final PsiElement parentElement = getParent();
  if (parentElement instanceof PsiDeclarationStatement) {
    return new LocalSearchScope(parentElement.getParent());
  }
  else {
    return ResolveScopeManager.getElementUseScope(this);
  }
}
项目:intellij-ce-playground    文件:AnalysisScope.java   
public AnalysisScope(@NotNull SearchScope scope, @NotNull Project project) {
  myProject = project;
  myElement = null;
  myModule = null;
  myModules = null;
  myScope = scope;
  myType = CUSTOM;
  mySearchInLibraries = scope instanceof GlobalSearchScope && ((GlobalSearchScope)scope).isSearchInLibraries();
  myVFiles = null;
}
项目:intellij-ce-playground    文件:PsiMethodImpl.java   
@Override
@NotNull
public SearchScope getUseScope() {
  return ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
    @Override
    public SearchScope compute() {
      return PsiImplUtil.getMemberUseScope(PsiMethodImpl.this);
    }
  });
}
项目:intellij-ce-playground    文件:JavaFxScopeEnlarger.java   
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
  PsiClass containingClass = null;
  if (element instanceof PsiField) {
    containingClass = ((PsiField)element).getContainingClass();
  }
  else if (element instanceof PsiParameter) {
    final PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
    if (declarationScope instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)declarationScope)) {
      containingClass = ((PsiMethod)declarationScope).getContainingClass();
    }
  }

  if (containingClass != null) {
    if (element instanceof PsiField && 
        !((PsiField)element).hasModifierProperty(PsiModifier.PUBLIC) && 
        AnnotationUtil.isAnnotated((PsiField)element, JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION, false) || element instanceof PsiParameter) {
      final Project project = element.getProject();
      final String qualifiedName = containingClass.getQualifiedName();
      if (qualifiedName != null && !JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName).isEmpty()) {
        final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
        return new DelegatingGlobalSearchScope(projectScope){
          @Override
          public boolean contains(@NotNull VirtualFile file) {
            return super.contains(file) && JavaFxFileTypeFactory.isFxml(file);
          }
        };
      }
    }
  } 

  return null;
}
项目:intellij-ce-playground    文件:GradleBuildClasspathResolveScopeEnlarger.java   
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
  String fileExtension = file.getExtension();
  if (GroovyFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
    GradleClassFinder gradleClassFinder = Extensions.findExtension(PsiElementFinder.EP_NAME, project, GradleClassFinder.class);
    final List<VirtualFile> roots = gradleClassFinder.getClassRoots();
    for (VirtualFile root : roots) {
      if (VfsUtilCore.isAncestor(root, file, true)) {
        return NonClasspathDirectoriesScope.compose(roots);
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:FunctionalExpressionSearch.java   
public static Query<PsiFunctionalExpression> search(@NotNull final PsiMethod psiMethod, @NotNull final SearchScope scope) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Query<PsiFunctionalExpression>>() {
    @Override
    public Query<PsiFunctionalExpression> compute() {
      if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
        final PsiClass containingClass = psiMethod.getContainingClass();
        if (containingClass != null) {
          return INSTANCE.createUniqueResultsQuery(new SearchParameters(containingClass, scope));
        }
      }

      return EmptyQuery.getEmptyQuery();
    }
  });
}
项目:intellij-ce-playground    文件:InplaceRefactoring.java   
protected SearchScope getReferencesSearchScope(VirtualFile file) {
  if (file == null) {
    return ProjectScope.getProjectScope(myElementToRename.getProject());
  }
  else {
    final PsiFile containingFile = myElementToRename.getContainingFile();
    if (!file.equals(containingFile.getVirtualFile())) {
      final PsiFile topLevelFile = PsiManager.getInstance(myProject).findFile(file);
      return topLevelFile == null ? ProjectScope.getProjectScope(myElementToRename.getProject()) 
                                  : new LocalSearchScope(topLevelFile);
    }
    return new LocalSearchScope(containingFile);
  }
}
项目:intellij-ce-playground    文件:InspectionRVContentProviderImpl.java   
@Override
public boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context,
                                     @NotNull final InspectionToolWrapper toolWrapper) {
  InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
  presentation.updateContent();

  final SearchScope searchScope = context.getCurrentScope().toSearchScope();
  if (searchScope instanceof LocalSearchScope) {
    final Map<String, Set<RefEntity>> contents = presentation.getContent();
    final Map<RefEntity, CommonProblemDescriptor[]> problemElements = presentation.getProblemElements();
    for (Set<RefEntity> entities : contents.values()) {
      for (Iterator<RefEntity> iterator = entities.iterator(); iterator.hasNext(); ) {
        RefEntity entity = iterator.next();
        if (entity instanceof RefElement) {
          final PsiElement element = ((RefElement)entity).getElement();
          if (element != null) {
            final TextRange range = element.getTextRange();
            if (range != null && ((LocalSearchScope)searchScope).containsRange(element.getContainingFile(), range)) {
              continue;
            }
          }
        }
        problemElements.remove(entity);
        iterator.remove();
      }
    }
  }

  return presentation.hasReportedProblems();
}
项目:intellij-ce-playground    文件:GrVariableBaseImpl.java   
@Override
@NotNull
public SearchScope getUseScope() {
  final GrVariableDeclarationOwner owner = PsiTreeUtil.getParentOfType(this, GrVariableDeclarationOwner.class);
  if (owner != null) return new LocalSearchScope(owner);
  return super.getUseScope();
}
项目:intellij-ce-playground    文件:GroovyScopeUtil.java   
public static SearchScope restrictScopeToGroovyFiles(SearchScope originalScope) {
  if (originalScope instanceof GlobalSearchScope) {
    return GlobalSearchScope
      .getScopeRestrictedByFileTypes((GlobalSearchScope)originalScope, GroovyFileType.getGroovyEnabledFileTypes());
  }
  return originalScope;
}
项目:intellij-ce-playground    文件:UsageViewManagerTest.java   
public void testScopeCreatedForFindInModuleContent() {
  FindModel findModel = new FindModel();
  findModel.setModuleName(getModule().getName());
  findModel.setProjectScope(false);
  UsageTarget target = new FindInProjectUtil.StringUsageTarget(getProject(), findModel);
  UsageViewManagerImpl manager = (UsageViewManagerImpl)UsageViewManager.getInstance(getProject());
  SearchScope scope = manager.getMaxSearchScopeToWarnOfFallingOutOf(new UsageTarget[]{target});
  assertEquals(scope, getModule().getModuleContentScope());
}
项目:intellij-ce-playground    文件:PyClassImpl.java   
@NotNull
@Override
public SearchScope getUseScope() {
  final ScopeOwner scopeOwner = ScopeUtil.getScopeOwner(this);
  if (scopeOwner instanceof PyFunction) {
    return new LocalSearchScope(scopeOwner);
  }
  return super.getUseScope();
}