| 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 | 4 |
| 5 library fasta.library_builder; | 5 library fasta.library_builder; |
| 6 | 6 |
| 7 import '../combinator.dart' show Combinator; | 7 import '../combinator.dart' show Combinator; |
| 8 | 8 |
| 9 import '../problems.dart' show internalProblem; | 9 import '../problems.dart' show internalProblem; |
| 10 | 10 |
| 11 import '../export.dart' show Export; | 11 import '../export.dart' show Export; |
| 12 | 12 |
| 13 import '../loader.dart' show Loader; | 13 import '../loader.dart' show Loader; |
| 14 | 14 |
| 15 import '../messages.dart' | 15 import '../messages.dart' |
| 16 show | 16 show |
| 17 Message, | 17 Message, |
| 18 deprecated_warning, | |
| 19 nit, | 18 nit, |
| 20 templateInternalProblemConstructorNotFound, | 19 templateInternalProblemConstructorNotFound, |
| 21 templateInternalProblemNotFoundIn, | 20 templateInternalProblemNotFoundIn, |
| 22 templateInternalProblemPrivateConstructorAccess, | 21 templateInternalProblemPrivateConstructorAccess, |
| 23 warning; | 22 warning; |
| 24 | 23 |
| 25 import '../util/relativize.dart' show relativizeUri; | 24 import '../util/relativize.dart' show relativizeUri; |
| 26 | 25 |
| 27 import 'builder.dart' | 26 import 'builder.dart' |
| 28 show | 27 show |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 67 |
| 69 Uri get uri; | 68 Uri get uri; |
| 70 | 69 |
| 71 Builder addBuilder(String name, Builder builder, int charOffset); | 70 Builder addBuilder(String name, Builder builder, int charOffset); |
| 72 | 71 |
| 73 void addExporter( | 72 void addExporter( |
| 74 LibraryBuilder exporter, List<Combinator> combinators, int charOffset) { | 73 LibraryBuilder exporter, List<Combinator> combinators, int charOffset) { |
| 75 exporters.add(new Export(exporter, this, combinators, charOffset)); | 74 exporters.add(new Export(exporter, this, combinators, charOffset)); |
| 76 } | 75 } |
| 77 | 76 |
| 78 /// See `Loader.deprecated_addCompileTimeError` for an explanation of the | 77 /// See `Loader.addCompileTimeError` for an explanation of the |
| 79 /// arguments passed to this method. | 78 /// arguments passed to this method. |
| 80 /// | 79 /// |
| 81 /// If [fileUri] is null, it defaults to `this.fileUri`. | 80 /// If [fileUri] is null, it defaults to `this.fileUri`. |
| 82 void deprecated_addCompileTimeError(int charOffset, Object message, | |
| 83 {Uri fileUri, bool silent: false, bool wasHandled: false}) { | |
| 84 hasCompileTimeErrors = true; | |
| 85 loader.deprecated_addCompileTimeError( | |
| 86 fileUri ?? this.fileUri, charOffset, message, | |
| 87 silent: silent, wasHandled: wasHandled); | |
| 88 } | |
| 89 | |
| 90 void addCompileTimeError(Message message, int charOffset, Uri uri, | 81 void addCompileTimeError(Message message, int charOffset, Uri uri, |
| 91 {bool silent: false, bool wasHandled: false}) { | 82 {bool silent: false, bool wasHandled: false}) { |
| 92 hasCompileTimeErrors = true; | 83 hasCompileTimeErrors = true; |
| 93 loader.addCompileTimeError(message, charOffset, uri, | 84 loader.addCompileTimeError(message, charOffset, uri, |
| 94 silent: silent, wasHandled: wasHandled); | 85 silent: silent, wasHandled: wasHandled); |
| 95 } | 86 } |
| 96 | 87 |
| 97 void addWarning(Message message, int charOffset, Uri uri, | 88 void addWarning(Message message, int charOffset, Uri uri, |
| 98 {bool silent: false}) { | 89 {bool silent: false}) { |
| 99 if (!silent) { | 90 if (!silent) { |
| 100 warning(message, charOffset, uri); | 91 warning(message, charOffset, uri); |
| 101 } | 92 } |
| 102 } | 93 } |
| 103 | 94 |
| 104 void addNit(Message message, int charOffset, Uri uri, {bool silent: false}) { | 95 void addNit(Message message, int charOffset, Uri uri, {bool silent: false}) { |
| 105 if (!silent) { | 96 if (!silent) { |
| 106 nit(message, charOffset, uri); | 97 nit(message, charOffset, uri); |
| 107 } | 98 } |
| 108 } | 99 } |
| 109 | 100 |
| 110 void deprecated_addWarning(int charOffset, Object message, | |
| 111 {Uri fileUri, bool silent: false}) { | |
| 112 fileUri ??= this.fileUri; | |
| 113 if (!silent) { | |
| 114 deprecated_warning(fileUri, charOffset, message); | |
| 115 } | |
| 116 } | |
| 117 | |
| 118 /// Returns true if the export scope was modified. | 101 /// Returns true if the export scope was modified. |
| 119 bool addToExportScope(String name, Builder member) { | 102 bool addToExportScope(String name, Builder member) { |
| 120 if (name.startsWith("_")) return false; | 103 if (name.startsWith("_")) return false; |
| 121 if (member is PrefixBuilder) return false; | 104 if (member is PrefixBuilder) return false; |
| 122 Map<String, Builder> map = | 105 Map<String, Builder> map = |
| 123 member.isSetter ? exports.setters : exports.local; | 106 member.isSetter ? exports.setters : exports.local; |
| 124 Builder existing = map[name]; | 107 Builder existing = map[name]; |
| 125 if (existing == member) return false; | 108 if (existing == member) return false; |
| 126 if (existing != null) { | 109 if (existing != null) { |
| 127 Builder result = | 110 Builder result = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 templateInternalProblemNotFoundIn.withArguments( | 193 templateInternalProblemNotFoundIn.withArguments( |
| 211 name, relativeFileUri), | 194 name, relativeFileUri), |
| 212 -1, | 195 -1, |
| 213 null); | 196 null); |
| 214 } | 197 } |
| 215 | 198 |
| 216 Builder lookup(String name, int charOffset, Uri fileUri) { | 199 Builder lookup(String name, int charOffset, Uri fileUri) { |
| 217 return scope.lookup(name, charOffset, fileUri); | 200 return scope.lookup(name, charOffset, fileUri); |
| 218 } | 201 } |
| 219 } | 202 } |
| OLD | NEW |