本文整理汇总了Java中com.intellij.psi.util.PsiMethodUtil.findMainMethod方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethodUtil.findMainMethod方法的具体用法?Java PsiMethodUtil.findMainMethod怎么用?Java PsiMethodUtil.findMainMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiMethodUtil
的用法示例。
在下文中一共展示了PsiMethodUtil.findMainMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isActionEnabled
import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
private static boolean isActionEnabled(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) return false;
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (editor == null) return false;
int offset = editor.getCaretModel().getOffset();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) return false;
PsiElement element = file.findElementAt(offset);
if (element == null) return false;
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass == null) return false;
if (PsiMethodUtil.findMainMethod(psiClass) != null) return false;
if (FormClassIndex.findFormsBoundToClass(project, psiClass).isEmpty()) return false;
return true;
}
示例2: isActionEnabled
import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
private static boolean isActionEnabled(final AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
if (project == null) return false;
Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (editor == null) return false;
int offset = editor.getCaretModel().getOffset();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) return false;
PsiElement element = file.findElementAt(offset);
if (element == null) return false;
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass == null) return false;
if (PsiMethodUtil.findMainMethod(psiClass) != null) return false;
if (FormClassIndex.findFormsBoundToClass(psiClass).isEmpty()) return false;
return true;
}
示例3: isActionEnabled
import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
private static boolean isActionEnabled(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) return false;
Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (editor == null) return false;
int offset = editor.getCaretModel().getOffset();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) return false;
PsiElement element = file.findElementAt(offset);
if (element == null) return false;
PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass == null) return false;
if (PsiMethodUtil.findMainMethod(psiClass) != null) return false;
if (FormClassIndex.findFormsBoundToClass(psiClass).isEmpty()) return false;
return true;
}
示例4: doSetupConfigFromContext
import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
protected boolean doSetupConfigFromContext(
BlazeCommandRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
PsiClass mainClass = getMainClass(context);
if (mainClass == null) {
return false;
}
// Try setting source element to a main method so ApplicationConfigurationProducer
// can't override our configuration by producing a more specific one.
PsiMethod mainMethod = PsiMethodUtil.findMainMethod(mainClass);
if (mainMethod == null) {
sourceElement.set(mainClass);
} else {
sourceElement.set(mainMethod);
}
TargetIdeInfo target = getTarget(context.getProject(), mainClass);
if (target == null) {
return false;
}
configuration.setTargetInfo(target.toTargetInfo());
BlazeCommandRunConfigurationCommonState handlerState =
configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setGeneratedName();
return true;
}