A few questions about the analyzer.

117 views
Skip to first unread message

Modestas Valauskas

unread,
Jan 31, 2020, 9:23:09 AM1/31/20
to Dart Analyzer Discussion
Hello,
I'm working on a 'visual flutter widget builder' that parses dart files to reconstruct widget trees and I have a few questions about the analyzer.

1: Are there any design documents or other documentation that outline the internal design of the analyzer? (outside of what the doc folder provides) 

2: I'd like to understand the steps that are taken to efficiently arrive at a resolved AST from an unresolved AST and the dependency graph. I don't have a background in building compilers so I'd appreciate any keywords or a very rough outline that could aid me in my research.

3: What is the role of the SDK summary and the library summaries? (Are summaries just serialized unresolved ASTs? Are summaries used for performance reasons so that they can be shared across isolates and subsequent analyzer runs?)

4: I'd like to resolve Dart files on mobile (offline) and I'm evaluating the plausibility of that idea. What does the analyzer need to be able to resolve an AST? Are summaries for each library in the .packages file enough or does it need all the .dart files?

5: I'm currently using heuristics to translate the AST into a runtime representation of the Flutter SDK (i.e. manually checking PrefixedIdentifiers against a list of known enums and so on). Are there any subsets of the analyzer package that could help me to resolve parts of an AST?

I'd greatly appreciate answers to even a few of those questions.

Thanks.

Brian Wilkerson

unread,
Jan 31, 2020, 9:46:44 AM1/31/20
to analyzer...@dartlang.org
I'm working on a 'visual flutter widget builder' that parses dart files to reconstruct widget trees ...

That sounds cool. How different is it from the Flutter outline feature in IntelliJ and VS Code?

1: Are there any design documents or other documentation that outline the internal design of the analyzer? (outside of what the doc folder provides)

Not really, no. This is a good forum for such questions, though, and we're open to suggestions for places where the documentation needs to be enhanced.

2: I'd like to understand the steps that are taken to efficiently arrive at a resolved AST from an unresolved AST and the dependency graph. I don't have a background in building compilers so I'd appreciate any keywords or a very rough outline that could aid me in my research.

If your goal is to have a resolved AST to work from, then I'll refer you to the method `AnalysisSession.getResolvedLibrary`, which will return a fully resolved AST. Note that you don't need to get a parsed AST before invoking that method.

If your goal is to understand compilers a bit better, then I'm happy to elaborate on how the analyzer works, but you'll get a much more complete picture from books like Compilers: Principles, Techniques, and Tools.


3: What is the role of the SDK summary and the library summaries? (Are summaries just serialized unresolved ASTs? Are summaries used for performance reasons so that they can be shared across isolates and subsequent analyzer runs?)

Yes, summaries are designed to improve performance, especially for incremental systems like the analysis server (which powers most IDEs).


4: I'd like to resolve Dart files on mobile (offline) and I'm evaluating the plausibility of that idea. What does the analyzer need to be able to resolve an AST? Are summaries for each library in the .packages file enough or does it need all the .dart files?

If the analyzer has access to the summary files it will use them, but it can also analyze from source without summary files. The summary files are not sufficient for the files for which you'll be requesting a resolved AST -- for those files you'll need the full source -- but they are sufficient for the files that are imported (directly or indirectly) from those files.

5: I'm currently using heuristics to translate the AST into a runtime representation of the Flutter SDK (i.e. manually checking PrefixedIdentifiers against a list of known enums and so on). Are there any subsets of the analyzer package that could help me to resolve parts of an AST?

Yes, most of the analyzer package is concerned with performing resolution, but most of that code is not part of the public API. The good news is that you don't really need to use it because public methods such as `AnalysisSession.getResolvedLibrary` will get you a resolved AST without any extra work.

--
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/a947257d-a775-46f5-aee6-d2ab9e7d0f8e%40dartlang.org.

Modestas Valauskas

unread,
Jan 31, 2020, 5:33:23 PM1/31/20
to Dart Analyzer Discussion
That sounds cool. How different is it from the Flutter outline feature in IntelliJ and VS Code?
The problems that I'm trying to solve are the following
- The outline feature needs to either have a running flutter app (for Hot UI) or doesn't have an immediate pixel perfect UI representation of all the widgets in the Flutter SDK. 
- There are no specialized code manipulation features (e.g. XY matrix for offsets, advanced color manipulation tools)
- The friction to experiment with Flutter is too high: one needs to download the SDK, an IDE, Dart & Flutter plugins, an emulator
- Not available on mobile


 The good news [...] `AnalysisSession.getResolvedLibrary` will get you a resolved AST without any extra work.
Oh, I did not know that. I was mainly going off of the logic in resolveFile which takes around 7-10 seconds on its first run.

Thank you.

Raed Abdullah

unread,
Jan 9, 2021, 11:23:13 AM1/9/21
to Dart Analyzer Discussion, valauska...@gmail.com
Sup man I'm working on a similar project, wanna chat about it? send me an email on raed...@gmail.com
Reply all
Reply to author
Forward
0 new messages