Move PackageConfigFileBuilder into the analyzer_testing public API and
deprecate the copy exposed from package:analyzer. The builder is only
used by test infrastructure, so keeping it in analyzer_testing makes the
ownership clearer and avoids exposing test-only utilities from analyzer.
Update the builder API to accept a rootFolder instead of a rootPath.
This lets callers pass the resource-provider folder directly, so the
generated rootUri is derived from the same file-system abstraction that
created the test files. This avoids accidentally passing POSIX paths
where resource provider paths are required, such as on Windows.
Update existing test utilities and callers to import the new library and
pass Folder objects. Remove the production analysis server dependency on
the builder by emitting the temporary plugin package config JSON
directly.
Change-Id: I46b14710626e0d6d5884afcdc5a05b23077acfc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499081
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The previous set of tests missed two cases:
- a primary constructor with a private named parameter
- constructors introduced by `new`
The latter had some bugs, which are fixed in this CL.
Change-Id: I872a3948dd1b0f791dbea1354c8377e83048e618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484227
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
My intention is to decouple LSP's Document Highlights from the legacy Occurrences implementation. Some recent changes (and one potential upcoming change) were complicated by the differences in the protocol so a separate implementation would be easier.
Along with that, IntelliJ doesn't use occurrences from the server, so it will be easier to deprecate and remove the legacy implementation if LSP is not reliant on it.
As a first step, this adds versions of all tests from `test\analysis\notification_occurrences_test.dart` that didn't already have equivalents in the LSP tests to ensure LSP still has full coverage if the implementations become separate.
Change-Id: I6b45358c812bdad8ca9611d22a27fb31027443a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478369
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
- Hovers
- Occurrences (both legacy and LSP document highlights)
- "Go to Type Definition"
- Outlines
They are mostly working OK. There are a couple of corners that aren't
exactly what I'd expect but probably aren't worth fixing. I added TODO
comments on the relevant tests to explain.
I'm still going through the rest of the checklist but I figured I'd send
out one batch.
Bug: https://github.com/dart-lang/sdk/issues/61644
Change-Id: I9d0fe7052e8b8c726b90d9ed7795be9be23c125e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478483
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
No more flag, always parse into the new AST, always visit new AST nodes,
always return them as child entities, parent-child structure reflects
the new AST.
So, use `namePart` and `body` where possible. Deprecate previous
properties.
This is still de jure a breaking change, because `parent` of deprecated
properties changes. De facto this required very few changes in google3.
Once this CL lands, I will publish `analyzer 10.0.0`, migrate everything
to new properties, delete deprecated properties, and publish `analyzer
11.0.0`.
Maybe deprecate `NamedCompilationUnitMember.name` and migrate to
subclass specific `name` or `namePart` properties before publishing
`analyzer 10.0.0`. This part is not breaking per se.
* Deprecations in `ClassDeclaration`:
* Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
* Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `EnumDeclaration`:
* Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
* Properties `name`, `typeParameters` are deprecated, use `namePart` instead.
* Deprecations in `ExtensionDeclaration`:
* Properties `leftBracket`, `members`, `rightBracket` are deprecated, use `body` instead.
* Deprecations in `ExtensionTypeDeclaration`:
* Properties `leftBracket`, `constants`, `members`, `rightBracket` are deprecated, use `body` instead.
* Properties `constKeyword`, `name`, `representation`, `typeParameters` are deprecated,
use `primaryConstructor` instead.
* **Breaking Change:** While the deprecated members mentioned above still exist in the AST,
their parent nodes have changed. This means that code relying on specific parent-child
relationships for these nodes might break.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: Ic48104da8b029c9b454bbd2336574b7823025565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461841
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This adds code to normalize file contents in `PubPackageAnalysisServerTest.newFile()` so all tests using this base class normalize their source newlines by default (this ensures we run with \r\n on Windows, regardless of the git settings always using \n in this repo).
A flag `useLineEndingsForPlatform` allows option out of this, and any tests that currently fail in this mode set this in their setUp - with the exception of a few that were just trivial fixes.
This will make it easier to fix the remaining tests (by looking at code that does `useLineEndingsForPlatform = false`, deleting it, then fixing those tests).
See https://github.com/dart-lang/sdk/issues/60234
Change-Id: If05bc5f7fe3007151c1290831157b6a62d6bf651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449880
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This allows us to write enums in the mock SDK (which is currently broken). This will allow me to land such an enum in the SDK, in
https://dart-review.googlesource.com/c/sdk/+/445403.
This diverges from the actual Dart SDK implementation of the Enum class
and the _Enum class. I think this is an acceptable divergence; these
classes hardly ever change, and the changes will be easy to follow
when they come, however many months or years from now.
Change-Id: Ia6ff3803415af8c251dbee330a218f2618395cc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446141
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
```
According to Gemini:
There is a very strong and widely followed recommendation.
The formal parameter for a setter in Dart should be named value.
```
So, it makes synthetic setters consistent with manually written setters.
These names sometimes are show in UI, e.g. in hover.
Change-Id: I4b53314aae63dce267906856d98a16ec22d38097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Significantly improve test coverage of `display_string_builder.dart`.
Fix an error involving a missing space when reading the enclosing
fragment of a local variable declaration.
Change the formatting of `ConstructorElement` to print only the type and
not the name to avoid duplication, as they were the same.
Change the formatting of `TypeAliasElement` to just print the name of
the aliased type, rather than the whole aliased element - as this rarely
provided useful information.
Change-Id: Ie1e4a3649063c2b3662ef7bd21327c17a5b1456b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441082
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Main changes:
1. Separating `FragmentBuilder` and `ElementBuilder`. I removed
`augmentation.dart` and its builders, because now it is implemented in
the new `ElementBuilder`.
2. Fragments are not given actual `Reference` objects anymore, there
might be some in the current state, but I will go over this in the
future and remove them completely.
3. Writing and reading elements also happens in two stages: first
fragments, then elements. Each fragment in the summary is given unique
ID, and during writing / reading elements we use these ID to locate
fragments and create elements around them.
4. Lazy loading of `ClassElement` members is simplified and generalized,
could be potentially applied to any `InstanceElement`. Maybe use also in
mixins, which are used somewhat often in Flutter.
5. There are slight changes to tests, mostly to the better, sometime a
bit reordering, a couple of new tests.
There is some dirty code added, especially around patching types for
getters, setters, and their fragments. I plan to clean this in future
CLs as I move toward better implementation, and from using fragments
where this is wrong.
Change-Id: I1e4bf2a3b7ff45f1dba133797e85cd70aa729c11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This was mostly a rename/move of the folder (and the analysis server updated all references), but I also had to:
- add `integration_test/analysis_options.yaml` to import from `../test` to get the same lint ignores
- update paths of exclusions in `verify_sorted_test.dart`
By moving all of the tests that start the server out-of-process out of test, we can:
1. Use "dart test" to just run the faster tests ("dart test test") and get functionality of the pkg:test runner (for example running tests concurrently and JSON output)
2. Allow VS Code to spawn different debug sessions for the "test" and "integration_test" folder, which means we can use a `preLaunchTask` to trigger compilation of the analysis server from source whenever running integration tests (avoiding having to compile manually, or run from source in a way that compiles a new server for each test suite)
Change-Id: I37cc03dc32d08c5b51a2eab79f6338bb079b32ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>