Commit Graph

170 Commits

Author SHA1 Message Date
Konstantin Shcheglov c6135cbeef CQ. Rename AnalysisOptionsFile to AnalysisOptionsFileKeys.
I'd like to free this name for `AnalysisOptionsFile` data object.

Change-Id: Ie553ef30e9bef1e312e398248d66550ed289018c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494567
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-10 13:44:00 -07:00
FMorschel ac0be94edd [analyzer] Adds lineNumberDifference and onSameLine methods to LineInfo
Bug: https://github.com/dart-lang/sdk/issues/61186
Change-Id: Ib0584203b000103f8137901c258a86ec571ff74c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-01-07 10:15:29 -08:00
Paul Berry 5d199d6afe [messages] Move SourceRange class to _fe_analyzer_shared.
This will allow `SourceRange` to be referred to by classes in
`pkg/_fe_analyzer_shared` such as `LocatableDiagnostic` and
`SyntacticEntity`.

Change-Id: I6a6a69641f9daa351fbea3a0cc61f760f7a966d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467683
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-11 14:51:41 -08:00
Paul Berry 22013528d6 [messages] Use lower case diagnostic names in analyzer.
Changes the logic in `pkg/analyzer` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.

Change-Id: I6a6a6964bae7f2d423e44211d2ad73202da65727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466281
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 08:04:44 -08:00
Paul Berry e4868ca176 [messages] Clean up ErrorProcessor behavior.
Currently, diagnostic codes associated with lints are named using
`lower_snake_case`, while analyzer diagnonstic codes are named using
`UPPER_SNAKE_CASE`.

However, when the analyzer builds instances of the `ErrorProcessor`
class, it always uses `UPPER_SNAKE_CASE` names.

Some pieces of logic that matched up `ErrorProcessor`s to diagnostic
codes accounted for this difference; others didn't.

This led to a some buggy behaviors:

- If an instance of `ErrorProcessor` got constructed outside of the
  analyzer (by an analyzer client using the analyzer public API), and
  it supplied a `lower_snake_case` name, then
  `ErrorProcessor.appliesTo` would only successfully match if the name
  referred to a lint.

