Commit Graph

51 Commits

Author SHA1 Message Date
Brian Wilkerson 602a8c2a7b Clean up usage of deprecated constants
Change-Id: I9005ba6e94529e15d8f7b21322591f4a9dabec47
Reviewed-on: https://dart-review.googlesource.com/45763
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-09 01:02:49 +00:00
Paul Berry 70f2969b6c Create a uniform mechanism for finding the 'pkg' directory when running tests.
Several tests need to access source files in the 'pkg' directory, and
they use various mechanisms for finding it.  This CL changes
everything to use the same mechanism.

Change-Id: I146a6d72ec05a20cf07451a83eada9fb8e71a966
Reviewed-on: https://dart-review.googlesource.com/5484
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-09-13 20:05:40 +00:00
Konstantin Shcheglov f78d43c3d3 Convert GeneratedContent to async and use AnalysisDriver for tasks graph.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/3002293003 .
2017-08-26 07:51:34 -07:00
Paul Berry e2f77056a5 Eliminate dependencies on pkg/front_end.
The API for pkg/front_end is still in flux so we want to avoid having
any packages depend directly on it (other than analyzer and
back-ends).

This CL re-exports some of the critical pieces of front_end needed by
analyzer clients so that those clients can access them via analyzer,
without having to directly depend on front_end.  It also updates
pkg/analyzer_plugin to make use of those re-exports.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2993123002 .
2017-08-07 09:46:30 -07:00
Dan Rubel 278c7bfbeb merge fasta.Token into analyzer.Token
This eliminates much of the duplication between the two token hierarchies
by merging much of the fasta.Token hierarchy into the analyzer.Token.

* merge token hierarchies
* cleanup fasta.Token.copy()
* set preceedingComments field via constructor
* replace isBuiltInIdentifier --> type.isBuiltIn
* change all fasta.Token references to analyzer.Token
* move fasta.Token.value() implementation into analyzer.SimpleToken

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2890523002 .
2017-05-16 11:50:14 -04:00
Konstantin Shcheglov 02cb71685e Move flat_buffer and api_signature into front_end.
I will need to use these in front_end to store precomputed information
and computing combined signatures.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2875373002 .
2017-05-12 10:48:28 -07:00
Paul Berry c78b4d66bb Move some of analyzer's code generation utilities into front_end.
These utilities are needed for generating the code that supports
summaries; in order to move summary logic into front_end, we will need
these code generation tools in front_end as well.

Also make a minor change to summary code generation logic so that it
talks to the file system directly rather than depending on analyzer's
file system abstraction.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2742333005 .
2017-03-14 12:30:18 -07:00
Paul Berry 2457a79b48 Change summary code generator to use Fasta parser.
The end goal is to move summary logic to the front end, which means
that it won't be able to depend on analyzer.  This removes a key
dependency on analyzer (the dependency of the code generator on the
analyzer parser).

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2748803003 .
2017-03-14 10:36:45 -07:00
Brian Wilkerson 22f561e914 Reapply "Add support for generic function type syntax, part 1"
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2622303006 .
2017-01-11 14:10:05 -08:00
Brian Wilkerson 85b1e7abbe Revert "Add support for generic function type syntax, part 1"
Review-Url: https://codereview.chromium.org/2624283003 .
2017-01-11 13:30:52 -08:00
Brian Wilkerson 1cd918533d Add support for generic function type syntax, part 1
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2613383003 .
2017-01-11 13:12:10 -08:00
Brian Wilkerson ecc84b26a4 Break up another large file
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2342733002 .
2016-09-15 07:49:27 -07:00
Konstantin Shcheglov 35bf41691e Change summaries setter generation to allow properties named 'value'.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2339053002 .
2016-09-15 07:08:38 -07:00
Konstantin Shcheglov 663a3e810c Reapply abc5051854: Remove 'Element.docRange'.
I also marked the corresponding information in summaries as @deprecated
and made a small tweak to the generator so that it knows that the ids
of deprecated fields are still used.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2330813002 .
2016-09-11 09:41:53 -07:00
pq b7f0ce083b Revert "Remove 'Element.docRange'."
This reverts commit abc5051854.

Background: required to keep `analyzer` version-compatible with `test`.

BUG=
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2293143003 .
2016-08-30 13:10:15 -07:00
Konstantin Shcheglov abc5051854 Remove 'Element.docRange'.
I also marked the corresponding information in summaries as @deprecated
and made a small tweak to the generator so that it knows that the ids
of deprecated fields are still used.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2270903002 .
2016-08-24 09:40:23 -07:00
Paul Berry 70bd623f36 Add an "api signature" to summaries.
The API signature of a summary is an MD5 hash of the API of the code
being summarized.  This will be used by analysis server to detect when
a summary needs to be relinked (because it was built with reference to
another summary whose API has since changed).

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2216873003 .
2016-08-04 16:12:49 -07:00
Paul Berry efe5a31421 Remove "_finished" assertion checks from summary codegen.
These assertions were helpful back when the client manually managed
offsets.  Now that offsets are managed automatically by the toBuffer()
logic, they don't carry any benefit.

