aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-09-15 19:37:11 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-09-16 10:17:38 +0000
commitac023bbcb127884e2c14c5c70848c61f149dfbbe (patch)
tree1a0cfc96e4fe1209fe3fc36535f45936823df44d /src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
parentfe87155b7154f7ef64c7ab095071b148980f035f (diff)
Get rid of transient errors during preprocessing and throw IOExceptions instead. Transient errors were only detected on IOExceptions, but preprocessing doesn't actually throw IOExceptions except if it fails before it even opens the main file, so there's no sense in trying to construct a package in that case.
-- MOS_MIGRATED_REVID=103119445
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java b/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
index acf06f9460..f3c792fbb9 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Preprocessor.java
@@ -97,23 +97,26 @@ public interface Preprocessor {
public final ParserInputSource result;
public final boolean preprocessed;
public final boolean containsErrors;
- public final boolean containsTransientErrors;
public final List<Event> events;
- private Result(ParserInputSource result,
- boolean preprocessed, boolean containsPersistentErrors, boolean containsTransientErrors,
+ private Result(
+ ParserInputSource result,
+ boolean preprocessed,
+ boolean containsErrors,
List<Event> events) {
this.result = result;
this.preprocessed = preprocessed;
- this.containsErrors = containsPersistentErrors || containsTransientErrors;
- this.containsTransientErrors = containsTransientErrors;
+ this.containsErrors = containsErrors;
this.events = ImmutableList.copyOf(events);
}
/** Convenience factory for a {@link Result} wrapping non-preprocessed BUILD file contents. */
public static Result noPreprocessing(ParserInputSource buildFileSource) {
- return new Result(buildFileSource, /*preprocessed=*/false, /*containsErrors=*/false,
- /*containsTransientErrors=*/false, ImmutableList.<Event>of());
+ return new Result(
+ buildFileSource,
+ /*preprocessed=*/false,
+ /*containsErrors=*/false,
+ ImmutableList.<Event>of());
}
/**
@@ -123,32 +126,31 @@ public interface Preprocessor {
*/
public static Result success(ParserInputSource result, boolean containsErrors,
List<Event> events) {
- return new Result(result, /*preprocessed=*/true, /*containsPersistentErrors=*/containsErrors,
- /*containsTransientErrors=*/false, events);
+ return new Result(result, /*preprocessed=*/true, containsErrors, events);
}
public static Result invalidSyntax(PathFragment buildFile, List<Event> events) {
- return new Result(ParserInputSource.create(EMPTY_CHARS, buildFile), /*preprocessed=*/true,
- /*containsPersistentErrors=*/true, /*containsTransientErrors=*/false, events);
- }
-
- public static Result transientError(PathFragment buildFile, List<Event> events) {
- return new Result(ParserInputSource.create(EMPTY_CHARS, buildFile), /*preprocessed=*/false,
- /*containsPersistentErrors=*/false, /*containsTransientErrors=*/true, events);
+ return new Result(
+ ParserInputSource.create(EMPTY_CHARS, buildFile),
+ /*preprocessed=*/true,
+ /*containsErrors=*/true,
+ events);
}
}
/**
* Returns a Result resulting from applying Python preprocessing to the contents of "in". If
* errors happen, they must be reported both as an event on eventHandler and in the function
- * return value.
+ * return value. An IOException is only thrown when preparing for preprocessing. Once
+ * preprocessing actually begins, any I/O problems encountered will be reflected in the return
+ * value, not manifested as exceptions.
*
* @param in the BUILD file to be preprocessed.
* @param packageName the BUILD file's package.
* @param globber a globber for evaluating globs.
* @param globals the global bindings for the Python environment.
* @param ruleNames the set of names of all rules in the build language.
- * @throws IOException if there was an I/O problem during preprocessing.
+ * @throws IOException if there was an I/O problem preparing for preprocessing.
* @return a pair of the ParserInputSource and a map of subincludes seen during the evaluation
*/
Result preprocess(