diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 9e769eafa196..c15167fc131c 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -243,7 +243,7 @@ serviceImplementation="com.intellij.psi.impl.PsiCachedValuesFactory"/> - data = DirectoryStorageUtil.loadFrom(libraries, PathMacroManager.getInstance(project)); - Element libraryTable = DefaultStateSerializerKt.deserializeState(DirectoryStorageUtil.getCompositeState(data, new ProjectLibraryTable.LibraryStateSplitter()), Element.class, null); + Element libraryTable = DefaultStateSerializerKt.deserializeState(DirectoryStorageUtil.getCompositeState(data, new LibraryStateSplitter()), Element.class, null); ((LibraryTableBase) ProjectLibraryTable.getInstance(project)).loadState(libraryTable); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index 10618afdccc1..75e8e26bed1e 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -246,7 +246,7 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi @NotNull private VirtualFilePointerListener getListener() { - Project project = myLibraryTable instanceof ProjectLibraryTableInterface ? ((ProjectLibraryTableInterface)myLibraryTable).getProject() : null; + Project project = myLibraryTable instanceof ProjectLibraryTable ? ((ProjectLibraryTable)myLibraryTable).getProject() : null; return myRootModel != null ? ((RootModelImpl)myRootModel).getRootsChangedListener() : project != null ? ProjectRootManagerImpl .getInstanceImpl(project).getRootsValidityChangedListener() : ProjectJdkImpl.getGlobalVirtualFilePointerListener(); } @@ -371,7 +371,7 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi Module module = getModule(); Project project; if (module == null) { - project = myLibraryTable instanceof ProjectLibraryTableInterface ? ((ProjectLibraryTableInterface)myLibraryTable).getProject() : null; + project = myLibraryTable instanceof ProjectLibraryTable ? ((ProjectLibraryTable)myLibraryTable).getProject() : null; } else { project = module.getProject(); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryStateSplitter.kt b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryStateSplitter.kt new file mode 100644 index 000000000000..9afcf5322743 --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryStateSplitter.kt @@ -0,0 +1,11 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.openapi.roots.impl.libraries + +import com.intellij.openapi.components.StateSplitterEx +import com.intellij.openapi.util.Pair +import org.jdom.Element + +class LibraryStateSplitter : StateSplitterEx() { + override fun splitState(state: Element): MutableList> = splitState( + state, LibraryImpl.LIBRARY_NAME_ATTR) +} \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.java new file mode 100644 index 000000000000..07e5ab681a11 --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.java @@ -0,0 +1,14 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.openapi.roots.impl.libraries; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.libraries.LibraryTable; + +public interface ProjectLibraryTable extends LibraryTable { + static LibraryTable getInstance(Project project) { + return ServiceManager.getService(project, ProjectLibraryTable.class); + } + + Project getProject(); +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.kt b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.kt deleted file mode 100644 index 7d130cda7e38..000000000000 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTable.kt +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.openapi.roots.impl.libraries - -import com.intellij.openapi.components.StateSplitterEx -import com.intellij.openapi.components.service -import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.libraries.LibraryTable -import com.intellij.openapi.util.Pair -import org.jdom.Element - -class ProjectLibraryTable private constructor() { - companion object { - @JvmStatic - fun getInstance(project: Project): LibraryTable = project.service() - } - - class LibraryStateSplitter : StateSplitterEx() { - override fun splitState(state: Element): MutableList> = StateSplitterEx.splitState(state, LibraryImpl.LIBRARY_NAME_ATTR) - } -} - -interface ProjectLibraryTableInterface: LibraryTable { - val project: Project -} \ No newline at end of file diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTableImpl.kt b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTableImpl.kt index 7352753cbad6..076816f4469e 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTableImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/ProjectLibraryTableImpl.kt @@ -8,10 +8,13 @@ import com.intellij.openapi.project.ProjectBundle import com.intellij.openapi.roots.libraries.LibraryTablePresentation import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar -@State(name = "libraryTable", storages = [(Storage(value = "libraries", stateSplitter = ProjectLibraryTable.LibraryStateSplitter::class))]) -class ProjectLibraryTableImpl(override val project: Project) : LibraryTableBase(), ProjectLibraryTableInterface { +@State(name = "libraryTable", storages = [(Storage(value = "libraries", stateSplitter = LibraryStateSplitter::class))]) +class ProjectLibraryTableImpl(val parentProject: Project) : LibraryTableBase(), ProjectLibraryTable { + override fun getProject(): Project = parentProject + override fun getTableLevel(): String = LibraryTablesRegistrar.PROJECT_LEVEL override fun getPresentation(): LibraryTablePresentation = PROJECT_LIBRARY_TABLE_PRESENTATION + } private val PROJECT_LIBRARY_TABLE_PRESENTATION = object : LibraryTablePresentation() {