@Override @Nullable public ObjectStubTree readFromVFile(Project project, final VirtualFile vFile) { if (DumbService.getInstance(project).isDumb()) { return null; } final int id = Math.abs(FileBasedIndex.getFileId(vFile)); if (id <= 0) { return null; } boolean wasIndexedAlready = FileBasedIndexImpl.isFileIndexed(vFile, StubUpdatingIndex.INDEX_ID); final List<SerializedStubTree> datas = FileBasedIndex.getInstance() .getValues(StubUpdatingIndex.INDEX_ID, id, GlobalSearchScope.fileScope(project, vFile)); final int size = datas.size(); if (size == 1) { Stub stub; try { stub = datas.get(0).getStub(false); } catch (SerializerNotFoundException e) { return processError( vFile, "No stub serializer: " + vFile.getPresentableUrl() + ": " + e.getMessage(), e); } ObjectStubTree tree = stub instanceof PsiFileStub ? new StubTree((PsiFileStub) stub) : new ObjectStubTree((ObjectStubBase) stub, true); tree.setDebugInfo( "created from index: " + StubUpdatingIndex.getIndexingStampInfo(vFile) + ", wasIndexedAlready=" + wasIndexedAlready + ", queried at " + vFile.getTimeStamp()); return tree; } else if (size != 0) { return processError( vFile, "Twin stubs: " + vFile.getPresentableUrl() + " has " + size + " stub versions. Should only have one. id=" + id, null); } return null; }
public static void forceReindex() { ID<?, ?>[] indexIds = new ID<?, ?>[] { ServicesDefinitionStubIndex.KEY, AnnotationRoutesStubIndex.KEY, ContainerParameterStubIndex.KEY, ServicesTagStubIndex.KEY, TwigExtendsStubIndex.KEY, TwigIncludeStubIndex.KEY, TwigMacroFromStubIndex.KEY, TwigMacroFunctionStubIndex.KEY, RoutesStubIndex.KEY, YamlTranslationStubIndex.KEY, DoctrineMetadataFileStubIndex.KEY }; for (ID<?, ?> id : indexIds) { FileBasedIndexImpl.getInstance().requestRebuild(id); FileBasedIndexImpl.getInstance().scheduleRebuild(id, new Throwable()); } }