Commit Graph

3080 Commits

Author SHA1 Message Date
Paul Berry 73a58c81d4 Merge commit '31d0896a8b8c7d2a8c0496c9d8d817356ef897ad' into analyzer 2018-11-02 10:44:56 -07:00
Paul Berry 31d0896a8b Introduce API so that the linter can be migrated away from Element.context.
The API change requires adding a "context" parameter to
NodeLintRule.registerNodeProcessors.  If we did this naively it would
be a breaking change since the existing linter code overrides this
method with an implementation that doesn't accept such a parameter.
So to avoid making this a breaking change, we introduce a new
interface NodeLintRuleWithContext that extends NodeLintRule, and adds
the context to the registerNodeProcessors method as an optional
parameter.  The analyzer will only pass in the new parameter if the
lint rule implements the new interface; otherwise it will call the
method in the old way.  This will allow the linter to be migrated to
use the new API at its pace.

The next breaking change version of the analyzer will change both
NodeLintRule and NodeLintRuleWithContext so that the context parameter
is required, and will pass in a context unconditionally.  At a later
date, after the linter has been fully migrated to the new analyzer
version, we will be able to switch back to NodeLintRule and deprecate
NodeLintRuleWithContext.

Change-Id: I75ada0e94e26f831d6f2cb82cddfa706100eb185
Reviewed-on: https://dart-review.googlesource.com/c/82522
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-11-02 14:22:12 +00:00
Konstantin Shcheglov e3c8774543 Add AnalysisSession.analysisContext, stop using AnalysisDriver's AnalysisResult outside the driver.
Change-Id: I63138e002d9e777f51d2d843f7ef2b1f32fed3e0
Reviewed-on: https://dart-review.googlesource.com/c/82529
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-11-02 14:16:31 +00:00
Paul Berry a4c73e3739 Merge commit '5226b5c307b04da8df96924a46780eb31a5bd75e' into analyzer 2018-11-02 06:06:20 -07:00
Konstantin Shcheglov 1fb58ad61b Fix CONVERT_DOCUMENTATION_INTO_LINE when there is an empty line.
R=brianwilkerson@google.com

Change-Id: Ib5c103426bf5ebb84945816c01e9f5bbcef941ba
Reviewed-on: https://dart-review.googlesource.com/c/82472
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-11-01 20:25:29 +00:00
Dan Rubel 8c20adffe6 Increment analysis server protocol version
Change-Id: I470a51b035c765d710e920f3fe77dfa11a7aca92
Reviewed-on: https://dart-review.googlesource.com/c/82480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-11-01 19:17:04 +00:00
Danny Tuppeny d802c7d33d Improve LSP server tests
Change-Id: Ib9c7cd2966c6cf4d0c02e56ec405761f899e6668
Reviewed-on: https://dart-review.googlesource.com/c/82441
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-11-01 17:08:16 +00:00
Konstantin Shcheglov d6d312cca6 Add 'Wrap with StreamBuilder' quick assist.
R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I109bfe41344943b6d1b456cb178f1db4d5e92858
Reviewed-on: https://dart-review.googlesource.com/c/82341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-11-01 15:33:04 +00:00
Danny Tuppeny 8852d36315 Add --lsp flag to analysis server and add basic Initialize handler
Change-Id: Iaf6c2a7cd56dea27233c4be1df2da900653e1822
Reviewed-on: https://dart-review.googlesource.com/c/81275
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-31 20:00:51 +00:00
Brian Wilkerson dee5e8a070 Convert more classes to mixins
Change-Id: I85bee426236a510305fc38a49b2f9348af7698df
Reviewed-on: https://dart-review.googlesource.com/c/82181
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-31 13:49:51 +00:00
Konstantin Shcheglov 87ee9c2c7d Don't generate library directive in CREATE_FILE.
R=brianwilkerson@google.com

