public boolean visitLeave( DependencyNode node ) { parents.pop(); return true; }
/** * Creates a new postorder list generator. */ public PostorderNodeListGenerator() { visits = new Stack<Boolean>(); }
/** * Creates a clone of the specified node. * * @param node The node to clone, must not be {@code null}. * @return The cloned node, never {@code null}. */ protected DependencyNode clone( DependencyNode node ) { DefaultDependencyNode clone = new DefaultDependencyNode( node ); return clone; }
/** * Creates a shallow clone of the specified node. * * @param node The node to copy, must not be {@code null}. */ public DefaultDependencyNode( DependencyNode node ) { setDependency( node.getDependency() ); setAliases( node.getAliases() ); setRequestContext( node.getRequestContext() ); setPremanagedScope( node.getPremanagedScope() ); setPremanagedVersion( node.getPremanagedVersion() ); setRelocations( node.getRelocations() ); setRepositories( node.getRepositories() ); setVersion( node.getVersion() ); setVersionConstraint( node.getVersionConstraint() ); setData( node.getData() ); }
@Override public DependencyNode cleanupDependencyTree( final DependencyNode root ) { final CloningDependencyVisitor clonningVisitor = new CloningDependencyVisitor(); final PatternExclusionsDependencyFilter nodeFilter = new PatternExclusionsDependencyFilter( new GenericVersionScheme(), "*:*:advice" ); final FilteringDependencyVisitor filter = new FilteringDependencyVisitor( clonningVisitor, nodeFilter ); root.accept( filter ); return clonningVisitor.getRootNode(); } }
public boolean visitEnter( DependencyNode node ) { boolean recurse = true; DependencyNode clone = clones.get( node ); if ( clone == null ) { clone = clone( node ); clones.put( node, clone ); } else { recurse = false; } DependencyNode parent = parents.peek(); if ( parent == null ) { root = clone; } else { parent.getChildren().add( clone ); } parents.push( clone ); return recurse; }
@Override public boolean visitEnter( DependencyNode node ) { boolean visited = !setVisited( node ); visits.push( Boolean.valueOf( visited ) ); if ( visited ) { return false; } return true; }
@Override public String toString() { Dependency dep = getDependency(); if ( dep == null ) { return String.valueOf( getChildren() ); } return dep.toString(); }
private UnsolvableVersionConflictException newFailure( final ConflictGroup group, final Map<?, ?> conflictIds, DependencyNode root ) { DependencyFilter filter = new DependencyFilter() { public boolean accept( DependencyNode node, List<DependencyNode> parents ) { return group.key.equals( conflictIds.get( node ) ); } }; PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( filter ); root.accept( visitor ); return new UnsolvableVersionConflictException( visitor.getPaths(), group.key ); }
@Override public boolean visitEnter( DependencyNode node ) { if ( !setVisited( node ) ) { return false; } if ( node.getDependency() != null ) { nodes.add( node ); } return true; }
public boolean visitEnter( DependencyNode node ) { boolean visited = visitedNodes.put( node, Boolean.TRUE ) != null; visits.push( Boolean.valueOf( visited ) ); if ( visited ) { return false; } return visitor.visitEnter( node ); }
public boolean accept( DependencyVisitor visitor ) { if ( visitor.visitEnter( this ) ) { for ( DependencyNode child : getChildren() ) { if ( !child.accept( visitor ) ) { break; } } } return visitor.visitLeave( this ); }
protected void handleDependencyResolveFailure(DependencyNode pomNode, Dependency dependency, Exception e) throws FailedToResolveDependency { FailedToResolveDependency exception = new FailedToResolveDependency(dependency, e); if (throwExceptionsOnResolveDependencyFailure) { throw exception; } else { LOGGER.warn(exception.getMessage(), e); // lets just add the current dependency without its full dependency tree DefaultDependencyNode node = new DefaultDependencyNode(dependency); pomNode.getChildren().add(node); } }
/** * Creates a new visitor that clones the visited nodes. */ public CloningDependencyVisitor() { parents = new Stack<DependencyNode>(); clones = new IdentityHashMap<DependencyNode, DependencyNode>( 256 ); }
public boolean visitLeave( DependencyNode node ) { parents.pop(); return true; }
/** * Creates a new visitor that delegates traversal of nodes matching the given filter to the specified visitor. * * @param visitor The visitor to delegate to, must not be {@code null}. * @param filter The filter to apply, may be {@code null} to not filter. */ public FilteringDependencyVisitor( DependencyVisitor visitor, DependencyFilter filter ) { if ( visitor == null ) { throw new IllegalArgumentException( "dependency visitor not specified" ); } this.visitor = visitor; this.filter = filter; this.accepts = new Stack<Boolean>(); this.parents = new Stack<DependencyNode>(); }
/** * Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths. * * @param filter The filter used to select terminal nodes of paths to record, may be {@code null} to match any node. * @param excludeChildrenOfMatches Flag controlling whether children of matched nodes should be excluded from the * traversal, thereby ignoring any potential paths to other matching nodes beneath a matching ancestor * node. If {@code true}, all recorded paths will have only one matching node (namely the terminal node), * if {@code false} a recorded path can consist of multiple matching nodes. */ public PathRecordingDependencyVisitor( DependencyFilter filter, boolean excludeChildrenOfMatches ) { this.filter = filter; this.excludeChildrenOfMatches = excludeChildrenOfMatches; paths = new ArrayList<List<DependencyNode>>(); parents = new Stack<DependencyNode>(); }
public boolean visitLeave( DependencyNode node ) { Boolean visited = visits.pop(); if ( visited.booleanValue() ) { return true; } return visitor.visitLeave( node ); }
/** * Creates a new visitor that delegates to the specified visitor. * * @param visitor The visitor to delegate to, must not be {@code null}. */ public TreeDependencyVisitor( DependencyVisitor visitor ) { if ( visitor == null ) { throw new IllegalArgumentException( "no visitor delegate specified" ); } this.visitor = visitor; visitedNodes = new IdentityHashMap<DependencyNode, Object>( 512 ); visits = new Stack<Boolean>(); }