Hello lovely people - I have one small question - ...
# compiler
m
Hello lovely people - I have one small question - does anybody knows if the order of plugins is arbitrary or does the compiler sticks to the order in which the plugins are registrated?
r
Hi @Matthias Geisler, My experience is that the compiler preserves order of registration when invoking the registered extensions. Something to keep in mind is your plugin still will get invoked after other plugins if they are registered for different phases regardless of order of registration. For example:
Copy code
Plugin1 -> Alters IR backend
Plugin2 -> Operates on Analysis
Plugin2 gets call first because Plugin1 refers to a later phase since IR comes after Analysis.
Copy code
Plugin1 -> Operates on Analysis
Plugin2 -> Operates on Analysis
Plugin1 gets call first because refers to the same phase but was registered first.
y
It's in order of registration. However, you can force your own order like Anvil does:
Copy code
private fun AnalysisHandlerExtension.Companion.registerExtensionFirst(
    project: MockProject,
    extension: AnalysisHandlerExtension
  ) {
    project.extensionArea
      .getExtensionPoint(AnalysisHandlerExtension.extensionPointName)
      .registerExtension(extension, LoadingOrder.FIRST, project)
  }
m
Awesome that helps a lot! Thx!