Change-Id: Ia2853119ac119cfeff4c72f2528ebe6bc51745e4
Reviewed-on: https://dart-review.googlesource.com/c/82161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-30 22:01:44 +00:00
Brian Wilkerson 56861d5c98 Additional cleanup following session api change
Change-Id: I838c840ca001231890ea6fd3591de446f24c3d1d
Reviewed-on: https://dart-review.googlesource.com/c/82160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-30 20:16:15 +00:00
Brian Wilkerson 298d22f4ab remove async parse method
Change-Id: I7a2e633b43283221790fb88a12065fed3dcdabb7
Reviewed-on: https://dart-review.googlesource.com/c/82120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-30 19:26:00 +00:00
Konstantin Shcheglov 1c6774ba34 Create AnalysisDriver in AbstractContextTest using the new API.
Change-Id: Ia3b8e0fa297026f8d002cf4b29f179e686876d8c
Reviewed-on: https://dart-review.googlesource.com/c/81980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-30 15:57:59 +00:00
Paul Berry 03df087c60 Merge commit '1215d9163af58229132e4776a89ea87d5302c9e3' into analyzer
Conflicts:
	pkg/analysis_server/lib/src/edit/edit_dartfix.dart
	pkg/analysis_server/lib/src/services/correction/assist_internal.dart
2018-10-29 08:48:27 -07:00
Brian Wilkerson 57c185c89d Remove remaining uses of Element.context from server
Change-Id: Ibc383064951e181fa8e951714904526c2ea42f5f
Reviewed-on: https://dart-review.googlesource.com/c/81749
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-10-29 14:56:24 +00:00
danrubel 0fe448a996 Revise the analysis server edit.dartfix protocol
This updates the edit.dartfix protocol to separate location from the text
describing the changes so that the dartfix client can choose
what location information to display and how it should be displayed.

Change-Id: Ic56a4cb187538571d60136d6de9265d879fccb53
Reviewed-on: https://dart-review.googlesource.com/c/81780
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-29 01:50:27 +00:00
Konstantin Shcheglov 142641e596 Stop using AnalysisContext.getContents() in SelectionAnalyzer.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I3464c88febba778b368061470b5aa80c3037e897
Reviewed-on: https://dart-review.googlesource.com/c/81660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-26 21:49:06 +00:00
Devon Carew d53b034a64 Fix several analysis lints.
Change-Id: If7921d5cfc3dd2af79699f9905d7f3b106254cd0
Reviewed-on: https://dart-review.googlesource.com/c/81722
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-10-26 21:41:35 +00:00
Konstantin Shcheglov 5b1641432d Create CorrectionUtils only for ResolveResult.
So, it is always self-consistent, never ask AnalysisContext for the
unit file content.

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

Change-Id: I93e71f7f8fa577b8e123c91252f3038a50cdccef
Reviewed-on: https://dart-review.googlesource.com/c/81580
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-26 14:04:12 +00:00
Brian Wilkerson 2fa00fd876 Remove the return type for Starter.start
Change-Id: Id60098a49f0eebeca7a43d99603e590e81d54682
Reviewed-on: https://dart-review.googlesource.com/c/81480
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2018-10-25 21:32:14 +00:00
Konstantin Shcheglov 20d81452e5 Remove AstProvider, use AnalysisSessionHelper.
This is a step toward making CorrectionUtils constructor accept full
ResolveResult, instead of partial (and potentially inconsistent) unit
and AnalysisContext.

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

Change-Id: Ic386d48af2d00ecaf9ef13b8480e7e78c7d52efc
Reviewed-on: https://dart-review.googlesource.com/c/81382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-25 19:09:11 +00:00
Konstantin Shcheglov c689578779 Switch AnalysisDriver to RestrictedAnalysisContext.
It has two methods that should not be there: getContents() and
parseCompilationUnit().  Removing them will require more work on
Analysis Server.  But at this CL shows that we don't do any resolution
or element access through AnalysisContext in analysis_server or analyzer_cli.

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

Change-Id: Ib1625a0f590ebce55153dd0b29984f9b6d51792b
Reviewed-on: https://dart-review.googlesource.com/c/81329
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-10-24 21:31:56 +00:00
Paul Berry 2e2c360371 Merge commit '0b15595913ff89d8486e6677af0254dd6feab350' into analyzer 2018-10-24 06:09:47 -07:00
Dan Rubel 4695b5f138 Add "convert to int literal" to dartfix
This updates the analysis server edit.dartfix request
to find and convert double literals to int literals.
Under the covers it uses the prefer_int_literal lint
and gracefully degrades if the lint is not found
(e.g. third_party/linter needs to be rolled).

