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

Issue 259: use enhanced (CompletionItem|Symbol)Kinds #288

Merged
merged 5 commits into from
Apr 16, 2018

Conversation

eddiemundo
Copy link
Contributor

@eddiemundo eddiemundo commented Apr 16, 2018

Closes #259

I added the new lsp CompletionItemKinds and SymbolKinds.

For CompletionItemKinds I only mapped TypeParameter and Function, but I'm not sure if you want Function mapped because it's not a new CompletionItemKind, and it wasn't previously mapped. I also think the Function case is dead-code cause when trying to complete a symbol that's a function it'll probably go into the val case.

For SymbolKinds I'm not convinced that I did the additions to ScalametaEnrichments correctly. I'm not sure if documentSymbol() adds Type.Param and Lit.Null to the list that it builds, so those additional cases might be pointless.

Finally the issue mentions Constant in CompletionItemKind. I'm not sure how to map that cause doesn't CompletionItemKind.Value cover that, or does Constant mean something else?

@gabro
Copy link
Member

gabro commented Apr 16, 2018

Thank you so much for this contribution @eddiemundo!

I think I'll have time to review this later today, meanwhile I can suggest to add test cases to CompletionsTest.scala so to test your assumptions: for instance, I too suspect that the isFunction will be dead code.

You can run ~metals/testOnly tests.compiler.CompletionsTest and go from there.

Copy link
Member

@gabro gabro left a comment

Choose a reason for hiding this comment

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

Pretty cool! I personally like the detection of Function as opposed to val

def isFunction(symbol: Symbol): Boolean = {
val typeSymbolFullName = symbol.info.finalResultType.typeSymbol.fullName
functionTraitRegex.findFirstIn(typeSymbolFullName).isDefined
}
Copy link
Member

Choose a reason for hiding this comment

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

You can query the compiler directly for this piece of information with

compiler.definitions.isFunctionSymbol(
  symbol.info.finalResultType.typeSymbol
)

(thanks @olafurpg for the tip)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spent way too long trying to figure something like that out before settling on the ugly regex solution... thanks

Copy link
Member

@gabro gabro left a comment

Choose a reason for hiding this comment

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

LGTM! 👍 Thank you for this contribution, @eddiemundo

Copy link
Member

@gabro gabro left a comment

Choose a reason for hiding this comment

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

LGTM! 👍 Thank you for this contribution, @eddiemundo

@gabro gabro requested a review from olafurpg April 16, 2018 11:57
Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for this contribution @eddiemundo !

@gabro gabro merged commit fcac1cc into scalameta:master Apr 16, 2018
olafurpg pushed a commit that referenced this pull request Feb 14, 2019
Issue 259: use enhanced (CompletionItem|Symbol)Kinds
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.

3 participants