Java Code Examples for com.intellij.openapi.util.Comparing

The following examples show how to use com.intellij.openapi.util.Comparing. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: consulo   Source File: JdkUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean checkForJdk(final File homePath) {
  File binPath = new File(homePath.getAbsolutePath() + File.separator + "bin");
  if (!binPath.exists()) return false;

  FileFilter fileFilter = new FileFilter() {
    @Override
    @SuppressWarnings({"HardCodedStringLiteral"})
    public boolean accept(File f) {
      if (f.isDirectory()) return false;
      return Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javac") ||
             Comparing.strEqual(FileUtil.getNameWithoutExtension(f), "javah");
    }
  };
  File[] children = binPath.listFiles(fileFilter);

  return children != null && children.length >= 2 &&
         checkForRuntime(homePath.getAbsolutePath());
}
 
Example 2
Source Project: consulo   Source File: PsiTestUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static ContentEntry addContentRoot(final Module module, final VirtualFile vDir) {
  final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  new WriteCommandAction.Simple(module.getProject()) {
    @Override
    protected void run() throws Throwable {
      final ModifiableRootModel rootModel = rootManager.getModifiableModel();
      rootModel.addContentEntry(vDir);
      rootModel.commit();
    }
  }.execute().throwException();
  for (ContentEntry entry : rootManager.getContentEntries()) {
    if (Comparing.equal(entry.getFile(), vDir)) {
      Assert.assertFalse(((ContentEntryImpl)entry).isDisposed());
      return entry;
    }
  }
  return null;
}
 
Example 3
Source Project: consulo   Source File: AnchorElementInfo.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean pointsToTheSameElementAs(@Nonnull final SmartPointerElementInfo other, @Nonnull SmartPointerManagerImpl manager) {
  if (other instanceof AnchorElementInfo) {
    if (!getVirtualFile().equals(other.getVirtualFile())) return false;

    long packed1 = myStubElementTypeAndId;
    long packed2 = ((AnchorElementInfo)other).myStubElementTypeAndId;

    if (packed1 != -1 && packed2 != -1) {
      return packed1 == packed2;
    }
    if (packed1 != -1 || packed2 != -1) {
      return ReadAction.compute(() -> Comparing.equal(restoreElement(manager), other.restoreElement(manager)));
    }
  }
  return super.pointsToTheSameElementAs(other, manager);
}
 
Example 4
Source Project: consulo   Source File: XBreakpointManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void updateBreakpointPresentation(@Nonnull XLineBreakpoint<?> breakpoint, @Nullable Image icon, @Nullable String errorMessage) {
  XLineBreakpointImpl lineBreakpoint = (XLineBreakpointImpl)breakpoint;
  CustomizedBreakpointPresentation presentation = lineBreakpoint.getCustomizedPresentation();
  if (presentation == null) {
    if (icon == null && errorMessage == null) {
      return;
    }
    presentation = new CustomizedBreakpointPresentation();
  }
  else if (Comparing.equal(presentation.getIcon(), icon) && Comparing.strEqual(presentation.getErrorMessage(), errorMessage)) {
    return;
  }

  presentation.setErrorMessage(errorMessage);
  presentation.setIcon(icon);
  lineBreakpoint.setCustomizedPresentation(presentation);
  myLineBreakpointManager.queueBreakpointUpdate(breakpoint);
}
 
Example 5
Source Project: consulo   Source File: ModuleConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setDisplayName(String name) {
  name = name.trim();
  final ModifiableModuleModel modifiableModuleModel = myConfigurator.getModuleModel();
  if (StringUtil.isEmpty(name)) return; //empty string comes on double click on module node
  if (Comparing.strEqual(name, myModuleName)) return; //nothing changed
  try {
    modifiableModuleModel.renameModule(myModule, name);
  }
  catch (ModuleWithNameAlreadyExistsException ignored) {
  }
  myConfigurator.moduleRenamed(myModule, myModuleName, name);
  myModuleName = name;
  myConfigurator.setModified(!Comparing.strEqual(myModuleName, myModule.getName()));
  myContext.getDaemonAnalyzer().queueUpdateForAllElementsWithErrors();
}
 
Example 6
Source Project: consulo   Source File: ComboBoxFieldPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void addItemSetText(String text) {
  JComboBox comboBox = getComboBox();
  int n = comboBox.getItemCount();
  boolean found = false;
  for (int i = 0; i < n; i++) {
    String item = (String)comboBox.getItemAt(i);
    if (Comparing.strEqual(item, text)) {
      found = true;
      break;
    }
  }
  if (!found) {
    comboBox.addItem(text);
  }
  comboBox.getEditor().setItem(text);
  setText(text);
}
 
