I am assuming that the location of package:flutter/foundation.dart is <path>/flutter/packages/flutter/lib/foundation.dart.
How can I pinpoint the problem?
How can I make sure the analyzer finds these imports?
Am I using the correct analyzer function? Currently I am using session.getUnitElement2 but I am unsure if this is the right approach.
Furthermore I have a hard time understanding what each of the methods exposed by AnalysisSession do.
--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/analyzer-discuss/e45513e7-af03-4134-b776-af178f9aa135n%40dartlang.org.
Since messages seems to b posted with a delay ...
Assuming I am correct with this assumption, I am wondering if it is possible to analyze a whole package (like the flutter package/sdk) and if yes how i'd do this.
--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/analyzer-discuss/efaf6f7f-fdb1-4d3d-98ba-8c73db8795dan%40dartlang.org.
When the analyzer needs to resolve a URI to a file location there are three options:
- If the URI is a `dart:` URI, then the library is found in a known location in the sdk.
- If the URI is a `package:` URI, then the analyzer looks in each of the parent directories containing the library for a file whose relative path is `.dart_tool/package_config.json`. That file contains a JSON encoding of a map from the name of the package (`flutter` in this case) to the path of the `lib` directory for that package (`<path>/flutter/packages/flutter/lib` in this case). Everything after the first `/` in the URI is then appended to the path to form the full path to the file.
- If the URI is any other kind of URI, then the normal URI resolution rules are followed.
The most likely problem here is that the analyzer is unable to locate the `package_config.json` file and hence can't convert the URI into a file path.By the way, the process of finding the `package_config.json` file happens at the time you create the `AnalysisContextCollection` so that it doesn't need to be repeated for each library you analyze. That, and the locations of the `analysis_options.yaml` files, is what determines how many analysis contexts get created in the collection.
That depends on what you're trying to do. The method `getUnitElement2` will return the results of fully analyzing the content of a single file, while the method `getResolvedLibrary2` will return the results of fully analyzing all of the files in a single library. Because of part files, libraries can sometimes consist of more than one file. For efficiency, the analyzer always analyzes all of the files in a library together, so if you use `getUnitElement2` for each of the files in a library you'll actually be analyzing the whole library multiple times. If the code you're analyzing doesn't use part files, then there's no difference between these two APIs. If you want to use `getResolvedLibrary2` then you'll need to use `getFile2` first to determine which files are library files and which are part files.
Sorry about that. Sounds like we need to enhance the documentation for those methods to make it more clear.Also, not that there's some minimal information in the analyzer package's `doc/tutorial` directory that might help explain some of the APIs and how they're used.
--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/analyzer-discuss/A94048EA-15BD-49EF-8F31-B4927A225C76%40gmail.com.