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

Refactor: Bring over additional types from Onivim 2 #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bryphe
Copy link
Member

@bryphe bryphe commented Apr 28, 2020

In starting to investigate wiring up this library to Onivim 2 (ie, replacing the Manifest and Scanner in Onivim 2 with the one ported over here) - I found there were several other types that needed to be brought over.

In particular, in the Manifest, there is a contributions section which contains information about commands, menu items, and conditions. It seems like the data model for all of those needs to be brought over - so this ports several Core.Types from Onivim 2: Config, Menu, IconTheme, WhenExpr, as well as some dependencies (KeyedStringMap/KeyedStringTree).

There might be other possibilities; like creating a functor or custom parsing strategies for Contributions - but I think these data models are somewhat coupled to the extension contributions, so I'm not sure if it is worth generalizing it to that extent. @glennsl , you might have ideas, though.

Copy link
Member

@glennsl glennsl left a comment

Choose a reason for hiding this comment

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

Most of these are actually designed to be independent of extension contributions, although they are of course heavily modelled after the requirements of vscode extensions. There seems to be very little of this that's actually used, however. From what I can see there's just Menu, IconTheme and WhenExpr, and all of those could easily be replaced by "dumber" data structures. The rest seems to have been brought along just because it's part of the same "ecosystem" of interconnected parts. On the other hand I did have a long-term goal of replacing more of the contribution data structures with these.

I can see a few different courses of action here:

  • Keep this PR as-is. Although I'd still suggest renaming the Types module to something more meaningful, as it's almost as generic as a project called SourceCode. DataStructures would be slightly more accurate, but still doesn't describe any actual structure. There's also a lot more to these than just what I'd call a "data structure" and certainly a lot more than just "types".

  • Move them to a separate package, like oni-platform perhaps.

  • Replace the few data structures that are needed with "dumber" equivalents. WhenExpr.t could just be kept as a string for example, to be parsed later.

  • Move all of this into Oni2. I'm not sure why this needs to be a separate package, so to me ti seems like a viable option at least.

  • Separate the "dumb" data structures from the surrounding logic, put them either here or in a separate package, then alias them in Oni2 where the rest of the logic lives.

My preference I think would be to either move ti all into Oni2, as I don't see why it needs to be separate and that would make it much easier to iterate on these things, or to make a separate oni-platform package.

@@ -0,0 +1,24 @@
module Key: {
Copy link
Member

Choose a reason for hiding this comment

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

This, and the interface, seems to be duplicated in Types.

Comment on lines +1 to +6
(library
(name Core)
(public_name vscode-exthost.core)
(library_flags (-linkall))
(libraries luv yojson decoders-yojson)
(preprocess (pps ppx_deriving.show ppx_deriving_yojson)))
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this should have been removed entirely?

@bryphe
Copy link
Member Author

bryphe commented Apr 28, 2020

@glennsl - thanks for the feedback! The reason I split it out is to make it easier to test extensions along with projects in isolation - there are less moving parts when the extension host is split out, so I can validate the behavior of extensions independently of Onivim 2.

Ultimately, I'd like to have an integration test suite here - where we validate the top X plugins we care about, along with scripts to provision projects to go with the plugins (ie, for Python, C#, Java, etc etc). Knowing that the exthost pieces passes all those cases, in isolation, gives a lot of confidence! IE, the test suite for a lot of: onivim/oni2#1058 can live here.

Upgrading the extension host in Onivim 2, or validating new extensions, has more cognitive overhead, just because there are more moving parts (ie, if it fails, which layer is to blame?) - removing the extra layers and being able to test in isolation makes it easier, at least for me, to work with.

In addition, we have cases where we are tightly coupled to the extension host for language features - I believe this split will help us maintain a clearer architectural boundary.

So I do plan on keeping this split - but I like your idea of an oni-platform project. How would you determine the split between editor-core-types and oni-platform - ie, what criteria should we use to determine whether a type belongs in editor-core-types or oni-platform? That boundary is fuzzy to me.

@glennsl
Copy link
Member

glennsl commented Apr 28, 2020

I don't think any of this requires a separate repository though. Like a monorepo, you can have strong separation within a single repository, although you'd still have to reorganize this code just like you're doing now. But it would be much easier to work on changes across repositories, because you don't have to create multiple PRs, wait for CI to merge, sync up dependencies, do releases to avoid resolutions etc. Of course there are other benefits to having s separate repository, like ease of external contribution, issues, licensing and such, but I can't see any of that really applying here.

How would you determine the split between editor-core-types and oni-platform

editor-core-types and oni-platform kind of serves the same role, but for different areas. They both provide a more general interface to decouple specific this-party implementations. editor-core-types connects onivim with the libvim ecosystem, while oni-platform connects onivim with the vscode ecosystem. So it might seem tempting to merge them, but that means other consumers of libvim will get a bunch of interface code that's really irrelevant to them.

There might be room to make this clearer by improving the naming, but the root of the problem is that we're trying to come up with general names for interfaces to implementations that are really very specific.

@bryphe
Copy link
Member Author

bryphe commented Apr 28, 2020

But it would be much easier to work on changes across repositories, because you don't have to create multiple PRs, wait for CI to merge, sync up dependencies, do releases to avoid resolutions etc.

That's a good point! I'll take a look at bringing this over to the Onivim repo. The downside is we'll have two 'ext host' concepts, until the v2 (the one in this repo) has functional parity with the v1 (the one in Onivim) - and at that point we can completely remove the old 'v1'. But seems reasonable as a transition step.

@glennsl
Copy link
Member

glennsl commented Apr 28, 2020

The downside is we'll have two 'ext host' concepts

Well, it's not the only thing we have two of, so it'll have company at least! 😄

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.

2 participants