Change-Id: I0236af9c19667e543541fef18836bfeeba8c67d7
Reviewed-on: https://dart-review.googlesource.com/c/81302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-10-24 01:22:02 +00:00
Dan Rubel 4f2a4e69a8 new convert-to-int-literal assist
Change-Id: I25f08d82fd4afaba485059e558536b37855bb6c9
Reviewed-on: https://dart-review.googlesource.com/c/81301
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-23 20:29:27 +00:00
Danny Tuppeny e4566d3dbd LSP: Fix nulls and missing fromJson calls in unions
Change-Id: I666d32e8a0463ba07756878b22293a7d3f55915d
Reviewed-on: https://dart-review.googlesource.com/c/81268
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-23 17:42:19 +00:00
Paul Berry 5954a3e5d0 Merge commit '6443a8036d3914f28f1d1e140a108487953cd909' into analyzer 2018-10-23 06:03:57 -07:00
Danny Tuppeny a394e4f492 Fix handling of JSON with interfaces nested within Unions
Change-Id: I926c2374860824db3ceae6d74286474feb730676
Reviewed-on: https://dart-review.googlesource.com/c/81100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-23 07:08:44 +00:00
Paul Berry 5665636983 Merge commit '7fd78ed5b606e64d30ec201de9adce6fdf8856ba' into analyzer 2018-10-22 13:07:24 -07:00
Brian Wilkerson 67b9f2ec8d Deprecate Element.unit and Element.computeNode
Change-Id: Id2a70b4a194cba28bfdc0990d7306d6561f422db
Reviewed-on: https://dart-review.googlesource.com/c/81060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-22 16:50:43 +00:00
Brian Wilkerson a342cecffd Disable support for the old super mixins
Change-Id: I8f8074b67ea43249fcc10deddd2325938996d529
Reviewed-on: https://dart-review.googlesource.com/c/79469
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-22 16:02:01 +00:00
Danny Tuppeny cddc2d42e1 Handle generic types in LSP spec parsing
The regex wasn't picking up generate type args (in interface definitions or usages in field definitions). This adds <> characters to the regex and handles them in mapping of types (as well as adds some additional tests to cover this).

Change-Id: I8187b3d2abb2b35c0d7638839e3116700cfbf9e0
Reviewed-on: https://dart-review.googlesource.com/c/81004
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-22 14:40:54 +00:00
Konstantin Shcheglov c44fa48f8f Extract and rewrite MethodInvocation resolution.
This is a copy of https://dart-review.googlesource.com/c/sdk/+/78182,
but now in the analyzer branch.

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

Change-Id: I75d17a351ee7a33c164d560009cf3ffd088d956a
Reviewed-on: https://dart-review.googlesource.com/c/80942
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-22 03:36:30 +00:00
Konstantin Shcheglov 02651515eb Fix identifyWidgetExpression() for Flutter.
Probably a bit pessimistic approach, allow only cases that we know
to be valid and useful.

R=brianwilkerson@google.com

Bug: https://github.com/flutter/flutter-intellij/issues/2714
Change-Id: I8835c03d919c1f00a986ff3ef677c7f69995682f
Reviewed-on: https://dart-review.googlesource.com/c/80985
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-21 21:12:13 +00:00
Konstantin Shcheglov 7c80d22878 Make indexing in AnalysisDriver optional.
This makes my Flutter benchmark about 6% faster.

It will not affect performance of `flutter analyze`, because for now
Analysis Server always enables indexing and search. But we could make
this optional, for DAS clients that need only errors, but not search,
refactorings, etc.

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