- The resolved correction producer base class `_BaseIgnoreDiagnostic`
  (which forms the basis for the quick fixes "Ignore '...' in
  `analysis_options.yaml`", "Ignore '...' for this line", and "Ignore
  '...' for the whole file") would only notice that a diagnostic was
  unignorable if the case matched exactly. In practice, this meant
  that when operating on instances of `ErrorProcessor` created by the
  analyzer, it wouldn't properly handle lints.

These buggy behaviors have been fixed by:

- Changing the `ErrorProcessor` constructor to always convert the
  `code` to lower case.

- Changing all references to `ErrorProcessor.code` to assume lower
  case.

Change-Id: I6a6a69645284f646e0c070fc2b55c4a90203d74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-11-19 11:31:21 -08:00
Jens Johansen b1c6707027 [analysis server] Make LSP change request processing faster
When processing a change request we have to construct the new content
for the changed file from the "diff" we receive. Before this CL we
calcualted a `LineInfo` to normally only use 1 entry in the list, then
calculated the new String, then calculated the new String once more.

This CL only gets the offset of the line we actually need (in what I
assume to be the normal case of only needing 1 line) and only calculates
the new string once for a reduction in processing time of about 50%.

For small files it probably wont matter much, but for bigger files it
will likely be noticeable.

To get the actual data in the benchmark this CL introduces `asJson` in
the timing pages, and picks out of the performance data the
"real number" for the change request. Turns out the overall number can
be very wrong because there's an async gap (where other stuff can be happening) between the calculation being done and the timing being
stopped.

Data:

Original -> Not doing the line starts:
Difference at 95.0% confidence
        -284.7 +/- 35.8987
        -33.0624% +/- 4.16893%
        (Student's t, pooled s = 38.2065)

Not doing the line starts -> also not doing the newContent calculation twice:
Difference at 95.0% confidence
        -207.2 +/- 31.3105
        -35.9473% +/- 5.43207%
        (Student's t, pooled s = 33.3233)

In total, i.e. from original -> this CL:
Difference at 95.0% confidence
        -491.9 +/- 34.8949
        -57.1246% +/- 4.05237%
        (Student's t, pooled s = 37.1383)


This is with a size of 16,000 in the benchmark, but the processing should be linear so the ~57% decrease should be valid overall - although naturally in raw numbers it's not going to cut of ~half a second per 25 change requests in smaller files.

Raw data:

```
Original:
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":830,"size 16000: peak virtual memory size (kb)":2473160,"size 16000: total program size (virtual) (kb)":2309328,"size 16000: peak resident set size (\"high water mark\") (kb)":540228,"size 16000: size of memory portions (rss) (kb)":373328}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":938,"size 16000: peak virtual memory size (kb)":2365488,"size 16000: total program size (virtual) (kb)":2306336,"size 16000: peak resident set size (\"high water mark\") (kb)":509212,"size 16000: size of memory portions (rss) (kb)":438796}
{"size 16000: Initial analysis (ms)":7,"size 16000: Processing time for 25 change requests (ms)":900,"size 16000: peak virtual memory size (kb)":2354420,"size 16000: total program size (virtual) (kb)":2300740,"size 16000: peak resident set size (\"high water mark\") (kb)":496768,"size 16000: size of memory portions (rss) (kb)":443892}
{"size 16000: Initial analysis (ms)":9,"size 16000: Processing time for 25 change requests (ms)":803,"size 16000: peak virtual memory size (kb)":2296448,"size 16000: total program size (virtual) (kb)":2223740,"size 16000: peak resident set size (\"high water mark\") (kb)":503040,"size 16000: size of memory portions (rss) (kb)":431608}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":821,"size 16000: peak virtual memory size (kb)":2315888,"size 16000: total program size (virtual) (kb)":2158996,"size 16000: peak resident set size (\"high water mark\") (kb)":520212,"size 16000: size of memory portions (rss) (kb)":360704}
{"size 16000: Initial analysis (ms)":15,"size 16000: Processing time for 25 change requests (ms)":835,"size 16000: peak virtual memory size (kb)":2323752,"size 16000: total program size (virtual) (kb)":2215748,"size 16000: peak resident set size (\"high water mark\") (kb)":534380,"size 16000: size of memory portions (rss) (kb)":416532}
{"size 16000: Initial analysis (ms)":8,"size 16000: Processing time for 25 change requests (ms)":848,"size 16000: peak virtual memory size (kb)":2349108,"size 16000: total program size (virtual) (kb)":2219696,"size 16000: peak resident set size (\"high water mark\") (kb)":469712,"size 16000: size of memory portions (rss) (kb)":361812}
{"size 16000: Initial analysis (ms)":7,"size 16000: Processing time for 25 change requests (ms)":870,"size 16000: peak virtual memory size (kb)":2288416,"size 16000: total program size (virtual) (kb)":2204484,"size 16000: peak resident set size (\"high water mark\") (kb)":486716,"size 16000: size of memory portions (rss) (kb)":396940}
{"size 16000: Initial analysis (ms)":9,"size 16000: Processing time for 25 change requests (ms)":895,"size 16000: peak virtual memory size (kb)":2280008,"size 16000: total program size (virtual) (kb)":2188336,"size 16000: peak resident set size (\"high water mark\") (kb)":476664,"size 16000: size of memory portions (rss) (kb)":398232}
{"size 16000: Initial analysis (ms)":18,"size 16000: Processing time for 25 change requests (ms)":871,"size 16000: peak virtual memory size (kb)":2281128,"size 16000: total program size (virtual) (kb)":2216500,"size 16000: peak resident set size (\"high water mark\") (kb)":477080,"size 16000: size of memory portions (rss) (kb)":426856}

No line starts:
{"size 16000: Initial analysis (ms)":8,"size 16000: Processing time for 25 change requests (ms)":633,"size 16000: peak virtual memory size (kb)":2279560,"size 16000: total program size (virtual) (kb)":2169640,"size 16000: peak resident set size (\"high water mark\") (kb)":467740,"size 16000: size of memory portions (rss) (kb)":365508}
{"size 16000: Initial analysis (ms)":9,"size 16000: Processing time for 25 change requests (ms)":578,"size 16000: peak virtual memory size (kb)":2481552,"size 16000: total program size (virtual) (kb)":2307804,"size 16000: peak resident set size (\"high water mark\") (kb)":547824,"size 16000: size of memory portions (rss) (kb)":370972}
{"size 16000: Initial analysis (ms)":6,"size 16000: Processing time for 25 change requests (ms)":568,"size 16000: peak virtual memory size (kb)":2412752,"size 16000: total program size (virtual) (kb)":2301564,"size 16000: peak resident set size (\"high water mark\") (kb)":546168,"size 16000: size of memory portions (rss) (kb)":447020}
{"size 16000: Initial analysis (ms)":5,"size 16000: Processing time for 25 change requests (ms)":530,"size 16000: peak virtual memory size (kb)":2426432,"size 16000: total program size (virtual) (kb)":2364240,"size 16000: peak resident set size (\"high water mark\") (kb)":565100,"size 16000: size of memory portions (rss) (kb)":503364}
{"size 16000: Initial analysis (ms)":12,"size 16000: Processing time for 25 change requests (ms)":620,"size 16000: peak virtual memory size (kb)":2276668,"size 16000: total program size (virtual) (kb)":2226296,"size 16000: peak resident set size (\"high water mark\") (kb)":477488,"size 16000: size of memory portions (rss) (kb)":434240}
{"size 16000: Initial analysis (ms)":12,"size 16000: Processing time for 25 change requests (ms)":534,"size 16000: peak virtual memory size (kb)":2391200,"size 16000: total program size (virtual) (kb)":2349392,"size 16000: peak resident set size (\"high water mark\") (kb)":531700,"size 16000: size of memory portions (rss) (kb)":490400}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":588,"size 16000: peak virtual memory size (kb)":2377112,"size 16000: total program size (virtual) (kb)":2278476,"size 16000: peak resident set size (\"high water mark\") (kb)":518740,"size 16000: size of memory portions (rss) (kb)":412952}
{"size 16000: Initial analysis (ms)":10,"size 16000: Processing time for 25 change requests (ms)":589,"size 16000: peak virtual memory size (kb)":2373204,"size 16000: total program size (virtual) (kb)":2258000,"size 16000: peak resident set size (\"high water mark\") (kb)":516188,"size 16000: size of memory portions (rss) (kb)":390972}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":583,"size 16000: peak virtual memory size (kb)":2349184,"size 16000: total program size (virtual) (kb)":2206488,"size 16000: peak resident set size (\"high water mark\") (kb)":555888,"size 16000: size of memory portions (rss) (kb)":404356}
{"size 16000: Initial analysis (ms)":9,"size 16000: Processing time for 25 change requests (ms)":541,"size 16000: peak virtual memory size (kb)":2335140,"size 16000: total program size (virtual) (kb)":2227132,"size 16000: peak resident set size (\"high water mark\") (kb)":540204,"size 16000: size of memory portions (rss) (kb)":433256}


Additionally don't do it twice:
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":379,"size 16000: peak virtual memory size (kb)":2274520,"size 16000: total program size (virtual) (kb)":2197944,"size 16000: peak resident set size (\"high water mark\") (kb)":470816,"size 16000: size of memory portions (rss) (kb)":393124}
{"size 16000: Initial analysis (ms)":8,"size 16000: Processing time for 25 change requests (ms)":431,"size 16000: peak virtual memory size (kb)":2353820,"size 16000: total program size (virtual) (kb)":2287616,"size 16000: peak resident set size (\"high water mark\") (kb)":494148,"size 16000: size of memory portions (rss) (kb)":428836}
{"size 16000: Initial analysis (ms)":15,"size 16000: Processing time for 25 change requests (ms)":334,"size 16000: peak virtual memory size (kb)":2210904,"size 16000: total program size (virtual) (kb)":2164796,"size 16000: peak resident set size (\"high water mark\") (kb)":472180,"size 16000: size of memory portions (rss) (kb)":437368}
{"size 16000: Initial analysis (ms)":16,"size 16000: Processing time for 25 change requests (ms)":364,"size 16000: peak virtual memory size (kb)":2284260,"size 16000: total program size (virtual) (kb)":2239292,"size 16000: peak resident set size (\"high water mark\") (kb)":482420,"size 16000: size of memory portions (rss) (kb)":437232}
{"size 16000: Initial analysis (ms)":8,"size 16000: Processing time for 25 change requests (ms)":397,"size 16000: peak virtual memory size (kb)":2148164,"size 16000: total program size (virtual) (kb)":2118072,"size 16000: peak resident set size (\"high water mark\") (kb)":479676,"size 16000: size of memory portions (rss) (kb)":446752}
{"size 16000: Initial analysis (ms)":5,"size 16000: Processing time for 25 change requests (ms)":327,"size 16000: peak virtual memory size (kb)":2292012,"size 16000: total program size (virtual) (kb)":2269972,"size 16000: peak resident set size (\"high water mark\") (kb)":487932,"size 16000: size of memory portions (rss) (kb)":476524}
{"size 16000: Initial analysis (ms)":8,"size 16000: Processing time for 25 change requests (ms)":339,"size 16000: peak virtual memory size (kb)":2348844,"size 16000: total program size (virtual) (kb)":2286660,"size 16000: peak resident set size (\"high water mark\") (kb)":484112,"size 16000: size of memory portions (rss) (kb)":432036}
{"size 16000: Initial analysis (ms)":16,"size 16000: Processing time for 25 change requests (ms)":393,"size 16000: peak virtual memory size (kb)":2277080,"size 16000: total program size (virtual) (kb)":2248636,"size 16000: peak resident set size (\"high water mark\") (kb)":472864,"size 16000: size of memory portions (rss) (kb)":440092}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":365,"size 16000: peak virtual memory size (kb)":2397828,"size 16000: total program size (virtual) (kb)":2201648,"size 16000: peak resident set size (\"high water mark\") (kb)":530176,"size 16000: size of memory portions (rss) (kb)":334264}
{"size 16000: Initial analysis (ms)":11,"size 16000: Processing time for 25 change requests (ms)":363,"size 16000: peak virtual memory size (kb)":2286312,"size 16000: total program size (virtual) (kb)":2253760,"size 16000: peak resident set size (\"high water mark\") (kb)":480004,"size 16000: size of memory portions (rss) (kb)":464720}
```

Change-Id: If122d4667da677fc07cab83ae97135d3a7ac99d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-10-29 02:05:35 -07:00
Paul Berry 8b23e3449d [analyzer] Move some error reporting code into _fe_analyzer_shared.
The following classes are moved from `package:analyzer` to
`package:_fe_analyzer_shared`:

- `Diagnostic`
- `DiagnosticMessage`
- `DiagnosticMessageImpl`

The following declarations are also moved, since they are needed by
the above classes:

- `formatList`
- `Severity`
- `Source`
- `TimestampedData`

There is no change to the analyzer public API, and `export`
declarations have been added to the analyzer libraries that the
declarations have been moved from, so that code depending on these
declarations is unaffected.

These changes are part of a larger arc of work that introduces methods
`.withArguments` and `.at`, forming a literate API for reporting
analyzer errors that looks roughly like this:

    diagnosticReporter.reportError(
        ERROR_CODE.withArguments(...arguments...).at(...location...));

Moving this code into `_fe_analyzer_shared` is necessary because
scanner error codes are defined inside `_fe_analyzer_shared` (to allow
the scanner to be shared between the analyzer and CFE). Hence, to
avoid a circular depedency between `_fe_analyzer_shared` and
`analyzer`, the `.withArguments` and `.at` methods will need to live
in `_fe_analyzer_shared` too, as well as the classes representing the
diagnostic messages they create.

Note that there are some minor changes to
`pkg/analysis_server_plugin/api.txt` and
`pkg/analyzer_plugin/api.txt`; these have to do with the way the
`api.txt` generator chooses to report referenced elements, and don't
reflect actual API changes.

Change-Id: I6a6a6964a5c46f4a0205ce0d85620669ce55eb3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-12 11:09:33 -07:00
Sam Rawlins 1692e68ccf Move AnalysisOptionsFile (yaml keys and values) out of validator file.
Change-Id: I978acaac38a502fbd97683d1dc3631617924d720
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-08-04 14:54:29 -07:00
Sam Rawlins 0ffd2849e4 analyzer: Move analysis options-validating code out of "task"
* OptionsValidator was defined in the `src/plugin/` directory (the only
  file in there), which I found confusing. Moved it to
  `src/analysis_options/`.
* OptionsFileValidator, and a few related classes, were defined in the
  `src/task/` (the last file in there!), so I moved it to the same
  place.

There is more to tidy in here, but this is a simple file-move.

Change-Id: I8f4c5cc0ae4e76eb6c17249457c50ab69c82590d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443147
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-31 15:05:31 -07:00
Paul Berry b1d1bbdf4f [analyzer] Make a pubic URI for clients to import TimestampedData.
The `TimestampedData` class is already exposed through the analyzer
API as a result of its use in the public `Source` class; this change
merely allows clients to refer to it directly without importing from
`package:analyzer/src`.

Making this change will allow an import of `package:analyzer/src` to
be removed from dartdoc.

Change-Id: I4d28662854513ba0098ef1f5279cb7cb276e832b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442163
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-29 12:13:50 -07:00
Sam Rawlins c219974ecf analyzer: Deprecate Diagnostic.errorCode in favor of diagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I2c7d64a81bc214e64fbc3ac95cf1fe2363a6ebd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-09 09:22:22 -07:00
Sam Rawlins 81ab0dab3c analyzer: Use Diagnostic instead of AnalysisError in lib/src
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ifce5f4919f5bb8e12ac73994263d1a9fe745e0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426402
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-04 12:29:51 -07:00
Sam Rawlins cfa4be3d93 analyzer: Use DiagnosticSeverity in analyzer packages
Work towards https://github.com/dart-lang/sdk/issues/60635

DiagnosticSeverity is the new name for ErrorSeverity.

Change-Id: I9d1040f23d4fe8affb234ff62527133e439adf50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-03 17:14:04 -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
Sam Rawlins 9e86286b66 Tidy up ErrorProcessor and AnalyzerConverter
Some of the parameters noted can be required and/or non-nullable as
per our internal usage, but this is all public API, so I'm just leaving
a note.

Mainly just simplify the implementation of ErrorProcessor.getProcessor.

Change-Id: Idebcf4a2485029c914d495cabfa3a1e98824c72c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396360
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-11-20 17:49:24 +00:00
Sam Rawlins 3f7df09ddb analyzer: Rename analysis options YAML keys variables
We rename `AnalyzerOptions` to `AnalysisFileOptions`, and change it's
comment from "`analyzer` analysis options constants." to avoid anyone
thinking it is specifying options for the `analyzer` section.

Additionally I privatize some of the static values that are only
present for validation - they are not meant to be used outside of
`options.dart`: `AnalyzerSection._trueOrFalse`,
`AnalyzerSection._options`, `AnalyzerSection._strongModeOptions`,
`AnalyzerSection._languageOptions`, `LinterSection._options`.

I also rename `_TopLevelAnalyzerOptionsValidator` to
`_AnalyzerTopLevelOptionsValidator` to align with
`_LinterTopLevelOptionsValidator`.

Change-Id: I4f5735d8bda8edbaf066387b473c05969c3ba7d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395060
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-15 21:41:29 +00:00
Sam Rawlins 998cd101b8 analyzer: Correct comment references in some source files
This corrects about 40 of 220 comment_references issues in the analyzer
package.

In correcting the `experimentStatusToStringList` function, I see that
it is unused.

Change-Id: I0c2ec602262121337e7305797596fac9df987973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392243
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-29 21:38:34 +00:00
Konstantin Shcheglov cf1f2e53a3 Breaking changes for analyzer version 7.0.0
Change-Id: Id6e329c7665d1dca1920d744dd7d0e9722da768c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311461
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 21:32:28 +00:00
Sam Rawlins 3518e02573 analyzer: Make strict modes part of AnalysisOptions API
I think when I was adding these modes, I put them on AnalysisOptionsImpl
to keep them secret and flexible. But they're pretty stable now.

Also split out the analysis options `include` tests to test merging
of individual lists and maps.

Change-Id: Ie54a1951dc82900c1fdfc06023cfa7cfb2f410a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391020
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 15:48:05 +00:00
Sam Rawlins d07ab77881 analyzer: Simplify ErrorConfig
Normally I'm all in favor of breaking up methods to improve readability,
especially to reduce indentation. But I was able to inline `_process`
and `_toSeverity`, and stop relying on `utilities_general.dart` and
keep the code with minimal indentation.

Change-Id: I1e0fe3be4b135de15400f9d2c854c21ae5f47240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389041
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-10 22:43:20 +00:00
Konstantin Shcheglov 2aa54ab42c Parts. Fix unnecessary_import before landing the reporting CL.
https://dart-review.googlesource.com/c/sdk/+/382901 will start
reporting it in more cases.

Change-Id: I3ae1d407f37a317f33cb98977b0e6eb08de75065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-09-03 03:51:29 +00:00
Konstantin Shcheglov 1b9cc28879 CQ. Make FileSource API, move to lib/source.
Change-Id: I981d3f0904917ada322ca06448f03ff33ae1f095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369360
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-06-03 00:36:59 +00:00
Sam Rawlins 73ab31b98a analyzer: Move the Source class to be public API.
Deprecate accessing LineInfo, Source, or SourceRange via the
old library (pkg/analyzer/lib/src/generated/source.dart).
Migrate all SDK code to the new library.

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

Change-Id: Ic7c98a5820415c92a457f9fa2756351b05520cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-14 17:10:37 +00:00
Danny Tuppeny 29c4b557eb [analysis_server] Migrate all remaining tests using legacy marker functions
+ remove legacy functions

Some of these tests still use `indexOf` to find positions (like `rangeAtSearch`) that could perhaps be changed to use ranges marked in the code too, however I'm not sure if that'll make them more readable and this CL ended up already being a little larger than originally planned.

Change-Id: If23b712134171c9d716aa0585045489d109fb39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333923
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-06 17:58:56 +00:00
Sam Rawlins f8c6f2135d [analyzer] Remove many instances of the word 'hint'
I took care to leave code and comments which _does still_ refer to the
remaining Hints. This CL is not super complete, but I think addresses
most of the outdated text refering to Hints. I will do another round
after migrating more to Warnings.

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Iab58dbbfbdef86e21dd65b2a96d8e34e3e7e54ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-03-23 03:59:55 +00:00
Sam Rawlins 105efd85b6 [analyzer] Add a valueOrThrow extension similar to our oft-used typeOrThrow
This really helps in complying with strict-casts. YamlNode.value returns
a `dynamic`, which is then often passed somewhere which accepts Object
(and then does some type tests). To avoid the implicit cast from
`dynamic`, we can use `.valueOrThrow` (or basically just
`.value as Object`).

The extension getter improves readability and avoids a lot of
as-expressions inside conditional expressions etc.

Change-Id: I50d2eebd51d6fc3eccf1c930652dd5ce70dd9eb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277582
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-01-03 18:53:39 +00:00
Sam Rawlins 9a79d61c36 Do not rename method parameter names in overrides
Change-Id: I8c2f91a56c767c89dc4d0bea22b64dec147870c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237852
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-21 17:32:22 +00:00
Konstantin Shcheglov 95644dcde5 Stop using the remaining methods of StringUtilities.
Change-Id: I099c4f79f2cd5dede474412e72d6d53ef555deff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223300
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-12-11 18:50:01 +00:00
Keerti Parthasarathy 56e7532f99 Implement rename method for Cider
Change-Id: I48d65146b9a7f1687f9afc437aebae3aaa6f533b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218785
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-11-03 23:33:13 +00:00
Konstantin Shcheglov 930895e8a2 Breaking changes for analyzer version 2.0.0
Latest google3 presubmit looks green.
https://test.corp.google.com/ui#id=OCL:374078884:BASE:382671882:1625203035014:dc4c1c68

Change-Id: I12f6a8a27b8783652e3a2c16d2f39a672dee4eb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-02 19:02:44 +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
Konstantin Shcheglov a51f1747e0 Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.
Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 15:12:10 +00:00
Konstantin Shcheglov ebd5b622ba Add DartSdk.languageVersion
Bug: https://github.com/dart-lang/build/issues/2763#issuecomment-666707445
Change-Id: I8232bd395abc9efea0e5c27716450d6a5442b3bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156489
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-04 21:01:09 +00:00
Brian Wilkerson 4776ac1f89 Fix a couple of recently introduced hints
Change-Id: I68b653ea44e548a2789f7e720d6abfddb7cfb08c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156721
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-07-31 17:33:58 +00:00
Devon Carew fc1999de15 [dartdev] Implement --enable-experiments for dart run and dart pub run.
Related to https://github.com/dart-lang/sdk/issues/42339.

Change-Id: I3fdeee33dcad0ca031f483e2e3692be300392958
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152960
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-30 23:22:42 +00:00
Sam Rawlins 648b5e9c68 Use ///-style doc comments in analyzer/lib
Bug: https://github.com/dart-lang/sdk/issues/33892
Change-Id: I573cb81dca6462c571bd6bf7bf309a46fd628967
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152610
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-26 17:58:50 +00:00
Jaime Wren 920ddae937 Re-write of the computation of the context type for code completion.  Instead of passing a parent and child node, a parent node with an offset is passed.  The primary purpose of this change was to fix a bug with argument lists which is close to being fixed.
I will follow up with some additional fixes and tests for map and list literals.

Change-Id: I1a26e8f900dcf13402385a49e8f3538c5d1b39df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151030
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-06-15 18:19:42 +00:00
Konstantin Shcheglov 439e99483f Remove DartSdk.getLinkedBundle().
R=brianwilkerson@google.com

Change-Id: I2335ad03856b73e6d864d939a90839ef85dcab78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149487
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-05-30 03:16:51 +00:00
Konstantin Shcheglov 6a551f8d54 Use allowed_experiments.json when building SDK summary (reland).
Landed: https://dart-review.googlesource.com/c/sdk/+/149052
Reverted: https://dart-review.googlesource.com/c/sdk/+/149201
Change-Id: Ief9430c58254fe8cbdcedc8d3678c61d4c086f67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-29 16:31:35 +00:00
Konstantin Shcheglov 21354dccc9 Remove SdkExtUriResolver.
Initial:  https://dart-review.googlesource.com/c/sdk/+/128770
Reverted: https://dart-review.googlesource.com/c/sdk/+/128820

R=brianwilkerson@google.com

Change-Id: I446d0ddf130712e94aab756e04c91ab4b5e83aeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-20 01:08:49 +00:00
Konstantin Shcheglov becb0c0b85 Revert "Remove SdkExtUriResolver."
This reverts commit 7ef8822c2a.

Reason for revert: breaks Flutter build because dartdoc is not updated there yet.

Original change's description:
> Remove SdkExtUriResolver.
> 
> R=​brianwilkerson@google.com
> 
> Change-Id: If0d7bb91e9b1c42e15935b315288fa8e3a000c6d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128770
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

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

Change-Id: I0c9a26662a6fe6abac558313c14949886364d28e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128820
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-18 01:07:34 +00:00
Konstantin Shcheglov 7ef8822c2a Remove SdkExtUriResolver.
R=brianwilkerson@google.com

Change-Id: If0d7bb91e9b1c42e15935b315288fa8e3a000c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128770
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-18 00:22:15 +00:00
Konstantin Shcheglov 54b7543c55 Fix unnecessary_const in analyzer.
The only non-mechanical change is update for tool/diagnostics/generate.dart
to handle MethodInvocation, because without resolution and without
explicit `new` and `const` we get MethodInvocation(s).

R=brianwilkerson@google.com

Change-Id: Ib89ce9c37066e9b27ad03aed96b349ef36f11d43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127453
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-06 15:03:00 +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
mnordine f594720679 Fix typo
Closes #39402
https://github.com/dart-lang/sdk/pull/39402

GitOrigin-RevId: 89a3ac03e3fc971e0fcfeb36ddcc1bc6b2ffcb34
Change-Id: Idee225262fbfa1c3dc7acbabd141eb7a275fee87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125442
Reviewed-by: Michael Thomsen <mit@google.com>
2019-11-20 11:25:52 +00:00
pq 8f90265176 de-lint collection size checks
Change-Id: Id8e7ce2ec59ad7cd2b0b9c961594a37d4fef621a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108522
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2019-07-10 13:46:43 +00:00
Brian Wilkerson 5f0de26d48 Clean up the remaining copyright notices
Change-Id: If099be4f71ba551df0dc3d69815ae6a9f55d1eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97781
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-03-24 20:11:28 +00:00
Konstantin Shcheglov 1ba59eb13d Make ERROR the default severity for StaticWarningCode. Remove _StrongModeTypeErrorProcessor.
As a preparatory step for re-landing https://dart-review.googlesource.com/c/sdk/+/91170
and making these two restored problems to warnings.

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

Change-Id: I6266632ade84743b5725c54475fe402902576c00
Reviewed-on: https://dart-review.googlesource.com/c/91420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-01-28 22:08:17 +00:00
Brian Wilkerson 6c2ea4936a Clean up several deprecation hints
Change-Id: I6191ddc4bb4a98c4976d8bc281b084bfd5073547
Reviewed-on: https://dart-review.googlesource.com/c/89941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-01-17 01:05:24 +00:00
Paul Berry a84863253c Re-apply "Add AnalysisDriver.resetUriResolution() and use it for analysis.reanalyze request."
Original change's description:
> Add AnalysisDriver.resetUriResolution() and use it for analysis.reanalyze request.
>
> This CL changes "analysis.reanalyze" API. We decided to repurpose it. It was not
> used for some time now in IntelliJ, and AFAIK has never been used in VS Code.
>
> R=​brianwilkerson@google.com, paulberry@google.com
>
> Change-Id: I7510b0189197c9f3f848b0fc59a7b2bd22889ac7
> Reviewed-on: https://dart-review.googlesource.com/c/85523
> Reviewed-by: Paul Berry <paulberry@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

Change-Id: I828c9a77f1e28d44c00bfcf39527514e39cccc42
Reviewed-on: https://dart-review.googlesource.com/c/86221
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-12-06 23:14:28 +00:00