| Index: compiler/java/com/google/dart/compiler/ast/LibraryImport.java
|
| diff --git a/compiler/java/com/google/dart/compiler/ast/LibraryImport.java b/compiler/java/com/google/dart/compiler/ast/LibraryImport.java
|
| index e14f6c8be314b3dc0224b21855e30c89401f1151..e6f32f557768403c2c508d200b7b0ed18bd334b3 100644
|
| --- a/compiler/java/com/google/dart/compiler/ast/LibraryImport.java
|
| +++ b/compiler/java/com/google/dart/compiler/ast/LibraryImport.java
|
| @@ -5,17 +5,28 @@
|
| package com.google.dart.compiler.ast;
|
|
|
| import com.google.common.base.Objects;
|
| +import com.google.common.collect.Sets;
|
| +
|
| +import java.util.List;
|
| +import java.util.Set;
|
|
|
| /**
|
| * Information about import - prefix and {@link LibraryUnit}.
|
| */
|
| public class LibraryImport {
|
| - private final String prefix;
|
| private final LibraryUnit library;
|
| + private final String prefix;
|
| + private final Set<String> showNames;
|
| + private final Set<String> hideNames;
|
| + private final boolean exported;
|
|
|
| - public LibraryImport(String prefix, LibraryUnit library) {
|
| - this.prefix = prefix;
|
| + public LibraryImport(LibraryUnit library, String prefix, List<ImportCombinator> combinators,
|
| + boolean exported) {
|
| this.library = library;
|
| + this.prefix = prefix;
|
| + this.showNames = createCombinatorsSet(combinators, true);
|
| + this.hideNames = createCombinatorsSet(combinators, false);
|
| + this.exported = exported;
|
| }
|
|
|
| @Override
|
| @@ -27,16 +38,57 @@ public class LibraryImport {
|
| public boolean equals(Object obj) {
|
| if (obj instanceof LibraryImport) {
|
| LibraryImport other = (LibraryImport) obj;
|
| - return Objects.equal(prefix, other.prefix) && Objects.equal(library, other.library);
|
| + return Objects.equal(library, other.library) && Objects.equal(prefix, other.prefix)
|
| + && Objects.equal(showNames, other.showNames) && Objects.equal(hideNames, other.hideNames)
|
| + && exported == other.exported;
|
| }
|
| return false;
|
| }
|
|
|
| + public LibraryUnit getLibrary() {
|
| + return library;
|
| + }
|
| +
|
| public String getPrefix() {
|
| return prefix;
|
| }
|
| +
|
| + public boolean isVisible(String name) {
|
| + if (hideNames.contains(name)) {
|
| + return false;
|
| + }
|
| + if (!showNames.isEmpty()) {
|
| + return showNames.contains(name);
|
| + }
|
| + return true;
|
| + }
|
|
|
| - public LibraryUnit getLibrary() {
|
| - return library;
|
| + public boolean isExported() {
|
| + return exported;
|
| + }
|
| +
|
| + private static Set<String> createCombinatorsSet(List<ImportCombinator> combinators, boolean show) {
|
| + Set<String> result = Sets.newHashSet();
|
| + for (ImportCombinator combinator : combinators) {
|
| + // show
|
| + if (show && combinator instanceof ImportShowCombinator) {
|
| + ImportShowCombinator showCombinator = (ImportShowCombinator) combinator;
|
| + for (DartIdentifier showName : showCombinator.getShownNames()) {
|
| + if (showName != null) {
|
| + result.add(showName.getName());
|
| + }
|
| + }
|
| + }
|
| + // hide
|
| + if (!show && combinator instanceof ImportHideCombinator) {
|
| + ImportHideCombinator hideCombinator = (ImportHideCombinator) combinator;
|
| + for (DartIdentifier hideName : hideCombinator.getHiddenNames()) {
|
| + if (hideName != null) {
|
| + result.add(hideName.getName());
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return result;
|
| }
|
| }
|
|
|