本文整理汇总了Java中com.intellij.openapi.roots.ProjectFileIndex.isInLibraryClasses方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectFileIndex.isInLibraryClasses方法的具体用法?Java ProjectFileIndex.isInLibraryClasses怎么用?Java ProjectFileIndex.isInLibraryClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ProjectFileIndex
的用法示例。
在下文中一共展示了ProjectFileIndex.isInLibraryClasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAdditionalResolveScope
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
if (index.isInLibraryClasses(file) || index.isInContent(file)) {
return null;
}
String fileExtension = file.getExtension();
if ("class".equals(fileExtension) || JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
for (PsiElementFinder finder : Extensions.getExtensions(PsiElementFinder.EP_NAME, project)) {
if (finder instanceof NonClasspathClassFinder) {
final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots();
for (VirtualFile root : roots) {
if (VfsUtilCore.isAncestor(root, file, true)) {
return NonClasspathDirectoriesScope.compose(roots);
}
}
}
}
}
return null;
}
示例2: adjustElement
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public PsiElement adjustElement(PsiElement psiElement) {
final ProjectFileIndex index = ProjectRootManager.getInstance(psiElement.getProject()).getFileIndex();
final PsiFile containingFile = psiElement.getContainingFile();
if (containingFile instanceof GroovyFileBase) {
final VirtualFile file = containingFile.getVirtualFile();
if (file != null && (index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || index.isInLibraryClasses(file) || index.isInLibrarySource(file))) {
if (psiElement instanceof GroovyFileBase) {
final GroovyFileBase grFile = (GroovyFileBase)psiElement;
if (grFile.getViewProvider().getBaseLanguage().equals(GroovyLanguage.INSTANCE)) {
final PsiClass[] psiClasses = grFile.getClasses();
if (psiClasses.length == 1 && !grFile.isScript()) {
return psiClasses[0];
}
}
}
else if (psiElement instanceof GrTypeDefinition) {
return psiElement;
}
}
return containingFile;
}
return psiElement;
}
示例3: getModulesFor
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private Module[] getModulesFor(PsiDirectory dir) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
final VirtualFile vFile = dir.getVirtualFile();
final Set<Module> modules = new HashSet<Module>();
final Module module = fileIndex.getModuleForFile(vFile);
if (module != null) {
modules.add(module);
}
if (fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile)) {
final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
if (orderEntries.isEmpty()) {
return Module.EMPTY_ARRAY;
}
for (OrderEntry entry : orderEntries) {
modules.add(entry.getOwnerModule());
}
}
return modules.toArray(new Module[modules.size()]);
}
示例4: getModule
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
protected static Module getModule(PsiDirectory dir) {
Project project = dir.getProject();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final VirtualFile vFile = dir.getVirtualFile();
if (fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile)) {
final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
if (orderEntries.isEmpty()) {
return null;
}
Set<Module> modules = new HashSet<Module>();
for (OrderEntry orderEntry : orderEntries) {
modules.add(orderEntry.getOwnerModule());
}
final Module[] candidates = modules.toArray(new Module[modules.size()]);
Arrays.sort(candidates, ModuleManager.getInstance(project).moduleDependencyComparator());
return candidates[0];
}
return fileIndex.getModuleForFile(vFile);
}
示例5: filterElements
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean filterElements(@NotNull ChooseByNameBase base,
@NotNull String pattern,
boolean everywhere,
@NotNull ProgressIndicator indicator,
@NotNull Processor<Object> consumer) {
if (pattern.contains("/") || pattern.contains("\\")) {
String path = FileUtil.toSystemIndependentName(ChooseByNamePopup.getTransformedPattern(pattern, myModel));
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPathIfCached(path);
if (vFile != null) {
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(myProject);
if (index.isInContent(vFile) || index.isInLibraryClasses(vFile) || index.isInLibrarySource(vFile)) {
PsiFileSystemItem fileOrDir = vFile.isDirectory() ?
PsiManager.getInstance(myProject).findDirectory(vFile) :
PsiManager.getInstance(myProject).findFile(vFile);
if (fileOrDir != null && !consumer.process(fileOrDir)) {
return false;
}
}
}
}
return super.filterElements(base, pattern, everywhere, indicator, consumer);
}
示例6: PostHighlightingVisitor
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
PostHighlightingVisitor(@NotNull PsiFile file,
@NotNull Document document,
@NotNull RefCountHolder refCountHolder) throws ProcessCanceledException {
myProject = file.getProject();
myFile = file;
myDocument = document;
myCurrentEntryIndex = -1;
myLanguageLevel = PsiUtil.getLanguageLevel(file);
final FileViewProvider viewProvider = myFile.getViewProvider();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
VirtualFile virtualFile = viewProvider.getVirtualFile();
myInLibrary = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
myRefCountHolder = refCountHolder;
ApplicationManager.getApplication().assertReadAccessAllowed();
InspectionProfile profile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
myDeadCodeKey = HighlightDisplayKey.find(UnusedDeclarationInspectionBase.SHORT_NAME);
myDeadCodeInspection = (UnusedDeclarationInspectionBase)profile.getUnwrappedTool(UnusedDeclarationInspectionBase.SHORT_NAME, myFile);
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || myDeadCodeInspection != null);
myUnusedSymbolInspection = myDeadCodeInspection != null ? myDeadCodeInspection.getSharedLocalInspectionTool() : null;
myDeadCodeInfoType = myDeadCodeKey == null
? HighlightInfoType.UNUSED_SYMBOL
: new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(myDeadCodeKey, myFile).getSeverity(),
HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
}
示例7: contains
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean contains(@NotNull final VirtualFile file) {
ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
if (!index.isInLibrarySource(file) && !index.isInLibraryClasses(file)) return false;
return someChildContainsFile(file, false);
}
示例8: 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);
}
示例9: update
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent e) {
final Project project = getEventProject(e);
boolean visible = false;
if (project != null && ModuleManager.getInstance(project).getModules().length > 0) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (VirtualFile root : getRoots(e)) {
if (!root.isInLocalFileSystem() && FileUtilRt.extensionEquals(root.getName(), "jar") && !fileIndex.isInLibraryClasses(root)) {
visible = true;
break;
}
if (root.isInLocalFileSystem() && root.isDirectory()) {
for (VirtualFile child : root.getChildren()) {
if (FileUtilRt.extensionEquals(child.getName(), "jar")) {
final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(child);
if (jarRoot != null && !fileIndex.isInLibraryClasses(child)) {
visible = true;
break;
}
}
}
}
}
}
e.getPresentation().setVisible(visible);
e.getPresentation().setEnabled(visible);
}
示例10: canSelect
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean canSelect(final SelectInContext context) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
final VirtualFile file = context.getVirtualFile();
if (file instanceof WrappingVirtualFile) {
final Object o = ((WrappingVirtualFile)file).getWrappedObject(context.getProject());
return o instanceof Facet;
}
return fileIndex.isInContent(file) || fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)
|| StdFileTypes.IDEA_MODULE.equals(file.getFileType()) && findModuleByModuleFile(context.getProject(), file) != null;
}
示例11: isNotUnderSourceRoot
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static boolean isNotUnderSourceRoot(@NotNull final Project project, @Nullable final PsiFile psiFile) {
if (psiFile == null) {
return true;
}
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isExcluded(virtualFile) || (fileIndex.isInLibraryClasses(virtualFile) && !fileIndex.isInContent(virtualFile))) {
return true;
}
}
return false;
}
示例12: filterNotInLibrary
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@NotNull
private static List<PropertiesFile> filterNotInLibrary(@NotNull Project project,
@NotNull List<PropertiesFile> propertiesFiles) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final List<PropertiesFile> result = new ArrayList<PropertiesFile>(propertiesFiles.size());
for (final PropertiesFile file : propertiesFiles) {
if (!fileIndex.isInLibraryClasses(file.getVirtualFile()) && !fileIndex.isInLibrarySource(file.getVirtualFile())) {
result.add(file);
}
}
return result;
}
示例13: isInSet
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean isInSet(@NotNull final VirtualFile file) {
final ProjectFileIndex index = myRootManager.getFileIndex();
if (index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file)) {
return !myFileTypeManager.isFileIgnored(file);
}
return false;
}
示例14: contains
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
/** Copy of {@link com.intellij.ide.projectView.impl.nodes.AbstractProjectNode#contains(com.intellij.openapi.vfs.VirtualFile)}*/
@Override
public boolean contains(@NotNull VirtualFile file) {
ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
final VirtualFile baseDir = getProject().getBaseDir();
return index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file) ||
(baseDir != null && VfsUtilCore.isAncestor(baseDir, file, false));
}
示例15: visitPyReferenceExpression
import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
super.visitPyElement(node);
if (shouldBeCompatibleWithPy3()) {
final TypeEvalContext context = TypeEvalContext.codeAnalysis(node.getProject(), node.getContainingFile());
final String nodeText = node.getText();
if (nodeText.endsWith("iteritems") || nodeText.endsWith("iterkeys") || nodeText.endsWith("itervalues")) {
final PyExpression qualifier = node.getQualifier();
if (qualifier != null) {
final PyType type = context.getType(qualifier);
final PyClassType dictType = PyBuiltinCache.getInstance(node).getDictType();
if (PyTypeChecker.match(dictType, type, context)) {
registerProblem(node, "dict.iterkeys(), dict.iteritems() and dict.itervalues() methods are not available in py3");
}
}
}
if (PyNames.BASESTRING.equals(nodeText)) {
PsiElement res = node.getReference().resolve();
if (res != null) {
ProjectFileIndex ind = ProjectRootManager.getInstance(node.getProject()).getFileIndex();
PsiFile file = res.getContainingFile();
if (file != null ) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null && ind.isInLibraryClasses(virtualFile)) {
registerProblem(node, "basestring type is not available in py3");
}
} else {
registerProblem(node, "basestring type is not available in py3");
}
}
}
}
}