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

Side by Side Diff: pkg/analyzer/lib/src/summary/format.dart

Issue 1733853002: IDL for index. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: We store only URI strings. Created 4 years, 9 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 // This file has been automatically generated. Please do not edit it manually. 5 // This file has been automatically generated. Please do not edit it manually.
6 // To regenerate the file, use the script "pkg/analyzer/tool/generate_files". 6 // To regenerate the file, use the script "pkg/analyzer/tool/generate_files".
7 7
8 library analyzer.src.summary.format; 8 library analyzer.src.summary.format;
9 9
10 import 'flat_buffers.dart' as fb; 10 import 'flat_buffers.dart' as fb;
11 import 'idl.dart' as idl; 11 import 'idl.dart' as idl;
12 import 'dart:convert' as convert; 12 import 'dart:convert' as convert;
13 13
14 class _IndexRelationKindReader extends fb.Reader<idl.IndexRelationKind> {
15 const _IndexRelationKindReader() : super();
16
17 @override
18 int get size => 1;
19
20 @override
21 idl.IndexRelationKind read(fb.BufferPointer bp) {
22 int index = const fb.Uint8Reader().read(bp);
23 return idl.IndexRelationKind.values[index];
24 }
25 }
26
14 class _ReferenceKindReader extends fb.Reader<idl.ReferenceKind> { 27 class _ReferenceKindReader extends fb.Reader<idl.ReferenceKind> {
15 const _ReferenceKindReader() : super(); 28 const _ReferenceKindReader() : super();
16 29
17 @override 30 @override
18 int get size => 1; 31 int get size => 1;
19 32
20 @override 33 @override
21 idl.ReferenceKind read(fb.BufferPointer bp) { 34 idl.ReferenceKind read(fb.BufferPointer bp) {
22 int index = const fb.Uint8Reader().read(bp); 35 int index = const fb.Uint8Reader().read(bp);
23 return idl.ReferenceKind.values[index]; 36 return idl.ReferenceKind.values[index];
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 "linkedLibraryUris": linkedLibraryUris, 1344 "linkedLibraryUris": linkedLibraryUris,
1332 "unlinkedUnitHashes": unlinkedUnitHashes, 1345 "unlinkedUnitHashes": unlinkedUnitHashes,
1333 "unlinkedUnits": unlinkedUnits, 1346 "unlinkedUnits": unlinkedUnits,
1334 "unlinkedUnitUris": unlinkedUnitUris, 1347 "unlinkedUnitUris": unlinkedUnitUris,
1335 }; 1348 };
1336 1349
1337 @override 1350 @override
1338 String toString() => convert.JSON.encode(toJson()); 1351 String toString() => convert.JSON.encode(toJson());
1339 } 1352 }
1340 1353
1354 class PackageIndexBuilder extends Object with _PackageIndexMixin implements idl. PackageIndex {
1355 bool _finished = false;
1356
1357 List<int> _elementLibraryUris;
1358 List<int> _elementOffsets;
1359 List<int> _elementUnits;
1360 List<int> _elementUnitUris;
1361 List<UnitIndexBuilder> _units;
1362 List<String> _uris;
1363
1364 @override
1365 List<int> get elementLibraryUris => _elementLibraryUris ??= <int>[];
1366
1367 /**
1368 * Each item of this list corresponds to a unique library URI with an element
1369 * referenced in the [PackageIndex]. It is index into [uris] list.
1370 */
1371 void set elementLibraryUris(List<int> _value) {
1372 assert(!_finished);
1373 assert(_value == null || _value.every((e) => e >= 0));
1374 _elementLibraryUris = _value;
1375 }
1376
1377 @override
1378 List<int> get elementOffsets => _elementOffsets ??= <int>[];
1379
1380 /**
1381 * Each item of this list corresponds to a unique referenced element. It is
1382 * the offset of the element name relative to the beginning of the file. The
1383 * list is sorted in ascending order, so that the client can quickly check
1384 * whether an element is referenced in this [PackageIndex].
1385 */
1386 void set elementOffsets(List<int> _value) {
1387 assert(!_finished);
1388 assert(_value == null || _value.every((e) => e >= 0));
1389 _elementOffsets = _value;
1390 }
1391
1392 @override
1393 List<int> get elementUnits => _elementUnits ??= <int>[];
1394
1395 /**
1396 * Each item of this list corresponds to a unique referenced element. It is
1397 * the index into [elementLibraryUris] and [elementUnitUris] for the library
1398 * specific unit where the element is declared.
1399 */
1400 void set elementUnits(List<int> _value) {
1401 assert(!_finished);
1402 assert(_value == null || _value.every((e) => e >= 0));
1403 _elementUnits = _value;
1404 }
1405
1406 @override
1407 List<int> get elementUnitUris => _elementUnitUris ??= <int>[];
1408
1409 /**
1410 * Each item of this list corresponds to a unique unit URI with an element
1411 * referenced in the [PackageIndex]. It is index into [uris] list.
1412 */
1413 void set elementUnitUris(List<int> _value) {
1414 assert(!_finished);
1415 assert(_value == null || _value.every((e) => e >= 0));
1416 _elementUnitUris = _value;
1417 }
1418
1419 @override
1420 List<UnitIndexBuilder> get units => _units ??= <UnitIndexBuilder>[];
1421
1422 /**
1423 * List of unit indexed in this [PackageIndex].
1424 */
1425 void set units(List<UnitIndexBuilder> _value) {
1426 assert(!_finished);
1427 _units = _value;
1428 }
1429
1430 @override
1431 List<String> get uris => _uris ??= <String>[];
1432
1433 /**
1434 * List of unique URIs used in this [PackageIndex].
1435 */
1436 void set uris(List<String> _value) {
1437 assert(!_finished);
1438 _uris = _value;
1439 }
1440
1441 PackageIndexBuilder({List<int> elementLibraryUris, List<int> elementOffsets, L ist<int> elementUnits, List<int> elementUnitUris, List<UnitIndexBuilder> units, List<String> uris})
1442 : _elementLibraryUris = elementLibraryUris,
1443 _elementOffsets = elementOffsets,
1444 _elementUnits = elementUnits,
1445 _elementUnitUris = elementUnitUris,
1446 _units = units,
1447 _uris = uris;
1448
1449 List<int> toBuffer() {
1450 fb.Builder fbBuilder = new fb.Builder();
1451 return fbBuilder.finish(finish(fbBuilder));
1452 }
1453
1454 fb.Offset finish(fb.Builder fbBuilder) {
1455 assert(!_finished);
1456 _finished = true;
1457 fb.Offset offset_elementLibraryUris;
1458 fb.Offset offset_elementOffsets;
1459 fb.Offset offset_elementUnits;
1460 fb.Offset offset_elementUnitUris;
1461 fb.Offset offset_units;
1462 fb.Offset offset_uris;
1463 if (!(_elementLibraryUris == null || _elementLibraryUris.isEmpty)) {
1464 offset_elementLibraryUris = fbBuilder.writeListUint32(_elementLibraryUris) ;
1465 }
1466 if (!(_elementOffsets == null || _elementOffsets.isEmpty)) {
1467 offset_elementOffsets = fbBuilder.writeListUint32(_elementOffsets);
1468 }
1469 if (!(_elementUnits == null || _elementUnits.isEmpty)) {
1470 offset_elementUnits = fbBuilder.writeListUint32(_elementUnits);
1471 }
1472 if (!(_elementUnitUris == null || _elementUnitUris.isEmpty)) {
1473 offset_elementUnitUris = fbBuilder.writeListUint32(_elementUnitUris);
1474 }
1475 if (!(_units == null || _units.isEmpty)) {
1476 offset_units = fbBuilder.writeList(_units.map((b) => b.finish(fbBuilder)). toList());
1477 }
1478 if (!(_uris == null || _uris.isEmpty)) {
1479 offset_uris = fbBuilder.writeList(_uris.map((b) => fbBuilder.writeString(b )).toList());
1480 }
1481 fbBuilder.startTable();
1482 if (offset_elementLibraryUris != null) {
1483 fbBuilder.addOffset(2, offset_elementLibraryUris);
1484 }
1485 if (offset_elementOffsets != null) {
1486 fbBuilder.addOffset(1, offset_elementOffsets);
1487 }
1488 if (offset_elementUnits != null) {
1489 fbBuilder.addOffset(0, offset_elementUnits);
1490 }
1491 if (offset_elementUnitUris != null) {
1492 fbBuilder.addOffset(3, offset_elementUnitUris);
1493 }
1494 if (offset_units != null) {
1495 fbBuilder.addOffset(5, offset_units);
1496 }
1497 if (offset_uris != null) {
1498 fbBuilder.addOffset(4, offset_uris);
1499 }
1500 return fbBuilder.endTable();
1501 }
1502 }
1503
1504 idl.PackageIndex readPackageIndex(List<int> buffer) {
1505 fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
1506 return const _PackageIndexReader().read(rootRef);
1507 }
1508
1509 class _PackageIndexReader extends fb.TableReader<_PackageIndexImpl> {
1510 const _PackageIndexReader();
1511
1512 @override
1513 _PackageIndexImpl createObject(fb.BufferPointer bp) => new _PackageIndexImpl(b p);
1514 }
1515
1516 class _PackageIndexImpl extends Object with _PackageIndexMixin implements idl.Pa ckageIndex {
1517 final fb.BufferPointer _bp;
1518
1519 _PackageIndexImpl(this._bp);
1520
1521 List<int> _elementLibraryUris;
1522 List<int> _elementOffsets;
1523 List<int> _elementUnits;
1524 List<int> _elementUnitUris;
1525 List<idl.UnitIndex> _units;
1526 List<String> _uris;
1527
1528 @override
1529 List<int> get elementLibraryUris {
1530 _elementLibraryUris ??= const fb.Uint32ListReader().vTableGet(_bp, 2, const <int>[]);
1531 return _elementLibraryUris;
1532 }
1533
1534 @override
1535 List<int> get elementOffsets {
1536 _elementOffsets ??= const fb.Uint32ListReader().vTableGet(_bp, 1, const <int >[]);
1537 return _elementOffsets;
1538 }
1539
1540 @override
1541 List<int> get elementUnits {
1542 _elementUnits ??= const fb.Uint32ListReader().vTableGet(_bp, 0, const <int>[ ]);
1543 return _elementUnits;
1544 }
1545
1546 @override
1547 List<int> get elementUnitUris {
1548 _elementUnitUris ??= const fb.Uint32ListReader().vTableGet(_bp, 3, const <in t>[]);
1549 return _elementUnitUris;
1550 }
1551
1552 @override
1553 List<idl.UnitIndex> get units {
1554 _units ??= const fb.ListReader<idl.UnitIndex>(const _UnitIndexReader()).vTab leGet(_bp, 5, const <idl.UnitIndex>[]);
1555 return _units;
1556 }
1557
1558 @override
1559 List<String> get uris {
1560 _uris ??= const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp , 4, const <String>[]);
1561 return _uris;
1562 }
1563 }
1564
1565 abstract class _PackageIndexMixin implements idl.PackageIndex {
1566 @override
1567 Map<String, Object> toJson() {
1568 Map<String, Object> _result = <String, Object>{};
1569 if (elementLibraryUris.isNotEmpty) _result["elementLibraryUris"] = elementLi braryUris;
1570 if (elementOffsets.isNotEmpty) _result["elementOffsets"] = elementOffsets;
1571 if (elementUnits.isNotEmpty) _result["elementUnits"] = elementUnits;
1572 if (elementUnitUris.isNotEmpty) _result["elementUnitUris"] = elementUnitUris ;
1573 if (units.isNotEmpty) _result["units"] = units.map((_value) => _value.toJson ()).toList();
1574 if (uris.isNotEmpty) _result["uris"] = uris;
1575 return _result;
1576 }
1577
1578 @override
1579 Map<String, Object> toMap() => {
1580 "elementLibraryUris": elementLibraryUris,
1581 "elementOffsets": elementOffsets,
1582 "elementUnits": elementUnits,
1583 "elementUnitUris": elementUnitUris,
1584 "units": units,
1585 "uris": uris,
1586 };
1587
1588 @override
1589 String toString() => convert.JSON.encode(toJson());
1590 }
1591
1592 class UnitIndexBuilder extends Object with _UnitIndexMixin implements idl.UnitIn dex {
1593 bool _finished = false;
1594
1595 List<int> _elements;
1596 List<idl.IndexRelationKind> _kinds;
1597 int _libraryUri;
1598 List<int> _locationLengths;
1599 List<int> _locationOffsets;
1600 int _unitUri;
1601
1602 @override
1603 List<int> get elements => _elements ??= <int>[];
1604
1605 /**
1606 * Each item of this list is the index into [PackageIndex.elementUnits] and
1607 * [PackageIndex.elementOffsets]. The list is sorted in ascending order, so
1608 * that the client can quickly find element references in this [UnitIndex].
1609 */
1610 void set elements(List<int> _value) {
1611 assert(!_finished);
1612 assert(_value == null || _value.every((e) => e >= 0));
1613 _elements = _value;
1614 }
1615
1616 @override
1617 List<idl.IndexRelationKind> get kinds => _kinds ??= <idl.IndexRelationKind>[];
1618
1619 /**
1620 * Each item of this list is the kind of the element usage.
1621 */
1622 void set kinds(List<idl.IndexRelationKind> _value) {
1623 assert(!_finished);
1624 _kinds = _value;
1625 }
1626
1627 @override
1628 int get libraryUri => _libraryUri ??= 0;
1629
1630 /**
1631 * The library source URI of this unit, e.g. `dart:core` or
1632 * `package:foo/bar.dart`, as index into [PackageIndex.uris].
1633 */
1634 void set libraryUri(int _value) {
1635 assert(!_finished);
1636 assert(_value == null || _value >= 0);
1637 _libraryUri = _value;
1638 }
1639
1640 @override
1641 List<int> get locationLengths => _locationLengths ??= <int>[];
1642
1643 /**
1644 * Each item of this list is the length of the element usage.
1645 */
1646 void set locationLengths(List<int> _value) {
1647 assert(!_finished);
1648 assert(_value == null || _value.every((e) => e >= 0));
1649 _locationLengths = _value;
1650 }
1651
1652 @override
1653 List<int> get locationOffsets => _locationOffsets ??= <int>[];
1654
1655 /**
1656 * Each item of this list is the offset of the element usage relative to the
1657 * beginning of the file.
1658 */
1659 void set locationOffsets(List<int> _value) {
1660 assert(!_finished);
1661 assert(_value == null || _value.every((e) => e >= 0));
1662 _locationOffsets = _value;
1663 }
1664
1665 @override
1666 int get unitUri => _unitUri ??= 0;
1667
1668 /**
1669 * The unit source URI of this unit, e.g. `dart:core/int.dart` or
1670 * `package:foo/bar/baz.dart`, as index into [PackageIndex.uris].
1671 */
1672 void set unitUri(int _value) {
1673 assert(!_finished);
1674 assert(_value == null || _value >= 0);
1675 _unitUri = _value;
1676 }
1677
1678 UnitIndexBuilder({List<int> elements, List<idl.IndexRelationKind> kinds, int l ibraryUri, List<int> locationLengths, List<int> locationOffsets, int unitUri})
1679 : _elements = elements,
1680 _kinds = kinds,
1681 _libraryUri = libraryUri,
1682 _locationLengths = locationLengths,
1683 _locationOffsets = locationOffsets,
1684 _unitUri = unitUri;
1685
1686 fb.Offset finish(fb.Builder fbBuilder) {
1687 assert(!_finished);
1688 _finished = true;
1689 fb.Offset offset_elements;
1690 fb.Offset offset_kinds;
1691 fb.Offset offset_locationLengths;
1692 fb.Offset offset_locationOffsets;
1693 if (!(_elements == null || _elements.isEmpty)) {
1694 offset_elements = fbBuilder.writeListUint32(_elements);
1695 }
1696 if (!(_kinds == null || _kinds.isEmpty)) {
1697 offset_kinds = fbBuilder.writeListUint8(_kinds.map((b) => b.index).toList( ));
1698 }
1699 if (!(_locationLengths == null || _locationLengths.isEmpty)) {
1700 offset_locationLengths = fbBuilder.writeListUint32(_locationLengths);
1701 }
1702 if (!(_locationOffsets == null || _locationOffsets.isEmpty)) {
1703 offset_locationOffsets = fbBuilder.writeListUint32(_locationOffsets);
1704 }
1705 fbBuilder.startTable();
1706 if (offset_elements != null) {
1707 fbBuilder.addOffset(4, offset_elements);
1708 }
1709 if (offset_kinds != null) {
1710 fbBuilder.addOffset(5, offset_kinds);
1711 }
1712 if (_libraryUri != null && _libraryUri != 0) {
1713 fbBuilder.addUint32(0, _libraryUri);
1714 }
1715 if (offset_locationLengths != null) {
1716 fbBuilder.addOffset(2, offset_locationLengths);
1717 }
1718 if (offset_locationOffsets != null) {
1719 fbBuilder.addOffset(3, offset_locationOffsets);
1720 }
1721 if (_unitUri != null && _unitUri != 0) {
1722 fbBuilder.addUint32(1, _unitUri);
1723 }
1724 return fbBuilder.endTable();
1725 }
1726 }
1727
1728 class _UnitIndexReader extends fb.TableReader<_UnitIndexImpl> {
1729 const _UnitIndexReader();
1730
1731 @override
1732 _UnitIndexImpl createObject(fb.BufferPointer bp) => new _UnitIndexImpl(bp);
1733 }
1734
1735 class _UnitIndexImpl extends Object with _UnitIndexMixin implements idl.UnitInde x {
1736 final fb.BufferPointer _bp;
1737
1738 _UnitIndexImpl(this._bp);
1739
1740 List<int> _elements;
1741 List<idl.IndexRelationKind> _kinds;
1742 int _libraryUri;
1743 List<int> _locationLengths;
1744 List<int> _locationOffsets;
1745 int _unitUri;
1746
1747 @override
1748 List<int> get elements {
1749 _elements ??= const fb.Uint32ListReader().vTableGet(_bp, 4, const <int>[]);
1750 return _elements;
1751 }
1752
1753 @override
1754 List<idl.IndexRelationKind> get kinds {
1755 _kinds ??= const fb.ListReader<idl.IndexRelationKind>(const _IndexRelationKi ndReader()).vTableGet(_bp, 5, const <idl.IndexRelationKind>[]);
1756 return _kinds;
1757 }
1758
1759 @override
1760 int get libraryUri {
1761 _libraryUri ??= const fb.Uint32Reader().vTableGet(_bp, 0, 0);
1762 return _libraryUri;
1763 }
1764
1765 @override
1766 List<int> get locationLengths {
1767 _locationLengths ??= const fb.Uint32ListReader().vTableGet(_bp, 2, const <in t>[]);
1768 return _locationLengths;
1769 }
1770
1771 @override
1772 List<int> get locationOffsets {
1773 _locationOffsets ??= const fb.Uint32ListReader().vTableGet(_bp, 3, const <in t>[]);
1774 return _locationOffsets;
1775 }
1776
1777 @override
1778 int get unitUri {
1779 _unitUri ??= const fb.Uint32Reader().vTableGet(_bp, 1, 0);
1780 return _unitUri;
1781 }
1782 }
1783
1784 abstract class _UnitIndexMixin implements idl.UnitIndex {
1785 @override
1786 Map<String, Object> toJson() {
1787 Map<String, Object> _result = <String, Object>{};
1788 if (elements.isNotEmpty) _result["elements"] = elements;
1789 if (kinds.isNotEmpty) _result["kinds"] = kinds.map((_value) => _value.toStri ng().split('.')[1]).toList();
1790 if (libraryUri != 0) _result["libraryUri"] = libraryUri;
1791 if (locationLengths.isNotEmpty) _result["locationLengths"] = locationLengths ;
1792 if (locationOffsets.isNotEmpty) _result["locationOffsets"] = locationOffsets ;
1793 if (unitUri != 0) _result["unitUri"] = unitUri;
1794 return _result;
1795 }
1796
1797 @override
1798 Map<String, Object> toMap() => {
1799 "elements": elements,
1800 "kinds": kinds,
1801 "libraryUri": libraryUri,
1802 "locationLengths": locationLengths,
1803 "locationOffsets": locationOffsets,
1804 "unitUri": unitUri,
1805 };
1806
1807 @override
1808 String toString() => convert.JSON.encode(toJson());
1809 }
1810
1341 class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements id l.UnlinkedClass { 1811 class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements id l.UnlinkedClass {
1342 bool _finished = false; 1812 bool _finished = false;
1343 1813
1344 List<UnlinkedConstBuilder> _annotations; 1814 List<UnlinkedConstBuilder> _annotations;
1345 UnlinkedDocumentationCommentBuilder _documentationComment; 1815 UnlinkedDocumentationCommentBuilder _documentationComment;
1346 List<UnlinkedExecutableBuilder> _executables; 1816 List<UnlinkedExecutableBuilder> _executables;
1347 List<UnlinkedVariableBuilder> _fields; 1817 List<UnlinkedVariableBuilder> _fields;
1348 bool _hasNoSupertype; 1818 bool _hasNoSupertype;
1349 List<EntityRefBuilder> _interfaces; 1819 List<EntityRefBuilder> _interfaces;
1350 bool _isAbstract; 1820 bool _isAbstract;
(...skipping 5139 matching lines...) Expand 10 before | Expand all | Expand 10 after
6490 "propagatedTypeSlot": propagatedTypeSlot, 6960 "propagatedTypeSlot": propagatedTypeSlot,
6491 "type": type, 6961 "type": type,
6492 "visibleLength": visibleLength, 6962 "visibleLength": visibleLength,
6493 "visibleOffset": visibleOffset, 6963 "visibleOffset": visibleOffset,
6494 }; 6964 };
6495 6965
6496 @override 6966 @override
6497 String toString() => convert.JSON.encode(toJson()); 6967 String toString() => convert.JSON.encode(toJson());
6498 } 6968 }
6499 6969
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/idl.dart » ('j') | pkg/analyzer/lib/src/summary/idl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698