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

COMP: Show the trait of an method #1213

Merged
merged 1 commit into from May 6, 2017

Conversation

farodin91
Copy link
Contributor

Fixes #1190

@@ -17,6 +17,11 @@ object CompletionEngine {
const val KEYWORD_PRIORITY = 10.0
}

fun RsFunction.generateAppendTailText(): String {
Copy link
Member

Choose a reason for hiding this comment

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

This can be private.

@@ -35,6 +40,7 @@ fun RsCompositeElement.createLookupElement(scopeName: String): LookupElement {
is RsFunction -> base
.withTypeText(retType?.typeReference?.text ?: "()")
.withTailText(valueParameterList?.text?.replace("\\s+".toRegex(), " ") ?: "()")
.appendTailText(generateAppendTailText(), false)
Copy link
Member

Choose a reason for hiding this comment

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

Don't you think it'll look better with grayed = true? Won't distract from the function signature so much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Look better

private fun RsFunction.generateAppendTailText(): String {
val trait = parentOfType<RsImplItem>()?.traitRef?.text ?: return ""
return " by $trait"
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks more like a property. Could also be more compact:

private val RsFunction.extraTailText: String
    get() = parentOfType<RsImplItem>()?.traitRef?.text?.let { " of $it" } ?: ""

@matklad
Copy link
Member

matklad commented May 6, 2017

Thanks!

@matklad
Copy link
Member

matklad commented May 6, 2017

bors r+

bors bot added a commit that referenced this pull request May 6, 2017
1213: COMP: Show the trait of an method r=matklad
Fixes #1190
@bors
Copy link
Contributor

bors bot commented May 6, 2017

Build succeeded

@bors bors bot merged commit 19afb98 into intellij-rust:master May 6, 2017
@farodin91 farodin91 deleted the autocomplete-trait branch May 7, 2017 14:47
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.

None yet

3 participants