dart_custom_lint icon indicating copy to clipboard operation
dart_custom_lint copied to clipboard

Fuse all plugins into one

Open pattobrien opened this issue 1 year ago • 2 comments

It'd be ideal if all plugins were fused into one, so that each implementation of custom_lint could share resources with one another. On analysis_options.yaml changes, we would fuse all plugins into one by doing something like the following (sudo code):

import 'package:my_plugin/my_plugin.dart' as plugin1;
import 'package:another/another.dart' as plugin2;

void main() {
  plugin1.main();
  plugin2.main();
}

Currently waiting for PRs to close to avoid any merge conflicts downstream, including: #26

pattobrien avatar Sep 07 '22 20:09 pattobrien

They already are in one process if I'm not mistaken, using Isolates.

I think you are suggesting we basically create one AnalysisDriver / resolve each file into ResolvedUnitResults and then run each plugin on the resolved files, so that they don't use different AnalysisDrivers / Analyzer contexts.

In that case, would we still have them in Isolates (this would depend on being able to pass CompilationUnitResults via a SendPort), or do we compile some sort of Map / registry of the custom plugins and then start the CustomLintPlugin passing in that registry?

TimWhiting avatar Sep 15 '22 02:09 TimWhiting

It'd be the latter.

My plan is basically to have:

  • custom_lint's analyzer_plugin generate a temporary project compiling all plugins into one (cf the main above)
  • start that new project
  • pipe all events from custom_lint's analyzer_plugin to that new project

rrousselGit avatar Sep 15 '22 09:09 rrousselGit