Is it possible to use multiline todo's in Inte

2020-02-24 05:03发布

If yes, how ?

If not, is there a workaround to get similar functionality ?

EDIT:

What I mean is something like this :

// TODO line1
// line2
// line3

and line1, line2, line3 belong to the same TODO and get highlighted with blue.

7条回答
孤傲高冷的网名
2楼-- · 2020-02-24 05:25

Building on NonGrate's answer:

Go to settings, search for TODO settings, and replace the existing todo entry "\btodo\b.*" with:

(\btodo\b.*)|(\/\*(\*(?!\/)|[^*])*\btodo\b(\*(?!\/)|[^*])*\*\/)

Result:

enter image description here

You must use */ to close the highlight.

It uses 2 patterns:

  1. (\btodo\b.) captures any line with the word todo
  2. (/\*(\*(?!/)|[^*])*\btodo\b(\*(?!/)|[^*]*\*/) captures multi line comments starting with /* and ending with */

Any other combinations may not work.

Note: You have to replace the existing regex to avoid having multiple instances of the same todo item appearing in the todo list.

查看更多
再贱就再见
3楼-- · 2020-02-24 05:25

In my settings I'm using such a regex for multiline TODO:

\/(\/|\*)[ ]*\btodo\b(.|\n)*(\*\/|)

The only problem is that it doesn't highlight last */ symbols of multiline comment. If anyone can solve that, it would be great!

查看更多
Root(大扎)
4楼-- · 2020-02-24 05:26

This is supported since 2018.3.

Multiline TODO comments

Multiline TODO comments

IntelliJ IDEA 2018.3 now supports multiline TODO comments, now the first and all subsequent TODO comment lines are highlighted in the editor and listed in the TODO Tool Window. Simply add an indent starting from the second line of your multiline TODO comment, and the IDE will differentiate it from an ordinary comment.

查看更多
叛逆
5楼-- · 2020-02-24 05:33

No, not for now.

This feature has been discussed, but not yet implemented.

EDIT/UPDATE:

It is implemented in 2018.3 version.

查看更多
趁早两清
6楼-- · 2020-02-24 05:34

You can use FIXME and TODO using tabs as follows

//FIXME: first line
//<tab> second line
//<tab> third line

For more information please refer to the documentation

查看更多
唯我独甜
7楼-- · 2020-02-24 05:39

This regex works for me:

(?:(?:todo|TODO)(?:\[[A-Z,a-z]+\-\d+\])?\s(\s*\b.*\b)*)|(?:\/\*\s*(?:todo|TODO)(?:\[[A-Z,a-z]+\-\d+\])?\s(?:(?!\*\/)[\s\S])*\*\/)

It basically looks for the following:

  • A todo or TODO keyword optionally suffixed by a ticket/issue id in brackets and any amount of characters after a single white space character.
  • A java multi line comment starting with /* followed by any amount of white space and then the conditions outlined in the single line todo description above. It terminates once it finds */ in any of the following lines.

Single-line examples:

todo some very important stuff
TODO[SAOY-1376] An urgent bug fix described in the SAOY-1376
// todo some very important stuff
// TODO[SAOY-1376] An urgent bug fix described in the SAOY-1376

Multi-line examples:

/* todo assignee or something
    a very important message
    another thing
*/

/* TODO[SAO-13]
 * a very important message
 * another thing
*/
查看更多
登录 后发表回答