Commit Graph

8489 Commits

Author SHA1 Message Date
Konstantin Shcheglov a2e4e671e9 Build full LIBRARY_ELEMENT for every library source in the import/export closure, when resolve a unit.
This fixed 8 Analysis Server tests.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1165283006.
2015-06-09 14:02:43 -07:00
Paul Berry 4e36247eea In constant evaluation, consistently handle const depending on non-const.
It is a compile-time error for a constant value to depend on a
non-constant value (or a non-constant constructor), however the
analyzer still needs to be able to handle it.

This CL adjusts the ConstantEvaluationEngine so that it consistently
reports all the dependencies of a given constant (whether those
dependencies are constant are not), but which is tolerant of being
asked to compute a constant value of a non-constant.

Fixes test failures with the new task model enabled.  No behavioral
change with the new task model disabled.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1167413005.
2015-06-09 13:48:43 -07:00
Paul Berry fc83ce5ba9 Fix analyzer's handling of import prefixes not followed by '.'.
If 'p' is an import prefix, then 'p = ...' is treated as synonymous
with 'this.p = ...', and 'p()' is treated as synonymous with
'this.p()'.  In all other circumstances where 'p' is not followed by
'.', the spec calls for a compile time error.

Previous to this CL, 'p' not followed by '.' was being treated as
synonymous with 'this.p' under all circumstances.  This CL brings
analyzer in line with the spec, and updates the tests in
tests/language accordingly.

The VM and Dart2js currently fail to implement the compile-time error
properly.  See issues #23611 and #23612.

