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

Side by Side Diff: pkg/front_end/lib/src/fasta/builder/builder.dart

Issue 2691523002: Ensure locations are always provided, but don't store them yet. (Closed)
Patch Set: Address comments. 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 fasta.builder; 5 library fasta.builder;
6 6
7 import '../errors.dart' show 7 import '../errors.dart' show
8 internalError; 8 internalError;
9 9
10 export 'class_builder.dart' show 10 export 'class_builder.dart' show
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 LibraryBuilder; 80 LibraryBuilder;
81 81
82 abstract class Builder { 82 abstract class Builder {
83 /// Used when multiple things with the same name are declared within the same 83 /// Used when multiple things with the same name are declared within the same
84 /// parent. Only used for declarations, not for scopes. 84 /// parent. Only used for declarations, not for scopes.
85 /// 85 ///
86 // TODO(ahe): Move to member builder or something. Then we can make 86 // TODO(ahe): Move to member builder or something. Then we can make
87 // this a const class. 87 // this a const class.
88 Builder next; 88 Builder next;
89 89
90 /// The values of [parent], [charOffset], and [fileUri] aren't stored. We
91 /// need to evaluate the memory impact of doing so, but want to ensure the
92 /// information is always provided.
93 Builder(Builder parent, int charOffset, Uri fileUri);
94
95 int get charOffset => -1;
96
97 Uri get fileUri => null;
98
90 /// Resolve types (lookup names in scope) recorded in this builder and return 99 /// Resolve types (lookup names in scope) recorded in this builder and return
91 /// the number of types resolved. 100 /// the number of types resolved.
92 int resolveTypes(Builder parent) => 0; 101 int resolveTypes(Builder parent) => 0;
93 102
94 /// Resolve constructors (lookup names in scope) recorded in this builder and 103 /// Resolve constructors (lookup names in scope) recorded in this builder and
95 /// return the number of constructors resolved. 104 /// return the number of constructors resolved.
96 int resolveConstructors(Builder parent) => 0; 105 int resolveConstructors(Builder parent) => 0;
97 106
98 /// Look for methods with the same name as their enclosing class and convert 107 /// Look for methods with the same name as their enclosing class and convert
99 /// them to constructors. Return the number of methods converted to 108 /// them to constructors. Return the number of methods converted to
(...skipping 18 matching lines...) Expand all
118 getUri(this)?.scheme != "dart") { 127 getUri(this)?.scheme != "dart") {
119 preferred = this; 128 preferred = this;
120 hidden = other; 129 hidden = other;
121 } else if (getUri(this)?.scheme == "dart" && 130 } else if (getUri(this)?.scheme == "dart" &&
122 getUri(other)?.scheme != "dart") { 131 getUri(other)?.scheme != "dart") {
123 preferred = other; 132 preferred = other;
124 hidden = this; 133 hidden = this;
125 } else { 134 } else {
126 print("${library.uri}: Note: '$name' is imported from both " 135 print("${library.uri}: Note: '$name' is imported from both "
127 "'${getUri(this)}' and '${getUri(other)}'."); 136 "'${getUri(this)}' and '${getUri(other)}'.");
128 return library.buildAmbiguousBuilder(name, this, other); 137 return library.buildAmbiguousBuilder(name, this, other, charOffset);
129 } 138 }
130 if (isLocal) { 139 if (isLocal) {
131 print("${library.uri}: Note: local definition of '$name' hides imported " 140 print("${library.uri}: Note: local definition of '$name' hides imported "
132 "version from '${getUri(other)}'."); 141 "version from '${getUri(other)}'.");
133 } else { 142 } else {
134 print("${library.uri}: import of '$name' (from '${getUri(preferred)}') " 143 print("${library.uri}: import of '$name' (from '${getUri(preferred)}') "
135 "hides imported version from '${getUri(hidden)}'."); 144 "hides imported version from '${getUri(hidden)}'.");
136 } 145 }
137 return preferred; 146 return preferred;
138 } 147 }
(...skipping 30 matching lines...) Expand all
169 178
170 static Uri getUri(Builder builder) { 179 static Uri getUri(Builder builder) {
171 if (builder == null) return internalError("Builder is null."); 180 if (builder == null) return internalError("Builder is null.");
172 while (builder != null) { 181 while (builder != null) {
173 if (builder is LibraryBuilder) return builder.uri; 182 if (builder is LibraryBuilder) return builder.uri;
174 builder = builder.parent; 183 builder = builder.parent;
175 } 184 }
176 return internalError("No library parent."); 185 return internalError("No library parent.");
177 } 186 }
178 } 187 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/analyzer/mock_element.dart ('k') | pkg/front_end/lib/src/fasta/builder/class_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698