Skip to content

Commit 7251778

Browse files
committed
use cache index keys where possible
1 parent 49a0fbe commit 7251778

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/util/DoctrineMetadataUtil.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
import com.intellij.psi.PsiFile;
1111
import com.intellij.psi.PsiManager;
1212
import com.intellij.psi.search.GlobalSearchScope;
13-
import com.intellij.psi.util.*;
13+
import com.intellij.psi.util.CachedValue;
14+
import com.intellij.psi.util.CachedValueProvider;
15+
import com.intellij.psi.util.CachedValuesManager;
16+
import com.intellij.psi.util.PsiTreeUtil;
1417
import com.intellij.psi.xml.XmlTag;
1518
import com.intellij.util.indexing.FileBasedIndex;
1619
import com.jetbrains.php.PhpIndex;
@@ -135,7 +138,7 @@ public static Collection<VirtualFile> findMetadataForRepositoryClass(final @NotN
135138
}
136139
}
137140

138-
return CachedValueProvider.Result.create(repositoryMap, PsiModificationTracker.MODIFICATION_COUNT);
141+
return CachedValueProvider.Result.create(repositoryMap, FileIndexCaches.getModificationTrackerForIndexId(project, DoctrineMetadataFileStubIndex.KEY));
139142
},
140143
false
141144
);

src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/cache/FileIndexCaches.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static public synchronized Set<String> getIndexKeysCache(@NotNull final Project
8989
}
9090

9191
@NotNull
92-
private static ModificationTracker getModificationTrackerForIndexId(@NotNull Project project, @NotNull final ID<?, ?> id) {
92+
public static ModificationTracker getModificationTrackerForIndexId(@NotNull Project project, @NotNull final ID<?, ?> id) {
9393
return () -> FileBasedIndex.getInstance().getIndexModificationStamp(id, project);
9494
}
9595
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/TwigUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import fr.adrienbrault.idea.symfony2plugin.extension.TwigNamespaceExtension;
4343
import fr.adrienbrault.idea.symfony2plugin.extension.TwigNamespaceExtensionParameter;
4444
import fr.adrienbrault.idea.symfony2plugin.stubs.SymfonyProcessors;
45+
import fr.adrienbrault.idea.symfony2plugin.stubs.cache.FileIndexCaches;
4546
import fr.adrienbrault.idea.symfony2plugin.stubs.dict.TemplateUsage;
4647
import fr.adrienbrault.idea.symfony2plugin.stubs.indexes.*;
4748
import fr.adrienbrault.idea.symfony2plugin.templating.TemplateLookupElement;
@@ -2822,7 +2823,7 @@ public static List<String> getIncludeTemplateUsageAsOrderedList(@NotNull Project
28222823
.limit(100)
28232824
.collect(Collectors.toList());
28242825

2825-
return CachedValueProvider.Result.create(collect, TimeSecondModificationTracker.TIMED_MODIFICATION_TRACKER_60);
2826+
return CachedValueProvider.Result.create(collect, FileIndexCaches.getModificationTrackerForIndexId(project, TwigIncludeStubIndex.KEY));
28262827
}, false);
28272828
}
28282829

@@ -2851,7 +2852,7 @@ public static List<String> getEmbedTemplateUsageAsOrderedList(@NotNull Project p
28512852
.limit(100)
28522853
.collect(Collectors.toList());
28532854

2854-
return CachedValueProvider.Result.create(collect, TimeSecondModificationTracker.TIMED_MODIFICATION_TRACKER_60);
2855+
return CachedValueProvider.Result.create(collect, FileIndexCaches.getModificationTrackerForIndexId(project, TwigIncludeStubIndex.KEY));
28552856
}, false);
28562857
}
28572858

@@ -2875,7 +2876,7 @@ public static List<String> getExtendsTemplateUsageAsOrderedList(@NotNull Project
28752876
.limit(100)
28762877
.collect(Collectors.toList());
28772878

2878-
return CachedValueProvider.Result.create(collect, TimeSecondModificationTracker.TIMED_MODIFICATION_TRACKER_60);
2879+
return CachedValueProvider.Result.create(collect, FileIndexCaches.getModificationTrackerForIndexId(project, TwigExtendsStubIndex.KEY));
28792880
}, false);
28802881
}
28812882

0 commit comments

Comments
 (0)