diff --git a/platform/lang-api/src/com/intellij/ide/projectView/NestingRulesProvider.java b/platform/lang-api/src/com/intellij/ide/projectView/NestingRulesProvider.java new file mode 100644 index 000000000000..0d4f1a6b849b --- /dev/null +++ b/platform/lang-api/src/com/intellij/ide/projectView/NestingRulesProvider.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2016 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.ide.projectView; + +import org.jetbrains.annotations.NotNull; + +/** + * This interface is intended for a provider of nesting rules for the project view. + * Implementations of the {@link #addFileNestingRules} method should pass + * the longest possible file name suffix to the consumer. + * Usually this suffix starts with a dot. For example ".js"->".min.js". + * You can specify a custom provider in the {@code plugin.xml} file:
+ * <extensions defaultExtensionNs="com.intellij">
+ *     <projectViewNestingRulesProvider implementation="my.package.MyRulesProvider"/>
+ * </extensions>
+ */ +public interface NestingRulesProvider { + void addFileNestingRules(@NotNull Consumer consumer); + + interface Consumer { + void addNestingRule(@NotNull String parentFileSuffix, @NotNull String childFileSuffix); + } +} diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/NestingTreeStructureProvider.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/NestingTreeStructureProvider.java index 7bb33ba2268d..6cd0ffcb7ba3 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/NestingTreeStructureProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/NestingTreeStructureProvider.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.projectView.impl; +import com.intellij.ide.projectView.NestingRulesProvider; import com.intellij.ide.projectView.TreeStructureProvider; import com.intellij.ide.projectView.ViewSettings; import com.intellij.ide.projectView.impl.nodes.NestingTreeNode; @@ -46,25 +47,13 @@ import java.util.*; * Nesting logic is based on file names only. Rules about files that should be nested are provided by * com.intellij.projectViewNestingRulesProvider extensions. * - * @see NestingTreeStructureProvider.NestingRulesProvider + * @see NestingRulesProvider */ public class NestingTreeStructureProvider implements TreeStructureProvider, DumbAware { private static ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.projectViewNestingRulesProvider"); - public interface NestingRulesProvider { - /** - * Implementations should pass the longest possible file name suffix to the consumer. - * Usually it starts with dot. For example ".js"->".min.js". - */ - void addFileNestingRules(@NotNull final NestingRulesConsumer consumer); - } - - public interface NestingRulesConsumer { - void addNestingRule(@NotNull final String parentFileSuffix, @NotNull final String childFileSuffix); - } - private static final Logger LOG = Logger.getInstance(NestingTreeStructureProvider.class); private Set myNestingRules; @@ -76,7 +65,7 @@ public class NestingTreeStructureProvider implements TreeStructureProvider, Dumb final MultiMap childToParentSuffix = new MultiMap<>(); final MultiMap parentToChildSuffix = new MultiMap<>(); - final NestingRulesConsumer consumer = new NestingRulesConsumer() { + final NestingRulesProvider.Consumer consumer = new NestingRulesProvider.Consumer() { @Override public void addNestingRule(@NotNull final String parentFileSuffix, @NotNull final String childFileSuffix) { LOG.assertTrue(!parentFileSuffix.isEmpty() && !childFileSuffix.isEmpty(), "file suffix must not be empty"); diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 62eea46b0605..00d46baa9cfa 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -880,7 +880,7 @@ + interface="com.intellij.ide.projectView.NestingRulesProvider"/>