Commit Graph

4276 Commits

Author SHA1 Message Date
Konstantin Shcheglov f7e81325d8 Resynthesize top-level accessors and variables from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987883003 .
2017-07-26 11:29:11 -07:00
Konstantin Shcheglov 89c58dd116 Don't resynthesize invalid constant expressions at all.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990733002 .
2017-07-26 11:13:07 -07:00
Erik Ernst 2e73ce1187 Revert "Implemented support for generalized void in analyzer."
This reverts commit 1d44f5296a,
because it causes failures for the analyzer in parser_test, error_test.

Review-Url: https://codereview.chromium.org/2990723002 .
2017-07-26 18:18:04 +02:00
Erik Ernst 1d44f5296a Implemented support for generalized void in analyzer.
Changed the analyzer parser to accept usages of `void` which were
previously rejected as syntax errors: `void` can now be the type
annotation for a variable or parameter, and it can be an actual type
argument.

Removed affected error codes like VOID_PARAMETER, VOID_VARIABLE,
VOID_RETURN_FOR_GETTER and associated declarations (like checking
functions), and adjusted test cases to expect success rather than
compile time errors.

Adjusted generalized_void_syntax_test.dart (it had real errors like
`final` variables with no initializer etc. that were not detected
when tools would just reject the file as syntactically wrong).

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2990703002 .
2017-07-26 17:45:13 +02:00
Dan Rubel 0b93c279e7 improve fasta closing brace recovery
Currently, fasta synthetically closes open braces until it finds
a match for the current closing brace. This works most of the time,
but provides less than optimal recovery in some common cases.
For example, given the following

class { foo()){print(a);} var a = 'hello'; }

the current brace recovery method fails to find any match for the
second closing parenthesis and synthetically closes the class
causing the rest of the file to be parsed as outside the class.

