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.resolver_test; | 5 library engine.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/context/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 5913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5924 expect(unit, isNotNull); | 5924 expect(unit, isNotNull); |
5925 expect(unit.name, "lib.dart"); | 5925 expect(unit.name, "lib.dart"); |
5926 expect(unit.library, element); | 5926 expect(unit.library, element); |
5927 expect(unit.accessors, hasLength(0)); | 5927 expect(unit.accessors, hasLength(0)); |
5928 expect(unit.functions, hasLength(0)); | 5928 expect(unit.functions, hasLength(0)); |
5929 expect(unit.functionTypeAliases, hasLength(0)); | 5929 expect(unit.functionTypeAliases, hasLength(0)); |
5930 expect(unit.types, hasLength(0)); | 5930 expect(unit.types, hasLength(0)); |
5931 expect(unit.topLevelVariables, hasLength(0)); | 5931 expect(unit.topLevelVariables, hasLength(0)); |
5932 } | 5932 } |
5933 | 5933 |
| 5934 void test_libraryElement_docRange() { |
| 5935 String code = r''' |
| 5936 /// My dart doc. |
| 5937 library lib; |
| 5938 |
| 5939 class A {}'''; |
| 5940 Source librarySource = addSource("/lib.dart", code); |
| 5941 LibraryElement element = _buildLibrary(librarySource); |
| 5942 expect(element, isNotNull); |
| 5943 SourceRange docRange = element.docRange; |
| 5944 expect(docRange, isNotNull); |
| 5945 expect(docRange.offset, code.indexOf('/// My dart doc.')); |
| 5946 expect(docRange.length, '/// My dart doc.'.length); |
| 5947 } |
| 5948 |
5934 void test_missingLibraryDirectiveWithPart() { | 5949 void test_missingLibraryDirectiveWithPart() { |
5935 addSource("/a.dart", "part of lib;"); | 5950 addSource("/a.dart", "part of lib;"); |
5936 Source librarySource = addSource("/lib.dart", "part 'a.dart';"); | 5951 Source librarySource = addSource("/lib.dart", "part 'a.dart';"); |
5937 LibraryElement element = _buildLibrary( | 5952 LibraryElement element = _buildLibrary( |
5938 librarySource, [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); | 5953 librarySource, [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); |
5939 expect(element, isNotNull); | 5954 expect(element, isNotNull); |
5940 } | 5955 } |
5941 | 5956 |
5942 void test_missingPartOfDirective() { | 5957 void test_missingPartOfDirective() { |
5943 addSource("/a.dart", "class A {}"); | 5958 addSource("/a.dart", "class A {}"); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5982 } else { | 5997 } else { |
5983 _assertTypes(sourcedUnits[0], ["C"]); | 5998 _assertTypes(sourcedUnits[0], ["C"]); |
5984 _assertTypes(sourcedUnits[1], ["B"]); | 5999 _assertTypes(sourcedUnits[1], ["B"]); |
5985 } | 6000 } |
5986 } | 6001 } |
5987 | 6002 |
5988 void test_singleFile() { | 6003 void test_singleFile() { |
5989 Source librarySource = addSource( | 6004 Source librarySource = addSource( |
5990 "/lib.dart", | 6005 "/lib.dart", |
5991 r''' | 6006 r''' |
| 6007 /// My dart doc. |
5992 library lib; | 6008 library lib; |
5993 | 6009 |
5994 class A {}'''); | 6010 class A {}'''); |
5995 LibraryElement element = _buildLibrary(librarySource); | 6011 LibraryElement element = _buildLibrary(librarySource); |
5996 expect(element, isNotNull); | 6012 expect(element, isNotNull); |
5997 _assertTypes(element.definingCompilationUnit, ["A"]); | 6013 _assertTypes(element.definingCompilationUnit, ["A"]); |
5998 } | 6014 } |
5999 | 6015 |
6000 /** | 6016 /** |
6001 * Ensure that there are elements representing all of the types in the given a
rray of type names. | 6017 * Ensure that there are elements representing all of the types in the given a
rray of type names. |
(...skipping 8835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14837 | 14853 |
14838 void _resolveTestUnit(String code) { | 14854 void _resolveTestUnit(String code) { |
14839 testCode = code; | 14855 testCode = code; |
14840 testSource = addSource(testCode); | 14856 testSource = addSource(testCode); |
14841 LibraryElement library = resolve2(testSource); | 14857 LibraryElement library = resolve2(testSource); |
14842 assertNoErrors(testSource); | 14858 assertNoErrors(testSource); |
14843 verify([testSource]); | 14859 verify([testSource]); |
14844 testUnit = resolveCompilationUnit(testSource, library); | 14860 testUnit = resolveCompilationUnit(testSource, library); |
14845 } | 14861 } |
14846 } | 14862 } |
OLD | NEW |