<commit_before>/*
 * Copyright 2000-2009 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 org.jetbrains.idea.maven.utils;

import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.ArrayUtil;
import gnu.trove.THashSet;
import org.jetbrains.idea.maven.project.MavenProjectsManager;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class MavenGotoSettingsFileContibutor implements ChooseByNameContributor, DumbAware {
  public String[] getNames(Project project, boolean includeNonProjectItems) {
    Set<String> result = new THashSet<String>();
    for (VirtualFile each : getSettingsFiles(project)) {
      result.add(each.getName());
    }
    return ArrayUtil.toStringArray(result);
  }

  public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
    List<NavigationItem> result = new ArrayList<NavigationItem>();
    for (VirtualFile each : getSettingsFiles(project)) {
      if (each.getName().equals(name)) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(each);
        if (psiFile != null) result.add(psiFile);
      }
    }
    return result.toArray(new NavigationItem[result.size()]);
  }

  private List<VirtualFile> getSettingsFiles(Project project) {
    return MavenProjectsManager.getInstance(project).getGeneralSettings().getEffectiveSettingsFiles();
  }
}<commit_msg>Maven: do not show settings.xml in ctrl+shift+N in project scope (IDEA-52825)<commit_after>/*
 * Copyright 2000-2009 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 org.jetbrains.idea.maven.utils;

import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.ArrayUtil;
import gnu.trove.THashSet;
import org.jetbrains.idea.maven.project.MavenProjectsManager;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class MavenGotoSettingsFileContibutor implements ChooseByNameContributor, DumbAware {
  public String[] getNames(Project project, boolean includeNonProjectItems) {
    if (!includeNonProjectItems) return ArrayUtil.EMPTY_STRING_ARRAY;

    Set<String> result = new THashSet<String>();
    for (VirtualFile each : getSettingsFiles(project)) {
      result.add(each.getName());
    }
    return ArrayUtil.toStringArray(result);
  }

  public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
    if (!includeNonProjectItems) return NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY;

    List<NavigationItem> result = new ArrayList<NavigationItem>();
    for (VirtualFile each : getSettingsFiles(project)) {
      if (each.getName().equals(name)) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(each);
        if (psiFile != null) result.add(psiFile);
      }
    }
    return result.toArray(new NavigationItem[result.size()]);
  }

  private List<VirtualFile> getSettingsFiles(Project project) {
    return MavenProjectsManager.getInstance(project).getGeneralSettings().getEffectiveSettingsFiles();
  }
}
{'fraction_non_alphanumeric': 0.09732412602503238, 'fraction_numerical': 0.0062580923608113945, 'mean_word_length': 4.859671302149178, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6277487', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1309, 'n_words': 358}