8000 Simplify hover for constants by jez · Pull Request #2302 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Simplify hover for constants #2302

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
Dec 6, 2019
Merged

Simplify hover for constants #2302

merged 1 commit into from
Dec 6, 2019

Conversation

jez
Copy link
Collaborator
@jez jez commented Dec 6, 2019

Motivation

I wanted to share some code between hover and completion, but then I
realized that the hover code was more complicated than it needed to be.

Test plan

See included automated tests.

@jez jez requested a review from a team December 6, 2019 02:26
@ghost ghost requested review from DarkDimius and removed request for a team December 6, 2019 02:26
const auto &data = constResp->symbol.data(gs);
auto type = constResp->retType.type;
if (data->isClassOrModule()) {
auto singletonClass = data->lookupSingletonClass(gs);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This lookupSingletonClass on the ConstantResponse symbol is the same code that DefLocSaver does when it creates ConstantResponses, so this whole branch is useless.

Copy link
Collaborator Author
@jez jez Dec 6, 2019

Choose a reason for hiding this comment

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

if (symbol.data(ctx)->isClassOrModule()) {
tp.type = symbol.data(ctx)->lookupSingletonClass(ctx).data(ctx)->externalType(ctx);
} else {
auto resultType = symbol.data(ctx)->resultType;
tp.type = resultType == nullptr ? core::Types::untyped(ctx, symbol) : resultType;
}

I wanted to share some code between hover and completion, but then I
realized that the hover code was more complicated than it needed to be.
@jez jez force-pushed the jez-simplify-hover branch from 2eeea59 to 9096923 Compare December 6, 2019 17:26
@jez jez requested review from aisamanra and removed request for DarkDimius December 6, 2019 21:36
Copy link
Contributor
@aisamanra aisamanra left a comment

Choose a reason for hiding this comment

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

Looks good!

@jez jez merged commit 44e1493 into master Dec 6, 2019
@jez jez deleted the jez-simplify-hover branch December 6, 2019 21:39
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
0