| Index: lib/compiler/implementation/elements/elements.dart
|
| diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
|
| index 0b9fca1014c852c45d5715f9bc5717251d906b35..5b7d44a8cf864a98fb83b98061e87280bd83addf 100644
|
| --- a/lib/compiler/implementation/elements/elements.dart
|
| +++ b/lib/compiler/implementation/elements/elements.dart
|
| @@ -96,7 +96,7 @@ class ElementKind {
|
| toString() => id;
|
| }
|
|
|
| -class Element implements Hashable {
|
| +class Element implements Comparable, Hashable {
|
| final SourceString name;
|
| final ElementKind kind;
|
| final Element enclosingElement;
|
| @@ -156,6 +156,23 @@ class Element implements Hashable {
|
| // the same hash code. Replace this with a simple id in the element?
|
| int hashCode() => name.hashCode();
|
|
|
| + /** Two elements are compared first according to their library name, then
|
| + * by their position in the source. */
|
| + int compareTo(Element other) {
|
| + SourceString lib1Name = this.getLibrary().name;
|
| + SourceString lib2Name = other.getLibrary().name;
|
| + int libComparison = lib1Name.compareTo(lib2Name);
|
| + if (libComparison != 0) return libComparison;
|
| + SourceString compilationUnitName1 = this.getCompilationUnit().name;
|
| + SourceString compilationUnitName2 = other.getCompilationUnit().name;
|
| + int compilationUnitComparison =
|
| + compilationUnitName1.compareTo(compilationUnitName2);
|
| + if (compilationUnitComparison != 0) return compilationUnitComparison;
|
| + int charOffset1 = this.position().charOffset;
|
| + int charOffset2 = other.position().charOffset;
|
| + return charOffset1.compareTo(charOffset2);
|
| + }
|
| +
|
| CompilationUnitElement getCompilationUnit() {
|
| Element element = this;
|
| while (element !== null && !element.isCompilationUnit()) {
|
|
|