简体   繁体   English

使用JDT编写带有注释参数的Java方法签名

[英]Write Java Method Signature with Annotated paramaters with JDT

I am writing an eclipse plug-in which generates code. 我正在编写一个生成代码的eclipse插件。 I am leveraging eclipse jdt to gen out classes, fields, and methods. 我利用Eclipse JDT生成了类,字段和方法。 One of the requirements I have is to generate methods with annotated paramaters... 我的要求之一是生成带有带注释的参数的方法。

public returnType foo(@someAnnotation int id)
{
     .....
     .....
}

Does anybody know how to write out the @someAnnotation using JDT? 有人知道如何使用JDT写出@someAnnotation吗? To write out normal parameters in JDT you could do something like the following 要在JDT中写出正常参数,您可以执行以下操作

Signature.createTypeSignature("int", false)

您是否尝试过调试带有注释的类型签名的创建,并检查传递给createTypeSignature的参数?

Yes I have tried this. 是的,我已经尝试过了。 The createTypeSignature() function does validation on the String that is passed to it. createTypeSignature()函数对传递给它的String进行验证。 When it sees something like the following it throws an exception... 当它看到类似以下内容的内容时,将引发异常...

Signature.createTypeSignature("@PathParam(\"custId\") int");

Hope this clears it up, and thanks for the response. 希望能解决这个问题,并感谢您的答复。 Let me know if you have any other ideas. 让我知道您是否还有其他想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM