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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_test.dart

Issue 1565283002: Add uriOffset and uriEnd to the summary. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.test.src.summary.summary_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1], 1752 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides[1],
1753 'Stream'); 1753 'Stream');
1754 } 1754 }
1755 1755
1756 test_export_no_combinators() { 1756 test_export_no_combinators() {
1757 serializeLibraryText('export "dart:async";'); 1757 serializeLibraryText('export "dart:async";');
1758 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); 1758 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1759 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty); 1759 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators, isEmpty);
1760 } 1760 }
1761 1761
1762 test_export_offset() {
1763 String libraryText = ' export "dart:async";';
1764 serializeLibraryText(libraryText);
1765 expect(unlinkedUnits[0].exports[0].uriOffset,
1766 libraryText.indexOf('"dart:async"'));
1767 expect(unlinkedUnits[0].exports[0].uriEnd, libraryText.indexOf(';'));
1768 }
1769
1762 test_export_show_order() { 1770 test_export_show_order() {
1763 serializeLibraryText('export "dart:async" show Future, Stream;'); 1771 serializeLibraryText('export "dart:async" show Future, Stream;');
1764 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1)); 1772 expect(unlinkedUnits[0].publicNamespace.exports, hasLength(1));
1765 expect( 1773 expect(
1766 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1)); 1774 unlinkedUnits[0].publicNamespace.exports[0].combinators, hasLength(1));
1767 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows, 1775 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows,
1768 hasLength(2)); 1776 hasLength(2));
1769 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides, 1777 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].hides,
1770 isEmpty); 1778 isEmpty);
1771 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0], 1779 expect(unlinkedUnits[0].publicNamespace.exports[0].combinators[0].shows[0],
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future'); 1861 expect(unlinkedUnits[0].imports[0].combinators[0].hides[0], 'Future');
1854 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream'); 1862 expect(unlinkedUnits[0].imports[0].combinators[0].hides[1], 'Stream');
1855 } 1863 }
1856 1864
1857 test_import_implicit() { 1865 test_import_implicit() {
1858 // The implicit import of dart:core is represented in the model. 1866 // The implicit import of dart:core is represented in the model.
1859 serializeLibraryText(''); 1867 serializeLibraryText('');
1860 expect(unlinkedUnits[0].imports, hasLength(1)); 1868 expect(unlinkedUnits[0].imports, hasLength(1));
1861 checkDependency(prelinked.importDependencies[0], 'dart:core', 'dart:core'); 1869 checkDependency(prelinked.importDependencies[0], 'dart:core', 'dart:core');
1862 expect(unlinkedUnits[0].imports[0].uri, isEmpty); 1870 expect(unlinkedUnits[0].imports[0].uri, isEmpty);
1871 expect(unlinkedUnits[0].imports[0].uriOffset, 0);
1872 expect(unlinkedUnits[0].imports[0].uriEnd, 0);
1863 expect(unlinkedUnits[0].imports[0].prefixReference, 0); 1873 expect(unlinkedUnits[0].imports[0].prefixReference, 0);
1864 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); 1874 expect(unlinkedUnits[0].imports[0].combinators, isEmpty);
1865 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue); 1875 expect(unlinkedUnits[0].imports[0].isImplicit, isTrue);
1866 } 1876 }
1867 1877
1868 test_import_no_combinators() { 1878 test_import_no_combinators() {
1869 serializeLibraryText('import "dart:async"; Future x;'); 1879 serializeLibraryText('import "dart:async"; Future x;');
1870 // Second import is the implicit import of dart:core 1880 // Second import is the implicit import of dart:core
1871 expect(unlinkedUnits[0].imports, hasLength(2)); 1881 expect(unlinkedUnits[0].imports, hasLength(2));
1872 expect(unlinkedUnits[0].imports[0].combinators, isEmpty); 1882 expect(unlinkedUnits[0].imports[0].combinators, isEmpty);
(...skipping 24 matching lines...) Expand all
1897 // re-export of bar.dart refers to a non-existent file. 1907 // re-export of bar.dart refers to a non-existent file.
1898 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}'); 1908 addNamedSource('/foo.dart', 'export "bar.dart"; class C {}');
1899 serializeLibraryText('import "foo.dart"; C x;'); 1909 serializeLibraryText('import "foo.dart"; C x;');
1900 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C'); 1910 checkTypeRef(findVariable('x').type, absUri('/foo.dart'), 'foo.dart', 'C');
1901 } 1911 }
1902 1912
1903 test_import_offset() { 1913 test_import_offset() {
1904 String libraryText = ' import "dart:async"; Future x;'; 1914 String libraryText = ' import "dart:async"; Future x;';
1905 serializeLibraryText(libraryText); 1915 serializeLibraryText(libraryText);
1906 expect(unlinkedUnits[0].imports[0].offset, libraryText.indexOf('import')); 1916 expect(unlinkedUnits[0].imports[0].offset, libraryText.indexOf('import'));
1917 expect(unlinkedUnits[0].imports[0].uriOffset,
1918 libraryText.indexOf('"dart:async"'));
1919 expect(unlinkedUnits[0].imports[0].uriEnd, libraryText.indexOf('; Future'));
1907 } 1920 }
1908 1921
1909 test_import_prefix_name() { 1922 test_import_prefix_name() {
1910 String libraryText = 'import "dart:async" as a; a.Future x;'; 1923 String libraryText = 'import "dart:async" as a; a.Future x;';
1911 serializeLibraryText(libraryText); 1924 serializeLibraryText(libraryText);
1912 // Second import is the implicit import of dart:core 1925 // Second import is the implicit import of dart:core
1913 expect(unlinkedUnits[0].imports, hasLength(2)); 1926 expect(unlinkedUnits[0].imports, hasLength(2));
1914 checkPrefix(unlinkedUnits[0].imports[0].prefixReference, 'a'); 1927 checkPrefix(unlinkedUnits[0].imports[0].prefixReference, 'a');
1915 } 1928 }
1916 1929
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 String text = 'library foo.bar;'; 2009 String text = 'library foo.bar;';
1997 serializeLibraryText(text); 2010 serializeLibraryText(text);
1998 expect(unlinkedUnits[0].libraryName, 'foo.bar'); 2011 expect(unlinkedUnits[0].libraryName, 'foo.bar');
1999 } 2012 }
2000 2013
2001 test_library_unnamed() { 2014 test_library_unnamed() {
2002 serializeLibraryText(''); 2015 serializeLibraryText('');
2003 expect(unlinkedUnits[0].libraryName, isEmpty); 2016 expect(unlinkedUnits[0].libraryName, isEmpty);
2004 } 2017 }
2005 2018
2019 test_part_declaration() {
2020 addNamedSource('/a.dart', 'part of my.lib;');
2021 String text = 'library my.lib; part "a.dart"; // <-part';
2022 serializeLibraryText(text);
2023 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
2024 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart');
2025 expect(unlinkedUnits[0].parts, hasLength(1));
2026 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"'));
2027 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
2028 }
2029
2006 test_parts_defining_compilation_unit() { 2030 test_parts_defining_compilation_unit() {
2007 serializeLibraryText(''); 2031 serializeLibraryText('');
2008 expect(prelinked.units, hasLength(1)); 2032 expect(prelinked.units, hasLength(1));
2009 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty); 2033 expect(unlinkedUnits[0].publicNamespace.parts, isEmpty);
2010 } 2034 }
2011 2035
2012 test_parts_included() { 2036 test_parts_included() {
2013 addNamedSource('/part1.dart', 'part of my.lib;'); 2037 addNamedSource('/part1.dart', 'part of my.lib;');
2014 String partString = '"part1.dart"'; 2038 String partString = '"part1.dart"';
2015 String libraryText = 'library my.lib; part $partString;'; 2039 String libraryText = 'library my.lib; part $partString;';
2016 serializeLibraryText(libraryText); 2040 serializeLibraryText(libraryText);
2017 expect(prelinked.units, hasLength(2)); 2041 expect(prelinked.units, hasLength(2));
2018 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); 2042 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
2019 expect(unlinkedUnits[0].publicNamespace.parts[0].uri, 'part1.dart'); 2043 expect(unlinkedUnits[0].publicNamespace.parts[0], 'part1.dart');
2020 } 2044 }
2021 2045
2022 test_public_namespace_of_part() { 2046 test_public_namespace_of_part() {
2023 addNamedSource('/a.dart', 'part of foo; class C {}'); 2047 addNamedSource('/a.dart', 'part of foo; class C {}');
2024 serializeLibraryText('library foo; part "a.dart";'); 2048 serializeLibraryText('library foo; part "a.dart";');
2025 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2049 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2026 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1)); 2050 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1));
2027 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C'); 2051 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C');
2028 } 2052 }
2029 2053
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 UnlinkedVariable variable = 2410 UnlinkedVariable variable =
2387 serializeVariableText('int i;', variableName: 'i'); 2411 serializeVariableText('int i;', variableName: 'i');
2388 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2412 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2389 } 2413 }
2390 2414
2391 test_varible_private() { 2415 test_varible_private() {
2392 serializeVariableText('int _i;', variableName: '_i'); 2416 serializeVariableText('int _i;', variableName: '_i');
2393 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2417 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2394 } 2418 }
2395 } 2419 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698