Commit Graph

8489 Commits

Author SHA1 Message Date
Paul Berry 306625d1bb Fix computation of documentationComment for class type aliases.
R=brianwilkerson@google.com, pquitslund@google.com

Review URL: https://codereview.chromium.org/1567243002 .
2016-01-08 10:37:13 -08:00
Paul Berry 55a3de53dc Set LibraryElement.entryPoint properly during summary resynthesis.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1561073007 .
2016-01-08 10:31:59 -08:00
John Messerly 4ab45e1415 guard against null staticInvokeType
this can happen if we don't have a static element

R=paulberry@google.com

Review URL: https://codereview.chromium.org/1567223002 .
2016-01-07 15:52:56 -08:00
Konstantin Shcheglov 5d7e5cc4bd Initial flat buffers implementation.
It supports tables and lists.

Virtual tables are not shared yet.

Construction is done forward.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1564913004 .
2016-01-07 15:21:44 -08:00
John Messerly 924f2f97b7 clean up generic methods in resolution
Introduces MethodInvocation.staticInvokeType to track the type of this invocation. This provides a natural place to store the instantiated generic function type. We then use this type when we are computing corresponding parameters or return types. As a result we do not need FunctionMember, and some of the code around generics becomes simpler/more uniform.

This approach should be a straightforward way to add support for generics in FunctionExpressionInvocation, in a follow up (see issue #25175).

Also renames "boundTypeParameters" to "typeFormals". "formals" and "actuals" is a pretty common way to describe these, I'm not sure why I didn't think of that better name originally. :)

Also removes broken ParameterMember.== that I had added in a previous CL. And the broken FunctionTypeImpl.originalFunction/instantiatedTypeArguments getters.

Finally, this fixes #23252 in the process of adding this. The return type of a "call" method was not being statically analyzed if the target was a VariableElement.

R=brianwilkerson@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1568643002 .
2016-01-07 14:51:36 -08:00
Paul Berry acc709b46b Add Element.nameOffset and LibraryElement.nameLength to summaries.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1569033002 .
2016-01-07 14:47:14 -08:00
Paul Berry f6a8f29ef0 Add uriOffset and uriEnd to the summary.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1565283002 .
2016-01-07 12:55:44 -08:00
Paul Berry 0e2393f903 Fix some corner cases of resynthesizing generic function types.
We weren't always setting FunctionTypeImpl._isInstantiated correctly,
resulting in incorrect types in some rare corner cases.  I've added a
public `isInstantiated` getter so that we can check this more
thoroughly in unit tests.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1569923002 .
2016-01-07 11:52:11 -08:00
Paul Berry 82497c1bee Fix resynthesis of variables/fields with implicit types.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1569633003 .
2016-01-07 09:32:54 -08:00
Brian Wilkerson 2173e44e0b Merge pull request #25343 from guillermooo-forks/doccomment-markers
allow for selectively writing begin/end doc comments markers
2016-01-07 07:16:13 -08:00
Leaf Petersen d11800e8f5 Fix type parameter element resolution for generics
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1567733002 .
2016-01-06 14:15:48 -08:00
Paul Berry 9d5e7bf83d Add a count of type parameters to UnlinkedPublicName.
This will be necessary to allow summaries to be relinked.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1558353003 .
2016-01-06 11:34:21 -08:00
Konstantin Shcheglov 5debf16e88 Tests for SummarySdkAnalysisContext.
The tests use the Dart SDK summary file which we include with the tests.

Not uploading the patch for pkg/analyzer/test/src/summary/sdk_analysis_summary because the file is too large.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1567583002 .
2016-01-06 08:18:52 -08:00
Paul Berry 2a4d803b32 Test and fix resynthesized function-typed parameters referring to type parameters.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1560343002 .
2016-01-06 07:50:49 -08:00
Paul Berry 5d47028137 Eliminate constructor return types from summaries.
These can be easily inferred at the time the summary is resynthesized
into an element model.  This should make the summary size marginally
smaller, and make it easier to create summaries straight from the AST.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1565643002 .
2016-01-06 06:47:58 -08:00
Paul Berry a318062285 Test and fix resynthesized FunctionTypeImpl type args/params.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1560923002 .
2016-01-05 15:55:18 -08:00
John Messerly e2fa77776c fix hints from analyzer in analyzer
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1559923006 .
2016-01-05 15:19:04 -08:00
Konstantin Shcheglov 3d3b875661 Parse generic function declarations with/without type.
Currently we parse only 'void' generic function declarations.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1560663004 .
2016-01-05 14:52:41 -08:00
Konstantin Shcheglov 22b044ca20 Use SummarySdkAnalysisContext if the SDK has the analysis_summary file.
This file does not exist yet, so it should be safe to have incomplete
implementation for now.

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

