| Index: pkg/analyzer/lib/src/generated/constant.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
|
| index 445ef2c9a2e3a7132b2450670fc3967cc66f17ce..77901f8b08f0f4ed8bd9e1c232d715249167fa7f 100644
|
| --- a/pkg/analyzer/lib/src/generated/constant.dart
|
| +++ b/pkg/analyzer/lib/src/generated/constant.dart
|
| @@ -17,6 +17,7 @@ import 'element.dart';
|
| import 'resolver.dart' show TypeProvider;
|
| import 'engine.dart' show AnalysisEngine;
|
| import 'utilities_dart.dart' show ParameterKind;
|
| +import 'utilities_collection.dart' show DirectedGraph;
|
|
|
| /**
|
| * Instances of the class `ConstantEvaluator` evaluate constant expressions to produce their
|
| @@ -888,170 +889,6 @@ class ConstantVisitor extends UnifyingAstVisitor<EvaluationResultImpl> {
|
| }
|
|
|
| /**
|
| - * Instances of the class `DirectedGraph` implement a directed graph in which the nodes are
|
| - * arbitrary (client provided) objects and edges are represented implicitly. The graph will allow an
|
| - * edge from any node to any other node, including itself, but will not represent multiple edges
|
| - * between the same pair of nodes.
|
| - *
|
| - * @param N the type of the nodes in the graph
|
| - */
|
| -class DirectedGraph<N> {
|
| - /**
|
| - * The table encoding the edges in the graph. An edge is represented by an entry mapping the head
|
| - * to a set of tails. Nodes that are not the head of any edge are represented by an entry mapping
|
| - * the node to an empty set of tails.
|
| - */
|
| - Map<N, Set<N>> _edges = new Map<N, Set<N>>();
|
| -
|
| - /**
|
| - * Add an edge from the given head node to the given tail node. Both nodes will be a part of the
|
| - * graph after this method is invoked, whether or not they were before.
|
| - *
|
| - * @param head the node at the head of the edge
|
| - * @param tail the node at the tail of the edge
|
| - */
|
| - void addEdge(N head, N tail) {
|
| - //
|
| - // First, ensure that the tail is a node known to the graph.
|
| - //
|
| - Set<N> tails = _edges[tail];
|
| - if (tails == null) {
|
| - _edges[tail] = new Set<N>();
|
| - }
|
| - //
|
| - // Then create the edge.
|
| - //
|
| - tails = _edges[head];
|
| - if (tails == null) {
|
| - tails = new Set<N>();
|
| - _edges[head] = tails;
|
| - }
|
| - tails.add(tail);
|
| - }
|
| -
|
| - /**
|
| - * Add the given node to the set of nodes in the graph.
|
| - *
|
| - * @param node the node to be added
|
| - */
|
| - void addNode(N node) {
|
| - Set<N> tails = _edges[node];
|
| - if (tails == null) {
|
| - _edges[node] = new Set<N>();
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Return a list of nodes that form a cycle, or `null` if there are no cycles in this graph.
|
| - *
|
| - * @return a list of nodes that form a cycle
|
| - */
|
| - List<N> findCycle() => null;
|
| -
|
| - /**
|
| - * Return the number of nodes in this graph.
|
| - *
|
| - * @return the number of nodes in this graph
|
| - */
|
| - int get nodeCount => _edges.length;
|
| -
|
| - /**
|
| - * Return a set containing the tails of edges that have the given node as their head. The set will
|
| - * be empty if there are no such edges or if the node is not part of the graph. Clients must not
|
| - * modify the returned set.
|
| - *
|
| - * @param head the node at the head of all of the edges whose tails are to be returned
|
| - * @return a set containing the tails of edges that have the given node as their head
|
| - */
|
| - Set<N> getTails(N head) {
|
| - Set<N> tails = _edges[head];
|
| - if (tails == null) {
|
| - return new Set<N>();
|
| - }
|
| - return tails;
|
| - }
|
| -
|
| - /**
|
| - * Return `true` if this graph is empty.
|
| - *
|
| - * @return `true` if this graph is empty
|
| - */
|
| - bool get isEmpty => _edges.isEmpty;
|
| -
|
| - /**
|
| - * Remove all of the given nodes from this graph. As a consequence, any edges for which those
|
| - * nodes were either a head or a tail will also be removed.
|
| - *
|
| - * @param nodes the nodes to be removed
|
| - */
|
| - void removeAllNodes(List<N> nodes) {
|
| - for (N node in nodes) {
|
| - removeNode(node);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Remove the edge from the given head node to the given tail node. If there was no such edge then
|
| - * the graph will be unmodified: the number of edges will be the same and the set of nodes will be
|
| - * the same (neither node will either be added or removed).
|
| - *
|
| - * @param head the node at the head of the edge
|
| - * @param tail the node at the tail of the edge
|
| - * @return `true` if the graph was modified as a result of this operation
|
| - */
|
| - void removeEdge(N head, N tail) {
|
| - Set<N> tails = _edges[head];
|
| - if (tails != null) {
|
| - tails.remove(tail);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Remove the given node from this graph. As a consequence, any edges for which that node was
|
| - * either a head or a tail will also be removed.
|
| - *
|
| - * @param node the node to be removed
|
| - */
|
| - void removeNode(N node) {
|
| - _edges.remove(node);
|
| - for (Set<N> tails in _edges.values) {
|
| - tails.remove(node);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Find one node (referred to as a sink node) that has no outgoing edges (that is, for which there
|
| - * are no edges that have that node as the head of the edge) and remove it from this graph. Return
|
| - * the node that was removed, or `null` if there are no such nodes either because the graph
|
| - * is empty or because every node in the graph has at least one outgoing edge. As a consequence of
|
| - * removing the node from the graph any edges for which that node was a tail will also be removed.
|
| - *
|
| - * @return the sink node that was removed
|
| - */
|
| - N removeSink() {
|
| - N sink = _findSink();
|
| - if (sink == null) {
|
| - return null;
|
| - }
|
| - removeNode(sink);
|
| - return sink;
|
| - }
|
| -
|
| - /**
|
| - * Return one node that has no outgoing edges (that is, for which there are no edges that have
|
| - * that node as the head of the edge), or `null` if there are no such nodes.
|
| - *
|
| - * @return a sink node
|
| - */
|
| - N _findSink() {
|
| - for (N key in _edges.keys) {
|
| - if (_edges[key].isEmpty) return key;
|
| - }
|
| - return null;
|
| - }
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `ErrorResult` represent the result of evaluating an expression that
|
| * is not a valid compile time constant.
|
| */
|
|
|