Intellij结构搜索,用于注释和评论内容

时间:2018-12-06 22:32:02

标签: java intellij-idea structural-search

我有一个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$ */

结构搜索功能可以做到吗?如果没有,我应该如何处理?

0 个答案:

没有答案