Commit Graph

482 Commits

Author SHA1 Message Date
Brian Wilkerson 76d22fe363 Move DelegatingAstVisitor into the public API
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1747093002 .
2016-03-01 07:57:01 -08:00
Paul Berry 5b78ff96b3 Expose LibraryElementImpl.libraryCycle through LibraryElement.
This ensures that `libraryCycle` will work properly when accessing an
element model resynthesized from summaries.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1744633002 .
2016-02-26 14:03:24 -08:00
Brian Wilkerson 70cbc0764d Fix dartdoc for AST nodes
R=keertip@google.com

Review URL: https://codereview.chromium.org/1738533003 .
2016-02-25 08:35:38 -08:00
pq 84f32fe5a6 Validation of @protected method invocations.
* Defines `isProtected` accessors.
* Adds a simple mechanism to our test `AnalysisContextFactory` allowing us to contribute package resolution to test cases.
* Adds `meta` awareness to `ResolverTest`.

NB: this *only* adds method invocation support.  I'll generalize to all members in a follow-up.  There's enough here though that I wanted to get some early feedback.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1723243002 .
2016-02-24 09:25:43 -08:00
John Messerly 18ef4ba22b cleanup to InvocationExpression AST declaration
follow up to https://github.com/dart-lang/sdk/commit/0c4e64c8efafd9ac6d8fd004706ee69639b0d04f
splits getter/setter, fixes some sorting

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1717243003 .
2016-02-22 16:52:51 -08:00
John Messerly 0c4e64c8ef fixes #25477, downward inference of generic methods
* we now push the context return type down when inferring
* we also take this into account in our initial downards inference for arguments
* adds a common AST interface for FunctionExpressionInvocation and MethodInvocation, so we can handle these more uniformly

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

Review URL: https://codereview.chromium.org/1720433002 .
2016-02-22 14:48:39 -08:00
Paul Berry 4eaafd3ee5 Deprecate old "isPotentiallyMutated..." API.
The getters are rewritten to return `true`.  Technically this is not a
breaking change, since all variables are "potentially mutated" in at
least a vacuous sense.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1711433002 .
2016-02-17 12:36:58 -08:00
Paul Berry c3d98acbeb Add data structures to AST to indicate potentially mutated variables.
These data structures provide the same functionality as
VariableElement.isPotentiallyMutatedInClosure and
VariableElement.isPotentiallyMutatedInScope, but are only accessible
from a resolved AST.  In a later CL,
VariableElement.isPotentiallyMutatedInClosure and
VariableElement.isPotentiallyMutatedInScope will be deprecated.

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

Review URL: https://codereview.chromium.org/1700263002 .
2016-02-16 14:04:25 -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
Bob Nystrom b0719aa402 Remove unused or unneeded stuff from java_core.dart.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1688113004 .
2016-02-12 11:10:48 -08:00
Bob Nystrom e19c6dd79d Consolidate the code that replaces a TypeParameter with its bound.
In the process, I fixed a bug where one version of this same lump of
code wasn't correct anymore now that you can have arbitrarily long
chains of type parameters.

DartType isn't maybe the ideal place for resolveToBound(). I wanted it
somewhere that:

1. Would be obvious enough that someone coming along later would
   discover it instead of reinventing it again.
2. Had access to the various data it needs.
3. Wouldn't need a "is TypeParameterType" guard at every callsite
   before it could be used.

I could put it on TypeProvider instead, since it needs access to Object,
but that felt arbitrary.

It could be a top level function, but then I don't think it would be
very discoverable.

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

