Skip to content

Revive autocomplete in IDE #649#682

Merged
JamesXNelson merged 1 commit intodeephaven:mainfrom
JamesXNelson:jxn/autocomplete
Jun 22, 2021
Merged

Revive autocomplete in IDE #649#682
JamesXNelson merged 1 commit intodeephaven:mainfrom
JamesXNelson:jxn/autocomplete

Conversation

@JamesXNelson
Copy link
Member

No description provided.

@JamesXNelson
Copy link
Member Author

@niloc132 (finally) done updates. I know it wasn't much, just way too many install questions all day to make decent progress.

@JamesXNelson
Copy link
Member Author

Also, the commit for newTable completion is JamesXNelson@1b2b811 but I think that one will be more likely to land on devin's plate, so 🤷

compile project(':open-api-shared-ide')
compile project(':open-api-shared-fu')
compile project(':IO')
compile project(':proto:proto-backplane-grpc')
Copy link
Member

Choose a reason for hiding this comment

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

not an "issue", just a remark:

in most other parts of the repo, we've tried to keep proto contained to grpc-api, so that the semantics of how you make calls doesn't creep into other aspects of the codebase - provided nothing else (like db) depends on lang-parser I don't think this dep is a problem, but just pointing out the decision that was made.

ditto dagger2, we're keeping that in grpc-api, and just encouraging other code to use patterns that make it easy for code to have dependencies injected, but not require consumers of the codebase to use our di

Copy link
Member

Choose a reason for hiding this comment

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

ah whoops, db does_ now depend on open-api-lang-parser... may need to revisit this soon if not right away, make sure this is unavoidable

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a diamond problem between the parser and the completer. The parser operates on "lsp types", so I used the grpc generated types. The completer needs objects like Table. The completer also needs the parser.

Advice on what to do here? If / when Table and TableDefinition (and VariableProvider) can be moved out of db, then I could resolve this, but, as is, unless I want to have three copies of the same objects in slightly different formats spread out across all the modules, I dunno how else to fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the completer mostly operates on the lsp types, but I put utilities into the AST nodes to make them able to understand / translate between AST and LSP. I might be able to extract them all into static util methods; annoything, but probably not impossible. I'll take a quick spin at it.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh man, there's lots and lots and lots of references :-/

Copy link
Member Author

@JamesXNelson JamesXNelson Jun 11, 2021

Choose a reason for hiding this comment

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

I think we should merge it like this, and just open a ticket to refactor these dependencies once the Table interface is split up, and things are ....less likely to suck in the whole world. That said... I built everything using the grpc-backplane types, and found that, of the three versions of the same object, they were the best to work with (and seemed appropriate given it is all server side).

If the goal is to avoid having DB suck them in (why? I don't understand.... the term backplane doesn't mean a lot to me)... then, I suppose it'll be possible to come up w/ an interface and DI to get my parser into the script session (nate had agreed it was the best place to put it, and I don't know enough of the infrastructure to disagree).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, pushed commit w/ a refactor. It's a little ugly w/ the type parameters, but the wider, shorter dependency tree is nicer.

assert replaceRange.start.greaterOrEqual(startPos);
assert replaceRange.end.greaterOrEqual(endPos);
assert LspTools.greaterOrEqual(replaceRange.getStart(), startPos);
assert LspTools.greaterOrEqual(replaceRange.getEnd(), endPos);
Copy link
Member

Choose a reason for hiding this comment

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

jvm code should use Assert or Require if this is a concern

Copy link
Member Author

Choose a reason for hiding this comment

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

it's really not, just there for testing. Plus, it's possible for these types to someday live on a client, if that's ever something we'd want to bother w/.

Thread.currentThread().interrupt();
break;
} catch (ExecutionException e) {
// TODO: log this;
Copy link
Member

Choose a reason for hiding this comment

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

file issues for new TODOs, or link them in code - format is // TODO (repo#issuenum) message

Copy link
Member Author

Choose a reason for hiding this comment

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

I just stuck in a logger, and trace() log it, instead of throwing an exception and breaking things over autocomplete misbehaving.

niloc132
niloc132 previously approved these changes Jun 22, 2021
Copy link
Member

@niloc132 niloc132 left a comment

Choose a reason for hiding this comment

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

two minor thoughts, i'd only ask that the TODOs get updated across the PR before merge

final JsPropertyMap<Object> posObj = pos.asPropertyMap();
final Position result = new Position();
result.setLine(posObj.getAny("line").asInt());
result.setCharacter(posObj.getAny("character").asInt());
Copy link
Member

Choose a reason for hiding this comment

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

i may revisit these later and make jsinterop "beans" for them, since asInt() has no power under prod builds, and will just write garbage - we will want/need something that even at runtime in prod gets typechecked for calls from non-typesafe code

Copy link
Member Author

Choose a reason for hiding this comment

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

luckily for us, these objects that come in from react will always be populated, so fine enough to leave like this for now.

@JamesXNelson JamesXNelson merged commit 9798e27 into deephaven:main Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get the minimal wiring to have an autocomplete service respond to client requests

2 participants