mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Move the NestingRulesProvider interface to public API
http://intellij-support.jetbrains.com/hc/en-us/community/posts/208573345-Is-it-OK-to-use-NestingTreeStructureProvider-
This commit is contained in:
@@ -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:<pre>
|
||||
* <extensions defaultExtensionNs="com.intellij">
|
||||
* <projectViewNestingRulesProvider implementation="my.package.MyRulesProvider"/>
|
||||
* </extensions></pre>
|
||||
*/
|
||||
public interface NestingRulesProvider {
|
||||
void addFileNestingRules(@NotNull Consumer consumer);
|
||||
|
||||
interface Consumer {
|
||||
void addNestingRule(@NotNull String parentFileSuffix, @NotNull String childFileSuffix);
|
||||
}
|
||||
}
|
||||
+3
-14
@@ -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
|
||||
* <code>com.intellij.projectViewNestingRulesProvider</code> extensions.
|
||||
*
|
||||
* @see NestingTreeStructureProvider.NestingRulesProvider
|
||||
* @see NestingRulesProvider
|
||||
*/
|
||||
public class NestingTreeStructureProvider implements TreeStructureProvider, DumbAware {
|
||||
|
||||
private static ExtensionPointName<NestingRulesProvider> EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.projectViewNestingRulesProvider");
|
||||
|
||||
public interface NestingRulesProvider {
|
||||
/**
|
||||
* Implementations should pass the longest possible file name suffix to the <code>consumer</code>.
|
||||
* 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<NestingRule> myNestingRules;
|
||||
|
||||
@@ -76,7 +65,7 @@ public class NestingTreeStructureProvider implements TreeStructureProvider, Dumb
|
||||
final MultiMap<String, String> childToParentSuffix = new MultiMap<>();
|
||||
final MultiMap<String, String> 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");
|
||||
|
||||
@@ -880,7 +880,7 @@
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="projectViewNestingRulesProvider"
|
||||
interface="com.intellij.ide.projectView.impl.NestingTreeStructureProvider$NestingRulesProvider"/>
|
||||
interface="com.intellij.ide.projectView.NestingRulesProvider"/>
|
||||
</extensionPoints>
|
||||
</idea-plugin>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user