Commit Graph

7128 Commits

Author SHA1 Message Date
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 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
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
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
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
Konstantin Shcheglov 83c1106ffe Compute values of elements a unit constant expressions depend on.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1539623002 .
2015-12-17 11:47:54 -08:00
Konstantin Shcheglov e5e1dc77bd Replace using '_commentBeforeFunction' with visitXyzInScope().
Otherwise it gets really ugly with using FunctionTypeAlias which does not have
a body, and getters not having a FormalParameterList, and with parameters for
function typed parameters...

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1526973005 .
2015-12-17 10:52:23 -08:00
Konstantin Shcheglov 9801d58eb7 Compute all default values of parameters.
Look at the following code.

main([p = double.INFINITY]) {}

In ConstantVerifier we validate the value of "p" and while doing this validate
the value of the ConstFieldElementImpl that corresponds to "double.INFINITY".

The problem is that we compute "double.INFINITY" in the task that requires
RESOLVED_UNIT_n, where "n" is too high. What we really need is just one value,
not all values, and of course not the resolved unit. And when we will use
summaries, we will be able to provide these values without using AST at all.

So, we need to explicitly require computation of the default value of "p",
an explicit dependency on "double.INFINITY" and its explicit computation.
Currently it still causes using ASTs, but we will change this soon.

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

Review URL: https://codereview.chromium.org/1531233002 .
2015-12-17 08:06:09 -08:00
Paul Berry 80fc29cecd Fixes to mock SDK to enable dart:core to be summarized.
This CL makes the following changes to the mock SDK used by
AnalysisContextFactory.initContextWithCore:

- Getters created by the ElementFactory have their `synthetic`
  property set correctly, and their corresponding synthetic fields
  have their `final` property set correctly.

- The following class elements all have at least one constructor:
  Function, Iterable, Iterator, Map, Null, StackTrace, Type, num,
  double, _Proxy.

This allows resynthesize_test.dart's `test_core` to pass.

Also, some minor improvements are made to resynthesize_test.dart to
allow failures to be diagnosed more easily.

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

Review URL: https://codereview.chromium.org/1532763002 .
2015-12-17 07:19:47 -08:00
Paul Berry 493a03a0ed Add UnlinkedClass.hasNoSupertype property to summaries.
This is necessary in order to properly summarize the core type `Object`,
which lacks a supertype.

Note that there is no test for this functionality in
resynthesize_test.dart.  It will be covered as soon as the test
`fail_core` is enabled.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1531913002 .
2015-12-16 15:18:49 -08:00
Konstantin Shcheglov 9cb4fc5f1d Resolve comment references before function type aliases.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1535533002 .
2015-12-16 15:13:12 -08:00
Konstantin Shcheglov 5eb20232e3 Skip comments code blocks indented with 4 spaces.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1536483002 .
2015-12-16 14:28:30 -08:00
Paul Berry 7adf62209d Fix summary resynthesis for operators ending in '='.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1530363002 .
2015-12-16 13:59:16 -08:00
Paul Berry ac170168dd Add support for the "external" keyword to summaries.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1528983004 .
2015-12-16 13:32:19 -08:00
Paul Berry 98e8b0a118 Fix resynthesis of operator[]= from summary.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1533563003 .
2015-12-16 11:29:54 -08:00
Konstantin Shcheglov c19e958822 Don't produce [references] in GitHub-like code blocks in comments.
Mostly for the cases when we would like to demonstrate use or
lists or maps: `a[i] == b[i]`.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1527393002 .
2015-12-16 10:32:10 -08:00
Konstantin Shcheglov ea922ef7f4 Fix for recording static elements of a prefixed comment reference.
I notied during reading idl.dart that I'd like to see highlighting and
search for type names in comment references like [PrelinkedLibrary.dependencies].

With this change we get highlighting, search and refactoring for both.
Navigation also works (*).

(*) does not work in IntelliJ - it does not parse Dart comments for reference expressions.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1531613002 .
2015-12-16 09:03:25 -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 66e07636f4 Moved the tests for the element model into locations corresponding to the implementation
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1529923003 .
2015-12-16 07:49:15 -08:00
Paul Berry b22d7d532f Merge the prefix and references tables.
This makes the UnlinkedLibrary type go away, which means that we no
longer have any unlinked summary data which is spread across the
compilation units constituting a library.  That in turn means that we
should be able to safely re-link summaries even in the (pathological)
case where a change to URI resolution affects the relationship between a
library and its parts.

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

Review URL: https://codereview.chromium.org/1528113002 .
2015-12-15 12:33:25 -08:00
Paul Berry ceecfe862b Reserve element 0 in the references table for dynamic.
In addition to simplifying some serialization/deserialization code, this
paves the way for merging the references table with the prefixes table
by allowing the zeroth entry in both tables to act as a sentinel value.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1528083002 .
2015-12-15 11:25:11 -08:00
Paul Berry 518ae623d6 Move summary references into UnlinkedUnit and PrelinkedUnit.
This is a follow up to commit
f85684604b, which reorganized the
declarations by compilation unit to pave the way for allowing
summaries to be "re-linked" if the relationship between part files
changes.  Organizing references by compilation unit is another
necessary step to make that possible.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1523093003 .
2015-12-15 10:55:45 -08:00
Paul Berry f85684604b Organize summary declarations by unit rather than by library.
In the initial implementation of summaries, all declarations for a
given library were thrown together into a single bucket, regardless of
the compilation unit in which they appeared.  This was done on the
grounds that semantically, the compilation unit in which a declaration
appears is irrelevant.

