当前位置: 首页>>代码示例>>Java>>正文


Java Query.findAll方法代码示例

本文整理汇总了Java中com.intellij.util.Query.findAll方法的典型用法代码示例。如果您正苦于以下问题:Java Query.findAll方法的具体用法?Java Query.findAll怎么用?Java Query.findAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.Query的用法示例。


在下文中一共展示了Query.findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findUsages

import com.intellij.util.Query; //导入方法依赖的package包/类
@Nullable
@Override
public List<UsageInfo> findUsages( PsiFile psiFile, PsiDirectory newParent, boolean searchInComments, boolean searchInNonJavaFiles )
{
  Module mod = ModuleUtilCore.findModuleForPsiElement( psiFile );
  ManModule module = ManProject.getModule( mod );
  PsiClass psiClass = findPsiClass( psiFile );
  if( psiClass == null )
  {
    return Collections.emptyList();
  }

  Query<PsiReference> search = ReferencesSearch.search( psiClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope( module.getIjModule() ) );
  List<UsageInfo> usages = new ArrayList<>();
  for( PsiReference ref: search.findAll() )
  {
    usages.add( new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
      ref.getRangeInElement().getEndOffset(), psiClass,
      ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) ) );
  }
  return usages;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:23,代码来源:MoveTypeManifoldFileProcessor.java

示例2: findUsages

import com.intellij.util.Query; //导入方法依赖的package包/类
private static List<UsageInfo> findUsages( PsiElement element, PsiElement ctx )
  {
//    Module mod = ModuleUtilCore.findModuleForPsiElement( element );
//    if( mod == null )
//    {
//      return Collections.emptyList();
//    }

    Query<PsiReference> search = ReferencesSearch.search( element, GlobalSearchScope.moduleScope( ModuleUtilCore.findModuleForPsiElement( ctx ) ) );
    List<UsageInfo> usages = new ArrayList<>();
    for( PsiReference ref : search.findAll() )
    {
      MoveRenameUsageInfo usageInfo = new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
                                                               ref.getRangeInElement().getEndOffset(), element,
                                                               ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) );
      usages.add( usageInfo );
    }
    return usages;
  }
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:RenameResourceElementProcessor.java

示例3: calculateLookupItems

import com.intellij.util.Query; //导入方法依赖的package包/类
@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
  final Query<PsiMember> query = findAnnotated(context, params);

  if (query != null) {
    Set<LookupElement> set = new LinkedHashSet<LookupElement>();
    final String secondParamValue = params.length > 1 ? params[1].calculateResult(context).toString() : null;
    final boolean isShortName = secondParamValue != null && !Boolean.valueOf(secondParamValue);
    final Project project = context.getProject();
    final PsiClass findInClass = secondParamValue != null
                                 ? JavaPsiFacade.getInstance(project).findClass(secondParamValue, GlobalSearchScope.allScope(project))
                                 : null;

    for (PsiMember object : query.findAll()) {
      if (findInClass != null && !object.getContainingClass().equals(findInClass)) continue;
      boolean isClazz = object instanceof PsiClass;
      final String name = isShortName || !isClazz ? object.getName() : ((PsiClass) object).getQualifiedName();
      set.add(LookupElementBuilder.create(name));
    }

    return set.toArray(new LookupElement[set.size()]);
  }
  return LookupElement.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AnnotatedMacro.java

示例4: collectRefsToInvert

