jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

Custom annotations do not support numeric values #425

Closed murdos closed 4 years ago

murdos commented 4 years ago
Overview of the issue

Parse error while using custom binary annotation in JDL with numeric parameter:

 SyntaxError: Error: MismatchedTokenException: Expecting token of type --> NAME <-- but found --> '2' <--
        at line: 8, column: 39
      at callApiMethod (lib\readers\jdl_reader.js:32:813)
      at parse (lib\readers\jdl_reader.js:32:84)
      at Object.parseFromFiles (lib\readers\jdl_reader.js:24:191)
      at parseFiles (lib\jdl\jdl_importer.js:46:582)
      at createImporterFromFiles (lib\jdl\jdl_importer.js:28:313)
      at Context.<anonymous> (test\spec\jdl\jdl_importer.spec.js:1044:26)
      at processImmediate (internal/timers.js:439:21)
Motivation for or Use Case

Sometimes you need numeric parameters, e.g. an order. It's not even possible to use '2' instead of 2 as a workaround.

Reproduce the error

Modified entity A from annotations.jdl test case, replacing value2 by 2 and also (another test case) value3 by '3'

@service(serviceClass)
@dto(mapstruct)
@skipClient
@myCustomUnaryOption
@myCustomBinaryOption(customValue)
@myCustomBinaryOption(customValue)
entity A {
  @id @multiValue(value1) @multiValue(2) @multiValue('3') name String
  noAnnotation String
}
Related issues
Suggest a Fix
JHipster Version(s)

6.5.1 but reproduced by modifying test case of jhipster-core master

JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System