Review URL: https://codereview.chromium.org/1555093005 .
2016-01-05 12:31:49 -08:00
Paul Berry ed783f3caa Compute FunctionTypeImpl type parameters lazily.
This will allow a FunctionTypeImpl to be constructed without having to
consult the underlying element, which is necessary to allow the
element model to be reconstituted from a summary.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1557213002 .
2016-01-05 12:05:22 -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
guillermooo 5367cd35bc allow for selectively writing begin/end doc comments markers
If a marker is null, it won't be written. For all other strings,
they'll be written as they are, including the empty string.

This enables nicer output for languages that don't have begin/end
markers for doc comments, such as Python.
2016-01-05 12:12:50 +01:00
Konstantin Shcheglov 3260f3561e Tweaks for compatibilities with summaries.
We cannot use runtimeType anymore, and have to use location.
As I can see this does not cause any significant performance degradation.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1553253002 .
2016-01-04 20:40:04 -08:00
Paul Berry 1bfb1bb612 Clean up resynthesis of typeArguments.
Previously, we had to jump through hoops to properly resynthesize
InterfaceTypeImpl.typeArguments and FunctionTypeImpl.typeArguments,
because the correct set of type arguments depends on the number of
type parameters, and that information wasn't available in the
prelinked summary.  Now it is.

Note that typeParameters and boundTypeParameters still aren't
resynthesized properly (and are untested).  These will be addressed in
a future CL.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1559123002 .
2016-01-04 16:13:18 -08:00
Paul Berry e626abcebc Encode number of type parameters in prelinked summary.
In a future CL, this should allow the element model to be
resynthesized from a summary more efficiently, since it won't be
necessary to consult the referenced elements when resynthesizing a
FunctionTypeImpl.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1555233002 .
2016-01-04 15:37:35 -08:00
John Messerly fcc84d1a03 fix #25305, DeclarationResolver.visitTypeParameter now handles generic methods
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1555213002 .
2016-01-04 15:22:48 -08:00
Konstantin Shcheglov 0eb91d0eef Test for changing method to/from getter/setter.
It does not match, so is not incrementally resolved.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1560433002 .
2016-01-04 13:29:22 -08:00
Brian Wilkerson dff4089ff2 First step towards a public API for AST nodes
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1558843002 .
2016-01-04 10:44:25 -08:00
Konstantin Shcheglov a2d615e52a Replace ResultProvider with 'aboutToComputeResult'.
This way we would be able to redirect to the SDK context, or get some
results from packages. Setting ResultProvider into AnalysisDriver does
not allow us to do this.

My quick and dirty experiment with using SDK summaries is broken now,
but I'm going to start updating actual SdkAnalysisContext using
summaries, if the bundle exists in the SDK.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1555073003 .
2016-01-04 10:19:16 -08:00
Paul Berry 8991b1c58d Use List<String> for combinators in summaries.
Now that summaries can contain List<String>, there's no need to use a
list of an intermediate data structure.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1559963002 .
2016-01-04 10:11:02 -08:00
Brian Wilkerson d86f7d29a8 Revert element hierarchy to its original form
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1555073002 .
2016-01-04 08:22:13 -08:00
Leaf Petersen a5addef318 Fix strong mode downwards inference for async and generator functions.
Downwards inference pushes the declared return type of a function down into the body in order to infer types for the returned or yielded values.  The asynchronous and generator cases were not being fully handled correctly.

This CL changes the return context stack kept by the inference context to contain the type expected to be returned or yielded (rather than the declared return type).  At each return/yield statement, this return/yield type is used to infer types for the returned/yielded expression.  At each yield* statement, the return/yield type is wrapped into the appropriate stream/iterable type.

This CL also adds future flattening when doing downwards inference on awaited expressions to avoid inferring nested future types.

BUG=
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1555603002 .
2015-12-30 10:35:33 -08:00
Konstantin Shcheglov 8302308b71 Issue 25314. Fix for incremental resolution of a function expression body in class declaration.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25314

