Package com.intellij.psi.search

Examples of com.intellij.psi.search.GlobalSearchScope


    }
  }

  @Nullable
  private static VirtualFile findJasmineTestFileSource(@NotNull Project project, @NotNull String joinedSuites) {
    GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
    joinedSuites += ' ';
    int lastSpaceInd = joinedSuites.indexOf(' ');
    while (lastSpaceInd >= 0) {
      String topLevelSuiteName = joinedSuites.substring(0, lastSpaceInd);
      String key = JsTestFileByTestNameIndex.createJasmineKey(Collections.singletonList(topLevelSuiteName));
View Full Code Here


  private static final AngularKeysProvider PROVIDER = new AngularKeysProvider();

  public static JSNamedElementProxy resolve(final Project project, final ID<String, Void> index, final String lookupKey) {
    JSNamedElementProxy result = null;
    final JavaScriptIndex jsIndex = JavaScriptIndex.getInstance(project);
    final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
    for (VirtualFile file : FileBasedIndex.getInstance().getContainingFiles(index, lookupKey, scope)) {
      final JSIndexEntry entry = jsIndex.getEntryForFile(file, scope);
      final JSNamedElementProxy resolve = entry != null ? entry.resolveAdditionalData(jsIndex, index.toString(), lookupKey) : null;
      if (resolve != null) {
        result = resolve;
View Full Code Here

    @Nullable
    @Override
    public CachedValueProvider.Result<List<String>> compute(final Pair<Project, ID<String, Void>> projectAndIndex) {
      final Set<String> allKeys = new THashSet<String>();
      final FileBasedIndex index = FileBasedIndex.getInstance();
      final GlobalSearchScope scope = GlobalSearchScope.allScope(projectAndIndex.first);
      final CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<String>(allKeys) {
        @Override
        protected boolean accept(String key) {
          return true;
        }
View Full Code Here

          }
          PsiType type = ((CfmlReferenceExpression)secondChild).getPsiType();
          if (!(type instanceof CfmlJavaLoaderClassType)) {
            return super.getReferences();
          }
          final GlobalSearchScope ss = ((CfmlJavaLoaderClassType)type).getSearchScope();

          String possibleJavaClassName = stringTextElement.getText();
          final JavaClassReferenceProvider provider = new JavaClassReferenceProvider() {
            @Override
            public GlobalSearchScope getScope(Project project) {
View Full Code Here

      // containingFile = containingFile == null ? null : containingFile.getOriginalFile();
      {
        CfmlFile cfmlConteiningFile = originalFile;
        PsiDirectory directory = cfmlConteiningFile.getParent();
        if (directory != null) {
          GlobalSearchScope searchScope = GlobalSearchScopes.directoryScope(directory, false);

          final Collection<CfmlComponent> components = CfmlIndex.getInstance(project).getComponentsByNameInScope(
            componentQualifiedName, searchScope);
          components.addAll(CfmlIndex.getInstance(project).getInterfacesByNameInScope(
            componentQualifiedName, searchScope));
          for (CfmlComponent component : components) {
            result.add(component);
          }
        }
        else {
          final Collection<CfmlComponent> components = CfmlIndex.getInstance(project).getComponentsByName(
            componentQualifiedName);
          components.addAll(CfmlIndex.getInstance(project).getInterfacesByName(componentQualifiedName));
          for (CfmlComponent component : components) {
            result.add(component);
          }
        }
      }
    }

    if (result.isEmpty()) {
      String componentName = getComponentName(componentQualifiedName);

      int i = componentQualifiedName.lastIndexOf(".");
      String directoryName;
      if (i == -1) {
        directoryName = "";
      }
      else {
        directoryName = componentQualifiedName.substring(0, i);
      }

      CfmlProjectConfiguration.State state = CfmlProjectConfiguration.getInstance(project).getState();
      CfmlMappingsConfig mappings = state != null ? state.getMapps().clone() : new CfmlMappingsConfig();
      adjustMappingsIfEmpty(mappings, originalFile.getProject());
      // addFakeMappingsForResolution(mappings);
      List<String> realPossiblePaths = mappings.mapVirtualToReal(directoryName);
      // Collections.sort(realPossiblePaths);

      final Collection<CfmlComponent> components = CfmlIndex.getInstance(project).getComponentsByName(
        componentName);
      components.addAll(CfmlIndex.getInstance(project).getInterfacesByName(
        componentName));

      for (CfmlComponent component : components) {
        PsiDirectory parent = component.getContainingFile().getParent();
        if (parent == null) {
          continue;
        }
        VirtualFile virtualFile = parent.getVirtualFile();
        for (String realPath : realPossiblePaths) {
          if (FileUtil.toSystemIndependentName(realPath).equals(FileUtil.toSystemIndependentName(virtualFile.getPresentableUrl()))) {
            result.add(component);
            break;
          }
        }
      }

      for (String realPath : realPossiblePaths) {
        VirtualFile fileByUrl = LocalFileSystem.getInstance().findFileByPath(realPath);
        if (fileByUrl != null) {
          PsiFile file = PsiManager.getInstance(project).findFile(fileByUrl);
          if (file != null) {
            PsiDirectory directory = file.getParent();
            if (directory != null) {
              GlobalSearchScope searchScope = GlobalSearchScopes.directoryScope(directory, false);

              final Collection<CfmlComponent> componentsFromGlobalScope = CfmlIndex.getInstance(project).getComponentsByNameInScope(
                componentName, searchScope);
              componentsFromGlobalScope.addAll(CfmlIndex.getInstance(project).getInterfacesByNameInScope(
                componentName, searchScope));

              for (CfmlComponent component : componentsFromGlobalScope) {
                result.add(component);
              }
            }
          }
        }
      }
    }

    if (result.isEmpty()) {
      final Couple<String> prefixAndName = CfmlUtil.getPrefixAndName(componentQualifiedName);
      final String componentName = prefixAndName.getSecond();
      final CfmlImport cfmlImport = CfmlUtil.getImportByPrefix(originalFile, prefixAndName.getFirst());
      if (cfmlImport != null && !StringUtil.isEmpty(componentName)) {
        String libtag = cfmlImport.getImportString();
        final VirtualFile folder = CfmlUtil.findFileByLibTag(originalFile, libtag);
        if (folder != null && folder.isDirectory()) {
          final GlobalSearchScope scope = GlobalSearchScopes.directoryScope(originalFile.getProject(), folder, true);
          result.addAll(CfmlIndex.getInstance(originalFile.getProject()).getComponentsByNameInScope(componentName, scope));
        }
      }
    }
    return result;
View Full Code Here

    }
  }

  @NotNull
  public static List<VirtualFile> findConfigFilesInProject(@NotNull VirtualFile jsTestFile, @NotNull Project project) {
    GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
    return findConfigFilesInScope(jsTestFile, allScope);
  }
View Full Code Here

    return res;
  }

  @NotNull
  public static List<VirtualFile> collectJstdConfigFilesInDirectory(@NotNull Project project, @NotNull VirtualFile directory) {
    GlobalSearchScope directorySearchScope = buildDirectorySearchScope(project, directory);
    if (directorySearchScope == null) {
      return Collections.emptyList();
    }
    Collection<VirtualFile> configs = FileTypeIndex.getFiles(JstdConfigFileType.INSTANCE, directorySearchScope);
    return Lists.newArrayList(configs);
View Full Code Here

    project.putUserData(JSTD_CONFIG_FILES_IN_PROJECT, value);
    return value;
  }

  public static boolean areJstdConfigFilesInProject(@NotNull Project project) {
    GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
    return areJstdConfigFilesInScope(projectScope);
  }
View Full Code Here

    GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
    return areJstdConfigFilesInScope(projectScope);
  }

  public static boolean areJstdConfigFilesInDirectory(@NotNull Project project, @NotNull VirtualFile directory) {
    GlobalSearchScope directorySearchScope = buildDirectorySearchScope(project, directory);
    if (directorySearchScope == null) {
      return false;
    }
    return areJstdConfigFilesInScope(directorySearchScope);
  }
View Full Code Here

  private static GlobalSearchScope buildDirectorySearchScope(@NotNull Project project, @NotNull VirtualFile directory) {
    final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(directory);
    if (module == null) {
      return null;
    }
    GlobalSearchScope directorySearchScope = GlobalSearchScopesCore.directoryScope(project, directory, true);
    return module.getModuleContentWithDependenciesScope().intersectWith(directorySearchScope);
  }
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.