我有一个Java代码库,在这里我既需要注释函数参数,又需要在文档注释的@param
标签中为该参数添加特定的注释字符串。我想进行自定义Intellij检查,以标记缺少注释或注释的实例。以@Foo
作为注释,以(and it's Foo'd!)
作为注释的示例:
/**
* This method should not be flagged, it has both.
* @param paramName this is a parameter (and it's Foo'd!)
*/
void func1(@Foo Type paramName){}
/**
* This method should be flagged. It is missing the note.
* @param paramName this is a parameter
*/
void func2(@foo Type paramName){}
/**
* This method should also be flagged. It is missing the annotation.
* @param paramName this is a parameter (and it's Foo'd!)
*/
void func3(Type paramName){}
/**
* This method also should not be flagged, it has neither.
* @param paramName this is a parameter
*/
void func4(Type paramName){}
/**
* This method should be flagged because the parameter name doesn't match.
* @param paramName this is a parameter
* @param otherParam this is a parameter (and it's Foo'd!)
*/
void func5(@Foo Type paramName, Type otherParam){}
从the docs看来,执行此操作的首选方法是创建自定义结构搜索。不过,我不知道如何使它正常工作。我什至无法使它与带有笔记的@param
标签和没有笔记的@param
标签匹配。我尝试过的一些事情:
/** @param $paramName$ $Comment$ (and it's Foo'd!) */
/** @$paramTag$ $paramName$ $Comment$ $note$ */
/** $paramTagNoAt$ $paramName$ $Comment$ $note$ */
结构搜索功能可以做到吗?如果没有,我应该如何处理?