Search in sources :

Example 1 with InvisibleTypeOrVariableDescription

use of org.eclipse.n4js.scoping.accessModifiers.InvisibleTypeOrVariableDescription in project n4js by eclipse.

the class TopLevelElementsCollector method getTopLevelElements.

/**
 * Returns an iterable of all top-level elements of the given module, given that they are accessed from the given
 * context resource.
 *
 * @param module
 *            The module
 * @param contextResource
 *            The context resource
 */
public Iterable<IEObjectDescription> getTopLevelElements(TModule module, Resource contextResource) {
    List<IEObjectDescription> visible = new ArrayList<>();
    List<IEObjectDescription> invisible = new ArrayList<>();
    module.getTopLevelTypes().forEach(it -> {
        TypeVisibility typeVisiblity = typeVisibilityChecker.isVisible(contextResource, it);
        if (typeVisiblity.visibility) {
            visible.add(createObjectDescription(it));
        } else {
            invisible.add(new InvisibleTypeOrVariableDescription(createObjectDescription(it), typeVisiblity.accessModifierSuggestion));
        }
    });
    module.getVariables().forEach(it -> {
        TypeVisibility typeVisiblity = variableVisibilityChecker.isVisible(contextResource, it);
        if (typeVisiblity.visibility) {
            visible.add(createObjectDescription(it));
        } else {
            invisible.add(new InvisibleTypeOrVariableDescription(createObjectDescription(it), typeVisiblity.accessModifierSuggestion));
        }
    });
    return Iterables.concat(visible, invisible);
}
Also used : TypeVisibility(org.eclipse.n4js.scoping.accessModifiers.AbstractTypeVisibilityChecker.TypeVisibility) ArrayList(java.util.ArrayList) InvisibleTypeOrVariableDescription(org.eclipse.n4js.scoping.accessModifiers.InvisibleTypeOrVariableDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

ArrayList (java.util.ArrayList)1 TypeVisibility (org.eclipse.n4js.scoping.accessModifiers.AbstractTypeVisibilityChecker.TypeVisibility)1 InvisibleTypeOrVariableDescription (org.eclipse.n4js.scoping.accessModifiers.InvisibleTypeOrVariableDescription)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1