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

The following examples show how to use groovy.lang.MetaClass#getProperties() . 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<FieldSignature, CompletionItem> getFields(CompletionContext context) {
    final Map<FieldSignature, CompletionItem> result = new HashMap<FieldSignature, CompletionItem>();
    final Class<?> clazz = loadClass(context);
    
    if (clazz != null) {
        final MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(clazz);

        if (metaClass != null) {
            
            for (Object field : metaClass.getProperties()) {
                MetaProperty prop = (MetaProperty) field;
                if (prop.getName().startsWith(context.getPrefix())) {
                    result.put(new FieldSignature(prop.getName()), new CompletionItem.FieldItem(
                            prop.getType().getSimpleName(),
                            prop.getName(),
                            prop.getModifiers(),
                            context.getAnchor()));
                }
            }
            GroovySystem.getMetaClassRegistry().removeMetaClass(clazz);
        }
    }
    
    return result;
}
 
Example 2
Source File: OwnedMetaClass.java    From groovy with Apache License 2.0 4 votes vote down vote up
public List<MetaProperty> getProperties() {
    final Object owner = getOwner();
    final MetaClass ownerMetaClass = getOwnerMetaClass(owner);
    return ownerMetaClass.getProperties();
}