Example usage for org.eclipse.jdt.core IMethod isMainMethod

List of usage examples for org.eclipse.jdt.core IMethod isMainMethod

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IMethod isMainMethod.

Prototype

boolean isMainMethod() throws JavaModelException;

Source Link

Document

Returns whether this method is a main method.

Usage

From source file:com.cb.eclipse.folding.java.calculation.MethodStrategy.java

License:Open Source License

private boolean isMainMethod(IMethod elem) throws JavaModelException {
    //   StopWatch watch = new StopWatch("isMainMethod");
    //      watch.start();
    boolean result = elem.isMainMethod();
    //   watch.endAndReport();
    return result;
}

From source file:com.sureassert.uc.builder.SaUCApplicationLaunchShortcutBak.java

License:Open Source License

/**
  * Returns the smallest enclosing <code>IType</code> if the specified object is a main method, or <code>null</code>
  * @param o the object to inspect/*from  w  ww.ja  v  a2  s . c o  m*/
  * @return the smallest enclosing <code>IType</code> of the specified object if it is a main method or <code>null</code> if it is not
  * @since 3.3
  */
 protected IType isMainMethod(Object o) {
     if(o instanceof IAdaptable) {
         IAdaptable adapt = (IAdaptable) o;
         IJavaElement element = (IJavaElement) adapt.getAdapter(IJavaElement.class);
         if(element != null && element.getElementType() == IJavaElement.METHOD) {
             try {
                 IMethod method = (IMethod) element;
                 if(method.isMainMethod()) {
                     return method.getDeclaringType();
                 }
             }
            catch (JavaModelException jme) {JDIDebugUIPlugin.log(jme);}
         }
     }
     return null;
 }

From source file:com.yannicklerestif.metapojos.plugin.project.MetaPojosLaunchShortcut.java

License:Open Source License

/**
 * Returns the smallest enclosing <code>IType</code> if the specified object is a main method, or <code>null</code>
 * @param o the object to inspect/*from  w ww.j a  va  2  s .  c o  m*/
 * @return the smallest enclosing <code>IType</code> of the specified object if it is a main method or <code>null</code> if it is not
 */
private IType isMainMethod(Object o) {
    if (o instanceof IAdaptable) {
        IAdaptable adapt = (IAdaptable) o;
        IJavaElement element = (IJavaElement) adapt.getAdapter(IJavaElement.class);
        if (element != null && element.getElementType() == IJavaElement.METHOD) {
            try {
                IMethod method = (IMethod) element;
                if (method.isMainMethod()) {
                    return method.getDeclaringType();
                }
            } catch (JavaModelException jme) {
                JDIDebugUIPlugin.log(jme);
            }
        }
    }
    return null;
}

From source file:hydrograph.ui.expression.editor.datastructure.ClassDetails.java

License:Apache License

private void addMethodsToClass(IMethod iMethod) throws JavaModelException {
    if (iMethod.isConstructor() || iMethod.isMainMethod() || isMethodDepricated(iMethod)) {
        return;//  www.j av a 2 s. co  m
    } else {
        if (Flags.isPublic(iMethod.getFlags()) && Flags.isStatic(iMethod.getFlags())) {
            if (StringUtils.isBlank(iMethod.getSource())) {
                methodList.add(new MethodDetails(iMethod, cName, false));
            } else
                methodList.add(new MethodDetails(iMethod, cName, true));
        }
    }
}

From source file:io.sarl.eclipse.util.Jdt2Ecore.java

License:Apache License

/** Create the JvmOperation for the given JDT method.
 *
 * @param method - the JDT method./*from  ww  w.  j a v a 2s .  com*/
 * @param context - the context of the constructor.
 * @return the JvmOperation
 * @throws JavaModelException if the Java model is invalid.
 */
public JvmOperation getJvmOperation(IMethod method, XtendTypeDeclaration context) throws JavaModelException {
    if (!method.isConstructor() && !method.isLambdaMethod() && !method.isMainMethod()) {
        final JvmType type = this.typeReferences
                .findDeclaredType(method.getDeclaringType().getFullyQualifiedName(), context);
        return getJvmOperation(method, type);
    }
    return null;
}

From source file:org.bonitasoft.studio.groovy.GroovyDocumentUtil.java

License:Open Source License