Example 7
Source Project: consulo   Source File: RootModelImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean removeLayer(@Nonnull String name, boolean initDefault) {
  assertWritable();
  ModuleRootLayerImpl removedLayer = myLayers.remove(name);
  if (removedLayer != null) {
    Disposer.dispose(removedLayer);

    if (initDefault && myLayers.isEmpty()) {
      initDefaultLayer(null);
    }

    if (Comparing.equal(myCurrentLayerName, name)) {
      setCurrentLayerSafe(myLayers.isEmpty() ? null : ContainerUtil.getFirstItem(myLayers.keySet()));
    }
  }
  return removedLayer != null;
}
 
Example 8
Source Project: consulo   Source File: ChangeListsIndexes.java    License: Apache License 2.0 6 votes vote down vote up
private void addChangeToIdx(final Change change, final VcsKey key) {
  final ContentRevision afterRevision = change.getAfterRevision();
  final ContentRevision beforeRevision = change.getBeforeRevision();
  if (afterRevision != null) {
    add(afterRevision.getFile(), change.getFileStatus(), key, beforeRevision == null ? VcsRevisionNumber.NULL : beforeRevision.getRevisionNumber());
  }
  if (beforeRevision != null) {
    if (afterRevision != null) {
      if (! Comparing.equal(beforeRevision.getFile(), afterRevision.getFile())) {
        add(beforeRevision.getFile(), FileStatus.DELETED, key, beforeRevision.getRevisionNumber());
      }
    } else {
      add(beforeRevision.getFile(), change.getFileStatus(), key, beforeRevision.getRevisionNumber());
    }
  }
}
 
Example 9
Source Project: consulo   Source File: ProjectSettingsPanel.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 10
@RequiredReadAction
@Nullable
@Override
public PsiElement resolve()
{
	return ResolveCache.getInstance(getProject()).resolveWithCaching(this, (expression, incompleteCode) ->
	{
		Ref<CSharpPreprocessorVariable> ref = Ref.create();
		collect(it ->
		{
			if(Comparing.equal(it.getName(), getElement().getText()))
			{
				ref.set(it);
				return false;
			}
			return true;
		});
		return ref.get();
	}, true, true);
}
 
Example 11
Source Project: consulo   Source File: ChangesModuleGroupingPolicy.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public ChangesBrowserNode getParentNodeFor(final StaticFilePath node, final ChangesBrowserNode rootNode) {
  if (myProject.isDefault()) return null;

  ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();

  VirtualFile vFile = node.getVf();
  if (vFile == null) {
    vFile = LocalFileSystem.getInstance().findFileByIoFile(new File(node.getPath()));
  }
  boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
  if (vFile != null && Comparing.equal(vFile, index.getContentRootForFile(vFile, hideExcludedFiles))) {
    Module module = index.getModuleForFile(vFile, hideExcludedFiles);
    return getNodeForModule(module, rootNode);
  }
  return null;
}
 
Example 12
Source Project: consulo   Source File: PsiCopyPasteManager.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
public PsiElement[] getElements(boolean[] isCopied) {
  try {
    Object transferData = myCopyPasteManager.getContents(ourDataFlavor);
    if (!(transferData instanceof MyData)) {
      return null;
    }
    MyData dataProxy = (MyData)transferData;
    if (!Comparing.equal(dataProxy, myRecentData)) {
      return null;
    }
    if (isCopied != null) {
      isCopied[0] = myRecentData.isCopied();
    }
    return myRecentData.getElements();
  }
  catch (Exception e) {
    LOG.debug(e);
    return null;
  }
}
 
Example 13
Source Project: consulo   Source File: ArrayUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Contract(pure = true)
public static <E> boolean startsWith(@Nonnull E[] array, @Nonnull E[] subArray) {
  //noinspection ArrayEquality
  if (array == subArray) {
    return true;
  }
  int length = subArray.length;
  if (array.length < length) {
    return false;
  }

  for (int i = 0; i < length; i++) {
    if (!Comparing.equal(array[i], subArray[i])) {
      return false;
    }
  }

  return true;
}
 
