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


Java PsiMethodUtil.isMainMethod方法代码示例

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


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

示例1: getInfo

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Nullable
@Override
public Info getInfo(final PsiElement e)
{
	if(isIdentifier(e))
	{
		PsiElement element = e.getParent();
		if(element instanceof PsiClass && PsiMethodUtil.findMainInClass((PsiClass) element) != null || element instanceof PsiMethod && "main".equals(((PsiMethod) element).getName()) &&
				PsiMethodUtil.isMainMethod((PsiMethod) element))
		{
			final AnAction[] actions = ExecutorAction.getActions(0);
			return new Info(AllIcons.RunConfigurations.TestState.Run, element1 -> StringUtil.join(ContainerUtil.mapNotNull(actions, action -> getText(action, element1)), "\n"), actions);
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ApplicationRunLineMarkerProvider.java

示例2: findMain

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Nullable
private static PsiMethod findMain(PsiElement element)
{
	PsiMethod method;
	while((method = PsiTreeUtil.getParentOfType(element, PsiMethod.class)) != null)
	{
		if(PsiMethodUtil.isMainMethod(method))
		{
			return method;
		}
		else
		{
			element = method.getParent();
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:AbstractApplicationConfigurationProducer.java

示例3: getInfo

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Nullable
@Override
public Info getInfo(PsiElement e) {
  if (isIdentifier(e)) {
    PsiElement element = e.getParent();
    if (element instanceof PsiClass && PsiMethodUtil.findMainInClass((PsiClass)element) != null)
      return new Info(ApplicationConfigurationType.getInstance().getIcon(), null, ExecutorAction.getActions(0));
    if (element instanceof PsiMethod && "main".equals(((PsiMethod)element).getName()) && PsiMethodUtil.isMainMethod((PsiMethod)element))
      return new Info(ApplicationConfigurationType.getInstance().getIcon(), null, ExecutorAction.getActions(0));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ApplicationRunLineMarkerProvider.java

示例4: findMain

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Nullable
private static PsiMethod findMain(PsiElement element) {
  PsiMethod method;
  while ((method = PsiTreeUtil.getParentOfType(element, PsiMethod.class)) != null) {
    if (PsiMethodUtil.isMainMethod(method)) return method;
    else element = method.getParent();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ApplicationConfigurationProducer.java

示例5: visitMethodCallExpression

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (!"exit".equals(methodName) && !"halt".equals(methodName)) {
    return;
  }
  final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
  if (ignoreInMainMethod && PsiMethodUtil.isMainMethod(containingMethod)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 1) {
    return;
  }
  final PsiParameter[] parameters = parameterList.getParameters();
  final PsiType parameterType = parameters[0].getType();
  if (!parameterType.equals(PsiType.INT)) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  final String className = aClass.getQualifiedName();
  if (!"java.lang.System".equals(className) && !"java.lang.Runtime".equals(className)) {
    return;
  }
  registerMethodCallError(expression, "System");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:SystemExitInspection.java

示例6: findMainInClass

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
public PsiMethod findMainInClass(PsiClass clazz) {
  final PsiMethod[] launches = clazz.findMethodsByName(LAUNCH_MAIN, true);
  for (PsiMethod launchMethod : launches) {
    if (PsiMethodUtil.isMainMethod(launchMethod)) {
      return launchMethod;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaFXApplicationMainMethodProvider.java

示例7: findMainMethod

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Nullable
public static PsiMethod findMainMethod(@Nullable PsiElement element) {
  PsiMethod method;
  while((method = PsiTreeUtil.getParentOfType(element, PsiMethod.class)) != null) {
    if(PsiMethodUtil.isMainMethod(method)) {
      return method;
    }

    element = method.getParent();
  }

  return null;
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:14,代码来源:DefracRunUtil.java

示例8: visitMethodCallExpression

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (!"exit".equals(methodName) && !"halt".equals(methodName)) {
    return;
  }
  final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class);
  if (ignoreInMainMethod && PsiMethodUtil.isMainMethod(containingMethod)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 1) {
    return;
  }
  final PsiParameter[] parameters = parameterList.getParameters();
  final PsiType parameterType = parameters[0].getType();
  if (!parameterType.equals(PsiType.INT)) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  final String className = aClass.getQualifiedName();
  if (!"java.lang.System".equals(className) && !"java.lang.Runtime".equals(className)) {
    return;
  }
  registerMethodCallError(expression, "System");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:SystemExitInspection.java


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