Fixes issue #23461.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1173523002.
2015-06-09 13:38:53 -07:00
Brian Wilkerson db0b64475d Include more errors when computing complete list
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1171893007.
2015-06-09 13:14:17 -07:00
Konstantin Shcheglov d2f80cfaec Fix the test to remove extra hint.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1174563003.
2015-06-09 10:49:33 -07:00
Konstantin Shcheglov 25620e2e59 Remove extra CompileTimeErrorCode.DUPLICATE_DEFINITION.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1170863002
2015-06-08 22:58:32 -07:00
Brian Wilkerson c60c313f59 Fix incremental resolver to work with new task model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1169803003
2015-06-08 12:56:58 -07:00
Paul Berry 2c533ac971 Create a TypeDefiningElement interface.
This interface is common to ClassElement, FunctionTypeAliasElement,
and the element for the pseudo-type "dynamic".  This should allow us
to avoid some unnecessary casting in the dev_compiler (see
https://codereview.chromium.org/1160223006/#msg11).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1165213002
2015-06-08 11:29:02 -07:00
Paul Berry 12696cafe9 Fix a corner case of constant constructor dependency computation.
If a constant constructor does not contain an explicit call to
super(), and the base class lacks an explicit constructor, we need to
avoid marking the implicit base class constructor as a dependency,
since it is non-const.  (Note: this shouldn't occur very often in
real-world usage since is a compile-time error, but we still need to
be able to analyze it without throwing an exception).

Fixes the following test when the new task model is switched on:
co19/Language/07_Classes/6_Constructors/3_Constant_Constructors_A03_t02

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1168563004
2015-06-08 11:23:32 -07:00
Brian Wilkerson 7230007d52 Fix several tests when the new task model is enabled
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1164223002
2015-06-07 19:31:04 -07:00
Konstantin Shcheglov 811877df42 Invalidate resolution of analysisOptions/sourceFactory changes.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1167483004
2015-06-05 14:09:12 -07:00
Konstantin Shcheglov 787e9fcf7f Reanalyze after creating a referenced part.
We need to finish linking CompilationUnitElement(s) to LibraryElement(s)
even for not existing sources. Otherwise we get NPE later and leave
model in the ERROR state.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1168743002
2015-06-05 11:29:04 -07:00
Konstantin Shcheglov 1c1497ff98 Another tweak for displaying performance.
1. It is still interesting to see performance tags, even with the next task model.

2. Factor out "WorkOrder.moveNext" as a separate performance tag, something like "intertask" for new tasks.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1161183004
2015-06-05 09:19:28 -07:00
Konstantin Shcheglov 32f4b9aca5 Only units with 'part of' and no other directives are parts.
Invalidate CONTAINING_LIBRARIES as needed.

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

Review URL: https://codereview.chromium.org//1160873004
2015-06-04 14:03:07 -07:00
Brian Wilkerson 56be513cf9 Add isExternal accessor to element model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1158793004
2015-06-04 12:38:31 -07:00
Konstantin Shcheglov a24d84ecd9 Ensure types are resolved for combined import/export closures.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1166983005
2015-06-04 11:48:56 -07:00
Konstantin Shcheglov a9632f3bab Fix for DeclarationResolver.
It's not the main problem we observe during pkg/analysis_server/test/operation/operation_test, but I still saw it.

The actual fix is removing "unary-".

The other change is just for performance.
It is much cheaper to compare int(s) than to compute (for methods) 'displayName'.
Maybe we should go as far as removing the name check altogether and use just element kind.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1149083007
2015-06-04 10:41:19 -07:00
Konstantin Shcheglov b35d54a8b7 Decide if unit without directives is a part or a library.
1. When there is a library containing it while we are parsing a part.

2. When a part was parsed, but then we found a library containing it.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1167733004
2015-06-02 16:01:01 -07:00
Konstantin Shcheglov 958638ca20 Record SourceKind.UNKNOWN for not existing sources.
So, they are not returned as library sources.
This fixes one of the Quick Fix tests.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1167773002
2015-06-02 13:18:56 -07:00
Konstantin Shcheglov 250992aad8 Ignore not existing parts.
We decided to produce an empty token streams, so empty units for them.
So, we need to have a separate check for not existing Source later.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1160543003
2015-06-02 11:09:27 -07:00
Konstantin Shcheglov b9dbeedb54 Prepare CompilationUnitElementDelta in IncrementalCompilationUnitElementBuilder.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1155543005
2015-06-02 11:03:03 -07:00
Brian Wilkerson d614533a9e Fix NPE in building element model when part URI could not be resolved
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1155693004
2015-06-02 10:40:03 -07:00
Brian Wilkerson a82c880bb1 Fix NPE when computing dependencies of enum constants
R=paulberry@google.com

Review URL: https://codereview.chromium.org//1156893006
2015-06-02 09:46:21 -07:00
Konstantin Shcheglov 34ce430b9e Reformat ast.dart with the current formatter.
Otherwise there are more changes than I'd like in the other CL.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1154923005
2015-06-01 15:19:23 -07:00
Paul Berry 717da6731b Eliminate Modifier.TYPEDEF and deprecate ClassElement.isTypedef.
Modifier.TYPEDEF was redundant with Modifier.MIXIN_APPLICATION and
ClassElement.isTypedef was redundant with
ClassElement.isMixinApplication.

Since Modifier.TYPEDEF was private to analyzer, it has been
eliminated.  Since ClassElement.isTypedef is part of the public API to
analyzer, it is retained, but with a "@deprecated" annotation.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1158193008
2015-06-01 14:17:40 -07:00
Paul Berry 62f7ac8c5d Fix handling of nested typedefs (for real this time).
This is a re-fix of dartbug.com/21912, which I previously fixed
incorrectly.  Previously, our approach to avoiding infinite loops when
comparing types was to maintain a set of typedefs being expanded on
the stack, and prune the comparison whenever an attempt was made to
expand a typedef that was already being expanded.  However, this was
too strict, since there are legal (non-circular) types which invole
expanding a given typedef in reentrant fashion; we can't prune these
types without producing incorrect semantics.  An example (from the bug
report) is the type of f in the code below:

    typedef T Function2<S, T>(S z);
    Function2<Function2<A, B>, Function2<B, A>> f;

The solution is to maintain the list of typedefs being expanded inside
each FunctionTypeImpl object (and InterfaceTypeImpl object) rather
than on the stack during the comparison; this allows us to distinguish
the situations where we need to prune (those having to do exclusively
with expansion of a typedef) from the situations where we shouldn't
prune (those having to do with substitution of a type parameter).

A beneficial side effect of this change is that code that interacts
with types no longer needs to worry about typedef circularities, since
the circularities will automatically be pruned while exploring the
type definitions.  This simplifies the implementation of
isAssignableTo, isSubtypeOf, operator==, and hashCode.  (Note,
however, that code still needs to cope with circularities in the
inheritance hierarchy).

BUG=dartbug.com/21912
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1143003007
2015-06-01 12:45:27 -07:00
Konstantin Shcheglov f1d4ef9164 Issue 23409. Don't set 'propagatedType' in (vs. after) 'name is Type'.
This fixes the corresponding 'Extract Method' issue.

R=brianwilkerson@google.com
BUG=https://code.google.com/p/dart/issues/detail?id=23409

Review URL: https://codereview.chromium.org//1161343002
2015-06-01 12:40:30 -07:00
Konstantin Shcheglov 9dc5bc79f1 Issue 23518. Match prefixes of prefixed types.
R=brianwilkerson@google.com
BUG= https://code.google.com/p/dart/issues/detail?id=23518

Review URL: https://codereview.chromium.org//1149953005
2015-06-01 09:27:29 -07:00
Paul Berry c9b672a6dd Make analyzer DDC warning clean.
R=brianwilkerson@google.com, vsm@google.com

Review URL: https://codereview.chromium.org//1153503005
2015-06-01 08:54:13 -07:00
Brian Wilkerson fb983067bd Rename Element.node
Review URL: https://codereview.chromium.org//1163573002
2015-05-28 08:27:23 -07:00
Paul Berry 535394c265 Remove debugging print statements.
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1149063005
2015-05-27 20:24:06 -07:00
Konstantin Shcheglov 8bcdd16e06 Schedule ChangeNotice results only after parse/resolve/errors.
We have too many steps to compute all the errors.
It does not worth to send them every time.

This helps to save 500 ms on the analyzer project.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1154033002
2015-05-24 10:02:44 -07:00
Konstantin Shcheglov dbd2463d6d Don't schedule LIBRARY_ERRORS_READY for libraries that should not be analyzed.
This helps to save about 1500 ms, or about 10% on the analyzer project.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1155473003
2015-05-24 10:00:21 -07:00
Konstantin Shcheglov 4ca0c7acbb Adapt the existing incremental resolution implementation to the new model.
This is hopefully a temporary implementation, to be used until we have a
proper task-based version. Otherwise the new task model is too slow to
conveniently dogfood it.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1144023009
2015-05-23 16:56:01 -07:00
Konstantin Shcheglov b92708a961 Use artificial hashCode values.
This slightly improves invalidation performance, 40 ms vs. 60 ms.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1152063004
2015-05-23 09:15:12 -07:00
Brian Wilkerson 2980c8839d Improve logging performance
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1152923002
2015-05-23 09:14:31 -07:00
Konstantin Shcheglov 87fe6b2408 Fill CacheEntry.modificationTime for implicit sources.
So that _validateCacheConsistency() will do nothing for them.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1148413004
2015-05-22 12:18:11 -07:00
Konstantin Shcheglov 1a324ac3e7 Use Set instead of List for 'dependentResults'.
With this change invalidation takes about 60 ms after a change in the cache.dart file.
It is about 80 times after than now - 5000 ms.

60 ms still seems too high :-(

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1150273003
2015-05-22 10:54:32 -07:00
Konstantin Shcheglov 224734d4e4 Manage 'libraries containing part' in DartWorkManager.
It is on the couple critical paths:
1. getErrors()
2. SearchEngine.

The SearchEngine is used in both search itself and by completion.
Without this change search has n^2 complexity, where `n` is the number of targets.

Statistics for search shows more than 10x performance improvement.
Before: 70 ms (analyzer), 230 ms (analyzer + dart2js).
After: 6 ms (analyzer), 17 ms (analyzer + dart2js).

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1152773002
2015-05-22 09:20:55 -07:00
Konstantin Shcheglov 50f786ad50 Use UnlimitedCacheFlushManager for DEFAULT_CACHING_POLICY.
By doing so we avoid _flushManagerMap lookups and also don't do anything for unlimited results.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1151193002
2015-05-22 08:11:19 -07:00
Konstantin Shcheglov 326816f571 Optimize AnalysisContext.getSourcesWithFullName().
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1151563004
2015-05-21 16:05:51 -07:00
Konstantin Shcheglov 85da53429b Fix for a memory leak in CacheFlushManager.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1154563002
2015-05-21 13:52:13 -07:00
Konstantin Shcheglov c3c64d2a86 Depend on LIBRARY_ELEMENT5 to invalidate CONSTRUCTORS.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1146413003
2015-05-21 13:50:49 -07:00
Konstantin Shcheglov deddddc9e5 Add and use AnalysisCache.sources getter.
This is not ideal, we might still want to start managing 'containingLibraries' at some point.

But it speeds up switching between file 10x - DartCompletionCache request of all top-level elements takes now about 170 ms, vs. 1800 ms before.

Also, we need "sources" in many places of AnalysisContext.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1149893004
2015-05-21 08:33:27 -07:00
Konstantin Shcheglov 515d5db2cf Don't get value in SingleMapIterator until it is requested.
So, later we can optimize couple places in AnalysisContextImpl.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1151723002
2015-05-20 15:11:25 -07:00
Konstantin Shcheglov b6fbad3348 Reuse CompilationUnitElement in BuildCompilationUnitElementTask.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1148153002
2015-05-20 11:12:26 -07:00
Paul Berry e519fb8afb In constant evaluation, handle annotation referring to non-const constructor.
We need to be more careful about this in the new task model, since the
new task model is more aggressive about chasing dependencies, and we
don't want constant evaluation to try to visit a non-const
constructor.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1145913002
2015-05-20 09:25:41 -07:00
Lasse R.H. Nielsen b8ad21b9e9 Fix typo in analyzer error message.
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1144043004
2015-05-20 10:07:45 +02:00
Paul Berry e2366de610 Generate the proper error when a constant refers to itself.
BUG=dartbug.com/23490
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1131383008
2015-05-19 19:37:19 -07:00
pq 0ce6fb29a6 Propogate and handle lint analysis option.
BUG=
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org//1131373004
2015-05-19 15:13:26 -07:00