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

项目:hybris-integration-intellij-idea-plugin    文件:DefaultSearchScopeConfigurator.java   
private static void addOrReplaceScopes(@NotNull Project project, @NotNull List<NamedScope> newScopes) {
    final Set<String> newScopeNames = newScopes
        .stream()
        .map(NamedScope::getName)
        .collect(Collectors.toSet());

    final NamedScopeManager namedScopeManager = NamedScopeManager.getInstance(project);
    final NamedScope[] existingScopes = namedScopeManager.getEditableScopes();

    final NamedScope[] filteredScopes = Arrays
        .stream(existingScopes)
        .filter(it -> !newScopeNames.contains(it.getName()))
        .toArray(NamedScope[]::new);

    namedScopeManager.setScopes(ArrayUtil.mergeArrays(
        filteredScopes,
        newScopes.toArray(new NamedScope[newScopes.size()])
    ));
}
项目:hybris-integration-intellij-idea-plugin    文件:DefaultSearchScopeConfigurator.java   
private NamedScope createScope(final Project project, final String firstGroupName, String secondGroupName) {
    final FilePatternPackageSet firstFilePatternPackageSet = new FilePatternPackageSet(
        SEARCH_SCOPE_GROUP_PREFIX + firstGroupName,
        "*//*"
    );
    final FilePatternPackageSet secondFilePatternPackageSet = new FilePatternPackageSet(
        SEARCH_SCOPE_GROUP_PREFIX + secondGroupName,
        "*//*"
    );
    final UnionPackageSet unionPackageSet = new UnionPackageSet(
        firstFilePatternPackageSet,
        secondFilePatternPackageSet
    );
    return new NamedScope(
        SEARCH_SCOPE_Y_PREFIX + " " + firstGroupName + " " + secondGroupName,
        unionPackageSet
    );
}
项目: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    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.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, EffectType.BOXED, 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);

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:intellij-ce-playground    文件:ToolsImpl.java   
@NotNull
@Override
public InspectionToolWrapper getInspectionTool(PsiElement element) {
  if (myTools != null) {
    final PsiFile containingFile = element == null ? null : element.getContainingFile();
    final Project project = containingFile == null ? null : containingFile.getProject();
    for (ScopeToolState state : myTools) {
      if (element == null) {
        return state.getTool();
      }
      NamedScope scope = state.getScope(project);
      if (scope != null) {
        final PackageSet packageSet = scope.getValue();
        if (packageSet != null) {
          if (containingFile != null && packageSet.contains(containingFile, DependencyValidationManager.getInstance(project))) {
            return state.getTool();
          }
        }
      }
    }

  }
  return myDefaultState.getTool();
}
项目:intellij-ce-playground    文件:ToolsImpl.java   
@Override
public boolean isEnabled(PsiElement element) {
  if (!myEnabled) return false;
  if (myTools == null || element == null) return myDefaultState.isEnabled();
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled();
      }
    }
  }
  return myDefaultState.isEnabled();
}
项目:intellij-ce-playground    文件:ToolsImpl.java   
@Override
@Nullable
public InspectionToolWrapper getEnabledTool(PsiElement element) {
  if (!myEnabled) return null;
  if (myTools == null || element == null) {
    return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
  }
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled() ? state.getTool() : null;
      }
    }
  }
  return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}
