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


Java PsiMethodUtil.hasMainMethod方法代码示例

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


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

示例1: isEntryPoint

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
public boolean isEntryPoint(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  if (element instanceof PsiMethod && isAddMainsEnabled() && PsiClassImplUtil.isMainOrPremainMethod((PsiMethod)element)) {
    return true;
  }
  if (element instanceof PsiClass) {
    PsiClass aClass = (PsiClass)element;
    final PsiClass applet = psiFacade.findClass("java.applet.Applet", GlobalSearchScope.allScope(project));
    if (isAddAppletEnabled() && applet != null && aClass.isInheritor(applet, true)) {
      return true;
    }

    final PsiClass servlet = psiFacade.findClass("javax.servlet.Servlet", GlobalSearchScope.allScope(project));
    if (isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true)) {
      return true;
    }
    if (isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass)) return true;
  }
  if (element instanceof PsiModifierListOwner) {
    final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
    if (entryPointsManager.isEntryPoint(element)) return true;
  }
  for (EntryPoint extension : myExtensions) {
    if (extension.isEntryPoint(element)) {
      return true;
    }
  }
  final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
  for (ImplicitUsageProvider provider : implicitUsageProviders) {
    if (provider.isImplicitUsage(element)) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:UnusedDeclarationInspectionBase.java

示例2: checkClass

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
protected boolean checkClass(@NotNull HeaderValuePart valuePart, @NotNull PsiClass aClass, @NotNull AnnotationHolder holder) {
  if (!PsiMethodUtil.hasMainMethod(aClass)) {
    holder.createErrorAnnotation(valuePart.getHighlightingRange(), ManifestBundle.message("header.main.class.invalid"));
    return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ClassReferenceParser.java

示例3: checkConfiguration

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
  JavaParametersUtil.checkAlternativeJRE(this);
  final JavaRunConfigurationModule configurationModule = getConfigurationModule();
  final PsiClass psiClass = configurationModule.checkModuleAndClassName(MAIN_CLASS_NAME, ExecutionBundle.message("no.main.class.specified.error.text"));
  if (!PsiMethodUtil.hasMainMethod(psiClass)) {
    throw new RuntimeConfigurationWarning(ExecutionBundle.message("main.method.not.found.in.class.error.message", MAIN_CLASS_NAME));
  }
  ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), configurationModule.getModule());
  JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ApplicationConfiguration.java

示例4: checkConfiguration

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
public void checkConfiguration() throws RuntimeConfigurationException {
  JavaParametersUtil.checkAlternativeJRE(this);
  final JavaRunConfigurationModule configurationModule = getConfigurationModule();
  final PsiClass psiClass = configurationModule.checkModuleAndClassName(MAIN_CLASS_NAME, ExecutionBundle.message("no.main.class.specified.error.text"));
  if (!PsiMethodUtil.hasMainMethod(psiClass)) {
    throw new RuntimeConfigurationWarning(ExecutionBundle.message("main.method.not.found.in.class.error.message", MAIN_CLASS_NAME));
  }
  ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), configurationModule.getModule());
  JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:ApplicationConfiguration.java

示例5: checkConfiguration

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
public void checkConfiguration() throws RuntimeConfigurationException
{
	JavaParametersUtil.checkAlternativeJRE(this);
	final JavaRunConfigurationModule configurationModule = getConfigurationModule();
	final PsiClass psiClass = configurationModule.checkModuleAndClassName(MAIN_CLASS_NAME, ExecutionBundle.message("no.main.class.specified.error.text"));
	if(!PsiMethodUtil.hasMainMethod(psiClass))
	{
		throw new RuntimeConfigurationWarning(ExecutionBundle.message("main.method.not.found.in.class.error.message", MAIN_CLASS_NAME));
	}
	ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), configurationModule.getModule());
	JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:ApplicationConfiguration.java

