Package com.intellij.psi.search

Examples of com.intellij.psi.search.GlobalSearchScope


    if (StringUtil.isEmpty(word)) {
      return;
    }

    if (p.getScope() instanceof GlobalSearchScope) {
      GlobalSearchScope restrictedScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)p.getScope(), GherkinFileType.INSTANCE);
      ReferencesSearch.search(new ReferencesSearch.SearchParameters(method, restrictedScope, false, p.getOptimizer())).forEach(consumer);
    }
  }
View Full Code Here


                                           boolean includeNonProjectItems) {
        if (GoSdkUtil.getGoogleGoSdkForProject(project) == null) {
            return new NavigationItem[0];
        }

        GlobalSearchScope scope = getSearchScope(includeNonProjectItems);
        Collection<NavigationItem> items = new ArrayList<NavigationItem>();
        for (GoTypeNameDeclaration type : StubIndex.getElements(GoTypeName.KEY, name,
                                                    project, scope, GoTypeNameDeclaration.class)) {
            if (type instanceof NavigationItem) {
                items.add((NavigationItem) type);
View Full Code Here

    public void fillCompletionVariants(CompletionParameters parameters, final CompletionResultSet result) {
        result.addElement(LookupElementBuilder.create("huzzah"));

        final Project project = parameters.getOriginalFile().getProject();

        GlobalSearchScope scope = ProjectScope.getProjectScope(project);

        Collection<JSQualifiedNamedElement> scopes = JSResolveUtil.findElementsByName("$scope", project, scope);


        String s = "\\$scope\\.(\\w*)";

        final FindManager findManager = FindManager.getInstance(project);
        final FindModel findModel = (FindModel) findManager.getFindInFileModel().clone();


        findModel.setRegularExpressions(true);
        findModel.setFileFilter("*.js, *.html");

        findModel.setStringToFind(s);
        findModel.setStringToReplace("$1");

        CommonProcessors.CollectProcessor<Usage> collectProcessor = new CommonProcessors.CollectProcessor<Usage>();

        PsiDirectory directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
        FindInProjectUtil.findUsages(findModel, directory, project,
                true, new AdapterProcessor<UsageInfo, Usage>(collectProcessor, UsageInfo2UsageAdapter.CONVERTER), new FindUsagesProcessPresentation());


        final Collection<Usage> usages = collectProcessor.getResults();

        //todo: needs code review. There must be a better way to do this
        Runnable runnable = new Runnable() {
            public void run() {
                for (final Usage r : usages) {

                    final UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter) r;
                    //avoid angular source files. Is there a better way to do this?
                    if (usage.getFile().getName().startsWith("angular")) continue;

                    usage.processRangeMarkers(new Processor<Segment>() {
                        @Override
                        public boolean process(Segment segment) {
                            try {
                                final int textOffset = segment.getStartOffset();

                                final int textEndOffset = segment.getEndOffset();
                                Document document = usage.getDocument();
                                CharSequence charsSequence = document.getCharsSequence();
                                final CharSequence foundString = charsSequence.subSequence(textOffset, textEndOffset);
                                String s = foundString.toString();
                                String regExMatch = FindManager.getInstance(project).getStringToReplace(s, findModel, textOffset, document.getText());
                                System.out.println(regExMatch);
                                PsiElement element = PsiUtilBase.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1);
                                PsiElement propElement = PsiUtilBase.getElementAtOffset(((UsageInfo2UsageAdapter) r).getUsageInfo().getFile(), textOffset + 1 + "$scope".length());
                                String elementText = element.getText();
                                System.out.println(elementText + ": " + regExMatch + " - " + s);

                                result.addElement(LookupElementBuilder.create(propElement, propElement.getText()));

                                return true;
                            } catch (FindManager.MalformedReplacementStringException e1) {
                                e1.printStackTrace();
                            }

                            return false;
                        }
                    });
                }

                result.addLookupAdvertisement("Results based on all '$scope's");
                GlobalSearchScope scope = ProjectScope.getProjectScope(project);

            }
        };

        ApplicationManager.getApplication().runReadAction(runnable);
View Full Code Here

  @Nullable
  public PsiClass findClass(final String qualifiedName) {
    if (qualifiedName == null) return null;
    final Module module = getModule();
    final GlobalSearchScope scope;
    if (module != null) {
      scope = myClassesInLibraries ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)
              : GlobalSearchScope.moduleWithDependenciesScope(module);
    }
    else {
View Full Code Here

    final PsiClassType.ClassResolveResult classResolveResult = type instanceof PsiClassType ? ((PsiClassType)type).resolveGenerics() : null;
    if (classResolveResult == null) return Pair.create(null, type);
    final PsiClass psiClass = classResolveResult.getElement();
    if (psiClass == null) return Pair.create(null, type);
    final PsiManager manager = psiClass.getManager();
    final GlobalSearchScope scope = manager.getProject().getAllScope();
    for (JavaContainerType collectionType : JavaContainerType.values()) {
      if (collectionType == JavaContainerType.ARRAY) continue;
      final PsiClass aClass = manager.findClass(collectionType.getJavaBaseClassName(), scope);
      if (aClass != null && (manager.areElementsEquivalent(aClass, psiClass) || psiClass.isInheritor(aClass, true))) {
        final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
View Full Code Here

    ArrayClass nodeClass = getArrayClass(subType);
    ArrayClass rendererClass = getArrayClass(superType);
    if (nodeClass == null || rendererClass == null) return false;

    if (nodeClass.dims == rendererClass.dims) {
      GlobalSearchScope scope = GlobalSearchScope.allScope(project);
      PsiClass psiNodeClass = PsiManager.getInstance(project).findClass(nodeClass.className,
                                                                        scope);
      PsiClass psiRendererClass = PsiManager.getInstance(project).findClass(rendererClass.className,
                                                                            scope);
      return InheritanceUtil.isInheritorOrSelf(psiNodeClass, psiRendererClass, true);
View Full Code Here

        PsiReference ref = psiRefFile.findReferenceAt(refOffset);
        assertNotNull("Did not find reference", ref);
        PsiElement resolved = ref.resolve();
        assertNotNull("Could not resolve reference", resolved);
        final Query<PsiReference> query;
        final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
        query = ReferencesSearch.search(resolved, projectScope);
        Collection<PsiReference> references = query.findAll();
        assertEquals(expectedUsagesCount, references.size());
    }
View Full Code Here

    }

    //todo: taken from 12 implementation LibrariesUtil.findJarWithClass, remove when retire 11.1 compatibility
    @Nullable
    public static VirtualFile findJarWithClass(@NotNull Module module, final String classQName) {
        GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
        for (PsiClass psiClass : JavaPsiFacade.getInstance(module.getProject()).findClasses(classQName, scope)) {
            final VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(psiClass.getContainingFile().getVirtualFile());
            if (local != null) {
                return local;
            }
View Full Code Here

public class ErlangModuleContributor implements ChooseByNameContributor {
  @NotNull
  @Override
  public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
    GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
    List<ErlangModule> result = ErlangModuleIndex.getModulesByName(project, name, scope);
    ArrayList<NavigationItem> items = new ArrayList<NavigationItem>(result.size());
    for (ErlangNamedElement element : result) {
      PsiFile containingFile = element.getContainingFile();
      VirtualFile virtualFile = containingFile != null ? containingFile.getVirtualFile() : null;
View Full Code Here

  }

  @NotNull
  @Override
  public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
    GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
    Collection<ErlangNamedElement> result = StubIndex.getElements(ErlangAllNameIndex.KEY, name, project, scope, ErlangNamedElement.class);
    List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size());
    for (final ErlangNamedElement element : result) {
      items.add(new ErlangStructureViewFactory.Element(element) {
        @Override
View Full Code Here

TOP

Related Classes of com.intellij.psi.search.GlobalSearchScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.