项目:intellij-ce-playground    文件:ToolsImpl.java   
public void disableTool(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
  if (myTools != null) {
    for (ScopeToolState state : myTools) {
      final NamedScope scope = state.getScope(project);
      if (scope != null) {
        final PackageSet packageSet = scope.getValue();
        if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) {
          state.setEnabled(false);
          return;
        }
      }
    }
    myDefaultState.setEnabled(false);
  }
  else {
    myDefaultState.setEnabled(false);
    setEnabled(false);
  }
}
项目: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   
@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    文件:ScopesChooser.java   
private void fillActionGroup(final DefaultActionGroup group,
                             final List<NamedScope> scopes,
                             final List<Descriptor> defaultDescriptors,
                             final InspectionProfileImpl inspectionProfile,
                             final Set<String> excludedScopeNames) {
  for (final NamedScope scope : scopes) {
    final String scopeName = scope.getName();
    if (excludedScopeNames.contains(scopeName)) {
      continue;
    }
    group.add(new DumbAwareAction(scopeName) {
      @Override
      public void actionPerformed(final AnActionEvent e) {
        for (final Descriptor defaultDescriptor : defaultDescriptors) {
          inspectionProfile.addScope(defaultDescriptor.getToolWrapper().createCopy(), scope, defaultDescriptor.getLevel(), true, getEventProject(e));
        }
        onScopeAdded();
      }
    });
  }
}
项目: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    文件:ScopeChooserCombo.java   
private ActionListener createScopeChooserListener() {
  return new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final String selection = getSelectedScopeName();
      final EditScopesDialog dlg = EditScopesDialog.showDialog(myProject, selection);
      if (dlg.isOK()){
        rebuildModel();
        final NamedScope namedScope = dlg.getSelectedScope();
        if (namedScope != null) {
          selectScope(namedScope.getName());
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:ScopeConfigurable.java   
public ScopeConfigurable(final NamedScope scope, final boolean shareScope, final Project project, final Runnable updateTree) {
  super(true, updateTree);
  myScope = scope;
  myShareScope = shareScope;
  myProject = project;
  mySharedCheckbox = new JCheckBox(IdeBundle.message("share.scope.checkbox.title"), shareScope);
  myPanel = new ScopeEditorPanel(project, getHolder());
  myIcon = getHolder(myShareScope).getIcon();
  mySharedCheckbox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      myIcon = getHolder().getIcon();
      myPanel.setHolder(getHolder());
    }
  });
}
项目: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    文件:CopyrightManager.java   
@Nullable
public CopyrightProfile getCopyrightOptions(@NotNull PsiFile file) {
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null || myOptions.getOptions(virtualFile.getFileType().getName()).getFileTypeOverride() == LanguageOptions.NO_COPYRIGHT) return null;
  final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
  for (String scopeName : myModuleToCopyrights.keySet()) {
    final NamedScope namedScope = validationManager.getScope(scopeName);
    if (namedScope != null) {
      final PackageSet packageSet = namedScope.getValue();
      if (packageSet != null) {
        if (packageSet.contains(file, validationManager)) {
          final CopyrightProfile profile = myCopyrights.get(myModuleToCopyrights.get(scopeName));
          if (profile != null) {
            return profile;
          }
        }
      }
    }
  }
  return myDefaultCopyright != null ? myDefaultCopyright : null;
}
项目:intellij-ce-playground    文件:ProjectSettingsPanel.java   
public boolean isModified() {
  final CopyrightProfile defaultCopyright = myManager.getDefaultCopyright();
  final Object selected = myProfilesComboBox.getSelectedItem();
  if (defaultCopyright != selected) {
    if (selected == null) return true;
    if (defaultCopyright == null) return true;
    if (!defaultCopyright.equals(selected)) return true;
  }
  final Map<String, String> map = myManager.getCopyrightsMapping();
  if (map.size() != myScopeMappingModel.getItems().size()) return true;
  final Iterator<String> iterator = map.keySet().iterator();
  for (ScopeSetting setting : myScopeMappingModel.getItems()) {
    final NamedScope scope = setting.getScope();
    if (!iterator.hasNext()) return true;
    final String scopeName = iterator.next();
    if (scope == null || !Comparing.strEqual(scopeName, scope.getName())) return true;
    final String profileName = map.get(scope.getName());
    if (profileName == null) return true;
    if (!profileName.equals(setting.getProfileName())) return true;
  }
  return false;
}
项目: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    文件:AdvHighlightingTest.java   
public void testScopeBased() throws Exception {
  NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
  NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
  NamedScopeManager scopeManager = NamedScopeManager.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 = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
  TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC);
  scheme.setAttributes(xKey, xAttributes);

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

  try {
    testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
  }
  finally {
    scopeManager.removeAllSets();
  }
}
项目:tools-idea    文件:ToolsImpl.java   
@Override
public boolean isEnabled(PsiElement element) {
  if (!myEnabled) return false;
  if (myTools == null || element == null) return myDefaultState.isEnabled();
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled();
      }
    }
  }
  return myDefaultState.isEnabled();
}
项目:tools-idea    文件:ToolsImpl.java   
@Override
@Nullable
public InspectionToolWrapper getEnabledTool(PsiElement element) {
  if (!myEnabled) return null;
  if (myTools == null || element == null) {
    return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
  }
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled() ? state.getTool() : null;
      }
    }
  }
  return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}
