mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Remove InstrumentationInformation.nodeInformation and related code.
Data was being stored in this field but never read. Change-Id: Ida763236b71401ba8ddd0ec5bf4880e7cc657d6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204281 Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
a093bbcde5
commit
0ab30d074d
2 changed files with 6 additions and 68 deletions
|
@ -20,20 +20,12 @@ class InstrumentationInformation {
|
|||
/// The node used for type sources that are never `null`.
|
||||
NullabilityNodeInfo never;
|
||||
|
||||
/// A map associating [NodeInformation] with [NullabilityNodeInfo] objects.
|
||||
Map<NullabilityNodeInfo, NodeInformation> nodeInformation = {};
|
||||
|
||||
/// The instrumentation information that is specific to a single source.
|
||||
final Map<Source, SourceInformation> sourceInformation = {};
|
||||
|
||||
/// Initialize a newly created holder of instrumentation information.
|
||||
InstrumentationInformation();
|
||||
|
||||
/// Return information about the given [node].
|
||||
NodeInformation nodeInfoFor(NullabilityNodeInfo node) {
|
||||
return nodeInformation[node];
|
||||
}
|
||||
|
||||
/// Return the type annotation associated with the [node] or `null` if the
|
||||
/// node represents an implicit type.
|
||||
TypeAnnotation typeAnnotationForNode(NullabilityNodeInfo node) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:nnbd_migration/instrumentation.dart';
|
||||
import 'package:nnbd_migration/src/edit_plan.dart';
|
||||
|
@ -32,22 +31,16 @@ class InstrumentationListener implements NullabilityMigrationInstrumentation {
|
|||
@override
|
||||
void explicitTypeNullability(
|
||||
Source source, TypeAnnotation typeAnnotation, NullabilityNodeInfo node) {
|
||||
data.nodeInformation[node] =
|
||||
NodeInformation(_filePathForSource(source), typeAnnotation, null);
|
||||
_sourceInfo(source).explicitTypeNullability[typeAnnotation] = node;
|
||||
}
|
||||
|
||||
@override
|
||||
void externalDecoratedType(Element element, DecoratedTypeInfo decoratedType) {
|
||||
_storeNodeInformation(decoratedType, element.source, null, element);
|
||||
}
|
||||
void externalDecoratedType(
|
||||
Element element, DecoratedTypeInfo decoratedType) {}
|
||||
|
||||
@override
|
||||
void externalDecoratedTypeParameterBound(
|
||||
TypeParameterElement typeParameter, DecoratedTypeInfo decoratedType) {
|
||||
_storeNodeInformation(
|
||||
decoratedType, typeParameter.source, null, typeParameter);
|
||||
}
|
||||
TypeParameterElement typeParameter, DecoratedTypeInfo decoratedType) {}
|
||||
|
||||
@override
|
||||
void finished() {
|
||||
|
@ -67,23 +60,15 @@ class InstrumentationListener implements NullabilityMigrationInstrumentation {
|
|||
|
||||
@override
|
||||
void implicitReturnType(
|
||||
Source source, AstNode node, DecoratedTypeInfo decoratedReturnType) {
|
||||
_storeNodeInformation(decoratedReturnType, source, node, null);
|
||||
}
|
||||
Source source, AstNode node, DecoratedTypeInfo decoratedReturnType) {}
|
||||
|
||||
@override
|
||||
void implicitType(
|
||||
Source source, AstNode node, DecoratedTypeInfo decoratedType) {
|
||||
_storeNodeInformation(decoratedType, source, node, null);
|
||||
}
|
||||
Source source, AstNode node, DecoratedTypeInfo decoratedType) {}
|
||||
|
||||
@override
|
||||
void implicitTypeArguments(
|
||||
Source source, AstNode node, Iterable<DecoratedTypeInfo> types) {
|
||||
for (var type in types) {
|
||||
_storeNodeInformation(type, source, node, null);
|
||||
}
|
||||
}
|
||||
Source source, AstNode node, Iterable<DecoratedTypeInfo> types) {}
|
||||
|
||||
@override
|
||||
void prepareForUpdate() {
|
||||
|
@ -92,47 +77,8 @@ class InstrumentationListener implements NullabilityMigrationInstrumentation {
|
|||
}
|
||||
}
|
||||
|
||||
String _filePathForSource(Source source) {
|
||||
return source.fullName;
|
||||
}
|
||||
|
||||
/// Return the source information associated with the given [source], creating
|
||||
/// it if there has been no previous information for that source.
|
||||
SourceInformation _sourceInfo(Source source) =>
|
||||
data.sourceInformation.putIfAbsent(source, () => SourceInformation());
|
||||
|
||||
// TODO(srawlins): This code is completely untested.
|
||||
void _storeNodeInformation(DecoratedTypeInfo decoratedType, Source source,
|
||||
AstNode astNode, Element element) {
|
||||
// Make sure source info exists for the given source.
|
||||
_sourceInfo(source);
|
||||
data.nodeInformation[decoratedType.node] =
|
||||
NodeInformation(_filePathForSource(source), astNode, element);
|
||||
var dartType = decoratedType.type;
|
||||
if (dartType is InterfaceType) {
|
||||
for (var i = 0; i < dartType.typeArguments.length; i++) {
|
||||
_storeNodeInformation(
|
||||
decoratedType.typeArgument(i), source, astNode, element);
|
||||
}
|
||||
} else if (dartType is FunctionType) {
|
||||
_storeNodeInformation(
|
||||
decoratedType.returnType,
|
||||
source,
|
||||
astNode,
|
||||
element,
|
||||
);
|
||||
var i = 0;
|
||||
for (var parameter in dartType.parameters) {
|
||||
if (parameter.isNamed) {
|
||||
var name = parameter.name;
|
||||
_storeNodeInformation(
|
||||
decoratedType.namedParameter(name), source, astNode, element);
|
||||
} else {
|
||||
_storeNodeInformation(
|
||||
decoratedType.positionalParameter(i), source, astNode, element);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue