如何将任务标记限制为 Eclipse 中的当前项目?

Eclipse 当前显示来自所有打开项目的任务标记(// TODO)。如果有人能指出我的偏好,我将不胜感激,因为我可以限制显示任务的范围(例如只显示来自当前项目的任务)。

17464 次浏览

AFAIK the Eclipse task list is workspace-based and cannot really be filtered by default.

Close projects that you aren't working on. Tasks show for any part of the workspace, so remove projects that you arent working on by doing a close operation. (right click on the project in the project explorer and then "close project")

There should be a down arrow in the top-right with several options in it. For the old Eclipse the option you want is Filters... And for the newer Eclipse the option is now Configure Contents. At the top of the Configure Contents dialog is a scope selection with options you want, I think.. If not check preferences and search for tasks, or scope. It should be in there somewhere.

Configure Contents... can be used to filter to things like working sets (if you're not already using working sets, you should), but yet another way is to use Mylyn to filter out any UI elements not relevant for what you're currently working on.

Filtering by working sets works fine, but I had to put the packages into a working set, rather than the whole project.

In Eclipse Helios (3.6) you can configure the scope.

Down arrow at the top right -> Configure Contents:

Configure Contents img

Select a configuration on the left (or create a new one) and on the right in the Scope section select "On any element in same project".

Simply close the projects you are not working on.
You can leave them in the workspace, too.

In Eclipse Juno 4.2.1, I found that it's possible to disable specific projects TODO tasks.

In the projects properties open: Java Compiler > Task Tags

From that page check the option "Enable project specific settings" and remove the TODO entry from the list below, after that the TODO comments from that project won't be shown in Tasks. You could also remove other tags from the list.

In Eclipse 2019-06:

1- Open the Tasks window.
2- Click on the arrow pointing down .
3- Click on Filters...
enter image description here


4- In the Configurations panel on the left select TODOs (or any configuration that you have saved).
5- Under Scope select On elements in selected projects
enter image description here

6- Click on Apply and Close

Now the task view will only show the tasks of the project where you are at the moment.