Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 library kernel.import_table; | 4 library kernel.import_table; |
| 5 | 5 |
| 6 import 'ast.dart'; | 6 import 'ast.dart'; |
| 7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
| 8 | 8 |
| 9 abstract class ImportTable { | 9 abstract class ImportTable { |
| 10 int getImportIndex(Library library); | 10 int getImportIndex(Library library); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 if (targetUri == null) { | 81 if (targetUri == null) { |
| 82 throw '$referenceUri cannot refer to library without an import URI'; | 82 throw '$referenceUri cannot refer to library without an import URI'; |
| 83 } | 83 } |
| 84 if (targetUri.scheme == 'file' && referenceUri.scheme == 'file') { | 84 if (targetUri.scheme == 'file' && referenceUri.scheme == 'file') { |
| 85 var targetDirectory = path.dirname(targetUri.path); | 85 var targetDirectory = path.dirname(targetUri.path); |
| 86 var currentDirectory = path.dirname(referenceUri.path); | 86 var currentDirectory = path.dirname(referenceUri.path); |
| 87 var relativeDirectory = | 87 var relativeDirectory = |
| 88 path.relative(targetDirectory, from: currentDirectory); | 88 path.relative(targetDirectory, from: currentDirectory); |
| 89 var filename = path.basename(targetUri.path); | 89 var filename = path.basename(targetUri.path); |
| 90 table.addImport(target, '$relativeDirectory/$filename'); | 90 table.addImport(target, '$relativeDirectory/$filename'); |
| 91 } else if (targetUri.scheme == 'file') { | 91 } else if (targetUri.scheme == 'file' && referenceUri.path != "_builtin") { |
|
asgerf
2016/12/09 10:57:58
Please add a comment explaining what this is
karlklose
2016/12/15 07:54:19
Removed.
| |
| 92 // Cannot import a file:URI from a dart:URI or package:URI. | 92 // Cannot import a file:URI from a dart:URI or package:URI. |
| 93 // We may want to remove this restriction, but for now it's just a sanity | 93 // We may want to remove this restriction, but for now it's just a sanity |
| 94 // check. | 94 // check. |
| 95 throw '$referenceUri cannot refer to application library $targetUri'; | 95 throw '$referenceUri cannot refer to application library $targetUri'; |
| 96 } else { | 96 } else { |
| 97 table.addImport(target, target.importUri.toString()); | 97 table.addImport(target, target.importUri.toString()); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 visitClassReference(Class node) { | 101 visitClassReference(Class node) { |
| 102 addLibraryImport(node.enclosingLibrary); | 102 addLibraryImport(node.enclosingLibrary); |
| 103 } | 103 } |
| 104 | 104 |
| 105 defaultMemberReference(Member node) { | 105 defaultMemberReference(Member node) { |
| 106 addLibraryImport(node.enclosingLibrary); | 106 addLibraryImport(node.enclosingLibrary); |
| 107 } | 107 } |
| 108 | 108 |
| 109 visitName(Name name) { | 109 visitName(Name name) { |
| 110 if (name.library != null) { | 110 if (name.library != null) { |
| 111 addLibraryImport(name.library); | 111 addLibraryImport(name.library); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 } | 114 } |
| OLD | NEW |