本文整理汇总了Java中com.intellij.openapi.roots.ProjectFileIndex.isInSourceContent方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectFileIndex.isInSourceContent方法的具体用法?Java ProjectFileIndex.isInSourceContent怎么用?Java ProjectFileIndex.isInSourceContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ProjectFileIndex
的用法示例。
在下文中一共展示了ProjectFileIndex.isInSourceContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProjectGdslFiles
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static List<VirtualFile> getProjectGdslFiles(Project project) {
final List<VirtualFile> result = ContainerUtil.newArrayList();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
for (VirtualFile vfile : FileBasedIndex.getInstance().getContainingFiles(NAME, OUR_KEY, scope)) {
if (!vfile.isValid()) {
continue;
}
if (!GdslUtil.GDSL_FILTER.value(vfile)) {
LOG.error("Index returned non-gdsl file: " + vfile);
continue;
}
if (fileIndex.isInLibrarySource(vfile)) {
continue;
}
if (!fileIndex.isInLibraryClasses(vfile)) {
if (!fileIndex.isInSourceContent(vfile) || !isActivated(vfile)) {
continue;
}
}
result.add(vfile);
}
return result;
}
示例2: getResolveScope
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
if (file.getFileType() != GroovyFileType.GROOVY_FILE_TYPE) return null;
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
Module module = projectFileIndex.getModuleForFile(file);
if (module == null) return null; //groovy files are only in modules
boolean includeTests = projectFileIndex.isInTestSourceContent(file) || !projectFileIndex.isInSourceContent(file);
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, includeTests);
final PsiFile psi = PsiManager.getInstance(project).findFile(file);
if (psi instanceof GroovyFile && ((GroovyFile)psi).isScript()) {
return GroovyScriptTypeDetector.patchResolveScope((GroovyFile)psi, scope);
}
else {
return scope;
}
}
示例3: update
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
if (!presentation.isVisible()) return;
IdeView view = LangDataKeys.IDE_VIEW.getData(e.getDataContext());
if (view == null) return;
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) return;
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiDirectory dir : view.getDirectories()) {
if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && checkPackageExists(dir)) {
for (GroovySourceFolderDetector detector : GroovySourceFolderDetector.EP_NAME.getExtensions()) {
if (detector.isGroovySourceFolder(dir)) {
presentation.setWeight(Presentation.HIGHER_WEIGHT);
break;
}
}
return;
}
}
}
示例4: hasBlazePackageChild
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static boolean hasBlazePackageChild(
ProjectFileIndex index, BuildSystemProvider buildSystemProvider, PsiDirectory directory) {
if (!index.isInSourceContent(directory.getVirtualFile())) {
// only search project files
return false;
}
if (buildSystemProvider.findBuildFileInDirectory(directory.getVirtualFile()) != null) {
return true;
}
for (PsiDirectory child : directory.getSubdirectories()) {
if (hasBlazePackageChild(index, buildSystemProvider, child)) {
return true;
}
}
return false;
}
示例5: canSelect
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private boolean canSelect(final VirtualFile vFile) {
if (vFile != null && vFile.isValid()) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
return fileIndex.isInSourceContent(vFile) || isInLibraryContentOnly(vFile);
}
else {
return false;
}
}
示例6: isInLibraryContentOnly
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private boolean isInLibraryContentOnly(final VirtualFile vFile) {
if (vFile == null) {
return false;
}
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
return (projectFileIndex.isInLibraryClasses(vFile) || projectFileIndex.isInLibrarySource(vFile)) && !projectFileIndex.isInSourceContent(vFile);
}
示例7: getCompilableFiles
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static VirtualFile[] getCompilableFiles(Project project, VirtualFile[] files) {
if (files == null || files.length == 0) {
return VirtualFile.EMPTY_ARRAY;
}
final PsiManager psiManager = PsiManager.getInstance(project);
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project);
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(project);
final List<VirtualFile> filesToCompile = new ArrayList<VirtualFile>();
for (final VirtualFile file : files) {
if (!fileIndex.isInSourceContent(file)) {
continue;
}
if (!file.isInLocalFileSystem()) {
continue;
}
if (file.isDirectory()) {
final PsiDirectory directory = psiManager.findDirectory(file);
if (directory == null || JavaDirectoryService.getInstance().getPackage(directory) == null) {
continue;
}
}
else {
FileType fileType = file.getFileType();
if (!(compilerManager.isCompilableFileType(fileType) || compilerConfiguration.isCompilableResourceFile(project, file))) {
continue;
}
}
filesToCompile.add(file);
}
return VfsUtilCore.toVirtualFileArray(filesToCompile);
}
示例8: hasDirectoryInPackage
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static boolean hasDirectoryInPackage(final Project project, final IdeView view) {
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
PsiDirectory[] dirs = view.getDirectories();
for (PsiDirectory dir : dirs) {
if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
return true;
}
}
return false;
}
示例9: selectIn
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
final Project project = context.getProject();
final VirtualFile file = context.getVirtualFile();
final Module module;
final Facet facet;
if (file instanceof WrappingVirtualFile) {
final Object o = ((WrappingVirtualFile)file).getWrappedObject(project);
facet = o instanceof Facet? (Facet)o : null;
module = facet == null? null : facet.getModule();
}
else {
Module moduleByIml = file.getFileType().equals(StdFileTypes.IDEA_MODULE) ? findModuleByModuleFile(project, file) : null;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
module = moduleByIml != null ? moduleByIml : fileIndex.getModuleForFile(file);
facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
}
if (module != null || facet != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (facet != null) {
ModulesConfigurator.showFacetSettingsDialog(facet, null);
}
else {
ProjectSettingsService.getInstance(project).openModuleSettings(module);
}
}
});
return;
}
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, project);
if (orderEntry != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
}
});
}
}