public class ParseContext extends Object
This class provides API to record information retrieved while parsing a build or package file like parsed rules or a package definition.
Constructor and Description |
---|
ParseContext(PackageContext packageContext) |
Modifier and Type | Method and Description |
---|---|
com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableMap<String,Optional<String>>> |
getAccessedConfigurationOptions() |
PackageMetadata |
getPackage() |
PackageContext |
getPackageContext()
Returns a context of the package currently being parsed.
|
static ParseContext |
getParseContext(com.google.devtools.build.lib.syntax.Environment env,
com.google.devtools.build.lib.syntax.FuncallExpression ast)
Get the
ParseContext by looking up in the environment. |
com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableMap<String,Object>> |
getRecordedRules() |
boolean |
hasRule(String name) |
void |
recordPackage(PackageMetadata pkg,
com.google.devtools.build.lib.syntax.FuncallExpression ast)
Records the parsed
rawPackage . |
void |
recordReadConfigurationOption(String section,
String key,
String value)
Records an accessed
section.key configuration and its returned value . |
void |
recordRule(com.google.common.collect.ImmutableMap<String,Object> rawRule,
com.google.devtools.build.lib.syntax.FuncallExpression ast)
Records the parsed
rawRule . |
void |
setup(com.google.devtools.build.lib.syntax.Environment env) |
public ParseContext(PackageContext packageContext)
public void recordPackage(PackageMetadata pkg, com.google.devtools.build.lib.syntax.FuncallExpression ast) throws com.google.devtools.build.lib.syntax.EvalException
rawPackage
.com.google.devtools.build.lib.syntax.EvalException
public void recordRule(com.google.common.collect.ImmutableMap<String,Object> rawRule, com.google.devtools.build.lib.syntax.FuncallExpression ast) throws com.google.devtools.build.lib.syntax.EvalException
rawRule
.com.google.devtools.build.lib.syntax.EvalException
public void recordReadConfigurationOption(String section, String key, @Nullable String value)
section.key
configuration and its returned value
.
It's safe to not have to override existing values because configuration options are frozen for the duration of build file parsing.
public PackageMetadata getPackage()
public com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableMap<String,Object>> getRecordedRules()
public boolean hasRule(String name)
true
if the rule with provided name exists, false
otherwise.public com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableMap<String,Optional<String>>> getAccessedConfigurationOptions()
public PackageContext getPackageContext()
public static ParseContext getParseContext(com.google.devtools.build.lib.syntax.Environment env, com.google.devtools.build.lib.syntax.FuncallExpression ast) throws com.google.devtools.build.lib.syntax.EvalException
ParseContext
by looking up in the environment.com.google.devtools.build.lib.syntax.EvalException
public void setup(com.google.devtools.build.lib.syntax.Environment env)