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


Java PsiShortNamesCache.getMethodsByNameIfNotMoreThan方法代码示例

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


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

示例1: getMethodsByNameIfNotMoreThan

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount)
{
	Merger<PsiMethod> merger = null;
	for(PsiShortNamesCache cache : myCaches)
	{
		PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, maxCount);
		if(methods.length == maxCount)
		{
			return methods;
		}
		if(methods.length != 0)
		{
			if(merger == null)
			{
				merger = new Merger<PsiMethod>();
			}
			merger.add(methods);
		}
	}
	PsiMethod[] result = merger == null ? null : merger.getResult();
	return result == null ? PsiMethod.EMPTY_ARRAY : result;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:CompositeShortNamesCache.java

示例2: getMethodsByNameIfNotMoreThan

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
  Merger<PsiMethod> merger = null;
  for (PsiShortNamesCache cache : myCaches) {
    PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, maxCount);
    if (methods.length == maxCount) return methods;
    if (methods.length != 0) {
      if (merger == null) merger = new Merger<PsiMethod>();
      merger.add(methods);
    }
  }
  PsiMethod[] result = merger == null ? null : merger.getResult();
  return result == null ? PsiMethod.EMPTY_ARRAY : result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:CompositeShortNamesCache.java

示例3: findDeclaredMethods

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] findDeclaredMethods(@NotNull final PsiManager manager, @NotNull String name) {
  final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
  GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
  return cache.getMethodsByNameIfNotMoreThan(name, scope, MAX_COUNT);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ExpectedTypesProvider.java

示例4: getMethodsToImport

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@NotNull
private List<PsiMethod> getMethodsToImport() {
  PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myMethodCall.getProject());

  GrMethodCall element = myMethodCall.getElement();
  LOG.assertTrue(element != null);
  GrReferenceExpression reference = getMethodExpression(element);
  LOG.assertTrue(reference != null);
  GrArgumentList argumentList = element.getArgumentList();
  String name = reference.getReferenceName();

  ArrayList<PsiMethod> list = new ArrayList<PsiMethod>();
  if (name == null) return list;
  GlobalSearchScope scope = element.getResolveScope();
  PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, 20);
  List<PsiMethod> applicableList = new ArrayList<PsiMethod>();
  for (PsiMethod method : methods) {
    ProgressManager.checkCanceled();
    if (JavaCompletionUtil.isInExcludedPackage(method, false)) continue;
    if (!method.hasModifierProperty(PsiModifier.STATIC)) continue;
    PsiFile file = method.getContainingFile();
    if (file instanceof PsiClassOwner
        //do not show methods from default package
        && !((PsiClassOwner)file).getPackageName().isEmpty() && PsiUtil.isAccessible(element, method)) {
      list.add(method);
      if (PsiUtil.isApplicable(PsiUtil.getArgumentTypes(element, true), method, PsiSubstitutor.EMPTY, element, false)) {
        applicableList.add(method);
      }
    }
  }
  List<PsiMethod> result = applicableList.isEmpty() ? list : applicableList;
  Collections.sort(result, new PsiProximityComparator(argumentList));
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GroovyStaticImportMethodFix.java

示例5: getMethodsToImport

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@NotNull
private List<PsiMethod> getMethodsToImport() {
  PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myMethodCall.getProject());

  GrMethodCall element = myMethodCall.getElement();
  LOG.assertTrue(element != null);
  GrReferenceExpression reference = getMethodExpression(element);
  LOG.assertTrue(reference != null);
  GrArgumentList argumentList = element.getArgumentList();
  String name = reference.getReferenceName();

  ArrayList<PsiMethod> list = new ArrayList<PsiMethod>();
  if (name == null) return list;
  GlobalSearchScope scope = element.getResolveScope();
  PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(name, scope, 20);
  List<PsiMethod> applicableList = new ArrayList<PsiMethod>();
  for (PsiMethod method : methods) {
    ProgressManager.checkCanceled();
    if (JavaCompletionUtil.isInExcludedPackage(method, false)) continue;
    if (!method.hasModifierProperty(PsiModifier.STATIC)) continue;
    PsiFile file = method.getContainingFile();
    if (file instanceof PsiClassOwner
        //do not show methods from default package
        && ((PsiClassOwner)file).getPackageName().length() != 0 && PsiUtil.isAccessible(element, method)) {
      list.add(method);
      if (PsiUtil.isApplicable(PsiUtil.getArgumentTypes(element, true), method, PsiSubstitutor.EMPTY, element, false)) {
        applicableList.add(method);
      }
    }
  }
  List<PsiMethod> result = applicableList.isEmpty() ? list : applicableList;
  Collections.sort(result, new PsiProximityComparator(argumentList));
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:GroovyStaticImportMethodFix.java

示例6: findDeclaredMethods

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] findDeclaredMethods(@NotNull final PsiManager manager, @NotNull String name)
{
	final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(manager.getProject());
	GlobalSearchScope scope = GlobalSearchScope.allScope(manager.getProject());
	return cache.getMethodsByNameIfNotMoreThan(name, scope, MAX_COUNT);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:ExpectedTypesProvider.java

示例7: guessExpectedTypes

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
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.getFieldsByNameIfNotMoreThan(fieldName, resolveScope, MAX_RAW_GUESSED_MEMBERS_COUNT);
      addMemberInfo(fields, expression, typesList, factory);
    }

    for (String methodName : expectedMethodNames) {
      PsiMethod[] methods = cache.getMethodsByNameIfNotMoreThan(methodName, resolveScope, MAX_RAW_GUESSED_MEMBERS_COUNT);
      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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:CreateFromUsageUtils.java


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