OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 3620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 // cycle. An added edge which points to another node within the cycle | 3631 // cycle. An added edge which points to another node within the cycle |
3632 // only invalidates the cycle. An added edge which points to a node earlier | 3632 // only invalidates the cycle. An added edge which points to a node earlier |
3633 // in the topological sort of cycles induces no invalidation (since there | 3633 // in the topological sort of cycles induces no invalidation (since there |
3634 // are by definition no back edges from earlier cycles in the topological | 3634 // are by definition no back edges from earlier cycles in the topological |
3635 // order, and hence no possible cycle can have been introduced. The only | 3635 // order, and hence no possible cycle can have been introduced. The only |
3636 // remaining case is that we have added an edge to a node which is later | 3636 // remaining case is that we have added an edge to a node which is later |
3637 // in the topological sort of cycles. This can induce cycles, since it | 3637 // in the topological sort of cycles. This can induce cycles, since it |
3638 // represents a new back edge. It would be sufficient to invalidate the | 3638 // represents a new back edge. It would be sufficient to invalidate the |
3639 // cycle information for all nodes that are between the target and the | 3639 // cycle information for all nodes that are between the target and the |
3640 // node in the topological order. For simplicity, we simply invalidate | 3640 // node in the topological order. For simplicity, we simply invalidate |
3641 // all nodes which are reachable from the the source node. | 3641 // all nodes which are reachable from the source node. |
3642 // Note that in the invalidation phase, we do not cut off when we encounter | 3642 // Note that in the invalidation phase, we do not cut off when we encounter |
3643 // a node with no library cycle information, since we do not know whether | 3643 // a node with no library cycle information, since we do not know whether |
3644 // we are in the case where invalidation has already been performed, or we | 3644 // we are in the case where invalidation has already been performed, or we |
3645 // are in the case where library cycles have simply never been computed from | 3645 // are in the case where library cycles have simply never been computed from |
3646 // a newly reachable node. | 3646 // a newly reachable node. |
3647 Set<LibraryElementImpl> active = new HashSet(); | 3647 Set<LibraryElementImpl> active = new HashSet(); |
3648 void invalidate(LibraryElement element) { | 3648 void invalidate(LibraryElement element) { |
3649 LibraryElementImpl library = | 3649 LibraryElementImpl library = |
3650 element is LibraryElementHandle ? element.actualElement : element; | 3650 element is LibraryElementHandle ? element.actualElement : element; |
3651 if (active.add(library)) { | 3651 if (active.add(library)) { |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4986 | 4986 |
4987 @override | 4987 @override |
4988 void visitElement(Element element) { | 4988 void visitElement(Element element) { |
4989 int offset = element.nameOffset; | 4989 int offset = element.nameOffset; |
4990 if (offset != -1) { | 4990 if (offset != -1) { |
4991 map[offset] = element; | 4991 map[offset] = element; |
4992 } | 4992 } |
4993 super.visitElement(element); | 4993 super.visitElement(element); |
4994 } | 4994 } |
4995 } | 4995 } |
OLD | NEW |