本文整理汇总了Java中com.intellij.util.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于com.intellij.util包,在下文中一共展示了Query类的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;
}
示例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;
}
示例3: isOverriddenInHierarchy
import com.intellij.util.Query; //导入依赖的package包/类
public static boolean isOverriddenInHierarchy(PsiMethod method, PsiClass baseClass) {
// previous implementation:
// final Query<PsiMethod> search = OverridingMethodsSearch.search(method);
//for (PsiMethod overridingMethod : search) {
// final PsiClass aClass = overridingMethod.getContainingClass();
// if (InheritanceUtil.isCorrectDescendant(aClass, baseClass, true)) {
// return true;
// }
//}
// was extremely slow and used an enormous amount of memory for clone()
final Query<PsiClass> search = ClassInheritorsSearch.search(baseClass, baseClass.getUseScope(), true, true, true);
for (PsiClass inheritor : search) {
final PsiMethod overridingMethod = inheritor.findMethodBySignature(method, false);
if (overridingMethod != null) {
return true;
}
}
return false;
}
示例4: addMaxSuperMembers
import com.intellij.util.Query; //导入依赖的package包/类
private static void addMaxSuperMembers(@NotNull SchemaTypeDef currentType,
@NotNull Function<SchemaTypeDef, PsiNamedElement> typeFunc,
@NotNull List<PsiNamedElement> acc) {
final int accSizeBefore = acc.size();
Query<SchemaTypeDef> parentsQuery = SchemaDirectTypeParentsSearch.search(currentType);
parentsQuery.forEach(typeDef -> {
PsiNamedElement member = typeFunc.apply(typeDef);
if (member != null) addMaxSuperMembers(typeDef, typeFunc, acc);
return true;
});
if (acc.size() == accSizeBefore /*&& accSizeBefore > 0*/) acc.add(currentType);
}
示例5: search
import com.intellij.util.Query; //导入依赖的package包/类
public static Query<PsiClass> search(final PsiClass aClass,
SearchScope scope,
boolean includeAnonymous,
final boolean checkInheritance) {
final Query<PsiClass> raw = INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope, includeAnonymous, checkInheritance));
if (!includeAnonymous) {
return new FilteredQuery<PsiClass>(raw, new Condition<PsiClass>() {
@Override
public boolean value(final PsiClass psiClass) {
return !(psiClass instanceof PsiAnonymousClass);
}
});
}
return raw;
}
示例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;
}
示例7: getUsageClass
import com.intellij.util.Query; //导入依赖的package包/类
/**
* @return the class the specified method is used from, or null if it is
* used from 0 or more than 1 other classes.
*/
@Nullable
public PsiClass getUsageClass(final PsiMethod method) {
final ProgressManager progressManager = ProgressManager.getInstance();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
final String name = method.getName();
final GlobalSearchScope scope = GlobalSearchScope.allScope(method.getProject());
if (searchHelper.isCheapEnoughToSearch(name, scope, null, progressManager.getProgressIndicator())
== PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) {
return null;
}
progressManager.runProcess(new Runnable() {
@Override
public void run() {
final Query<PsiReference> query = MethodReferencesSearch.search(method);
if (!query.forEach(UsageProcessor.this)) {
foundClass.set(null);
}
}
}, null);
return foundClass.get();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:StaticMethodOnlyUsedInOneClassInspectionBase.java
示例8: findLongestExistingPackage
import com.intellij.util.Query; //导入依赖的package包/类
private static PsiPackage findLongestExistingPackage(Module module, String packageName) {
final PsiManager manager = PsiManager.getInstance(module.getProject());
String nameToMatch = packageName;
while (true) {
Query<VirtualFile> vFiles = ModulePackageIndex.getInstance(module).getDirsByPackageName(nameToMatch, false);
PsiDirectory directory = getWritableModuleDirectory(vFiles, module, manager);
if (directory != null) return JavaDirectoryService.getInstance().getPackage(directory);
int lastDotIndex = nameToMatch.lastIndexOf('.');
if (lastDotIndex >= 0) {
nameToMatch = nameToMatch.substring(0, lastDotIndex);
}
else {
return null;
}
}
}
示例9: 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);
}
}
}
示例10: filterReferences
import com.intellij.util.Query; //导入依赖的package包/类
public static List<PsiReference> filterReferences(final PsiClass psiClass, final Query<PsiReference> memberReferences) {
final List<PsiReference> refs = new ArrayList<PsiReference>();
for (PsiReference memberReference : memberReferences) {
if (psiClass == null) {
refs.add(memberReference);
} else {
final PsiElement referencedElement = memberReference.getElement();
if (referencedElement instanceof PsiReferenceExpression) {
final PsiExpression qualifierExpression = ((PsiReferenceExpression)referencedElement).getQualifierExpression();
if (qualifierExpression != null) {
final PsiType qualifierType = qualifierExpression.getType();
if (qualifierType instanceof PsiClassType && psiClass == ((PsiClassType)qualifierType).resolve()) {
refs.add(memberReference);
}
} else {
if (psiClass == PsiTreeUtil.getParentOfType(referencedElement, PsiClass.class)) {
refs.add(memberReference);
}
}
}
}
}
return refs;
}
示例11: QuerySearchRequest
import com.intellij.util.Query; //导入依赖的package包/类
public QuerySearchRequest(@NotNull Query<PsiReference> query,
@NotNull final SearchRequestCollector collector,
boolean inReadAction,
@NotNull final PairProcessor<PsiReference, SearchRequestCollector> processor) {
this.query = query;
this.collector = collector;
if (inReadAction) {
this.processor = new ReadActionProcessor<PsiReference>() {
@Override
public boolean processInReadAction(PsiReference psiReference) {
return processor.process(psiReference, collector);
}
};
}
else {
this.processor = new Processor<PsiReference>() {
@Override
public boolean process(PsiReference psiReference) {
return processor.process(psiReference, collector);
}
};
}
}
示例12: visitMethod
import com.intellij.util.Query; //导入依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() == 0) {
return;
}
final Query<MethodSignatureBackedByPsiMethod> query =
SuperMethodsSearch.search(
method, method.getContainingClass(), true, false);
final MethodSignatureBackedByPsiMethod methodSignature =
query.findFirst();
if (methodSignature == null) {
return;
}
final PsiMethod superMethod = methodSignature.getMethod();
final PsiParameter[] parameters = parameterList.getParameters();
checkParameters(superMethod, parameters);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ParameterNameDiffersFromOverriddenParameterInspectionBase.java
示例13: getAssignmentToInline
import com.intellij.util.Query; //导入依赖的package包/类
private static Pair<PyStatement, Boolean> getAssignmentToInline(ScopeOwner containerBlock, PyReferenceExpression expr,
PyTargetExpression local, Project project) {
if (expr != null) {
try {
final List<ReadWriteInstruction> candidates = PyDefUseUtil.getLatestDefs(containerBlock, local.getName(), expr, true);
if (candidates.size() == 1) {
final PyStatement expression = getAssignmentByLeftPart((PyElement)candidates.get(0).getElement());
return Pair.create(expression, false);
}
return Pair.create(null, candidates.size() > 0);
}
catch (PyDefUseUtil.InstructionNotFoundException ignored) {
}
}
final Query<PsiReference> query = ReferencesSearch.search(local, GlobalSearchScope.allScope(project), false);
final PsiReference first = query.findFirst();
final PyElement lValue = first != null ? (PyElement)first.resolve() : null;
return lValue != null ? Pair.create(getAssignmentByLeftPart(lValue), false) : EMPTY_DEF_RESULT;
}
示例14: buildFixes
import com.intellij.util.Query; //导入依赖的package包/类
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
final List<InspectionGadgetsFix> fixes = new ArrayList<InspectionGadgetsFix>();
final PsiClass aClass = (PsiClass)infos[0];
final PsiMethod constructor = getNullArgConstructor(aClass);
if (constructor == null) {
fixes.add(new CreateEmptyPrivateConstructor());
}
else {
final Query<PsiReference> query = ReferencesSearch.search(constructor, constructor.getUseScope());
final PsiReference reference = query.findFirst();
if (reference == null) {
fixes.add(new MakeConstructorPrivateFix());
}
}
AddToIgnoreIfAnnotatedByListQuickFix.build(aClass, ignorableAnnotations, fixes);
return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UtilityClassWithoutPrivateConstructorInspection.java
示例15: visitMethod
import com.intellij.util.Query; //导入依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
if (!TestUtils.isJUnitTestMethod(method)) {
return;
}
final PsiReferenceList throwsList = method.getThrowsList();
final PsiJavaCodeReferenceElement[] referenceElements =
throwsList.getReferenceElements();
if (referenceElements.length < 2) {
return;
}
final Query<PsiReference> query =
MethodReferencesSearch.search(method);
final PsiReference firstReference = query.findFirst();
if (firstReference != null) {
return;
}
registerError(throwsList);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MultipleExceptionsDeclaredOnTestMethodInspection.java