OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @deprecated | 5 @deprecated |
6 library analyzer.source.embedder; | 6 library analyzer.source.embedder; |
7 | 7 |
8 import 'dart:collection' show HashMap; | 8 import 'dart:collection' show HashMap; |
9 import 'dart:core' hide Resource; | 9 import 'dart:core' hide Resource; |
| 10 import 'dart:io' as io; |
10 | 11 |
11 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
12 import 'package:analyzer/source/package_map_provider.dart' | 13 import 'package:analyzer/source/package_map_provider.dart' |
13 show PackageMapProvider; | 14 show PackageMapProvider; |
14 import 'package:analyzer/src/generated/java_core.dart'; | 15 import 'package:analyzer/src/generated/java_core.dart'; |
15 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; | 16 import 'package:analyzer/src/generated/java_io.dart' show JavaFile; |
16 import 'package:analyzer/src/generated/sdk.dart'; | 17 import 'package:analyzer/src/generated/sdk.dart'; |
17 import 'package:analyzer/src/generated/sdk_io.dart'; | 18 import 'package:analyzer/src/generated/sdk_io.dart'; |
18 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
19 import 'package:analyzer/src/generated/source_io.dart' show FileBasedSource; | 20 import 'package:analyzer/src/generated/source_io.dart' show FileBasedSource; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 69 } |
69 SdkLibrary library = getSdkLibrary(libraryName); | 70 SdkLibrary library = getSdkLibrary(libraryName); |
70 if (library == null) { | 71 if (library == null) { |
71 return null; | 72 return null; |
72 } | 73 } |
73 String srcPath; | 74 String srcPath; |
74 if (relativePath.isEmpty) { | 75 if (relativePath.isEmpty) { |
75 srcPath = library.path; | 76 srcPath = library.path; |
76 } else { | 77 } else { |
77 String libraryPath = library.path; | 78 String libraryPath = library.path; |
78 int index = libraryPath.lastIndexOf(JavaFile.separator); | 79 int index = libraryPath.lastIndexOf(io.Platform.pathSeparator); |
79 if (index == -1) { | 80 if (index == -1) { |
80 index = libraryPath.lastIndexOf('/'); | 81 index = libraryPath.lastIndexOf('/'); |
81 if (index == -1) { | 82 if (index == -1) { |
82 return null; | 83 return null; |
83 } | 84 } |
84 } | 85 } |
85 String prefix = libraryPath.substring(0, index + 1); | 86 String prefix = libraryPath.substring(0, index + 1); |
86 srcPath = '$prefix$relativePath'; | 87 srcPath = '$prefix$relativePath'; |
87 } | 88 } |
88 String filePath = srcPath.replaceAll('/', JavaFile.separator); | 89 String filePath = srcPath.replaceAll('/', io.Platform.pathSeparator); |
89 try { | 90 try { |
90 JavaFile file = new JavaFile(filePath); | 91 JavaFile file = new JavaFile(filePath); |
91 return new FileBasedSource(file, parseUriWithException(dartUri)); | 92 return new FileBasedSource(file, parseUriWithException(dartUri)); |
92 } on URISyntaxException { | 93 } on URISyntaxException { |
93 return null; | 94 return null; |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 /// Install the mapping from [name] to [libDir]/[file]. | 98 /// Install the mapping from [name] to [libDir]/[file]. |
98 void _processEmbeddedLibs(String name, String file, Folder libDir) { | 99 void _processEmbeddedLibs(String name, String file, Folder libDir) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 @override | 177 @override |
177 Uri restoreAbsolute(Source source) { | 178 Uri restoreAbsolute(Source source) { |
178 String path = source.fullName; | 179 String path = source.fullName; |
179 if (path.length > 3 && path[1] == ':' && path[2] == '\\') { | 180 if (path.length > 3 && path[1] == ':' && path[2] == '\\') { |
180 path = '/${path[0]}:${path.substring(2).replaceAll('\\', '/')}'; | 181 path = '/${path[0]}:${path.substring(2).replaceAll('\\', '/')}'; |
181 } | 182 } |
182 Source sdkSource = dartSdk.fromFileUri(Uri.parse('file://$path')); | 183 Source sdkSource = dartSdk.fromFileUri(Uri.parse('file://$path')); |
183 return sdkSource?.uri; | 184 return sdkSource?.uri; |
184 } | 185 } |
185 } | 186 } |
OLD | NEW |