Search in sources :

Example 21 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project intellij-community by JetBrains.

the class FrameworkDetectionManager method getValidDetectedFrameworks.

private List<? extends DetectedFrameworkDescription> getValidDetectedFrameworks() {
    final Set<Integer> detectors = myDetectedFrameworksData.getDetectorsForDetectedFrameworks();
    List<DetectedFrameworkDescription> descriptions = new ArrayList<>();
    final FileBasedIndex index = FileBasedIndex.getInstance();
    final DetectionExcludesConfiguration excludesConfiguration = DetectionExcludesConfiguration.getInstance(myProject);
    for (Integer id : detectors) {
        final Collection<? extends DetectedFrameworkDescription> frameworks = runDetector(id, index, excludesConfiguration, false);
        for (DetectedFrameworkDescription framework : frameworks) {
            descriptions.add(framework);
        }
    }
    return FrameworkDetectionUtil.removeDisabled(descriptions);
}
Also used : DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) DetectionExcludesConfiguration(com.intellij.framework.detection.DetectionExcludesConfiguration)

Example 22 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project intellij-community by JetBrains.

the class PythonMockSdk method create.

public static Sdk create(final String version, @NotNull final VirtualFile... additionalRoots) {
    final String mock_path = PythonTestUtil.getTestDataPath() + "/MockSdk" + version + "/";
    String sdkHome = new File(mock_path, "bin/python" + version).getPath();
    SdkType sdkType = PythonSdkType.getInstance();
    final Sdk sdk = new ProjectJdkImpl(MOCK_SDK_NAME + " " + version, sdkType) {

        @Override
        public String getVersionString() {
            return "Python " + version + " Mock SDK";
        }
    };
    final SdkModificator sdkModificator = sdk.getSdkModificator();
    sdkModificator.setHomePath(sdkHome);
    File libPath = new File(mock_path, "Lib");
    if (libPath.exists()) {
        sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath), OrderRootType.CLASSES);
    }
    sdkModificator.addRoot(PyUserSkeletonsUtil.getUserSkeletonsDirectory(), OrderRootType.CLASSES);
    final LanguageLevel level = LanguageLevel.fromPythonVersion(version);
    final VirtualFile typeShedDir = PyTypeShed.INSTANCE.getDirectory();
    PyTypeShed.INSTANCE.findRootsForLanguageLevel(level).forEach(path -> {
        final VirtualFile file = typeShedDir.findFileByRelativePath(path);
        if (file != null) {
            sdkModificator.addRoot(file, OrderRootType.CLASSES);
        }
    });
    String mock_stubs_path = mock_path + PythonSdkType.SKELETON_DIR_NAME;
    sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), PythonSdkType.BUILTIN_ROOT_TYPE);
    for (final VirtualFile root : additionalRoots) {
        sdkModificator.addRoot(root, OrderRootType.CLASSES);
    }
    sdkModificator.commitChanges();
    final FileBasedIndex index = FileBasedIndex.getInstance();
    index.requestRebuild(StubUpdatingIndex.INDEX_ID);
    index.requestRebuild(PyModuleNameIndex.NAME);
    return sdk;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PythonSdkType(com.jetbrains.python.sdk.PythonSdkType) SdkType(com.intellij.openapi.projectRoots.SdkType) LanguageLevel(com.jetbrains.python.psi.LanguageLevel) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Example 23 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project oxy-template-support-plugin by mutant-industries.

the class OxyTemplateIndexUtil method getJsMacroNameReferences.

@NotNull
public static List<JSElement> getJsMacroNameReferences(@NotNull String macroName, @NotNull VirtualFile file, @NotNull final Project project) {
    final GlobalSearchScope allScope = ProjectScope.getProjectScope(project);
    FileBasedIndex index = FileBasedIndex.getInstance();
    MacroCollector<JSElement, JsMacroNameIndexedElement> processor = new JsMacroCollector(project);
    index.processValues(JsMacroNameIndex.INDEX_ID, macroName, file, processor, allScope);
    // size <= 1
    return processor.getResult();
}
Also used : JsMacroNameIndexedElement(ool.intellij.plugin.file.index.nacro.js.JsMacroNameIndexedElement) JsMacroCollector(ool.intellij.plugin.file.index.collector.JsMacroCollector) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JSElement(com.intellij.lang.javascript.psi.JSElement) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project intellij-swagger by zalando.

the class OpenApiIndexService method isMainOpenApiFile.

public boolean isMainOpenApiFile(final VirtualFile virtualFile, final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    final Collection<VirtualFile> openApiFiles = index.getContainingFiles(OpenApiFileIndex.OPEN_API_INDEX_ID, OpenApiFileIndex.MAIN_OPEN_API_FILE, GlobalSearchScope.allScope(project));
    return openApiFiles.contains(virtualFile);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Example 25 with FileBasedIndex

use of com.intellij.util.indexing.FileBasedIndex in project intellij-swagger by zalando.

the class SwaggerIndexService method isMainSwaggerFile.

public boolean isMainSwaggerFile(final VirtualFile virtualFile, final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    final Collection<VirtualFile> swaggerFiles = index.getContainingFiles(SwaggerFileIndex.SWAGGER_INDEX_ID, SwaggerFileIndex.MAIN_SWAGGER_FILE, GlobalSearchScope.allScope(project));
    return swaggerFiles.contains(virtualFile);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Aggregations

FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)27 VirtualFile (com.intellij.openapi.vfs.VirtualFile)18 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)13 NotNull (org.jetbrains.annotations.NotNull)10 PsiFile (com.intellij.psi.PsiFile)6 Project (com.intellij.openapi.project.Project)5 PsiElement (com.intellij.psi.PsiElement)4 JSElement (com.intellij.lang.javascript.psi.JSElement)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 DetectedFrameworkDescription (com.intellij.framework.detection.DetectedFrameworkDescription)2 DetectionExcludesConfiguration (com.intellij.framework.detection.DetectionExcludesConfiguration)2 JSOffsetBasedImplicitElement (com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement)2 JSImplicitElementImpl (com.intellij.lang.javascript.psi.stubs.impl.JSImplicitElementImpl)2 Module (com.intellij.openapi.module.Module)2 PsiManager (com.intellij.psi.PsiManager)2 XmlFile (com.intellij.psi.xml.XmlFile)2 HashMap (com.intellij.util.containers.HashMap)2 HashSet (com.intellij.util.containers.HashSet)2