Review URL: https://codereview.chromium.org/1686893002 .
2016-02-11 11:27:01 -08:00
Konstantin Shcheglov 0f78186005 Set visible ranges for local variables/functions to the ranges of enclosing blocks.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1690783002 .
2016-02-10 16:16:56 -08:00
Brian Wilkerson ec04f012f7 Move Token into the public API
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1690523002 .
2016-02-10 09:12:26 -08:00
Paul Berry c5b3141564 Deprecate PrefixElement.importedLibraries.
It has never worked.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1686863002 .
2016-02-09 14:59:57 -08:00
Brian Wilkerson a9d0e2bf76 Add comments to public libraries
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1672383002 .
2016-02-06 16:27:54 -08:00
Paul Berry c43622e897 Use ElementAnnotation as the ConstantEvaluationTarget for annotations.
Previously, we had a special class,
ConstantEvaluationTarget_Annotation, for this purpose.  It held on to
a the AST node for the annotation.  This was bad because it meant that
the presence of any ConstantEvaluationTarget_Annotation referring to a
given compilation unit would keep the entire compilation unit's AST in
memory.

Now we copy just the portions of the AST we need into
ElementAnnotation, just as we do for all other constant evaluation
targets.  In addition to saving memory, this paves the way for
supporting annotations in summaries, by making it possible to compute
the constant value of an annotation without having to consult the full
AST.

Fixes #25285.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1665353002 .
2016-02-04 15:22:40 -08:00
Bob Nystrom 434f5bc922 Implement the spec's notion of LUB for function types.
Fixes #23381.

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

Review URL: https://codereview.chromium.org/1648063002 .
2016-01-29 10:37:58 -08:00
Brian Wilkerson 9c56d05746 Stop creating duplicate enum members when the element model has already been built
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1633233002 .
2016-01-26 14:00:02 -08:00
Brian Wilkerson 5d9274bd79 Move Modifier out of the public API
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1633823003 .
2016-01-26 09:27:44 -08:00
Paul Berry 4e86a006db Stop precomputing ClassElement.isValidMixin.
Previously, we would precompute the value of ClassElement.isValidMixin
and store it in the Modifier.MIXIN.  But this didn't really save any
time, because (a) isValidMixin isn't used inside analyzer, and (b) it
is easily derivable from other information already present in the
element model.

Also, we were computing it incorrectly when the `--supermixin` flag
was present.

This CL replaces the precomputation logic with a direct implementation
in ClassElement.isValidMixin which is correct regardless of the
presence of the `--supermixin` flag.  The tests are beefed up so that
(a) they validate correct behavior for both states of the flag, (b)
they validate correct behavior in the presence of factory
constructors, and (c) they validate that the behavior of
`isValidMixin` is consistent with the error messages produced by the
analyzer.

In addition to fixing bugs, the removal of Modifier.MIXIN means we
have one less piece of information to store in summaries.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1635063003 .
2016-01-26 07:29:48 -08:00
John Messerly 9a4b1c36ce fixes #25482, flatten futures in strong mode so Future.then works
Also fixes https://github.com/dart-lang/dev_compiler/issues/228

A few tweaks were made to the propagatedType inference for Future.then:
* only record type if better than static type
* only go down this path when strong mode is off

also renames tests: test_pseudoGeneric to test_genericMethod.

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

Review URL: https://codereview.chromium.org/1609093003 .
2016-01-22 13:29:58 -08:00
Brian Wilkerson 21ecb14548 Clean-up imports
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1602803002 .
2016-01-18 15:42:16 -08:00
Brian Wilkerson 539f0dff4a Move AST implementation out of generated
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1595243003 .
2016-01-18 13:02:12 -08:00
Brian Wilkerson 6f56368747 Create a public interface for AST nodes and rename the implementation classes
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1594313002 .
2016-01-18 09:53:40 -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
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
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
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
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 ea7e6b29ed Introduce code to resynthesize element models from summaries.
A lot of work remains to do (see TODO comments), but the basic
infrastructure is now in place.

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

Review URL: https://codereview.chromium.org/1526243002 .
2015-12-16 08:39:56 -08:00
Brian Wilkerson 2a190aa11a Fix imports within the analyzer package
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1524893002 .
2015-12-14 12:25:41 -08:00
Brian Wilkerson 86472f32ce Move public API for elements into a public location
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1519283003 .
2015-12-13 10:48:56 -08:00