Java Xtext自定义警告抑制
我已经建立了我的DSL,并设置了一些信息、警告和错误消息 例如:Java Xtext自定义警告抑制,java,validation,code-generation,xtext,suppress-warnings,Java,Validation,Code Generation,Xtext,Suppress Warnings,我已经建立了我的DSL,并设置了一些信息、警告和错误消息 例如: warning('''some message''', obj, package.Literals.LITERAL) 然后我将项目(生成器生成的类Main.xtend)导出到一个some_name.jar中 Main.xtend包含: // Validate the resource val issues = validator.validate(resource, CheckMode.ALL,CancelIndicator.
warning('''some message''', obj, package.Literals.LITERAL)
然后我将项目(生成器生成的类Main.xtend)导出到一个some_name.jar中
Main.xtend包含:
// Validate the resource
val issues = validator.validate(resource, CheckMode.ALL,CancelIndicator.NullImpl)
if (!issues.empty) {
issues.forEach[System.err.println(it)]
return
}
// Configure and start the generator
fileAccess.outputPath = 'src-gen/'
val context = new GeneratorContext => [cancelIndicator = CancelIndicator.NullImpl]
generator.generate(resource, fileAccess, context)
System.out.println('Code generation finished.')
现在当我跑的时候
> *java -jar some_name.jar my_file*
生成器不会生成代码,因为这些信息/警告消息
如何抑制特定信息/警告/错误信息?我不明白。首先,您必须自定义一些不在信息/警告上生成的内容。您还可以查看可配置问题(ConfigurableIssueCodeProvider),因此只需在issues.empty处添加一个过滤器,代码中的内容就会很复杂。首先,您必须自定义一些不在信息/警告上生成的内容。您还可以查看可配置问题(ConfigurableIssueCodeProvider),因此只需在issues.empty处添加一个过滤器即可