Review URL: https://codereview.chromium.org/1546223003 .
2015-12-27 13:16:20 -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
Paul Berry ac37dc71d0 Create a section of the summary for public namespace information.
This will make it easier to re-link summaries when a file changes,
since all the information that is needed from imported libraries will
be in the "public namespace" section of the summary.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1543403002 .
2015-12-24 15:55:16 -08:00
Konstantin Shcheglov 4b1048f80b Delay TypeProvider.objectType access until after dart:core resynthesizing.
This way we solve a chicken-and-egg problem with TypeProvider.

Fix for referencing elements from non-first part.

Fix for TODO to update implicit fields for a getter/setter pair.
The type List has it, so I have to fix it to use for SDK summaries.

Add SummaryTypeProvider to use with SDK summaries.
It is initialized in two steps: first dart:core, then dart:async libraries.
    resynthesizer = new SummaryResynthesizer(context, typeProvider,
        _getPrelinkedSummary, _getUnlinkedSummary, context.sourceFactory);
    _buildCoreLibrary();
    _buildAsyncLibrary();

  void _buildCoreLibrary() {
    LibraryElement library = resynthesizer.getLibraryElement('dart:core');
    typeProvider.initializeCore(library);
  }

  void _buildAsyncLibrary() {
    LibraryElement library = resynthesizer.getLibraryElement('dart:async');
    typeProvider.initializeAsync(library);
  }

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

Review URL: https://codereview.chromium.org/1543313002 .
2015-12-24 14:48:03 -08:00
Konstantin Shcheglov f5963da1d5 ResultProvider - an alternative source of analysis results.
I don't like the name, so I'm open to any ideas.

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

Review URL: https://codereview.chromium.org/1539093002 .
2015-12-21 10:27:24 -08:00
Konstantin Shcheglov a20bbc5f7f Don't cast to ClassElementImpl where we don't need to.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1537233002 .
2015-12-20 11:59:06 -08:00
Konstantin Shcheglov 69723d3388 Change SdkBundle to better fit its usage by SummaryResynthesizer.
This is probably a better format for using with FlatBuffers - we don't
need to read every library to find an unlinked unit.

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

Review URL: https://codereview.chromium.org/1539103002 .
2015-12-20 10:27:07 -08:00
Konstantin Shcheglov 8d1067566a Clear 'referenceMap' before summarizing a new unit.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1537223002 .
2015-12-20 10:02:55 -08:00
Leaf Petersen a34bab7fde Use READY_RESOLVED_UNIT flag for ordering tasks.
Fixes #25271.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1534033004 .
2015-12-18 14:17:52 -08:00
pq 34780784f2 Error code validation updates.
Updates validation to handle configured severities (`error`, `info`, and `warning`).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1541453002 .
2015-12-18 12:58:25 -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
Konstantin Shcheglov 0e283fe46f Fix for typedef-typed field formal parameter.
Found it while generating SDK summaries.
But this is the only exception - the rest worked fine.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1540533002 .
2015-12-18 07:54:13 -08:00
Konstantin Shcheglov 50876b0b2c Information about SDK libraries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1540493003 .
2015-12-18 07:01:34 -08:00
pq 1f8eddcc21 Cache element docs (and add to completions) [#23694].
This does away with the expensive call to `computeDocumentationComment` in favor of cached comments.  Notably this makes adding doc content to code completion proposals performant (and so is done here).  It should also make `dartdoc` *much* faster for doc generation since there are no more trips to disk to fetch comments  for elements (still needed for source though).

For more on the desire for docs in completions see here: https://github.com/dart-lang/sdk/issues/23694

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

Review URL: https://codereview.chromium.org/1534043002 .
2015-12-17 21:07:42 -08:00
Paul Berry 3ff75cc723 Separate prelinked and unlinked parts of summaries.
This will allow summaries to be "re-linked" without having to touch
their UnlinkedUnit data structures (which are much larger than the
corresponding prelinked data).

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1530303005 .
2015-12-17 14:27:10 -08:00
Konstantin Shcheglov e1455ce920 Stop using RESOLVED_UNIT_x for other libraries.
This makes analysis of a command line Hello World application about 20% faster.
Even before summaries :-)

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1531393002 .
2015-12-17 13:57:20 -08:00
Ivan Posva a3f816e75b - Fix usage of Platform.packageRoot.
BUG=

Review URL: https://codereview.chromium.org/1533693003 .
2015-12-17 13:08:19 -08:00
Konstantin Shcheglov 17118efd71 Constant instance creation dependencies also should be computed.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1533823006 .
2015-12-17 13:01:13 -08:00