本文整理汇总了Java中com.intellij.psi.util.PsiMethodUtil类的典型用法代码示例。如果您正苦于以下问题:Java PsiMethodUtil类的具体用法?Java PsiMethodUtil怎么用?Java PsiMethodUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiMethodUtil类属于com.intellij.psi.util包,在下文中一共展示了PsiMethodUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ApplicationRunLineMarkerProvider.java
示例5: 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;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:AbstractApplicationConfigurationProducer.java
示例6: createUIComponents
import com.intellij.psi.util.PsiMethodUtil; //导入依赖的package包/类
private void createUIComponents() {
myMainClass = new LabeledComponent<>();
myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, (declaration, place) -> {
if (declaration instanceof PsiClass) {
final PsiClass aClass = (PsiClass) declaration;
if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null) {
return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE;
}
}
return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE;
}
));
}
开发者ID:testIT-LivingDoc,项目名称:livingdoc-intellij,代码行数:15,代码来源:RunConfigurationEditor.java
示例7: 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
示例8: 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
示例9: 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
示例10: createUIComponents
import com.intellij.psi.util.PsiMethodUtil; //导入依赖的package包/类
private void createUIComponents() {
myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>();
myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
if (declaration instanceof PsiClass) {
final PsiClass aClass = (PsiClass)declaration;
if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null && myModuleSelector.findClass(((PsiClass)declaration).getQualifiedName()) != null) {
return Visibility.VISIBLE;
}
}
return Visibility.NOT_VISIBLE;
}
}));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ApplicationConfigurable.java
示例11: 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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ApplicationRunLineMarkerProvider.java
示例12: 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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ApplicationConfigurationProducer.java
示例13: isAccepted
import com.intellij.psi.util.PsiMethodUtil; //导入依赖的package包/类
public boolean isAccepted(final PsiClass aClass) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return PsiMethodUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.hasMainMethod(aClass);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ManifestFileUtil.java
示例14: 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");
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:SystemExitInspection.java
示例15: 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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaFXApplicationMainMethodProvider.java
示例16: 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
示例17: createUIComponents
import com.intellij.psi.util.PsiMethodUtil; //导入依赖的package包/类
/**
* Creates UI Components
*/
private void createUIComponents() {
myMainClass = new LabeledComponent<>();
myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, (declaration, place) -> {
if (declaration instanceof PsiClass) {
final PsiClass aClass = (PsiClass)declaration;
if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null && myModuleSelector.findClass(((PsiClass)declaration).getQualifiedName()) != null) {
return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE;
}
}
return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE;
}));
}
开发者ID:asebak,项目名称:embeddedlinux-jvmdebugger-intellij,代码行数:16,代码来源:RunConfigurationEditor.java
示例18: 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;
}
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:14,代码来源:DefracRunUtil.java
示例19: 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
示例20: createUIComponents
import com.intellij.psi.util.PsiMethodUtil; //导入依赖的package包/类
private void createUIComponents() {
myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>();
myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
if (declaration instanceof PsiClass) {
final PsiClass aClass = (PsiClass)declaration;
if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null) {
return Visibility.VISIBLE;
}
}
return Visibility.NOT_VISIBLE;
}
}));
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:ApplicationConfigurable.java
注:本文中的com.intellij.psi.util.PsiMethodUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论