mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Divide searched directories per project (IDEA-74620)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.find;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FindInProjectSettings {
|
||||
|
||||
static FindInProjectSettings getInstance(Project project) {
|
||||
return ServiceManager.getService(project, FindInProjectSettings.class);
|
||||
}
|
||||
|
||||
void addStringToFind(@NotNull String s);
|
||||
|
||||
void addStringToReplace(@NotNull String s);
|
||||
|
||||
void addDirectory(@NotNull String s);
|
||||
|
||||
@NotNull
|
||||
String[] getRecentFindStrings();
|
||||
|
||||
@NotNull
|
||||
String[] getRecentReplaceStrings();
|
||||
|
||||
@NotNull
|
||||
List<String> getRecentDirectories();
|
||||
}
|
||||
@@ -79,15 +79,33 @@ public abstract class FindSettings{
|
||||
|
||||
public abstract void setLocalRegularExpressions(boolean regularExpressions);
|
||||
|
||||
/**
|
||||
* FindInProjectSettings.addDirectory
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addStringToFind(@NotNull String s);
|
||||
|
||||
/**
|
||||
* Use FindInProjectSettings.addDirectory
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addStringToReplace(@NotNull String s);
|
||||
|
||||
/**
|
||||
* Use FindInProjectSettings.addDirectory
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void addDirectory(@NotNull String s);
|
||||
|
||||
/**
|
||||
* FindInProjectSettings.addDirectory
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String[] getRecentFindStrings();
|
||||
|
||||
/**
|
||||
* FindInProjectSettings.addDirectory
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String[] getRecentReplaceStrings();
|
||||
|
||||
@@ -101,6 +119,10 @@ public abstract class FindSettings{
|
||||
@NotNull
|
||||
public abstract String[] getRecentFileMasks();
|
||||
|
||||
/**
|
||||
* Use FindInProjectSettings.getRecentDirectories
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public abstract List<String> getRecentDirectories();
|
||||
|
||||
|
||||
@@ -205,8 +205,9 @@ public class FindUtil {
|
||||
return;
|
||||
}
|
||||
FindManager findManager = FindManager.getInstance(project);
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(project);
|
||||
String s = text.subSequence(start, end).toString();
|
||||
FindSettings.getInstance().addStringToFind(s);
|
||||
findInProjectSettings.addStringToFind(s);
|
||||
findManager.getFindInFileModel().setStringToFind(s);
|
||||
findManager.setFindWasPerformed();
|
||||
findManager.clearFindingNextUsageInFile();
|
||||
|
||||
@@ -411,13 +411,14 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat
|
||||
public void addTextToRecent(@NotNull JTextComponent textField) {
|
||||
final String text = textField.getText();
|
||||
if (text.length() > 0) {
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
|
||||
if (textField == mySearchTextComponent) {
|
||||
FindSettings.getInstance().addStringToFind(text);
|
||||
findInProjectSettings.addStringToFind(text);
|
||||
if (mySearchFieldWrapper.getTargetComponent() instanceof SearchTextField) {
|
||||
((SearchTextField)mySearchFieldWrapper.getTargetComponent()).addCurrentTextToHistory();
|
||||
}
|
||||
} else {
|
||||
FindSettings.getInstance().addStringToReplace(text);
|
||||
findInProjectSettings.addStringToReplace(text);
|
||||
if (myReplaceFieldWrapper.getTargetComponent() instanceof SearchTextField) {
|
||||
((SearchTextField)myReplaceFieldWrapper.getTargetComponent()).addCurrentTextToHistory();
|
||||
}
|
||||
@@ -454,8 +455,10 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat
|
||||
textComponent.setOpaque(false);
|
||||
}
|
||||
searchTextField.setHistorySize(20);
|
||||
searchTextField.setHistory(ContainerUtil.reverse(Arrays.asList(search ? FindSettings.getInstance().getRecentFindStrings()
|
||||
: FindSettings.getInstance().getRecentReplaceStrings())));
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
|
||||
|
||||
searchTextField.setHistory(ContainerUtil.reverse(Arrays.asList(search ? findInProjectSettings.getRecentFindStrings()
|
||||
: findInProjectSettings.getRecentReplaceStrings())));
|
||||
textComponent.registerKeyboardAction(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
|
||||
@@ -161,8 +161,9 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("find.recent.search");
|
||||
String[] recent = myShowSearchHistory ? FindSettings.getInstance().getRecentFindStrings()
|
||||
: FindSettings.getInstance().getRecentReplaceStrings();
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(e.getProject());
|
||||
String[] recent = myShowSearchHistory ? findInProjectSettings.getRecentFindStrings()
|
||||
: findInProjectSettings.getRecentReplaceStrings();
|
||||
String title = "Recent " + (myShowSearchHistory ? "Searches" : "Replaces");
|
||||
JBList historyList = new JBList((Object[])ArrayUtil.reverseArray(recent));
|
||||
Utils.showCompletionPopup(myTextArea, historyList, title, myTextArea, null);
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package com.intellij.find.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.find.FindBundle;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.FindModel;
|
||||
import com.intellij.find.FindSettings;
|
||||
import com.intellij.find.*;
|
||||
import com.intellij.find.actions.ShowUsagesAction;
|
||||
import com.intellij.ide.util.scopeChooser.ScopeChooserCombo;
|
||||
import com.intellij.ide.util.scopeChooser.ScopeDescriptor;
|
||||
@@ -1566,7 +1563,7 @@ public class FindDialog extends DialogWrapper {
|
||||
|
||||
if (myModel.isMultipleFiles()) {
|
||||
final String dirName = myModel.getDirectoryName();
|
||||
setDirectories(FindSettings.getInstance().getRecentDirectories(), dirName);
|
||||
setDirectories(FindInProjectSettings.getInstance(myProject).getRecentDirectories(), dirName);
|
||||
|
||||
if (!StringUtil.isEmptyOrSpaces(dirName)) {
|
||||
VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(dirName);
|
||||
@@ -1653,10 +1650,11 @@ public class FindDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
setStringsToComboBox(FindSettings.getInstance().getRecentFindStrings(), myInputComboBox, myModel.getStringToFind());
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
|
||||
setStringsToComboBox(findInProjectSettings.getRecentFindStrings(), myInputComboBox, myModel.getStringToFind());
|
||||
if (myModel.isReplaceState()){
|
||||
myCbPreserveCase.setSelected(myModel.isPreserveCase());
|
||||
setStringsToComboBox(FindSettings.getInstance().getRecentReplaceStrings(), myReplaceComboBox, myModel.getStringToReplace());
|
||||
setStringsToComboBox(findInProjectSettings.getRecentReplaceStrings(), myReplaceComboBox, myModel.getStringToReplace());
|
||||
}
|
||||
updateControls();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.find.impl;
|
||||
|
||||
import com.intellij.find.FindInProjectSettings;
|
||||
import com.intellij.find.FindSettings;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@State(
|
||||
name = "FindInProjectRecents",
|
||||
storages = {@Storage(value = StoragePathMacros.WORKSPACE_FILE, roamingType = RoamingType.DISABLED)}
|
||||
)
|
||||
final class FindInProjectRecents extends FindInProjectSettingsBase implements FindInProjectSettings {
|
||||
public static FindInProjectSettings getInstance(Project project) {
|
||||
return ServiceManager.getService(project, FindInProjectSettings.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getRecentDirectories() {
|
||||
return ContainerUtil.concat(FindSettings.getInstance().getRecentDirectories(), super.getRecentDirectories());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getRecentFindStrings(){
|
||||
return ArrayUtil.mergeArrays(FindSettings.getInstance().getRecentFindStrings(), super.getRecentFindStrings());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getRecentReplaceStrings(){
|
||||
return ArrayUtil.mergeArrays(FindSettings.getInstance().getRecentReplaceStrings(), super.getRecentReplaceStrings());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.find.impl;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class FindInProjectSettingsBase implements PersistentStateComponent<FindInProjectSettingsBase> {
|
||||
private static final int MAX_RECENT_SIZE = 30;
|
||||
|
||||
@Tag("findStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "find", elementValueAttribute = "")
|
||||
public List<String> findStrings = new ArrayList<String>();
|
||||
|
||||
@Tag("replaceStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "replace", elementValueAttribute = "")
|
||||
public List<String> replaceStrings = new ArrayList<String>();
|
||||
|
||||
@Tag("dirStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "dir", elementValueAttribute = "")
|
||||
public List<String> dirStrings = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void loadState(FindInProjectSettingsBase state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
//Avoid duplicates
|
||||
LinkedHashSet<String> tmp = new LinkedHashSet<>(findStrings);
|
||||
findStrings.clear();
|
||||
findStrings.addAll(tmp);
|
||||
|
||||
tmp.clear();
|
||||
tmp.addAll(replaceStrings);
|
||||
replaceStrings.clear();
|
||||
replaceStrings.addAll(tmp);
|
||||
|
||||
tmp.clear();
|
||||
tmp.addAll(dirStrings);
|
||||
dirStrings.clear();
|
||||
dirStrings.addAll(tmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FindInProjectSettingsBase getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void addDirectory(@NotNull String s) {
|
||||
if (s.isEmpty()){
|
||||
return;
|
||||
}
|
||||
addRecentStringToList(s, dirStrings);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getRecentDirectories() {
|
||||
return new ArrayList<String>(dirStrings);
|
||||
}
|
||||
|
||||
public void addStringToFind(@NotNull String s){
|
||||
if (s.indexOf('\r') >= 0 || s.indexOf('\n') >= 0){
|
||||
return;
|
||||
}
|
||||
addRecentStringToList(s, findStrings);
|
||||
}
|
||||
|
||||
public void addStringToReplace(@NotNull String s) {
|
||||
if (s.indexOf('\r') >= 0 || s.indexOf('\n') >= 0){
|
||||
return;
|
||||
}
|
||||
addRecentStringToList(s, replaceStrings);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getRecentFindStrings(){
|
||||
return ArrayUtil.toStringArray(findStrings);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getRecentReplaceStrings(){
|
||||
return ArrayUtil.toStringArray(replaceStrings);
|
||||
}
|
||||
|
||||
|
||||
static void addRecentStringToList(@NotNull String str, @NotNull List<String> list) {
|
||||
if (list.contains(str)) {
|
||||
list.remove(str);
|
||||
}
|
||||
list.add(str);
|
||||
while (list.size() > MAX_RECENT_SIZE) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,17 +184,19 @@ public class FindManagerImpl extends FindManager {
|
||||
|
||||
void changeGlobalSettings(FindModel findModel) {
|
||||
String stringToFind = findModel.getStringToFind();
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
|
||||
|
||||
if (!StringUtil.isEmpty(stringToFind)) {
|
||||
FindSettings.getInstance().addStringToFind(stringToFind);
|
||||
findInProjectSettings.addStringToFind(stringToFind);
|
||||
}
|
||||
if (!findModel.isMultipleFiles()) {
|
||||
setFindWasPerformed();
|
||||
}
|
||||
if (findModel.isReplaceState()) {
|
||||
FindSettings.getInstance().addStringToReplace(findModel.getStringToReplace());
|
||||
findInProjectSettings.addStringToReplace(findModel.getStringToReplace());
|
||||
}
|
||||
if (findModel.isMultipleFiles() && !findModel.isProjectScope() && findModel.getDirectoryName() != null) {
|
||||
FindSettings.getInstance().addDirectory(findModel.getDirectoryName());
|
||||
findInProjectSettings.addDirectory(findModel.getDirectoryName());
|
||||
myFindInProjectModel.setWithSubdirectories(findModel.isWithSubdirectories());
|
||||
}
|
||||
FindSettings.getInstance().setShowResultsInSeparateView(findModel.isOpenInNewTab());
|
||||
|
||||
@@ -621,7 +621,7 @@ public class FindPopupPanel extends JBPanel {
|
||||
}
|
||||
mySelectedScope = getScope(myModel);
|
||||
final String dirName = myModel.getDirectoryName();
|
||||
setDirectories(FindSettings.getInstance().getRecentDirectories(), dirName);
|
||||
setDirectories(FindInProjectSettings.getInstance(myProject).getRecentDirectories(), dirName);
|
||||
|
||||
if (!StringUtil.isEmptyOrSpaces(dirName)) {
|
||||
VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(dirName);
|
||||
@@ -646,14 +646,18 @@ public class FindPopupPanel extends JBPanel {
|
||||
myFileMaskField.setEnabled(isThereFileFilter);
|
||||
updateScopeDetailsPanel();
|
||||
String toSearch = myModel.getStringToFind();
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
|
||||
|
||||
if (StringUtil.isEmpty(toSearch)) {
|
||||
String[] history = FindSettings.getInstance().getRecentFindStrings();
|
||||
String[] history = findInProjectSettings.getRecentFindStrings();
|
||||
toSearch = history.length > 0 ? history[history.length - 1] : "";
|
||||
}
|
||||
|
||||
mySearchComponent.setText(toSearch);
|
||||
String toReplace = myModel.getStringToReplace();
|
||||
|
||||
if (StringUtil.isEmpty(toReplace)) {
|
||||
String[] history = FindSettings.getInstance().getRecentReplaceStrings();
|
||||
String[] history = findInProjectSettings.getRecentReplaceStrings();
|
||||
toReplace = history.length > 0 ? history[history.length - 1] : "";
|
||||
}
|
||||
myReplaceComponent.setText(toReplace);
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
@State(
|
||||
@@ -49,8 +48,6 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
@NonNls private static final String FIND_SCOPE_GLOBAL = "global";
|
||||
@NonNls private static final String FIND_SCOPE_SELECTED = "selected";
|
||||
private static final String DEFAULT_SEARCH_SCOPE = FindBundle.message("find.scope.all.project.classes");
|
||||
|
||||
private static final int MAX_RECENT_SIZE = 30;
|
||||
|
||||
public FindSettingsImpl() {
|
||||
recentFileMasks.add("*.properties");
|
||||
@@ -283,50 +280,31 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
model.setCustomScopeName(FIND_SCOPE);
|
||||
}
|
||||
|
||||
private static void addStringToList(@NotNull String str, @NotNull List<String> list, int maxSize) {
|
||||
if (list.contains(str)) {
|
||||
list.remove(str);
|
||||
}
|
||||
list.add(str);
|
||||
while (list.size() > maxSize) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStringToFind(@NotNull String s){
|
||||
if (s.indexOf('\r') >= 0 || s.indexOf('\n') >= 0){
|
||||
return;
|
||||
}
|
||||
addStringToList(s, FindRecents.getInstance().findStrings, MAX_RECENT_SIZE);
|
||||
FindRecents.getInstance().addStringToFind(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStringToReplace(@NotNull String s) {
|
||||
if (s.indexOf('\r') >= 0 || s.indexOf('\n') >= 0){
|
||||
return;
|
||||
}
|
||||
addStringToList(s, FindRecents.getInstance().replaceStrings, MAX_RECENT_SIZE);
|
||||
FindRecents.getInstance().addStringToReplace(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDirectory(@NotNull String s) {
|
||||
if (s.isEmpty()){
|
||||
return;
|
||||
}
|
||||
addStringToList(s, FindRecents.getInstance().dirStrings, MAX_RECENT_SIZE);
|
||||
FindRecents.getInstance().addDirectory(s);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getRecentFindStrings(){
|
||||
return ArrayUtil.toStringArray(FindRecents.getInstance().findStrings);
|
||||
return FindRecents.getInstance().getRecentFindStrings();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getRecentReplaceStrings(){
|
||||
return ArrayUtil.toStringArray(FindRecents.getInstance().replaceStrings);
|
||||
return FindRecents.getInstance().getRecentReplaceStrings();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -338,7 +316,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getRecentDirectories(){
|
||||
return new ArrayList<>(FindRecents.getInstance().dirStrings);
|
||||
return FindRecents.getInstance().getRecentDirectories();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -351,7 +329,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
public void setFileMask(String _fileMask) {
|
||||
FILE_MASK = _fileMask;
|
||||
if (!StringUtil.isEmptyOrSpaces(_fileMask)) {
|
||||
addStringToList(_fileMask, recentFileMasks, MAX_RECENT_SIZE);
|
||||
FindInProjectSettingsBase.addRecentStringToList(_fileMask, recentFileMasks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,48 +407,9 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
name = "FindRecents",
|
||||
storages = {@Storage(value = "find.recents.xml", roamingType = RoamingType.DISABLED)}
|
||||
)
|
||||
static final class FindRecents implements PersistentStateComponent<FindRecents> {
|
||||
static final class FindRecents extends FindInProjectSettingsBase {
|
||||
public static FindRecents getInstance() {
|
||||
return ServiceManager.getService(FindRecents.class);
|
||||
}
|
||||
|
||||
@Tag("findStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "find", elementValueAttribute = "")
|
||||
public List<String> findStrings = new ArrayList<>();
|
||||
|
||||
@Tag("replaceStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "replace", elementValueAttribute = "")
|
||||
public List<String> replaceStrings = new ArrayList<>();
|
||||
|
||||
@Tag("dirStrings")
|
||||
@Property(surroundWithTag = false)
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "dir", elementValueAttribute = "")
|
||||
public List<String> dirStrings = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void loadState(FindRecents state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
//Avoid duplicates
|
||||
LinkedHashSet<String> tmp = new LinkedHashSet<>(findStrings);
|
||||
findStrings.clear();
|
||||
findStrings.addAll(tmp);
|
||||
|
||||
tmp.clear();
|
||||
tmp.addAll(replaceStrings);
|
||||
replaceStrings.clear();
|
||||
replaceStrings.addAll(tmp);
|
||||
|
||||
tmp.clear();
|
||||
tmp.addAll(dirStrings);
|
||||
dirStrings.clear();
|
||||
dirStrings.addAll(tmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FindRecents getState() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
<applicationService serviceInterface="com.intellij.find.FindSettings"
|
||||
serviceImplementation="com.intellij.find.impl.FindSettingsImpl"/>
|
||||
<applicationService serviceImplementation="com.intellij.find.impl.FindSettingsImpl$FindRecents"/>
|
||||
<projectService serviceInterface="com.intellij.find.FindInProjectSettings" serviceImplementation="com.intellij.find.impl.FindInProjectRecents"/>
|
||||
|
||||
<applicationService serviceImplementation="com.intellij.codeInsight.CodeInsightSettings"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user