From c5f79ef3b2148207046918295b41b3814dc2b224 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Sat, 18 Nov 2017 18:08:37 +0100 Subject: [PATCH] Allow adding custom global search scopes reference: OC-9143 Add 'File added to Xcode project' scope OC-3934 Add 'Files not added to Xcode project' scope to help find and add such files to the project. CPP-505 Better CMake files overview in the project pane --- .../search/PredefinedSearchScopeProvider.java | 16 +------------- .../psi/search/SearchScopeProvider.java | 16 ++++++++++++++ .../PredefinedSearchScopeProviderImpl.java | 21 ++++++------------- .../src/META-INF/LangExtensionPoints.xml | 1 + 4 files changed, 24 insertions(+), 30 deletions(-) create mode 100644 platform/analysis-impl/src/com/intellij/psi/search/SearchScopeProvider.java diff --git a/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java b/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java index b0a8e6e50446..1da60759d671 100644 --- a/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java +++ b/platform/analysis-impl/src/com/intellij/psi/search/PredefinedSearchScopeProvider.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2017 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.psi.search; import com.intellij.openapi.actionSystem.DataContext; diff --git a/platform/analysis-impl/src/com/intellij/psi/search/SearchScopeProvider.java b/platform/analysis-impl/src/com/intellij/psi/search/SearchScopeProvider.java new file mode 100644 index 000000000000..aedcbac7c864 --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/psi/search/SearchScopeProvider.java @@ -0,0 +1,16 @@ +// Copyright 2000-2017 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.psi.search; + +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.util.List; + +public interface SearchScopeProvider { + ExtensionPointName EP = ExtensionPointName.create("com.intellij.searchScopesProvider"); + + /** + * General project scopes are added after 'Project', 'Everything' but before 'Production', 'Tests', etc. + * @see PredefinedSearchScopeProvider + */ + List getGeneralProjectScopes(); +} diff --git a/platform/lang-impl/src/com/intellij/psi/search/PredefinedSearchScopeProviderImpl.java b/platform/lang-impl/src/com/intellij/psi/search/PredefinedSearchScopeProviderImpl.java index 4471768a6531..10c4db661566 100644 --- a/platform/lang-impl/src/com/intellij/psi/search/PredefinedSearchScopeProviderImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/search/PredefinedSearchScopeProviderImpl.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2017 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.psi.search; import com.intellij.ide.IdeBundle; @@ -27,6 +13,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.module.*; import com.intellij.openapi.project.Project; @@ -76,6 +63,10 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv result.add(GlobalSearchScope.allScope(project)); } + for (SearchScopeProvider each : Extensions.getExtensions(SearchScopeProvider.EP, project)) { + result.addAll(each.getGeneralProjectScopes()); + } + if (ModuleUtil.isSupportedRootType(project, JavaSourceRootType.TEST_SOURCE)) { result.add(GlobalSearchScopesCore.projectProductionScope(project)); result.add(GlobalSearchScopesCore.projectTestScope(project)); diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 41cee2c5356e..970491cb8ef0 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -258,6 +258,7 @@ +