Search in sources :

Example 1 with SkylarkExportable

use of com.google.devtools.build.lib.packages.SkylarkExportable in project bazel by bazelbuild.

the class SkylarkImportLookupFunction method possiblyExport.

private static void possiblyExport(Statement statement, Label extensionLabel, EventHandler eventHandler, com.google.devtools.build.lib.syntax.Environment extensionEnv) {
    if (!(statement instanceof AssignmentStatement)) {
        return;
    }
    AssignmentStatement assignmentStatement = (AssignmentStatement) statement;
    ImmutableSet<String> boundNames = assignmentStatement.getLValue().boundNames();
    for (String name : boundNames) {
        Object lookup = extensionEnv.lookup(name);
        if (lookup instanceof SkylarkExportable) {
            try {
                SkylarkExportable exportable = (SkylarkExportable) lookup;
                if (!exportable.isExported()) {
                    exportable.export(extensionLabel, name);
                }
            } catch (EvalException e) {
                eventHandler.handle(Event.error(e.getLocation(), e.getMessage()));
            }
        }
    }
}
Also used : AssignmentStatement(com.google.devtools.build.lib.syntax.AssignmentStatement) SkylarkExportable(com.google.devtools.build.lib.packages.SkylarkExportable) EvalException(com.google.devtools.build.lib.syntax.EvalException)

Aggregations

SkylarkExportable (com.google.devtools.build.lib.packages.SkylarkExportable)1 AssignmentStatement (com.google.devtools.build.lib.syntax.AssignmentStatement)1 EvalException (com.google.devtools.build.lib.syntax.EvalException)1