Skip to content

Commit e359106

Browse files
authored
[record_use] Remove source locations (dart-lang#3043)
This PR completely removes source location tracking (URI, line, column) from the `record_use` package. This type of debug information should not be needed for errors from a link hook if the APIs annotated with `@RecordUse()` are already annotated with `@mustBeConst`. Closes: dart-lang#3023
1 parent 4003fc3 commit e359106

41 files changed

Lines changed: 59 additions & 689 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎pkgs/hooks_runner/test/build_runner/resources_test.dart‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,11 @@ final _pirateAdventureRecordings = Recordings(
129129
): [
130130
const CallWithArguments(
131131
loadingUnit: 'root',
132-
location: Location(
133-
uri: 'package:pirate_adventure/bin/pirate_adventure.dart',
134-
line: 10,
135-
column: 5,
136-
),
137132
positionalArguments: [StringConstant('Hello')],
138133
namedArguments: {},
139134
),
140135
const CallWithArguments(
141136
loadingUnit: 'root',
142-
location: Location(
143-
uri: 'package:pirate_adventure/bin/pirate_adventure.dart',
144-
line: 11,
145-
column: 5,
146-
),
147137
positionalArguments: [StringConstant('Money')],
148138
namedArguments: {},
149139
),
@@ -156,11 +146,6 @@ final _pirateAdventureRecordings = Recordings(
156146
): [
157147
const CallWithArguments(
158148
loadingUnit: 'root',
159-
location: Location(
160-
uri: 'package:pirate_adventure/bin/pirate_adventure.dart',
161-
line: 20,
162-
column: 5,
163-
),
164149
positionalArguments: [],
165150
namedArguments: {},
166151
),

‎pkgs/record_use/CHANGELOG.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## 0.5.0-wip
22

3-
- Made locations optional to accomodate for dart2js compiler not providing
4-
source locations for constant instances.
5-
- Introduce a JSON schema for the json encoding.
3+
- Completely overhauled the JSON format.
64

75
## 0.4.2
86

‎pkgs/record_use/doc/schema/record_use.schema.json‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
}
2020
]
2121
},
22-
"@": {
23-
"type": "integer"
24-
},
2522
"loading_unit": {
2623
"type": "string"
2724
}
@@ -238,9 +235,6 @@
238235
"Instance": {
239236
"type": "object",
240237
"properties": {
241-
"@": {
242-
"type": "integer"
243-
},
244238
"constant_index": {
245239
"type": "integer"
246240
},
@@ -253,23 +247,6 @@
253247
"loading_unit"
254248
]
255249
},
256-
"Location": {
257-
"type": "object",
258-
"properties": {
259-
"column": {
260-
"type": "integer"
261-
},
262-
"line": {
263-
"type": "integer"
264-
},
265-
"uri": {
266-
"type": "string"
267-
}
268-
},
269-
"required": [
270-
"uri"
271-
]
272-
},
273250
"MapEntry": {
274251
"type": "object",
275252
"properties": {
@@ -294,12 +271,6 @@
294271
"$ref": "#/definitions/Constant"
295272
}
296273
},
297-
"locations": {
298-
"type": "array",
299-
"items": {
300-
"$ref": "#/definitions/Location"
301-
}
302-
},
303274
"metadata": {
304275
"type": "object",
305276
"properties": {

‎pkgs/record_use/lib/record_use_internal.dart‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export 'src/constant.dart'
1515
StringConstant;
1616
export 'src/definition.dart' show Definition;
1717
export 'src/identifier.dart' show Identifier;
18-
export 'src/location.dart' show Location;
1918
export 'src/metadata.dart' show Metadata;
2019
export 'src/record_use.dart' show RecordedUsages;
2120
export 'src/recordings.dart'

‎pkgs/record_use/lib/src/location.dart‎

Lines changed: 0 additions & 70 deletions
This file was deleted.

‎pkgs/record_use/lib/src/recordings.dart‎

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'constant.dart';
1111
import 'definition.dart';
1212
import 'helper.dart';
1313
import 'identifier.dart';
14-
import 'location.dart';
1514
import 'metadata.dart';
1615
import 'reference.dart';
1716
import 'syntax.g.dart';
@@ -24,7 +23,7 @@ import 'syntax.g.dart';
2423
/// core data, associating each [Definition] with its corresponding [Reference]
2524
/// details.
2625
///
27-
/// The class uses a normalized JSON format, allowing the reuse of locations and
26+
/// The class uses a normalized JSON format, allowing the reuse of
2827
/// constants across multiple recordings to optimize storage.
2928
class Recordings {
3029
/// [Metadata] such as the recording protocol version.
@@ -77,14 +76,6 @@ Error: $e
7776
}
7877
}
7978

80-
final locations = <Location>[];
81-
for (final locationSyntax in syntax.locations ?? <LocationSyntax>[]) {
82-
final location = LocationProtected.fromSyntax(locationSyntax);
83-
if (!locations.contains(location)) {
84-
locations.add(location);
85-
}
86-
}
87-
8879
final callsForDefinition = <Definition, List<CallReference>>{};
8980
final instancesForDefinition = <Definition, List<InstanceReference>>{};
9081

@@ -98,7 +89,6 @@ Error: $e
9889
(callSyntax) => CallReferenceProtected.fromSyntax(
9990
callSyntax,
10091
constants,
101-
locations,
10292
),
10393
)
10494
.toList();
@@ -110,7 +100,6 @@ Error: $e
110100
(instanceSyntax) => InstanceReferenceProtected.fromSyntax(
111101
instanceSyntax,
112102
constants,
113-
locations,
114103
),
115104
)
116105
.toList();
@@ -152,25 +141,14 @@ Error: $e
152141
),
153142
}.flatten().asMapToIndices;
154143

