-
Notifications
You must be signed in to change notification settings - Fork 41
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
Multiline macro in Impex inspection #666
Comments
Hello, @uvoigt thank you for highlighting this. |
@uvoigt , it looks like something like that is also possible and it may make me sleepless :) As for now, I'm not sure how to properly adjust Parser/Lexer for such cases
|
btw, Rauf Aliev described multi-line support in 2016 :) suggesting - not to use it. |
@mlytvyn I see this as a Lexer problem only. Since there is no line break like in multiline strings, the Lexer could simply remove the backslash (keeping positional information of course) and continue on the next line |
To be able to properly implement it, the whole approach has to be changed - instead of parsing it line by line content has to be split by For example, this macro is valid, but will be imported not in complete:
Btw, I've already adjusted lexer for macro name and macro value, but it is not ideal and doesn't not support special symbols I'd like to remind about possible separation of the ImpEx and FlexibleSearch, last one can be extracted into own fxs file and loaded via FileLoaderValueTranslator (https://help.sap.com/doc/61058561bffb416395816991f147f6f0/2005/en-US/de/hybris/platform/commerceservices/impex/impl/FileLoaderValueTranslator.html). |
@mlytvyn I agree with you that fundamentally changing the approach may be too much effort. It would be much easier if the original authors of the Impex engine would have used a grammar based parser as well. |
That's odd, in quite many projects translator worked well. Can you please check out this thread and ensure that all files are in right place? There is a Slack channel for the Plugin (see readme.md), if you want we can discuss details of that specific issue. |
Yes, you're right. It works using the path from the source root with a leading slash. |
here is Lexer regex for macro name: macro value regex is way more complex, will try to adjust it according to your case |
This is rather strange: to me it seems backslashes can be at any place in Impex. Some kind of pre-processing and not polluting the grammar with the handling of backslashes could be a better approach, while I don't know if this can be done with the Flex implementation. Positional information would be dropped if there is no such input as a stream of tokens holding the original positional info Even this statement seems to be valid:
|
Could it be an option to simply remove all backslashes before feeding the Lexer? |
backslashes required to know that two lines are related and should not be treated as separate entities. in other words: |
But that is what the CSVReader essentially does. It looks for a backslash at the end of the line (forgot to mention that) and then wraps all following lines ending with the backslash to one until end of the stream or a line without a backslash at the end. |
sure, I understand your point, it is valid for actual processing and import of the p.s. thanks for reminding about |
What I meant by #666 (comment) is that it might be possible to intercept the input CharSequence provided to the Lexer and replace it by an own implementation of CharSequence which might be able to restore original position information of joined multilines by doing the same CSVReader does but save original multiline positions while joining. But I don't have enough inside into the current Lexer implementation to see if that is possible or not. |
unfortunately, I'm in the same busy boat. here is flex file: https://github.com/epam/sap-commerce-intellij-idea-plugin/blob/main/src/com/intellij/idea/plugin/hybris/impex/Impex.flex, while let's proceed with baby-steps. |
I agree. |
@uvoigt , added multi-line
take a note, that for I've also:
As usual, it will be part of the next |
@mlytvyn nice work! |
@uvoigt , thank you and, once again, thank you for bringing this up! I dig into OOTB translators and know more now :).
IntelliJ may re-trigger Inspections many-many times, some inspections we have rely on readiness of the Index, so they are usually constantly re-triggered and cancelled till the moment Index is ready. This state may rely on size of the |
@uvoigt let's call it a day and close as completed. Thank you and looking forward to your suggestions! |
Hi,
Would it be possible to respect multiline macros in Impex inspection?
The text was updated successfully, but these errors were encountered: