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

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

Issue 1762193002: Resynthesize codeOffset/codeLength properties. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Use CodeRange object. 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.fbs ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | 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) 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 /** 5 /**
6 * This file is an "idl" style description of the summary format. It 6 * This file is an "idl" style description of the summary format. It
7 * contains abstract classes which declare the interface for reading data from 7 * contains abstract classes which declare the interface for reading data from
8 * summaries. It is parsed and transformed into code that implements the 8 * summaries. It is parsed and transformed into code that implements the
9 * summary format. 9 * summary format.
10 * 10 *
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 import 'format.dart' as generated; 46 import 'format.dart' as generated;
47 47
48 /** 48 /**
49 * Annotation describing information which is not part of Dart semantics; in 49 * Annotation describing information which is not part of Dart semantics; in
50 * other words, if this information (or any information it refers to) changes, 50 * other words, if this information (or any information it refers to) changes,
51 * static analysis and runtime behavior of the library are unaffected. 51 * static analysis and runtime behavior of the library are unaffected.
52 */ 52 */
53 const informative = null; 53 const informative = null;
54 54
55 /** 55 /**
56 * Information about an element code range.
57 */
58 abstract class CodeRange extends base.SummaryClass {
59 /**
60 * Length of the element code.
61 */
62 @Id(1)
63 int get length;
64
65 /**
66 * Offset of the element code relative to the beginning of the file.
67 */
68 @Id(0)
69 int get offset;
70 }
71
72 /**
56 * Summary information about a reference to a an entity such as a type, top 73 * Summary information about a reference to a an entity such as a type, top
57 * level executable, or executable within a class. 74 * level executable, or executable within a class.
58 */ 75 */
59 abstract class EntityRef extends base.SummaryClass { 76 abstract class EntityRef extends base.SummaryClass {
60 /** 77 /**
61 * If this is a reference to a function type implicitly defined by a 78 * If this is a reference to a function type implicitly defined by a
62 * function-typed parameter, a list of zero-based indices indicating the path 79 * function-typed parameter, a list of zero-based indices indicating the path
63 * from the entity referred to by [reference] to the appropriate type 80 * from the entity referred to by [reference] to the appropriate type
64 * parameter. Otherwise the empty list. 81 * parameter. Otherwise the empty list.
65 * 82 *
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 */ 439 */
423 @Id(0) 440 @Id(0)
424 int get unit; 441 int get unit;
425 } 442 }
426 443
427 /** 444 /**
428 * Linked summary of a compilation unit. 445 * Linked summary of a compilation unit.
429 */ 446 */
430 abstract class LinkedUnit extends base.SummaryClass { 447 abstract class LinkedUnit extends base.SummaryClass {
431 /** 448 /**
449 * List of slot ids (referring to [UnlinkedExecutable.constCycleSlot])
450 * corresponding to const constructors that are part of cycles.
451 */
452 @Id(2)
453 List<int> get constCycles;
454
455 /**
432 * Information about the resolution of references within the compilation 456 * Information about the resolution of references within the compilation
433 * unit. Each element of [UnlinkedUnit.references] has a corresponding 457 * unit. Each element of [UnlinkedUnit.references] has a corresponding
434 * element in this list (at the same index). If this list has additional 458 * element in this list (at the same index). If this list has additional
435 * elements beyond the number of elements in [UnlinkedUnit.references], those 459 * elements beyond the number of elements in [UnlinkedUnit.references], those
436 * additional elements are references that are only referred to implicitly 460 * additional elements are references that are only referred to implicitly
437 * (e.g. elements involved in inferred or propagated types). 461 * (e.g. elements involved in inferred or propagated types).
438 */ 462 */
439 @Id(0) 463 @Id(0)
440 List<LinkedReference> get references; 464 List<LinkedReference> get references;
441 465
442 /** 466 /**
443 * List associating slot ids found inside the unlinked summary for the 467 * List associating slot ids found inside the unlinked summary for the
444 * compilation unit with propagated and inferred types. 468 * compilation unit with propagated and inferred types.
445 */ 469 */
446 @Id(1) 470 @Id(1)
447 List<EntityRef> get types; 471 List<EntityRef> get types;
448
449 /**
450 * List of slot ids (referring to [UnlinkedExecutable.constCycleSlot])
451 * corresponding to const constructors that are part of cycles.
452 */
453 @Id(2)
454 List<int> get constCycles;
455 } 472 }
456 473
457 /** 474 /**
458 * Summary information about a package. 475 * Summary information about a package.
459 */ 476 */
460 @TopLevel('PBdl') 477 @TopLevel('PBdl')
461 abstract class PackageBundle extends base.SummaryClass { 478 abstract class PackageBundle extends base.SummaryClass {
462 factory PackageBundle.fromBuffer(List<int> buffer) => 479 factory PackageBundle.fromBuffer(List<int> buffer) =>
463 generated.readPackageBundle(buffer); 480 generated.readPackageBundle(buffer);
464 481
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 * Unlinked summary information about a class declaration. 748 * Unlinked summary information about a class declaration.
732 */ 749 */
733 abstract class UnlinkedClass extends base.SummaryClass { 750 abstract class UnlinkedClass extends base.SummaryClass {
734 /** 751 /**
735 * Annotations for this class. 752 * Annotations for this class.
736 */ 753 */
737 @Id(5) 754 @Id(5)
738 List<UnlinkedConst> get annotations; 755 List<UnlinkedConst> get annotations;
739 756
740 /** 757 /**
758 * Code range of the class.
759 */
760 @Id(13)
761 CodeRange get codeRange;
762
763 /**
741 * Documentation comment for the class, or `null` if there is no 764 * Documentation comment for the class, or `null` if there is no
742 * documentation comment. 765 * documentation comment.
743 */ 766 */
744 @informative 767 @informative
745 @Id(6) 768 @Id(6)
746 UnlinkedDocumentationComment get documentationComment; 769 UnlinkedDocumentationComment get documentationComment;
747 770
748 /** 771 /**
749 * Executable objects (methods, getters, and setters) contained in the class. 772 * Executable objects (methods, getters, and setters) contained in the class.
750 */ 773 */
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 * Unlinked summary information about an enum declaration. 1304 * Unlinked summary information about an enum declaration.
1282 */ 1305 */
1283 abstract class UnlinkedEnum extends base.SummaryClass { 1306 abstract class UnlinkedEnum extends base.SummaryClass {
1284 /** 1307 /**
1285 * Annotations for this enum. 1308 * Annotations for this enum.
1286 */ 1309 */
1287 @Id(4) 1310 @Id(4)
1288 List<UnlinkedConst> get annotations; 1311 List<UnlinkedConst> get annotations;
1289 1312
1290 /** 1313 /**
1314 * Code range of the enum.
1315 */
1316 @Id(5)
1317 CodeRange get codeRange;
1318
1319 /**
1291 * Documentation comment for the enum, or `null` if there is no documentation 1320 * Documentation comment for the enum, or `null` if there is no documentation
1292 * comment. 1321 * comment.
1293 */ 1322 */
1294 @informative 1323 @informative
1295 @Id(3) 1324 @Id(3)
1296 UnlinkedDocumentationComment get documentationComment; 1325 UnlinkedDocumentationComment get documentationComment;
1297 1326
1298 /** 1327 /**
1299 * Name of the enum type. 1328 * Name of the enum type.
1300 */ 1329 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 * declaration. 1376 * declaration.
1348 */ 1377 */
1349 abstract class UnlinkedExecutable extends base.SummaryClass { 1378 abstract class UnlinkedExecutable extends base.SummaryClass {
1350 /** 1379 /**
1351 * Annotations for this executable. 1380 * Annotations for this executable.
1352 */ 1381 */
1353 @Id(6) 1382 @Id(6)
1354 List<UnlinkedConst> get annotations; 1383 List<UnlinkedConst> get annotations;
1355 1384
1356 /** 1385 /**
1386 * Code range of the executable.
1387 */
1388 @Id(26)
1389 CodeRange get codeRange;
1390
1391 /**
1357 * If a constant [UnlinkedExecutableKind.constructor], the constructor 1392 * If a constant [UnlinkedExecutableKind.constructor], the constructor
1358 * initializers. Otherwise empty. 1393 * initializers. Otherwise empty.
1359 */ 1394 */
1360 @Id(14) 1395 @Id(14)
1361 List<UnlinkedConstructorInitializer> get constantInitializers; 1396 List<UnlinkedConstructorInitializer> get constantInitializers;
1362 1397
1363 /** 1398 /**
1399 * If [kind] is [UnlinkedExecutableKind.constructor] and [isConst] is `true`,
1400 * a nonzero slot id which is unique within this compilation unit. If this id
1401 * is found in [LinkedUnit.constCycles], then this constructor is part of a
1402 * cycle.
1403 *
1404 * Otherwise, zero.
1405 */
1406 @Id(25)
1407 int get constCycleSlot;
1408
1409 /**
1364 * Documentation comment for the executable, or `null` if there is no 1410 * Documentation comment for the executable, or `null` if there is no
1365 * documentation comment. 1411 * documentation comment.
1366 */ 1412 */
1367 @informative 1413 @informative
1368 @Id(7) 1414 @Id(7)
1369 UnlinkedDocumentationComment get documentationComment; 1415 UnlinkedDocumentationComment get documentationComment;
1370 1416
1371 /** 1417 /**
1372 * If this executable's return type is inferable, nonzero slot id 1418 * If this executable's return type is inferable, nonzero slot id
1373 * identifying which entry in [LinkedUnit.types] contains the inferred 1419 * identifying which entry in [LinkedUnit.types] contains the inferred
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 * If a local function, the length of the visible range; zero otherwise. 1567 * If a local function, the length of the visible range; zero otherwise.
1522 */ 1568 */
1523 @Id(20) 1569 @Id(20)
1524 int get visibleLength; 1570 int get visibleLength;
1525 1571
1526 /** 1572 /**
1527 * If a local function, the beginning of the visible range; zero otherwise. 1573 * If a local function, the beginning of the visible range; zero otherwise.
1528 */ 1574 */
1529 @Id(21) 1575 @Id(21)
1530 int get visibleOffset; 1576 int get visibleOffset;
1531
1532 /**
1533 * If [kind] is [UnlinkedExecutableKind.constructor] and [isConst] is `true`,
1534 * a nonzero slot id which is unique within this compilation unit. If this id
1535 * is found in [LinkedUnit.constCycles], then this constructor is part of a
1536 * cycle.
1537 *
1538 * Otherwise, zero.
1539 */
1540 @Id(25)
1541 int get constCycleSlot;
1542 } 1577 }
1543 1578
1544 /** 1579 /**
1545 * Enum used to indicate the kind of an executable. 1580 * Enum used to indicate the kind of an executable.
1546 */ 1581 */
1547 enum UnlinkedExecutableKind { 1582 enum UnlinkedExecutableKind {
1548 /** 1583 /**
1549 * Executable is a function or method. 1584 * Executable is a function or method.
1550 */ 1585 */
1551 functionOrMethod, 1586 functionOrMethod,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 * Unlinked summary information about a function parameter. 1765 * Unlinked summary information about a function parameter.
1731 */ 1766 */
1732 abstract class UnlinkedParam extends base.SummaryClass { 1767 abstract class UnlinkedParam extends base.SummaryClass {
1733 /** 1768 /**
1734 * Annotations for this parameter. 1769 * Annotations for this parameter.
1735 */ 1770 */
1736 @Id(9) 1771 @Id(9)
1737 List<UnlinkedConst> get annotations; 1772 List<UnlinkedConst> get annotations;
1738 1773
1739 /** 1774 /**
1775 * Code range of the parameter.
1776 */
1777 @Id(14)
1778 CodeRange get codeRange;
1779
1780 /**
1740 * If the parameter has a default value, the constant expression in the 1781 * If the parameter has a default value, the constant expression in the
1741 * default value. Note that the presence of this expression does not mean 1782 * default value. Note that the presence of this expression does not mean
1742 * that it is a valid, check [UnlinkedConst.isInvalid]. 1783 * that it is a valid, check [UnlinkedConst.isInvalid].
1743 */ 1784 */
1744 @Id(7) 1785 @Id(7)
1745 UnlinkedConst get defaultValue; 1786 UnlinkedConst get defaultValue;
1746 1787
1747 /** 1788 /**
1748 * If the parameter has a default value, the source text of the constant 1789 * If the parameter has a default value, the source text of the constant
1749 * expression in the default value. Otherwise the empty string. 1790 * expression in the default value. Otherwise the empty string.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 * Unlinked summary information about a typedef declaration. 2021 * Unlinked summary information about a typedef declaration.
1981 */ 2022 */
1982 abstract class UnlinkedTypedef extends base.SummaryClass { 2023 abstract class UnlinkedTypedef extends base.SummaryClass {
1983 /** 2024 /**
1984 * Annotations for this typedef. 2025 * Annotations for this typedef.
1985 */ 2026 */
1986 @Id(4) 2027 @Id(4)
1987 List<UnlinkedConst> get annotations; 2028 List<UnlinkedConst> get annotations;
1988 2029
1989 /** 2030 /**
2031 * Code range of the typedef.
2032 */
2033 @Id(7)
2034 CodeRange get codeRange;
2035
2036 /**
1990 * Documentation comment for the typedef, or `null` if there is no 2037 * Documentation comment for the typedef, or `null` if there is no
1991 * documentation comment. 2038 * documentation comment.
1992 */ 2039 */
1993 @informative 2040 @informative
1994 @Id(6) 2041 @Id(6)
1995 UnlinkedDocumentationComment get documentationComment; 2042 UnlinkedDocumentationComment get documentationComment;
1996 2043
1997 /** 2044 /**
1998 * Name of the typedef. 2045 * Name of the typedef.
1999 */ 2046 */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 List<UnlinkedConst> get annotations; 2084 List<UnlinkedConst> get annotations;
2038 2085
2039 /** 2086 /**
2040 * Bound of the type parameter, if a bound is explicitly declared. Otherwise 2087 * Bound of the type parameter, if a bound is explicitly declared. Otherwise
2041 * null. 2088 * null.
2042 */ 2089 */
2043 @Id(2) 2090 @Id(2)
2044 EntityRef get bound; 2091 EntityRef get bound;
2045 2092
2046 /** 2093 /**
2094 * Code range of the type parameter.
2095 */
2096 @Id(4)
2097 CodeRange get codeRange;
2098
2099 /**
2047 * Name of the type parameter. 2100 * Name of the type parameter.
2048 */ 2101 */
2049 @Id(0) 2102 @Id(0)
2050 String get name; 2103 String get name;
2051 2104
2052 /** 2105 /**
2053 * Offset of the type parameter name relative to the beginning of the file. 2106 * Offset of the type parameter name relative to the beginning of the file.
2054 */ 2107 */
2055 @informative 2108 @informative
2056 @Id(1) 2109 @Id(1)
2057 int get nameOffset; 2110 int get nameOffset;
2058 } 2111 }
2059 2112
2060 /** 2113 /**
2061 * Unlinked summary information about a compilation unit ("part file"). 2114 * Unlinked summary information about a compilation unit ("part file").
2062 */ 2115 */
2063 @TopLevel('UUnt') 2116 @TopLevel('UUnt')
2064 abstract class UnlinkedUnit extends base.SummaryClass { 2117 abstract class UnlinkedUnit extends base.SummaryClass {
2065 factory UnlinkedUnit.fromBuffer(List<int> buffer) => 2118 factory UnlinkedUnit.fromBuffer(List<int> buffer) =>
2066 generated.readUnlinkedUnit(buffer); 2119 generated.readUnlinkedUnit(buffer);
2067 2120
2068 /** 2121 /**
2069 * Classes declared in the compilation unit. 2122 * Classes declared in the compilation unit.
2070 */ 2123 */
2071 @Id(2) 2124 @Id(2)
2072 List<UnlinkedClass> get classes; 2125 List<UnlinkedClass> get classes;
2073 2126
2074 /** 2127 /**
2128 * Code range of the unit.
2129 */
2130 @Id(15)
2131 CodeRange get codeRange;
2132
2133 /**
2075 * Enums declared in the compilation unit. 2134 * Enums declared in the compilation unit.
2076 */ 2135 */
2077 @Id(12) 2136 @Id(12)
2078 List<UnlinkedEnum> get enums; 2137 List<UnlinkedEnum> get enums;
2079 2138
2080 /** 2139 /**
2081 * Top level executable objects (functions, getters, and setters) declared in 2140 * Top level executable objects (functions, getters, and setters) declared in
2082 * the compilation unit. 2141 * the compilation unit.
2083 */ 2142 */
2084 @Id(4) 2143 @Id(4)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 * a field. 2232 * a field.
2174 */ 2233 */
2175 abstract class UnlinkedVariable extends base.SummaryClass { 2234 abstract class UnlinkedVariable extends base.SummaryClass {
2176 /** 2235 /**
2177 * Annotations for this variable. 2236 * Annotations for this variable.
2178 */ 2237 */
2179 @Id(8) 2238 @Id(8)
2180 List<UnlinkedConst> get annotations; 2239 List<UnlinkedConst> get annotations;
2181 2240
2182 /** 2241 /**
2242 * Code range of the variable.
2243 */
2244 @Id(14)
2245 CodeRange get codeRange;
2246
2247 /**
2183 * If [isConst] is true, and the variable has an initializer, the constant 2248 * If [isConst] is true, and the variable has an initializer, the constant
2184 * expression in the initializer. Note that the presence of this expression 2249 * expression in the initializer. Note that the presence of this expression
2185 * does not mean that it is a valid, check [UnlinkedConst.isInvalid]. 2250 * does not mean that it is a valid, check [UnlinkedConst.isInvalid].
2186 */ 2251 */
2187 @Id(5) 2252 @Id(5)
2188 UnlinkedConst get constExpr; 2253 UnlinkedConst get constExpr;
2189 2254
2190 /** 2255 /**
2191 * Documentation comment for the variable, or `null` if there is no 2256 * Documentation comment for the variable, or `null` if there is no
2192 * documentation comment. 2257 * documentation comment.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 */ 2333 */
2269 @Id(11) 2334 @Id(11)
2270 int get visibleLength; 2335 int get visibleLength;
2271 2336
2272 /** 2337 /**
2273 * If a local variable, the beginning of the visible range; zero otherwise. 2338 * If a local variable, the beginning of the visible range; zero otherwise.
2274 */ 2339 */
2275 @Id(12) 2340 @Id(12)
2276 int get visibleOffset; 2341 int get visibleOffset;
2277 } 2342 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.fbs ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698