Rework declaration visitor for plugins