Commit Graph

8489 Commits

Author SHA1 Message Date
Paul Berry 1a75281742 Rework handling of potentially-constant variables.
Previously, we had a mixin class PotentiallyConstVariableElement to
represent variables which might be constant.  This left some holes in
the type hierarchy which didn't implement
PotentiallyConstVariableElement but nonetheless could be reached by
constant evaluation code in the event of errors in the code being
analyzed, resulting in an invalid cast exception.

This CL drops PotentiallyConstVariableElement and moves its one getter
to VariableElementImpl so that it will be available to all variable
elements.  This allows us to avoid a lot of casts, including the one
that previously caused the exception.

Fixes #24645.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1416873003 .
2015-10-20 12:37:10 -07:00
Brian Wilkerson cc8f64b824 Do not generate warnings when noSuchMethod is inherited (issue 24337)
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1414003003 .
2015-10-20 10:35:53 -07:00
Konstantin Shcheglov 29f3baf646 Issue 24552. Disable reporting HTML parsing errors.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24552

Review URL: https://codereview.chromium.org/1418663002 .
2015-10-20 10:34:40 -07:00
Paul Berry 4e41dc0d66 Fix PackageUriResolver.restoreAbsolute on Windows
Previously, this method attempted to create a package URI by appending
part of a filesystem path to "package:"; on Windows this resulted in
nonsense URIs like "package:foo\bar.dart".

Now we transform the filesystem paths to "file:" URIs before doing other
computations; this normalizes the path separator to "/", so we can
safely use part of the resulting URIs to construct a "package:" URI.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1416863003 .
2015-10-20 09:56:24 -07:00
Konstantin Shcheglov 58937b50ef Issue 24639. Check the correct object for null.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24639

Review URL: https://codereview.chromium.org/1414733006 .
2015-10-20 09:34:23 -07:00
Leaf Petersen 10915a849b Library Cycle invalidation. Library cycle information on the element model was not being correctly invalidated on incremental updates to source files, since the appropriate dependencies cannot be surfaced in the task model directly. This CL adds logic to conservatively invalidate the element model information as needed.
BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1413273002 .
2015-10-19 17:08:07 -07:00
Brian Wilkerson f8092a1012 Enable the new task model everywhere
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1411593005 .
2015-10-19 14:17:22 -07:00
Paul Berry f145f89ccb Create loadLibrary function element eagerly.
Previously we created this element lazily (when requested) but this
didn't work well with the new task model, because creating the element
required calling back into the context and requesting full analysis of
`dart:async` (in order to get access to the Future type), and this
could lead to reentrant task execution.

Now we explicitly create the element in ResolveLibraryTypeNamesTask,
which allows us to get the Future type from the TypeProvider, avoiding
reentrancy.

