• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PsiElementUsage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.usages.rules.PsiElementUsage的典型用法代码示例。如果您正苦于以下问题:Java PsiElementUsage类的具体用法?Java PsiElementUsage怎么用?Java PsiElementUsage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PsiElementUsage类属于com.intellij.usages.rules包,在下文中一共展示了PsiElementUsage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) {
    return null;
  }
  PsiElementUsage elementUsage = (PsiElementUsage)usage;

  PsiElement element = elementUsage.getElement();
  VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);

  if (virtualFile == null) {
    return null;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
  boolean isInLib = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
  if (isInLib) return LIBRARY;
  boolean isInTest = fileIndex.isInTestSourceContent(virtualFile);
  return isInTest ? TEST : PRODUCTION;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsageScopeGroupingRule.java


示例2: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage, @NotNull UsageTarget[] targets) {
  if (usage instanceof PsiElementUsage) {
    PsiElementUsage elementUsage = (PsiElementUsage)usage;

    PsiElement element = elementUsage.getElement();
    UsageType usageType = getUsageType(element, targets);

    if (usageType == null && element instanceof PsiFile && elementUsage instanceof UsageInfo2UsageAdapter) {
      usageType = ((UsageInfo2UsageAdapter)elementUsage).getUsageType();
    }

    if (usageType != null) return new UsageTypeGroup(usageType);

    if (usage instanceof ReadWriteAccessUsage) {
      ReadWriteAccessUsage u = (ReadWriteAccessUsage)usage;
      if (u.isAccessedForWriting()) return new UsageTypeGroup(UsageType.WRITE);
      if (u.isAccessedForReading()) return new UsageTypeGroup(UsageType.READ);
    }

    return new UsageTypeGroup(UsageType.UNCLASSIFIED);
  }


  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:UsageTypeGroupingRule.java


示例3: isSelfUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
public static boolean isSelfUsage(@NotNull final Usage usage, @NotNull final UsageTarget[] searchForTarget) {
  if (!(usage instanceof PsiElementUsage)) return false;
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      final PsiElement element = ((PsiElementUsage)usage).getElement();
      if (element == null) return false;

      for (UsageTarget ut : searchForTarget) {
        if (ut instanceof PsiElementUsageTarget) {
          if (isSelfUsage(element, ((PsiElementUsageTarget)ut).getElement())) {
            return true;
          }
        }
      }
      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsageViewManager.java


示例4: collectFiles

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
protected static Set<VirtualFile> collectFiles(Set<Usage> usages, boolean findFirst) {
  final Set<VirtualFile> files = new HashSet<VirtualFile>();
  for (Usage usage : usages) {
    if (usage instanceof PsiElementUsage) {
      PsiElement psiElement = ((PsiElementUsage)usage).getElement();
      if (psiElement != null && psiElement.isValid()) {
        PsiFile psiFile = psiElement.getContainingFile();
        if (psiFile != null) {
          VirtualFile file = psiFile.getVirtualFile();
          if (file != null) {
            files.add(file);
            if (findFirst) return files;
          }
        }
      }
    }
  }
  return files;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PredefinedSearchScopeProviderImpl.java


示例5: findUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
/**
 * Finds all usages of element. Works much like method in {@link com.intellij.testFramework.fixtures.CodeInsightTestFixture#findUsages(com.intellij.psi.PsiElement)},
 * but supports {@link com.intellij.find.findUsages.CustomUsageSearcher} and {@link com.intellij.psi.search.searches.ReferencesSearch} as well
 *
 * @param element what to find
 * @return usages
 */
@NotNull
protected Collection<PsiElement> findUsage(@NotNull final PsiElement element) {
  final Collection<PsiElement> result = new ArrayList<PsiElement>();
  final CollectProcessor<Usage> usageCollector = new CollectProcessor<Usage>();
  for (final CustomUsageSearcher searcher : CustomUsageSearcher.EP_NAME.getExtensions()) {
    searcher.processElementUsages(element, usageCollector, new FindUsagesOptions(myFixture.getProject()));
  }
  for (final Usage usage : usageCollector.getResults()) {
    if (usage instanceof PsiElementUsage) {
      result.add(((PsiElementUsage)usage).getElement());
    }
  }
  for (final PsiReference reference : ReferencesSearch.search(element).findAll()) {
    result.add(reference.getElement());
  }

  for (final UsageInfo info : myFixture.findUsages(element)) {
    result.add(info.getElement());
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PyTestCase.java


示例6: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:NonCodeUsageGroupingRule.java


示例7: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage, @NotNull UsageTarget[] targets) {
  if (usage instanceof PsiElementUsage) {
    PsiElementUsage elementUsage = (PsiElementUsage)usage;

    UsageType usageType = getUsageType(elementUsage.getElement(), targets);
    if (usageType != null) return new UsageTypeGroup(usageType);

    if (usage instanceof ReadWriteAccessUsage) {
      ReadWriteAccessUsage u = (ReadWriteAccessUsage)usage;
      if (u.isAccessedForWriting()) return new UsageTypeGroup(UsageType.WRITE);
      if (u.isAccessedForReading()) return new UsageTypeGroup(UsageType.READ);
    }

    return new UsageTypeGroup(UsageType.UNCLASSIFIED);
  }


  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:UsageTypeGroupingRule.java


示例8: getUsageGroupingRule

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Nullable
@Override
public UsageGroupingRule getUsageGroupingRule(Project project)
{
	return new UsageGroupingRule()
	{
		@Nullable
		@Override
		public UsageGroup groupUsage(@NotNull Usage usage)
		{
			if(!(usage instanceof PsiElementUsage))
			{
				return null;
			}
			PsiElement element = ((PsiElementUsage) usage).getElement();

			DotNetTypeDeclaration typeDeclaration = PsiTreeUtil.getParentOfType(element, DotNetTypeDeclaration.class);
			if(typeDeclaration != null)
			{
				return new CSharpBaseGroupingRule<DotNetTypeDeclaration>(typeDeclaration);
			}
			return null;
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:26,代码来源:CSharpTypeGroupRuleProvider.java


示例9: getUsageGroupingRule

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Nullable
@Override
public UsageGroupingRule getUsageGroupingRule(Project project)
{
	return new UsageGroupingRule()
	{
		@Nullable
		@Override
		public UsageGroup groupUsage(@NotNull Usage usage)
		{
			if(!(usage instanceof PsiElementUsage))
			{
				return null;
			}
			PsiElement element = ((PsiElementUsage) usage).getElement();

			DotNetCodeBlockOwner codeBlockOwner = PsiTreeUtil.getParentOfType(element, DotNetCodeBlockOwner.class);
			if(codeBlockOwner != null)
			{
				return new CSharpBaseGroupingRule<DotNetCodeBlockOwner>(codeBlockOwner);
			}
			return null;
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:26,代码来源:CSharpCodeBlockOwnerGroupRuleProvider.java


示例10: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@Nonnull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) {
    return null;
  }
  PsiElementUsage elementUsage = (PsiElementUsage)usage;

  PsiElement element = elementUsage.getElement();
  VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);

  if (virtualFile == null) {
    return null;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
  boolean isInLib = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
  if (isInLib) return LIBRARY;
  boolean isInTest = fileIndex.isInTestSourceContent(virtualFile);
  return isInTest ? TEST : PRODUCTION;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:UsageScopeGroupingRule.java


示例11: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@Nonnull Usage usage) {
  if (usage instanceof UsageInFile) {
    VirtualFile file = ((UsageInFile)usage).getFile();
    if (file != null) {
      if (GeneratedSourcesFilter.isGenerated(myProject, file)) {
        return UsageInGeneratedCodeGroup.INSTANCE;
      }
    }
  }
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:NonCodeUsageGroupingRule.java


示例12: getParentGroupFor

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@javax.annotation.Nullable
@Override
protected UsageGroup getParentGroupFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) {
  if (usage instanceof PsiElementUsage) {
    PsiElementUsage elementUsage = (PsiElementUsage)usage;

    PsiElement element = elementUsage.getElement();
    UsageType usageType = getUsageType(element, targets);

    if (usageType == null && element instanceof PsiFile && elementUsage instanceof UsageInfo2UsageAdapter) {
      usageType = ((UsageInfo2UsageAdapter)elementUsage).getUsageType();
    }

    if (usageType != null) return new UsageTypeGroup(usageType);

    if (usage instanceof ReadWriteAccessUsage) {
      ReadWriteAccessUsage u = (ReadWriteAccessUsage)usage;
      if (u.isAccessedForWriting()) return new UsageTypeGroup(UsageType.WRITE);
      if (u.isAccessedForReading()) return new UsageTypeGroup(UsageType.READ);
    }

    return new UsageTypeGroup(UsageType.UNCLASSIFIED);
  }

  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:UsageTypeGroupingRule.java


示例13: isSelfUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
public static boolean isSelfUsage(@Nonnull final Usage usage, @Nonnull final UsageTarget[] searchForTarget) {
  if (!(usage instanceof PsiElementUsage)) return false;
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      final PsiElement element = ((PsiElementUsage)usage).getElement();
      if (element == null) return false;

      for (UsageTarget ut : searchForTarget) {
        if (ut instanceof PsiElementUsageTarget) {
          if (isSelfUsage(element, ((PsiElementUsageTarget)ut).getElement())) {
            return true;
          }
        }
      }
      return false;
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:UsageViewManager.java


示例14: collectFiles

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
protected static Set<VirtualFile> collectFiles(Set<Usage> usages, boolean findFirst) {
  final Set<VirtualFile> files = new HashSet<>();
  for (Usage usage : usages) {
    if (usage instanceof PsiElementUsage) {
      PsiElement psiElement = ((PsiElementUsage)usage).getElement();
      if (psiElement != null && psiElement.isValid()) {
        PsiFile psiFile = psiElement.getContainingFile();
        if (psiFile != null) {
          VirtualFile file = psiFile.getVirtualFile();
          if (file != null) {
            files.add(file);
            if (findFirst) return files;
          }
        }
      }
    }
  }
  return files;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:PredefinedSearchScopeProviderImpl.java


示例15: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) return null;
  PsiElement psiElement = ((PsiElementUsage)usage).getElement();
  PsiFile containingFile = psiElement.getContainingFile();
  if (containingFile == null) return null;
  InjectedLanguageManager manager = InjectedLanguageManager.getInstance(containingFile.getProject());
  PsiFile topLevelFile = manager.getTopLevelFile(containingFile);
  if (topLevelFile instanceof PsiJavaFile) {
    PsiElement containingMethod = topLevelFile == containingFile ? psiElement : manager.getInjectionHost(containingFile);
    if (usage instanceof UsageInfo2UsageAdapter && topLevelFile == containingFile) {
      int offset = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getNavigationOffset();
      containingMethod = containingFile.findElementAt(offset);
    }
    do {
      containingMethod = PsiTreeUtil.getParentOfType(containingMethod, PsiMethod.class, true);
      if (containingMethod == null) break;
      final PsiClass containingClass = ((PsiMethod)containingMethod).getContainingClass();
      if (containingClass == null || containingClass.getQualifiedName() != null) break;
    }
    while (true);

    if (containingMethod != null) {
      return new MethodUsageGroup((PsiMethod)containingMethod);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MethodGroupingRule.java


示例16: isVisible

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public boolean isVisible(@NotNull Usage usage) {
  final PsiElement psiElement = usage instanceof PsiElementUsage? ((PsiElementUsage)usage).getElement() : null;
  if (psiElement != null) {
    final PsiFile containingFile = psiElement.getContainingFile();
    if (containingFile instanceof PsiJavaFile) {
      // check whether the element is in the import list
      final PsiImportList importList = PsiTreeUtil.getParentOfType(psiElement, PsiImportList.class, true);
      return importList == null;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ImportFilteringRule.java


示例17: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (usage instanceof UsageInFile) {
    VirtualFile file = ((UsageInFile)usage).getFile();
    if (file != null) {
      for (GeneratedSourcesFilter filter : myGeneratedSourcesFilters) {
        if (filter.isGeneratedSource(file, myProject)) {
          return UsageInGeneratedCodeGroup.INSTANCE;
        }
      }
    }
  }
  if (usage instanceof PsiElementUsage) {
    if (usage instanceof UsageInfo2UsageAdapter) {
      final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
      if (usageInfo.isDynamicUsage()) {
        return DynamicUsageGroup.INSTANCE;
      }
    }
    if (((PsiElementUsage)usage).isNonCodeUsage()) {
      return NonCodeUsageGroup.INSTANCE;
    }
    else {
      return CodeUsageGroup.INSTANCE;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:NonCodeUsageGroupingRule.java


示例18: isInScope

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
public static boolean isInScope(@NotNull Usage usage, @NotNull SearchScope searchScope) {
  PsiElement element = null;
  VirtualFile file = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() :
                     usage instanceof PsiElementUsage ? PsiUtilCore.getVirtualFile(element = ((PsiElementUsage)usage).getElement()) : null;
  if (file != null) {
    return isFileInScope(file, searchScope);
  }
  else if(element != null) {
    return searchScope instanceof EverythingGlobalScope ||
           searchScope instanceof ProjectScopeImpl ||
           searchScope instanceof ProjectAndLibrariesScope;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UsageViewManagerImpl.java


示例19: groupUsage

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) return null;
  final PsiElement psiElement = ((PsiElementUsage)usage).getElement();
  final PyFunction pyFunction = PsiTreeUtil.getParentOfType(psiElement, PyFunction.class, false, PyClass.class);
  if (pyFunction != null) {
    return new PsiNamedElementUsageGroupBase<PyFunction>(pyFunction);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PyFunctionGroupingRuleProvider.java


示例20: isVisible

import com.intellij.usages.rules.PsiElementUsage; //导入依赖的package包/类
@Override
public boolean isVisible(@NotNull Usage usage) {
  if (usage instanceof PsiElementUsage) {
    final PsiElement psiElement = ((PsiElementUsage)usage).getElement();
    final PsiFile containingFile = psiElement.getContainingFile();
    if (containingFile instanceof PyFile) {
      // check whether the element is in the import list
      final PyImportStatementBase importStatement = PsiTreeUtil.getParentOfType(psiElement, PyImportStatementBase.class, true);
      return importStatement == null;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PyImportFilteringRule.java



注:本文中的com.intellij.usages.rules.PsiElementUsage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShortCircuitShmIdProto类代码示例发布时间:2022-05-23
下一篇:
Java PortletURLFactoryUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap