nwolverson / purescript-language-server

MIT License
184 stars 41 forks source link

Refactor main module #125

Closed wclr closed 3 years ago

wclr commented 3 years ago

@nwolverson

Some time ago we discussed a couple of questions in slack on ide tools and LS, but I only now got my hands on the PR. I've been exploring the work of LS I came to the conclusion that the main function in the Main module that embraced all the logic was very big and hard to grasp at once. So I decided to split it up. I tried to make it concise, though it is kindа first approach.

This refactoring may seem extensive, but actually, it is just moving logic outside of the main and I think it is necessary for further work. And though there are no tests related to Main logic, actually as always with PS it should be fully safe. I've checked and worked with it for some time.

Also, I included in this PR (in a separate commit) auto build-diagnostics for files when they are opened in the editor.

So if you have considerations or objections to the proposed change will be glad to hear and fix it.

nwolverson commented 3 years ago

I'll take a look in detail later but this looks good, for sure that code has just spread over time. I think half of the structure of the main function is just because there is a ref or two captured if I recall

wclr commented 3 years ago

I think half of the structure of the main function is just because there is a ref or two captured if I recall

Yeah, have to pass them around, but it still looks cleaner and easier to handle. It also reveals hidden complexity, so eventually some more concise way of managing state could be applied.

wclr commented 3 years ago

Cool.