示例6: canBeRunByGroovy

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
public static boolean canBeRunByGroovy(final PsiClass psiClass) {
  return psiClass instanceof GroovyScriptClass ||
         isRunnable(psiClass) ||
         psiClass instanceof GrTypeDefinition && PsiMethodUtil.hasMainMethod(psiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:GroovyRunnerPsiUtil.java

示例7: isContext

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
@Override
protected boolean isContext(ConfigurationContext context) {
    return super.isContext(context) && !isTestScope &&
            psiClass != null && PsiMethodUtil.hasMainMethod(psiClass);
}
 
开发者ID:shlxue,项目名称:MvnRunner,代码行数:6,代码来源:MvnRunConfigurationProducer.java

示例8: isEntryPoint

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
public boolean isEntryPoint(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  if (element instanceof PsiMethod && isAddMainsEnabled() && PsiClassImplUtil.isMainOrPremainMethod((PsiMethod)element)) {
    return true;
  }
  if (element instanceof PsiClass) {
    PsiClass aClass = (PsiClass)element;
    /*
    if (aClass.isAnnotationType()) {
      return true;
    }

    if (aClass.isEnum()) {
      return true;
    }
    */
    final PsiClass applet = psiFacade.findClass("java.applet.Applet", GlobalSearchScope.allScope(project));
    if (isAddAppletEnabled() && applet != null && aClass.isInheritor(applet, true)) {
      return true;
    }

    final PsiClass servlet = psiFacade.findClass("javax.servlet.Servlet", GlobalSearchScope.allScope(project));
    if (isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true)) {
      return true;
    }
    if (isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass)) return true;
  }
  if (element instanceof PsiModifierListOwner) {
    final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
    if (entryPointsManager.isEntryPoint((PsiModifierListOwner)element)) return true;
    //if (AnnotationUtil
    //  .checkAnnotatedUsingPatterns((PsiModifierListOwner)element, entryPointsManager.ADDITIONAL_ANNOTATIONS) ||
    //  AnnotationUtil
    //  .checkAnnotatedUsingPatterns((PsiModifierListOwner)element, entryPointsManager.getAdditionalAnnotations())) {
    //  return true;
    //}
  }
  for (EntryPoint extension : myExtensions) {
    if (extension.isEntryPoint(element)) {
      return true;
    }
  }
  final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
  for (ImplicitUsageProvider provider : implicitUsageProviders) {
    if (provider.isImplicitUsage(element)) return true;
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:50,代码来源:UnusedDeclarationInspection.java

示例9: isEntryPoint

import com.intellij.psi.util.PsiMethodUtil; //导入方法依赖的package包/类
public boolean isEntryPoint(@NotNull PsiElement element)
{
	final Project project = element.getProject();
	final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
	if(element instanceof PsiMethod && isAddMainsEnabled() && PsiClassImplUtil.isMainOrPremainMethod((PsiMethod)
			element))
	{
		return true;
	}
	if(element instanceof PsiClass)
	{
		PsiClass aClass = (PsiClass) element;
		final PsiClass applet = psiFacade.findClass("java.applet.Applet", GlobalSearchScope.allScope(project));
		if(isAddAppletEnabled() && applet != null && aClass.isInheritor(applet, true))
		{
			return true;
		}

		final PsiClass servlet = psiFacade.findClass("javax.servlet.Servlet", GlobalSearchScope.allScope(project));
		if(isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true))
		{
			return true;
		}
		if(isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass))
		{
			return true;
		}
	}
	if(element instanceof PsiModifierListOwner)
	{
		final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
		if(entryPointsManager.isEntryPoint(element))
		{
			return true;
		}
	}
	for(EntryPoint extension : myExtensions)
	{
		if(extension.isEntryPoint(element))
		{
			return true;
		}
	}
	final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
	for(ImplicitUsageProvider provider : implicitUsageProviders)
	{
		if(provider.isImplicitUsage(element))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:54,代码来源:UnusedDeclarationInspectionBase.java


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