155-
final locationsIndex = {
156-
...callsForDefinition.values
157-
.expand((calls) => calls)
158-
.map((call) => call.location)
159-
.nonNulls,
160-
...instancesForDefinition.values
161-
.expand((instances) => instances)
162-
.map((instance) => instance.location)
163-
.nonNulls,
164-
}.asMapToIndices;
165-
166144
final recordings = <RecordingSyntax>[];
167145
if (callsForDefinition.isNotEmpty) {
168146
recordings.addAll(
169147
callsForDefinition.entries.map(
170148
(entry) => RecordingSyntax(
171149
definition: entry.key.toSyntax(),
172150
calls: entry.value
173-
.map((call) => call.toSyntax(constantsIndex, locationsIndex))
151+
.map((call) => call.toSyntax(constantsIndex))
174152
.toList(),
175153
),
176154
),
@@ -183,8 +161,7 @@ Error: $e
183161
definition: entry.key.toSyntax(),
184162
instances: entry.value
185163
.map(
186-
(instance) =>
187-
instance.toSyntax(constantsIndex, locationsIndex),
164+
(instance) => instance.toSyntax(constantsIndex),
188165
)
189166
.toList(),
190167
),
@@ -199,9 +176,6 @@ Error: $e
199176
: constantsIndex.keys
200177
.map((constant) => constant.toSyntax(constantsIndex))
201178
.toList(),
202-
locations: locationsIndex.isEmpty
203-
? null
204-
: locationsIndex.keys.map((location) => location.toSyntax()).toList(),
205179
recordings: recordings.isEmpty ? null : recordings,
206180
);
207181
}
@@ -247,10 +221,6 @@ Error: $e
247221
/// If [allowTearOffToStaticPromotion] is `true`, allows an [expected]
248222
/// function tear-off to match an `actual` static call.
249223
///
250-
/// If [allowLocationNull] is `true`, having a `null` in one and a column and
251-
/// line number in the other is considered semantically equal. Useful for if
252-
/// one compiler does not provide source locations but the other does.
253-
///
254224
/// If [allowDefinitionLoadingUnitNull] is `true`, allows a definition's
255225
/// loading unit to be `null` in one set but not the other. This handles
256226
/// cases where a compiler might not emit loading unit information for all
@@ -268,7 +238,6 @@ Error: $e
268238
bool expectedIsSubset = false,
269239
bool allowDeadCodeElimination = false,
270240
bool allowTearOffToStaticPromotion = false,
271-
bool allowLocationNull = false,
272241
bool allowDefinitionLoadingUnitNull = false,
273242
bool allowMoreConstArguments = false,
274243
bool allowMetadataMismatch = false,
@@ -296,7 +265,6 @@ Error: $e
296265
referenceMatches: (CallReference a, CallReference b) => a.semanticEquals(
297266
b,
298267
allowTearOffToStaticPromotion: allowTearOffToStaticPromotion,
299-
allowLocationNull: allowLocationNull,
300268
allowMoreConstArguments: allowMoreConstArguments,
301269
uriMapping: uriMapping,
302270
loadingUnitMapping: loadingUnitMapping,
@@ -315,7 +283,6 @@ Error: $e
315283
// ignore: invalid_use_of_visible_for_testing_member
316284
a.semanticEquals(
317285
b,
318-
allowLocationNull: allowLocationNull,
319286
uriMapping: uriMapping,
320287
loadingUnitMapping: loadingUnitMapping,
321288
),

0 commit comments

Comments
 (0)