Example 14
Source Project: intellij-haxe   Source File: ExtractSuperBaseProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@NotNull
protected UsageInfo[] findUsages() {
  PsiReference[] refs = ReferencesSearch.search(myClass, GlobalSearchScope.projectScope(myProject), false).toArray(new PsiReference[0]);
  final ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
  detectTurnToSuperRefs(refs, result);
  final PsiPackage originalPackage = JavaDirectoryService.getInstance().getPackage(myClass.getContainingFile().getContainingDirectory());
  if (Comparing.equal(JavaDirectoryService.getInstance().getPackage(myTargetDirectory), originalPackage)) {
    result.clear();
  }
  for (final PsiReference ref : refs) {
    final PsiElement element = ref.getElement();
    if (!canTurnToSuper(element) && !RefactoringUtil.inImportStatement(ref, element)) {
      result.add(new BindToOldUsageInfo(element, ref, myClass));
    }
  }
  UsageInfo[] usageInfos = result.toArray(new UsageInfo[result.size()]);
  return UsageViewUtil.removeDuplicatedUsages(usageInfos);
}
 
Example 15
Source Project: consulo   Source File: ActionsTreeUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Condition<AnAction> isActionFiltered(final ActionManager actionManager,
                                                   final Keymap keymap,
                                                   final KeyboardShortcut keyboardShortcut) {
  return new Condition<AnAction>() {
    public boolean value(final AnAction action) {
      if (keyboardShortcut == null) return true;
      if (action == null) return false;
      final Shortcut[] actionShortcuts =
        keymap.getShortcuts(action instanceof ActionStub ? ((ActionStub)action).getId() : actionManager.getId(action));
      for (Shortcut shortcut : actionShortcuts) {
        if (shortcut instanceof KeyboardShortcut) {
          final KeyboardShortcut keyboardActionShortcut = (KeyboardShortcut)shortcut;
          if (Comparing.equal(keyboardActionShortcut, keyboardShortcut)) {
            return true;
          }
        }
      }
      return false;
    }
  };
}
 
