void () { if (mySerializersLoaded) return; //noinspection SynchronizeOnThis synchronized (this) { if (mySerializersLoaded) { return; } ProgressManager.getInstance().executeNonCancelableSection(() -> { instantiateElementTypesFromFields(); StubIndexEx.initExtensions(); }); registerSerializer(PsiFileStubImpl.TYPE); final List<StubFieldAccessor> lazySerializers = IStubElementType.loadRegisteredStubElementTypes(); final IElementType[] stubElementTypes = IElementType.enumerate(type -> type instanceof StubSerializer); Arrays.sort( stubElementTypes, comparing((IElementType type) -> type.getLanguage().getID()) //TODO RC: not sure .debugName is enough for stable sorting. Maybe use .getClass() instead? .thenComparing(type -> type.getDebugName()) ); for (IElementType type : stubElementTypes) { if (type instanceof StubFileElementType && StubFileElementType.DEFAULT_EXTERNAL_ID.equals(((StubFileElementType<?>)type).getExternalId())) { continue; } registerSerializer((StubSerializer<?>)type); } final List<StubFieldAccessor> sortedLazySerializers = lazySerializers.stream() //TODO RC: is .externalId enough for stable sorting? Seems like .myField is also important, // but it should also be dependent on .externalId... .sorted(comparing(sfa -> sfa.externalId)) .toList(); for (StubFieldAccessor lazySerializer : sortedLazySerializers) { registerSerializer(lazySerializer.externalId, lazySerializer); } mySerializersLoaded = true; } }