Removing these assertions will pave the way for allowing a summary to be
created, serialized, modified, and then serialized again, which we will
need to do to efficiently generate both "full" and "semantic" summaries.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2110693002 .
2016-06-28 16:22:57 -07:00
Konstantin Shcheglov 0f441fa3ea Use BufferContext + offset instead of BufferPointer.
This lets us avoid creating tens of millions of BufferPointer instances
and makes DDC compilation about 6% faster.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1998833002 .
2016-05-19 20:08:26 -07:00
Konstantin Shcheglov 58bde1b3b4 Add the --build-summary-exclude-informative flag.
It (in combination with --build-summary-only-diet) makes the
package:path summary is almost 3 times smaller, partially because of
skipping bodies, patially because of excluding documentation comments,
and partially because of making 'codeRange' fields informative.

We also remove MD5 hashes.

As I can see after changes in method bodies we generate the exactly
same file (or at least 'cmp -l' thinks so). Adding a new field results
in a file of different length.

R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1828973002 .
2016-03-24 08:20:56 -07:00
Paul Berry ff6a744f38 Implement forwards compatibility for summary enums.
If an attempt is made to read an unrecognized enum value, then rather
than crashing, we will read the default (first) value of the enum type.

This facilitates forwards compatibility by ensuring that if a new enum
value is added in the future, older code will still be able to read the
resulting summary files without crashing.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1747413002 .
2016-03-01 13:28:10 -08:00
Paul Berry 9a983bcbda Add the ability to deprecate Flatbuffer fields.
If an IDL field is marked as `@deprecated`, no setter will be
generated for it, and the getter generated for it will throw an
UnimplementedError.  This is similar to the behavior of standard
Flatbuffer tools (which generate neither setters nor getters for
deprecated fields) except that we have to generate a getter in order
to avoid warnings.

Once we have begun using summaries in the wild, we will need to make
use of this feature in order to avoid changing Id numbers and breaking
backwards compatibility.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1753883002 .
2016-03-01 13:25:02 -08:00
Konstantin Shcheglov 7d0fbd1b11 Separate 'isQualified' flags as List<bool>.
It turned out that for used names we don't need any flags because we
want to store only qualified unresolved (potential) class member
usages. So, no flags for used names at all, at least for now.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1750163003 .
2016-03-01 11:06:40 -08:00
Paul Berry e399f0f5a7 Generate a ".fbs" file representing the summary format.
This file can be consumed by standard flatbuffer tools, allowing
summaries to be consumed from other languages.  For example, a summary
file can now be converted to JSON using:

    flatc -o $outputDirectory -t \
        pkg/analyzer/lib/src/summary/format.fbs -- $inputFile

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1743713002 .
2016-02-26 10:53:33 -08:00
Paul Berry 7481eff6a8 Add file identifiers to summaries.
These should make it easier for summary files to interoperate with
standard FlatBuffer tools.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1738833004 .
2016-02-25 10:36:42 -08:00
Paul Berry 4cd82a693e Generate useful toString() methods for summary classes.
This should make debugging easier.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1712023002 .
2016-02-19 08:33:13 -08:00
Brian Wilkerson 71e7ed86c0 Move scanner out of generated and clean up imports
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1693083004 .
2016-02-14 07:48:44 -08:00
Paul Berry 92ad0e0cba Store enums in summary file as bytes.
Reduces SDK summary file size by about 1%.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1690183003 .
2016-02-12 10:57:14 -08:00
Paul Berry 5a58e09639 Make summary format stable when adding getters to idl.
This mechanism is the same as the "id" mechanism described in
http://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html,
except that for us the ids are always mandatory.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1691923002 .
2016-02-11 14:38:24 -08:00
Paul Berry 71b593f89e Minor improvements to list representation in flatbuffers.
This CL makes the following changes:

- Renames _FbInt32List to _FbGenericList, and makes it able to
  represent lists of entities whose size isn't 4.

- Adds Uint32ListReader and _FbUint32List classes, which are
  specialized to handle lists of 32-bit unsigned ints.

- Moves common elements of all _Fb*List classes to the _FbList base
  class.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1685263003 .
2016-02-11 12:14:29 -08:00
Paul Berry 3057754843 Use summary IDL file for interface classes.
This CL makes a small change to the format of the summary IDL file:
instead of containing classes with fields, it now contains classes
with getters.  This allows the classes in the IDL file to be directly
used as interface classes, which makes code navigation much smoother.

