Skip to content

Commit

Permalink
[element model] migrate scope_test (fix scope.get2)
Browse files Browse the repository at this point in the history
Change-Id: I0fdc5dac753ea452dfd0d7b4c8c310929233fd8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405442
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Jan 23, 2025
1 parent f7f17cf commit 4c50e5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/resolver/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class PrefixedNamespace implements Namespace {
}

@override
Element2? get2(String name) => Namespace._convert(_definedNames[name]);
Element2? get2(String name) => Namespace._convert(get(name));

@override
Element? getPrefixed(String prefix, String name) {
Expand Down
12 changes: 5 additions & 7 deletions pkg/analyzer/test/src/dart/resolution/scope_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: analyzer_use_new_elements

import 'package:analyzer/src/dart/resolver/scope.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:test/test.dart';
Expand All @@ -25,24 +23,24 @@ import 'dart:math' as prefix;
''', [
error(WarningCode.UNUSED_IMPORT, 7, 11),
]);
var namespace = findElement.import('dart:math').namespace;
var namespace = findElement2.import('dart:math').namespace;
return namespace as PrefixedNamespace;
}

void test_lookup_missing() async {
var namespace = await _dartMath;
expect(namespace.get('prefix.Missing'), isNull);
expect(namespace.get2('prefix.Missing'), isNull);
}

Future<void> test_lookup_missing_matchesPrefix() async {
var namespace = await _dartMath;
expect(namespace.get('prefix'), isNull);
expect(namespace.get2('prefix'), isNull);
}

Future<void> test_lookup_valid() async {
var namespace = await _dartMath;

var random = findElement.importFind('dart:math').class_('Random');
expect(namespace.get('prefix.Random'), same(random));
var random = findElement2.importFind('dart:math').class_('Random');
expect(namespace.get2('prefix.Random'), same(random));
}
}

0 comments on commit 4c50e5e

Please sign in to comment.