Commit Graph

264 Commits

Author SHA1 Message Date
Dan Rubel dde9eb69a9 add handleInvalidMember to improve recovery
* add handleInvalidMember event
* update NodeListener to track invalidMemberCount
* update ClassMethodModifierContext to trigger handleInvalidMember
  event, reducing number of superflous errors.

Also, address comment
https://dart-review.googlesource.com/c/sdk/+/16040/1/pkg/analyzer/lib/src/fasta/ast_builder.dart#1580
Change-Id: I4c630faeee7731e2f85bbfaf0a6790bf6f4382b3
Reviewed-on: https://dart-review.googlesource.com/16100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2017-10-24 02:58:28 +00:00
Brian Wilkerson 9575182790 Pass the period in field formal parameters to listeners to enable recovery
Change-Id: I04975f3fb1aeb3b3b6b842e3373a792f13a91685
Reviewed-on: https://dart-review.googlesource.com/16000
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2017-10-23 20:57:00 +00:00
Brian Wilkerson a22c8dc958 Recover when enum constants have metadata
Change-Id: I1432c3b2d4ce63c5520087c79dd33e48c57cee5b
Reviewed-on: https://dart-review.googlesource.com/13102
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2017-10-12 20:50:31 +00:00
Dan Rubel efeaa0eab3 Class header recovery
This updates the fasta parser to handle out of order clauses
in the class header similar to analyzer.

Also:
* Fix parseTopLevelDeclaration in parser test proxy
* Fix parseStuff to correctly update token stream
* Extract skipUnexpectedTokenOpt
Change-Id: Ic20c0ab1355e866aa241c591ceeada390890c46a
Reviewed-on: https://dart-review.googlesource.com/9880
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-10-04 21:33:09 +00:00
Dan Rubel 5a67a64957 Refactor parseClass
Refactored the parseClass method in preparation for
adding recovery, updating error messages, and analyzer integration.

* Added several new parser events
    - handleClassExtends
    - handleClassImplements
    - handleClassHeader

* Revised the endClassDeclaration event

Change-Id: Ib58893097650eefb45051b462e9df7260b7776b2
Reviewed-on: https://dart-review.googlesource.com/9580
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-29 19:34:15 +00:00
Dan Rubel 9527f37146 refactor parse import
* `as` clause and `deferred as` clause processing pushed
     into a new processImportPrefixOpt method.
* New handleImportPrefix event for communicating 
    `as` clause and `deferred as` clause to the listeners.
* Several new more detailed error messages for out of order
    clauses and keywords in the import directive.

Change-Id: I133842c7225403fa000ca1cf0e49af9f8a011386
Reviewed-on: https://dart-review.googlesource.com/8580
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-29 14:39:01 +00:00
Dan Rubel f0caee1b24 Improve import directive recovery and report analyzer errors
- New handleRecoverImport event
    for clauses in import directive that are out of order
- New error codes for
    Duplicate prefix
    Prefix after combinator

Change-Id: I0fea7ad4b4014a0b8578d3982e0515fe85044854
Reviewed-on: https://dart-review.googlesource.com/7980
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-27 12:56:46 +00:00
Brian Wilkerson bd33fb43bd Pass the left brace in an enum declaration to the listeners (rather than the right brace)
Change-Id: I3bec6cbde6beb1233c48e7ed8926f0e98fd8e3a5
Reviewed-on: https://dart-review.googlesource.com/6741
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2017-09-19 15:35:33 +00:00
Dan Rubel db7129d8a4 cleanup endMetadataStar event
Change-Id: I9fcd69219858cdb063d3e37f2788750f72132d65
Reviewed-on: https://dart-review.googlesource.com/6140
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-09-15 12:37:37 +00:00
Dan Rubel d69a0aa3d5 revise parser to use handleNativeClause
modify the fasta parser to use handleNativeClause
when parsing methods with a native clause.

Change-Id: Ia631c471f9f8ea7a9e261d112a8ccd96f9eafa46
Reviewed-on: https://dart-review.googlesource.com/3786
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-09-14 13:25:48 +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
Paul Berry 16d505327b Rename handleBinary{Operator,Expression} to {begin,end}BinaryExpression.
This makes the names more consistent with the other parser listener
methods.

Change-Id: Ic9f636a520bcc40e0ed281963ff079d4ce0202db
Reviewed-on: https://dart-review.googlesource.com/4120
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
2017-09-08 18:03:51 +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
Dan Rubel d1385f099f support class native clause
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2996163002 .
2017-08-22 07:42:56 -04:00
Dan Rubel aefd73b8d3 new handleInvalidTopLevelDeclaration event in fasta parser
This adds a new event for better fasta parser recovery
when the parser detects an invalid character at the top level.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2985703002 .
2017-08-16 09:36:24 -04: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
Peter von der Ahé 3216bda008 Move parser helper classes to own files and clean them up.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2978063002 .
2017-07-18 13:02:41 +02:00
Dan Rubel 14b76d6b22 cleanup fasta parser send and expression events
* remove unused beginSend
* rename endSend to handleSend