Since the IDL file is now being used directly by the code, it has been
relocated to pkg/analyzer/lib/src/summary/idl.dart.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1667723002 .
2016-02-03 08:57:44 -08:00
Paul Berry 5e27219e9a Modify summary codegen so that builder getters return builders.
This should allow more flexibility in the code that creates summaries,
since it will be possible to things like:

    FooBuilder foo = new FooBuilder(bar: new BarBuilder);
    foo.bar.baz = ...;

(Previously this would have been disallowed because foo.bar would have
returned a `Foo` rather than a `FooBuilder`, and the `Foo` class doesn't
have a setter for `baz`).

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1606283003 .
2016-01-21 11:26:53 -08:00
Konstantin Shcheglov b0704262d9 Generate documentation for enumeration values.
I missed it previous time, now noticed that format.dart does not change
when I update the idl.dart file constant operations.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1617123002 .
2016-01-21 10:59:49 -08:00
Konstantin Shcheglov 6794b47c38 Use Uint32 for int in IDL.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1615453002 .
2016-01-20 14:40:44 -08:00
Konstantin Shcheglov 0a495243c6 Validate that int values that we write to summaries are >= 0.
Also make tweaks for TestTypeProvider to ensure that this is true.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1605763007 .
2016-01-20 13:38:10 -08:00
Konstantin Shcheglov 028254cea1 Generate code UnlinkedConst / UnlinkedConstOperation.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1596703002 .
2016-01-17 08:58:35 -08:00
Konstantin Shcheglov 6f5082ea7c Generate enum readers.
This is just nicer for the clients, plus also will allow us to use
these readers in lists.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1589823007 .
2016-01-15 15:05:56 -08:00
Paul Berry ba31abe429 Use constructor args in favor of summary "encode" functions.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1585973004 .
2016-01-14 09:30:04 -08:00
Paul Berry c1642e9d9f Make summary builder classes implement summary interfaces.
This allows for easier unit testing, since we can use a builder class
directly rather than having to serialize and deserialize it.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1581993002 .
2016-01-13 08:54:48 -08:00
Konstantin Shcheglov 65f1aa1ef0 Cache values of fields and lists in summary implementations.
This significantly improves analysis time of a trivial HTML app.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1579663002 .
2016-01-11 09:29:23 -08:00
Konstantin Shcheglov 5e326a505c Remove BuilderContext from summary builders.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1577663002 .
2016-01-10 14:03:41 -08:00
Konstantin Shcheglov 7b21739c27 Use addBool() and BoolReader in summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1570383002 .
2016-01-09 14:57:17 -08:00
Konstantin Shcheglov 68bf8244f8 Use FlatBuffers for summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1576663002 .
2016-01-09 10:55:00 -08:00
Konstantin Shcheglov dfda5d273a Generate documentation for summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1563453002 .
2016-01-05 09:53:48 -08:00
Paul Berry 8a445a3f01 Introduce code to generate UnlinkedPublicNamespace directly from an AST.
This is an initial step towards allowing the entire summary to be
generated directly from the AST rather than requiring an element model
to be built.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1544213002 .
2015-12-25 19:17:59 -08:00
Konstantin Shcheglov 69068313c6 Allow String and List<String> in summary IDL.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1533213002 .
2015-12-20 10:05:59 -08:00
Paul Berry f1ea359020 Fix "if" conditions in summary Builder setters.
Previously, we were generating code like:

    if (_value != null || _value == <default>) {
      <store _value in the summary>
    }

which meant that (a) default values were being unnecessarily stored in
the summaries, and (b) passing null to a summary Builder setter would
have caused a crash.

This CL modifies the code generator to output code like this:

    if (!(_value == null || _value == <default>)) {
      <store _value in the summary>
    }

which has the intended behavior of treating `null` like the default
value, and suppressing the default value from appearing in the summary.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1539953002 .
2015-12-18 10:23:03 -08:00
Paul Berry 9cff7ca404 Ensure that summary builders aren't used after call to finish()
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1522123002 .
2015-12-14 08:59:20 -08:00
Paul Berry 178cebb634 Modify summary Builder classes to avoid the use of Object.
Instead of passing around opaque Objects which are the result of
calling the Builder.finish() methods, we pass around the Builder
objects themselves, and we call finish() from within the generated
code.  This pushes the lack of type safety into the generated code,
leaving the handwritten code type safe.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1452363002 .
2015-11-17 15:50:26 -08:00
Paul Berry 74f09b99f1 Introduce code to generate summaries from an element model.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1420053011 .
2015-11-11 13:17:59 -08:00