forked from phoedos/pmd
Fix merge
This commit is contained in:
parent
a8eae0bd9b
commit
5c2b8e0afe
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
|
||||
/**
|
||||
@ -46,4 +47,46 @@ public final class IteratorUtil {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/** Counts the items in this iterator, exhausting it. */
|
||||
public static int count(Iterator<?> it) {
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public static <T> Iterable<T> asReversed(final List<T> lst) {
|
||||
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
|
||||
ListIterator<T> li = lst.listIterator(lst.size());
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return li.hasPrevious();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return li.previous();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
li.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.stream.Collectors;
|
||||
import org.reactfx.EventStreams;
|
||||
import org.reactfx.value.Var;
|
||||
|
||||
import net.sourceforge.pmd.internal.util.IteratorUtil;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.metrics.LanguageMetricsProvider;
|
||||
@ -209,7 +210,7 @@ public class NodeInfoPanelController extends AbstractController {
|
||||
// Otherwise, when you select a node in the scope tree, since focus of the app is shifted to that
|
||||
// node, the scope hierarchy is reset and you lose the selection - even though obviously the node
|
||||
// you selected is in its own scope hierarchy so it looks buggy.
|
||||
int maxDepth = DesignerIteratorUtil.count(DesignerIteratorUtil.parentIterator(previousSelection, true));
|
||||
int maxDepth = IteratorUtil.count(DesignerIteratorUtil.parentIterator(previousSelection, true));
|
||||
rootScope.tryFindNode(previousSelection.getValue(), maxDepth)
|
||||
.ifPresent(scopeHierarchyTreeView.getSelectionModel()::select);
|
||||
}
|
||||
|
@ -71,8 +71,6 @@ public class SourceEditorController extends AbstractController {
|
||||
@FXML
|
||||
private ASTTreeView astTreeView;
|
||||
@FXML
|
||||
private ToolbarTitledPane astViewTitledPane;
|
||||
@FXML
|
||||
private HighlightLayerCodeArea<StyleLayerIds> codeEditorArea;
|
||||
@FXML
|
||||
private NodeParentageCrumbBar focusNodeParentageCrumbBar;
|
||||
|
@ -7,8 +7,6 @@ package net.sourceforge.pmd.util.fxdesigner.util;
|
||||
import static net.sourceforge.pmd.internal.util.IteratorUtil.toIterable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -25,42 +23,12 @@ public final class DesignerIteratorUtil {
|
||||
|
||||
// TODO move that into PMD core with Java 8
|
||||
|
||||
|
||||
private DesignerIteratorUtil() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Counts the items in this iterator, exhausting it. */
|
||||
public static int count(Iterator<?> it) {
|
||||
int count = 0;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public static <T> Iterable<T> asReversed(List<T> lst) {
|
||||
|
||||
return () -> new Iterator<T>() {
|
||||
|
||||
ListIterator<T> li = lst.listIterator(lst.size());
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return li.hasPrevious();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return li.previous();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean isParent(Node parent, Node child) {
|
||||
return any(parentIterator(child, false), p -> parent == p);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
package net.sourceforge.pmd.util.fxdesigner.util.controls;
|
||||
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.IteratorUtil.parentIterator;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.IteratorUtil.toIterable;
|
||||
import static net.sourceforge.pmd.internal.util.IteratorUtil.toIterable;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.DesignerIteratorUtil.parentIterator;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -111,7 +111,7 @@ public class ASTTreeView extends TreeView<Node> {
|
||||
* Returns true if the item at the given index
|
||||
* is visible in the TreeView.
|
||||
*/
|
||||
public boolean isIndexVisible(int index) {
|
||||
private boolean isIndexVisible(int index) {
|
||||
return myWrapper.isIndexVisible(index);
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
package net.sourceforge.pmd.util.fxdesigner.util.controls;
|
||||
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.IteratorUtil.asReversed;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.IteratorUtil.count;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.IteratorUtil.parentIterator;
|
||||
|
||||
import static net.sourceforge.pmd.internal.util.IteratorUtil.asReversed;
|
||||
import static net.sourceforge.pmd.internal.util.IteratorUtil.count;
|
||||
import static net.sourceforge.pmd.util.fxdesigner.util.DesignerIteratorUtil.parentIterator;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
Loading…
x
Reference in New Issue
Block a user