Java 类com.intellij.psi.search.scope.packageSet.NamedScopesHolder 实例源码

项目:intellij-ce-playground    文件:HighlightNamesUtil.java   
private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
  PsiFile file = element.getContainingFile();
  if (file == null) return null;
  TextAttributes result = null;
  DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject());
  List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes();
  for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
    final NamedScope namedScope = scope.getFirst();
    final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName());
    final TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
    if (attributes == null || attributes.isEmpty()) {
      continue;
    }
    final PackageSet packageSet = namedScope.getValue();
    if (packageSet != null && packageSet.contains(file, scope.getSecond())) {
      result = TextAttributes.merge(attributes, result);
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:GroupTreeNode.java   
private void rebuildFiles(boolean groupByPackages,
                          @Nullable Pair<PackageSetBase, NamedScopesHolder> filter,
                          boolean showOnlyFilteredItems) {
  for (int i = getChildCount() - 1; i >= 0; i--) {
    final TreeNode node = getChildAt(i);
    if (node instanceof Disposable) {
      Disposer.dispose((Disposable)node);
    }
  }
  removeAllChildren();

  if (groupByPackages) {
    buildPackages();
    acceptFilter(filter, showOnlyFilteredItems);
  }
  else {
    buildFiles(filter, showOnlyFilteredItems);
  }

  setTreeModel(myTreeModel);

  if (myTreeModel != null) {
    myTreeModel.nodeStructureChanged(this);
  }
}
项目:intellij-ce-playground    文件:FileTreeNode.java   
@Override
protected boolean acceptFilter(Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  try {
    VirtualFilePointer filePointer = getFilePointer();
    if (!filePointer.isValid()) {
      return false;
    }
    VirtualFile file = filePointer.getFile();
    if (file != null && file.isValid() && filter.first.contains(file, getProject(), filter.second)) {
      applyFilter(true);
      return true;
    }
  }
  catch (Throwable e) {
    // TODO: catch and ignore exceptions: see to FilePatternPackageSet
    // sometimes for new file DirectoryFileIndex.getContentRootForFile() return random path
  }
  return false;
}
项目:intellij-ce-playground    文件:AbstractTreeNode.java   
protected boolean acceptFilter(@Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  boolean apply = false;
  if (children != null && filter != null) {
    for (Iterator it = children.iterator(); it.hasNext(); ) {
      AbstractTreeNode node = (AbstractTreeNode)it.next();
      if (node.acceptFilter(filter, showOnlyFilteredItems)) {
        apply = true;
      }
      else if (showOnlyFilteredItems) {
        if (node instanceof Disposable) {
          Disposer.dispose((Disposable)node);
        }
        it.remove();
      }
    }
    applyFilter(apply);
  }
  return apply;
}
项目:intellij-ce-playground    文件:UpdateInfoTree.java   
@Nullable
private Pair<PackageSetBase, NamedScopesHolder> getScopeFilter() {
  String scopeName = VcsConfiguration.getInstance(myProject).UPDATE_FILTER_SCOPE_NAME;
  if (scopeName != null) {
    for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
      NamedScope scope = holder.getScope(scopeName);
      if (scope != null) {
        PackageSet packageSet = scope.getValue();
        if (packageSet instanceof PackageSetBase) {
          return Pair.create((PackageSetBase)packageSet, holder);
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:VcsUpdateInfoScopeFilterConfigurable.java   
VcsUpdateInfoScopeFilterConfigurable(Project project, VcsConfiguration vcsConfiguration) {
  myVcsConfiguration = vcsConfiguration;
  myCheckbox = new JCheckBox(VcsBundle.getString("settings.filter.update.project.info.by.scope"));
  myComboBox = new ComboBox();

  myComboBox.setEnabled(myCheckbox.isSelected());
  myCheckbox.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(@NotNull ChangeEvent e) {
      myComboBox.setEnabled(myCheckbox.isSelected());
    }
  });

  myNamedScopeHolders = NamedScopesHolder.getAllNamedScopeHolders(project);
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    holder.addScopeListener(this);
  }
}
项目:intellij-ce-playground    文件:VcsUpdateInfoScopeFilterConfigurable.java   
@Override
public void reset() {
  myComboBox.removeAllItems();
  boolean selection = false;
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    for (NamedScope scope : holder.getEditableScopes()) {
      myComboBox.addItem(scope.getName());
      if (!selection && scope.getName().equals(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME)) {
        selection = true;
      }
    }
  }
  if (selection) {
    myComboBox.setSelectedItem(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME);
  }
  myCheckbox.setSelected(selection);
}
项目:intellij-ce-playground    文件:ScopesOrderDialog.java   
private void fillList() {
  DefaultListModel model = new DefaultListModel();
  model.removeAllElements();

  final List<String> scopes = new ArrayList<String>();
  for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
    for (final NamedScope scope : holder.getScopes()) {
      if (!(scope instanceof NonProjectFilesScope)) {
        scopes.add(scope.getName());
      }
    }
  }
  scopes.remove(CustomScopesProviderEx.getAllScope().getName());
  Collections.sort(scopes, new ScopeOrderComparator(myInspectionProfile));
  for (String scopeName : scopes) {
    model.addElement(scopeName);
  }
  myOptionsList.setModel(model);
  myOptionsList.setSelectedIndex(0);
}
项目:intellij-ce-playground    文件:HierarchyTreeStructure.java   
protected SearchScope getSearchScope(final String scopeType, final PsiElement thisClass) {
  SearchScope searchScope = GlobalSearchScope.allScope(myProject);
  if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
    searchScope = new LocalSearchScope(thisClass);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_PROJECT.equals(scopeType)) {
    searchScope = GlobalSearchScopesCore.projectProductionScope(myProject);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) {
    searchScope = GlobalSearchScopesCore.projectTestScope(myProject);
  } else {
    final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType);
    if (namedScope != null) {
      searchScope = GlobalSearchScopesCore.filterScope(myProject, namedScope);
    }
  }
  return searchScope;
}
项目:intellij-ce-playground    文件:HierarchyBrowserBaseEx.java   
private Collection<String> getValidScopeNames() {
  List<String> result = new ArrayList<String>();
  result.add(SCOPE_PROJECT);
  result.add(SCOPE_TEST);
  result.add(SCOPE_ALL);
  result.add(SCOPE_CLASS);

  final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
  for (NamedScopesHolder holder : holders) {
    NamedScope[] scopes = holder.getEditableScopes(); //predefined scopes already included
    for (NamedScope scope : scopes) {
      result.add(scope.getName());
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:SuppressForTestsScopeFix.java   
private void addRemoveTestsScope(Project project, boolean add) {
  final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
  final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getInspectionProfile();
  final String shortName = myInspection.getShortName();
  final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
  if (tool == null) {
    return;
  }
  final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
  final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
  final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
  if (add) {
    profile.addScope(tool, namedScope, level, false, project);
  }
  else {
    profile.removeScope(shortName, 0, project);
  }
  profile.scopesChanged();
}
项目:intellij-ce-playground    文件:ProjectSettingsPanel.java   
public TableCellRenderer getRenderer(final ScopeSetting mapping) {
  return new DefaultTableCellRenderer() {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value == null) {
        setText("");
      }
      else {
        final String scopeName = ((NamedScope)value).getName();
        if (!isSelected) {
          final NamedScope scope = NamedScopesHolder.getScope(myProject, scopeName);
          if (scope == null) setForeground(JBColor.RED);
        }
        setText(scopeName);
      }
      return this;
    }
  };
}
项目:tools-idea    文件:HighlightNamesUtil.java   
private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
  PsiFile file = element.getContainingFile();
  if (file == null) return null;
  TextAttributes result = null;
  final DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(file.getProject());
  List<Pair<NamedScope,NamedScopesHolder>> scopes = daemonCodeAnalyzer.getScopeBasedHighlightingCachedScopes();
  for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
    NamedScope namedScope = scope.getFirst();
    NamedScopesHolder scopesHolder = scope.getSecond();
    PackageSet packageSet = namedScope.getValue();
    if (packageSet != null && packageSet.contains(file, scopesHolder)) {
      TextAttributesKey scopeKey = ColorAndFontOptions.getScopeTextAttributeKey(namedScope.getName());
      TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
      if (attributes == null || attributes.isEmpty()) {
        continue;
      }
      result = TextAttributes.merge(attributes, result);
    }
  }
  return result;
}
项目:tools-idea    文件:GroupTreeNode.java   
private void rebuildFiles(boolean groupByPackages,
                          @Nullable Pair<PackageSetBase, NamedScopesHolder> filter,
                          boolean showOnlyFilteredItems) {
  for (int i = getChildCount() - 1; i >= 0; i--) {
    final TreeNode node = getChildAt(i);
    if (node instanceof Disposable) {
      Disposer.dispose((Disposable)node);
    }
  }
  removeAllChildren();

  if (groupByPackages) {
    buildPackages();
    acceptFilter(filter, showOnlyFilteredItems);
  }
  else {
    buildFiles(filter, showOnlyFilteredItems);
  }

  setTreeModel(myTreeModel);

  if (myTreeModel != null) {
    myTreeModel.nodeStructureChanged(this);
  }
}
项目:tools-idea    文件:FileTreeNode.java   
@Override
protected boolean acceptFilter(Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  try {
    VirtualFilePointer filePointer = getFilePointer();
    if (!filePointer.isValid()) {
      return false;
    }
    VirtualFile file = filePointer.getFile();
    if (file != null && file.isValid() && filter.first.contains(file, getProject(), filter.second)) {
      applyFilter(true);
      return true;
    }
  }
  catch (Throwable e) {
    // TODO: catch and ignore exceptions: see to FilePatternPackageSet
    // sometimes for new file DirectoryFileIndex.getContentRootForFile() return random path
  }
  return false;
}
项目:tools-idea    文件:AbstractTreeNode.java   
protected boolean acceptFilter(@Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  boolean apply = false;
  if (children != null && filter != null) {
    for (Iterator it = children.iterator(); it.hasNext(); ) {
      AbstractTreeNode node = (AbstractTreeNode)it.next();
      if (node.acceptFilter(filter, showOnlyFilteredItems)) {
        apply = true;
      }
      else if (showOnlyFilteredItems) {
        if (node instanceof Disposable) {
          Disposer.dispose((Disposable)node);
        }
        it.remove();
      }
    }
    applyFilter(apply);
  }
  return apply;
}
项目:tools-idea    文件:UpdateInfoTree.java   
@Nullable
private Pair<PackageSetBase, NamedScopesHolder> getScopeFilter() {
  String scopeName = VcsConfiguration.getInstance(myProject).UPDATE_FILTER_SCOPE_NAME;
  if (scopeName != null) {
    for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
      NamedScope scope = holder.getScope(scopeName);
      if (scope != null) {
        PackageSet packageSet = scope.getValue();
        if (packageSet instanceof PackageSetBase) {
          return new Pair<PackageSetBase, NamedScopesHolder>((PackageSetBase)packageSet, holder);
        }
      }
    }
  }
  return null;
}
项目:tools-idea    文件:VcsUpdateInfoScopeFilterConfigurable.java   
VcsUpdateInfoScopeFilterConfigurable(Project project, VcsConfiguration vcsConfiguration) {
  myProject = project;
  myVcsConfiguration = vcsConfiguration;
  myCheckbox = new JCheckBox(VcsBundle.getString("settings.filter.update.project.info.by.scope"));
  myComboBox = new JComboBox();

  myComboBox.setEnabled(myCheckbox.isSelected());
  myCheckbox.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      myComboBox.setEnabled(myCheckbox.isSelected());
    }
  });

  myNamedScopeHolders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    holder.addScopeListener(this);
  }
}
项目:tools-idea    文件:VcsUpdateInfoScopeFilterConfigurable.java   
@Override
public void reset() {
  myComboBox.removeAllItems();
  boolean selection = false;
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    for (NamedScope scope : holder.getEditableScopes()) {
      myComboBox.addItem(scope.getName());
      if (!selection && scope.getName().equals(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME)) {
        selection = true;
      }
    }
  }
  if (selection) {
    myComboBox.setSelectedItem(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME);
  }
  myCheckbox.setSelected(selection);
}
项目:tools-idea    文件:AddScopeAction.java   
private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) {
  final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
  for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
    Collections.addAll(scopes, holder.getScopes());
  }
  scopes.remove(CustomScopesProviderEx.getAllScope());

  CustomScopesProviderEx.filterNoSettingsScopes(project, scopes);

  final Set<NamedScope> used = new HashSet<NamedScope>();
  for (Descriptor descriptor : descriptors) {
    final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString(), project);
    if (nonDefaultTools != null) {
      for (ScopeToolState state : nonDefaultTools) {
        used.add(state.getScope(project));
      }
    }
  }
  scopes.removeAll(used);

  final List<String> availableScopes = new ArrayList<String>();
  for (NamedScope scope : scopes) {
    availableScopes.add(scope.getName());
  }
  return availableScopes;
}
项目:tools-idea    文件:HierarchyTreeStructure.java   
protected SearchScope getSearchScope(final String scopeType, final PsiElement thisClass) {
  SearchScope searchScope = GlobalSearchScope.allScope(myProject);
  if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
    searchScope = new LocalSearchScope(thisClass);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_PROJECT.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectProductionScope(myProject);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectTestScope(myProject);
  } else {
    final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType);
    if (namedScope != null) {
      searchScope = GlobalSearchScopes.filterScope(myProject, namedScope);
    }
  }
  return searchScope;
}
项目:tools-idea    文件:HierarchyBrowserBaseEx.java   
private Collection<String> getValidScopeNames() {
  List<String> result = new ArrayList<String>();
  result.add(SCOPE_PROJECT);
  result.add(SCOPE_TEST);
  result.add(SCOPE_ALL);
  result.add(SCOPE_CLASS);

  final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
  for (NamedScopesHolder holder : holders) {
    NamedScope[] scopes = holder.getEditableScopes(); //predefined scopes already included
    for (NamedScope scope : scopes) {
      result.add(scope.getName());
    }
  }
  return result;
}
项目:tools-idea    文件:ProjectSettingsPanel.java   
public TableCellRenderer getRenderer(final ScopeSetting mapping) {
  return new DefaultTableCellRenderer() {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value == null) {
        setText("");
      }
      else {
        final String scopeName = ((NamedScope)value).getName();
        if (!isSelected) {
          final NamedScope scope = NamedScopesHolder.getScope(myProject, scopeName);
          if (scope == null) setForeground(JBColor.RED);
        }
        setText(scopeName);
      }
      return this;
    }
  };
}
项目:consulo    文件:GroupTreeNode.java   
private void rebuildFiles(boolean groupByPackages,
                          @Nullable Pair<PackageSetBase, NamedScopesHolder> filter,
                          boolean showOnlyFilteredItems) {
  for (int i = getChildCount() - 1; i >= 0; i--) {
    final TreeNode node = getChildAt(i);
    if (node instanceof Disposable) {
      Disposer.dispose((Disposable)node);
    }
  }
  removeAllChildren();

  if (groupByPackages) {
    buildPackages();
    acceptFilter(filter, showOnlyFilteredItems);
  }
  else {
    buildFiles(filter, showOnlyFilteredItems);
  }

  setTreeModel(myTreeModel);

  if (myTreeModel != null) {
    myTreeModel.nodeStructureChanged(this);
  }
}
项目:consulo    文件:FileTreeNode.java   
@Override
protected boolean acceptFilter(Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  try {
    VirtualFilePointer filePointer = getFilePointer();
    if (!filePointer.isValid()) {
      return false;
    }
    VirtualFile file = filePointer.getFile();
    if (file != null && file.isValid() && filter.first.contains(file, filter.second)) {
      applyFilter(true);
      return true;
    }
  }
  catch (Throwable e) {
    // TODO: catch and ignore exceptions: see to FilePatternPackageSet
    // sometimes for new file DirectoryFileIndex.getContentRootForFile() return random path
  }
  return false;
}
项目:consulo    文件:AbstractTreeNode.java   
protected boolean acceptFilter(@Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  boolean apply = false;
  if (children != null && filter != null) {
    for (Iterator it = children.iterator(); it.hasNext(); ) {
      AbstractTreeNode node = (AbstractTreeNode)it.next();
      if (node.acceptFilter(filter, showOnlyFilteredItems)) {
        apply = true;
      }
      else if (showOnlyFilteredItems) {
        if (node instanceof Disposable) {
          Disposer.dispose((Disposable)node);
        }
        it.remove();
      }
    }
    applyFilter(apply);
  }
  return apply;
}
项目:consulo    文件:UpdateInfoTree.java   
@Nullable
private Pair<PackageSetBase, NamedScopesHolder> getScopeFilter() {
  String scopeName = getFilterScopeName();
  if (scopeName != null) {
    for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
      NamedScope scope = holder.getScope(scopeName);
      if (scope != null) {
        PackageSet packageSet = scope.getValue();
        if (packageSet instanceof PackageSetBase) {
          return Pair.create((PackageSetBase)packageSet, holder);
        }
      }
    }
  }
  return null;
}
项目:consulo    文件:VcsUpdateInfoScopeFilterConfigurable.java   
VcsUpdateInfoScopeFilterConfigurable(Project project, VcsConfiguration vcsConfiguration) {
  myProject = project;
  myVcsConfiguration = vcsConfiguration;
  myCheckbox = new JCheckBox(VcsBundle.message("settings.filter.update.project.info.by.scope"));
  myComboBox = new JComboBox();

  myComboBox.setEnabled(myCheckbox.isSelected());
  myCheckbox.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      myComboBox.setEnabled(myCheckbox.isSelected());
    }
  });

  myNamedScopeHolders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    holder.addScopeListener(this);
  }
}
项目:consulo    文件:VcsUpdateInfoScopeFilterConfigurable.java   
@Override
public void reset() {
  myComboBox.removeAllItems();
  boolean selection = false;
  for (NamedScopesHolder holder : myNamedScopeHolders) {
    for (NamedScope scope : holder.getEditableScopes()) {
      myComboBox.addItem(scope.getName());
      if (!selection && scope.getName().equals(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME)) {
        selection = true;
      }
    }
  }
  if (selection) {
    myComboBox.setSelectedItem(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME);
  }
  myCheckbox.setSelected(selection);
}
项目:consulo    文件:ProjectSettingsPanel.java   
public TableCellRenderer getRenderer(final ScopeSetting mapping) {
  return new DefaultTableCellRenderer() {
    public Component getTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (value == null) {
        setText("");
      }
      else {
        final String scopeName = ((NamedScope)value).getName();
        if (!isSelected) {
          final NamedScope scope = NamedScopesHolder.getScope(myProject, scopeName);
          if (scope == null) setForeground(JBColor.RED);
        }
        setText(scopeName);
      }
      return this;
    }
  };
}
项目:consulo    文件:ScopesOrderDialog.java   
private void fillList() {
  DefaultListModel model = new DefaultListModel();
  model.removeAllElements();

  final List<String> scopes = new ArrayList<String>();
  for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
    for (final NamedScope scope : holder.getScopes()) {
      if (!(scope instanceof NonProjectFilesScope)) {
        scopes.add(scope.getName());
      }
    }
  }
  scopes.remove(CustomScopesProviderEx.getAllScope().getName());
  Collections.sort(scopes, new ScopeOrderComparator(myInspectionProfile));
  for (String scopeName : scopes) {
    model.addElement(scopeName);
  }
  myOptionsList.setModel(model);
  myOptionsList.setSelectedIndex(0);
}
项目:consulo    文件:HierarchyTreeStructure.java   
protected SearchScope getSearchScope(final String scopeType, final PsiElement thisClass) {
  SearchScope searchScope = GlobalSearchScope.allScope(myProject);
  if (HierarchyBrowserBaseEx.SCOPE_CLASS.equals(scopeType)) {
    searchScope = new LocalSearchScope(thisClass);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_PROJECT.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectProductionScope(myProject);
  }
  else if (HierarchyBrowserBaseEx.SCOPE_TEST.equals(scopeType)) {
    searchScope = GlobalSearchScopes.projectTestScope(myProject);
  } else {
    final NamedScope namedScope = NamedScopesHolder.getScope(myProject, scopeType);
    if (namedScope != null) {
      searchScope = GlobalSearchScopes.filterScope(myProject, namedScope);
    }
  }
  return searchScope;
}
项目:consulo    文件:HierarchyBrowserBaseEx.java   
private Collection<String> getValidScopeNames() {
  List<String> result = new ArrayList<String>();
  result.add(SCOPE_PROJECT);
  result.add(SCOPE_TEST);
  result.add(SCOPE_ALL);
  result.add(SCOPE_CLASS);

  final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
  for (NamedScopesHolder holder : holders) {
    NamedScope[] scopes = holder.getEditableScopes(); //predefined scopes already included
    for (NamedScope scope : scopes) {
      result.add(scope.getName());
    }
  }
  return result;
}
项目:consulo-java    文件:SuppressForTestsScopeFix.java   
private void addRemoveTestsScope(Project project, boolean add)
{
    final InspectionProfileImpl profile = (InspectionProfileImpl) InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
    final String shortName = myInspection.getShortName();
    final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
    if(tool == null)
    {
        return;
    }
    if(add)
    {
        final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
        final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
        final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
        profile.addScope(tool, namedScope, level, false, project);
    }
    else
    {
        profile.removeScope(shortName, "Tests", project);
    }
    profile.scopesChanged();
}
项目:intellij-ce-playground    文件:AdvHighlightingTest.java   
public void testSharedScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopesHolder scopeManager = DependencyValidationManager.getInstance(getProject());
  scopeManager.addScope(xScope);
  scopeManager.addScope(utilScope);

  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);
  TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, null, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

  TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
  TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
  scheme.setAttributes(utilKey, utilAttributes);

  NamedScope projectScope = PackagesScopesProvider.getInstance(myProject).getProjectProductionScope();
  TextAttributesKey projectKey = ScopeAttributesUtil.getScopeTextAttributeKey(projectScope.getName());
  TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(projectKey, projectAttributes);

  try {
    testFile(BASE_PATH + "/scopeBased/x/Shared.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:intellij-ce-playground    文件:ScopeToolState.java   
@Nullable
public NamedScope getScope(Project project) {
  if (myScope == null && project != null) {
    myScope = NamedScopesHolder.getScope(project, myScopeName);
  }
  return myScope;
}
项目:intellij-ce-playground    文件:GroupTreeNode.java   
public void rebuild(boolean groupByPackages, @Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  myFilterAttributes = null;
  if (containsGroups()) {
    rebuildGroups(groupByPackages, filter, showOnlyFilteredItems);
  }
  else {
    rebuildFiles(groupByPackages, filter, showOnlyFilteredItems);
  }
}
项目:intellij-ce-playground    文件:GroupTreeNode.java   
private void rebuildGroups(boolean groupByPackages,
                           @Nullable Pair<PackageSetBase, NamedScopesHolder> filter,
                           boolean showOnlyFilteredItems) {
  boolean apply = false;
  for (int i = 0; i < getChildCount(); i++) {
    GroupTreeNode childGroup = (GroupTreeNode)getChildAt(i);
    childGroup.rebuild(groupByPackages, filter, showOnlyFilteredItems);
    apply |= childGroup.myFilterAttributes != null;
  }
  applyFilter(apply);
}
项目:intellij-ce-playground    文件:GroupTreeNode.java   
private void buildFiles(@Nullable Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  Collections.sort(myFilePaths, new Comparator<String>() {
    @Override
    public int compare(String path1, String path2) {
      return path1.compareToIgnoreCase(path2);
    }
  });

  boolean apply = false;

  for (final String filePath : myFilePaths) {
    final FileTreeNode child = new FileTreeNode(filePath, myInvalidAttributes, myProject, null);
    if (filter != null) {
      if (child.acceptFilter(filter, showOnlyFilteredItems)) {
        apply = true;
      }
      else if (showOnlyFilteredItems) {
        Disposer.dispose(child);
        continue;
      }
    }
    final String error = myErrorsMap.get(filePath);
    if (error != null) {
      child.setErrorText(error);
    }
    add(child);
    Disposer.register(this, child);
  }

  applyFilter(apply);
}
项目:intellij-ce-playground    文件:ScopesChooser.java   
@NotNull
@Override
public DefaultActionGroup createPopupActionGroup(final JComponent component) {
  final DefaultActionGroup group = new DefaultActionGroup();

  final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>();
  final List<NamedScope> customScopes = new ArrayList<NamedScope>();
  for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
    Collections.addAll(customScopes, holder.getEditableScopes());
    predefinedScopes.addAll(holder.getPredefinedScopes());
  }
  predefinedScopes.remove(CustomScopesProviderEx.getAllScope());
  for (NamedScope predefinedScope : predefinedScopes) {
    if (predefinedScope instanceof NonProjectFilesScope) {
      predefinedScopes.remove(predefinedScope);
      break;
    }
  }

  fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);
  group.addSeparator();
  fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);

  group.addSeparator();
  group.add(new DumbAwareAction("Edit Scopes Order...") {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      final ScopesOrderDialog dlg = new ScopesOrderDialog(component, myInspectionProfile, myProject);
      if (dlg.showAndGet()) {
        onScopesOrderChanged();
      }
    }
  });

  return group;
}