However, it turns out that this conflicts with one of the design goals
of summaries, which is to allow summaries to be quickly "re-linked"
when URI resolution changes.  Since "part" declarations use URIs to
refer to part files, this means that URI resolution may affect the
relationship among compilation units within a library; thus, the
declarations for each compilation unit need to be in their own data
structure.

A side benefit of this reorganization is to make the structure of the
summary more similar to the structure of the element model; this
should in turn make it simpler (and possibly more performant) to
convert between element models and summaries.

This CL reorganizes the declarations themselves; future CLs will
reorganize the dependency and resolution information to match.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1530503002 .
2015-12-14 16:30:15 -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 1f3dabd9c7 Ensure that a complete library element has constants evaluated (issue 24890)
R=danrubel@google.com, eernst@google.com, paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1486663003 .
2015-12-14 07:51:07 -08:00
Konstantin Shcheglov 2f0f398c73 Fix lints: unnecessary_brace_in_string_interp
Also fixes two cases of empty_constructor_bodies.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1521883002 .
2015-12-13 13:05:00 -08:00
Konstantin Shcheglov 56f0adf9bf Issue 25238. Update LoclaElement(s) visible ranges during incremental resolution.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25238

Review URL: https://codereview.chromium.org/1522583005 .
2015-12-12 17:15:06 -08:00
Paul Berry 45068f01ed Track implicit vs explicit types in summaries.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1524443002 .
2015-12-11 13:49:14 -08:00
John Messerly b2d7ebe56c fix #25171, clear "hasBeenInferred" flag when re-running resolution
TypeResolverVisitor undoes the work of InstanceMemberInferrer, so it should also unset the flag.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1513143004 .
2015-12-10 16:16:52 -08:00
Brian Slesinsky f0eb582d49 A class that's only used as a field type should be considered used
BUG=https://github.com/dart-lang/sdk/issues/25184
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1512833007 .
2015-12-10 13:52:41 -08:00
Konstantin Shcheglov e94ec76865 Parse HTML files with keeping original attributes case.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1516073002 .
2015-12-10 13:51:48 -08:00
pq 62656833d4 Wraps up the server-side of the 'Allow a user to configure which hints are "fatal"' ask (#24452).
* migrates error filtering from a predicate to a process that can customize severities.
* moves filtering/processing from the `dart` task into the `getErrors` request and the errors notification.

See: https://github.com/dart-lang/sdk/issues/24452

(Pending a thumbs-up, support for CLI to follow.)

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1517723002 .
2015-12-10 13:35:11 -08:00
Konstantin Shcheglov eb6da55838 Paths where '..' is not right between separators are normalized.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1512363002 .
2015-12-10 10:39:53 -08:00
Konstantin Shcheglov 0f95992770 Issue 25218. The reference type of 'A' in 'A..foo' is 'Type'.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25218

Review URL: https://codereview.chromium.org/1519583002 .
2015-12-10 10:20:40 -08:00
Brian Wilkerson f0d249e269 Clean up package imports and library names
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1513643009 .
2015-12-10 08:11:56 -08:00
John Messerly 0e09465f0c fix #25183, add support to ErrorVerifier for generic methods
R=brianwilkerson@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1514683002 .
2015-12-09 15:16:00 -08:00
Konstantin Shcheglov e48f962af1 Validate that root paths are absolute and normalized.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25203

Review URL: https://codereview.chromium.org/1511833004 .
2015-12-09 15:05:22 -08:00
John Messerly 7de1d190b9 fix #25182, downwards inference for calls to fields/getters/vars/params/locals
R=leafp@google.com

Review URL: https://codereview.chromium.org/1513603002 .
2015-12-08 16:17:06 -08:00
Leaf Petersen 9ea88b3e55 Generic method subtyping.
Fixes #25176 .

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1509263002 .
2015-12-08 14:56:47 -08:00
John Messerly c985c599ed fixes #25094, type params in static methods shouldn't always be an error
R=leafp@google.com

Review URL: https://codereview.chromium.org/1508183002 .
2015-12-08 14:08:24 -08:00
John Messerly e90e905978 fixes #25174, downward inference on list and map initializers with explicit type args
R=leafp@google.com

Review URL: https://codereview.chromium.org/1507883003 .
2015-12-08 14:02:56 -08:00
Konstantin Shcheglov 72cf3cbe91 Remove unnecessary 'noSuchMethod' declarations.
Also format these file.
I don't like how the new formatter changed the code :-(

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1507813004 .
2015-12-08 11:39:37 -08:00
Konstantin Shcheglov 1b0a5c313f Issue 24648. Report HintCode.UNNECESSARY_NO_SUCH_METHOD.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24648

Review URL: https://codereview.chromium.org/1506903005 .
2015-12-08 10:28:38 -08:00
Paul Berry 4c28eb6f67 Merge remote-tracking branch 'origin/master' into analyzer-breaking-0.27 2015-12-08 10:16:29 -08:00
John Messerly 5e11857451 Refactor strong mode to remove duplicate TypeRules
Most of this code is already in StrongTypeSystemImpl. A few helpers move there, with some moving into CodeChecker. This does not rename "rules" parameters/variables yet, but let me know if we should do that.

This just moves code around. One subtle thing: TypeRules.isAssignableTo was only used in one place, in override checking, and that method just forwarded to TypeRules.isSubTypeOf. By contrast, StrongTypeSystemImpl does *not* just forward. So OverrideChecker now uses isSubtypeOf, preserving its old behavior.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1507933002 .
2015-12-07 17:19:13 -08:00