-
Notifications
You must be signed in to change notification settings - Fork 19
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
Improved argument injections handling #92
Improved argument injections handling #92
Conversation
b25bba2
to
7d3f4a1
Compare
argumentExpression.accept(object : PsiRecursiveElementWalkingVisitor() { | ||
override fun visitElement(element: PsiElement?) { | ||
if (element is PsiLanguageInjectionHost && StyledComponentsInjector.matchInjectionTarget(element) != null) { | ||
hasChildInjection = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it really work O_o? Wow
Hey! Sorry for not paying attention to this project. The issue described in #76 seems to appear intermittently (try it with the sample from the original post, paste the sample into a file, usually no error is shown, make some small whitespace edits, error will usually appear), so it seems possible it's a highlighting error, not on the level of building injected PSI content. Errors in injected code are filtered by ... |
@undeadcat thank you for the details, I'll check it out. It looks like for this case something stopped working. A range containing
But I don't see any logic which will ignore this kind of errors. It is caused by an EXTERNAL_FRAGMENT insertion, but it is located in a position where all the errors will be visible. |
@vepanimas, I don't think we ever handled the case of
(NB: without semicolon after argument) without extra highlights. It would be nice to fix it, but this seems distinct from the issue described in #76 |
@undeadcat I can't agree that they are distinct. At first, all the examples in the related issue contain a nested injection, so we can talk about them as the most common use cases. Second, an example I mentioned in my previous comment is from here, I mistakenly copied the wrong text from the editor to the comment. It also contains an injection and has an error displayed in the middle of the |
After a little investigation, I can confirm that the issue refers to the platform itself, not the plugin. We can configure a standalone LESS injection with prefix="div {" and suffix="}" in WebStorm and will have this error consistently reproduced.
Note that if we remove nested injection it will work as expected:
Created a separate issue https://youtrack.jetbrains.com/issue/WEB-47350. |
@anstarovoyt fixed in 7bb3683 based on the current implementation in IDEA. |
7bb3683
to
00a060f
Compare
8489228
to
5aec0f7
Compare
@anstarovoyt
#76
The general idea is to ignore nested styled-components injections which we could assume valid CSS fragments instead of replacing them with
EXTERNAL_FRAGMENT
.So this code
will be replaced with syntactically correct
This kind of injections will be handled as before:
I think this is a safe heuristic that we can use now, and it should cover all the most painful cases.
Also, I provided a temporary registry key to disable this new behavior if something goes wrong for someone:
styled.components.experimental.injections
.