PsiMethod (PsiClass clazz) { PsiMethod[] methods = clazz.findMethodsByName("main", false); // is it public static void main(String[] args) for (PsiMethod method : methods) { // must be public if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { continue; } // must be static if (!method.hasModifierProperty(PsiModifier.STATIC)) { continue; } // must have void as return type PsiType returnType = method.getReturnType(); if (!PsiTypes.voidType().equals(returnType)) { continue; } // must have one parameter PsiParameter[] parameters = method.getParameterList().getParameters(); if (parameters.length != 1) { continue; } // parameter must be string array if (!isStringArrayType(parameters[0].getType())) { continue; } // public static void main(String[] args) method found return method; } // main not found return null; }