本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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");
}