Skip to content

COMP: Show the trait of an method #1213

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

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.

@farodin91 farodin91 force-pushed the autocomplete-trait branch from 15799cf to 7589d94 Compare May 5, 2017 18:15
@@ -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" } ?: ""

@farodin91 farodin91 force-pushed the autocomplete-trait branch from 7589d94 to 19afb98 Compare May 6, 2017 10:10
@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.

3 participants