项目:tools-idea    文件:ToolsImpl.java   
public void disableTool(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
  if (myTools != null) {
    for (ScopeToolState state : myTools) {
      final NamedScope scope = state.getScope(project);
      if (scope != null) {
        final PackageSet packageSet = scope.getValue();
        if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) {
          state.setEnabled(false);
          return;
        }
      }
    }
    myDefaultState.setEnabled(false);
  }
  else {
    myDefaultState.setEnabled(false);
    setEnabled(false);
  }
}
项目:tools-idea    文件:ToolsImpl.java   
public void setLevel(@NotNull HighlightDisplayLevel level, int idx, Project project) {
  if (myTools != null && myTools.size() > idx && idx >= 0) {
    final ScopeToolState scopeToolState = myTools.get(idx);
    myTools.remove(idx);
    final NamedScope scope = scopeToolState.getScope(project);
    InspectionToolWrapper toolWrapper = scopeToolState.getTool();
    if (scope != null) {
      myTools.add(idx, new ScopeToolState(scope, toolWrapper, scopeToolState.isEnabled(), level));
    }
    else {
      myTools.add(idx, new ScopeToolState(scopeToolState.getScopeName(), toolWrapper, scopeToolState.isEnabled(), level));
    }
  }
  else if (idx == -1) {
    myDefaultState.setLevel(level);
  }
}
项目: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   
@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    文件:ScopeBasedTodosPanel.java   
private void rebuildModel(Project project, String scopeName) {
  final ArrayList<ScopeWrapper> scopes = new ArrayList<ScopeWrapper>();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);

  scopes.add(new ScopeWrapper("Predefined Scopes"));
  List<NamedScope> predefinedScopesList = manager.getPredefinedScopes();
  NamedScope[] predefinedScopes = predefinedScopesList.toArray(new NamedScope[predefinedScopesList.size()]);
  predefinedScopes = NonProjectFilesScope.removeFromList(predefinedScopes);
  for (NamedScope predefinedScope : predefinedScopes) {
    scopes.add(new ScopeWrapper(predefinedScope));
  }

  collectEditableScopes(scopes, manager, "Custom Project Scopes");
  collectEditableScopes(scopes, NamedScopeManager.getInstance(project), "Custom Local Scopes");

  myScopes.setModel(new DefaultComboBoxModel(scopes.toArray(new ScopeWrapper[scopes.size()])));
  setSelection(scopeName, scopes);
}
项目:tools-idea    文件:ScopeChooserCombo.java   
private ActionListener createScopeChooserListener() {
  return new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final String selection = getSelectedScopeName();
      final EditScopesDialog dlg = EditScopesDialog.showDialog(myProject, selection);
      if (dlg.isOK()){
        rebuildModel();
        final NamedScope namedScope = dlg.getSelectedScope();
        if (namedScope != null) {
          selectScope(namedScope.getName());
        }
      }
    }
  };
}
项目:tools-idea    文件:ScopeConfigurable.java   
public ScopeConfigurable(final NamedScope scope, final boolean shareScope, final Project project, final Runnable updateTree) {
  super(true, updateTree);
  myScope = scope;
  myShareScope = shareScope;
  myProject = project;
  mySharedCheckbox = new JCheckBox(IdeBundle.message("share.scope.checkbox.title"), shareScope);
  myPanel = new ScopeEditorPanel(project, getHolder());
  myIcon = getHolder(myShareScope).getIcon();
  mySharedCheckbox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      myIcon = getHolder().getIcon();
      myPanel.setHolder(getHolder());
    }
  });
}
项目:tools-idea    文件:CopyrightManager.java   
@Nullable
public CopyrightProfile getCopyrightOptions(@NotNull PsiFile file) {
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null || myOptions.getOptions(virtualFile.getFileType().getName()).getFileTypeOverride() == LanguageOptions.NO_COPYRIGHT) return null;
  final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
  for (String scopeName : myModule2Copyrights.keySet()) {
    final NamedScope namedScope = validationManager.getScope(scopeName);
    if (namedScope != null) {
      final PackageSet packageSet = namedScope.getValue();
      if (packageSet != null) {
        if (packageSet.contains(file, validationManager)) {
          final CopyrightProfile profile = myCopyrights.get(myModule2Copyrights.get(scopeName));
          if (profile != null) {
            return profile;
          }
        }
      }
    }
  }
  return myDefaultCopyright != null ? myDefaultCopyright : null;
}
项目:tools-idea    文件:ProjectSettingsPanel.java   
public boolean isModified() {
  final CopyrightProfile defaultCopyright = myManager.getDefaultCopyright();
  final Object selected = myProfilesComboBox.getSelectedItem();
  if (defaultCopyright != selected) {
    if (selected == null) return true;
    if (defaultCopyright == null) return true;
    if (!defaultCopyright.equals(selected)) return true;
  }
  final Map<String, String> map = myManager.getCopyrightsMapping();
  if (map.size() != myScopeMappingModel.getItems().size()) return true;
  final Iterator<String> iterator = map.keySet().iterator();
  for (ScopeSetting setting : myScopeMappingModel.getItems()) {
    final NamedScope scope = setting.getScope();
    if (!iterator.hasNext()) return true;
    final String scopeName = iterator.next();
    if (scope == null || !Comparing.strEqual(scopeName, scope.getName())) return true;
    final String profileName = map.get(scope.getName());
    if (profileName == null) return true;
    if (!profileName.equals(setting.getProfileName())) return true;
  }
  return false;
}
项目: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    文件:ToolsImpl.java   
@Nonnull
@Override
public InspectionToolWrapper getInspectionTool(PsiElement element) {
  if (myTools != null) {
    final PsiFile containingFile = element == null ? null : element.getContainingFile();
    final Project project = containingFile == null ? null : containingFile.getProject();
    for (ScopeToolState state : myTools) {
      if (element == null) {
        return state.getTool();
      }
      NamedScope scope = state.getScope(project);
      if (scope != null) {
        final PackageSet packageSet = scope.getValue();
        if (packageSet != null) {
          if (containingFile != null && packageSet.contains(containingFile, DependencyValidationManager.getInstance(project))) {
            return state.getTool();
          }
        }
      }
    }

  }
  return myDefaultState.getTool();
}
项目:consulo    文件:ToolsImpl.java   
@Override
public boolean isEnabled(PsiElement element) {
  if (!myEnabled) return false;
  if (myTools == null || element == null) return myDefaultState.isEnabled();
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled();
      }
    }
  }
  return myDefaultState.isEnabled();
}
项目:consulo    文件:ToolsImpl.java   
@Override
@Nullable
public InspectionToolWrapper getEnabledTool(PsiElement element) {
  if (!myEnabled) return null;
  if (myTools == null || element == null) {
    return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
  }
  final Project project = element.getProject();
  final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
  for (ScopeToolState state : myTools) {
    final NamedScope scope = state.getScope(project);
    if (scope != null) {
      final PackageSet set = scope.getValue();
      if (set != null && set.contains(element.getContainingFile(), manager)) {
        return state.isEnabled() ? state.getTool() : null;
      }
    }
  }
  return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}