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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1370833002: Remove ElementLocator.locateWithOffset altogether. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.all_the_rest_test; 5 library engine.all_the_rest_test;
6 6
7 import 'package:analyzer/file_system/physical_file_system.dart'; 7 import 'package:analyzer/file_system/physical_file_system.dart';
8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 7037 matching lines...) Expand 10 before | Expand all | Expand 10 after
7048 7048
7049 void test_locate_VariableDeclaration() { 7049 void test_locate_VariableDeclaration() {
7050 AstNode id = _findNodeIn("x", "var x = 'abc';"); 7050 AstNode id = _findNodeIn("x", "var x = 'abc';");
7051 VariableDeclaration declaration = 7051 VariableDeclaration declaration =
7052 id.getAncestor((node) => node is VariableDeclaration); 7052 id.getAncestor((node) => node is VariableDeclaration);
7053 Element element = ElementLocator.locate(declaration); 7053 Element element = ElementLocator.locate(declaration);
7054 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement, 7054 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement,
7055 TopLevelVariableElement, element); 7055 TopLevelVariableElement, element);
7056 } 7056 }
7057 7057
7058 void test_locateWithOffset_BinaryExpression() {
7059 AstNode id = _findNodeIn("+", "var x = 3 + 4;");
7060 Element element = ElementLocator.locateWithOffset(id, 0);
7061 EngineTestCase.assertInstanceOf(
7062 (obj) => obj is MethodElement, MethodElement, element);
7063 }
7064
7065 void test_locateWithOffset_StringLiteral() {
7066 AstNode id = _findNodeIn("abc", "var x = 'abc';");
7067 Element element = ElementLocator.locateWithOffset(id, 1);
7068 expect(element, isNull);
7069 }
7070
7071 /** 7058 /**
7072 * Find the first AST node matching a pattern in the resolved AST for the give n source. 7059 * Find the first AST node matching a pattern in the resolved AST for the give n source.
7073 * 7060 *
7074 * [nodePattern] the (unique) pattern used to identify the node of interest. 7061 * [nodePattern] the (unique) pattern used to identify the node of interest.
7075 * [code] the code to resolve. 7062 * [code] the code to resolve.
7076 * Returns the matched node in the resolved AST for the given source lines. 7063 * Returns the matched node in the resolved AST for the given source lines.
7077 */ 7064 */
7078 AstNode _findNodeIn(String nodePattern, String code) { 7065 AstNode _findNodeIn(String nodePattern, String code) {
7079 return _findNodeIndexedIn(nodePattern, 0, code); 7066 return _findNodeIndexedIn(nodePattern, 0, code);
7080 } 7067 }
(...skipping 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after
9326 if (_expectedExternalScriptName == null) { 9313 if (_expectedExternalScriptName == null) {
9327 expect(scriptSource, isNull, reason: "script $scriptIndex"); 9314 expect(scriptSource, isNull, reason: "script $scriptIndex");
9328 } else { 9315 } else {
9329 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9316 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9330 String actualExternalScriptName = scriptSource.shortName; 9317 String actualExternalScriptName = scriptSource.shortName;
9331 expect(actualExternalScriptName, _expectedExternalScriptName, 9318 expect(actualExternalScriptName, _expectedExternalScriptName,
9332 reason: "script $scriptIndex"); 9319 reason: "script $scriptIndex");
9333 } 9320 }
9334 } 9321 }
9335 } 9322 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698