| OLD | NEW |
| 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 6950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6961 CompilationUnit cu = _resolveContents(code); | 6961 CompilationUnit cu = _resolveContents(code); |
| 6962 int offset = code.indexOf('foo(0)'); | 6962 int offset = code.indexOf('foo(0)'); |
| 6963 AstNode node = new NodeLocator(offset).searchWithin(cu); | 6963 AstNode node = new NodeLocator(offset).searchWithin(cu); |
| 6964 MethodInvocation invocation = | 6964 MethodInvocation invocation = |
| 6965 node.getAncestor((n) => n is MethodInvocation); | 6965 node.getAncestor((n) => n is MethodInvocation); |
| 6966 Element element = ElementLocator.locate(invocation); | 6966 Element element = ElementLocator.locate(invocation); |
| 6967 EngineTestCase.assertInstanceOf( | 6967 EngineTestCase.assertInstanceOf( |
| 6968 (obj) => obj is FunctionElement, FunctionElement, element); | 6968 (obj) => obj is FunctionElement, FunctionElement, element); |
| 6969 } | 6969 } |
| 6970 | 6970 |
| 6971 void test_locate_PartOfDirective() { |
| 6972 Source librarySource = addNamedSource( |
| 6973 '/lib.dart', |
| 6974 ''' |
| 6975 library my.lib; |
| 6976 part 'part.dart'; |
| 6977 '''); |
| 6978 Source unitSource = addNamedSource( |
| 6979 '/part.dart', |
| 6980 ''' |
| 6981 part of my.lib; |
| 6982 '''); |
| 6983 CompilationUnit unit = |
| 6984 analysisContext.resolveCompilationUnit2(unitSource, librarySource); |
| 6985 PartOfDirective partOf = unit.directives.first; |
| 6986 Element element = ElementLocator.locate(partOf); |
| 6987 EngineTestCase.assertInstanceOf( |
| 6988 (obj) => obj is LibraryElement, LibraryElement, element); |
| 6989 } |
| 6990 |
| 6971 void test_locate_PostfixExpression() { | 6991 void test_locate_PostfixExpression() { |
| 6972 AstNode id = _findNodeIn("++", "int addOne(int x) => x++;"); | 6992 AstNode id = _findNodeIn("++", "int addOne(int x) => x++;"); |
| 6973 Element element = ElementLocator.locate(id); | 6993 Element element = ElementLocator.locate(id); |
| 6974 EngineTestCase.assertInstanceOf( | 6994 EngineTestCase.assertInstanceOf( |
| 6975 (obj) => obj is MethodElement, MethodElement, element); | 6995 (obj) => obj is MethodElement, MethodElement, element); |
| 6976 } | 6996 } |
| 6977 | 6997 |
| 6978 void test_locate_PrefixedIdentifier() { | 6998 void test_locate_PrefixedIdentifier() { |
| 6979 AstNode id = _findNodeIn( | 6999 AstNode id = _findNodeIn( |
| 6980 "int", | 7000 "int", |
| (...skipping 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9306 if (_expectedExternalScriptName == null) { | 9326 if (_expectedExternalScriptName == null) { |
| 9307 expect(scriptSource, isNull, reason: "script $scriptIndex"); | 9327 expect(scriptSource, isNull, reason: "script $scriptIndex"); |
| 9308 } else { | 9328 } else { |
| 9309 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); | 9329 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); |
| 9310 String actualExternalScriptName = scriptSource.shortName; | 9330 String actualExternalScriptName = scriptSource.shortName; |
| 9311 expect(actualExternalScriptName, _expectedExternalScriptName, | 9331 expect(actualExternalScriptName, _expectedExternalScriptName, |
| 9312 reason: "script $scriptIndex"); | 9332 reason: "script $scriptIndex"); |
| 9313 } | 9333 } |
| 9314 } | 9334 } |
| 9315 } | 9335 } |
| OLD | NEW |