Skip to content

Commit ea64cf1

Browse files
committed
fix(index): match AppMap metadata files by name, not JSON file type
On build 262 the AppMap indexes returned nothing, so metadata/name/classMap lookups (and AppMap discovery) came up empty. Root cause: both the index input filters and the appMapsWithExcluded search scope gated on JsonFileType.INSTANCE, but JSON language support is provided by a separate platform module whose file-type registration is not active in every runtime (notably the 262 test sandbox). Files such as metadata.json were therefore not classified as JSON, so a FileTypeSpecificInputFilter never offered them to the indexer and getScopeRestrictedByFileTypes(..., JsonFileType) excluded them from the query scope. The files we index have specific, known names, so the JSON file type gate was only ever an optimisation on top of an exact-name match. Replace the FileTypeSpecificInputFilter with a plain FileBasedIndex.InputFilter that matches by file name alone, and drop the JsonFileType restriction from appMapsWithExcluded. The scope is only used to query our own name-matched indexes and to locate *.appmap.json files by extension via the platform's FilenameIndex, neither of which needs a file-type restriction. Bump the shared index version (66 -> 67) to rebuild indexes once on upgrade. Verified: the index tests and OpenRecentAppMapActionTest pass on both 251 and 262 (they failed on 262 before this change). Assisted-by: Claude:claude-opus-4-8
1 parent 305708d commit ea64cf1

5 files changed

Lines changed: 14 additions & 39 deletions

File tree

plugin-core/src/main/java/appland/index/AbstractAppMapMetadataFileIndex.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package appland.index;
22

33
import com.google.gson.JsonParseException;
4-
import com.intellij.json.JsonFileType;
54
import com.intellij.openapi.diagnostic.Logger;
65
import com.intellij.util.indexing.FileBasedIndex;
76
import com.intellij.util.indexing.FileContent;
@@ -20,9 +19,10 @@
2019
abstract class AbstractAppMapMetadataFileIndex<T> extends SingleEntryFileBasedIndexExtension<T> {
2120
private static final Logger LOG = Logger.getInstance(AbstractAppMapMetadataFileIndex.class);
2221

23-
private final FileBasedIndex.InputFilter inputFilter = new NamedFileTypeFilter(JsonFileType.INSTANCE, fileName -> {
24-
return getIndexedFileName().equalsIgnoreCase(fileName);
25-
});
22+
// Match by file name only. We intentionally do not use a FileTypeSpecificInputFilter keyed on the
23+
// JSON file type: JSON language support is a separate platform module whose file-type registration
24+
// is not active in every runtime (e.g. the 262 test sandbox), which would silently exclude our files.
25+
private final FileBasedIndex.InputFilter inputFilter = file -> getIndexedFileName().equalsIgnoreCase(file.getName());
2626

2727
private final SingleEntryIndexer<T> indexer = new SingleEntryIndexer<>(false) {
2828
@Override

plugin-core/src/main/java/appland/index/AppMapSearchScopes.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package appland.index;
22

3-
import com.intellij.json.JsonFileType;
43
import com.intellij.openapi.module.Module;
54
import com.intellij.openapi.project.Project;
65
import com.intellij.openapi.roots.FileIndexFacade;
@@ -23,10 +22,14 @@ private AppMapSearchScopes() {
2322

2423
/**
2524
* @param project Project
26-
* @return Search scope, which contains all .appmap.json files of the project, included files inside excluded directories. The scope is also restricted by the JSON file type.
25+
* @return Search scope, which contains all project files, including files inside excluded directories.
26+
* The scope is intentionally not restricted by the JSON file type: it is used to query AppMap
27+
* metadata indexes whose input filters already match the specific file names, and JSON language
28+
* support is an optional platform module that may not classify {@code .json} files as JSON in every
29+
* runtime.
2730
*/
2831
public static @NotNull GlobalSearchScope appMapsWithExcluded(@NotNull Project project) {
29-
return GlobalSearchScope.getScopeRestrictedByFileTypes(projectFilesWithExcluded(project), JsonFileType.INSTANCE);
32+
return projectFilesWithExcluded(project);
3033
}
3134

3235
public static @NotNull GlobalSearchScope appMapConfigSearchScope(@NotNull Project project) {

plugin-core/src/main/java/appland/index/ClassMapTypeIndex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package appland.index;
22

33
import appland.files.AppMapFiles;
4-
import com.intellij.json.JsonFileType;
54
import com.intellij.openapi.diagnostic.Logger;
65
import com.intellij.openapi.project.DumbService;
76
import com.intellij.openapi.project.Project;
@@ -27,7 +26,8 @@
2726
*/
2827
public class ClassMapTypeIndex extends FileBasedIndexExtension<ClassMapItemType, List<ClassMapItem>> {
2928
private static final ID<ClassMapItemType, List<ClassMapItem>> INDEX_ID = ID.create("appmap.classMap");
30-
private static final FileBasedIndex.FileTypeSpecificInputFilter INPUT_FILTER = new NamedFileTypeFilter(JsonFileType.INSTANCE, ClassMapUtil.CLASS_MAP_FILE::equalsIgnoreCase);
29+
// Match by file name only, not by JSON file type (see AbstractAppMapMetadataFileIndex).
30+
private static final FileBasedIndex.InputFilter INPUT_FILTER = file -> ClassMapUtil.CLASS_MAP_FILE.equalsIgnoreCase(file.getName());
3131
private static final DataExternalizer<List<ClassMapItem>> DATA_EXTERNALIZER = new DataExternalizer<>() {
3232
@Override
3333
public void save(@NotNull DataOutput out, @NotNull List<ClassMapItem> values) throws IOException {

plugin-core/src/main/java/appland/index/IndexUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
final class IndexUtil {
2828
// base version for our indexes, increase when the data structures or the parsing logic change
29-
static final int BASE_VERSION = 66;
29+
// 67: input filters match by file name only, no longer gated on the JSON file type
30+
static final int BASE_VERSION = 67;
3031

3132
// filenames covered by our own indexes
3233
static final Set<String> indexedFilenames = Collections.unmodifiableSet(findIndexedFilenames());

plugin-core/src/main/java/appland/index/NamedFileTypeFilter.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)