From 64245cd331234ed2520cd2ecfba5388e4ba77425 Mon Sep 17 00:00:00 2001 From: Ilya Korennoy Date: Wed, 20 May 2026 16:44:52 +0400 Subject: [PATCH] IJPL-243276 Migrate ModulePackageIndex service GitOrigin-RevId: 01b14673e026e4697a153187390371b5f7d837b7 --- java/java-backend/resources/META-INF/JavaPlugin.xml | 4 ++-- .../roots/impl/ModulePackageIndexFactoryImpl.kt | 12 ++++++++++++ .../intellij/openapi/roots/ModulePackageIndex.java | 2 +- .../openapi/roots/ModulePackageIndexFactory.kt | 10 ++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt create mode 100644 java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt diff --git a/java/java-backend/resources/META-INF/JavaPlugin.xml b/java/java-backend/resources/META-INF/JavaPlugin.xml index e62023397a89..742001bf87a0 100644 --- a/java/java-backend/resources/META-INF/JavaPlugin.xml +++ b/java/java-backend/resources/META-INF/JavaPlugin.xml @@ -41,8 +41,8 @@ - + diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt b/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt new file mode 100644 index 000000000000..014c280f2f81 --- /dev/null +++ b/java/java-impl/src/com/intellij/openapi/roots/impl/ModulePackageIndexFactoryImpl.kt @@ -0,0 +1,12 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.roots.impl + +import com.intellij.openapi.module.Module +import com.intellij.openapi.roots.ModulePackageIndex +import com.intellij.openapi.roots.ModulePackageIndexFactory + +internal class ModulePackageIndexFactoryImpl: ModulePackageIndexFactory { + override fun getService(module: Module): ModulePackageIndex { + return ModulePackageIndexImpl(module) + } +} \ No newline at end of file diff --git a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java index 3e11fee5c316..87ccc16a7946 100644 --- a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java +++ b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndex.java @@ -5,6 +5,6 @@ import com.intellij.openapi.module.Module; public abstract class ModulePackageIndex extends PackageIndex { public static ModulePackageIndex getInstance(Module module) { - return module.getService(ModulePackageIndex.class); + return module.getProject().getService(ModulePackageIndexFactory.class).getService(module); } } diff --git a/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt new file mode 100644 index 000000000000..88879fb84fbd --- /dev/null +++ b/java/java-indexing-api/src/com/intellij/openapi/roots/ModulePackageIndexFactory.kt @@ -0,0 +1,10 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.openapi.roots + +import com.intellij.openapi.module.Module +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Internal +interface ModulePackageIndexFactory { + fun getService(module: Module): ModulePackageIndex +} \ No newline at end of file