Fix null checks in bazel workspace.

Change-Id: I5af11caba2cecac95c4d4070bcd6cc831df4666a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/workspace/bazel.dart b/pkg/analyzer/lib/src/workspace/bazel.dart
index 8627efe..fdf4b00 100644
--- a/pkg/analyzer/lib/src/workspace/bazel.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel.dart
@@ -446,8 +446,9 @@
         return writableFile;
       }
       // READONLY
+      var readonly = this.readonly;
       if (readonly != null) {
-        File file = provider.getFile(context.join(readonly!, relative));
+        File file = provider.getFile(context.join(readonly, relative));
         if (file.exists) {
           return file;
         }
@@ -573,8 +574,9 @@
       }
     }
     // READONLY
+    var readonly = this.readonly;
     if (readonly != null) {
-      if (context.isWithin(readonly!, p)) {
+      if (context.isWithin(readonly, p)) {
         return context.relative(p, from: readonly);
       }
     }
@@ -751,21 +753,13 @@
 
   @override
   bool contains(Source source) {
-    if (source.uri.isScheme('package')) {
-      return source.uri.toString().startsWith(_uriPrefix);
-    }
-    var filePath = source.fullName;
-    if (workspace.findFile(filePath) == null) {
-      return false;
-    }
-    if (!workspace.provider.pathContext.isWithin(root, filePath)) {
-      return false;
+    var uri = source.uri;
+    if (uri.isScheme('package')) {
+      return uri.toString().startsWith(_uriPrefix);
     }
 
-    // Just because [filePath] is within [root] does not mean it is in this
-    // package; it could be in a "subpackage." Must go through the work of
-    // learning exactly which package [filePath] is contained in.
-    return workspace.findPackageFor(filePath)!.root == root;
+    var path = source.fullName;
+    return workspace.findPackageFor(path)?.root == root;
   }
 
   @override