Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 The analysis package defines support for performing static analysis of Dart | 1 # Analyzer for Dart |
| 2 code. It was designed to support tooling efforts, but has also been used for | |
| 3 such things as statistics gathering and code transformers. | |
| 4 | 2 |
| 5 If you are interested in providing Dart support in a long-running tool, such as | 3 This package provides a low-level _library_ that performs static analysis |
| 6 an editor or IDE, you should use the analysis server instead of this package. | 4 of Dart code. It is useful for tool |
| 7 The analysis server is currently shipped as an executable in the SDK and will | 5 integration and embedding. |
| 8 be released as a package in the near future. In the meantime, if you'd like to | 6 |
| 9 learn more about it, please look at the | 7 End-users should use the [dartanalyzer][analyzercli] command-line tool |
| 10 [Analysis Server API Specification](http://htmlpreview.github.io/?https://github .com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html) | 8 to analyze their Dart code. |
| 11 or contact the mailing list (see below). | 9 |
| 10 Integrators that want to add Dart support to their editor | |
| 11 should use the _Dart Analysis Server_. | |
| 12 The [Analysis Server API Specification][serverapi] is available. | |
| 13 If you are adding Dart support to an editor or IDE, please let us know | |
| 14 by emailing our [list][]. | |
|
pquitslund
2015/10/20 15:48:01
Is this shorthand for [list][list]?
sethladd
2015/10/20 18:32:15
yup!
| |
| 15 | |
| 16 ## Configuring the analyzer | |
| 17 | |
| 18 Both the dartanalyzer and Dart Analysis Server can be configured | |
| 19 with a `.analysis_options` file. This YAML file can control which files | |
| 20 and paths are analyzed, which lints are applied, and more. | |
| 21 | |
| 22 If you are embedding the analyzer library in your project, you are | |
| 23 responsible for finding the `.analysis_options` file, parsing it, | |
| 24 and configuring the analyzer. | |
| 25 | |
| 26 The `.analysis_options` file should live | |
| 27 at the root of your project (typically, next to your `pubspec.yaml`). | |
|
Cutch
2015/10/20 01:10:36
remove 'typically'
pquitslund
2015/10/20 15:48:01
Just another motivation to formalize (though I'm n
sethladd
2015/10/20 18:32:15
Done.
| |
| 28 Different embedders of analyzer, such as dartanalyzer or Dart Analysis Server, | |
| 29 may choose to find the file in various different ways. Consult their | |
| 30 documentation to learn more. | |
| 31 | |
| 32 Here is an example file that instructs the analyzer | |
| 33 to ignore two files: | |
| 34 | |
| 35 ``` | |
| 36 analyzer: | |
| 37 exclude: | |
| 38 - test/_data/p4/lib/lib1.dart | |
| 39 - test/_data/p5/p5.dart | |
|
Cutch
2015/10/20 01:10:36
Show an example of globbing:
- 'test/_data/bad*.d
pquitslund
2015/10/20 15:48:01
+1.
FWIW: this is enough of a potential snag that
sethladd
2015/10/20 18:32:15
Done.
| |
| 40 ``` | |
| 41 | |
| 42 Here is an example file that enables the analyzer's [strong mode][strongmode]: | |
| 43 | |
| 44 ``` | |
| 45 analyzer: | |
| 46 strong-mode: true | |
| 47 ``` | |
| 48 | |
| 49 Here is an example file that enables two lint rules: | |
| 50 | |
| 51 ``` | |
| 52 linter: | |
| 53 rules: | |
| 54 - camel_case_types | |
| 55 - empty_constructor_bodies | |
| 56 ``` | |
| 57 | |
| 58 Check out all the available [Dart lint rules][lintrules]. | |
| 59 | |
| 60 You can combine the `analyzer` section and the `linter` section into a single | |
| 61 configuration. Here is an example: | |
| 62 | |
| 63 ``` | |
| 64 analyzer: | |
| 65 exclude: | |
| 66 - test/_data/p4/lib/lib1.dart | |
| 67 linter: | |
| 68 rules: | |
| 69 - camel_case_types | |
| 70 ``` | |
| 71 | |
| 72 ## Who uses this library? | |
| 73 | |
| 74 Many tools embed this library, such as: | |
| 75 | |
| 76 * dartfmt - a formatter for Dart code | |
| 77 * dartdoc - a documentation generator for Dart code | |
| 78 * Dart Analysis Server - a stateful server that supports IDEs and editors | |
| 79 | |
| 80 ## Support | |
| 81 | |
| 82 Questions and requests for additional functionality are welcome. | |
| 83 Please open an issue at | |
| 84 [http://dartbug.com](http://dartbug.com) | |
| 85 or by email | |
| 86 [analyzer-discuss@dartlang.org][list]. | |
| 87 | |
| 88 ## Background | |
| 12 | 89 |
| 13 The API's in this package are, quite frankly, a mess at the moment. They were | 90 The API's in this package are, quite frankly, a mess at the moment. They were |
|
pquitslund
2015/10/20 15:48:01
API's => APIs ?
sethladd
2015/10/20 18:32:15
Done.
| |
| 14 originally machine generated by a translator and were based on an earlier Java | 91 originally machine generated by a translator and were based on an earlier Java |
| 15 implementation. Several of the API's still look like their Java predecessors | 92 implementation. Several of the API's still look like their Java predecessors |
| 16 (or worse) rather than clean Dart API's. | 93 (or worse) rather than clean Dart API's. |
| 17 | 94 |
| 18 In addition, there is currently no clean distinction between public and internal | 95 In addition, there is currently no clean distinction between public and internal |
| 19 API's. We plan to address this issue soon, but doing so will, unfortunately, | 96 API's. We plan to address this issue but doing so will, unfortunately, |
|
pquitslund
2015/10/20 15:48:01
API's => APIs ?
sethladd
2015/10/20 18:32:15
Done.
| |
| 20 require a large number of breaking changes. We will try to minimize the pain | 97 require a large number of breaking changes. We will try to minimize the pain |
| 21 this causes for our clients, but some pain is inevitable. | 98 this causes for our clients, but some pain is inevitable. |
| 22 | 99 |
| 23 Questions and requests for additional functionality are welcome, and can be made | 100 ## License |
| 24 by either opening an issue at | 101 |
| 25 [http://dartbug.com](http://dartbug.com) | 102 See the LICENSE file. |
| 26 or by emailing | 103 |
| 27 [analyzer-discuss@dartlang.org](https://groups.google.com/a/dartlang.org/forum/# !forum/analyzer-discuss). | 104 [serverapi]: http://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob /master/pkg/analysis_server/doc/api.html |
| 105 [analyzercli]: https://github.com/dart-lang/analyzer_cli | |
| 106 [list]: https://groups.google.com/a/dartlang.org/forum/#!forum/analyzer-discuss | |
| 107 [lintrules]: http://dart-lang.github.io/linter/lints/ | |
| 108 [strongmode]: https://github.com/dart-lang/dev_compiler/blob/master/STRONG_MODE. md | |
| OLD | NEW |