Closed EduardoVaz06 closed 4 months ago
Oh wow, I've literally never seen this kind of pattern before. Good fun, we'll need to make some changes to the compiler directive parser to support this kind of nesting.
Explaining the use case a little better.
In the organization where I work we often use Git submodules as dependencies of our Delphi projects.
To add an extra layer of security, we add a version.txt file in the submodule storing the dependency version (git tag name). In software that uses this submodule, we maintain a constant with the expected version and at compile time we check if the file version.txt and the constant have the same value, if the value is different the software will not compile, forcing the developer to check why this happened.
Developers often updated the version of submodules by mistake, this strategy prevents this from being done unintentionally.
The strategy I mentioned is done through the code example brought by @EduardoVaz06.
Prerequisites
SonarDelphi version
1.6.0
SonarQube version
No response
Issue description
An exception is raised in some delphi files while analyzing it, au.integradev.delphi.preprocessor.directive.CompilerDirectiveParserImpl$CompilerDirectiveParserError: UNexpected character: '{'
(CompilerDirectiveParserImpl.java) EXPRESSION_LEXER seems to not expect another directive and fails to compile the file.
Full exception on file: exception-log.txt
Steps to reproduce
Create directive that calls another directive recursively (like the example code below)
Execute Sonar Scanner analysis with Sonar Delphi
An exception should be raised in the file with the directive that calls another directive
Minimal Delphi code exhibiting the issue