aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/events
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-06-12 11:37:46 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-06-12 11:52:48 +0000
commit4833822ced449008ffc57d217334edac3122ef7e (patch)
treed85e6abf853d68568d47051c2f56eb605a561f71 /src/main/java/com/google/devtools/build/lib/events
parent19f3413dbc4bda45df09ddfbe882c41fc81350d8 (diff)
Remove Path from Location, ParserInputSource and bunch of other low-level classes.
This makes the code cleaner because a lot of places never read the file and thus never needed a Path in the first place. I got to this change in a bit convoluted way: - I wanted the default tools in Android rules to point to //external: - I wanted to make sure that that doesn't cause an error is no Android rules are built, thus I had to add some binding for them in the default WORKSPACE file - I wanted the Android rules not to depend on Bazel core with an eye towards eventually moving them to a separate jar / Skylark code - The default WORKSPACE file is currently composed from files extracted by the Bazel launcher which would make the Android rules depend on a very core mechanism - I couldn't simply pass in jdk.WORKSPACE as a String because Location, ParserInputSource and a bunch of other things needed a Path, which a simple string doesn't have. Thus, this change. -- MOS_MIGRATED_REVID=95828839
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/events')
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/Location.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/events/Location.java b/src/main/java/com/google/devtools/build/lib/events/Location.java
index c16c244c5d..160d4a586d 100644
--- a/src/main/java/com/google/devtools/build/lib/events/Location.java
+++ b/src/main/java/com/google/devtools/build/lib/events/Location.java
@@ -23,11 +23,11 @@ import java.io.Serializable;
/**
* A Location is a range of characters within a file.
*
- * The start and end locations may be the same, in which case the Location
+ * <p>The start and end locations may be the same, in which case the Location
* denotes a point in the file, not a range. The path may be null, indicating
* an unknown file.
*
- * Implementations of Location should be optimised for speed of construction,
+ * <p>Implementations of Location should be optimised for speed of construction,
* not speed of attribute access, as far more Locations are created during
* parsing than are ever used to display error messages.
*/
@@ -38,10 +38,10 @@ public abstract class Location implements Serializable {
private final PathFragment path;
private final LineAndColumn startLineAndColumn;
- private LocationWithPathAndStartColumn(Path path, int startOffSet, int endOffSet,
+ private LocationWithPathAndStartColumn(PathFragment path, int startOffSet, int endOffSet,
LineAndColumn startLineAndColumn) {
super(startOffSet, endOffSet);
- this.path = path != null ? path.asFragment() : null;
+ this.path = path;
this.startLineAndColumn = startLineAndColumn;
}
@@ -60,7 +60,7 @@ public abstract class Location implements Serializable {
/**
* Returns a Location with a given Path, start and end offset and start line and column info.
*/
- public static Location fromPathAndStartColumn(Path path, int startOffSet, int endOffSet,
+ public static Location fromPathAndStartColumn(PathFragment path, int startOffSet, int endOffSet,
LineAndColumn startLineAndColumn) {
return new LocationWithPathAndStartColumn(path, startOffSet, endOffSet, startLineAndColumn);
}
@@ -70,14 +70,17 @@ public abstract class Location implements Serializable {
* region within the file. Try to use a more specific location if possible.
*/
public static Location fromFile(Path path) {
- return fromFileAndOffsets(path, 0, 0);
+ return fromFileAndOffsets(path.asFragment(), 0, 0);
}
+ public static Location fromPathFragment(PathFragment path) {
+ return fromFileAndOffsets(path, 0, 0);
+ }
/**
* Returns a Location relating to the subset of file 'path', starting at
* 'startOffset' and ending at 'endOffset'.
*/
- public static Location fromFileAndOffsets(final Path path,
+ public static Location fromFileAndOffsets(final PathFragment path,
int startOffset,
int endOffset) {
return new LocationWithPathAndStartColumn(path, startOffset, endOffset, null);
@@ -113,7 +116,7 @@ public abstract class Location implements Serializable {
* Returns the path of the file to which the start/end offsets refer. May be
* null if the file name information is not available.
*
- * This method is intentionally abstract, as a space optimisation. Some
+ * <p>This method is intentionally abstract, as a space optimisation. Some
* subclass instances implement sharing of common data (e.g. tables for
* convering offsets into line numbers) and this enables them to share the
* Path value in the same way.