How to get a Source for a given File now that .createSource is deprecated?

33 views
Skip to first unread message

dark...@gmail.com

unread,
Jun 22, 2024, 6:19:10 AM6/22/24
to Dart Analyzer Discussion
Hello!

I'm trying to migrate away from File.createSource, and was wondering how to get a Source instance (for the sake of creating an ErrorReporter)

The depreciation notice mentions using the analysis result. But the thing is, I'm trying to get a Source for possibly non-dart files. In which case, I don't want to analyze those files.

As such, how could I get a Source?
Thanks!

Brian Wilkerson

unread,
Jun 24, 2024, 5:28:50 PM6/24/24
to analyzer...@dartlang.org, Konstantin Shcheglov
--
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/cf0666a4-3f88-493a-9e49-2d25fea2bf41n%40dartlang.org.

Konstantin Shcheglov

unread,
Jun 24, 2024, 5:34:33 PM6/24/24
to Brian Wilkerson, analyzer...@dartlang.org

  You can instantiate `FileSource` directly, it is an API now.

  Theoretically (not now yet), you don't need to provide `Source` for `ErrorListener` or `ErrorReporter`.
  Or `AnalysisError`.
  They all are bound to some file, but it should happen externally, e.g. `LibraryAnalyzer`, see `UnitAnalysis`.
--
Konstantin Scheglov
Software Engineer
Google, Inc.
Reply all
Reply to author
Forward
0 new messages