Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: pkg/analyzer/lib/src/generated/bazel.dart

Issue 2667633004: Remove class FastUri from analyzer. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.bazel; 5 library analyzer.src.generated.bazel;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:core'; 8 import 'dart:core';
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
11 import 'package:analyzer/src/generated/sdk.dart'; 11 import 'package:analyzer/src/generated/sdk.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:analyzer/src/generated/source_io.dart'; 13 import 'package:analyzer/src/generated/source_io.dart';
14 import 'package:analyzer/src/generated/workspace.dart'; 14 import 'package:analyzer/src/generated/workspace.dart';
15 import 'package:analyzer/src/util/fast_uri.dart';
16 import 'package:path/path.dart'; 15 import 'package:path/path.dart';
17 16
18 /** 17 /**
19 * Instances of the class `BazelFileUriResolver` resolve `file` URI's by first 18 * Instances of the class `BazelFileUriResolver` resolve `file` URI's by first
20 * resolving file uri's in the expected way, and then by looking in the 19 * resolving file uri's in the expected way, and then by looking in the
21 * corresponding generated directories. 20 * corresponding generated directories.
22 */ 21 */
23 class BazelFileUriResolver extends ResourceUriResolver { 22 class BazelFileUriResolver extends ResourceUriResolver {
24 final BazelWorkspace workspace; 23 final BazelWorkspace workspace;
25 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Uri restore(String root, String path) { 97 Uri restore(String root, String path) {
99 if (root != null && context.isWithin(root, path)) { 98 if (root != null && context.isWithin(root, path)) {
100 String relative = context.relative(path, from: root); 99 String relative = context.relative(path, from: root);
101 List<String> components = context.split(relative); 100 List<String> components = context.split(relative);
102 if (components.length >= 1 && components[0] == 'third_party') { 101 if (components.length >= 1 && components[0] == 'third_party') {
103 if (components.length > 4 && 102 if (components.length > 4 &&
104 components[1] == 'dart' && 103 components[1] == 'dart' &&
105 components[3] == 'lib') { 104 components[3] == 'lib') {
106 String packageName = components[2]; 105 String packageName = components[2];
107 String pathInLib = components.skip(4).join('/'); 106 String pathInLib = components.skip(4).join('/');
108 return FastUri.parse('package:$packageName/$pathInLib'); 107 return Uri.parse('package:$packageName/$pathInLib');
109 } 108 }
110 } else { 109 } else {
111 for (int i = 2; i < components.length - 1; i++) { 110 for (int i = 2; i < components.length - 1; i++) {
112 String component = components[i]; 111 String component = components[i];
113 if (component == 'lib') { 112 if (component == 'lib') {
114 String packageName = components.getRange(0, i).join('.'); 113 String packageName = components.getRange(0, i).join('.');
115 String pathInLib = components.skip(i + 1).join('/'); 114 String pathInLib = components.skip(i + 1).join('/');
116 return FastUri.parse('package:$packageName/$pathInLib'); 115 return Uri.parse('package:$packageName/$pathInLib');
117 } 116 }
118 } 117 }
119 } 118 }
120 } 119 }
121 return null; 120 return null;
122 } 121 }
123 122
124 // Search in each root. 123 // Search in each root.
125 for (String root in [ 124 for (String root in [
126 _workspace.bin, 125 _workspace.bin,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) { 319 if (provider.getFolder(context.join(root, 'blaze-genfiles')).exists) {
321 return 'blaze'; 320 return 'blaze';
322 } 321 }
323 if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) { 322 if (provider.getFolder(context.join(root, 'bazel-genfiles')).exists) {
324 return 'bazel'; 323 return 'bazel';
325 } 324 }
326 // Couldn't find it. Make a default assumption. 325 // Couldn't find it. Make a default assumption.
327 return defaultSymlinkPrefix; 326 return defaultSymlinkPrefix;
328 } 327 }
329 } 328 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/file_state.dart ('k') | pkg/analyzer/lib/src/generated/gn.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698