Java Code Examples for com.intellij.util.ArrayUtil#newIntArray()
The following examples show how to use
com.intellij.util.ArrayUtil#newIntArray() .
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: LogicalPositionCache.java From consulo with Apache License 2.0 | 5 votes |
private static LineData create(@Nonnull Document document, int line, int tabSize) { int start = document.getLineStartOffset(line); int end = document.getLineEndOffset(line); int cacheSize = (end - start) / CACHE_FREQUENCY; int[] cache = ArrayUtil.newIntArray(cacheSize); CharSequence text = document.getImmutableCharSequence(); int column = 0; boolean hasTabsOrSurrogates = false; for (int i = start; i < end; i++) { if (i > start && (i - start) % CACHE_FREQUENCY == 0) { cache[(i - start) / CACHE_FREQUENCY - 1] = column; } char c = text.charAt(i); if (c == '\t') { column = (column / tabSize + 1) * tabSize; hasTabsOrSurrogates = true; } else { if (Character.isHighSurrogate(c)) { hasTabsOrSurrogates = true; if (i + 1 < text.length() && Character.isLowSurrogate(text.charAt(i + 1))) continue; } else { hasTabsOrSurrogates |= Character.isLowSurrogate(c); } column++; } } if (cacheSize > 0 && (end - start) % CACHE_FREQUENCY == 0) cache[cacheSize - 1] = column; return hasTabsOrSurrogates ? new LineData(cache) : TRIVIAL; }
Example 2
Source File: FoldRegionsTree.java From consulo with Apache License 2.0 | 5 votes |
private void ensureInlayDataAvailable() { if (topFoldedInlaysHeightValid || !ApplicationManager.getApplication().isDispatchThread()) return; topFoldedInlaysHeightValid = true; if (hasBlockInlays()) { int count = topLevelRegions.length; topFoldedInlaysHeight = ArrayUtil.newIntArray(count); int inlaysHeightSum = 0; for (int i = 0; i < count; i++) { topFoldedInlaysHeight[i] = (inlaysHeightSum += getBlockInlaysHeight(topStartOffsets[i], topEndOffsets[i])); } } else { topFoldedInlaysHeight = null; } }
Example 3
Source File: Enumerator.java From consulo with Apache License 2.0 | 5 votes |
public int[] enumerate(T[] objects, final int startShift, final int endCut) { int[] idx = ArrayUtil.newIntArray(objects.length - startShift - endCut); for (int i = startShift; i < (objects.length - endCut); i++) { final T object = objects[i]; final int number = enumerate(object); idx[i - startShift] = number; } return idx; }