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


Java PsiMethodUtil.findMainMethod方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GenerateMainAction.java

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

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

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


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