Commit Graph

4276 Commits

Author SHA1 Message Date
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
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
Brian Wilkerson 650ac5458d Add plugin support for command-line access
R=pquitslund@google.com

Review URL: https://codereview.chromium.org//1136633007
2015-05-19 14:27:54 -07:00
Brian Wilkerson 0e8520eaa9 Create default tasks if plugins are not being used
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1140313003
2015-05-19 14:12:13 -07:00
Paul Berry a9982b0e02 Properly handle circular references among constants in the task model.
Tasks may now override the getter "handlesDependencyCycles" to return
true to indicate that they can deal with circular dependencies.  Most
tasks will not have to do this, since outside of constant evaluation
circular dependencies among tasks should only be possible due to an
analyzer bug.

Any task that handles dependency cycles can detect that a cycle has
occurred by consulting AnalysisTask.dependencyCycle inside its
internalPerform() method.  The ComputeConstantValueTask uses this to
determine which constants are involved in the cycle.

This required modifying the TaskInputBuilder classes so that if the
current input can't be evaluated due to a circularity, they can
continue on to evaluate other inputs.  This allows the circularity to
be reported on the whole strongly connected component, rather than
just the firs cycle that was noticed (which would be
nondeterministic).

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

Review URL: https://codereview.chromium.org//1147853002
2015-05-19 12:43:28 -07:00
Paul Berry eb6d1e2579 Fix constant evaluation dependency analysis for const external factories.
With the current constant evaluator, the bug is benign because we only
do dependency analysis within a library cycle, and the library cycle
containing dart:core (which is the only library cycle with const
external factories) contains no invocations of those const external
factories.

But in the new task model we do full dependency analysis across
library cycles, so the dependency analysis needs to be correct in
order for the const external factory to be safely invoked.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1134343003
2015-05-18 13:18:24 -07:00
Konstantin Shcheglov 7e8f650d35 Use short names in 'Create File' Quick Fix messages.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1147733002
2015-05-18 12:47:40 -07:00
Konstantin Shcheglov 4936eb8d5d Fix for 'Create part' Quick Fix.
1. NonExistingSource.modificationStamp should return -1.
2. NonExistingSource.fullName should be always an absolute path, not a URI.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1135073004
2015-05-18 11:55:23 -07:00
Brian Wilkerson c4a723465b Stop reporting error when not parsing function bodies (issue 23460)
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1145733002
2015-05-18 10:43:53 -07:00
Brian Wilkerson 1a3e349409 Handle type parameters correctly when generating hints (issue 23243)
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1142853002
2015-05-18 10:41:11 -07:00
scheglov@google.com a9d194d049 Always send errors/lines with parsed/resolved units.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1141953002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45812 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 15:44:29 +00:00
scheglov@google.com f058a6ad33 Tweaks for using task model in Editor.
It works in general, bug currently it is buggy and slow.

Notes:

1. Implicit dependencies backfire.
   If the cache size is not big enough and we end up flushing some CU, then recreating it, it looses its LibraryElement.
   We need an explicit dependency on it.

2. If the cache size is not big enough, this still may cause an infinite analysis cycle.

3. We need to implement activating / deactivating cache partitions to change cache size.

4. Probably we need to set LineInfo into ChangeNotice always.

5. There are bugs in type hierarchy.

6. Semantic highlighting takes too long to display.

7. Overlay changes are not used.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1125303008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45811 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 15:04:50 +00:00
paulberry@google.com 955a7c53a3 Modify WorkOrder to use a dependency walking algorithm that handles cycles.
There is no functional change in the behavior of the WorkOrder class;
if a cycle is found, we still set the ".exception" field in all the
work items involved in the cycle.

In a follow-up CL I will add the ability to override this behavior
when computing constant values.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1144563003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45800 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-14 22:38:26 +00:00