61 Commits

Author SHA1 Message Date
Konstantin Shcheglov 47ba94ebea CQ. Switch ErrorReporterTest to simpler RecordingDiagnosticListener.
Change-Id: Iaf5a243ed0b35c369e254e5541448aab06c48b6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511280
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-06-11 10:51:44 -07:00
Konstantin Shcheglov 809d8a778a CQ. Start removing resolution state from ResolutionTest.
We still have `late ResolvedUnitResultImpl result` for now, but many
tests migrated to explicit `TestResolvedUnitResult` and its getters.

Start migrating analyzer resolution tests away from the implicit
ResolutionTest state. Store the TestResolvedUnitResult returned by
resolve helpers in local variables, then read nodes and elements through
that result.

Update helper methods to take the resolved result explicitly when they
need access to findNode or findElement. Also return resolved results
from small wrapper helpers so their callers do not have to depend on
shared state.

This keeps each test tied to the unit it resolved and prepares the test
harness for removing the remaining stored resolution result.

Change-Id: I5e9331fb574d962473e5d36922107f674d7340cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505621
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-22 09:39:40 -07:00
Konstantin Shcheglov 5d17e0aa92 CQ. Stop using mocks of Source in analyzer/.
Use FileSource backed by analyzer_testing resources instead of the
test-only Source implementations in analyzer tests.

Update the lightweight TestAnalysisContext to receive a
ResourceProviderMixin and install a URI resolver that produces real
FileSource instances for the dart: and package: URIs used by mock SDK
elements. Convert scanner, diagnostic, options, constant, type system,
and workspace tests to create sources from in-memory files.

Remove the remaining Source mock helpers, including TestSource,
TestSourceWithUri, local Source mocks, and the unused TestTypeProvider.
This keeps test sources closer to production Source behavior and avoids
partial mock implementations that rely on noSuchMethod stubs.

Change-Id: Iad600fb7f5ea00d2c015191df548e0d66a424940
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499422
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-30 12:39:38 -07:00
Danny Tuppeny a2fc9d8767 [analyzer] Improve locations for diagnostic context messages when no names
Previously -1 was used as the offset for unnamed elements when building diagnostics, but this is never a valid location (and for VS Code, results in the diagnostic not appearing at all, even if the invalid location is only in a context message).

With this change we use the offset of the fragment instead.

Fixes https://github.com/dart-lang/sdk/issues/62955.

Change-Id: I6aec9b7a9a6d49b151b1cf3eaea4b684486b6d8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490121
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-03-25 13:13:30 -07:00
Paul Berry 758d3a8803 [messages] Convert assignability checks to use literate diagnostic API.
Converts the code that reports diagnostic codes `invalidAssignment`
and `argumentTypeNotAssignable` to use the literate diagnostic
reporting API.

This was challenging because some of the code for reporting these
diagnostics (specifically the method
`ErrorDetectionHelpers.checkForAssignableExpressionAtType`) was
parameterized by diagnostic code, but the two diagnostics accepted a
different number of parameters. To get the type safety of the literate
diagnostic API while preserving the existing behavior, I've created an
abstract base class, `NonAssignabilityReporter`, with a method
`createDiagnostic`, that encapsulates the differences in how to handle
the two diagnostic codes.

Change-Id: I6a6a69649e53f6980b5033771b14dbfdaa5895d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467481
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-12-11 10:13:50 -08:00
Paul Berry a396025ba0 [messages] Begin migrating analyzer to new diagnostic message reporting.
Translates uses of the old diagnostic reporting API, e.g.:


    _diagnosticReporter.atNode(
      node,
      diag.deprecatedExtend,
      arguments: [element.name!],
    );

To use the new "literate" diagnostic reporting API, e.g.:

    _diagnosticReporter.report(
      diag.deprecatedExtend.withArguments(typeName: element.name!).at(node),
    );

This CL was created by the following steps:

