Commit Graph

3034 Commits

Author SHA1 Message Date
Brian Wilkerson b8755a97a2 Triage the newly added tests for Fasta
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/3004063002 .
2017-08-30 07:37:15 -07:00
Brian Wilkerson ce952b77ab Add simple tests for Fasta parser
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/3011553002 .
2017-08-29 12:42:12 -07:00
Brian Wilkerson 75ee4aa546 Run the parser recovery tests under fasta
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/3008783002 .
2017-08-29 11:30:21 -07:00
Brian Wilkerson 893d2f6b81 Move one test to run under Fasta, sort files
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/3004843002 .
2017-08-29 10:27:40 -07:00
Dan Rubel 059e877d23 report abstract as extraneous modifier
R=ahe@google.com

Review-Url: https://codereview.chromium.org/3004683002 .
2017-08-29 11:00:35 -04:00
Peter von der Ahé 1b5cbc7694 Add debug names to scopes.
R=johnniwinther@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2995023002 .
2017-08-29 11:19:50 +02:00
Dan Rubel 8786656783 map fasta error codes to analyzer
Rather than have multple fine grained error codes for each type
of modifier in each situation, this CL adds a new analyzer
ParserErrorCode.EXTRANEOUS_MODIFIER parallel to the fast parser
error code and updates the AstBuilder to generate that error
rather than ParserErrorCode.ABSTRACT_CLASS_MEMBER.

My goal is to review each analyzer error code similar to
ParserErrorCode.ABSTRACT_CLASS_MEMBER and map each to the same
ParserErrorCode.EXTRANEOUS_MODIFIER error code.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2999303002 .
2017-08-25 09:00:18 -04:00
Konstantin Shcheglov 556b0284b3 Report compile time errors when assert initializers fail.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/3003363002 .
2017-08-24 14:48:15 -07:00
Dan Rubel 69e9106ead improve fasta export directive recovery
R=ahe@google.com

Review-Url: https://codereview.chromium.org/3001993002 .
2017-08-22 16:52:23 -04: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 bf7d6530b4 fasta parser test for analyzer error codes
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2999163002 .
2017-08-17 13:27:30 -04:00
Dan Rubel dd10e9ff06 update AstBuilder to support part of <uri>
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/3001003002 .
2017-08-17 08:52:10 -04:00
Dan Rubel 6a958b3edb refactor AstBuilder
Refactor the AstBuilder to use scriptTag, directives, and declarations
fields rather than pushing top level nodes on a generic stack
and later popping and sorting objects from the that generic stack.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2995963002 .
2017-08-16 09:47:27 -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
Konstantin Shcheglov 2923edc4c0 Check for null constructor field initializer expression.
When the initializer expression is null, this means that we detected that it was not actually a constant expression.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/3000743002 .
2017-08-11 12:35:19 -07:00
Dan Rubel 02ce510601 translate missing ">" fasta error code to analyzer error
Fix #30320

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2996673002 .
2017-08-11 15:29:49 -04:00
Brian Wilkerson 471b7fd568 Emit a hint when using generic method comment syntax (issue 30356)
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2990383002 .
2017-08-08 09:12:26 -07:00
Dan Rubel 6e4f00a27c fasta listener assert enclosing event
The fasta parser generates begin/end event pairs such as
[beginCompilationUnit] and [endCompilationUnit].
Each event should be generated "within" a "higher level" begin/end event pair,
except for [beginCompilationUnit] and [endCompilationUnit],
which should not be generated within any begin/end event pair.

This CL updates the fasta test listener and associated test code to assert that
[endTopLevelDeclaration] is generated within or is enclosed by
a begin/end "CompilationUnit" event pair, and that the [beginCompilationUnit]
and [endCompilationUnit] events are not enclosed by any begin/end event pairs.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2993833002 .
2017-08-07 14:22:01 -04:00
Paul Berry 89c910b9c1 Move byte_store.dart and file_byte_store.dart to their own subdirectory.
This allows us to use the subpackage relationships test to verify that
they don't import any other parts of front_end, which paves the way
for the possibility of moving them to their own package in the future.

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

Review-Url: https://codereview.chromium.org/2990323002 .
2017-08-07 11:04:48 -07:00
Brian Wilkerson 4c635b7b85 Initial support for an explicit plugin list
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2988343002 .
2017-08-02 11:30:57 -07:00
Dan Rubel dcd8c471ef update fasta parser compatibility tests to check error codes
This updates the analyzer parser compatibility tests to check for
error codes. Any test that was passing but failed as a result of these
changes was updated to continue passing and a duplicate test'2' added
in the subclass and marked as failing.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2990003002 .
2017-07-30 23:12:41 -04:00
Konstantin Shcheglov bf25080cc1 Replace typed_mock with mockito in analyzer.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991913002 .
2017-07-27 16:15:17 -07:00
Erik Ernst 9336e199fd Re-land of CL 2990703002, adding fixes to analyzer_test and error_test.
This CL is identical to the reverted CL 2990703002 which implements
syntactic support for generalized void in the analyzer, plus two bug
fixes in pkg/analyzer/test/generated/parser_test.dart and
pkg/analyzer_cli/test/error_test.dart. In the former, a test on parsing
`void,` was changed to expect an error: _isTypeIdentifier on a lone
`void` will no longer return true, which is necessary because `void`
can now be used as a type annotation alone. Another test on `void x`
was added, which produces the behavior previously seen for `void,`.
In error_test, the error which is used throughout was changed from
`void foo;` to `var int foo;` (because the former is no longer an
error).