@SuppressWarnings("restriction")
public static List<IMethod> getModuleMethods(GroovyCompilationUnit unit) {
    List<IMethod> methods = new ArrayList<IMethod>();

    try {/*from   w w  w  . ja  v  a  2s .  c  o m*/
        IType[] types = unit.getAllTypes();
        for (IType t : types) {
            for (IMethod m : t.getMethods()) {
                if (!m.isBinary() && !m.isMainMethod() && !m.isConstructor()
                        && !m.getElementName().equals("run")) {
                    methods.add(m);
                }
            }
        }

    } catch (JavaModelException e) {
        BonitaStudioLog.error(e);
    }

    return methods;

}

From source file:org.eclipse.acceleo.internal.ide.ui.launching.AcceleoApplicationLaunchShortcut.java

License:Open Source License

/**
 * Returns the smallest enclosing <code>IType</code> if the specified object is a main method, or
 * <code>null</code>.//from ww  w . jav  a  2s. co  m
 * 
 * @param o
 *            the object to inspect
 * @return the smallest enclosing <code>IType</code> of the specified object if it is a main method or
 *         <code>null</code> if it is not
 */
private IType isMainMethod(Object o) {
    if (o instanceof IAdaptable) {
        IAdaptable adapt = (IAdaptable) o;
        IJavaElement element = (IJavaElement) adapt.getAdapter(IJavaElement.class);
        if (element != null && element.getElementType() == IJavaElement.METHOD) {
            try {
                IMethod method = (IMethod) element;
                if (method.isMainMethod()) {
                    return method.getDeclaringType();
                }
            } catch (JavaModelException e) {
                AcceleoUIActivator.getDefault().getLog().log(e.getStatus());
            }
        }
    }
    return null;
}

From source file:org.eclipse.objectteams.otdt.core.TypeHelper.java

License:Open Source License

public static IMethod[] getRoleMethodsComplete(IRoleType role) throws JavaModelException {
    Map<String, IMethod> result = new HashMap<String, IMethod>();
    List<IMethod> methods = new LinkedList<IMethod>();
    IRoleType[] roles = getImplicitSuperRoles(role);

    // for all roles add declared role methods
    for (int roleIdx = 0; roleIdx < roles.length; roleIdx++) {
        methods.addAll(Arrays.asList(roles[roleIdx].getMethods()));
    }//from  www.  j av a2 s .  c om

    // for all roles add regular inherited methods
    for (int roleIdx = 0; roleIdx < roles.length; roleIdx++) {
        methods.addAll(getAllRegularInheritedMethods(roles[roleIdx]));
    }

    for (Iterator<IMethod> methIdx = methods.iterator(); methIdx.hasNext();) {
        IMethod meth = methIdx.next();

        // Just in case
        if (meth == null) {
            continue;
        }

        // filter _OT$ methods
        if (meth.getElementName().startsWith(IOTConstants.OT_DOLLAR)) {
            continue;
        }

        // filter constructors and main()
        if (meth.isConstructor() || meth.isMainMethod()) {
            continue;
        }

        String key = getMethodSignature(meth);
        if (!result.containsKey(key)) {
            result.put(key, meth);
        }
    }

    return result.values().toArray(new IMethod[result.size()]);
}

From source file:org.objectstyle.wolips.jdt.decorator.ActionMethodDecorator.java

License:Open Source License

private boolean isAction(Object element) {
    if (!(element instanceof IMethod)) {
        return false;
    }/*ww  w.  j a  v a 2s  .  com*/
    try {
        IMethod method = (IMethod) element;
        if (!method.getJavaProject().isOnClasspath(method)) {
            return false;
        }
        if (method.isConstructor()) {
            return false;
        }
        if (method.isMainMethod()) {
            return false;
        }
        int flags = method.getFlags();
        if (Flags.isPrivate(flags) || Flags.isStatic(flags)) {
            return false;
        }
        if (method.getNumberOfParameters() > 0) {
            return false;
        }
        String returnType = method.getReturnType();
        if (returnType == null || returnType.length() == 0) {
            return false;
        }
        if (returnType.equals("QWOComponent;")) {
            return true;
        }
        if (returnType.equals("QWOActionResults;")) {
            return true;
        }
    } catch (JavaModelException e) {
        // shit happens
    }
    return false;
}

From source file:org.seasar.s2jsfplugin.model.ManagedBean.java

License:Apache License

private boolean checkMethod(IMethod method) {
    try {/*from w  ww. j  av  a  2  s  .c  o  m*/
        if (!method.isConstructor() && !method.isMainMethod() && Flags.isPublic(method.getFlags())) {
            return true;
        }
    } catch (Exception ex) {

    }
    return false;
}