todo index: get rid of file field in TokenSetTodoIndexer

GitOrigin-RevId: 582f0832ff44317e3120aafd9edad9c43c57bee3
This commit is contained in:
Dmitry Batkovich
2019-12-17 14:06:19 +00:00
committed by intellij-monorepo-bot
parent def80e2924
commit 4b12ff67d9
2 changed files with 6 additions and 10 deletions
@@ -14,7 +14,6 @@ import com.intellij.openapi.fileTypes.InternalFileType;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.CustomHighlighterTokenType;
import com.intellij.psi.impl.cache.CacheUtil;
import com.intellij.psi.impl.cache.impl.BaseFilterLexer;
@@ -45,7 +44,7 @@ public abstract class PlatformIdTableBuilding {
private PlatformIdTableBuilding() {}
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType) {
final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
if (extIndexer != null) {
return extIndexer;
@@ -56,12 +55,12 @@ public abstract class PlatformIdTableBuilding {
final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
if (commentTokens != null) {
return new TokenSetTodoIndexer(commentTokens, virtualFile);
return new TokenSetTodoIndexer(commentTokens);
}
}
if (fileType instanceof CustomSyntaxTableFileType) {
return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS);
}
return null;
@@ -83,11 +82,9 @@ public abstract class PlatformIdTableBuilding {
private static class TokenSetTodoIndexer extends VersionedTodoIndexer {
@NotNull private final TokenSet myCommentTokens;
private final VirtualFile myFile;
TokenSetTodoIndexer(@NotNull final TokenSet commentTokens, @NotNull final VirtualFile file) {
TokenSetTodoIndexer(@NotNull final TokenSet commentTokens) {
myCommentTokens = commentTokens;
myFile = file;
}
@Override
@@ -103,7 +100,7 @@ public abstract class PlatformIdTableBuilding {
highlighter = editorHighlighter;
}
else {
highlighter = HighlighterFactory.createHighlighter(inputData.getProject(), myFile);
highlighter = HighlighterFactory.createHighlighter(inputData.getProject(), inputData.getFile());
highlighter.setText(chars);
}
@@ -78,8 +78,7 @@ public final class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Int
@NotNull
public Map<TodoIndexEntry, Integer> map(@NotNull final FileContent inputData) {
final VirtualFile file = inputData.getFile();
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = PlatformIdTableBuilding
.getTodoIndexer(inputData.getFileType(), file);
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = PlatformIdTableBuilding.getTodoIndexer(inputData.getFileType());
if (indexer != null) {
return indexer.map(inputData);
}