With this CL, fasta still synthetically closes open braces when it finds
a match for the current closing brace, but if there is no match, then
it just skips over the extra closer and continues. This approach dramatically
improves recovery in many cases where there is an extra closing parenthesis
or extra closing square bracket. In the example above, fasta parses
everything after the second closing parenthesis inside the class.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2981343002 .
2017-07-26 10:37:19 -04:00
Leaf Petersen c595972d74 Remove toplevel inference restriction hints, and restore as much
toplevel inference as possible to match the new front end toplevel
inference.

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2983293002 .
2017-07-25 15:57:07 -07:00
Konstantin Shcheglov 2b1e3a3b81 Resynthesize factoring constructor redirects from Kernel.
Generic redirects are not implemented yet, I was not able to find type
arguments in RedirectingFactoryBody.

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987863002 .
2017-07-25 14:54:33 -07:00
pq b72742e8da Update linter engine to use driver (linter#743).
R=brianwilkerson@google.com, scheglov@google.com

See: https://github.com/dart-lang/linter/issues/743
Review-Url: https://codereview.chromium.org/2992463003 .
2017-07-25 14:22:56 -07:00
Konstantin Shcheglov a2afba2be0 Resynthesize FunctionType(s) from Kernel.
Also fixes resynthesizing generic methods and functions.

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991723002 .
2017-07-25 13:14:35 -07:00
Konstantin Shcheglov 05f34f52d5 Resynthesize import prefixes from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983423003 .
2017-07-25 13:05:49 -07:00
Konstantin Shcheglov 939d8aaf6d Issue 30238. Fix for subscribing for a notifications with already cached analysis result.
With the new 'sendCachedToStream' option we can control that whether
cached analysis result is also reported into the 'results' stream when
it is desirable (when we do this to send analysis notifications from
the stream listener). Or not, when it is not desirable, e.g. when we
ask becaue we need the results unit for Quick Assists.

R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/30238

Review-Url: https://codereview.chromium.org/2989633002 .
2017-07-25 10:28:25 -07:00
Konstantin Shcheglov 7bdfd098f6 Extract KernelResynthesizer from tests into analyzer/lib.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990603002 .
2017-07-25 09:56:32 -07:00
Konstantin Shcheglov e0658b18a3 Resynthesize constructor initializers from Kernel.
We don't resynthesize assert initializers yet, because they are
compiled into an unholy mess.

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983413002 .
2017-07-25 09:24:13 -07:00
Jennifer Messerly ff8511c83e fix override checking of mixins
it was rejecting some patterns that are sound, because the mixin member is overridden and thus not exposed.

R=leafp@google.com

Review-Url: https://codereview.chromium.org/2988673003 .
2017-07-24 16:27:08 -07:00
Konstantin Shcheglov e3c418a3db Start marking @_fastaProblem, fix for unresolved mixin, fix for type parameter context.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2984153002 .
2017-07-24 11:50:12 -07:00
Konstantin Shcheglov ce4d7b1891 Restore UriReferencedElement and its uri/uriOffset/uriEnd properties.
This is a partial rollback of bdd69ccd6c,
it restores APIs and implementations, but does not restore its usages
in analyzer or analysis_server. Should be enough to make clients
temporary OK, but also keeps resynthesizing from Kernel working.

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

Review-Url: https://codereview.chromium.org/2991453002 .
2017-07-21 16:59:52 -07:00
Jennifer Messerly fb613c0635 fix #29766, fix #29782 - fix override checker's interface checking
R=vsm@google.com

Review-Url: https://codereview.chromium.org/2981183003 .
2017-07-21 16:02:52 -07:00
Paul Berry c057f091c2 Implement AstBuilder integration for method/function invocations.
This is tricky because there isn't a clean correspondence between
analyzer's AST (which reflects user syntax) and kernel representation.
For example:

  f(args);

could be a call to a static function f, a method f in the current
class, or an invocation of a function-typed object stored in a
variable called f.  ResolutionStorer operates on the kernel
representation, so it sees the difference, but ResolutionApplier
operates on the analyzer AST, so it does not.  So we go to some extra
work to make sure a type is stored for f, regardless of whether f is a
function, method, or a variable.  This requires some re-ordering logic
in ResolutionStorer, since the inferred type of f is not known until
after the args have been visited.

The implementation is not complete; currently the type that we store
in the first two cases is `dynamic` because the type inference
mechanism doesn't preserve enough information to allow us to determine
the correct type; this will be remidied in a future CL.

A similar situation occurs for:

  x.m(args);

which could be a call to a method m in the object x, or an invocation
of a function-typed object returned by the getter m in the object x.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2984013002 .
2017-07-21 10:47:25 -07:00
Konstantin Shcheglov ebd3ed5ade Resynthesize mixins from Kernel.
This adds Class.isSyntheticMixinImplementation flag which is set
to 'true' for synthetic X&Y classes.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2982373002 .
2017-07-21 10:29:46 -07:00
Konstantin Shcheglov 2289ce12ae Add import dependencies to Kernel libraries and use them to resynthesize ImportElement(s) in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987553002 .
2017-07-21 09:21:57 -07:00
Leaf Petersen 1eb480d266 Add --no-declaration-casts option to analyzer.
Adds a flag to disable and enable declaration casts independently
from other casts.

Fixes #29546

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

Review-Url: https://codereview.chromium.org/2976963002 .
2017-07-20 15:55:07 -07:00
Paul Berry cc97126aed Implement AstBuilder integration for parenthesized expressions.
The type inference engine doesn't even see parenthesized expressions
as a separate entity, since parentheses don't have any semantics.  So
we just copy the static type from the enclosed expression.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2982323003 .
2017-07-20 13:49:20 -07:00
Konstantin Shcheglov 70933930cb Resynthesize instance creation expressions from Kernel.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986593002 .
2017-07-20 12:57:27 -07:00
Paul Berry f1efb202d1 Implement AstBuilder integration for instance creation expressions.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2982323002 .
2017-07-20 12:52:10 -07:00
Konstantin Shcheglov 25e695a71a Resynthesize field formal parameters from Kernel.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2978353002 .
2017-07-20 10:59:54 -07:00
Paul Berry a93aee1a08 Further integration of front end type inference into analyzer.
This CL propagates types from top level variable declarations into
analyzer ASTs.

This required adding a finishFields method to parser listeners (and a
corresponding method DietListener.listenerFinishFields which calls
it); this allows AnalyzerDietListener to thread the types through from
the BodyBuilder to the AstBuilder.  This is similar to what we were
already doing for methods.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2987503003 .
2017-07-19 23:00:52 -07:00
Jennifer Messerly 132067f685 ignore @proxy in strong mode
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2980383002 .
2017-07-19 18:17:01 -07:00
Konstantin Shcheglov 607445ae9b Delay finishing dart:core and dart:async libraries until after TypeProvider is set for the context.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986493002 .
2017-07-19 14:55:49 -07:00
Konstantin Shcheglov bdd69ccd6c Remove UriReferencedElement with its uri/uriOffset/uriEnd properties.
The 'Move File' refactoring does not work, so I comment out most
of its code.

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

Review-Url: https://codereview.chromium.org/2982993003 .
2017-07-19 09:31:03 -07:00
Konstantin Shcheglov 9d5a249ed3 Resynthesize expressions for Kernel's StaticGet and PropertyGet.
Note, that we don't restore the original AST for StaticGet(s).
The original AST is not available in Kernel.
Instead we generate simple identifiers with correct elements.
It should be enough to compute constant values, although some clients
might have to adapt to the change.

R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983773002 .
2017-07-18 13:09:16 -07:00
Peter von der Ahé 3709ff5150 Add closeBraceTokenFor and use it instead of BeginToken.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2978073002 .
2017-07-18 13:57:10 +02: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
Peter von der Ahé c348f019ec Rename FunctionDeclaration to LocalFunctionDeclaration.
R=danrubel@google.com, johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2982033002 .
2017-07-18 12:35:41 +02:00
Konstantin Shcheglov e77482de7e Resynthesize literal expressions from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2978113002 .
2017-07-17 16:58:22 -07:00
Konstantin Shcheglov 32dd753aab Resynthesize class fields and accessors from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977263002 .
2017-07-17 16:43:20 -07:00
Konstantin Shcheglov 0c7e36bbfa Resynthesize top-level functions from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2978093002 .
2017-07-17 10:16:41 -07:00
Konstantin Shcheglov ea40294eb3 Resynthesize parameters from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2979133002 .
2017-07-17 10:11:53 -07:00
Konstantin Shcheglov 892d7caab3 Resynthesize methods from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2976263002 .
2017-07-17 08:37:32 -07:00
Konstantin Shcheglov 8a98f240a9 Resynthesize top-level variables from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2981943002 .
2017-07-15 10:06:46 -07:00
Konstantin Shcheglov d31fe5225d Resynthesize interfaces from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2981063002 .
2017-07-15 10:01:57 -07:00
Konstantin Shcheglov a9fbe224bc Add documentationComment for Class to Kernel. Parse it. Resynthesize in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977133002 .
2017-07-15 09:53:48 -07:00
Konstantin Shcheglov 41e1087dcc Resynthesize InterfaceType, class type parameters and supertype.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977983002 .
2017-07-14 15:08:28 -07:00
Konstantin Shcheglov 592357028e Resynthesize factory constructors from Kernel.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977963003 .
2017-07-14 14:04:25 -07:00
Dan Rubel bb9ba11c6c translate more fasta error codes to analyzer error codes
R=ahe@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2978993002 .
2017-07-14 12:31:13 -04:00
Dan Rubel f12be9d64d more fasta event cleanup and testing
* make _end(optional: false) which uncovered unbalanced begin/end pairs
* update and document top level member events
* rename handleSwitchCase to endSwitchCase to better align with beginSwitchCase
* update and document begin/endFor/endForIn events
* cleanup test listener

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

Review-Url: https://codereview.chromium.org/2980043003 .
2017-07-14 12:28:09 -04:00
Konstantin Shcheglov 5f545f1305 Resynthesize constructor properties.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2980963002 .
2017-07-14 08:58:09 -07: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
Konstantin Shcheglov 0d9357431d The very first bits of resynthesizing elements from kernels.
Just parts of library, defining unit and class for now.
This is enough to pass 15 tests out of 522 :-)
Although some of them are passing accidentally.

Only strong mode tests for now.

We don't compare with Analyzer elements created using Analyzer builders,
because these builders will go away. But we miss testing for things
like name offsets.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2980863003 .
2017-07-13 22:20:55 -07:00
Paul Berry df91c79078 Further integration of front end type inference into analyzer.
This CL propagates types for simple variable declarations into analyzer ASTs.

Note that for a variable declaration like `int x` we need to store two
pieces of information: the element pointed to by `int`, and the type
of `x`.  This CL handles the latter.  The former will wait until we
have enough of the element model built that we have an element to
point to.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2980053002 .
2017-07-13 14:42:05 -07:00
Paul Berry 04ad043f49 Remove code associated with the old "kompile" functionality.
This code is no longer needed because we no longer run the front end
in "kompile" mode.

Also remove the old expectations files used by the "kompile" tests.

I will remove more code in future CLs.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2980883003 .
2017-07-13 12:18:44 -07:00