Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2848)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java

Issue 594843006: Fix for issue 14497 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver2.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java
index a5e5ec4fc59b36b9d537efc01e82625efd36a12f..a0a6404558f3a9362bdfb3865b5176b5bd19b96b 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver.java
@@ -16,8 +16,10 @@ package com.google.dart.engine.internal.resolver;
import com.google.dart.engine.AnalysisEngine;
import com.google.dart.engine.ast.Combinator;
import com.google.dart.engine.ast.CompilationUnit;
+import com.google.dart.engine.ast.CompilationUnitMember;
import com.google.dart.engine.ast.Directive;
import com.google.dart.engine.ast.ExportDirective;
+import com.google.dart.engine.ast.FunctionTypeAlias;
import com.google.dart.engine.ast.HideCombinator;
import com.google.dart.engine.ast.ImportDirective;
import com.google.dart.engine.ast.NamespaceDirective;
@@ -26,6 +28,7 @@ import com.google.dart.engine.ast.ShowCombinator;
import com.google.dart.engine.ast.SimpleIdentifier;
import com.google.dart.engine.ast.StringInterpolation;
import com.google.dart.engine.ast.StringLiteral;
+import com.google.dart.engine.ast.TypeAlias;
import com.google.dart.engine.ast.UriBasedDirective;
import com.google.dart.engine.context.AnalysisException;
import com.google.dart.engine.element.Element;
@@ -66,6 +69,7 @@ import com.google.dart.engine.utilities.io.UriUtilities;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
/**
@@ -76,6 +80,28 @@ import java.util.Set;
*/
public class LibraryResolver {
/**
+ * Instances of the class {@code TypeAliasInfo} hold information about a {@link TypeAlias}.
+ */
+ private static class TypeAliasInfo {
+ private Library library;
+ private Source source;
+ private FunctionTypeAlias typeAlias;
+
+ /**
+ * Initialize a newly created information holder with the given information.
+ *
+ * @param library the library containing the type alias
+ * @param source the source of the file containing the type alias
+ * @param typeAlias the type alias being remembered
+ */
+ public TypeAliasInfo(Library library, Source source, FunctionTypeAlias typeAlias) {
+ this.library = library;
+ this.source = source;
+ this.typeAlias = typeAlias;
+ }
+ }
+
+ /**
* The analysis context in which the libraries are being analyzed.
*/
private InternalAnalysisContext analysisContext;
@@ -211,6 +237,7 @@ public class LibraryResolver {
buildDirectiveModels();
instrumentation.metric("buildDirectiveModels", "complete");
typeProvider = new TypeProviderImpl(coreElement);
+ buildTypeAliases();
buildTypeHierarchies();
instrumentation.metric("buildTypeHierarchies", "complete");
//
@@ -298,6 +325,7 @@ public class LibraryResolver {
instrumentation.metric("buildDirectiveModels", "complete");
typeProvider = new TypeProviderImpl(coreElement);
buildEnumMembers();
+ buildTypeAliases();
buildTypeHierarchies();
instrumentation.metric("buildTypeHierarchies", "complete");
//
@@ -583,6 +611,40 @@ public class LibraryResolver {
}
/**
+ * Resolve the types referenced by function type aliases across all of the function type aliases
+ * defined in the current cycle.
+ *
+ * @throws AnalysisException if any of the function type aliases could not be resolved
+ */
+ private void buildTypeAliases() throws AnalysisException {
+ TimeCounterHandle timeCounter = PerformanceStatistics.resolve.start();
+ try {
+ List<TypeAliasInfo> typeAliases = new ArrayList<TypeAliasInfo>();
+ for (Library library : librariesInCycles) {
+ for (Source source : library.getCompilationUnitSources()) {
+ CompilationUnit ast = library.getAST(source);
+ for (CompilationUnitMember member : ast.getDeclarations()) {
+ if (member instanceof FunctionTypeAlias) {
+ typeAliases.add(new TypeAliasInfo(library, source, (FunctionTypeAlias) member));
+ }
+ }
+ }
+ }
+ // TODO(brianwilkerson) We need to sort the type aliases such that all aliases referenced by
+ // an alias T are resolved before we resolve T.
+ for (TypeAliasInfo info : typeAliases) {
+ TypeResolverVisitor visitor = new TypeResolverVisitor(
+ info.library,
+ info.source,
+ typeProvider);
+ info.typeAlias.accept(visitor);
+ }
+ } finally {
+ timeCounter.stop();
+ }
+ }
+
+ /**
* Resolve the type hierarchy across all of the types declared in the libraries in the current
* cycle.
*
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/LibraryResolver2.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698