- Run the script
  `pkg/analyzer_utilities/tool/messages/use_literate_api_in_analyzer.dart`

- Execute `dart fix --apply --code=unnecessary_import` on the
  `pkg/analyzer` directory (this removes imports that are no longer
  necessary due to the change)

Not all call sites have been updated at this point. Complex cases were
skipped by the tool and will have to be updated manually. Also,
diagnostic messages that still have the old placeholder parameter
names `p0`, `p1`, `p2`, etc. are still reported using the old API; I
plan to migrate these call sites at the time that I update the
parameter names (by re-running the script).

Change-Id: I6a6a6964671ac6e2ad5acc9ed55658cd6c02e4b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467460
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-12-10 20:14:49 -08:00
Paul Berry 9f6d1c1029 [messages] Start using toplevel diagnostic constants.
Changes the analyzer and related packages so that when they refer to
diagnostic constants, they do so via the import prefix `diag`, which
refers to the appropriate `diagnostic.dart` file containing the top
level diagnostic constant declarations, rather than the static
declarations inside `DiagnosticCode`-derived classes (which will soon
be removed).

This CL was created by the following steps:

- Run the script
  `pkg/analyzer_utilities/tool/messages/switch_to_toplevel_diagnostics.dart`.

- Execute `dart fix --apply --code=unused_import,unnecessary_import`
  on the following directories (this removes imports that are no
  longer necessary due to the change):
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end`
  - `pkg/analyzer_cli`

- Execute `dart format` on the following files and directories:
  - `pkg/analysis_server`
  - `pkg/analyzer`
  - `pkg/linter`
  - `pkg/analysis_server_plugin`
  - `pkg/analyzer_plugin`
  - `pkg/analyzer_testing`
  - `pkg/front_end/test/scanner_test.dart`

  (Note that `pkg/front_end` and `pkg/analyzer_cli` are not
  re-formatted as whole directories because they contain `.dart` files
  that are test cases rather than source code, and reformatting those
  files might change test expectations.)

- Manually add `diag` to
  pkg/front_end/test/spell_checking_list_tests.txt.

- Manually fix the ignore comment in
  `pkg/analyzer_testing/lib/src/analysis_rule/pub_package_resolution.dart`. (The
  script `switch_to_toplevel_diagnostics.dart` automatically adds it
  after `import 'package:analyzer/src/diagnostic/diagnostic.dart' as
  diag;`, but then executing `dart format` bumps the ignore comment to
  the following line, where it has no effect.)

Change-Id: I6a6a69643022aab2b5a6224fb4124eead243260d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461521
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-11-12 16:53:42 -08:00
Sam Rawlins 7059532b48 analyzer: Remove AnalysisErrorListener and friends
* Remove AnalysisErrorListener, `RecordingDiagnosticListener.errors`,
  and `RecordingDiagnosticListener.getErrorsForSource`.
* Deprecate `BooleanDiagnosticListener.onError` and
  `RecordingDiagnosticListener.onError` in favor of `.onDiagnostic`.
* Deprecate DiagnosticOrErrorListener. Where this class is used in
  private API, replace it with DiagnosticListener. Where this class is
  used in public API, keep it and ignore the deprecation lint.

Change-Id: Ie9c89008269db8f42e4ebd161df2764d27dfe0da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-20 12:58:24 -07:00
Paul Berry f2123a8f7c [analyzer] Rename error constants to camelCase.
This change was generated by the following process:

- The script `pkg/analyzer/tool/messages/rename_error_constants.dart`
  was run. This generated the vast majority of the diffs.

- Then all modified files were reformatted using
  `tools/sdk/dart-sdk/bin/dart/format`.

- Finally, the script `pkg/analyzer/tool/messages/generate.dart` was
  run, to rebuild generated code.

Change-Id: I6a6a69644ed8740ad6269d98cb169076151824ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-08-13 22:02:42 -07:00
Fedor Shcheglov 8cfa901c6e Rename nameOffset2 to nameOffset
Change-Id: I3c8051840122b6046bc89ed48ec329c825607fe5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-13 20:44:49 -07:00
Fedor Shcheglov 318aeb322b Deprecate DartType.element3, use element instead.
Change-Id: Idef9da09c565a05fa84869f7433df3c24c6fbb5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435521
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 07:23:11 -07:00
Sam Rawlins f51d37e9b1 analyzer: Rename ErrorReporter to DiagnosticReporter
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I84b095199773040fc0444364964654c4373a9d77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433740
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-10 12:24:34 -07:00
Sam Rawlins 903d77cc82 analyzer: Rename ErrorListener classes to DiagnosticListener
Work towards https://github.com/dart-lang/sdk/issues/60635

I tried to keep this minimal but still sensible:

* Rename AnalysisErrorListener and all subtypes to use 'Diagnostic'.
* Rename all instantiations of such classes if they previously
  contained the word 'error'.
* Rename `RecordingDiagnosticListener.errors` to `.diagnostics`.
* Rename some _testing_ instance members that had the word 'error'
  to instead use 'diagnostic'.

Change-Id: I3948e27ba28ac2494092e04f4e1d201a20cc1135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433004
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-05 14:05:40 -07:00
Sam Rawlins 1804a38ad4 analyzer: Use Diagnostic instead of deprecated AnalysisError in tests
Change-Id: I0fdc8664f1bfd0b887dedd3c7399046ec6ccb3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426901
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-06 08:56:51 -07:00
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Konstantin Shcheglov cb96256bc2 Elements. Migrate src/dart/analysis/search.dart
Replace index / search of `CompilationUnitElement` with special
`referencesLibraryFragment(LibraryFragment)`, because they are not
elements.


Change-Id: I4de4ce42270bdad92996bedbd06f108a7c71dffe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412681
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-02-27 14:13:33 -08:00
Brian Wilkerson 0577ca064d [Migrate] error_reporter_test.dart
Change-Id: Iee6e8ec17881bcc514b8cef9039f88e2f5afcde3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403908
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-01-10 07:54:39 -08:00
Konstantin Shcheglov 30b3f9d0a6 CQ. Deprecate 'reportErrorForSpan', use 'atSourceSpan' instead.
Change-Id: I4324154842ec462acbdda49e09d1a74f147c56f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383443
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2024-09-03 20:14:34 +00:00
Konstantin Shcheglov 0ef8f05c6c Fix 'unnecessary_final' in analyzer/.
But don't enable it yet, pending https://github.com/dart-lang/linter/issues/4938

Change-Id: I42df6e5c2699b08d729518c0565165d81e07ad3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-16 21:46:15 +00:00
Konstantin Shcheglov 106db0d7b4 CQ. ErrorReporter, use atElement() instead of reportErrorForElement()
Change-Id: Ife5f6d04ee7c15e7703db3ad81eb7707c7f00ceb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352053
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-13 17:16:07 +00:00
Konstantin Shcheglov 2a88162b84 ErrorReporter. Use atNode() instead of reportErrorForNode().
Change-Id: I118fb7623d3effc3bf4bebdeb586196659e8da88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349630
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-02 01:56:59 +00:00
Konstantin Shcheglov 3ea570739d Legacy. Deprecate 'isNonNullableByDefault' in ErrorReporter constructor.
Change-Id: Ia05e113115fb29b47ba12fc9bf46c1d4c04721b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349463
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-01 01:51:48 +00:00
Keerti Parthasarathy c31be01bbe Improve message when generating error ARGUMENT_TYPE_NOT_ASSIGNABLE for records.
Fixes BUG: #53580

Change-Id: I4c5a7b5147875ced2319ba36a396067a5ce1a657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330668
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-10-18 17:56:49 +00:00
Brian Wilkerson 38581783e6 Generate the list of error codes
Change-Id: I315619a30ac8690e90be2b3a3ad7d849c28f2c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-10 17:26:00 +00:00
Konstantin Shcheglov 683e2419da Deprecate 'DartType.element2' use 'element' instead.
Change-Id: I6986a058616db489987789cfab09d53a450e3ab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262666
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-10-05 16:30:09 +00:00
Konstantin Shcheglov e03170035a Deprecate 'get name2', use 'get name' instead.
Change-Id: Iee8ef5fb6700d96c857a22a99dc61dac3da88572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260443
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-22 02:22:47 +00:00
Konstantin Shcheglov cbfad8f802 Deprecate DartType.element, use specific element accessor for InterfaceType, TypeParameterType.
For `InterfaceType` keep `element2` deprecated and define
`InterfaceElement get element2` instead. Most changes are because
of this.

Change-Id: I13b888610fc707438c3c97b676f1460e7fc2b040
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253564
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-04 16:18:06 +00:00
Konstantin Shcheglov 01173e2aa2 Deprecate 'name' in AST, use 'name2' token instead.
Change-Id: I867f009dca12208f835199297d2ea85c203c8556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252566
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-02 16:25:34 +00:00
Danny Tuppeny 147dca35a3 [analyzer] Use LinkedHashSet for recording errors to keep order consistent
Fixes https://github.com/Dart-Code/Dart-Code/issues/3934.

Change-Id: I1cd9fd35ddbbd768877e6b2b2984056ed5ec5d9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-04-20 16:03:18 +00:00
Konstantin Shcheglov 20b560226e Rename newFile2() to newFile().
Change-Id: I1c2a4f15dee607a0a6241dfaf2d764a7d284389b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241510
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-04-19 02:59:57 +00:00
Sam Rawlins 843a31fe45 Prefer string interpolations; other small fixes for lints 2.0.0
Change-Id: Ie66c42ac738adbcf07d0b7c5ccc77e34975008c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-18 22:13:21 +00:00
Konstantin Shcheglov 41b3e0abcc Make 'content' required in ResourceProviderMixin.newFile()
Change-Id: Id697b0736b95a913c31247a66425027852f1ddc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-03-14 17:31:48 +00:00
Konstantin Shcheglov 60b428e2b1 Deprecate superclass2, mixinTypes2, etc.
Change-Id: Ieaaeab57930cb93f5b6b1323efe63c3395b79993
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232742
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-17 02:20:42 +00:00
Paul Berry 0a39aa7cf6 Make all analyzer message arguments non-nullable.
Cases where `null` was being passed as an argument to formatting a
message have all been fixed in previous CLs; all that remains to do is
change the type system to reflect that, and insert `!`s in a few
places.

This brings us one step closer to being able to make analyzer message
formatting type safe.

Change-Id: Id9e0d0b32f29cde0fdc5227417b7a2e3fc3b443d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216272
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-20 11:31:51 +00:00
Konstantin Shcheglov e1b5db7478 Deprecate getters that return TypeName, replace with returning NamedType.
Change-Id: I13764db3da27d5eabe972aab32cdf587a7de53e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-22 21:01:58 +00:00
Ahmed Ashour f1ded6af56 Remove import dart:core
Fixes #47092

TEST=existing

Change-Id: I3c5c0a1ec5e0426642a5dc70aa9a0391a143ed93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212298
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-09-06 11:57:40 +00:00
Konstantin Shcheglov 3a2e4d92a2 Remove ExperimentStatus.latestWithNullSafety
Change-Id: I0a813ce1a64f1d6201005280cf7a116deaf8da1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209581
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-11 02:37:44 +00:00
Konstantin Shcheglov 79327c9f05 Make ResolvedUnitResult.content/unit non-nullable.
Change-Id: Ia79567d248f2c91290bfdf8204ea7e9f3dc85fa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206668
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-14 02:33:10 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Sam Rawlins 13f9993511 Analyzer: Extract parser test base classes, helpers
Each of the *_Fasta test cases has a lot of test cases from the
corresponding *Mixin mixin. I started to combine _all_ of these
in parser_test.dart, but the file became too long; the formatter
was freezing IntelliJ.

So I've extracted out the non-test classes into parser_test_base.dart.

I'd like to extract each test class into its own file. For now, I
reduce half a dozen *_Fasta/*Mixin pairs into individual test classes.

Change-Id: I8dd7f28a6fe23e31f956cdb2f1d221669db376dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176064
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-15 03:57:59 +00:00
Sam Rawlins 1b060fb77b Analyzer: prep for null safety with explicit casts, late hints
* `reference.hasElementFor` implies that `reference.element` is not null.
* Using `whereType` prevents an explicit cast from being needed.

Change-Id: I800f7183292ecd0bb6370a381b1d0b924b7f5a61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170744
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 22:07:43 +00:00
Sam Rawlins e56e5104cf Analyzer: prep file_system tests for null safety.
Fields initialized in `setUp` are late.

Variables initialized with implicit casts like:

    ClassDeclaration clazz = unit.declarations[0];

would need a cast:

    ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;

so they are updated to use var, which is more idiomatic:

    var clazz = unit.declarations[0] as ClassDeclaration;

Change-Id: I4e4ae814a814d3a4200c5078a6904dbac0a8140c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170520
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-05 17:39:37 +00:00
Konstantin Shcheglov c2379a800a Move more tests to PubPackageResolutionTest.
R=brianwilkerson@google.com

Change-Id: Ic6c37d069323cc06c6ab630757625a7e0b072200
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-06 22:30:39 +00:00
Konstantin Shcheglov ba92b78acd Move errors from StaticWarningCode to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/42821
Change-Id: I153c48d7a2e4a02026928e6203aacf8f2dc029ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-26 04:19:25 +00:00
Konstantin Shcheglov 1cc5d6927a Deprecate ErrorReporter.reportTypeErrorForNode()
We always want to convert DartType(s) to their String presentations
using getDisplayString(), never using toString(). Also it is OK  to do
some processing during error reporting, it should be rare operation.

R=brianwilkerson@google.com

Change-Id: I57b80cdd7e91de2eb0d06aa84e15ffc0f577090b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-10 18:41:35 +00:00
Konstantin Shcheglov 9456316b51 ErrorReporter should know isNonNullableByDefault.
So, when we call DartType.getDisplayString() we know if the type
presentation should include nullability suffixes.

This fixes many, but not all places where we need to present types.
There are places where we don't go through ErrorReporter, but call
ErrorListener directly. I plan to replace all these with ErrorReporter.

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

Bug: https://github.com/dart-lang/sdk/issues/39651
Change-Id: Ic77a556e7834d8f757c8b13eed37ed1d34f47348
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127744
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-12-10 01:31:22 +00:00
Konstantin Shcheglov 364dd8936b Fix unnecessary_new in analyzer.
R=brianwilkerson@google.com

Change-Id: I70f80baa3da4b14c0a52c1f28da16a9ad26d7dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127424
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-06 01:11:30 +00:00
Johnni Winther 00c2962db8 [cfe+analyzer] Move messages, scanner and parser to package:_fe_analyzer_shared
Change-Id: I4fa87aee65f30a9868a6cf8f0342591869ece7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-01 09:37:57 +00:00
Brian Wilkerson 3f80de6dc5 Generate errors rather than hints for ffi conformance checks
Change-Id: Icb3a3b393200ae7b2cd0d0b603472e90174c970b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121403
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-10-11 17:18:09 +00:00
Konstantin Shcheglov bf361ebe19 Replace addTestFile()/resolveTestFile() pair with resolveTestCode().
R=brianwilkerson@google.com

Change-Id: Ie3289e355421b0339b012319ce39d2b8eb9569d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-09-25 16:03:16 +00:00