Java Code Examples for com.intellij.util.ArrayUtil#EMPTY_INT_ARRAY

The following examples show how to use com.intellij.util.ArrayUtil#EMPTY_INT_ARRAY . 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 File: ModuleExtensionIndexCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static int[] get(@Nonnull Class<?> clazz) {
  if (ourClassCache == null) {
    throw new IllegalArgumentException("Calling #get() without initializing.");
  }

  int[] ints = ourClassCache.get(clazz);
  return ints == null ? ArrayUtil.EMPTY_INT_ARRAY : ints;
}
 
Example 2
Source File: LowLevelSearchUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
static int[] getTextOccurrencesInScope(@Nonnull PsiElement scope, @Nonnull StringSearcher searcher, ProgressIndicator progress) {
  if (progress != null) progress.checkCanceled();

  PsiFile file = scope.getContainingFile();
  FileViewProvider viewProvider = file.getViewProvider();
  final CharSequence buffer = viewProvider.getContents();

  TextRange range = scope.getTextRange();
  if (range == null) {
    LOG.error("Element " + scope + " of class " + scope.getClass() + " has null range");
    return ArrayUtil.EMPTY_INT_ARRAY;
  }

  int startOffset = range.getStartOffset();
  int endOffset = range.getEndOffset();
  if (endOffset > buffer.length()) {
    diagnoseInvalidRange(scope, file, viewProvider, buffer, range);
    return ArrayUtil.EMPTY_INT_ARRAY;
  }

  int[] offsets = getTextOccurrences(buffer, startOffset, endOffset, searcher, progress);
  for (int i = 0; i < offsets.length; i++) {
    offsets[i] -= startOffset;
  }
  return offsets;
}
 
Example 3
Source File: PaintersHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
int[] computeOffsets(Graphics gg, @Nonnull JComponent component) {
  if (myPainters.isEmpty()) return ArrayUtil.EMPTY_INT_ARRAY;
  int i = 0;
  int[] offsets = new int[2 + myPainters.size() * 2];
  // store current graphics transform
  Graphics2D g = (Graphics2D)gg;
  AffineTransform tx = g.getTransform();
  // graphics tx offsets include graphics scale
  offsets[i++] = (int)tx.getTranslateX();
  offsets[i++] = (int)tx.getTranslateY();
  // calculate relative offsets for painters
  Rectangle r = null;
  Component prev = null;
  for (Painter painter : myPainters) {
    if (!painter.needsRepaint()) continue;

    Component cur = myPainter2Component.get(painter);
    if (cur != prev || r == null) {
      Container curParent = cur.getParent();
      if (curParent == null) continue;
      r = SwingUtilities.convertRectangle(curParent, cur.getBounds(), component);
      prev = cur;
    }
    // component offsets don't include graphics scale, so compensate
    offsets[i++] = (int)(r.x * tx.getScaleX());
    offsets[i++] = (int)(r.y * tx.getScaleY());
  }
  return offsets;
}
 
Example 4
Source File: TrailingSpacesStripper.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void clearLineModificationFlags(@Nonnull Document document) {
  if (document instanceof DocumentWindow) {
    document = ((DocumentWindow)document).getDelegate();
  }
  if (!(document instanceof DocumentImpl)) {
    return;
  }

  Editor activeEditor = getActiveEditor(document);

  // when virtual space enabled, we can strip whitespace anywhere
  boolean isVirtualSpaceEnabled = activeEditor == null || activeEditor.getSettings().isVirtualSpace();

  final EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
  if (settings == null) return;

  boolean enabled = !Boolean.TRUE.equals(DISABLE_FOR_FILE_KEY.get(FileDocumentManager.getInstance().getFile(document)));
  if (!enabled) return;
  String stripTrailingSpaces = settings.getStripTrailingSpaces();
  final boolean doStrip = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
  final boolean inChangedLinesOnly = !stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);

  int[] caretLines;
  if (activeEditor != null && inChangedLinesOnly && doStrip && !isVirtualSpaceEnabled) {
    List<Caret> carets = activeEditor.getCaretModel().getAllCarets();
    caretLines = new int[carets.size()];
    for (int i = 0; i < carets.size(); i++) {
      Caret caret = carets.get(i);
      caretLines[i] = caret.getLogicalPosition().line;
    }
  }
  else {
    caretLines = ArrayUtil.EMPTY_INT_ARRAY;
  }
  ((DocumentImpl)document).clearLineModificationFlagsExcept(caretLines);
}
 
Example 5
Source File: IntToIntSetMap.java    From consulo with Apache License 2.0 5 votes vote down vote up
public int[] get(int key) {
  if (mySingle.containsKey(key)) {
    return new int[]{mySingle.get(key)};
  }
  TIntHashSet items = myMulti.get(key);
  if (items == null) return ArrayUtil.EMPTY_INT_ARRAY;
  return items.toArray();
}
 
Example 6
Source File: MessageBusImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MessageBusImpl(@Nonnull InjectingContainerOwner owner) {
  myOwner = owner;
  myConnectionDisposable = Disposable.newDisposable(myOwner.toString());
  myOrder = ArrayUtil.EMPTY_INT_ARRAY;
  myRootBus = (RootBus)this;
  myLazyConnection = connect();
}
 
Example 7
Source File: EmptyIntHashSet.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public int[] toArray() {
  return ArrayUtil.EMPTY_INT_ARRAY;
}
 
Example 8
Source File: TableSorter.java    From consulo with Apache License 2.0 4 votes vote down vote up
public TableSorter() {
  indexes = ArrayUtil.EMPTY_INT_ARRAY; // for consistency
}
 
Example 9
Source File: SEListSelectionTracker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private int[] calcIndicesToSelect() {
  List<Object> items = myListModel.getItems();
  if (items.isEmpty()) return ArrayUtil.EMPTY_INT_ARRAY;

  return IntStream.range(0, items.size()).filter(i -> mySelectedItems.contains(items.get(i))).toArray();
}