* remove unused beginThrowExpression
* remove unused beginExpression event
* rename endThrowExpression to handleThrowExpression

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2976103002 .
2017-07-14 10:20:01 -04:00
Peter von der Ahé 710ddf02ff Remove all deprecated fasta message methods from analyzer.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2975823002 .
2017-07-11 09:26:27 +02:00
Peter von der Ahé b023d925ea Use FastaMessage instead of String. Part 1.
See #30080.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2965393002 .
2017-07-10 19:50:14 +02:00
Peter von der Ahé 9236a3445e Deprecate all diagnostics methods that use strings.
See #30080.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2970273004 .
2017-07-10 11:23:09 +02:00
Brian Wilkerson 62d0376231 Run the sorter to reduce code churn
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2933753002 .
2017-06-12 07:37:14 -07:00
Peter von der Ahé 61d855bb47 Prepare for development branch by updating externally-used API.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2898183002 .
2017-05-24 14:32:45 +02:00
Peter von der Ahé 6e0fd8ebb2 Update mini_ast.dart to new Listener interface.
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2896573002 .
2017-05-19 14:10:52 +02: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
Dan Rubel 81d25f4c71 more work aligning fasta.Token with analyzer.Token
* move isPseudo getter out of Token into TokenType
* move special case charCount logic out of fasta.Token into fasta.ErrorToken
* move more accessors from fasta.Token into analyzer.Token
* add @overrides to denote which methods have been declared in analyzer.Token
* make fasta LazySubstring and its subclasses private
* rename fasta.previousToken to previous to match analyzer.Token
* flatten fasta.Token.preceedingCommentTokens into preceedingComments
* normalize fasta.Token.next and analyzer.Token.next

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2872433005 .
2017-05-09 00:09:56 -04:00
Paul Berry 77d26a330c Add top level type inference logic for integer literals.
This CL hooks up enough infrastructure for doing simple top level type
inference of variables whose initializer is an int.

Additional type inference rules will be added in follow-up CLs.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2828253003 .
2017-04-21 04:38:18 -07:00
Dan Rubel 80c8479587 fasta.CommentToken implement analyzer.CommentToken
* update the fasta scanner to generate comment and dartdoc tokens

* replace fasta.preceedingComments field
  with preceedingCommentTokens field and preceedingComments getter/setter

* update token translator

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2763833002 .
2017-03-21 11:40:47 -04:00
Jens Johansen 4d208e2ffb [fasta] Add and correct even more offsets
E.g. kernel debugging of async functions should now work.

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2746013003 .
2017-03-21 10:57:30 +01:00
pq 09886f491f Remove unneeded strong_mode_down_cast_composite ignores.
As `strong_mode_down_cast_composite` is now a strong-mode hint these should no longer need to be explicitly ignored.

Follow-up from: https://github.com/flutter/flutter/pull/8853

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2755013003 .
2017-03-17 12:32:59 -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
Konstantin Shcheglov fa24d1caaa Stop generating index information for SDK and simplify summary generation.
The implementation is still element model based, I will switch it to
the AST based approach in a following CL.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2345793002 .
2016-09-15 16:15:20 -07: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 e31e7757d5 Move summary inspection code out of pkg/analyzer/lib.
It depends on mirrors, which aren't supported by Flutter.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2257563002 .
2016-08-17 12:15:16 -07:00
Brian Wilkerson c41427383b Deprecate DirectoryBasedDartSdk and transition existing uses to the new API
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2242853002 .
2016-08-12 09:18:12 -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
pq 9a75f18e47 Introduce build configuration to summary building.
Options are largely unused but are in line with what is specified in CLI to support `build_mode` bringing us a step closer to a unified summary builder and in the short term to a provisional API that should work for Flutter SDK generation experiments in the next alpha release.

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

Review URL: https://codereview.chromium.org/2078033002 .
2016-06-17 13:37:29 -07:00
pq 772972ad32 Make SDK summary writing available to analyzer clients.
Not API (in `lib/src`) but available nonethess to clients such as flutter who need to be able to write their own SDK summaries (and ideally not duplicate low-level flat_buffer interactions).

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

Review URL: https://codereview.chromium.org/2077583002 .
2016-06-16 15:09:42 -07:00
pq ed4dc77436 Switch statement cleanups.
BUG=
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2067973002 .
2016-06-14 12:34:08 -07:00
pq 1eefb68c25 SDK summary creation generalization (pt 1).
Steps towards generalizing summary creation bits (to allow for, among other things, flutter SDK summary creation).  API is provisional (note still in `lib/src`).

Next up:
* move result writing out of `tool/` to allow for reuse
* `SummaryBuilder.forPackageMap(..)` factory (or similar) for use in the flutter SDK case

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

Review URL: https://codereview.chromium.org/2055543002 .
2016-06-09 12:06:36 -07:00