Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate HLS plugins #3112

Merged
merged 7 commits into from
Aug 19, 2022
Merged

Deduplicate HLS plugins #3112

merged 7 commits into from
Aug 19, 2022

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Aug 17, 2022

Use a smart constructor to prevent duplicated plugins. We cannot use a
set since order matters for plugin execution.

@pepeiborra pepeiborra requested a review from wz1000 August 17, 2022 16:46
@pepeiborra pepeiborra mentioned this pull request Aug 17, 2022
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wz1000
Copy link
Collaborator

wz1000 commented Aug 18, 2022

I think it would be better to use a Map, and then use an explicit priority (a simple Int) for ordering rather than implicitly depending on the order that we construct the list.

Perhaps we also want a richer graph structure in the future so we can express dependencies between plugins, but lets just go for explicit priorities for now.

@pepeiborra pepeiborra force-pushed the deduplicate-plugins branch from 41446c8 to 2a7561b Compare August 18, 2022 09:55
@pepeiborra
Copy link
Collaborator Author

I think it would be better to use a Map, and then use an explicit priority (a simple Int) for ordering rather than implicitly depending on the order that we construct the list.

Agreed, explicit priorities are much better. Added now

@wz1000 wz1000 enabled auto-merge (rebase) August 18, 2022 10:12
@pepeiborra pepeiborra force-pushed the deduplicate-plugins branch 3 times, most recently from 76a6cff to 7baaaab Compare August 18, 2022 22:05
hls-plugin-api/src/Ide/Types.hs Show resolved Hide resolved
@@ -113,6 +152,8 @@ instance Show (IdeCommand st) where show _ = "<ide command>"
data PluginDescriptor (ideState :: *) =
PluginDescriptor { pluginId :: !PluginId
-- ^ Unique identifier of the plugin.
, pluginPriority :: Natural
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if two plugins have the same priority?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unspecified order as decided by unordered-containers


-- ---------------------------------------------------------------------

descriptor :: PluginId -> PluginDescriptor IdeState
descriptor plId = (defaultPluginDescriptor plId)
{ pluginHandlers = mkPluginHandler J.STextDocumentCodeAction codeActionProvider
<> mkPluginHandler J.STextDocumentCompletion completion
, pluginPriority = ghcideCompletionsPluginPriority + 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth explaining

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, I forgot adding a line there.

@wz1000 wz1000 merged commit 099b4e7 into master Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants