/**
* Returns a list of the names of the gems which have the specified return type and no inputs.
*/
private List <String> fetchGemsOfType(final TypeExpr returnTypeExpr) {
GemViewer gemViewer = new GemViewer();
final ModuleTypeInfo moduleTypeInfo = perspective.getWorkingModuleTypeInfo();
// Create a filter which will find all gems which return the specified type
// and take no inputs.
// TODO: add support for gems which do take inputs...
GemFilter filter = new GemFilter() {
@Override
public boolean select(GemEntity gemEntity) {
TypeExpr gemType = gemEntity.getTypeExpr();
return TypeExpr.canPatternMatch(gemType, returnTypeExpr, moduleTypeInfo);
}
};
gemViewer.addFilter(filter);
Perspective newPerspective = new Perspective(perspective.getWorkspace(), perspective.getWorkingModule());
newPerspective.setGemEntityViewer(gemViewer);
Set<GemEntity> matchingGems = newPerspective.getVisibleGemEntities();