You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That is true. The method toSource probably wasn't designed for your use case. Can you tell me what it is that you're trying to do? I might be able to suggest an alternative.
Ok. The recommended / supported way to modify source code is by modifying the content of the file directly (string manipulation). The analyzer package doesn't support code modification via the AST structure.
The AST nodes carry position information (offset and length), so it's easy to know which range of characters to replace. The only "trick" is to edit the file from largest offset to smallest (by iterating over the directives in reverse order) so that each edit does not invalid the offsets for the next edit.
dart --version
)2.0 Stable
analyzer: 0.32.5
Linux
Console App
If the code contains comments, then when Compilation Unit.toSource() is called, they are removed
Output:
The text was updated successfully, but these errors were encountered: