Java Code Examples for groovy.lang.MetaClass#getMetaMethods()

The following examples show how to use groovy.lang.MetaClass#getMetaMethods() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaElementsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Map<MethodSignature, CompletionItem> getMethods(CompletionContext context) {
    final Map<MethodSignature, CompletionItem> result = new HashMap<MethodSignature, CompletionItem>();
    final Class clz = loadClass(context);
    
    if (clz != null) {
        final MetaClass metaClz = GroovySystem.getMetaClassRegistry().getMetaClass(clz);

        if (metaClz != null) {
            for (MetaMethod method : metaClz.getMetaMethods()) {
                if (!method.isStatic()) {
                    populateProposal(clz, method, context.getPrefix(), context.getAnchor(), result, context.isNameOnly());
                }
            }
        }
        GroovySystem.getMetaClassRegistry().removeMetaClass(clz);
    }
    return result;
}
 
Example 2
Source File: MetaElementsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Map<MethodSignature, CompletionItem> getStaticMethods(CompletionContext context) {
    final Map<MethodSignature, CompletionItem> result = new HashMap<MethodSignature, CompletionItem>();
    final Class clz = loadClass(context);

    if (clz != null) {
        final MetaClass metaClz = GroovySystem.getMetaClassRegistry().getMetaClass(clz);

        if (metaClz != null) {
            for (MetaMethod method : metaClz.getMetaMethods()) {
                if (method.isStatic()) {
                    populateProposal(clz, method, context.getPrefix(), context.getAnchor(), result, context.isNameOnly());
                }
            }
        }
        GroovySystem.getMetaClassRegistry().removeMetaClass(clz);
    }
    return result;
}
 
Example 3
Source File: Inspector.java    From groovy with Apache License 2.0 5 votes vote down vote up
/**
 * Get info about instance and class Methods that are dynamically added through Groovy.
 *
 * @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
 */
public Object[] getMetaMethods() {
    MetaClass metaClass = InvokerHelper.getMetaClass(objectUnderInspection);
    List metaMethods = metaClass.getMetaMethods();
    Object[] result = new Object[metaMethods.size()];
    int i = 0;
    for (Iterator iter = metaMethods.iterator(); iter.hasNext(); i++) {
        MetaMethod metaMethod = (MetaMethod) iter.next();
        result[i] = methodInfo(metaMethod);
    }
    return result;
}
 
Example 4
Source File: OwnedMetaClass.java    From groovy with Apache License 2.0 4 votes vote down vote up
public List<MetaMethod> getMetaMethods() {
    final Object owner = getOwner();
    final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
    return ownerMetaClass.getMetaMethods();
}