本文整理汇总了Java中com.intellij.psi.search.PsiShortNamesCache.getFieldsByName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiShortNamesCache.getFieldsByName方法的具体用法?Java PsiShortNamesCache.getFieldsByName怎么用?Java PsiShortNamesCache.getFieldsByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.search.PsiShortNamesCache
的用法示例。
在下文中一共展示了PsiShortNamesCache.getFieldsByName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multiResolve
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
Project project = myElement.getProject();
final String enumLiteralJavaModelName = myElement.getText().replaceAll("\"", "").toUpperCase();
final PsiShortNamesCache psiShortNamesCache = PsiShortNamesCache.getInstance(project);
final PsiField[] javaEnumLiteralFields = psiShortNamesCache.getFieldsByName(
enumLiteralJavaModelName, GlobalSearchScope.allScope(project)
);
final Set<PsiField> enumFields = stream(javaEnumLiteralFields)
.filter(literal -> literal.getParent() != null)
.filter(literal -> literal.getParent() instanceof ClsClassImpl)
.filter(literal -> ((ClsClassImpl) literal.getParent()).isEnum())
.collect(Collectors.toSet());
return PsiElementResolveResult.createResults(enumFields);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:20,代码来源:HybrisEnumLiteralItemReference.java
示例2: getItemsByName
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
List<PsiMember> result = new ArrayList<PsiMember>();
for (PsiMethod method : cache.getMethodsByName(name, scope)) {
if (!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method)) {
result.add(method);
}
}
for (PsiField field : cache.getFieldsByName(name, scope)) {
if (isOpenable(field)) {
result.add(field);
}
}
for (PsiClass aClass : cache.getClassesByName(name, scope)) {
if (isOpenable(aClass)) {
result.add(aClass);
}
}
PsiMember[] array = result.toArray(new PsiMember[result.size()]);
Arrays.sort(array, MyComparator.INSTANCE);
return array;
}
示例3: getFieldsByName
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiField[] getFieldsByName(@NotNull String name, @NotNull GlobalSearchScope scope)
{
Merger<PsiField> merger = null;
for(PsiShortNamesCache cache : myCaches)
{
PsiField[] classes = cache.getFieldsByName(name, scope);
if(classes.length != 0)
{
if(merger == null)
{
merger = new Merger<PsiField>();
}
merger.add(classes);
}
}
PsiField[] result = merger == null ? null : merger.getResult();
return result == null ? PsiField.EMPTY_ARRAY : result;
}
示例4: getFieldsByName
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiField[] getFieldsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
Merger<PsiField> merger = null;
for (PsiShortNamesCache cache : myCaches) {
PsiField[] classes = cache.getFieldsByName(name, scope);
if (classes.length != 0) {
if (merger == null) merger = new Merger<PsiField>();
merger.add(classes);
}
}
PsiField[] result = merger == null ? null : merger.getResult();
return result == null ? PsiField.EMPTY_ARRAY : result;
}
示例5: findDeclaredFields
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiField[] findDeclaredFields(@NotNull final PsiManager manager, @NotNull String name) {
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
return cache.getFieldsByName(name, scope);
}
示例6: getItemsByName
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
Condition<PsiMember> qualifiedMatcher = getQualifiedNameMatcher(pattern);
List<PsiMember> result = new ArrayList<PsiMember>();
for (PsiMethod method : cache.getMethodsByName(name, scope)) {
if (!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method, scope, qualifiedMatcher)) {
result.add(method);
}
}
for (PsiField field : cache.getFieldsByName(name, scope)) {
if (isOpenable(field)) {
result.add(field);
}
}
for (PsiClass aClass : cache.getClassesByName(name, scope)) {
if (isOpenable(aClass)) {
result.add(aClass);
}
}
PsiMember[] array = result.toArray(new PsiMember[result.size()]);
Arrays.sort(array, MyComparator.INSTANCE);
return array;
}
示例7: findDeclaredFields
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiField[] findDeclaredFields(@NotNull final PsiManager manager, @NotNull String name)
{
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
return cache.getFieldsByName(name, scope);
}
示例8: getItemsByName
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems)
{
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
List<PsiMember> result = new ArrayList<PsiMember>();
for(PsiMethod method : cache.getMethodsByName(name, scope))
{
if(!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method))
{
result.add(method);
}
}
for(PsiField field : cache.getFieldsByName(name, scope))
{
if(isOpenable(field))
{
result.add(field);
}
}
for(PsiClass aClass : cache.getClassesByName(name, scope))
{
if(isOpenable(aClass))
{
result.add(aClass);
}
}
PsiMember[] array = result.toArray(new PsiMember[result.size()]);
Arrays.sort(array, MyComparator.INSTANCE);
return array;
}
示例9: guessExpectedTypes
import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
public static ExpectedTypeInfo[] guessExpectedTypes (PsiExpression expression, boolean allowVoidType) {
PsiManager manager = expression.getManager();
GlobalSearchScope resolveScope = expression.getResolveScope();
List<ExpectedTypeInfo[]> typesList = new ArrayList<ExpectedTypeInfo[]>();
List<String> expectedMethodNames = new ArrayList<String>();
List<String> expectedFieldNames = new ArrayList<String>();
getExpectedInformation(expression, typesList, expectedMethodNames, expectedFieldNames);
if (typesList.size() == 1 && (!expectedFieldNames.isEmpty() || !expectedMethodNames.isEmpty())) {
ExpectedTypeInfo[] infos = typesList.get(0);
if (infos.length == 1 && infos[0].getKind() == ExpectedTypeInfo.TYPE_OR_SUBTYPE &&
infos[0].getType().equals(PsiType.getJavaLangObject(manager, resolveScope))) {
typesList.clear();
}
}
if (typesList.isEmpty()) {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(expression.getProject());
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(expression.getProject());
PsiElementFactory factory = facade.getElementFactory();
for (String fieldName : expectedFieldNames) {
PsiField[] fields = cache.getFieldsByName(fieldName, resolveScope);
addMemberInfo(fields, expression, typesList, factory);
}
for (String methodName : expectedMethodNames) {
PsiMethod[] methods = cache.getMethodsByName(methodName, resolveScope);
addMemberInfo(methods, expression, typesList, factory);
}
}
ExpectedTypeInfo[] expectedTypes = ExpectedTypeUtil.intersect(typesList);
if (expectedTypes.length == 0 && !typesList.isEmpty()) {
List<ExpectedTypeInfo> union = new ArrayList<ExpectedTypeInfo>();
for (ExpectedTypeInfo[] aTypesList : typesList) {
ContainerUtil.addAll(union, (ExpectedTypeInfo[])aTypesList);
}
expectedTypes = union.toArray(new ExpectedTypeInfo[union.size()]);
}
if (expectedTypes.length == 0) {
PsiType t = allowVoidType ? PsiType.VOID : PsiType.getJavaLangObject(manager, resolveScope);
expectedTypes = new ExpectedTypeInfo[] {ExpectedTypesProvider.createInfo(t, ExpectedTypeInfo.TYPE_OR_SUBTYPE, t, TailType.NONE)};
}
return expectedTypes;
}