CodeGenerator
CodeGenerator copied to clipboard
Cannot add own suffix to generated class - default package names starts with redundant '\n'
- Plugin version 1.5.2. IDEA Build #IU-223.8214.52 OS - Linux
- new template created
<CodeTemplate>
<option name="name" value="TestDataFactory" />
<option name="type" value="class" />
<option name="template" value="public class ${ClassName} { public static ${class0.name} aDefault${class0.name}(){ return ${class0.name}.build(); } } " />
<option name="classNameVm" value="${class0.qualifiedName}TestDataFactory" />
<option name="defaultTargetPackage" value="" />
<option name="defaultTargetModule" value="" />
</CodeTemplate>
- generate code
package
ru.test.example;
directory with name started with '\n' created
src/test/java$ ls
''$'\n''ru' ru
UI file manager screenshot:

Didn't found the way to fix.
After some investigation I see that expression
<option name="classNameVm" value="${class0.qualifiedName}TestDataFactory" />
resolved to ''$'\n''. It caused wrong name of package.
So I didn't find the way to generate new class with my own suffix
DEBUG logs
2023-02-03 23:00:13,258 [2810998] FINE - #me.lotabout.codegenerator.action.CodeGeneratorAction - +++ executePipeline - START +++
2023-02-03 23:00:13,260 [2811000] FINE - #me.lotabout.codegenerator.action.CodeGeneratorAction - Current project leetcode
2023-02-03 23:00:13,268 [2811008] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,269 [2811009] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,269 [2811009] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,269 [2811009] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,269 [2811009] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,269 [2811009] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: TreeNode, returnType=null
2023-02-03 23:00:13,270 [2811010] WARN - #o.j.j.g.e.ElementFactory - This method does not have a valid return type: Object, returnType=null
2023-02-03 23:00:13,273 [2811013] FINE - #me.lotabout.codegenerator.action.CodeGeneratorAction - Select member/class through pipeline
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Velocity Template:
${class0.name}TestDataFactory
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Executing velocity +++ START +++
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Executing velocity +++ END +++
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.worker.JavaClassWorker - FQClass generated
TreeNodeTestDataFactory
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Velocity Template:
public class ${ClassName} {
}
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Executing velocity +++ START +++
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.util.GenerationUtil - Executing velocity +++ END +++
2023-02-03 23:00:13,274 [2811014] FINE - #me.lotabout.codegenerator.worker.JavaClassWorker - Method body generated from Velocity:
public class
TreeNodeTestDataFactory {
}
Looks like RCA is https://github.com/lotabout/CodeGenerator/pull/18/commits/e82d4f0a28ca82b9b2bc596ecf4e729f390952d5#diff-bbabbde4dbf64a0cac897295690b776062d991f172593f4094bde3be1eeca370
var templateWithDefaultImports = defaultImportParseExpression + System.getProperty("line.separator") + template;
Not reproduced with 1.4.1. Will use it while waiting for an update. Thanks for the plugin!