Review-Url: https://codereview.chromium.org/2992623002 .
2017-07-27 12:39:19 +02: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
Dan Rubel 3b2625ccde rename test methods and format
* rename usingFasta --> usingFastaParser
* add usingFastaScanner
* apply dartfmt

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2981283002 .
2017-07-20 09:51:43 -04: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
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
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 00d5012906 Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt.
...instead of mixing formatting with actual changes in many CLs.

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

Review-Url: https://codereview.chromium.org/2975253002 .
2017-07-13 16:28:18 -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
Paul Berry b87556e00d Start copying resolution/inference data from front end to analyzer ASTs.
This CL lays the groundwork for integrating the front end with
analyzer by creating a mechanism to copy resolution and type inference
information (produced by the front end's type inference engine) into
analyzer ASTs (produced by AstBuilder).

The general technique is to parse each function twice: once with
BodyBuilder as a listener and once with AstBuilder as a listener.  The
BodyBuilder generates a kernel representation of the function, but
this isn't used; instead, type inference and resolution information is
captured using ResolutionStorer (which is a TypeInferenceListener).
Later, this information is applied to the analyzer AST generated by
AstBuilder using ResolutionApplier (which is an analyzer AST visitor).

At the moment the intermediate data exchanged between ResolutionStorer
and ResolutionApplier is simply a list of types (one for each
subexpression, in a post-order traversal of the program syntax).  For
debugging and validation purposes, this is augmented with a list of
file offsets, so that if the ResolutionStorer and ResolutionApplier
get out of sync we can diagnose the problem easily.

In later CLs, more data will need to be exchanged between
ResolutionStorer and ResolutionApplier (e.g. a list of elements to
which identifiers are resolved).

This CL doesn't tackle the problem of translating between the kernel
and analyzer representation of types; for now we simply map each type
to `dynamic`.  This is sufficient for early development, since it is
still enough to let us verify that ResolutionStorer and
ResolutionApplier stay in sync.

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

Review-Url: https://codereview.chromium.org/2981693002 .
2017-07-13 08:55:29 -07:00
Dan Rubel 6e87f881cf track fasta parser begin/end event pairs
This is a first cut at tracking fasta parser events
to ensure that I don't break them when improving parser recovery
and integrating the fasta parser into analyzer.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2975123002 .
2017-07-13 11:49:08 -04:00
Peter von der Ahé 83e4138cd4 Remove deprecated api from LibraryBuilder.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977713002 .
2017-07-12 22:31:13 +02:00
Peter von der Ahé 59e9638232 Remove deprecated methods from ClassBuilder.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977693002 .
2017-07-12 21:59:46 +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
Konstantin Shcheglov 4323722416 Stop using ExecutableElement.functions in tests.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2965423002 .
2017-07-07 13:05:38 -07:00
Konstantin Shcheglov 2c064df145 Remove visitLabelElement() and visitLocalVariableElement().
These elements are not parts of the bigger element model, so it
does not make sense to implement these visit methods.

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

Review-Url: https://codereview.chromium.org/2971253002 .
2017-07-07 08:04:59 -07:00
Jennifer Messerly 90380dfdfa fix #27259, implement covariance checking for strong mode and DDC
R=vsm@google.com

Review-Url: https://codereview.chromium.org/2954523002 .
2017-07-06 14:31:35 -07:00
Brian Wilkerson e454986288 Add code to run more tests from test_all
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2968233002 .
2017-07-06 12:24:01 -07:00
Konstantin Shcheglov 4f7a4f443d Remove ExecutableElement.labels usages in tests.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2974513002 .
2017-07-06 11:44:32 -07:00
Konstantin Shcheglov ee177cb51e Remove other usages of ExecutableElement.localVariables.
Use AST to find LocalVariableElement(s), don't test for empty.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2971893002 .
2017-07-05 14:33:09 -07:00
Konstantin Shcheglov e64c18435f Issue 30028. Fix for invoking loadLibrary() for deferred library with invalid URI.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/30028

Review-Url: https://codereview.chromium.org/2968763002 .
2017-06-30 10:32:25 -07:00
Konstantin Shcheglov 077b6b687d Remove incremental: logger, validator, options.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2968473002 .
2017-06-29 11:51:12 -07:00
Brian Wilkerson 563720617c Allow trailing comma in assert
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2961063002 .
2017-06-28 10:46:44 -07:00