use of com.intellij.openapi.roots.ProjectFileIndex in project android by JetBrains.
the class AndroidSdkResolveScopeProvider method getResolveScope.
@Nullable
@Override
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID))
return null;
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
JdkOrderEntry entry = ContainerUtil.findInstance(index.getOrderEntriesForFile(file), JdkOrderEntry.class);
final Sdk sdk = entry == null ? null : entry.getJdk();
if (sdk == null || !(sdk.getSdkType() instanceof AndroidSdkType)) {
return null;
}
return new MyJdkScope(project, entry, index.isInLibrarySource(file));
}
use of com.intellij.openapi.roots.ProjectFileIndex in project android by JetBrains.
the class InstantRunPositionManager method getRelPathFromSourceRoot.
@Nullable
private static String getRelPathFromSourceRoot(@NotNull Project project, @NotNull PsiFile file) {
ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file.getVirtualFile());
if (sourceRoot == null) {
return null;
}
return VfsUtilCore.getRelativePath(file.getVirtualFile(), sourceRoot);
}
use of com.intellij.openapi.roots.ProjectFileIndex in project android by JetBrains.
the class AndroidViewProjectNode method contains.
/** Copy of {@link com.intellij.ide.projectView.impl.nodes.AbstractProjectNode#contains(VirtualFile)}*/
@Override
public boolean contains(@NotNull VirtualFile file) {
Project project = getProject();
assert project != null;
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
VirtualFile baseDir = getProject().getBaseDir();
return index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file) || (baseDir != null && isAncestor(baseDir, file, false));
}
use of com.intellij.openapi.roots.ProjectFileIndex in project android by JetBrains.
the class TestArtifactSearchScopes method get.
@Nullable
public static TestArtifactSearchScopes get(@NotNull VirtualFile file, @NotNull Project project) {
if (GradleSyncState.getInstance(project).lastSyncFailed()) {
return null;
}
ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(project);
Module module = projectFileIndex.getModuleForFile(file);
return module != null ? get(module) : null;
}
use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-plugins by JetBrains.
the class DartAnnotator method canBeAnalyzedByServer.
@Contract("_, null -> false")
private static boolean canBeAnalyzedByServer(@NotNull final Project project, @Nullable final VirtualFile file) {
if (!DartAnalysisServerService.isLocalAnalyzableFile(file))
return false;
final DartSdk sdk = DartSdk.getDartSdk(project);
if (sdk == null || !DartAnalysisServerService.isDartSdkVersionSufficient(sdk))
return false;
// server can highlight files from Dart SDK, packages and from modules with enabled Dart support
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isInLibraryClasses(file))
return true;
final Module module = fileIndex.getModuleForFile(file);
return module != null && DartSdkLibUtil.isDartSdkEnabled(module);
}
Aggregations