/** * Returns the previous sibling of the PSI element. * * @return the previous sibling, or null if the node is the first in the list of siblings. */ @Override public PsiElement getPrevSibling() { @SuppressWarnings("ConstantConditions") final PsiElement[] siblings = getParent().getChildren(); final int i = ArrayUtil.indexOf(siblings, this); PsiElement prevSibling; if (i < 1) { prevSibling = null; } else { prevSibling = siblings[i - 1]; } return prevSibling; }
/** * Returns the next sibling of the PSI element. * * @return the next sibling, or null if the node is the last in the list of siblings. */ @Override public PsiElement getNextSibling() { @SuppressWarnings("ConstantConditions") final PsiElement[] siblings = getParent().getChildren(); final int i = ArrayUtil.indexOf(siblings, this); PsiElement nextSibling; if (i < 0 || i >= siblings.length - 1) { nextSibling = null; } else { nextSibling = siblings[i + 1]; } return nextSibling; }
@Contract(pure=true) public static int indexOf(@NotNull Object[] objects, @Nullable Object object) { return indexOf(objects, object, 0, objects.length); }
@Contract(pure=true) public static <T> boolean contains(@Nullable final T o, @NotNull T... objects) { return indexOf(objects, o) >= 0; }
@Contract(pure=true) public static int find(@NotNull int[] src, int obj) { return indexOf(src, obj); }
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") static <T> void executeActionWithRecursiveGuard(@NotNull T object, @NotNull List<T> recursiveGuard, @NotNull final ObjectTreeAction<T> action) { synchronized (recursiveGuard) { if (ArrayUtil.indexOf(recursiveGuard, object, ContainerUtil.<T>identityStrategy()) != -1) return; recursiveGuard.add(object); } try { action.execute(object); } finally { synchronized (recursiveGuard) { int i = ArrayUtil.lastIndexOf(recursiveGuard, object, ContainerUtil.<T>identityStrategy()); assert i != -1; recursiveGuard.remove(i); } } }
} else { for (String path : pluginClassPaths) { if (ArrayUtil.indexOf(arguments.getPluginClasspaths(), path) < 0) { arguments.setPluginClasspaths(ArrayUtil.append(arguments.getPluginClasspaths(), path));