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


Java PsiShortNamesCache.getMethodsByName方法代码示例

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


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

示例1: 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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:DefaultSymbolNavigationContributor.java

示例2: getMethodsByName

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByName(@NotNull String name, @NotNull GlobalSearchScope scope)
{
	Merger<PsiMethod> merger = null;
	for(PsiShortNamesCache cache : myCaches)
	{
		PsiMethod[] methods = cache.getMethodsByName(name, scope);
		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,代码行数:21,代码来源:CompositeShortNamesCache.java

示例3: getMethodsByName

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
  Merger<PsiMethod> merger = null;
  for (PsiShortNamesCache cache : myCaches) {
    PsiMethod[] methods = cache.getMethodsByName(name, scope);
    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,代码行数:15,代码来源:CompositeShortNamesCache.java

示例4: 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:DefaultSymbolNavigationContributor.java

示例5: vanishGeneratedSources

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
/**
 * Removes all generated sources
 */
private void vanishGeneratedSources() {
  final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject);
  final PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME, GlobalSearchScope.projectScope(myProject));

  CodeInsightUtil.preparePsiElementsForWrite(methods);

  for (int i = 0; i < methods.length; i++) {
    final PsiMethod method = methods[i];
    final PsiClass aClass = method.getContainingClass();
    if (aClass != null) {
      try {
        final PsiFile psiFile = aClass.getContainingFile();
        LOG.assertTrue(psiFile != null);
        final VirtualFile vFile = psiFile.getVirtualFile();
        LOG.assertTrue(vFile != null);
        myProgressWindow.setText(UIDesignerBundle.message("progress.converting", vFile.getPresentableUrl()));
        myProgressWindow.setFraction(((double)i) / ((double)methods.length));
        if (vFile.isWritable()) {
          FormSourceCodeGenerator.cleanup(aClass);
        }
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:GuiDesignerConfigurable.java

示例6: vanishGeneratedSources

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
/**
 * Removes all generated sources
 */
private void vanishGeneratedSources()
{
	final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(myProject);
	final PsiMethod[] methods = cache.getMethodsByName(AsmCodeGenerator.SETUP_METHOD_NAME,
			GlobalSearchScope.projectScope(myProject));

	CodeInsightUtil.preparePsiElementsForWrite(methods);

	for(int i = 0; i < methods.length; i++)
	{
		final PsiMethod method = methods[i];
		final PsiClass aClass = method.getContainingClass();
		if(aClass != null)
		{
			try
			{
				final PsiFile psiFile = aClass.getContainingFile();
				LOG.assertTrue(psiFile != null);
				final VirtualFile vFile = psiFile.getVirtualFile();
				LOG.assertTrue(vFile != null);
				myProgressWindow.setText(UIDesignerBundle.message("progress.converting",
						vFile.getPresentableUrl()));
				myProgressWindow.setFraction(((double) i) / ((double) methods.length));
				if(vFile.isWritable())
				{
					FormSourceCodeGenerator.cleanup(aClass);
				}
			}
			catch(IncorrectOperationException e)
			{
				LOG.error(e);
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-ui-designer,代码行数:39,代码来源:GuiDesignerConfigurable.java

示例7: 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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:DefaultSymbolNavigationContributor.java

示例8: resolveInner

import com.intellij.psi.search.PsiShortNamesCache; //导入方法依赖的package包/类
@NotNull
private ResolveResult[] resolveInner() {
  final String methodName = myElement.getValue();
  if (methodName == null) {
    return ResolveResult.EMPTY_ARRAY;
  }
  final Module module = ModuleUtilCore.findModuleForPsiElement(myElement);

  if (module == null) {
    return ResolveResult.EMPTY_ARRAY;
  }
  final Project project = myElement.getProject();
  final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);

  final PsiMethod[] methods = cache.getMethodsByName(methodName, module.getModuleWithDependenciesScope());
  if (methods.length == 0) {
    return ResolveResult.EMPTY_ARRAY;
  }
  final PsiClass activityBaseClass = JavaPsiFacade.getInstance(project).findClass(
    AndroidUtils.ACTIVITY_BASE_CLASS_NAME, module.getModuleWithDependenciesAndLibrariesScope(false));

  if (activityBaseClass == null) {
    return ResolveResult.EMPTY_ARRAY;
  }
  final List<ResolveResult> result = new ArrayList<ResolveResult>();
  final List<ResolveResult> resultsWithMistake = new ArrayList<ResolveResult>();

  for (PsiMethod method : methods) {
    final PsiClass parentClass = method.getContainingClass();

    if (parentClass != null && parentClass.isInheritor(activityBaseClass, true)) {
      if (checkSignature(method)) {
        result.add(new MyResolveResult(method, true));
      }
      else {
        resultsWithMistake.add(new MyResolveResult(method, false));
      }
    }
  }
  return result.size() > 0
         ? result.toArray(new ResolveResult[result.size()])
         : resultsWithMistake.toArray(new ResolveResult[resultsWithMistake.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:OnClickConverter.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:51,代码来源:CreateFromUsageUtils.java


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