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

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

Issue 2974933002: Remove deprecated_internalProblem. (Closed)
Patch Set: Created 3 years, 5 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.scope; 5 library fasta.scope;
6 6
7 import 'builder/builder.dart' show Builder, TypeVariableBuilder; 7 import 'builder/builder.dart' show Builder, TypeVariableBuilder;
8 8
9 import 'deprecated_problems.dart' 9 import 'deprecated_problems.dart' show deprecated_InputError;
10 show deprecated_InputError, deprecated_internalProblem; 10
11 import 'problems.dart' show internalProblem, unsupported;
12
13 import 'fasta_codes.dart' show messageInternalProblemExtendingUnmodifiableScope;
11 14
12 class MutableScope { 15 class MutableScope {
13 /// Names declared in this scope. 16 /// Names declared in this scope.
14 Map<String, Builder> local; 17 Map<String, Builder> local;
15 18
16 /// Setters declared in this scope. 19 /// Setters declared in this scope.
17 Map<String, Builder> setters; 20 Map<String, Builder> setters;
18 21
19 /// The scope that this scope is nested within, or `null` if this is the top 22 /// The scope that this scope is nested within, or `null` if this is the top
20 /// level scope. 23 /// level scope.
(...skipping 22 matching lines...) Expand all
43 isModifiable: isModifiable); 46 isModifiable: isModifiable);
44 47
45 Scope.immutable() 48 Scope.immutable()
46 : this(const <String, Builder>{}, const <String, Builder>{}, null, 49 : this(const <String, Builder>{}, const <String, Builder>{}, null,
47 isModifiable: false); 50 isModifiable: false);
48 51
49 Scope.nested(Scope parent, {bool isModifiable: true}) 52 Scope.nested(Scope parent, {bool isModifiable: true})
50 : this(<String, Builder>{}, null, parent, isModifiable: isModifiable); 53 : this(<String, Builder>{}, null, parent, isModifiable: isModifiable);
51 54
52 /// Don't use this. Use [becomePartOf] instead. 55 /// Don't use this. Use [becomePartOf] instead.
53 void set local(_) => deprecated_internalProblem("Unsupported operation."); 56 void set local(_) => unsupported("local=", -1, null);
54 57
55 /// Don't use this. Use [becomePartOf] instead. 58 /// Don't use this. Use [becomePartOf] instead.
56 void set setters(_) => deprecated_internalProblem("Unsupported operation."); 59 void set setters(_) => unsupported("setters=", -1, null);
57 60
58 /// Don't use this. Use [becomePartOf] instead. 61 /// Don't use this. Use [becomePartOf] instead.
59 void set parent(_) => deprecated_internalProblem("Unsupported operation."); 62 void set parent(_) => unsupported("parent=", -1, null);
60 63
61 /// This scope becomes equivalent to [scope]. This is used for parts to 64 /// This scope becomes equivalent to [scope]. This is used for parts to
62 /// become part of their library's scope. 65 /// become part of their library's scope.
63 void becomePartOf(Scope scope) { 66 void becomePartOf(Scope scope) {
64 assert(parent.parent == null); 67 assert(parent.parent == null);
65 assert(scope.parent.parent == null); 68 assert(scope.parent.parent == null);
66 super.local = scope.local; 69 super.local = scope.local;
67 super.setters = scope.setters; 70 super.setters = scope.setters;
68 super.parent = scope.parent; 71 super.parent = scope.parent;
69 } 72 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 116 }
114 117
115 Builder lookup(String name, int charOffset, Uri fileUri, 118 Builder lookup(String name, int charOffset, Uri fileUri,
116 {bool isInstanceScope: true}) { 119 {bool isInstanceScope: true}) {
117 recordUse(name, charOffset, fileUri); 120 recordUse(name, charOffset, fileUri);
118 Builder builder = 121 Builder builder =
119 lookupIn(name, charOffset, fileUri, local, isInstanceScope); 122 lookupIn(name, charOffset, fileUri, local, isInstanceScope);
120 if (builder != null) return builder; 123 if (builder != null) return builder;
121 builder = lookupIn(name, charOffset, fileUri, setters, isInstanceScope); 124 builder = lookupIn(name, charOffset, fileUri, setters, isInstanceScope);
122 if (builder != null && !builder.hasProblem) { 125 if (builder != null && !builder.hasProblem) {
123 return new deprecated_AccessErrorBuilder( 126 return new AccessErrorBuilder(name, builder, charOffset, fileUri);
124 name, builder, charOffset, fileUri);
125 } 127 }
126 if (!isInstanceScope) { 128 if (!isInstanceScope) {
127 // For static lookup, do not seach the parent scope. 129 // For static lookup, do not seach the parent scope.
128 return builder; 130 return builder;
129 } 131 }
130 return builder ?? parent?.lookup(name, charOffset, fileUri); 132 return builder ?? parent?.lookup(name, charOffset, fileUri);
131 } 133 }
132 134
133 Builder lookupSetter(String name, int charOffset, Uri fileUri, 135 Builder lookupSetter(String name, int charOffset, Uri fileUri,
134 {bool isInstanceScope: true}) { 136 {bool isInstanceScope: true}) {
135 recordUse(name, charOffset, fileUri); 137 recordUse(name, charOffset, fileUri);
136 Builder builder = 138 Builder builder =
137 lookupIn(name, charOffset, fileUri, setters, isInstanceScope); 139 lookupIn(name, charOffset, fileUri, setters, isInstanceScope);
138 if (builder != null) return builder; 140 if (builder != null) return builder;
139 builder = lookupIn(name, charOffset, fileUri, local, isInstanceScope); 141 builder = lookupIn(name, charOffset, fileUri, local, isInstanceScope);
140 if (builder != null && !builder.hasProblem) { 142 if (builder != null && !builder.hasProblem) {
141 return new deprecated_AccessErrorBuilder( 143 return new AccessErrorBuilder(name, builder, charOffset, fileUri);
142 name, builder, charOffset, fileUri);
143 } 144 }
144 if (!isInstanceScope) { 145 if (!isInstanceScope) {
145 // For static lookup, do not seach the parent scope. 146 // For static lookup, do not seach the parent scope.
146 return builder; 147 return builder;
147 } 148 }
148 return builder ?? parent?.lookupSetter(name, charOffset, fileUri); 149 return builder ?? parent?.lookupSetter(name, charOffset, fileUri);
149 } 150 }
150 151
151 bool hasLocalLabel(String name) => labels != null && labels.containsKey(name); 152 bool hasLocalLabel(String name) => labels != null && labels.containsKey(name);
152 153
153 void declareLabel(String name, Builder target) { 154 void declareLabel(String name, Builder target) {
154 if (isModifiable) { 155 if (isModifiable) {
155 labels ??= <String, Builder>{}; 156 labels ??= <String, Builder>{};
156 labels[name] = target; 157 labels[name] = target;
157 } else { 158 } else {
158 deprecated_internalProblem("Can't extend an unmodifiable scope."); 159 internalProblem(
160 messageInternalProblemExtendingUnmodifiableScope, -1, null);
159 } 161 }
160 } 162 }
161 163
162 void forwardDeclareLabel(String name, Builder target) { 164 void forwardDeclareLabel(String name, Builder target) {
163 declareLabel(name, target); 165 declareLabel(name, target);
164 forwardDeclaredLabels ??= <String, Builder>{}; 166 forwardDeclaredLabels ??= <String, Builder>{};
165 forwardDeclaredLabels[name] = target; 167 forwardDeclaredLabels[name] = target;
166 } 168 }
167 169
168 void claimLabel(String name) { 170 void claimLabel(String name) {
(...skipping 20 matching lines...) Expand all
189 deprecated_InputError declare( 191 deprecated_InputError declare(
190 String name, Builder builder, int charOffset, Uri fileUri) { 192 String name, Builder builder, int charOffset, Uri fileUri) {
191 if (isModifiable) { 193 if (isModifiable) {
192 if (usedNames?.containsKey(name) ?? false) { 194 if (usedNames?.containsKey(name) ?? false) {
193 return new deprecated_InputError( 195 return new deprecated_InputError(
194 fileUri, usedNames[name], "Previous use of '$name'."); 196 fileUri, usedNames[name], "Previous use of '$name'.");
195 } 197 }
196 recordUse(name, charOffset, fileUri); 198 recordUse(name, charOffset, fileUri);
197 local[name] = builder; 199 local[name] = builder;
198 } else { 200 } else {
199 deprecated_internalProblem("Can't extend an unmodifiable scope."); 201 internalProblem(
202 messageInternalProblemExtendingUnmodifiableScope, -1, null);
200 } 203 }
201 return null; 204 return null;
202 } 205 }
203 206
204 void merge(Scope scope, 207 void merge(Scope scope,
205 buildAmbiguousBuilder(String name, Builder existing, Builder member)) { 208 buildAmbiguousBuilder(String name, Builder existing, Builder member)) {
206 Map<String, Builder> map = local; 209 Map<String, Builder> map = local;
207 210
208 void mergeMember(String name, Builder member) { 211 void mergeMember(String name, Builder member) {
209 Builder existing = map[name]; 212 Builder existing = map[name];
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 bool get hasProblem => true; 280 bool get hasProblem => true;
278 281
279 String get deprecated_message; 282 String get deprecated_message;
280 283
281 @override 284 @override
282 String get fullNameForErrors => name; 285 String get fullNameForErrors => name;
283 } 286 }
284 287
285 /// Represents a [builder] that's being accessed incorrectly. For example, an 288 /// Represents a [builder] that's being accessed incorrectly. For example, an
286 /// attempt to write to a final field, or to read from a setter. 289 /// attempt to write to a final field, or to read from a setter.
287 class deprecated_AccessErrorBuilder extends ProblemBuilder { 290 class AccessErrorBuilder extends ProblemBuilder {
288 deprecated_AccessErrorBuilder( 291 AccessErrorBuilder(String name, Builder builder, int charOffset, Uri fileUri)
289 String name, Builder builder, int charOffset, Uri fileUri)
290 : super(name, builder, charOffset, fileUri); 292 : super(name, builder, charOffset, fileUri);
291 293
292 Builder get parent => builder; 294 Builder get parent => builder;
293 295
294 bool get isFinal => builder.isFinal; 296 bool get isFinal => builder.isFinal;
295 297
296 bool get isField => builder.isField; 298 bool get isField => builder.isField;
297 299
298 bool get isRegularMethod => builder.isRegularMethod; 300 bool get isRegularMethod => builder.isRegularMethod;
299 301
(...skipping 13 matching lines...) Expand all
313 315
314 String get deprecated_message => "Access error: '$name'."; 316 String get deprecated_message => "Access error: '$name'.";
315 } 317 }
316 318
317 class AmbiguousBuilder extends ProblemBuilder { 319 class AmbiguousBuilder extends ProblemBuilder {
318 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri) 320 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri)
319 : super(name, builder, charOffset, fileUri); 321 : super(name, builder, charOffset, fileUri);
320 322
321 String get deprecated_message => "Duplicated named: '$name'."; 323 String get deprecated_message => "Duplicated named: '$name'.";
322 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698