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

Support split strings within inspections & method target references #2358

Merged

Conversation

FxMorin
Copy link
Contributor

@FxMorin FxMorin commented Aug 14, 2024

Description:

Currently some inspections don't support strings that have been split to support a line width limit, same goes for Injection method targets.

Changes:

Removed multiple direct PsiLiteral checks which where not needed, since all calls would lead to PsiElement.constantStringValue, which will return null if its not suppose to.

Now, all these calls will use the ConstantExpressionVisitor.compute call which takes care of the split string logic.

Examples:

Method Reference

Before - Single (Expected behaviour)
Before - Single
Before - Split
Before - Split

After - Split
After - Split

AmbiguousReferenceInspection

Before
Before

After
After

InvalidMemberReferenceInspection

Before
Before

After
After

UnnecessaryQualifiedMemberReferenceInspection

Before
Before

After
After

Copy link
Member

@Earthcomputer Earthcomputer left a comment

Choose a reason for hiding this comment

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

Are you sure that checks for PsiLiteral weren't the only problem? The constantEvaluationHelper is already supposed to handle string concatenation, see ConstantExpressionVisitor.compute

@FxMorin
Copy link
Contributor Author

FxMorin commented Aug 14, 2024

Are you sure that checks for PsiLiteral weren't the only problem? The constantEvaluationHelper is already supposed to handle string concatenation, see ConstantExpressionVisitor.compute

I was not aware of this. I just tested it, and you're right. I'll remove the changes to PsiElement.constantStringValue

@Earthcomputer Earthcomputer merged commit 8e06246 into minecraft-dev:dev Aug 14, 2024
5 checks passed
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