diff options
author | 2016-02-05 22:32:08 +0000 | |
---|---|---|
committer | 2016-02-07 11:33:27 +0000 | |
commit | 5e95a46074fa011461f58cb04521e4b7c2a5f3d5 (patch) | |
tree | b5f601749a3bb0efd6e07a30d1965628c82f7805 /src/main/java/com/google/devtools/build/lib/syntax | |
parent | bc8b5e09ff667c7d0bf7186a7a207629e6d7bad5 (diff) |
WorkspaceASTFunction returns a list of ASTs so we can split the AST before load statements
Issue #824 Step 2.
--
MOS_MIGRATED_REVID=113986176
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java index 1ff08835a2..3d324b21bf 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java @@ -59,6 +59,30 @@ public class BuildFileAST extends ASTNode { setLocation(result.location); } + private BuildFileAST( + ImmutableList<Statement> stmts, + boolean containsErrors, + String contentHashCode, + Location location) { + this.stmts = stmts; + this.containsErrors = containsErrors; + this.contentHashCode = contentHashCode; + this.comments = ImmutableList.of(); + this.setLocation(location); + } + + /** + * Extract a subtree containing only statements from {@code firstStatement} (included) up to + * {@code lastStatement} excluded. + */ + public BuildFileAST subTree(int firstStatement, int lastStatement) { + return new BuildFileAST( + stmts.subList(firstStatement, lastStatement), + containsErrors, + null, + stmts.get(firstStatement).getLocation()); + } + /** Collects all load statements */ private ImmutableList<SkylarkImport> fetchLoads(List<Statement> stmts) { ImmutableList.Builder<SkylarkImport> imports = new ImmutableList.Builder<>(); |