Change-Id: I4eafc37592a3bb18bd2c6ab84dc2515a4d42697b
Reviewed-on: https://dart-review.googlesource.com/c/80880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-10-21 20:20:05 +00:00
Brian Wilkerson 4e36069271 Add fixes for missing implementation of a superclass constraint
Change-Id: I5ea1e961dbb98c034131c15d1945f21bcfa0df1d
Reviewed-on: https://dart-review.googlesource.com/c/80980
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-21 15:03:16 +00:00
Brian Wilkerson 20c75ccfb1 Remove more dead code from server
Change-Id: I20689dc5fefd3a636f78b38929a886ea96d01e0f
Reviewed-on: https://dart-review.googlesource.com/c/80961
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-20 00:30:51 +00:00
Paul Berry fe5467092a Merge commit '7a3762d4a91aed0b3885259b297953d0c38ce849' into analyzer 2018-10-19 10:00:38 -07:00
Brian Wilkerson 961484aa05 Remove an unused field from AnalysisServer
Change-Id: I7b7724db25451f3c64bdb299a43c8d475b8c28c7
Reviewed-on: https://dart-review.googlesource.com/c/80840
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-19 16:55:38 +00:00
Brian Wilkerson b35e717fae Clean up the fix processor hierarchy
Change-Id: I2ca593397f061aa1cb0d91c98874451c8f53a206
Reviewed-on: https://dart-review.googlesource.com/c/80841
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-19 16:21:23 +00:00
Danny Tuppeny a502061c11 Add test and implementation for package: uris
Change-Id: Ibf114d83cade42ced7601befafec8a7e7c9f4bc7
Reviewed-on: https://dart-review.googlesource.com/c/78985
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-19 10:41:48 +00:00
Danny Tuppeny bb93696c96 Simplify canParse on LSP types to only check for required fields
Change-Id: Idafb6936f0dd7adf283a690c5e56e2eebfc53ee4
Reviewed-on: https://dart-review.googlesource.com/c/80666
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-18 14:55:39 +00:00
Danny Tuppeny 36551624e1 Implement fromJson() constructors for LSP types
Also add a canParse() method that can check whether some provided JSON can be decoded into that type (used for detecting with type from a union to decode as).
Support equality checks on unions and a valueEquals() helper
Remove brittle tests that do exact comparisons on generated code
Fix deserialisation of lists to be cast and toList()'d
Add a more complete JSON test that includes lists, enums

Change-Id: Id56fdad9b1454e540e55907e0ff2608263a87c40
Reviewed-on: https://dart-review.googlesource.com/c/80580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-18 13:52:59 +00:00
danrubel 5c1a40837e Update analyzer fix sorting by priority
Change-Id: I23dd4c8125c47de9e0c16cde1c43908f18649e6e
Reviewed-on: https://dart-review.googlesource.com/c/79601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-10-17 02:16:02 +00:00
Jaime Wren 2d397d1da6 Fix for dartbug.com/34821, variable_name_contributor.dart to complete "var SomeType |", to "someType" and "_someType", for declarations that can be denoted private.
Change-Id: I712ebc0f7a7288e1ace713f57b6694f0ed4874eb
Reviewed-on: https://dart-review.googlesource.com/c/80362
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-10-16 22:58:27 +00:00
Brian Wilkerson da67d58110 Remove some unnecessary await expressions
Change-Id: I2a2c5625bba824270d6b9d1ca67e8476e1fbc374
Reviewed-on: https://dart-review.googlesource.com/c/80341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-10-16 20:29:23 +00:00
Danny Tuppeny 3a69805f6b Switch enums that don't have type aliases to stronger-typed values
Change-Id: Ia05c234c27c0c71bbb25ed29c3f7a0c02e938acb
Reviewed-on: https://dart-review.googlesource.com/c/80203
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2018-10-16 18:03:59 +00:00
Brian Wilkerson fade5f33f0 Regenerate code based on the server spec after updates to the generator
Change-Id: I3643bf8fb3732e3a664ae2bfdccc554fe4621a06
Reviewed-on: https://dart-review.googlesource.com/c/80262
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-10-16 16:47:59 +00:00
Danny Tuppeny 9ba152b69e Mark deprecated fields as such
Change-Id: Ifda0be1a8ab3824278994dc70002115fa82976e1
Reviewed-on: https://dart-review.googlesource.com/c/79841
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-10-16 15:57:16 +00:00