Example 16
Source Project: consulo   Source File: TooltipController.java    License: Apache License 2.0 6 votes vote down vote up
public void showTooltip(@Nonnull Editor editor,
                        @Nonnull Point p,
                        @Nonnull TooltipRenderer tooltipRenderer,
                        boolean alignToRight,
                        @Nonnull TooltipGroup group,
                        @Nonnull HintHint hintInfo) {
  if (myCurrentTooltip == null || !myCurrentTooltip.isVisible()) {
    myCurrentTooltipObject = null;
  }

  if (Comparing.equal(tooltipRenderer, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  if (myCurrentTooltipGroup != null && group.compareTo(myCurrentTooltipGroup) < 0) return;

  p = new Point(p);
  hideCurrentTooltip();

  LightweightHint hint = tooltipRenderer.show(editor, p, alignToRight, group, hintInfo);

  myCurrentTooltipGroup = group;
  myCurrentTooltip = hint;
  myCurrentTooltipObject = tooltipRenderer;
}
 
Example 17
Source Project: dagger-intellij-plugin   Source File: ShowUsagesAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int compare(UsageNode c1, UsageNode c2) {
  if (c1 instanceof StringNode) return 1;
  if (c2 instanceof StringNode) return -1;
  Usage o1 = c1.getUsage();
  Usage o2 = c2.getUsage();
  if (o1 == MORE_USAGES_SEPARATOR) return 1;
  if (o2 == MORE_USAGES_SEPARATOR) return -1;

  VirtualFile v1 = UsageListCellRenderer.getVirtualFile(o1);
  VirtualFile v2 = UsageListCellRenderer.getVirtualFile(o2);
  String name1 = v1 == null ? null : v1.getName();
  String name2 = v2 == null ? null : v2.getName();
  int i = Comparing.compare(name1, name2);
  if (i != 0) return i;

  if (o1 instanceof Comparable && o2 instanceof Comparable) {
    return ((Comparable) o1).compareTo(o2);
  }

  FileEditorLocation loc1 = o1.getLocation();
  FileEditorLocation loc2 = o2.getLocation();
  return Comparing.compare(loc1, loc2);
}
 
Example 18
Source Project: consulo   Source File: AbstractTestTreeBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public void setStatisticsComparator(TestConsoleProperties properties, boolean sortByStatistics) {
  if (!sortByStatistics) {
    setTestsComparator(TestConsoleProperties.SORT_ALPHABETICALLY.value(properties));
  }
  else {
    setNodeDescriptorComparator(new Comparator<NodeDescriptor>() {
      @Override
      public int compare(NodeDescriptor o1, NodeDescriptor o2) {
        if (o1.getParentDescriptor() == o2.getParentDescriptor() &&
            o1 instanceof BaseTestProxyNodeDescriptor &&
            o2 instanceof BaseTestProxyNodeDescriptor) {
          final Long d1 = ((BaseTestProxyNodeDescriptor)o1).getElement().getDuration();
          final Long d2 = ((BaseTestProxyNodeDescriptor)o2).getElement().getDuration();
          return Comparing.compare(d2, d1);
        }
        return 0;
      }
    });
  }
  queueUpdate();
}
 
Example 19
private static Collection<? extends PackagingSourceItem> createModuleItems(ArtifactEditorContext editorContext, Artifact artifact,
                                                                           @Nonnull String[] groupPath) {
  final Module[] modules = editorContext.getModulesProvider().getModules();
  final List<PackagingSourceItem> items = new ArrayList<PackagingSourceItem>();
  Set<String> groups = new HashSet<String>();
  for (Module module : modules) {
    String[] path = ModuleManager.getInstance(editorContext.getProject()).getModuleGroupPath(module);
    if (path == null) {
      path = ArrayUtil.EMPTY_STRING_ARRAY;
    }

    if (Comparing.equal(path, groupPath)) {
      items.add(new ModuleSourceItemGroup(module));
    }
    else if (ArrayUtil.startsWith(path, groupPath)) {
      groups.add(path[groupPath.length]);
    }
  }
  for (String group : groups) {
    items.add(0, new ModuleGroupItem(ArrayUtil.append(groupPath, group)));
  }
  return items;
}
 
Example 20
Source Project: consulo   Source File: ExternalizablePropertyContainer.java    License: Apache License 2.0 6 votes vote down vote up
public void writeExternal(@Nonnull Element element) {
  if (myExternalizers.isEmpty()) {
    return;
  }

  List<AbstractProperty> properties = new ArrayList<AbstractProperty>(myExternalizers.keySet());
  Collections.sort(properties, AbstractProperty.NAME_COMPARATOR);
  for (AbstractProperty property : properties) {
    Externalizer externalizer = myExternalizers.get(property);
    if (externalizer == null) {
      continue;
    }

    Object propValue = property.get(this);
    if (!Comparing.equal(propValue, property.getDefault(this))) {
      Element child = new Element(property.getName());
      externalizer.writeValue(child, propValue);
      if (!JDOMUtil.isEmpty(child)) {
        element.addContent(child);
      }
    }
  }
}
 
Example 21
Source Project: consulo   Source File: ShowCoveringTestsAction.java    License: Apache License 2.0 6 votes vote down vote up
private void extractTests(final File traceFile, final DataInputStream in, final Set<String> tests) throws IOException {
  long traceSize = in.readInt();
  for (int i = 0; i < traceSize; i++) {
    final String className = in.readUTF();
    final int linesSize = in.readInt();
    for(int l = 0; l < linesSize; l++) {
      final int line = in.readInt();
      if (Comparing.strEqual(className, myClassFQName)) {
        if (myLineData.getLineNumber() == line) {
          tests.add(FileUtil.getNameWithoutExtension(traceFile));
          return;
        }
      }
    }
  }
}
 
Example 22
Source Project: consulo   Source File: DeployToServerSettingsEditor.java    License: Apache License 2.0 6 votes vote down vote up
private void onDeploymentSourceChanged(@javax.annotation.Nullable D configuration) {
  DeploymentSource selected = mySourceListModel.getSelectedItem();
  if (Comparing.equal(selected, myLastSelection)) {
    if (configuration != null && myDeploymentSettingsEditor != null) {
      myDeploymentSettingsEditor.resetFrom(configuration);
    }
    return;
  }

  updateBeforeRunOptions(myLastSelection, false);
  updateBeforeRunOptions(selected, true);
  myDeploymentSettingsComponent.removeAll();
  myDeploymentSettingsEditor = myDeploymentConfigurator.createEditor(selected);
  if (myDeploymentSettingsEditor != null) {
    Disposer.register(this, myDeploymentSettingsEditor);
    myDeploymentSettingsComponent.add(BorderLayout.CENTER, myDeploymentSettingsEditor.getComponent());
    if (configuration != null) {
      myDeploymentSettingsEditor.resetFrom(configuration);
    }
  }
  myLastSelection = selected;
}
 
Example 23
public void updateDataModel() {
    String endpointURL = this.customRadioButton.isSelected() ? this.endpointURL.getText() : QUARKUS_CODE_URL;
    if (!Comparing.strEqual(this.wizardContext.getUserData(QuarkusConstants.WIZARD_ENDPOINT_URL_KEY), endpointURL)) {
        this.endpointURL.addCurrentTextToHistory();
        this.wizardContext.putUserData(QuarkusConstants.WIZARD_ENDPOINT_URL_KEY, endpointURL);
        PropertiesComponent.getInstance().setValue(LAST_ENDPOINT_URL, endpointURL);
    }
}
 
Example 24
Source Project: consulo   Source File: PsiAwareFileEditorManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void doChangeInUI(final PsiTreeChangeEvent event) {
  final PsiFile psiFile = event.getFile();
  if (psiFile == null) return;
  VirtualFile file = psiFile.getVirtualFile();
  if (file == null) return;
  FileEditor[] editors = getAllEditors(file);
  if (editors.length == 0) return;

  final VirtualFile currentFile = getCurrentFile();
  if (currentFile != null && Comparing.equal(psiFile.getVirtualFile(), currentFile)) {
    updateFileIcon(currentFile);
  }
}
 
Example 25
Source Project: consulo   Source File: TabInfo.java    License: Apache License 2.0 5 votes vote down vote up
public TabInfo setTooltipText(final String text) {
  String old = myTooltipText;
  if (!Comparing.equal(old, text)) {
    myTooltipText = text;
    myChangeSupport.firePropertyChange(TEXT, old, myTooltipText);
  }
  return this;
}
 
Example 26
Source Project: consulo   Source File: ExtensionCheckedTreeNode.java    License: Apache License 2.0 5 votes vote down vote up
public ExtensionCheckedTreeNode(@Nullable ModuleExtensionProviderEP providerEP,
                                @Nonnull ModuleConfigurationState state,
                                ExtensionEditor extensionEditor) {
  super(null);
  myProviderEP = providerEP;
  myState = state;
  myExtensionEditor = extensionEditor;

  String parentKey = null;
  if (providerEP != null) {
    parentKey = providerEP.key;

    final ModifiableRootModel model = state.getRootModel();
    if (model != null) {
      myExtension = model.getExtensionWithoutCheck(providerEP.getKey());
    }
  }

  setAllowsChildren(true);
  Vector<TreeNode> child = new Vector<>();
  for (ModuleExtensionProviderEP ep : ModuleExtensionProviders.getProviders()) {
    if (Comparing.equal(ep.parentKey, parentKey)) {
      final ExtensionCheckedTreeNode e = new ExtensionCheckedTreeNode(ep, state, myExtensionEditor);
      e.setParent(this);

      child.add(e);
    }
  }
  Collections.sort(child, ExtensionProviderEPComparator.INSTANCE);
  setUserObject(myExtension);
  // at java 9 children is Vector<TreeNode>()
  //noinspection Convert2Diamond
  children = child.isEmpty() ? null : child;
}
 
Example 27
Source Project: consulo   Source File: ProjectViewNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected boolean hasProblemFileBeneath() {
  if (!Registry.is("projectView.showHierarchyErrors")) return false;

  return WolfTheProblemSolver.getInstance(getProject()).hasProblemFilesBeneath(new Condition<VirtualFile>() {
    @Override
    public boolean value(final VirtualFile virtualFile) {
      return contains(virtualFile)
             // in case of flattened packages, when package node a.b.c contains error file, node a.b might not.
             && (getValue() instanceof PsiElement && Comparing.equal(PsiUtilBase.getVirtualFile((PsiElement)getValue()), virtualFile) || someChildContainsFile(virtualFile));
    }
  });
}
 
Example 28
Source Project: consulo   Source File: RangeHighlighterImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setErrorStripeMarkColor(Color color) {
  boolean oldRenderedInScrollBar = isRenderedInScrollBar();
  if (color == null) color = NULL_COLOR;
  Color old = myErrorStripeColor;
  myErrorStripeColor = color;
  if (isRenderedInScrollBar() != oldRenderedInScrollBar) {
    myModel.treeFor(this).updateRenderedFlags(this);
  }
  if (!Comparing.equal(old, color)) {
    fireChanged(false, false);
  }
}
 
Example 29
Source Project: consulo   Source File: PlatformTestUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Comparator<AbstractTreeNode> createComparator(final Queryable.PrintInfo printInfo) {
  return new Comparator<AbstractTreeNode>() {
    @Override
    public int compare(final AbstractTreeNode o1, final AbstractTreeNode o2) {
      String displayText1 = o1.toTestString(printInfo);
      String displayText2 = o2.toTestString(printInfo);
      return Comparing.compare(displayText1, displayText2);
    }
  };
}
 
Example 30
Source Project: consulo   Source File: ToolsImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public HighlightDisplayLevel getLevel(final NamedScope scope, Project project) {
  if (myTools != null && scope != null){
    for (ScopeToolState state : myTools) {
      if (Comparing.equal(state.getScope(project), scope)) {
        return state.getLevel();
      }
    }
  }
  return myDefaultState.getLevel();
}