From 42a8c58fa55679dd13623d4dbb7cfbe7d1db10ca Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 13 Jun 2017 19:20:55 +0300 Subject: [PATCH] Enable todo indexing in content roots only - all OpenProjects are used to avoid generating different indexing results for different projects - only content-files are included since IndexTodoCacheManagerImpl.getFilesWithTodoItems filter out all non-content todo-entries --- .../psi/impl/cache/impl/todo/TodoIndex.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/todo/TodoIndex.java b/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/todo/TodoIndex.java index cf1f76405738..93a2feef6a07 100644 --- a/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/todo/TodoIndex.java +++ b/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/todo/TodoIndex.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,9 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeRegistry; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.impl.cache.impl.id.PlatformIdTableBuilding; @@ -115,6 +118,10 @@ public class TodoIndex extends FileBasedIndexExtension return false; // do not index TODOs in library sources } + if(!isInContentOfAnyProject(file)) { + return false; + } + final FileType fileType = file.getFileType(); if (fileType instanceof LanguageFileType) { @@ -128,6 +135,15 @@ public class TodoIndex extends FileBasedIndexExtension fileType instanceof CustomSyntaxTableFileType; }; + private static boolean isInContentOfAnyProject(@NotNull VirtualFile file) { + for (Project project : ProjectManager.getInstance().getOpenProjects()) { + if (ProjectFileIndex.getInstance(project).isInContent(file)) { + return true; + } + } + return false; + } + @Override public int getVersion() { int version = 9;