Fixes #24627.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1405963005 .
2015-10-19 13:34:20 -07:00
Konstantin Shcheglov 4249335a0e Improve incomplete for-each parsing.
Othewise a bizzare structure is returned with identifier in place of a semicolon.
It is easier for client to work with a more correct AST.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1413953003 .
2015-10-19 12:16:26 -07:00
Konstantin Shcheglov 78c7cde132 Improve recovery for local variable declarations.
We need this to improve code completion, and to *not* suggest method/keywords/etc
in cases like "main() {String s^}". Currently it is parsed as "main() {String; s^;}",
so completion cannot distinguish the variable name "s" from a of start a new expression.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1413773003 .
2015-10-19 10:24:21 -07:00
pq 140a4f5891 Register .analysis_options files for analysis.
Some oportunistic constant cleanup as well (follow-up from: https://codereview.chromium.org/1399893004/).

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

Review URL: https://codereview.chromium.org/1412213003 .
2015-10-19 09:46:54 -07:00
Brian Wilkerson 27eb09033f Clean up wording of client usage expectations
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1409353002 .
2015-10-19 07:46:49 -07:00
Brian Wilkerson b49a389fbf Add missed override
Review URL: https://codereview.chromium.org/1413823002 .
2015-10-17 08:36:54 -07:00
Brian Wilkerson 873d46cbbb Remove MissingTypeError to remove duplicate warnings (issue 24610)
R=leafp@google.com

Review URL: https://codereview.chromium.org/1413743003 .
2015-10-17 08:20:46 -07:00
Brian Wilkerson 204ee60bd0 Add a public API for the results of constant evaluation
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1410643003 .
2015-10-17 07:51:10 -07:00
Brian Wilkerson 40b38e988b Include parameter annotations in toSource (issue 24578)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1408923002 .
2015-10-16 07:41:05 -07:00
pq 91e5facc0f Registry memory leak fixes.
Fixes #24549.

A few notes:
  * does away with registry in favor of context-associated configurations
  * pulls in linter rev that does the context association
  * bumps analyzer version before publishing (needed to update analyzer_cli)

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1406043002 .
2015-10-15 14:24:20 -07:00
Brian Wilkerson d2b1edb695 Fix another place where identifiers were not being re-resolved correctly
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1409813002 .
2015-10-15 13:59:48 -07:00
Paul Berry 395b82c041 Fix additional test failures caused by cae05d6bd4
TBR=pquitslund@google.com

Review URL: https://codereview.chromium.org/1403633008 .
2015-10-15 07:06:46 -07:00
pq cae05d6bd4 Context invalidation on option changes (Implements #24574).
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1399893004 .
2015-10-14 20:42:50 -07:00
Vijay Menon 5ec298794b Fix loop var inference when iterating on a type-param type.
Fixes https://github.com/dart-lang/dev_compiler/issues/336

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

Review URL: https://codereview.chromium.org/1405803003 .
2015-10-14 20:05:21 -07:00
pq 888c4c526f State-carrying context API.
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1403033002 .
2015-10-14 15:33:09 -07:00
John Messerly f092c247fd move strong mode hints behind flag
these test features were not supposed to be leaking into the UI

R=leafp@google.com

Review URL: https://codereview.chromium.org/1402813005 .
2015-10-13 16:46:24 -07:00
Konstantin Shcheglov a41819650e Issue 24566. Main AnalysisContext.getLibrariesContaining() should work also for SDK sources.
This also fixes IDEA's Iterable hierarchy problem.

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

Review URL: https://codereview.chromium.org/1405643002 .
2015-10-13 14:25:07 -07:00
Brian Wilkerson e6b4389f0f Partial fix for the task model issue in which analysis is not always redone when needed.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1403003002 .
2015-10-13 11:37:56 -07:00
John Messerly 0544735a60 allow computeErrors to work on non-.dart files
This is similar to the change we made recently to resolveCompilationUnit2. If someone programmatically uses the API to request resolution errors, treat it as a Dart file.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1394023004 .
2015-10-13 11:16:19 -07:00
Paul Berry ec144a055a Fix type of EninePlugin List<ResultDescriptor> getters.
These getters were improperly typed as List<TaskDescriptor>.  Due to the
fact that the underlying lists they were returning were List<dynamic>,
and the fact that new warnings for for-in loops haven't been implemented
yet (see commit 89607f06e9), no warnings
or runtime errors alerted us to the incorrect type.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1406583002 .
2015-10-13 10:45:28 -07:00
Leaf Petersen 4ca8a3f19b Strong mode checker integration. This integrates jmesserly's CL, and adds a task for computing strong mode errors and an annotated unit.
BUG=
R=brianwilkerson@google.com, jmesserly@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1396273004 .
2015-10-13 10:16:35 -07:00
John Messerly 8ae0534c1c port DDC checker code to analyzer
It's not used yet, except by its own test.

Naturally there's a *lot* to clean up here in follow ups. I tried to keep the ported code in its own directory so it's obvious. Ideally we can remove this directory once the code has been moved out.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1402783004 .
2015-10-12 12:31:00 -07:00
Sigurd Meldgaard a763c71d92 Introduce the "Embedded" category.
It is not visible from the dart2js command line.

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

Committed: https://github.com/dart-lang/sdk/commit/0aef0efb6a38a65fa676fa9e8daa85a972521745
Reverted: https://codereview.chromium.org/1401513002

Review URL: https://codereview.chromium.org/1395863002 .
2015-10-12 12:15:48 +02:00
Konstantin Shcheglov ebdfa991d4 Issue 24538. Route SDK results into SDK context DartWorkManager.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24538

Review URL: https://codereview.chromium.org/1399873002 .
2015-10-09 21:45:35 -07:00
Paul Berry 9af099fcdf Access types safely in TypeResolverVisior.visitMethodDeclaration()
Previously, when attempting to figure out the type of the synthetic
field associated with a getter (or setter),
TypeResolverVisitor.visitMethodDeclaration() used the getters
FunctionTypeImpl.returnType (or FunctionTypeImpl.normalParameterTypes)
to extract the appropriate type.  But those getters are only safe to
use after types have been fully constructed (because they may try to
perform type substitution).  Fortunately, type substitution isn't
needed here, so we can simply use FunctionTypeImpl.baseReturnType (or
FunctionTypeImpl.baseParameters) instead.

Fixes #24539.

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

Review URL: https://codereview.chromium.org/1397193002 .
2015-10-09 14:21:12 -07:00
Sam Rawlins bd8ba4b2ce Fix TODO comments; other nits
Also s/Sets/Set/ and s/Returns/Return/ for consistency.

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

Review URL: https://codereview.chromium.org/1395243002 .
2015-10-09 13:45:30 -07:00
pq 695256d586 Linter hookup into AS.
Note the TODO to fix the extension manager interaction hijinx.  Really we should ensure that we are only using the one in engine.  At the moment, it's easy to get this wrong (as the initialization heroics herein testify).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1392683003 .
2015-10-09 13:40:07 -07:00
Paul Berry 3ae9e62284 Create a breadcrumb trail for analyzing of task model extensions.
This change paves the way for modifying
pkg/analyzer/tool/task_dependency_graph.dart so that it will be able to
understand the extensibility mechanisms in the task model.
Specifically, it adds the ExtensionPointId annotation, which
task_dependency_graph.dart will be able to use to locate the
TaskDescriptors that are plugged into each task model extension point.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1401543002 .
2015-10-09 11:05:14 -07:00
Konstantin Shcheglov e1083af258 Ignore absence of DOCTYPE in HTML files.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1395033003 .
2015-10-09 10:44:03 -07:00
Konstantin Shcheglov 14ab3cae4d Fix for top level variable documention ranges.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1396693004 .
2015-10-09 10:39:46 -07:00
pq 1b6c6660f1 Lint task cleanup.
Follow-up from:

https://codereview.chromium.org/1385293002/diff/20001/pkg/analyzer/lib/src/task/dart.dart

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1386323003 .
2015-10-09 08:27:33 -07:00
Sigurd Meldgaard 01d6977030 Revert "Introduce the "Embedded" category."
This reverts commit 0aef0efb6a.

BUG=

Review URL: https://codereview.chromium.org/1401513002 .
2015-10-09 13:29:53 +02:00
Sigurd Meldgaard 0aef0efb6a Introduce the "Embedded" category.
It is not visible from the dart2js command line.

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

Review URL: https://codereview.chromium.org/1395863002 .
2015-10-09 13:08:26 +02:00
pq e19f10fbec Add context to OptionsProcessor callback API.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1392143002 .
2015-10-08 10:47:06 -07:00
Konstantin Shcheglov 9f8da95217 The (failing) test for the invalid hint / used elements problem.
The problem is that during computing RESOLVED_UNIT3 we reuse RESOLVED_UNIT2
with the previously resolved bodies. And resolver ignores already resolved
identifiers. So, this causes pointing to the stale element model, etc.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1398433004 .
2015-10-07 21:46:03 -07:00
Leaf Petersen 651221bb82 Resolve ordering issues.
This CL changes the way that the task model does strong mode inference to use the strongly connected components in the import/export graph.  Library cycles are computed and inference is staged by forcing each stage of inference to happen across an entire library cycle at once, and to force all external dependencies of a library cycle to have completed inference before inference for the library cycle can begin.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1386023002 .
2015-10-07 16:14:35 -07:00
John McCutchan 98638457ce Remove final users of dart:profiler library
BUG=
R=turnidge@google.com

Review URL: https://codereview.chromium.org/1394533002 .
2015-10-07 09:27:22 -07:00
Paul Berry e40b231771 Make ResolveVariableReferencesTask depend on RESOLVED_UNIT3.
Technically, ResolveVariableReferencesTask only requires the
information guaranteed by RESOLVED_UNIT1 to do its job.  However,
later tasks, such as ResolveFunctionBodiesInUnitTask, require the
information computed by ResolveUnitTypeNamesTask (which produces
RESOLVED_UNIT3).  Normally this is not a problem, because
ResolveFunctionBodiesInUnitTask depends (via a rather complex
dependency chain) upon LIBRARY_ELEMENT5, which in turn depends on
ResolveLibraryTypeNamesTask, which depends on RESOLVED_UNIT3.  So
ResolvuUnitTypeNamesTask winds up getting run.

However, it's possible that due to analysis cache pressure, the
resolved unit will get thrown away, while the library element is
preserved.  If this happens, then when the resolved unit is being
recomputed, it won't be necessary to run ResolveLibraryTypeNamesTask
in order to recompute LIBRARY_ELEMENT5 (becase LIBRARY_ELEMENT5 is
still cached).  As a result, nothing is left that depends on
RESOLVED_UNIT3, so there is nothing to force ResolveUnitTypeNamesTask
to run.

The outward manifestation of this problem is that when trying to
resolve a library, a TypeName will be found whose ".type" property is
unexpectedly null, causing an exception in the ResolverVisitor.

The easy fix is to make ResolveVariableReferencesTask depend on
RESOLVED_UNIT3, so there is a complete dependency chain through all
the RESOLVED_UNIT[N] results that doesn't rely on any
LIBRARY_ELEMENT[N] intermediates.

This is not an ideal fix because it forces us to compute
RESOLVED_UNITs 2 and 3 even if they might not be needed.  Fortunately,
computing these RESOLVED_UNITs should be fast, so I don't expect a
significant performance penalty.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1386363002 .
2015-10-06 18:21:12 -07:00
pq fe76c6f3c4 Lint support for the new task model.
Related bug: https://github.com/dart-lang/analyzer_cli/issues/64

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1385293002 .
2015-10-06 16:45:45 -07:00
Konstantin Shcheglov 4e6195fdf5 Issue 24514. Set documentation range for LibraryElement.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24514

Review URL: https://codereview.chromium.org/1390003002 .
2015-10-06 16:13:57 -07:00
pq 90e975b656 Suppress scanner errors for non-existent URIs.
Fixes #23754.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1378503003 .
2015-10-06 10:25:50 -07:00
Konstantin Shcheglov ef434d6a9b Issue 24503. Disable type overrides for properties.
R=brianwilkerson@google.com, paulberry@google.com
BUG= https://github.com/dart-lang/sdk/issues/24503

Review URL: https://codereview.chromium.org/1386033003 .
2015-10-06 08:40:02 -07:00
Konstantin Shcheglov c4427ca8f4 Fix for incremental resolver - changing field formal parameter name is sometimes a non-incremental change.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1374313007 .
2015-10-06 08:35:07 -07:00