From e7dec055cfdceac3b11bc5ee8acc1e7a281eaae2 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 9 Jun 2017 11:53:49 +0200 Subject: [PATCH] project model: ModuleDescription class moved to core-api module This is needed to allow referencing ModuleDescription from GlobalSearchScope. The classes were converted to Java because we cannot use Kotlin in core-api module which is used inside the Kotlin compiler. Properties were converted to functions in implementations because Kotlin doesn't allow overriding Java getters with properties (KT-6653). --- .../module/LoadedModuleDescription.java | 28 +++++++++++++++ .../openapi/module/ModuleDescription.java} | 33 ++++++++---------- .../module/UnloadedModuleDescription.java | 34 +++++++++++++++++++ .../impl/LoadedModuleDescriptionImpl.kt | 10 +++--- .../impl/UnloadedModuleDescriptionImpl.kt | 14 ++++---- 5 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 platform/core-api/src/com/intellij/openapi/module/LoadedModuleDescription.java rename platform/{projectModel-api/src/com/intellij/openapi/module/ModuleDescription.kt => core-api/src/com/intellij/openapi/module/ModuleDescription.java} (57%) create mode 100644 platform/core-api/src/com/intellij/openapi/module/UnloadedModuleDescription.java diff --git a/platform/core-api/src/com/intellij/openapi/module/LoadedModuleDescription.java b/platform/core-api/src/com/intellij/openapi/module/LoadedModuleDescription.java new file mode 100644 index 000000000000..4ca143362976 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/module/LoadedModuleDescription.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.module; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * @author nik + */ +@ApiStatus.Experimental +public interface LoadedModuleDescription extends ModuleDescription { + @NotNull + Module getModule(); +} diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleDescription.kt b/platform/core-api/src/com/intellij/openapi/module/ModuleDescription.java similarity index 57% rename from platform/projectModel-api/src/com/intellij/openapi/module/ModuleDescription.kt rename to platform/core-api/src/com/intellij/openapi/module/ModuleDescription.java index d2da9b365720..95c743fccf91 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleDescription.kt +++ b/platform/core-api/src/com/intellij/openapi/module/ModuleDescription.java @@ -13,34 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.module +package com.intellij.openapi.module; -import com.intellij.openapi.vfs.pointers.VirtualFilePointer -import org.jetbrains.annotations.ApiStatus +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; /** * Represents a description of a module which may be either loaded into the project or unloaded. Use this class only if you need to process - * all modules including unloaded, in other cases [Module] should be used instead. - * @see [ModuleManager.getUnloadedModuleDescriptions] + * all modules including unloaded, in other cases {@link Module} should be used instead. + * + * @see UnloadedModuleDescription + * @see LoadedModuleDescription * @author nik */ @ApiStatus.Experimental -interface ModuleDescription { - val name: String +public interface ModuleDescription { + @NotNull + String getName(); /** * Names of the modules on which the current module depend. */ - val dependencyModuleNames: List + @NotNull + List getDependencyModuleNames(); } - -@ApiStatus.Experimental -interface UnloadedModuleDescription : ModuleDescription { - val contentRoots: List - val groupPath: List -} - -@ApiStatus.Experimental -interface LoadedModuleDescription : ModuleDescription { - val module: Module -} \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/openapi/module/UnloadedModuleDescription.java b/platform/core-api/src/com/intellij/openapi/module/UnloadedModuleDescription.java new file mode 100644 index 000000000000..1d4be72a6015 --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/module/UnloadedModuleDescription.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.module; + +import com.intellij.openapi.vfs.pointers.VirtualFilePointer; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author nik + */ +@ApiStatus.Experimental +public interface UnloadedModuleDescription extends ModuleDescription { + @NotNull + List getContentRoots(); + + @NotNull + List getGroupPath(); +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/LoadedModuleDescriptionImpl.kt b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/LoadedModuleDescriptionImpl.kt index 16a920338248..fb1e0ed2609c 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/LoadedModuleDescriptionImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/LoadedModuleDescriptionImpl.kt @@ -22,10 +22,10 @@ import com.intellij.openapi.roots.ModuleRootManager /** * @author nik */ -class LoadedModuleDescriptionImpl(override val module: Module): LoadedModuleDescription { - override val name: String - get() = module.name +class LoadedModuleDescriptionImpl(private val module: Module): LoadedModuleDescription { + override fun getModule() = module - override val dependencyModuleNames: List - get() = ModuleRootManager.getInstance(module).dependencyModuleNames.asList() + override fun getName() = module.name + + override fun getDependencyModuleNames() = ModuleRootManager.getInstance(module).dependencyModuleNames.asList() } \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/UnloadedModuleDescriptionImpl.kt b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/UnloadedModuleDescriptionImpl.kt index 6256e1999341..9e19ca16f992 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/UnloadedModuleDescriptionImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/UnloadedModuleDescriptionImpl.kt @@ -30,13 +30,15 @@ import java.nio.file.Paths * @author nik */ class UnloadedModuleDescriptionImpl(val modulePath: ModulePath, - override val dependencyModuleNames: List, - override val contentRoots: List) : UnloadedModuleDescription { - override val groupPath: List - get() = modulePath.group?.split(ModuleManagerImpl.MODULE_GROUP_SEPARATOR) ?: emptyList() + private val dependencyModuleNames: List, + private val contentRoots: List) : UnloadedModuleDescription { + override fun getGroupPath() = modulePath.group?.split(ModuleManagerImpl.MODULE_GROUP_SEPARATOR) ?: emptyList() - override val name: String - get() = modulePath.moduleName + override fun getName() = modulePath.moduleName + + override fun getContentRoots() = contentRoots + + override fun getDependencyModuleNames() = dependencyModuleNames companion object { @JvmStatic -- 2.23.3