import com.intellij.util.Query; //导入方法依赖的package包/类
public void collectRefsToInvert(PsiElement namedElement, Collection<PsiElement> elementsToInvert) {
  final Query<PsiReference> query = namedElement instanceof PsiMethod ?
                                    MethodReferencesSearch.search((PsiMethod)namedElement) :
                                    ReferencesSearch.search(namedElement);
  final Collection<PsiReference> refs = query.findAll();

  for (PsiReference ref : refs) {
    final PsiElement element = ref.getElement();
    PsiElement refElement = getElementToInvert(namedElement, element);
    if (refElement == null) {
      refElement = getForeignElementToInvert(namedElement, element, JavaLanguage.INSTANCE);
    }
    if (refElement != null) {
      elementsToInvert.add(refElement);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaInvertBooleanDelegate.java

示例5: isUnused

import com.intellij.util.Query; //导入方法依赖的package包/类
private static boolean isUnused(PsiElement obj, Query<PsiReference> query) {
    if (obj instanceof XsltParameter) {
        final Collection<PsiReference> references = query.findAll();
        int n = references.size();
        for (PsiReference reference : references) {
            final PsiElement element = reference.getElement();
            if (element instanceof XmlAttributeValue) {
                final XmlAttribute parent = (XmlAttribute)element.getParent();
                if ("name".equals(parent.getName())) {
                    final XmlTag tag = parent.getParent();
                    if (tag != null && "with-param".equals(tag.getLocalName())) {
                        n--;
                    }
                }
            }
        }
        return n == 0;
    } else {
        return query.findFirst() == null;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XsltValidator.java

示例6: moveSubClassImplementsToExtends

import com.intellij.util.Query; //导入方法依赖的package包/类
private static boolean moveSubClassImplementsToExtends(PsiClass oldInterface) throws IncorrectOperationException {
  final Project project = oldInterface.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiElementFactory elementFactory = psiFacade.getElementFactory();
  final PsiJavaCodeReferenceElement oldInterfaceReference = elementFactory.createClassReferenceElement(oldInterface);
  final SearchScope searchScope = oldInterface.getUseScope();
  final Query<PsiClass> query = ClassInheritorsSearch.search(oldInterface, searchScope, false);
  final Collection<PsiClass> inheritors = query.findAll();
  final boolean success = CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, inheritors, false);
  if (!success) {
    return false;
  }
  for (PsiClass inheritor : inheritors) {
    final PsiReferenceList implementsList = inheritor.getImplementsList();
    final PsiReferenceList extendsList = inheritor.getExtendsList();
    if (implementsList != null) {
      moveReference(implementsList, extendsList, oldInterfaceReference);
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ConvertInterfaceToClassIntention.java

示例7: storeTypeManifoldReferences

import com.intellij.util.Query; //导入方法依赖的package包/类
private void storeTypeManifoldReferences( @NotNull PsiElement element )
{
  Module mod = ModuleUtilCore.findModuleForPsiElement( element );
  if( mod == null )
  {
    return;
  }

  ManModule module = ManProject.getModule( mod );

  PsiClass psiClass = findPsiClass( (PsiFileSystemItem)element, module );
  if( psiClass == null )
  {
    return;
  }

  Query<PsiReference> search = ReferencesSearch.search( psiClass, GlobalSearchScope.projectScope( mod.getProject() ) );
  List<UsageInfo> usages = new ArrayList<>();
  for( PsiReference ref: search.findAll() )
  {
    usages.add( new MoveRenameUsageInfo( ref.getElement(), ref, ref.getRangeInElement().getStartOffset(),
      ref.getRangeInElement().getEndOffset(), element,
      ref.resolve() == null && !(ref instanceof PsiPolyVariantReference && ((PsiPolyVariantReference)ref).multiResolve( true ).length > 0) ) );
  }
  _usages = usages;

  if( psiClass instanceof ManifoldPsiClass )
  {
    PsiElement fakeElement = ManGotoDeclarationHandler.find( psiClass, (ManifoldPsiClass)psiClass );
    if( fakeElement instanceof PsiNamedElement && isTopLevelClassDeclaration( fakeElement ) )
    {
      _classDeclElement = (PsiNamedElement)fakeElement;
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:36,代码来源:RenameTypeManifoldFileProcessor.java

示例8: findUsages

import com.intellij.util.Query; //导入方法依赖的package包/类
@Override
public UsageInfo[] findUsages(ChangeInfo info) {
  if (info instanceof PyChangeInfo) {
    final List<UsageInfo> usages = PyRefactoringUtil.findUsages(((PyChangeInfo)info).getMethod(), true);
    final Query<PyFunction> search = PyOverridingMethodsSearch.search(((PyChangeInfo)info).getMethod(), true);
    final Collection<PyFunction> functions = search.findAll();
    for (PyFunction function : functions) {
      usages.add(new UsageInfo(function));
      usages.addAll(PyRefactoringUtil.findUsages(function, true));
    }
    return usages.toArray(new UsageInfo[usages.size()]);
  }
  return UsageInfo.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PyChangeSignatureUsageProcessor.java

示例9: findInheritors

import com.intellij.util.Query; //导入方法依赖的package包/类
@NotNull
public static Collection<PsiClass> findInheritors(@NotNull Project project, @Nullable final Module module, @NotNull final String className, boolean inModuleOnly) {
  PsiClass base = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
  if (base != null) {
    GlobalSearchScope scope = inModuleOnly && module != null
                              ? GlobalSearchScope.moduleWithDependenciesScope(module)
                              : GlobalSearchScope.allScope(project);
    Query<PsiClass> query = ClassInheritorsSearch.search(base, scope, true);
    return query.findAll();
  }
  return new ArrayList<PsiClass>();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PackageClassConverter.java

示例10: doPropertyUsageTest

import com.intellij.util.Query; //导入方法依赖的package包/类
private void doPropertyUsageTest(final String propertyFileName) {
  PropertiesFile propFile = (PropertiesFile) myPsiManager.findFile(myTestProjectRoot.findChild(propertyFileName));
  assertNotNull(propFile);
  final Property prop = (Property)propFile.findPropertyByKey("key");
  assertNotNull(prop);
  final Query<PsiReference> query = ReferencesSearch.search(prop);
  final Collection<PsiReference> result = query.findAll();
  assertEquals(1, result.size());
  verifyReference(result, 0, "form.form", 960);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FormPropertyUsageTest.java

示例11: doPropertyFileUsageTest

import com.intellij.util.Query; //导入方法依赖的package包/类
private void doPropertyFileUsageTest(final String fileName) {
  PropertiesFile propFile = (PropertiesFile) myPsiManager.findFile(myTestProjectRoot.findChild(fileName));
  assertNotNull(propFile);
  final Query<PsiReference> query = ReferencesSearch.search(propFile.getContainingFile());
  final Collection<PsiReference> result = query.findAll();
  assertEquals(1, result.size());
  verifyReference(result, 0, "form.form", 949);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:FormPropertyUsageTest.java

示例12: doFix

import com.intellij.util.Query; //导入方法依赖的package包/类
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  final PsiMethod method = (PsiMethod)element.getParent();
  final PsiParameterList parameterList = method.getParameterList();
  final PsiParameter[] parameters = parameterList.getParameters();
  final PsiParameter lastParameter = parameters[parameters.length - 1];
  if (!lastParameter.isVarArgs()) {
    return;
  }
  final PsiEllipsisType type = (PsiEllipsisType)lastParameter.getType();
  final Query<PsiReference> query = ReferencesSearch.search(method);
  final PsiType componentType = type.getComponentType();
  final String typeText;
  if (componentType instanceof PsiClassType) {
    final PsiClassType classType = (PsiClassType)componentType;
    typeText = classType.rawType().getCanonicalText();
  } else {
    typeText = componentType.getCanonicalText();
  }
  final Collection<PsiReference> references = query.findAll();
  for (PsiReference reference : references) {
    modifyCalls(reference, typeText, parameters.length - 1);
  }
  final PsiType arrayType = type.toArrayType();
  final PsiManager psiManager = lastParameter.getManager();
  final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
  final PsiTypeElement newTypeElement = factory.createTypeElement(arrayType);
  final PsiTypeElement typeElement = lastParameter.getTypeElement();
  if (typeElement == null) {
    return;
  }
  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, "java.lang.SafeVarargs");
  if (annotation != null) {
    annotation.delete();
  }
  typeElement.replace(newTypeElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:VarargParameterInspection.java

示例13: isFixApplicable

import com.intellij.util.Query; //导入方法依赖的package包/类
private static boolean isFixApplicable(PsiExpression location) {
  // conservative check to see if the result value of the postfix
  // expression is used later in the same expression statement.
  // Applying the quick fix in such a case would break the code
  // because the explicit unboxing code would split the expression in
  // multiple statements.
  final PsiElement parent = location.getParent();
  if (!(parent instanceof PsiPostfixExpression)) {
    return true;
  }
  final PsiReferenceExpression reference;
  if (location instanceof PsiReferenceExpression) {
    reference = (PsiReferenceExpression)location;
  }
  else if (location instanceof PsiArrayAccessExpression) {
    final PsiArrayAccessExpression arrayAccessExpression = (PsiArrayAccessExpression)location;
    final PsiExpression expression = arrayAccessExpression.getArrayExpression();
    if (!(expression instanceof PsiReferenceExpression)) {
      return true;
    }
    reference = (PsiReferenceExpression)expression;
  }
  else {
    return true;
  }
  final PsiElement element = reference.resolve();
  if (element == null) {
    return true;
  }
  final PsiStatement statement = PsiTreeUtil.getParentOfType(parent, PsiStatement.class);
  final LocalSearchScope scope = new LocalSearchScope(statement);
  final Query<PsiReference> query = ReferencesSearch.search(element, scope);
  final Collection<PsiReference> references = query.findAll();
  return references.size() <= 1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:AutoUnboxingInspection.java

示例14: showRenameTemplate

import com.intellij.util.Query; //导入方法依赖的package包/类
public static void showRenameTemplate(PsiElement context, PsiNameIdentifierOwner element) {
  context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(context);
  final Query<PsiReference> query = ReferencesSearch.search(element, element.getUseScope());
  final Collection<PsiReference> references = query.findAll();
  final Project project = context.getProject();
  final FileEditorManager fileEditorManager =
    FileEditorManager.getInstance(project);
  final Editor editor = fileEditorManager.getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
  final Expression macroCallNode = new MacroCallNode(
    new SuggestVariableNameMacro());
  final PsiElement identifier = element.getNameIdentifier();
  builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
  for (PsiReference reference : references) {
    builder.replaceElement(reference, "PATTERN", "PATTERN", false);
  }
  final Template template = builder.buildInlineTemplate();
  final TextRange textRange = context.getTextRange();
  final int startOffset = textRange.getStartOffset();
  editor.getCaretModel().moveToOffset(startOffset);
  final TemplateManager templateManager =
    TemplateManager.getInstance(project);
  templateManager.startTemplate(editor, template);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:HighlightUtil.java

示例15: extractDagger2ModulesPsiClasses

import com.intellij.util.Query; //导入方法依赖的package包/类
@NotNull
private List<PsiClass> extractDagger2ModulesPsiClasses(AnActionEvent e) {
    DaggerModuleClassFilter filter = new DaggerModuleClassFilter();
    final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
    SearchScope scope = GlobalSearchScope.moduleScope(module);
    Query<PsiClass> search = AllClassesSearch.search(scope, e.getProject());
    List<PsiClass> modulesClasses = new ArrayList<>();
    for (PsiClass psiClass : search.findAll()) {
        if (filter.isAccepted(psiClass)) {
            modulesClasses.add(psiClass);
        }
    }
    return modulesClasses;
}
 
开发者ID:phajduk,项目名称:dagger2-intellij-plugin,代码行数:15,代码来源:GenerateComponentAction.java


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