Version 1.10.0-dev.0.0

svn merge -r 44223:44706 https://dart.googlecode.com/svn/branches/bleeding_edge trunk


diff --git a/dart/.gitignore b/dart/.gitignore
index 917e10a..65d9dea 100644
--- a/dart/.gitignore
+++ b/dart/.gitignore

@@ -44,6 +44,9 @@
# Compiled python binaries
*.pyc

+# pydev project file.
+.pydevproject
+
# From the Mac OS X Finder
.DS_Store


diff --git a/dart/docs/language/dartLangSpec.tex b/dart/docs/language/dartLangSpec.tex
index eddcbb8..502038c 100644
--- a/dart/docs/language/dartLangSpec.tex
+++ b/dart/docs/language/dartLangSpec.tex

@@ -8,7 +8,6 @@
\newcommand{\code}[1]{{\sf #1}}
\title{Dart Programming Language  Specification \\
{\large Version 1.9}}
-%\author{The Dart Team}

% For information about Location Markers (and in particular the
% commands \LMHash and \LMLabel), see the long comment at the
@@ -40,8 +39,6 @@
\LMHash{}
A conforming implementation is permitted to provide additional APIs, but not additional syntax.

-% A claim of conformance with this Ecma Standard shall specify?
-
\section{Normative References}
\LMLabel{ecmaNormativeReferences}

@@ -1003,6 +1000,8 @@
\LMHash{}
It is a static warning if the return type of the user-declared operator \code{[]=} is explicitly declared and not \VOID{}.

+% add rationale: return in []= methods will have no effect, a the expression always returns its second argument (the RHS of the assignment, for consistency with assignment in general). So it's best to enforce this by declaring the method to be void, even though the expression that uses it returns an object with the type of the RHS, as described in \ref{assignment}.
+

\subsection{Getters}
\LMLabel{getters}
@@ -3090,7 +3089,33 @@
The static type of a function literal of the form

$(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k])$ \ASYNC{} $=> e$
-is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarrow Future<T_0>$, where $T_0$ is the static type of $e$.
+is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarrow Future<flatten(T_0)>$, where $T_0$ is the static type of $e$ and  $flatten(T)$ is defined as follows:
+
+ If $T = Future<S>$ then $flatten(T) = flatten(S)$.
+
+ Otherwise if $T <: Future$ then let $S$ be a type such that $T << Future<S>$ and for all $R$, if $T << Future<R>$ then $S << R$.
+
+\rationale{
+This ensures that $Future<S>$ is the most specific instantiation of \cd{Future} that is a super type of $T$.
+}
+
+Then $flatten(T) = S$.
+
+In any other circumstance, $flatten(T) = T$.
+
+
+
+\rationale{
+We collapse multiple layers of futures into one. If $e$ evaluates to a future $f$, the future will not invoke its \code{then()} callback until f completes to a non-future value, and so the result of an await is never a future, and the result of an async function will never have type \code{Future$<X>$} where $X$ itself is an invocation of \code{Future}.
+
+The  exception to that would be a type $X$ that extended or implemented \code{Future}. In that case, only one unwrapping takes place. As an example of why this is done, consider
+
+\cd{\CLASS{} C$<$T$>$  \IMPLEMENTS{}  Future$<$C$<$C$<$T$>>>$ \ldots }
+
+Here, a naive definition of $flatten$ diverges; there is not even a fixed point. A more sophisticated definition of $flatten$ is possible, but the existing rule deals with most realistic examples while remaining relatively simple to understand.
+
+}
+

\LMHash{}
The static type of a function literal of the form
@@ -3105,7 +3130,7 @@

$(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})$ \ASYNC{}  $=> e$

-is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightarrow Future<T_0>$, where $T_0$ is the static type of $e$.
+is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightarrow Future<flatten(T_0)>$, where $T_0$ is the static type of $e$.

\LMHash{}
The static type of a function literal of the form
@@ -3521,7 +3546,7 @@
}

\LMHash{}
-When iteration over the iterable is started, by getting an iterator $j$ from the iterable and calling \code{moveNext()} on it, execution of the body of $f$ will begin. When $f$ terminates, $j$ is positioned after its last element, so that its current value is \NULL{} and the current call to \code{moveNext()} on $j$ returns false, as will all further calls.
+When iteration over the iterable is started, by getting an iterator $j$ from the iterable and calling \code{moveNext()}, execution of the body of $f$ will begin. When $f$ terminates, $j$ is positioned after its last element, so that its current value is \NULL{} and the current call to \code{moveNext()} on $j$ returns false, as will all further calls.

Each iterator starts a separate computation. If the \SYNC* function is impure, the sequence of values yielded by each iterator may differ.

@@ -3779,7 +3804,7 @@

\LMHash{}
If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$.
-f $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, then if $g$ is a getter that forwards to a static getter, getter lookup fails.
+If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, then if $g$ is a getter that forwards to a static getter, getter lookup fails.
If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking
the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$.

@@ -4596,12 +4621,7 @@
}

\LMHash{}
-Let $flatten(T) = flatten(S)$ if $T = Future<S>$, and $T$ otherwise. The static type of $a$ is $flatten(T)$ where $T$ is the static type of $e$.
-
-\rationale{
-We collapse multiple layers of futures into one. If $e$ evaluates to a future $f$, the future will not invoke its \code{then()} callback until f completes to a non-future value, and so the result of an await is never a future, and the result of an async function will never have type \code{Future$<X>$} where $X$ itself is an invocation of \code{Future}.
-}
-
+The static type of $a$ is $flatten(T)$ (the $flatten$ function is defined in section \ref{functionExpressions}) where $T$ is the static type of $e$.

@@ -5739,7 +5759,7 @@
Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing function.

\LMHash{}
-It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \code{Future$<$flatten(T)$>$} (\ref{awaitExpressions}) may not be assigned to the declared return type of $f$.   Otherwise, it is a static type warning if $T$ may not be assigned to the declared return type of $f$.
+It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \code{Future$<$flatten(T)$>$} (\ref{functionExpressions}) may not be assigned to the declared return type of $f$.    Otherwise, it is a static type warning if $T$ may not be assigned to the declared return type of $f$.

\LMHash{}
Let $S$ be the runtime type of $o$. In checked mode:
@@ -5911,10 +5931,18 @@
}

\LMHash{}
+Otherwise, if the enclosing function $m$ is marked \ASYNC* (\ref{functions}) then the enclosing function may suspend.
+
+\rationale {
+If a \YIELD{} occurred inside an infinite loop and the enclosing function never suspended, there might not be an opportunity for consumers of the  enclosing stream to run and access the data in the stream.  The stream might then accumulate an unbounded number of elements. Such a situation is untenable. Therefore, we allow the enclosing function to be suspended when a new value is added to its associated stream. However, it is not essential (and in fact, can be quite costly) to suspend the function on every \YIELD{}. The implementation is free to decide how often to suspend the enclosing function. The only requirement is that consumers are not blocked indefinitely.
+}
+
+
+\LMHash{}
If the enclosing function $m$ is marked \SYNC* (\ref{functions}) then:
\begin{itemize}
\item
-Execution of the function $m$ immediately enclosing $s$ is suspended until the method \code{moveNext()} is invoked upon the iterator used to initiate the current invocation of $m$.
+Execution of the function $m$ immediately enclosing $s$ is suspended until the nullary method \code{moveNext()} is invoked upon the iterator used to initiate the current invocation of $m$.
\item
The current call to \code{moveNext()} returns \TRUE.
\end{itemize}
@@ -5945,27 +5973,39 @@
\end{grammar}

\LMHash{}
-Execution of a statement s of the form \code{\YIELD* $e$;}  proceeds as follows:
+Execution of a statement $s$ of the form \code{\YIELD* $e$;}  proceeds as follows:

\LMHash{}
-First, the expression $e$ is evaluated to an object $o$. If the immediately enclosing function $m$ is synchronous, then it is a dynamic error if the class of $o$ does not implement \code{Iterable}.  If $m$ asynchronous, then it is a dynamic error if the class of $o$ does not implement \code{Stream}. Next, for each element $x$ of $o$:
-\begin{itemize}
-\item
-If $m$ is marked \ASYNC* (\ref{functions}) and the stream $u$ associated with $m$ has been paused,  then execution of $m$ is suspended until $u$ is resumed or canceled.
-\item
- $x$ is added to the iterable or stream associated with $m$ in the order it appears in $o$.
- \item
-If $m$ is marked \ASYNC* and the stream $u$ associated with $m$ has been canceled, then let $c$ be the \FINALLY{} clause (\ref{try}) of the innermost enclosing try-finally statement, if any. If $c$ is defined,  let $h$ be the handler induced by $c$. If $h$ is defined, control is transferred to $h$. If $h$ is undefined, the immediately enclosing function terminates.
-\end{itemize}
+First, the expression $e$ is evaluated to an object $o$.

\LMHash{}
-If the enclosing function is marked \SYNC* (\ref{functions}) then:
-\begin{itemize}
-\item
-Execution of the function $m$ immediately enclosing $s$ is suspended until the method \code{moveNext()} is invoked upon the iterator used to initiate the current invocation of $m$.
+If the immediately enclosing function $m$ is marked \SYNC* (\ref{functions}), then:
+\begin{enumerate}
+\item It is a dynamic error if the class of $o$ does not implement \code{Iterable}.  Otherwise
+\item The method \cd{iterator} is invoked upon $o$ returning an object $i$.
+\item \label{moveNext} The \cd{moveNext} method of $i$ is invoked on it with no arguments. If \cd{moveNext} returns \FALSE{} execution of $s$ is complete. Otherwise
+\item The getter \cd{current} is invoked on $i$. If the invocation raises an exception $ex$, execution of $s$ throws $ex$. Otherwise, the result $x$ of the getter invocation is added to the iterable associated with $m$.
+Execution of the function $m$ immediately enclosing $s$ is suspended until the nullary method \code{moveNext()} is invoked upon the iterator used to initiate the current invocation of $m$, at which point execution of $s$ continues at \ref{moveNext}.
\item
The current call to \code{moveNext()} returns \TRUE.
+\end{enumerate}
+
+\LMHash{}
+If $m$ is marked \ASYNC* (\ref{functions}), then:
+\begin{itemize}
+\item  It is a dynamic error if the class of $o$ does not implement \code{Stream}. Otherwise
+\item For each element $x$ of $o$:
+\begin{itemize}
+\item
+If the stream $u$ associated with $m$ has been paused,  then execution of $m$ is suspended until $u$ is resumed or canceled.
+ \item
+If the stream $u$ associated with $m$ has been canceled, then let $c$ be the \FINALLY{} clause (\ref{try}) of the innermost enclosing try-finally statement, if any. If $c$ is defined,  let $h$ be the handler induced by $c$. If $h$ is defined, control is transferred to $h$. If $h$ is undefined, the immediately enclosing function terminates.
+\item
+Otherwise,  $x$ is added to the stream associated with $m$ in the order it appears in $o$.  The function $m$ may suspend.
\end{itemize}
+\item If the stream $o$ is done, execution of $s$ is complete.
+\end{itemize}
+

\LMHash{}
It is a compile-time error if a yield-each statement appears in a function that is not a generator function.

diff --git a/dart/editor/tools/plugins/com.google.dart.eclipse.ui/src/com/google/dart/eclipse/ui/internal/navigator/PubCacheProjectPropertyTester.java b/dart/editor/tools/plugins/com.google.dart.eclipse.ui/src/com/google/dart/eclipse/ui/internal/navigator/PubCacheProjectPropertyTester.java
index 8ba36ed..915a40c 100644

@@ -13,13 +13,16 @@
*/

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;

/**
- * A test to check if the project represents a package in the pub cache
+ * A test to check if the project represents a package in the pub cache, and is not opened as a dart
+ * project.
*/
public class PubCacheProjectPropertyTester extends PropertyTester {

@@ -30,10 +33,14 @@

if (IS_IN_PUB_CACHE.equalsIgnoreCase(property)) {
+        try {
+        } catch (CoreException e) {
+          return false;
+        }
}
}
return false;
}
-
}

diff --git a/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java b/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java
index 9796614..cbef7ea 100644

@@ -97,15 +97,22 @@
private final String returnType;

/**
+   * The type parameter list for the element. If the element doesn't have type parameters, this field
+   * will not be defined.
+   */
+  private final String typeParameters;
+
+  /**
*/
-  public Element(String kind, String name, Location location, int flags, String parameters, String returnType) {
+  public Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters) {
this.kind = kind;
this.name = name;
this.location = location;
this.flags = flags;
this.parameters = parameters;
this.returnType = returnType;
+    this.typeParameters = typeParameters;
}

@Override
@@ -118,7 +125,8 @@
ObjectUtilities.equals(other.location, location) &&
other.flags == flags &&
ObjectUtilities.equals(other.parameters, parameters) &&
-        ObjectUtilities.equals(other.returnType, returnType);
+        ObjectUtilities.equals(other.returnType, returnType) &&
+        ObjectUtilities.equals(other.typeParameters, typeParameters);
}
return false;
}
@@ -130,7 +138,8 @@
int flags = jsonObject.get("flags").getAsInt();
String parameters = jsonObject.get("parameters") == null ? null : jsonObject.get("parameters").getAsString();
String returnType = jsonObject.get("returnType") == null ? null : jsonObject.get("returnType").getAsString();
-    return new Element(kind, name, location, flags, parameters, returnType);
+    String typeParameters = jsonObject.get("typeParameters") == null ? null : jsonObject.get("typeParameters").getAsString();
+    return new Element(kind, name, location, flags, parameters, returnType, typeParameters);
}

public static List<Element> fromJsonArray(JsonArray jsonArray) {
@@ -198,6 +207,14 @@
return returnType;
}

+  /**
+   * The type parameter list for the element. If the element doesn't have type parameters, this field
+   * will not be defined.
+   */
+  public String getTypeParameters() {
+    return typeParameters;
+  }
+
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
@@ -207,6 +224,7 @@
builder.append(flags);
builder.append(parameters);
builder.append(returnType);
+    builder.append(typeParameters);
return builder.toHashCode();
}

@@ -248,6 +266,9 @@
if (returnType != null) {
}
+    if (typeParameters != null) {
+    }
return jsonObject;
}

@@ -266,7 +287,9 @@
builder.append("parameters=");
builder.append(parameters + ", ");
builder.append("returnType=");
-    builder.append(returnType);
+    builder.append(returnType + ", ");
+    builder.append("typeParameters=");
+    builder.append(typeParameters);
builder.append("]");
return builder.toString();
}

diff --git a/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/HoverInformation.java b/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/HoverInformation.java
index 5eccf91..b203bcb 100644

@@ -69,6 +69,12 @@
private final String containingLibraryName;

/**
+   * A human-readable description of the class declaring the element being referenced. This data is
+   * omitted if there is no referenced element, or if the element is not a class member.
+   */
+  private final String containingClassDescription;
+
+  /**
* The dartdoc associated with the referenced element. Other than the removal of the comment
* delimiters, including leading asterisks in the case of a block comment, the dartdoc is
* unprocessed markdown. This data is omitted if there is no referenced element, or if the element
@@ -109,11 +115,12 @@
/**
*/
-  public HoverInformation(int offset, int length, String containingLibraryPath, String containingLibraryName, String dartdoc, String elementDescription, String elementKind, String parameter, String propagatedType, String staticType) {
+  public HoverInformation(int offset, int length, String containingLibraryPath, String containingLibraryName, String containingClassDescription, String dartdoc, String elementDescription, String elementKind, String parameter, String propagatedType, String staticType) {
this.offset = offset;
this.length = length;
this.containingLibraryPath = containingLibraryPath;
this.containingLibraryName = containingLibraryName;
+    this.containingClassDescription = containingClassDescription;
this.dartdoc = dartdoc;
this.elementDescription = elementDescription;
this.elementKind = elementKind;
@@ -131,6 +138,7 @@
other.length == length &&
ObjectUtilities.equals(other.containingLibraryPath, containingLibraryPath) &&
ObjectUtilities.equals(other.containingLibraryName, containingLibraryName) &&
+        ObjectUtilities.equals(other.containingClassDescription, containingClassDescription) &&
ObjectUtilities.equals(other.dartdoc, dartdoc) &&
ObjectUtilities.equals(other.elementDescription, elementDescription) &&
ObjectUtilities.equals(other.elementKind, elementKind) &&
@@ -146,13 +154,14 @@
int length = jsonObject.get("length").getAsInt();
String containingLibraryPath = jsonObject.get("containingLibraryPath") == null ? null : jsonObject.get("containingLibraryPath").getAsString();
String containingLibraryName = jsonObject.get("containingLibraryName") == null ? null : jsonObject.get("containingLibraryName").getAsString();
+    String containingClassDescription = jsonObject.get("containingClassDescription") == null ? null : jsonObject.get("containingClassDescription").getAsString();
String dartdoc = jsonObject.get("dartdoc") == null ? null : jsonObject.get("dartdoc").getAsString();
String elementDescription = jsonObject.get("elementDescription") == null ? null : jsonObject.get("elementDescription").getAsString();
String elementKind = jsonObject.get("elementKind") == null ? null : jsonObject.get("elementKind").getAsString();
String parameter = jsonObject.get("parameter") == null ? null : jsonObject.get("parameter").getAsString();
String propagatedType = jsonObject.get("propagatedType") == null ? null : jsonObject.get("propagatedType").getAsString();
String staticType = jsonObject.get("staticType") == null ? null : jsonObject.get("staticType").getAsString();
-    return new HoverInformation(offset, length, containingLibraryPath, containingLibraryName, dartdoc, elementDescription, elementKind, parameter, propagatedType, staticType);
+    return new HoverInformation(offset, length, containingLibraryPath, containingLibraryName, containingClassDescription, dartdoc, elementDescription, elementKind, parameter, propagatedType, staticType);
}

public static List<HoverInformation> fromJsonArray(JsonArray jsonArray) {
@@ -168,6 +177,14 @@
}

/**
+   * A human-readable description of the class declaring the element being referenced. This data is
+   * omitted if there is no referenced element, or if the element is not a class member.
+   */
+  public String getContainingClassDescription() {
+    return containingClassDescription;
+  }
+
+  /**
* The name of the library in which the referenced element is declared. This data is omitted if
* there is no referenced element, or if the element is declared inside an HTML file.
*/
@@ -257,6 +274,7 @@
builder.append(length);
builder.append(containingLibraryPath);
builder.append(containingLibraryName);
+    builder.append(containingClassDescription);
builder.append(dartdoc);
builder.append(elementDescription);
builder.append(elementKind);
@@ -276,6 +294,9 @@
if (containingLibraryName != null) {
}
+    if (containingClassDescription != null) {
+    }
if (dartdoc != null) {
}
@@ -309,6 +330,8 @@
builder.append(containingLibraryPath + ", ");
builder.append("containingLibraryName=");
builder.append(containingLibraryName + ", ");
+    builder.append("containingClassDescription=");
+    builder.append(containingClassDescription + ", ");
builder.append("dartdoc=");
builder.append(dartdoc + ", ");
builder.append("elementDescription=");

diff --git a/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Occurrences.java b/dart/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Occurrences.java
index 4c39b04..db04138 100644

@@ -67,9 +67,9 @@
this.length = length;
}

-  public boolean contains(int x) {
+  public boolean containsInclusive(int x) {
for (int offset : offsets) {
-      if (offset <= x && x < offset + length) {
+      if (offset <= x && x <= offset + length) {
return true;
}
}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/analysis/model/DartProjectManager.java b/dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/analysis/model/DartProjectManager.java
index 8b797db..c44bba5 100644

@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;

import java.io.File;
@@ -105,19 +104,12 @@
List<String> includedPaths = Lists.newArrayList();
List<String> excludedPaths = Lists.newArrayList();
HashMap<String, String> packageRoots = new HashMap<String, String>();
-    for (IProject proj : root.getProjects()) {
-      try {
-        boolean hasNature = proj.isOpen() && proj.hasNature(DartCore.DART_PROJECT_NATURE);
-        if (hasNature) {
-          String projPath = proj.getLocation().toOSString();
-          File packageRoot = IPackageRootProvider.DEFAULT.getPackageRoot(proj);
-          if (packageRoot != null) {
-            packageRoots.put(projPath, packageRoot.getPath());
-          }
-        }
-      } catch (CoreException e) {
-        DartCore.logError("Failed to determine if project should be analyzed: " + proj.getName(), e);
+    for (IProject proj : DartCore.getDartProjects()) {
+      String projPath = proj.getLocation().toOSString();
+      File packageRoot = IPackageRootProvider.DEFAULT.getPackageRoot(proj);
+      if (packageRoot != null) {
+        packageRoots.put(projPath, packageRoot.getPath());
}
}
for (String path : ignoreManager.getExclusionPatterns()) {

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/util/ResourceUtil.java b/dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/util/ResourceUtil.java
index 87b0519..e9bcb9d 100644

@@ -84,7 +84,15 @@
}

/**
-   * Answer the Eclipse resource associated with the specified file or <code>null</code> if none
+   * Return the {@link IResource} associated with the given Java {@link File}.
+   * <p>
+   * If the {@link File} is an existing directory, then {@link IContainer} is returned.
+   * <p>
+   * If the {@link File} is an existing file or does not exist in the file system, then
+   * {@link IFile} is returned.
+   * <p>
+   * If the {@link File} does not represent a valid part in the workspace, then {@code null} is
+   * returned.
*/
public static IResource getResource(File file) {
if (file == null) {
@@ -98,15 +106,13 @@
}
return containers[0];
}
-    if (file.isFile()) {
-      IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-      IFile[] files = workspaceRoot.findFilesForLocationURI(file.toURI());
-      if (files.length == 0) {
-        return null;
-      }
-      return files[0];
+    // probably IFile
+    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+    IFile[] files = workspaceRoot.findFilesForLocationURI(file.toURI());
+    if (files.length == 0) {
+      return null;
}
-    return null;
+    return files[0];
}

/**

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/dartium/DartiumPackageSourceContainer.java b/dart/editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/dartium/DartiumPackageSourceContainer.java
index bac3b72..af9bde2 100644

@@ -17,6 +17,7 @@

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
@@ -44,12 +45,27 @@

@Override
public Object[] findSourceElements(String name) throws CoreException {
-    if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
-      // This class is not used with the Analysis Server.
+
+    if (!name.startsWith("package:")) {
return EMPTY;
}

-    if (!name.startsWith("package:")) {
+    if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+      UriToFileResolver resolver = DartiumDebugTarget.getActiveTarget().getUriToFileResolver();
+      String filePath = resolver.getFileForUri(name);
+      System.out.println("");
+      for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+        String projectLocation = project.getLocation().toString();
+
+        if (filePath.startsWith(projectLocation)) {
+          // /mydir/myproject/lib/lib.dart => lib/lib.dart
+          String path = filePath.substring(projectLocation.length() + 1);
+          IResource resource = project.findMember(path);
+          if (resource != null) {
+            return new Object[] {resource};
+          }
+        }
+      }
return EMPTY;
}


diff --git a/dart/editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/source/UriToFileResolver.java b/dart/editor/tools/plugins/com.google.dart.tools.debug.core/src/com/google/dart/tools/debug/core/source/UriToFileResolver.java
index c1db655..b6e2846 100644

@@ -135,8 +135,6 @@
if (url == null) {
return null;
}
-      URI uri = new URI(url);
-      String uriScheme = uri.getScheme();

// Special case Chrome extension paths.
if (url.startsWith(chromeExt)) {
@@ -146,6 +144,13 @@
}
}

+      if (url.startsWith("/")) {
+        return url;
+      }
+
+      URI uri = new URI(url);
+      String uriScheme = uri.getScheme();
+
// handle dart:lib/lib.dart in DartSdkSourceContainer,
// exclude "_patch.dart" files, they don't exist as files in sdk/lib folder
if (uri != null && "dart".equals(uriScheme)) {
@@ -155,9 +160,7 @@
}

// Handle both fully absolute path names and http: urls.
-      if (url.startsWith("/")) {
-        return url;
-      } else if (uriScheme == null) {
+      if (uriScheme == null) {
// handle relative file path
filePath = resolveRelativePath(url);
} else {

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/OmniBoxPopup.java b/dart/editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/OmniBoxPopup.java
index 6273872..ee58bd3 100644

@@ -947,8 +947,8 @@
: element;
}
}
-    close();
if (selectedElement != null) {
+      close();
handleElementSelected(text, selectedElement);
}
}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameProjectParticipant.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/rename/RenameProjectParticipant.java
index 7f07c13..9f37923 100644

@@ -14,11 +14,14 @@

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -26,6 +29,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.Change;
@@ -92,8 +96,12 @@
}

private void renamePubSpec(IProject newProject) {
+      // Analysis Server will return the required change.
+      if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+        return;
+      }
+      // do rename
IFile pubspec = newProject.getFile(DartCore.PUBSPEC_FILE_NAME);
-
if (pubspec != null) {
try {
@@ -101,7 +109,6 @@
model.setName(newName);
model.save();
} catch (Exception e) {
-
}
}
}
@@ -133,12 +140,19 @@
}

@Override
-  public Change createChange(final IProgressMonitor pm) throws CoreException,
+  public Change createChange(IProgressMonitor pm) {
+    RenameArguments arguments = getArguments();
+    String newName = arguments.getNewName();
+    return new RenameProjectFolderChange(project, newName);
+  }
+
+  @Override
+  public Change createPreChange(final IProgressMonitor pm) throws CoreException,
OperationCanceledException {
return ExecutionUtils.runObjectCore(new RunnableObjectEx<Change>() {
@Override
public Change runObject() throws Exception {
-        return createChangeEx(pm);
+        return createPreChangeEx(pm);
}
});
}
@@ -158,11 +172,28 @@
}

/**
-   * Implementation of {@link #createChange(IProgressMonitor)} which can throw any exception.
+   * Implementation of {@link #createPreChangeEx(IProgressMonitor)} which can throw any exception.
*/
-  private Change createChangeEx(IProgressMonitor pm) throws Exception {
-    RenameArguments arguments = getArguments();
-    return new RenameProjectFolderChange(project, arguments.getNewName());
+  private Change createPreChangeEx(IProgressMonitor pm) throws Exception {
+    if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+      try {
+        RenameArguments arguments = getArguments();
+        IPath fileLocation = project.getLocation();
+        String oldFile = fileLocation.toOSString();
+        String oldDir = fileLocation.removeLastSegments(1).toOSString();
+        String newName = arguments.getNewName();
+        String newFile = FilenameUtils.concat(oldDir, newName);
+        ServerMoveFileRefactoring refactoring = new ServerMoveFileRefactoring(oldFile);
+        refactoring.setNewFile(newFile);
+        if (refactoring.checkAllConditions(pm).hasError()) {
+          return null;
+        }
+        return refactoring.createChange(pm);
+      } catch (Throwable e) {
+        return null;
+      }
+    } else {
+      return null;
+    }
}
-
}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/search/ui/SearchResultPage_NEW.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/search/ui/SearchResultPage_NEW.java
index ae3d82b..59dba24 100644

@@ -780,6 +780,7 @@
}
}
calculateNumMatches(rootItem);
+      setResultsDescription(rootItem.numMatches);
// update viewer
viewer.refresh();
// update markers
@@ -922,9 +923,11 @@
private boolean filterEnabledSdk = false;
private boolean filterEnabledPotential = false;
private boolean filterEnabledProject = false;
+  private int totalCount = 0;
private int filteredCountSdk = 0;
private int filteredCountPotential = 0;
private int filteredCountProject = 0;
+  private String filtersDesc;

private static final Predicate<SearchResult> FILTER_SDK = new Predicate<SearchResult>() {
@Override
@@ -1324,10 +1327,9 @@
beforeRefresh();
// do query
List<SearchResult> results = runQuery();
-          int totalCount = results.size();
+          totalCount = results.size();
results = applyFilters(results);
// set description
-          String filtersDesc;
{
filtersDesc = "";
filtersDesc += ",   SDK: " + filteredCountSdk;
@@ -1347,8 +1349,7 @@
}
}
}
-          setContentDescription("'" + getQueryElementName() + "' - " + results.size() + " "
-              + getQueryKindName() + ",   total: " + totalCount + filtersDesc);
+          setResultsDescription(results.size());
// process query results
rootItem = buildElementItemTree(results);
itemCursor = new ItemCursor(rootItem);
@@ -1417,6 +1418,11 @@
});
}

+  private void setResultsDescription(int resultCount) {
+    setContentDescription("'" + getQueryElementName() + "' - " + resultCount + " "
+        + getQueryKindName() + ",   total: " + totalCount + filtersDesc);
+  }
+
/**
* Shows current {@link #itemCursor} state.
*/

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/DartElementImageDescriptor.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/DartElementImageDescriptor.java
index 322493c..f116766 100644

@@ -179,9 +179,10 @@

drawImage(bg, 0, 0);

+    drawOver();
drawTopRight();
-    drawBottomRight();
drawBottomLeft();
+    drawBottomRight();

}

@@ -210,6 +211,11 @@
}
}

+  private void addOverImage(ImageDescriptor desc) {
+    ImageData data = getImageData(desc);
+    drawImage(data, 0, 0);
+  }
+
private void addTopRightImage(ImageDescriptor desc, Point pos) {
ImageData data = getImageData(desc);
int x = pos.x - data.width;
@@ -273,8 +279,12 @@
if ((flags & SETTER) != 0) {
}
+  }
+
+  private void drawOver() {
+    int flags = fFlags;
if ((flags & DEPRECATED) != 0) {
}
}

@@ -298,7 +308,6 @@
if ((fFlags & CONST) != 0) {
}
-
}

private ImageData getImageData(ImageDescriptor descriptor) {

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ExtractMethodInputPage_NEW.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ExtractMethodInputPage_NEW.java
index eab4e13..7827045 100644

@@ -170,6 +170,7 @@
@Override
public void widgetSelected(SelectionEvent e) {
refactoring.setCreateGetter(((Button) e.widget).getSelection());
+          updatePreview();
}
});
layouter.perform(checkBox);

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServiceUtils_NEW.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/refactoring/ServiceUtils_NEW.java
index e3e3fe3..cd2cffa 100644

@@ -26,6 +26,7 @@
@@ -249,7 +250,11 @@
private static IFile getFile(SourceFileEdit change) {
String filePath = change.getFile();
File fileJava = new File(filePath);
-    return ResourceUtil.getFile(fileJava);
+    IFile file = ResourceUtil.getFile(fileJava);
+    if (PubCacheManager_NEW.isPubCacheResource(file)) {
+      return null;
+    }
+    return file;
}


diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/CreateFileChange.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/CreateFileChange.java
index 2ef6cab..bfe7a6b 100644

@@ -13,9 +13,7 @@
*/

@@ -76,8 +74,7 @@
// prepare IFile
final IFile newFile;
{
-      Source source = new FileBasedSource(file);
-      IResource resource = DartCore.getProjectManager().getResource(source);
+      IResource resource = ResourceUtil.getResource(file);
if (!(resource instanceof IFile)) {
return null;
}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/dart/DartServerProposal.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/dart/DartServerProposal.java
index d8cc1ff..c05976d 100644

@@ -166,7 +166,37 @@
private static String CSS_STYLES;
private final static char[] TRIGGERS = new char[] {
' ', '\t', '.', ',', ';', '(', '[', '{', '=', '!', '#'};
+
+  /**
+   * Return {@code true} if the text entered matches the given completion text.
+   *
+   * @param textEntered the text entered by the user
+   * @param completion the completion text
+   * @return {@code true} if matching, else {@code false}
+   */
+  public static boolean match(String textEntered, String completion) {
+    // Ignore leading '_' when matching
+    if (completion.startsWith("_") && !textEntered.startsWith("_")) {
+      completion = completion.substring(1);
+    }
+    if (completion.length() == 0 || completion.length() < textEntered.length()) {
+      return false;
+    }
+    // If the user has entered an upper case char as the first char
+    // then filter using only camelCaseMatching
+    if (!Character.isUpperCase(textEntered.charAt(0))) {
+      String partialCompletion = completion.substring(0, textEntered.length());
+      if (partialCompletion.equalsIgnoreCase(textEntered)) {
+        return true;
+      }
+    }
+    char[] pattern = textEntered.toCharArray();
+    char[] name = completion.toCharArray();
+    return CharOperation.camelCaseMatch(pattern, 0, pattern.length, name, 0, name.length, false);
+  }
+
private final DartServerProposalCollector collector;
+
private final CompletionSuggestion suggestion;

private final StyledString styledCompletion;
@@ -519,20 +549,7 @@
return false;
}
String completion = TextProcessor.deprocess(getDisplayString());
-    if (completion.length() == 0 || completion.length() < textEntered.length()) {
-      return false;
-    }
-    // If the user has entered an upper case char as the first char
-    // then filter using only camelCaseMatching
-    if (!Character.isUpperCase(textEntered.charAt(0))) {
-      String partialCompletion = completion.substring(0, textEntered.length());
-      if (partialCompletion.equalsIgnoreCase(textEntered)) {
-        return true;
-      }
-    }
-    char[] pattern = textEntered.toCharArray();
-    char[] name = completion.toCharArray();
-    return CharOperation.camelCaseMatch(pattern, 0, pattern.length, name, 0, name.length, false);
+    return match(textEntered, completion);
}


diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/BasicDartEditorActionContributor.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/BasicDartEditorActionContributor.java
index ba69040..fba801d 100644

@@ -13,6 +13,7 @@
*/

@@ -122,14 +123,16 @@
"OpenStructure."); //$NON-NLS-1$
fOpenStructure.setActionDefinitionId(DartEditorActionDefinitionIds.OPEN_STRUCTURE);

-    fStructureSelectEnclosingAction = new RetargetTextEditorAction(b, "StructureSelectEnclosing."); //$NON-NLS-1$
-    fStructureSelectEnclosingAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_ENCLOSING);
-    fStructureSelectNextAction = new RetargetTextEditorAction(b, "StructureSelectNext."); //$NON-NLS-1$
-    fStructureSelectNextAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_NEXT);
-    fStructureSelectPreviousAction = new RetargetTextEditorAction(b, "StructureSelectPrevious."); //$NON-NLS-1$
-    fStructureSelectPreviousAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_PREVIOUS);
-    fStructureSelectHistoryAction = new RetargetTextEditorAction(b, "StructureSelectHistory."); //$NON-NLS-1$
-    fStructureSelectHistoryAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_LAST);
+    if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+      fStructureSelectEnclosingAction = new RetargetTextEditorAction(b, "StructureSelectEnclosing."); //$NON-NLS-1$
+      fStructureSelectEnclosingAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_ENCLOSING);
+      fStructureSelectNextAction = new RetargetTextEditorAction(b, "StructureSelectNext."); //$NON-NLS-1$
+      fStructureSelectNextAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_NEXT);
+      fStructureSelectPreviousAction = new RetargetTextEditorAction(b, "StructureSelectPrevious."); //$NON-NLS-1$
+      fStructureSelectPreviousAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_PREVIOUS);
+      fStructureSelectHistoryAction = new RetargetTextEditorAction(b, "StructureSelectHistory."); //$NON-NLS-1$
+      fStructureSelectHistoryAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_LAST);
+    }

fGotoNextMemberAction = new RetargetTextEditorAction(b, "GotoNextMember."); //$NON-NLS-1$
fGotoNextMemberAction.setActionDefinitionId(DartEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
@@ -256,14 +259,18 @@

fOpenDeclaration.setAction(getAction(textEditor, "OpenEditor"));

-    fStructureSelectEnclosingAction.setAction(getAction(
-        textEditor,
-        StructureSelectionAction.ENCLOSING));
-    fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
-    fStructureSelectPreviousAction.setAction(getAction(
-        textEditor,
-        StructureSelectionAction.PREVIOUS));
-    fStructureSelectHistoryAction.setAction(getAction(textEditor, StructureSelectionAction.HISTORY));
+    if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+      fStructureSelectEnclosingAction.setAction(getAction(
+          textEditor,
+          StructureSelectionAction.ENCLOSING));
+      fStructureSelectNextAction.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
+      fStructureSelectPreviousAction.setAction(getAction(
+          textEditor,
+          StructureSelectionAction.PREVIOUS));
+      fStructureSelectHistoryAction.setAction(getAction(
+          textEditor,
+          StructureSelectionAction.HISTORY));
+    }

fGotoNextMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
fGotoPreviousMemberAction.setAction(getAction(

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java
index 262d3de..38bddf2 100644

@@ -2639,24 +2639,26 @@

fSelectionHistory = new SelectionHistory(this);

-    action = new StructureSelectEnclosingAction(this, fSelectionHistory);
-    action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_ENCLOSING);
-    setAction(StructureSelectionAction.ENCLOSING, action);
+    if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
+      action = new StructureSelectEnclosingAction(this, fSelectionHistory);
+      action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_ENCLOSING);
+      setAction(StructureSelectionAction.ENCLOSING, action);

-    action = new StructureSelectNextAction(this, fSelectionHistory);
-    action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_NEXT);
-    setAction(StructureSelectionAction.NEXT, action);
+      action = new StructureSelectNextAction(this, fSelectionHistory);
+      action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_NEXT);
+      setAction(StructureSelectionAction.NEXT, action);

-    action = new StructureSelectPreviousAction(this, fSelectionHistory);
-    action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_PREVIOUS);
-    setAction(StructureSelectionAction.PREVIOUS, action);
+      action = new StructureSelectPreviousAction(this, fSelectionHistory);
+      action.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_PREVIOUS);
+      setAction(StructureSelectionAction.PREVIOUS, action);

-    StructureSelectHistoryAction historyAction = new StructureSelectHistoryAction(
-        this,
-        fSelectionHistory);
-    historyAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_LAST);
-    setAction(StructureSelectionAction.HISTORY, historyAction);
-    fSelectionHistory.setHistoryAction(historyAction);
+      StructureSelectHistoryAction historyAction = new StructureSelectHistoryAction(
+          this,
+          fSelectionHistory);
+      historyAction.setActionDefinitionId(DartEditorActionDefinitionIds.SELECT_LAST);
+      setAction(StructureSelectionAction.HISTORY, historyAction);
+      fSelectionHistory.setHistoryAction(historyAction);
+    }

action = GoToNextPreviousMemberAction.newGoToNextMemberAction(this);
action.setActionDefinitionId(DartEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
@@ -3405,7 +3407,10 @@
protected void installOccurrencesFinder(boolean forceUpdate) {
DartSourceViewer viewer = (DartSourceViewer) getSourceViewer();
if (DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
-      occurrencesManager_NEW = new MarkOccurrencesManager_NEW(this, viewer);
+      occurrencesManager_NEW = new MarkOccurrencesManager_NEW(
+          this,
+          viewer,
+          getDartReconcilingStrategy());
} else {
occurrencesManager_OLD = new MarkOccurrencesManager_OLD(this, viewer);
}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartHover.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartHover.java
index 00f6d6c..83b006e 100644

@@ -171,6 +171,7 @@

private Composite container;
private TextSection elementSection;
+    private TextSection classSection;
private TextSection librarySection;
private AnnotationsSection problemsSection;
private DocSection docSection;
@@ -210,6 +211,7 @@
hasContents = false;
// Hide all sections.
setGridVisible(elementSection, false);
+      setGridVisible(classSection, false);
setGridVisible(librarySection, false);
setGridVisible(problemsSection, false);
setGridVisible(docSection, false);
@@ -234,6 +236,14 @@
elementSection.setText(text);
}
}
+            // show Class
+            {
+              String className = hover.getContainingClassDescription();
+              if (className != null) {
+                setGridVisible(classSection, true);
+                classSection.setText(className);
+              }
+            }
// show Library
{
String unitName = hover.getContainingLibraryPath();
@@ -402,7 +412,8 @@
container = toolkit.createComposite(parent);
GridLayoutFactory.create(container);
elementSection = new TextSection(container, "Element");
-      librarySection = new TextSection(container, "Library");
+      classSection = new TextSection(container, "Containing class");
+      librarySection = new TextSection(container, "Containing library");
problemsSection = new AnnotationsSection(container, "Problems");
docSection = new DocSection(container, "Documentation");
staticTypeSection = new TextSection(container, "Static type");

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/ElementLabelProvider_NEW.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/ElementLabelProvider_NEW.java
index 7d1c45d..20b21d4 100644

@@ -138,6 +138,11 @@
public StyledString getStyledText(Object obj, String text) {
Element element = (Element) obj;
StyledString styledString = new StyledString(text);
+    // append type parameters
+    String typeParameters = element.getTypeParameters();
+    if (typeParameters != null) {
+      styledString.append(typeParameters);
+    }
// append parameters
String parameters = element.getParameters();
if (parameters != null) {

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/MarkOccurrencesManager_NEW.java b/dart/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/MarkOccurrencesManager_NEW.java
index b48190c..bf4701f 100644

@@ -18,6 +18,7 @@

@@ -43,7 +44,8 @@
private static final String TYPE = "com.google.dart.tools.ui.occurrences";

private final DartEditor editor;
-  private final DartSourceViewer viewer;
+  private final IDocument document;
+  private final DartReconcilingStrategy reconcilingStrategy;
private final IEditorInput editorInput;
private final String file;

@@ -54,9 +56,11 @@
private Annotation[] fOccurrenceAnnotations;
private IRegion fMarkOccurrenceTargetRegion;

-  public MarkOccurrencesManager_NEW(DartEditor _editor, DartSourceViewer viewer) {
-    this.editor = _editor;
-    this.viewer = viewer;
+  public MarkOccurrencesManager_NEW(DartEditor editor, DartSourceViewer viewer,
+      DartReconcilingStrategy reconcilingStrategy) {
+    this.editor = editor;
+    this.document = viewer.getDocument();
+    this.reconcilingStrategy = reconcilingStrategy;
this.editorInput = editor.getEditorInput();
this.file = editor.getInputFilePath();
@@ -171,11 +175,6 @@
}

private void updateOccurrenceAnnotations() {
-    IDocument document = viewer.getDocument();
-    if (document == null) {
-      return;
-    }
-
if (document instanceof IDocumentExtension4) {
IRegion markOccurrenceTargetRegion = fMarkOccurrenceTargetRegion;
if (markOccurrenceTargetRegion != null) {
@@ -200,11 +199,13 @@
}

Occurrences targetOccurrences = null;
-    Occurrences[] occurrencesArray = DartCore.getAnalysisServerData().getOccurrences(file);
-    for (Occurrences occurrences : occurrencesArray) {
-      if (occurrences.contains(selectionOffset)) {
-        targetOccurrences = occurrences;
-        break;
+    if (!reconcilingStrategy.hasPendingContentChanges()) {
+      Occurrences[] occurrencesArray = DartCore.getAnalysisServerData().getOccurrences(file);
+      for (Occurrences occurrences : occurrencesArray) {
+        if (occurrences.containsInclusive(selectionOffset)) {
+          targetOccurrences = occurrences;
+          break;
+        }
}
}


diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartServerProposalTest.java b/dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartServerProposalTest.java
new file mode 100644
index 0000000..a46b2e0
--- /dev/null

@@ -0,0 +1,50 @@
+
+import junit.framework.TestCase;
+
+public class DartServerProposalTest extends TestCase {
+
+  public void test_match() throws Exception {
+
+    // Simple match
+    assertMatch("foo", "f", true);
+    assertMatch("foo", "fo", true);
+    assertMatch("foo", "foo", true);
+    assertMatch("foo", "fooX", false);
+    assertMatch("_foo", "_f", true);
+    assertMatch("_foo", "_fo", true);
+    assertMatch("_foo", "_foo", true);
+    assertMatch("_foo", "_fooX", false);
+
+    // CamelCase matching
+    assertMatch("OneClass", "O", true);
+    assertMatch("OneClass", "OC", true);
+    assertMatch("OneClass", "OCl", true);
+    assertMatch("OneClass", "OnC", true);
+    assertMatch("OneClass", "Ol", false);
+    assertMatch("OneClass", "OnCa", false);
+    assertMatch("_OneClass", "_O", true);
+    assertMatch("_OneClass", "_OC", true);
+    assertMatch("_OneClass", "_OCl", true);
+    assertMatch("_OneClass", "_OnC", true);
+    assertMatch("_OneClass", "_Ol", false);
+    assertMatch("_OneClass", "_OnCa", false);
+
+    // Ignore leading _ when matching
+    assertMatch("_foo", "f", true);
+    assertMatch("_foo", "fo", true);
+    assertMatch("_foo", "foo", true);
+    assertMatch("_foo", "fooX", false);
+    assertMatch("_OneClass", "O", true);
+    assertMatch("_OneClass", "OC", true);
+    assertMatch("_OneClass", "OCl", true);
+    assertMatch("_OneClass", "OnC", true);
+    assertMatch("_OneClass", "Ol", false);
+    assertMatch("_OneClass", "OnCa", false);
+  }
+
+  private void assertMatch(String completion, String textEntered, boolean expected) {
+    boolean actual = DartServerProposal.match(textEntered, completion);
+    assertEquals(expected, actual);
+  }
+}

diff --git a/dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/TestAll.java b/dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/TestAll.java
index cb52f5a..fe21942 100644

@@ -27,6 +27,7 @@
return suite;
}
}

diff --git a/dart/pkg/analysis_server/doc/api.html b/dart/pkg/analysis_server/doc/api.html
index 5585838..f0dac74 100644
--- a/dart/pkg/analysis_server/doc/api.html
+++ b/dart/pkg/analysis_server/doc/api.html

@@ -43,7 +43,7 @@
<body>
<h1>Analysis Server API Specification</h1>
-    <h1 style="color:#999999">Version 1.3.0</h1>
+    <h1 style="color:#999999">Version 1.5.0</h1>
<p>
This document contains a specification of the API provided by the
analysis server.  The API in this document is currently under
@@ -227,7 +227,7 @@

-    <h3>Requests</h3><dl><dt class="request">server.getVersion</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_server.getVersion">server.getVersion</a> (<a href="#request_server.getVersion">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "server.getVersion"
}</pre><br><pre>response: {
@@ -242,7 +242,7 @@
<h4>Returns</h4><dl><dt class="field"><b><i>version ( String )</i></b></dt><dd>

<p>The version number of the analysis server.</p>
-          </dd></dl></dd><dt class="request">server.shutdown</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_server.shutdown">server.shutdown</a> (<a href="#request_server.shutdown">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "server.shutdown"
}</pre><br><pre>response: {
@@ -257,7 +257,7 @@
further responses or notifications will be sent after the
response to this request has been sent.
</p>
-      </dd><dt class="request">server.setSubscriptions</dt><dd><div class="box"><pre>request: {
+      </dd><dt class="request"><a name="request_server.setSubscriptions">server.setSubscriptions</a> (<a href="#request_server.setSubscriptions">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "server.setSubscriptions"
"params": {
@@ -280,7 +280,7 @@
<h4>Parameters</h4><dl><dt class="field"><b><i>subscriptions ( List&lt;<a href="#type_ServerService">ServerService</a>&gt; )</i></b></dt><dd>

<p>A list of the services being subscribed to.</p>
"event": "server.connected"
"params": {
"<b>version</b>": String
@@ -300,7 +300,7 @@
<h4>Parameters</h4><dl><dt class="field"><b><i>version ( String )</i></b></dt><dd>

<p>The version number of the analysis server.</p>
"event": "server.error"
"params": {
"<b>isFatal</b>": bool
@@ -340,7 +340,7 @@
The stack trace associated with the generation of the
error, used for debugging the server.
</p>
"event": "server.status"
"params": {
"<b>analysis</b>": <span style="color:#999999">optional</span> <a href="#type_AnalysisStatus">AnalysisStatus</a>
@@ -397,7 +397,7 @@

-    <h3>Requests</h3><dl><dt class="request">analysis.getErrors</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_analysis.getErrors">analysis.getErrors</a> (<a href="#request_analysis.getErrors">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.getErrors"
"params": {
@@ -449,7 +449,7 @@
<p>
The errors associated with the file.
</p>
-          </dd></dl></dd><dt class="request">analysis.getHover</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.getHover">analysis.getHover</a> (<a href="#request_analysis.getHover">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.getHover"
"params": {
@@ -491,7 +491,7 @@
in multiple contexts in conflicting ways (such as a
part that is included in multiple libraries).
</p>
-          </dd></dl></dd><dt class="request">analysis.getLibraryDependencies</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.getLibraryDependencies">analysis.getLibraryDependencies</a> (<a href="#request_analysis.getLibraryDependencies">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.getLibraryDependencies"
}</pre><br><pre>response: {
@@ -520,7 +520,7 @@
package names to source directories for use in client-side
package URI resolution.
</p>
"id": String
"params": {
@@ -592,7 +592,7 @@
A list of the navigation regions within the requested region of
the file.
</p>
-          </dd></dl></dd><dt class="request">analysis.reanalyze</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.reanalyze">analysis.reanalyze</a> (<a href="#request_analysis.reanalyze">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.reanalyze"
"params": {
@@ -621,7 +621,7 @@
<p>
A list of the analysis roots that are to be re-analyzed.
</p>
-          </dd></dl></dd><dt class="request">analysis.setAnalysisRoots</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.setAnalysisRoots">analysis.setAnalysisRoots</a> (<a href="#request_analysis.setAnalysisRoots">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.setAnalysisRoots"
"params": {
@@ -698,7 +698,7 @@
or the empty map is specified, that indicates that the
normal pubspec.yaml mechanism should always be used.
</p>
-          </dd></dl></dd><dt class="request">analysis.setPriorityFiles</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.setPriorityFiles">analysis.setPriorityFiles</a> (<a href="#request_analysis.setPriorityFiles">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.setPriorityFiles"
"params": {
@@ -739,7 +739,7 @@
<p>
The files that are to be a priority for analysis.
</p>
-          </dd></dl></dd><dt class="request">analysis.setSubscriptions</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.setSubscriptions">analysis.setSubscriptions</a> (<a href="#request_analysis.setSubscriptions">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.setSubscriptions"
"params": {
@@ -789,7 +789,7 @@
A table mapping services to a list of the files being
subscribed to the service.
</p>
-          </dd></dl></dd><dt class="request">analysis.updateContent</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_analysis.updateContent">analysis.updateContent</a> (<a href="#request_analysis.updateContent">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.updateContent"
"params": {
@@ -819,7 +819,7 @@
A table mapping the files whose content has changed to a
description of the content change.
</p>
-          </dd></dl><h4>Returns</h4><dl></dl></dd><dt class="request">analysis.updateOptions</dt><dd><div class="box"><pre>request: {
+          </dd></dl><h4>Returns</h4><dl></dl></dd><dt class="request"><a name="request_analysis.updateOptions">analysis.updateOptions</a> (<a href="#request_analysis.updateOptions">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "analysis.updateOptions"
"params": {
@@ -842,7 +842,7 @@
<p>
The options that are to be used to control analysis.
</p>
"event": "analysis.errors"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -869,7 +869,7 @@
<p>
The errors contained in the file.
</p>
"event": "analysis.flushResults"
"params": {
"<b>files</b>": List&lt;<a href="#type_FilePath">FilePath</a>&gt;
@@ -898,7 +898,7 @@
<p>
The files that are no longer being analyzed.
</p>
"event": "analysis.folding"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -929,7 +929,7 @@
<p>
The folding regions contained in the file.
</p>
"event": "analysis.highlights"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -961,7 +961,7 @@
other highlight regions if there is more than one
meaning associated with a particular region.
</p>
"event": "analysis.invalidate"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -1002,7 +1002,7 @@
the invalidated region in order to update it so that it doesn't
need to be re-requested.
</p>
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -1054,7 +1054,7 @@
They are referenced by <tt>NavigationTarget</tt>s by their
index in this array.
</p>
"event": "analysis.occurrences"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -1083,7 +1083,7 @@
The occurrences of references to elements within the
file.
</p>
"event": "analysis.outline"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -1110,7 +1110,7 @@
<p>
The outline associated with the file.
</p>
"event": "analysis.overrides"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -1145,7 +1145,7 @@
</p>

-    <h3>Requests</h3><dl><dt class="request">completion.getSuggestions</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_completion.getSuggestions">completion.getSuggestions</a> (<a href="#request_completion.getSuggestions">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "completion.getSuggestions"
"params": {
@@ -1183,7 +1183,7 @@
The identifier used to associate results with this
completion request.
</p>
"event": "completion.results"
"params": {
"<b>id</b>": <a href="#type_CompletionId">CompletionId</a>
@@ -1251,7 +1251,7 @@

-    <h3>Requests</h3><dl><dt class="request">search.findElementReferences</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_search.findElementReferences">search.findElementReferences</a> (<a href="#request_search.findElementReferences">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "search.findElementReferences"
"params": {
@@ -1318,7 +1318,7 @@
If no element was found at the given location, this
field will be absent.
</p>
-          </dd></dl></dd><dt class="request">search.findMemberDeclarations</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_search.findMemberDeclarations">search.findMemberDeclarations</a> (<a href="#request_search.findMemberDeclarations">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "search.findMemberDeclarations"
"params": {
@@ -1353,7 +1353,7 @@
The identifier used to associate results with this
search request.
</p>
-          </dd></dl></dd><dt class="request">search.findMemberReferences</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_search.findMemberReferences">search.findMemberReferences</a> (<a href="#request_search.findMemberReferences">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "search.findMemberReferences"
"params": {
@@ -1390,7 +1390,7 @@
The identifier used to associate results with this
search request.
</p>
-          </dd></dl></dd><dt class="request">search.findTopLevelDeclarations</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_search.findTopLevelDeclarations">search.findTopLevelDeclarations</a> (<a href="#request_search.findTopLevelDeclarations">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "search.findTopLevelDeclarations"
"params": {
@@ -1427,7 +1427,7 @@
The identifier used to associate results with this
search request.
</p>
-          </dd></dl></dd><dt class="request">search.getTypeHierarchy</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_search.getTypeHierarchy">search.getTypeHierarchy</a> (<a href="#request_search.getTypeHierarchy">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "search.getTypeHierarchy"
"params": {
@@ -1474,7 +1474,7 @@
not been sufficiently analyzed to allow a type hierarchy
to be produced.
</p>
"event": "search.results"
"params": {
"<b>id</b>": <a href="#type_SearchId">SearchId</a>
@@ -1518,7 +1518,7 @@

-    <h3>Requests</h3><dl><dt class="request">edit.format</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_edit.format">edit.format</a> (<a href="#request_edit.format">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.format"
"params": {
@@ -1585,7 +1585,7 @@
<p>
The length of the selection after formatting the code.
</p>
-          </dd></dl></dd><dt class="request">edit.getAssists</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_edit.getAssists">edit.getAssists</a> (<a href="#request_edit.getAssists">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.getAssists"
"params": {
@@ -1631,7 +1631,7 @@
<p>
The assists that are available at the given location.
</p>
-          </dd></dl></dd><dt class="request">edit.getAvailableRefactorings</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_edit.getAvailableRefactorings">edit.getAvailableRefactorings</a> (<a href="#request_edit.getAvailableRefactorings">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.getAvailableRefactorings"
"params": {
@@ -1676,7 +1676,7 @@
The kinds of refactorings that are valid for the given
selection.
</p>
-          </dd></dl></dd><dt class="request">edit.getFixes</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_edit.getFixes">edit.getFixes</a> (<a href="#request_edit.getFixes">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.getFixes"
"params": {
@@ -1713,7 +1713,7 @@
<p>
The fixes that are available for the errors at the given offset.
</p>
-          </dd></dl></dd><dt class="request">edit.getRefactoring</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_edit.getRefactoring">edit.getRefactoring</a> (<a href="#request_edit.getRefactoring">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.getRefactoring"
"params": {
@@ -1837,7 +1837,7 @@
will be omitted if the change field is omitted or if there are no
potential edits for the refactoring.
</p>
-          </dd></dl></dd><dt class="request">edit.sortMembers</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_edit.sortMembers">edit.sortMembers</a> (<a href="#request_edit.sortMembers">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "edit.sortMembers"
"params": {
@@ -1887,7 +1887,7 @@

-    <h3>Requests</h3><dl><dt class="request">execution.createContext</dt><dd><div class="box"><pre>request: {
+    <h3>Requests</h3><dl><dt class="request"><a name="request_execution.createContext">execution.createContext</a> (<a href="#request_execution.createContext">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "execution.createContext"
"params": {
@@ -1920,7 +1920,7 @@
The identifier used to refer to the execution context that was
created.
</p>
-          </dd></dl></dd><dt class="request">execution.deleteContext</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_execution.deleteContext">execution.deleteContext</a> (<a href="#request_execution.deleteContext">#</a>)</dt><dd><div class="box"><pre>request: {
"<b>id</b>": String
"method": "execution.deleteContext"
"params": {
@@ -1941,7 +1941,7 @@
<p>
The identifier of the execution context that is to be deleted.
</p>
-          </dd></dl></dd><dt class="request">execution.mapUri</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_execution.mapUri">execution.mapUri</a> (<a href="#request_execution.mapUri">#</a>)</dt><dd><div class="box"><pre>request: {
"<b>id</b>": String
"method": "execution.mapUri"
"params": {
@@ -2015,7 +2015,7 @@
The URI to which the file path was mapped. This field is omitted
if the file field was not given in the request.
</p>
-          </dd></dl></dd><dt class="request">execution.setSubscriptions</dt><dd><div class="box"><pre>request: {
+          </dd></dl></dd><dt class="request"><a name="request_execution.setSubscriptions">execution.setSubscriptions</a> (<a href="#request_execution.setSubscriptions">#</a>)</dt><dd><div class="box"><pre>request: {
"id": String
"method": "execution.setSubscriptions"
"params": {
@@ -2040,7 +2040,7 @@
<p>
A list of the services being subscribed to.
</p>
"event": "execution.launchData"
"params": {
"<b>file</b>": <a href="#type_FilePath">FilePath</a>
@@ -2528,6 +2528,12 @@
element does not have a declared return type, this field
will contain an empty string.
</p>
+          </dd><dt class="field"><b><i>typeParameters ( <span style="color:#999999">optional</span> String )</i></b></dt><dd>
+
+            <p>
+              The type parameter list for the element. If the element doesn't
+              have type parameters, this field will not be defined.
+            </p>
</dd></dl></dd><dt class="typeDefinition"><a name="type_ElementKind">ElementKind: String</a></dt><dd>
<p>
An enumeration of the kinds of elements.
@@ -2656,6 +2662,13 @@
element, or if the element is declared inside an HTML
file.
</p>
+          </dd><dt class="field"><b><i>containingClassDescription ( <span style="color:#999999">optional</span> String )</i></b></dt><dd>
+
+            <p>
+              A human-readable description of the class declaring the element
+              being referenced. This data is omitted if there is no referenced
+              element, or if the element is not a class member.
+            </p>
</dd><dt class="field"><b><i>dartdoc ( <span style="color:#999999">optional</span> String )</i></b></dt><dd>

<p>

diff --git a/dart/pkg/analysis_server/lib/src/analysis_server.dart b/dart/pkg/analysis_server/lib/src/analysis_server.dart
--- a/dart/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/dart/pkg/analysis_server/lib/src/analysis_server.dart

@@ -20,6 +20,7 @@
import 'package:analysis_server/src/services/search/search_engine.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
+import 'package:analyzer/plugin/plugin.dart';
import 'package:analyzer/source/package_map_provider.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
@@ -65,7 +66,7 @@
* The version of the analysis server. The value should be replaced
* automatically during the build.
*/
-  static final String VERSION = '1.3.0';
+  static final String VERSION = '1.5.0';

/**
* The number of milliseconds to perform operations before inserting
@@ -234,6 +235,11 @@
final ContentCache overlayState = new ContentCache();

/**
+   * The plugins that are defined outside the analysis_server package.
+   */
+  List<Plugin> userDefinedPlugins;
+
+  /**
* Initialize a newly created server to receive requests from and send
* responses to the given [channel].
*

diff --git a/dart/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/dart/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index 2c98c84..0491336 100644
--- a/dart/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/dart/pkg/analysis_server/lib/src/computer/computer_highlights.dart

@@ -168,7 +168,7 @@
Element enclosingElement = element.enclosingElement;
if (enclosingElement is ClassElement && enclosingElement.isEnum) {
type = HighlightRegionType.ENUM_CONSTANT;
-      } else if ((element as FieldElement).isStatic) {
+      } else if (element.isStatic) {
type = HighlightRegionType.FIELD_STATIC;
} else {
type = HighlightRegionType.FIELD;

diff --git a/dart/pkg/analysis_server/lib/src/computer/computer_hover.dart b/dart/pkg/analysis_server/lib/src/computer/computer_hover.dart
--- a/dart/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/dart/pkg/analysis_server/lib/src/computer/computer_hover.dart

@@ -95,7 +95,13 @@
// description
hover.elementDescription = element.toString();
hover.elementKind = element.kind.displayName;
-        // library
+        // containing class
+        ClassElement containingClass =
+            element.getAncestor((e) => e is ClassElement);
+        if (containingClass != null) {
+          hover.containingClassDescription = containingClass.toString();
+        }
+        // containing library
LibraryElement library = element.library;
if (library != null) {
hover.containingLibraryName = library.name;

diff --git a/dart/pkg/analysis_server/lib/src/computer/computer_outline.dart b/dart/pkg/analysis_server/lib/src/computer/computer_outline.dart
index c8351df..81e9b50 100644
--- a/dart/pkg/analysis_server/lib/src/computer/computer_outline.dart
+++ b/dart/pkg/analysis_server/lib/src/computer/computer_outline.dart

@@ -138,11 +138,10 @@
// unit or class member
if (parent is CompilationUnit) {
firstOffset = 0;
-      siblings = (parent as CompilationUnit).declarations;
+      siblings = parent.declarations;
} else if (parent is ClassDeclaration) {
-      ClassDeclaration classDeclaration = parent as ClassDeclaration;
-      firstOffset = classDeclaration.leftBracket.end;
-      siblings = classDeclaration.members;
+      firstOffset = parent.leftBracket.end;
+      siblings = parent.members;
} else {
int offset = node.offset;
return new _SourceRegion(offset, endOffset - offset);
@@ -157,30 +156,31 @@
return new _SourceRegion(prevSiblingEnd, endOffset - prevSiblingEnd);
}

-  Outline _newClassOutline(
-      ClassDeclaration classDeclaration, List<Outline> classContents) {
-    SimpleIdentifier nameNode = classDeclaration.name;
+  Outline _newClassOutline(ClassDeclaration node, List<Outline> classContents) {
+    SimpleIdentifier nameNode = node.name;
String name = nameNode.name;
-    _SourceRegion sourceRegion = _getSourceRegion(classDeclaration);
+    _SourceRegion sourceRegion = _getSourceRegion(node);
Element element = new Element(ElementKind.CLASS, name, Element.makeFlags(
isPrivate: Identifier.isPrivateName(name),
-            isDeprecated: _isDeprecated(classDeclaration),
-            isAbstract: classDeclaration.isAbstract),
-        location: _getLocationNode(nameNode));
+            isDeprecated: _isDeprecated(node),
+            isAbstract: node.isAbstract),
+        location: _getLocationNode(nameNode),
return new Outline(element, sourceRegion.offset, sourceRegion.length,
children: nullIfEmpty(classContents));
}

-  Outline _newClassTypeAlias(ClassTypeAlias alias) {
-    SimpleIdentifier nameNode = alias.name;
+  Outline _newClassTypeAlias(ClassTypeAlias node) {
+    SimpleIdentifier nameNode = node.name;
String name = nameNode.name;
-    _SourceRegion sourceRegion = _getSourceRegion(alias);
+    _SourceRegion sourceRegion = _getSourceRegion(node);
Element element = new Element(ElementKind.CLASS_TYPE_ALIAS, name, Element
.makeFlags(
isPrivate: Identifier.isPrivateName(name),
-                isDeprecated: _isDeprecated(alias),
-                isAbstract: alias.isAbstract),
-        location: _getLocationNode(nameNode));
+                isDeprecated: _isDeprecated(node),
+                isAbstract: node.isAbstract),
+        location: _getLocationNode(nameNode),
return new Outline(element, sourceRegion.offset, sourceRegion.length);
}

@@ -268,21 +268,22 @@
return outline;
}

-  Outline _newFunctionTypeAliasOutline(FunctionTypeAlias alias) {
-    TypeName returnType = alias.returnType;
-    SimpleIdentifier nameNode = alias.name;
+  Outline _newFunctionTypeAliasOutline(FunctionTypeAlias node) {
+    TypeName returnType = node.returnType;
+    SimpleIdentifier nameNode = node.name;
String name = nameNode.name;
-    _SourceRegion sourceRegion = _getSourceRegion(alias);
-    FormalParameterList parameters = alias.parameters;
+    _SourceRegion sourceRegion = _getSourceRegion(node);
+    FormalParameterList parameters = node.parameters;
String parametersStr = parameters != null ? parameters.toSource() : '';
String returnTypeStr = returnType != null ? returnType.toSource() : '';
Element element = new Element(ElementKind.FUNCTION_TYPE_ALIAS, name, Element
.makeFlags(
isPrivate: Identifier.isPrivateName(name),
-                isDeprecated: _isDeprecated(alias)),
+                isDeprecated: _isDeprecated(node)),
location: _getLocationNode(nameNode),
-        returnType: returnTypeStr);
+        returnType: returnTypeStr,
return new Outline(element, sourceRegion.offset, sourceRegion.length);
}

@@ -325,6 +326,13 @@
children: nullIfEmpty(unitContents));
}

+  static String _getTypeParametersStr(TypeParameterList parameters) {
+    if (parameters == null) {
+      return null;
+    }
+    return parameters.toSource();
+  }
+
Outline _newVariableOutline(String typeName, ElementKind kind,
VariableDeclaration variable, bool isStatic) {
SimpleIdentifier nameNode = variable.name;

diff --git a/dart/pkg/analysis_server/lib/src/context_manager.dart b/dart/pkg/analysis_server/lib/src/context_manager.dart
index d715b6b..058662c 100644
--- a/dart/pkg/analysis_server/lib/src/context_manager.dart
+++ b/dart/pkg/analysis_server/lib/src/context_manager.dart

@@ -18,7 +18,6 @@
import 'package:analyzer/src/generated/source_io.dart';
import 'package:path/path.dart' as pathos;
import 'package:watcher/watcher.dart';
-import 'package:analyzer/src/generated/java_engine.dart';

/**
* The name of packages folders.
@@ -134,7 +133,7 @@
}
}
}
-    return flushedFiles.toList(growable:false);
+    return flushedFiles.toList(growable: false);
}

/**
@@ -286,7 +285,7 @@
List<Resource> children;
try {
children = folder.getChildren();
-    } on FileSystemException catch (exception) {
+    } on FileSystemException {
// The folder no longer exists, or cannot be read, to there's nothing to
// do.
return;
@@ -656,9 +655,6 @@
if (context == null) {
return source;
}
-    if (context.sourceFactory == null) {
-      return null;
-    }
Uri uri = context.sourceFactory.restoreUri(source);
return file.createSource(uri);
}

diff --git a/dart/pkg/analysis_server/lib/src/domain_execution.dart b/dart/pkg/analysis_server/lib/src/domain_execution.dart
index 08ff54e..59d70af 100644
--- a/dart/pkg/analysis_server/lib/src/domain_execution.dart
+++ b/dart/pkg/analysis_server/lib/src/domain_execution.dart

@@ -154,10 +154,7 @@
Source source = notice.source;
String filePath = source.fullName;
-      if (!_isInAnalysisRoot(filePath)) {
-        return;
-      }
-      AnalysisContext context = server.getAnalysisContext(filePath);
+      AnalysisContext context = server.getContainingContext(filePath);
if (context == null) {
return;
}

diff --git a/dart/pkg/analysis_server/lib/src/edit/edit_domain.dart b/dart/pkg/analysis_server/lib/src/edit/edit_domain.dart
index edf92e7..9d4c7df 100644
--- a/dart/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/dart/pkg/analysis_server/lib/src/edit/edit_domain.dart

@@ -491,7 +491,7 @@
engine.AnalysisContext context = contextSource.context;
Source source = contextSource.source;
refactoring = new MoveFileRefactoring(
-          server.resourceProvider.pathContext, searchEngine, context, source);
+          server.resourceProvider, searchEngine, context, source, file);
}
if (kind == RefactoringKind.RENAME) {
List<AstNode> nodes = server.getNodesAtOffset(file, offset);

diff --git a/dart/pkg/analysis_server/lib/src/generated_protocol.dart b/dart/pkg/analysis_server/lib/src/generated_protocol.dart
index 844635f..bbd7572 100644
--- a/dart/pkg/analysis_server/lib/src/generated_protocol.dart
+++ b/dart/pkg/analysis_server/lib/src/generated_protocol.dart

@@ -6432,6 +6432,7 @@
*   "flags": int
*   "parameters": optional String
*   "returnType": optional String
+ *   "typeParameters": optional String
* }
*/
class Element implements HasToJson {
@@ -6497,7 +6498,13 @@
*/
String returnType;

-  Element(this.kind, this.name, this.flags, {this.location, this.parameters, this.returnType});
+  /**
+   * The type parameter list for the element. If the element doesn't have type
+   * parameters, this field will not be defined.
+   */
+  String typeParameters;
+
+  Element(this.kind, this.name, this.flags, {this.location, this.parameters, this.returnType, this.typeParameters});

factory Element.fromJson(JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
@@ -6534,7 +6541,11 @@
if (json.containsKey("returnType")) {
returnType = jsonDecoder._decodeString(jsonPath + ".returnType", json["returnType"]);
}
-      return new Element(kind, name, flags, location: location, parameters: parameters, returnType: returnType);
+      String typeParameters;
+      if (json.containsKey("typeParameters")) {
+        typeParameters = jsonDecoder._decodeString(jsonPath + ".typeParameters", json["typeParameters"]);
+      }
+      return new Element(kind, name, flags, location: location, parameters: parameters, returnType: returnType, typeParameters: typeParameters);
} else {
throw jsonDecoder.mismatch(jsonPath, "Element");
}
@@ -6561,6 +6572,9 @@
if (returnType != null) {
result["returnType"] = returnType;
}
+    if (typeParameters != null) {
+      result["typeParameters"] = typeParameters;
+    }
return result;
}

@@ -6575,7 +6589,8 @@
location == other.location &&
flags == other.flags &&
parameters == other.parameters &&
-          returnType == other.returnType;
+          returnType == other.returnType &&
+          typeParameters == other.typeParameters;
}
return false;
}
@@ -6589,6 +6604,7 @@
hash = _JenkinsSmiHash.combine(hash, flags.hashCode);
hash = _JenkinsSmiHash.combine(hash, parameters.hashCode);
hash = _JenkinsSmiHash.combine(hash, returnType.hashCode);
+    hash = _JenkinsSmiHash.combine(hash, typeParameters.hashCode);
return _JenkinsSmiHash.finish(hash);
}
}
@@ -7392,6 +7408,7 @@
*   "length": int
*   "containingLibraryPath": optional String
*   "containingLibraryName": optional String
+ *   "containingClassDescription": optional String
*   "dartdoc": optional String
*   "elementDescription": optional String
*   "elementKind": optional String
@@ -7428,6 +7445,13 @@
String containingLibraryName;

/**
+   * A human-readable description of the class declaring the element being
+   * referenced. This data is omitted if there is no referenced element, or if
+   * the element is not a class member.
+   */
+  String containingClassDescription;
+
+  /**
* The dartdoc associated with the referenced element. Other than the removal
* of the comment delimiters, including leading asterisks in the case of a
* block comment, the dartdoc is unprocessed markdown. This data is omitted
@@ -7468,7 +7492,7 @@
*/
String staticType;

-  HoverInformation(this.offset, this.length, {this.containingLibraryPath, this.containingLibraryName, this.dartdoc, this.elementDescription, this.elementKind, this.parameter, this.propagatedType, this.staticType});
+  HoverInformation(this.offset, this.length, {this.containingLibraryPath, this.containingLibraryName, this.containingClassDescription, this.dartdoc, this.elementDescription, this.elementKind, this.parameter, this.propagatedType, this.staticType});

factory HoverInformation.fromJson(JsonDecoder jsonDecoder, String jsonPath, Object json) {
if (json == null) {
@@ -7495,6 +7519,10 @@
if (json.containsKey("containingLibraryName")) {
containingLibraryName = jsonDecoder._decodeString(jsonPath + ".containingLibraryName", json["containingLibraryName"]);
}
+      String containingClassDescription;
+      if (json.containsKey("containingClassDescription")) {
+        containingClassDescription = jsonDecoder._decodeString(jsonPath + ".containingClassDescription", json["containingClassDescription"]);
+      }
String dartdoc;
if (json.containsKey("dartdoc")) {
dartdoc = jsonDecoder._decodeString(jsonPath + ".dartdoc", json["dartdoc"]);
@@ -7519,7 +7547,7 @@
if (json.containsKey("staticType")) {
staticType = jsonDecoder._decodeString(jsonPath + ".staticType", json["staticType"]);
}
-      return new HoverInformation(offset, length, containingLibraryPath: containingLibraryPath, containingLibraryName: containingLibraryName, dartdoc: dartdoc, elementDescription: elementDescription, elementKind: elementKind, parameter: parameter, propagatedType: propagatedType, staticType: staticType);
+      return new HoverInformation(offset, length, containingLibraryPath: containingLibraryPath, containingLibraryName: containingLibraryName, containingClassDescription: containingClassDescription, dartdoc: dartdoc, elementDescription: elementDescription, elementKind: elementKind, parameter: parameter, propagatedType: propagatedType, staticType: staticType);
} else {
throw jsonDecoder.mismatch(jsonPath, "HoverInformation");
}
@@ -7535,6 +7563,9 @@
if (containingLibraryName != null) {
result["containingLibraryName"] = containingLibraryName;
}
+    if (containingClassDescription != null) {
+      result["containingClassDescription"] = containingClassDescription;
+    }
if (dartdoc != null) {
result["dartdoc"] = dartdoc;
}
@@ -7566,6 +7597,7 @@
length == other.length &&
containingLibraryPath == other.containingLibraryPath &&
containingLibraryName == other.containingLibraryName &&
+          containingClassDescription == other.containingClassDescription &&
dartdoc == other.dartdoc &&
elementDescription == other.elementDescription &&
elementKind == other.elementKind &&
@@ -7583,6 +7615,7 @@
hash = _JenkinsSmiHash.combine(hash, length.hashCode);
hash = _JenkinsSmiHash.combine(hash, containingLibraryPath.hashCode);
hash = _JenkinsSmiHash.combine(hash, containingLibraryName.hashCode);
+    hash = _JenkinsSmiHash.combine(hash, containingClassDescription.hashCode);
hash = _JenkinsSmiHash.combine(hash, dartdoc.hashCode);
hash = _JenkinsSmiHash.combine(hash, elementDescription.hashCode);
hash = _JenkinsSmiHash.combine(hash, elementKind.hashCode);

diff --git a/dart/pkg/analysis_server/lib/src/get_handler.dart b/dart/pkg/analysis_server/lib/src/get_handler.dart
--- a/dart/pkg/analysis_server/lib/src/get_handler.dart
+++ b/dart/pkg/analysis_server/lib/src/get_handler.dart

@@ -10,6 +10,7 @@
import 'dart:io';
import 'dart:math';

+import 'package:analyzer/plugin/plugin.dart';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/domain_completion.dart';
import 'package:analysis_server/src/domain_execution.dart';
@@ -402,8 +403,8 @@

List<Folder> allContexts = <Folder>[];
Map<Folder, SourceEntry> entryMap = new HashMap<Folder, SourceEntry>();
-    analysisServer.folderMap.forEach(
-        (Folder folder, AnalysisContextImpl context) {
+    analysisServer.folderMap
+        .forEach((Folder folder, AnalysisContextImpl context) {
Source source = context.sourceFactory.forUri(sourceUri);
if (source != null) {
@@ -459,8 +460,8 @@
};

buffer.write('<h3>Library Independent</h3>');
-        _writeDescriptorTable(buffer,
+        _writeDescriptorTable(buffer, entry.descriptors, entry.getState,
if (entry is DartEntry) {
for (Source librarySource in entry.containingLibraries) {
String libraryName = HTML_ESCAPE.convert(librarySource.fullName);
@@ -575,8 +576,8 @@
: 0;
buffer.write('<h4>Startup</h4>');
buffer.write('<table>');
-          _writeRow(
-              buffer, [requestCount, 'requests'], classes: ["right", null]);
+          _writeRow(buffer, [requestCount, 'requests'],
+              classes: ["right", null]);
_writeRow(buffer, [averageLatency, 'ms average latency'],
classes: ["right", null]);
_writeRow(buffer, [maximumLatency, 'ms maximum latency'],
@@ -605,8 +606,8 @@
: 0;
buffer.write('<h4>Current</h4>');
buffer.write('<table>');
-          _writeRow(
-              buffer, [requestCount, 'requests'], classes: ["right", null]);
+          _writeRow(buffer, [requestCount, 'requests'],
+              classes: ["right", null]);
_writeRow(buffer, [averageLatency, 'ms average latency'],
classes: ["right", null]);
_writeRow(buffer, [maximumLatency, 'ms maximum latency'],
@@ -712,9 +713,8 @@
}

_writeResponse(request, (StringBuffer buffer) {
-      _writePage(buffer, 'Analysis Server - Context', [
-        'Context: $contextFilter' - ], (StringBuffer buffer) { + _writePage(buffer, 'Analysis Server - Context', + ['Context:$contextFilter'], (StringBuffer buffer) {
buffer.write('<h3>Summary</h3>');
@@ -833,14 +833,13 @@
Map<List<String>, List<InspectLocation>> relations =
await index.findElementsByName(name);
_writeResponse(request, (StringBuffer buffer) {
-        _writePage(buffer, 'Analysis Server - Index Elements', [
-          'Name: $name' - ], (StringBuffer buffer) { + _writePage(buffer, 'Analysis Server - Index Elements', ['Name:$name'],
+            (StringBuffer buffer) {
buffer.write('<table border="1">');
_writeRow(buffer, ['Element', 'Relationship', 'Location'],
-          relations.forEach(
-              (List<String> elementPath, List<InspectLocation> relations) {
+          relations.forEach((List<String> elementPath,
+              List<InspectLocation> relations) {
String elementLocation = elementPath.join(' ');
relations.forEach((InspectLocation location) {
var relString = location.relationship.identifier;
@@ -912,6 +911,7 @@
_writeAnalysisStatus(buffer);
_writeEditStatus(buffer);
_writeExecutionStatus(buffer);
+          _writePluginStatus(buffer);
_writeRecentOutput(buffer);
}
});
@@ -1007,6 +1007,8 @@
_writeOption(
buffer, 'Analyze functon bodies', options.analyzeFunctionBodies);
_writeOption(buffer, 'Cache size', options.cacheSize);
+      _writeOption(
+          buffer, 'Enable strict call checks', options.enableStrictCallChecks);
_writeOption(buffer, 'Generate hints', options.hint);
_writeOption(buffer, 'Generate dart2js hints', options.dart2jsHint);
_writeOption(buffer, 'Generate errors in implicit files',
@@ -1016,8 +1018,8 @@
_writeOption(buffer, 'Incremental resolution', options.incremental);
_writeOption(buffer, 'Incremental resolution with API changes',
options.incrementalApi);
-      _writeOption(
+          last: true);
buffer.write('</p>');
int freq = AnalysisServer.performOperationDelayFreqency;
String delay = freq > 0 ? '1 ms every $freq ms' : 'off'; @@ -1313,6 +1315,26 @@ * Write the recent output section (on the main status page) to the given * [buffer] object. */ + void _writePluginStatus(StringBuffer buffer) { + void writePlugin(Plugin plugin) { + buffer.write(_server.serverPlugin.uniqueIdentifier); + buffer.write(' ('); + buffer.write(_server.serverPlugin.runtimeType); + buffer.write(')<br>'); + } + buffer.write('<h3>Plugin Status</h3><p>'); + writePlugin(AnalysisEngine.instance.enginePlugin); + writePlugin(_server.serverPlugin); + for (Plugin plugin in _server.analysisServer.userDefinedPlugins) { + writePlugin(plugin); + } + buffer.write('<p>'); + } + + /** + * Write the recent output section (on the main status page) to the given + * [buffer] object. + */ void _writeRecentOutput(StringBuffer buffer) { buffer.write('<h3>Recent Output</h3>'); String output = HTML_ESCAPE.convert(_printBuffer.join('\n'));  diff --git a/dart/pkg/analysis_server/lib/src/plugin/server_plugin.dart b/dart/pkg/analysis_server/lib/src/plugin/server_plugin.dart index faeecc4..b74fb7f 100644 --- a/dart/pkg/analysis_server/lib/src/plugin/server_plugin.dart +++ b/dart/pkg/analysis_server/lib/src/plugin/server_plugin.dart  @@ -4,7 +4,6 @@ library analysis_server.src.plugin.server_plugin; -import 'package:analysis_server/plugin/plugin.dart'; import 'package:analysis_server/src/analysis_server.dart'; import 'package:analysis_server/src/domain_analysis.dart'; import 'package:analysis_server/src/domain_completion.dart'; @@ -13,12 +12,11 @@ import 'package:analysis_server/src/edit/edit_domain.dart'; import 'package:analysis_server/src/protocol.dart'; import 'package:analysis_server/src/search/search_domain.dart'; +import 'package:analyzer/plugin/plugin.dart'; /** * A function that will create a request handler that can be used by the given * [server]. - * - * TODO(brianwilkerson) Move this into 'protocol.dart'. */ typedef RequestHandler RequestHandlerFactory(AnalysisServer server);  diff --git a/dart/pkg/analysis_server/lib/src/protocol_server.dart b/dart/pkg/analysis_server/lib/src/protocol_server.dart index 7618308..f5c5806 100644 --- a/dart/pkg/analysis_server/lib/src/protocol_server.dart +++ b/dart/pkg/analysis_server/lib/src/protocol_server.dart  @@ -84,6 +84,7 @@ */ Element newElement_fromEngine(engine.Element element) { String name = element.displayName; + String elementTypeParameters = _getTypeParametersString(element); String elementParameters = _getParametersString(element); String elementReturnType = _getReturnTypeString(element); return new Element(newElementKind_fromEngine(element.kind), name, Element @@ -95,6 +96,7 @@ isFinal: _isFinal(element), isStatic: _isStatic(element)), location: newLocation_fromElement(element), + typeParameters: elementTypeParameters, parameters: elementParameters, returnType: elementReturnType); } @@ -351,6 +353,19 @@ } } +String _getTypeParametersString(engine.Element element) { + List<engine.TypeParameterElement> typeParameters; + if (element is engine.ClassElement) { + typeParameters = element.typeParameters; + } else if (element is engine.FunctionTypeAliasElement) { + typeParameters = element.typeParameters; + } + if (typeParameters == null || typeParameters.isEmpty) { + return null; + } + return '<${typeParameters.join(', ')}>';
+}
+
bool _isAbstract(engine.Element element) {
// TODO(scheglov) add isAbstract to Element API
if (element is engine.ClassElement) {

diff --git a/dart/pkg/analysis_server/lib/src/server/driver.dart b/dart/pkg/analysis_server/lib/src/server/driver.dart
index c09c6c9..bc7c17b 100644
--- a/dart/pkg/analysis_server/lib/src/server/driver.dart
+++ b/dart/pkg/analysis_server/lib/src/server/driver.dart

@@ -8,9 +8,7 @@
import 'dart:io';
import 'dart:math';

-import 'package:analysis_server/plugin/plugin.dart';
import 'package:analysis_server/src/analysis_server.dart';
-import 'package:analysis_server/src/plugin/plugin_impl.dart';
import 'package:analysis_server/src/plugin/server_plugin.dart';
import 'package:analysis_server/src/server/http_server.dart';
import 'package:analysis_server/src/server/stdio_server.dart';
@@ -19,12 +17,14 @@
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/instrumentation/file_instrumentation.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
+import 'package:analyzer/options.dart';
+import 'package:analyzer/plugin/plugin.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/incremental_logger.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
-import 'package:analyzer/options.dart';
+import 'package:analyzer/src/plugin/plugin_impl.dart';
import 'package:args/args.dart';

/**
@@ -262,6 +262,7 @@
//
ServerPlugin serverPlugin = new ServerPlugin();
List<Plugin> plugins = <Plugin>[];
ExtensionManager manager = new ExtensionManager();
@@ -271,6 +272,7 @@
analysisServerOptions, defaultSdk, service, serverPlugin);
httpServer = new HttpAnalysisServer(socketServer);
stdioServer = new StdioAnalysisServer(socketServer);
+    socketServer.userDefinedPlugins = _userDefinedPlugins;

if (serve_http) {
httpServer.serveHttp(port);

diff --git a/dart/pkg/analysis_server/lib/src/services/completion/local_computer.dart b/dart/pkg/analysis_server/lib/src/services/completion/local_computer.dart
index 028b116..5602d81 100644
--- a/dart/pkg/analysis_server/lib/src/services/completion/local_computer.dart
+++ b/dart/pkg/analysis_server/lib/src/services/completion/local_computer.dart

@@ -429,6 +429,11 @@
final DartCompletionRequest request;
final OpType optype;

+  /**
+   * The simple identifier that is being completed, or null if none.
+   */
+  SimpleIdentifier targetId;
+
_LocalVisitor(this.request, int offset, this.optype) : super(offset);

@override
@@ -626,6 +631,13 @@
}
}

+  @override
+  void visitSimpleIdentifier(SimpleIdentifier node) {
+    // Record the visited identifier so as not to suggest it
+    targetId = node;
+    return super.visitSimpleIdentifier(node);
+  }
+
CompletionSuggestion suggestion, FormalParameterList parameters) {
var paramList = parameters.parameters;
@@ -664,7 +676,7 @@

bool isDeprecated, int defaultRelevance, {ClassDeclaration classDecl}) {
-    if (id != null) {
+    if (id != null && !identical(id, targetId)) {
String completion = id.name;
if (completion != null && completion.length > 0 && completion != '_') {
CompletionSuggestion suggestion = new CompletionSuggestion(

diff --git a/dart/pkg/analysis_server/lib/src/services/completion/optype.dart b/dart/pkg/analysis_server/lib/src/services/completion/optype.dart
index 72c6e22..83ef718 100644
--- a/dart/pkg/analysis_server/lib/src/services/completion/optype.dart
+++ b/dart/pkg/analysis_server/lib/src/services/completion/optype.dart

@@ -139,22 +139,6 @@
@override
void visitBinaryExpression(BinaryExpression node) {
if (identical(entity, node.rightOperand)) {
-      // An empty type argument list is parsed as a binary expression
-      // C<> is parsed as C < 
-      Object entity = this.entity;
-      if (entity is SimpleIdentifier && entity.isSynthetic) {
-        Token operator = node.operator;
-        if (operator != null && operator.lexeme == '<') {
-          Token next = entity.token.next;
-          if (next is StringToken && next.lexeme.length == 0) {
-            next = next.next;
-          }
-          if (next != null && next.lexeme == '>') {
-            optype.includeTypeNameSuggestions = true;
-            return;
-          }
-        }
-      }
optype.includeReturnValueSuggestions = true;
optype.includeTypeNameSuggestions = true;
}
@@ -336,6 +320,12 @@
}

@override
+  void visitFunctionExpression(FunctionExpression node) {}
+
+  @override
+  void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {}
+
+  @override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
if (identical(entity, node.returnType) ||
identical(entity, node.name) && node.returnType == null) {
@@ -448,6 +438,12 @@
}

@override
+  void visitPostfixExpression(PostfixExpression node) {
+    optype.includeReturnValueSuggestions = true;
+    optype.includeTypeNameSuggestions = true;
+  }
+
+  @override
void visitPrefixedIdentifier(PrefixedIdentifier node) {
if (identical(entity, node.identifier)) {
optype.includeInvocationSuggestions = true;
@@ -512,6 +508,12 @@
}

@override
+  void visitThrowExpression(ThrowExpression node) {
+    optype.includeReturnValueSuggestions = true;
+    optype.includeTypeNameSuggestions = true;
+  }
+
+  @override
void visitTypeArgumentList(TypeArgumentList node) {
NodeList<TypeName> arguments = node.arguments;
for (TypeName typeName in arguments) {

diff --git a/dart/pkg/analysis_server/lib/src/services/correction/assist.dart b/dart/pkg/analysis_server/lib/src/services/correction/assist.dart
index 5054644..f71a98f 100644
--- a/dart/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/dart/pkg/analysis_server/lib/src/services/correction/assist.dart

@@ -51,6 +51,8 @@
'CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body");
static const CONVERT_INTO_EXPRESSION_BODY = const AssistKind(
'CONVERT_INTO_EXPRESSION_BODY', 30, "Convert into expression body");
+  static const CONVERT_INTO_FOR_INDEX = const AssistKind(
+      'CONVERT_INTO_FOR_INDEX', 30, "Convert into for-index loop");
static const CONVERT_INTO_IS_NOT =
const AssistKind('CONVERT_INTO_IS_NOT', 30, "Convert into is!");
static const CONVERT_INTO_IS_NOT_EMPTY = const AssistKind(

diff --git a/dart/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/dart/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index 525a198..63287c4 100644
--- a/dart/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/dart/pkg/analysis_server/lib/src/services/correction/assist_internal.dart

@@ -81,6 +81,7 @@
@@ -203,6 +204,11 @@
_coverageMarker();
return;
}
+    // type source might be null, if the type is private
+    if (typeSource == null) {
+      _coverageMarker();
+      return;
+    }
Token keyword = declaredIdentifier.keyword;
if (keyword is KeywordToken && keyword.keyword == Keyword.VAR) {
@@ -215,6 +221,49 @@
}

+    AstNode node = this.node;
+    // should be the name of a simple parameter
+    if (node is! SimpleIdentifier || node.parent is! SimpleFormalParameter) {
+      _coverageMarker();
+      return;
+    }
+    SimpleIdentifier name = node;
+    SimpleFormalParameter parameter = node.parent;
+    // the parameter should not have a type
+    if (parameter.type != null) {
+      _coverageMarker();
+      return;
+    }
+    // prepare propagated type
+    DartType type = name.propagatedType;
+    // TODO(scheglov) If the parameter is in a method declaration, and if the
+    // method overrides a method that has a type for the corresponding
+    // parameter, it would be nice to copy down the type from the overridden
+    // method.
+    if (type is! InterfaceType) {
+      _coverageMarker();
+      return;
+    }
+    // prepare type source
+    String typeSource;
+    {
+      _configureTargetLocation(node);
+      Set<LibraryElement> librariesToImport = new Set<LibraryElement>();
+      typeSource = utils.getTypeSource(type, librariesToImport);
+    }
+    // type source might be null, if the type is private
+    if (typeSource == null) {
+      _coverageMarker();
+      return;
+    }
+    _addInsertEdit(name.offset, '$typeSource '); + // add proposal + _addAssist(AssistKind.ADD_TYPE_ANNOTATION, []); + } + void _addProposal_addTypeAnnotation_VariableDeclaration() { AstNode node = this.node; // check if "var v = 42;^" @@ -258,6 +307,11 @@ _coverageMarker(); return; } + // type source might be null, if the type is private + if (typeSource == null) { + _coverageMarker(); + return; + } // add edit Token keyword = declarationList.keyword; if (keyword is KeywordToken && keyword.keyword == Keyword.VAR) { @@ -270,44 +324,6 @@ _addAssist(AssistKind.ADD_TYPE_ANNOTATION, []); } - void _addProposal_addTypeAnnotation_SimpleFormalParameter() { - AstNode node = this.node; - // should be the name of a simple parameter - if (node is! SimpleIdentifier || node.parent is! SimpleFormalParameter) { - _coverageMarker(); - return; - } - SimpleIdentifier name = node; - SimpleFormalParameter parameter = node.parent; - // the parameter should not have a type - if (parameter.type != null) { - _coverageMarker(); - return; - } - // prepare propagated type - DartType type = name.propagatedType; - // TODO(scheglov) If the parameter is in a method declaration, and if the - // method overrides a method that has a type for the corresponding - // parameter, it would be nice to copy down the type from the overridden - // method. - if (type is! InterfaceType) { - _coverageMarker(); - return; - } - // prepare type source - String typeSource; - { - _configureTargetLocation(node); - Set<LibraryElement> librariesToImport = new Set<LibraryElement>(); - typeSource = utils.getTypeSource(type, librariesToImport); - addLibraryImports(change, unitLibraryElement, librariesToImport); - } - // add edit - _addInsertEdit(name.offset, '$typeSource ');
-  }
-
// prepare enclosing ExpressionStatement
Statement statement = node.getAncestor((node) => node is Statement);
@@ -424,6 +440,81 @@
}

+    // find enclosing ForEachStatement
+    ForEachStatement forEachStatement =
+        node.getAncestor((n) => n is ForEachStatement);
+    if (forEachStatement == null) {
+      _coverageMarker();
+      return;
+    }
+    if (selectionOffset < forEachStatement.offset ||
+        forEachStatement.rightParenthesis.end < selectionOffset) {
+      _coverageMarker();
+      return;
+    }
+    // loop should declare variable
+    DeclaredIdentifier loopVariable = forEachStatement.loopVariable;
+    if (loopVariable == null) {
+      _coverageMarker();
+      return;
+    }
+    // iterable should be VariableElement
+    String listName;
+    Expression iterable = forEachStatement.iterable;
+    if (iterable is SimpleIdentifier &&
+        iterable.staticElement is VariableElement) {
+      listName = iterable.name;
+    } else {
+      _coverageMarker();
+      return;
+    }
+    // iterable should be List
+    {
+      DartType iterableType = iterable.bestType;
+      InterfaceType listType = context.typeProvider.listType;
+      if (iterableType is! InterfaceType ||
+          iterableType.element != listType.element) {
+        _coverageMarker();
+        return;
+      }
+    }
+    // body should be Block
+    if (forEachStatement.body is! Block) {
+      _coverageMarker();
+      return;
+    }
+    Block body = forEachStatement.body;
+    // prepare a name for the index variable
+    String indexName;
+    {
+      Set<String> conflicts =
+          utils.findPossibleLocalVariableConflicts(forEachStatement.offset);
+      if (!conflicts.contains('i')) {
+        indexName = 'i';
+      } else if (!conflicts.contains('j')) {
+        indexName = 'j';
+      } else if (!conflicts.contains('k')) {
+        indexName = 'k';
+      } else {
+        _coverageMarker();
+        return;
+      }
+    }
+    // prepare environment
+    String prefix = utils.getNodePrefix(forEachStatement);
+    String indent = utils.getIndent(1);
+    int firstBlockLine = utils.getLineContentEnd(body.leftBracket.end);
+        rangeStartEnd(forEachStatement, forEachStatement.rightParenthesis),
+        'for (int $indexName = 0;$indexName < $listName.length;$indexName++)');
+        '$prefix$indent$loopVariable =$listName[$indexName];$eol');
+  }
+
// may be child of "is"
AstNode node = this.node;
@@ -711,10 +802,19 @@
_coverageMarker();
return;
}
+    // prepare location
+    int offset;
+    String statementPrefix;
+    if (isExpression.notOperator == null) {
+      offset = targetBlock.leftBracket.end;
+      statementPrefix = indent;
+    } else {
+      offset = targetBlock.rightBracket.end;
+      statementPrefix = '';
+    }
// prepare source
-    int offset = targetBlock.leftBracket.end;
SourceBuilder builder = new SourceBuilder(file, offset);
-    builder.append(eol + prefix + indent);
+    builder.append(eol + prefix + statementPrefix);
builder.append(castTypeCode);
// prepare excluded names
Set<String> excluded = new Set<String>();

diff --git a/dart/pkg/analysis_server/lib/src/services/correction/fix.dart b/dart/pkg/analysis_server/lib/src/services/correction/fix.dart
index 0bca27d..beb3367 100644
--- a/dart/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/dart/pkg/analysis_server/lib/src/services/correction/fix.dart

@@ -44,6 +44,8 @@
class FixKind {
+  static const ADD_FIELD_FORMAL_PARAMETERS = const FixKind(
static const ADD_PACKAGE_DEPENDENCY = const FixKind(
static const ADD_SUPER_CONSTRUCTOR_INVOCATION = const FixKind(
@@ -56,6 +58,9 @@
const FixKind('CREATE_CLASS', 50, "Create class '{0}'");
static const CREATE_CONSTRUCTOR =
const FixKind('CREATE_CONSTRUCTOR', 50, "Create constructor '{0}'");
+  static const CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS = const FixKind(
+      'CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS', 50,
+      "Create constructor for final fields");
static const CREATE_CONSTRUCTOR_SUPER = const FixKind(
'CREATE_CONSTRUCTOR_SUPER', 50, "Create constructor to call {0}");
static const CREATE_FIELD =
@@ -94,6 +99,10 @@
"Remove parentheses in getter invocation");
static const REMOVE_UNNECASSARY_CAST =
const FixKind('REMOVE_UNNECASSARY_CAST', 50, "Remove unnecessary cast");
+  static const REMOVE_UNUSED_CATCH_CLAUSE = const FixKind(
+      'REMOVE_UNUSED_CATCH', 50, "Remove unused 'catch' clause");
+  static const REMOVE_UNUSED_CATCH_STACK = const FixKind(
+      'REMOVE_UNUSED_CATCH_STACK', 50, "Remove unused stack trace variable");
static const REMOVE_UNUSED_IMPORT =
const FixKind('REMOVE_UNUSED_IMPORT', 50, "Remove unused import");
static const REPLACE_BOOLEAN_WITH_BOOL = const FixKind(
@@ -102,6 +111,9 @@
const FixKind('REPLACE_IMPORT_URI', 50, "Replace with '{0}'");
static const REPLACE_VAR_WITH_DYNAMIC = const FixKind(
'REPLACE_VAR_WITH_DYNAMIC', 50, "Replace 'var' with 'dynamic'");
+  static const REPLACE_RETURN_TYPE_FUTURE = const FixKind(
+      'REPLACE_RETURN_TYPE_FUTURE', 50,
+      "Return 'Future' from 'async' function");
static const USE_CONST = const FixKind('USE_CONST', 50, "Change to constant");
static const USE_EFFECTIVE_INTEGER_DIVISION = const FixKind(
'USE_EFFECTIVE_INTEGER_DIVISION', 50,

diff --git a/dart/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/dart/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 17944cd..0ff70e6 100644
--- a/dart/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/dart/pkg/analysis_server/lib/src/services/correction/fix_internal.dart

@@ -35,7 +35,7 @@
/**
* A predicate is a one-argument function that returns a boolean value.
*/
-typedef bool Predicate<E>(E argument);
+typedef bool ElementPredicate(Element argument);

/**
* The computer for Dart fixes.
@@ -134,6 +134,7 @@
}
if (errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST) {
}
if (errorCode == HintCode.DIVISION_OPTIMIZATION) {
@@ -145,9 +146,24 @@
if (errorCode == HintCode.TYPE_CHECK_IS_NULL) {
}
+    if (errorCode == HintCode.UNDEFINED_GETTER) {
+    }
+    if (errorCode == HintCode.UNDEFINED_SETTER) {
+    }
if (errorCode == HintCode.UNNECESSARY_CAST) {
}
+    if (errorCode == HintCode.UNUSED_CATCH_CLAUSE) {
+    }
+    if (errorCode == HintCode.UNUSED_CATCH_STACK) {
+    }
if (errorCode == HintCode.UNUSED_IMPORT) {
}
@@ -198,9 +214,19 @@
}
+    if (errorCode == StaticWarningCode.FINAL_NOT_INITIALIZED) {
+    }
+    if (errorCode == StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1 ||
+        errorCode == StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2 ||
+        errorCode ==
+            StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS) {
+    }
if (errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER) {
if (!isAsync) {
@@ -209,6 +235,9 @@
}
}
+    if (errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE) {
+    }
if (errorCode == StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER) {
@@ -226,6 +255,7 @@
}
if (errorCode == StaticTypeWarningCode.UNDEFINED_GETTER) {
@@ -238,6 +268,7 @@
}
if (errorCode == StaticTypeWarningCode.UNDEFINED_SETTER) {
}
// done
@@ -335,6 +366,49 @@
}
}

+  /**
+   * Here we handle cases when there are no constructors in a class, and the
+   * class has uninitialized final fields.
+   */
+    if (node is! SimpleIdentifier || node.parent is! VariableDeclaration) {
+      return;
+    }
+    ClassDeclaration classDeclaration =
+        node.getAncestor((node) => node is ClassDeclaration);
+    // prepare names of uninitialized final fields
+    List<String> fieldNames = <String>[];
+    for (ClassMember member in classDeclaration.members) {
+      if (member is FieldDeclaration) {
+        VariableDeclarationList variableList = member.fields;
+        if (variableList.isFinal) {
+              .where((v) => v.initializer == null)
+              .map((v) => v.name.name));
+        }
+      }
+    }
+    // prepare location for a new constructor
+    _ConstructorLocation targetLocation =
+        _prepareNewConstructorLocation(classDeclaration);
+    // build constructor source
+    SourceBuilder sb = new SourceBuilder(file, targetLocation.offset);
+    {
+      String indent = '  ';
+      sb.append(targetLocation.prefix);
+      sb.append(indent);
+      sb.append(classDeclaration.name.name);
+      sb.append('(');
+      sb.append(fieldNames.map((name) => 'this.$name').join(', ')); + sb.append(');'); + sb.append(targetLocation.suffix); + } + // insert source + _insertBuilder(sb, unitElement); + // add proposal + _addFix(FixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS, []); + } + void _addFix_createConstructor_insteadOfSyntheticDefault() { TypeName typeName = null; ConstructorName constructorName = null; @@ -1013,6 +1087,39 @@ _addFix(FixKind.CREATE_NO_SUCH_METHOD, []); } + void _addFix_createPartUri() { + if (node is SimpleStringLiteral && node.parent is PartDirective) { + PartDirective partDirective = node.parent; + Source source = partDirective.source; + if (source != null) { + String file = source.fullName; + String libName = unitLibraryElement.name; + SourceEdit edit = new SourceEdit(0, 0, 'part of$libName;$eol$eol');
+      }
+    }
+  }
+
+    InterfaceType futureType = context.typeProvider.futureType;
+    String futureTypeCode = utils.getTypeSource(futureType, librariesToImport);
+    // prepare the existing type
+    TypeName typeName = node.getAncestor((n) => n is TypeName);
+    String nodeCode = utils.getNodeText(typeName);
+    // wrap the existing type with Future
+    String returnTypeCode;
+    if (nodeCode == 'void') {
+      returnTypeCode = futureTypeCode;
+    } else {
+      returnTypeCode = '$futureTypeCode<$nodeCode>';
+    }
+  }
+
void _addFix_importLibrary(FixKind kind, String importPath) {
CompilationUnitElement libraryUnitElement =
unitLibraryElement.definingCompilationUnit;
@@ -1075,8 +1182,10 @@
if (prefix != null) {
SourceRange range = rf.rangeStartLength(node, 0);
_addReplaceEdit(range, '${prefix.displayName}.'); - _addFix(FixKind.IMPORT_LIBRARY_PREFIX, - [libraryElement.displayName, prefix.displayName]); + _addFix(FixKind.IMPORT_LIBRARY_PREFIX, [ + libraryElement.displayName, + prefix.displayName + ]); continue; } // may be update "show" directive @@ -1274,6 +1383,30 @@ _addFix(FixKind.REMOVE_UNNECASSARY_CAST, []); } + void _addFix_removeUnusedCatchClause() { + if (node is SimpleIdentifier) { + AstNode catchClause = node.parent; + if (catchClause is CatchClause && + catchClause.exceptionParameter == node) { + _addRemoveEdit( + rf.rangeStartStart(catchClause.catchKeyword, catchClause.body)); + _addFix(FixKind.REMOVE_UNUSED_CATCH_CLAUSE, []); + } + } + } + + void _addFix_removeUnusedCatchStack() { + if (node is SimpleIdentifier) { + AstNode catchClause = node.parent; + if (catchClause is CatchClause && + catchClause.stackTraceParameter == node && + catchClause.exceptionParameter != null) { + _addRemoveEdit(rf.rangeEndEnd(catchClause.exceptionParameter, node)); + _addFix(FixKind.REMOVE_UNUSED_CATCH_STACK, []); + } + } + } + void _addFix_removeUnusedImport() { // prepare ImportDirective ImportDirective importDirective = @@ -1359,6 +1492,62 @@ } } + void _addFix_undefinedClassAccessor_useSimilar() { + AstNode node = this.node; + if (node is SimpleIdentifier) { + // prepare target + Expression target = null; + if (node.parent is PrefixedIdentifier) { + PrefixedIdentifier invocation = node.parent as PrefixedIdentifier; + target = invocation.prefix; + } + // find getter + if (node.inGetterContext()) { + _addFix_undefinedClassMember_useSimilar(target, (Element element) { + return element is PropertyAccessorElement && element.isGetter || + element is FieldElement && element.getter != null; + }); + } + // find setter + if (node.inSetterContext()) { + _addFix_undefinedClassMember_useSimilar(target, (Element element) { + return element is PropertyAccessorElement && element.isSetter || + element is FieldElement && element.setter != null; + }); + } + } + } + + void _addFix_undefinedClassMember_useSimilar( + Expression target, ElementPredicate predicate) { + if (node is SimpleIdentifier) { + String name = (node as SimpleIdentifier).name; + _ClosestElementFinder finder = + new _ClosestElementFinder(name, predicate, MAX_LEVENSHTEIN_DISTANCE); + // unqualified invocation + if (target == null) { + ClassDeclaration clazz = + node.getAncestor((node) => node is ClassDeclaration); + if (clazz != null) { + ClassElement classElement = clazz.element; + _updateFinderWithClassMembers(finder, classElement); + } + } else { + DartType type = target.bestType; + if (type is InterfaceType) { + ClassElement classElement = type.element; + _updateFinderWithClassMembers(finder, classElement); + } + } + // if we have close enough element, suggest to use it + if (finder._element != null) { + String closestName = finder._element.name; + _addReplaceEdit(rf.rangeNode(node), closestName); + _addFix(FixKind.CHANGE_TO, [closestName]); + } + } + } + void _addFix_undefinedFunction_create() { // should be the name of the invocation if (node is SimpleIdentifier && node.parent is MethodInvocation) {} else { @@ -1549,34 +1738,50 @@ } void _addFix_undefinedMethod_useSimilar() { - if (node is SimpleIdentifier && node.parent is MethodInvocation) { + if (node.parent is MethodInvocation) { MethodInvocation invocation = node.parent as MethodInvocation; - String name = (node as SimpleIdentifier).name; - _ClosestElementFinder finder = new _ClosestElementFinder(name, - (Element element) => element is MethodElement && !element.isOperator, - MAX_LEVENSHTEIN_DISTANCE); - // unqualified invocation - Expression target = invocation.realTarget; - if (target == null) { - ClassDeclaration clazz = - invocation.getAncestor((node) => node is ClassDeclaration); - if (clazz != null) { - ClassElement classElement = clazz.element; - _updateFinderWithClassMembers(finder, classElement); + _addFix_undefinedClassMember_useSimilar(invocation.realTarget, + (Element element) => element is MethodElement && !element.isOperator); + } + } + + /** + * Here we handle cases when a constructors does not initialize all of the + * final fields. + */ + void _addFix_updateConstructor_forUninitializedFinalFields() { + if (node is! SimpleIdentifier || node.parent is! ConstructorDeclaration) { + return; + } + ConstructorDeclaration constructor = node.parent; + // add these fields + List<FieldElement> fields = + error.getProperty(ErrorProperty.NOT_INITIALIZED_FIELDS); + if (fields != null) { + // prepare new parameters code + fields.sort((a, b) => a.nameOffset - b.nameOffset); + String fieldParametersCode = + fields.map((field) => 'this.${field.name}').join(', ');
+      // prepare the last required parameter
+      FormalParameter lastRequiredParameter;
+      List<FormalParameter> parameters = constructor.parameters.parameters;
+      for (FormalParameter parameter in parameters) {
+        if (parameter.kind == ParameterKind.REQUIRED) {
+          lastRequiredParameter = parameter;
}
+      }
+      // append new field formal initializers
+      if (lastRequiredParameter != null) {
+        _addInsertEdit(lastRequiredParameter.end, ', $fieldParametersCode'); } else { - DartType type = target.bestType; - if (type is InterfaceType) { - ClassElement classElement = type.element; - _updateFinderWithClassMembers(finder, classElement); + int offset = constructor.parameters.leftParenthesis.end; + if (parameters.isNotEmpty) { + fieldParametersCode += ', '; } + _addInsertEdit(offset, fieldParametersCode); } - // if we have close enough element, suggest to use it - if (finder._element != null) { - String closestName = finder._element.name; - _addReplaceEdit(rf.rangeNode(node), closestName); - _addFix(FixKind.CHANGE_TO, [closestName]); - } + // add proposal + _addFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, []); } } @@ -1585,8 +1790,7 @@ if (n is MethodInvocation && n.offset == errorOffset && n.length == errorLength) { - MethodInvocation invocation = n as MethodInvocation; - Expression target = invocation.target; + Expression target = n.target; while (target is ParenthesizedExpression) { target = (target as ParenthesizedExpression).expression; } @@ -1594,8 +1798,8 @@ BinaryExpression binary = target as BinaryExpression; _addReplaceEdit(rf.rangeToken(binary.operator), '~/'); // remove everything before and after - _addRemoveEdit(rf.rangeStartStart(invocation, binary.leftOperand)); - _addRemoveEdit(rf.rangeEndEnd(binary.rightOperand, invocation)); + _addRemoveEdit(rf.rangeStartStart(n, binary.leftOperand)); + _addRemoveEdit(rf.rangeEndEnd(binary.rightOperand, n)); // add proposal _addFix(FixKind.USE_EFFECTIVE_INTEGER_DIVISION, []); // done @@ -1886,7 +2090,7 @@ } /** - * Returns the [Type] with given name from the dart:core library. + * Returns the [DartType] with given name from the dart:core library. */ DartType _getCoreType(String name) { List<LibraryElement> libraries = unitLibraryElement.importedLibraries; @@ -2234,7 +2438,7 @@ */ class _ClosestElementFinder { final String _targetName; - final Predicate<Element> _predicate; + final ElementPredicate _predicate; Element _element = null; int _distance;  diff --git a/dart/pkg/analysis_server/lib/src/services/correction/sort_members.dart b/dart/pkg/analysis_server/lib/src/services/correction/sort_members.dart index a7270c2..c66c521 100644 --- a/dart/pkg/analysis_server/lib/src/services/correction/sort_members.dart +++ b/dart/pkg/analysis_server/lib/src/services/correction/sort_members.dart  @@ -7,6 +7,7 @@ import 'package:analysis_server/src/protocol.dart' hide Element; import 'package:analysis_server/src/services/correction/strings.dart'; import 'package:analyzer/src/generated/ast.dart'; +import 'package:analyzer/src/generated/scanner.dart'; /** * Sorter for unit/class members. @@ -41,20 +42,11 @@ final String initialCode; final CompilationUnit unit; String code; + String endOfLine; MemberSorter(this.initialCode, this.unit) { this.code = initialCode; - } - - /** - * Return the EOL to use for [code]. - */ - String get endOfLine { - if (code.contains('\r\n')) { - return '\r\n'; - } else { - return '\n'; - } + this.endOfLine = getEOL(code); } /** @@ -233,6 +225,29 @@ directivesCode = sb.toString(); directivesCode = directivesCode.trimRight(); } + // append comment tokens which otherwise would be removed completely + { + bool firstCommentToken = true; + Token token = unit.beginToken; + while (token != null && + token.type != TokenType.EOF && + token.end < lastDirectiveEnd) { + Token commentToken = token.precedingComments; + while (commentToken != null) { + int offset = commentToken.offset; + int end = commentToken.end; + if (offset > firstDirectiveOffset && offset < lastDirectiveEnd) { + if (firstCommentToken) { + directivesCode += endOfLine; + firstCommentToken = false; + } + directivesCode += code.substring(offset, end) + endOfLine; + } + commentToken = commentToken.next; + } + token = token.next; + } + } // prepare code String beforeDirectives = code.substring(0, firstDirectiveOffset); String afterDirectives = code.substring(lastDirectiveEnd); @@ -297,6 +312,17 @@ _sortAndReorderMembers(members); } + /** + * Return the EOL to use for [code]. + */ + static String getEOL(String code) { + if (code.contains('\r\n')) { + return '\r\n'; + } else { + return '\n'; + } + } + static int _getPriority(_PriorityItem item) { for (int i = 0; i < _PRIORITY_ITEMS.length; i++) { if (_PRIORITY_ITEMS[i] == item) {  diff --git a/dart/pkg/analysis_server/lib/src/services/correction/util.dart b/dart/pkg/analysis_server/lib/src/services/correction/util.dart index f214c9f..c19a4c8 100644 --- a/dart/pkg/analysis_server/lib/src/services/correction/util.dart +++ b/dart/pkg/analysis_server/lib/src/services/correction/util.dart  @@ -12,6 +12,7 @@ show doSourceChange_addElementEdit; import 'package:analysis_server/src/services/correction/source_range.dart'; import 'package:analysis_server/src/services/correction/strings.dart'; +import 'package:analysis_server/src/services/search/element_visitors.dart'; import 'package:analyzer/src/generated/ast.dart'; import 'package:analyzer/src/generated/element.dart'; import 'package:analyzer/src/generated/engine.dart'; @@ -596,6 +597,33 @@ new NodeLocator.con1(offset).searchWithin(unit); /** + * Returns names of elements that might conflict with a new local variable + * declared at [offset]. + */ + Set<String> findPossibleLocalVariableConflicts(int offset) { + Set<String> conflicts = new Set<String>(); + AstNode enclosingNode = findNode(offset); + Block enclosingBlock = enclosingNode.getAncestor((node) => node is Block); + if (enclosingBlock != null) { + SourceRange newRange = rangeStartEnd(offset, enclosingBlock.end); + ExecutableElement enclosingExecutable = + getEnclosingExecutableElement(enclosingNode); + if (enclosingExecutable != null) { + visitChildren(enclosingExecutable, (Element element) { + if (element is LocalElement) { + SourceRange elementRange = element.visibleRange; + if (elementRange != null && elementRange.intersects(newRange)) { + conflicts.add(element.displayName); + } + } + return true; + }); + } + } + return conflicts; + } + + /** * Returns the actual type source of the given [Expression], may be null * if can not be resolved, should be treated as the dynamic type. */ @@ -973,6 +1001,11 @@ // check if imported LibraryElement library = element.library; if (library != null && library != _library) { + // no source, if private + if (element.isPrivate) { + return null; + } + // ensure import ImportElement importElement = _getImportElement(element); if (importElement != null) { if (importElement.prefix != null) { @@ -1005,7 +1038,11 @@ sb.write(", "); } String argumentSrc = getTypeSource(argument, librariesToImport); - sb.write(argumentSrc); + if (argumentSrc != null) { + sb.write(argumentSrc); + } else { + return null; + } } sb.write(">"); }  diff --git a/dart/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart b/dart/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart index e01942c..8d7782c 100644 --- a/dart/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart +++ b/dart/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart  @@ -17,7 +17,6 @@ import 'package:analysis_server/src/services/refactoring/naming_conventions.dart'; import 'package:analysis_server/src/services/refactoring/refactoring.dart'; import 'package:analysis_server/src/services/refactoring/refactoring_internal.dart'; -import 'package:analysis_server/src/services/search/element_visitors.dart'; import 'package:analyzer/src/generated/ast.dart'; import 'package:analyzer/src/generated/element.dart'; import 'package:analyzer/src/generated/java_core.dart'; @@ -51,7 +50,7 @@ String stringLiteralPart; final List<SourceRange> occurrences = <SourceRange>[]; final Map<Element, int> elementIds = <Element, int>{}; - final Set<String> excludedVariableNames = new Set<String>(); + Set<String> excludedVariableNames = new Set<String>(); ExtractLocalRefactoringImpl( this.unit, this.selectionOffset, this.selectionLength) { @@ -94,7 +93,8 @@ _prepareOccurrences(); _prepareOffsetsLengths(); // names - _prepareExcludedNames(); + excludedVariableNames = + utils.findPossibleLocalVariableConflicts(selectionOffset); _prepareNames(); // done return new Future.value(result); @@ -371,31 +371,6 @@ return false; } - void _prepareExcludedNames() { - excludedVariableNames.clear(); - AstNode enclosingNode = - new NodeLocator.con1(selectionOffset).searchWithin(unit); - Block enclosingBlock = enclosingNode.getAncestor((node) => node is Block); - if (enclosingBlock != null) { - SourceRange newVariableVisibleRange = - rangeStartEnd(selectionRange, enclosingBlock.end); - ExecutableElement enclosingExecutable = - getEnclosingExecutableElement(enclosingNode); - if (enclosingExecutable != null) { - visitChildren(enclosingExecutable, (Element element) { - if (element is LocalElement) { - SourceRange elementRange = element.visibleRange; - if (elementRange != null && - elementRange.intersects(newVariableVisibleRange)) { - excludedVariableNames.add(element.displayName); - } - } - return true; - }); - } - } - } - void _prepareNames() { names.clear(); if (stringLiteralPart != null) {  diff --git a/dart/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/dart/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart index f6cb0b3..da4e4e4 100644 --- a/dart/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart +++ b/dart/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart  @@ -179,7 +179,8 @@ _prepareOffsetsLengths(); // getter canCreateGetter = _computeCanCreateGetter(); - _initializeCreateGetter(); + createGetter = + canCreateGetter && _isExpressionForGetter(_selectionExpression); // names _prepareExcludedNames(); _prepareNames(); @@ -523,36 +524,6 @@ } /** - * Initializes [createGetter] flag. - */ - void _initializeCreateGetter() { - createGetter = false; - // maybe we cannot at all - if (!canCreateGetter) { - return; - } - // OK, just expression - if (_selectionExpression != null) { - createGetter = !_hasMethodInvocation(_selectionExpression); - return; - } - // allow code blocks without cycles - if (_selectionStatements != null) { - createGetter = true; - for (Statement statement in _selectionStatements) { - // method invocation is something heavy, - // so we don't want to extract it as a part of a getter - if (_hasMethodInvocation(statement)) { - createGetter = false; - return; - } - // don't allow cycles - statement.accept(new _ResetCanCreateGetterVisitor(this)); - } - } - } - - /** * Fills [_occurrences] field. */ void _initializeOccurrences() { @@ -706,12 +677,29 @@ } /** - * Checks if [node] has a [MethodInvocation]. + * Checks if the given [expression] is reasonable to extract as a getter. */ - static bool _hasMethodInvocation(AstNode node) { - var visitor = new _HasMethodInvocationVisitor(); - node.accept(visitor); - return visitor.result; + static bool _isExpressionForGetter(Expression expression) { + if (expression is BinaryExpression) { + return _isExpressionForGetter(expression.leftOperand) && + _isExpressionForGetter(expression.rightOperand); + } + if (expression is Literal) { + return true; + } + if (expression is PrefixExpression) { + return _isExpressionForGetter(expression.operand); + } + if (expression is PrefixedIdentifier) { + return _isExpressionForGetter(expression.prefix); + } + if (expression is PropertyAccess) { + return _isExpressionForGetter(expression.target); + } + if (expression is SimpleIdentifier) { + return true; + } + return false; } /** @@ -867,15 +855,6 @@ } } -class _HasMethodInvocationVisitor extends RecursiveAstVisitor { - bool result = false; - - @override - visitMethodInvocation(MethodInvocation node) { - result = true; - } -} - class _HasReturnStatementVisitor extends RecursiveAstVisitor { bool hasReturn = false; @@ -961,8 +940,8 @@ new _Occurrence(nodeRange, ref.selectionRange.intersects(nodeRange)); ref._occurrences.add(occurrence); // prepare mapping of parameter names to the occurrence variables - nodePattern.originalToPatternNames.forEach( - (String originalName, String patternName) { + nodePattern.originalToPatternNames + .forEach((String originalName, String patternName) { String selectionName = patternToSelectionName[patternName]; occurrence._parameterOldToOccurrenceName[selectionName] = originalName; }); @@ -1079,36 +1058,6 @@ _Occurrence(this.range, this.isSelection); } -class _ResetCanCreateGetterVisitor extends RecursiveAstVisitor { - final ExtractMethodRefactoringImpl ref; - - _ResetCanCreateGetterVisitor(this.ref); - - @override - visitDoStatement(DoStatement node) { - ref.createGetter = false; - super.visitDoStatement(node); - } - - @override - visitForEachStatement(ForEachStatement node) { - ref.createGetter = false; - super.visitForEachStatement(node); - } - - @override - visitForStatement(ForStatement node) { - ref.createGetter = false; - super.visitForStatement(node); - } - - @override - visitWhileStatement(WhileStatement node) { - ref.createGetter = false; - super.visitWhileStatement(node); - } -} - class _ReturnTypeComputer extends RecursiveAstVisitor { DartType returnType;  diff --git a/dart/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/dart/pkg/analysis_server/lib/src/services/refactoring/move_file.dart index fe1cbe0..3f24fa9 100644 --- a/dart/pkg/analysis_server/lib/src/services/refactoring/move_file.dart +++ b/dart/pkg/analysis_server/lib/src/services/refactoring/move_file.dart  @@ -11,16 +11,20 @@ import 'package:analysis_server/src/services/refactoring/refactoring.dart'; import 'package:analysis_server/src/services/refactoring/refactoring_internal.dart'; import 'package:analysis_server/src/services/search/search_engine.dart'; +import 'package:analyzer/file_system/file_system.dart'; import 'package:analyzer/src/generated/element.dart'; import 'package:analyzer/src/generated/engine.dart'; import 'package:analyzer/src/generated/source.dart'; import 'package:path/path.dart' as pathos; +import 'package:source_span/src/span.dart'; +import 'package:yaml/yaml.dart'; /** * [ExtractLocalRefactoring] implementation. */ class MoveFileRefactoringImpl extends RefactoringImpl implements MoveFileRefactoring { + final ResourceProvider resourceProvider; final pathos.Context pathContext; final SearchEngine searchEngine; final AnalysisContext context; @@ -34,9 +38,13 @@ String oldLibraryDir; String newLibraryDir; - MoveFileRefactoringImpl( - this.pathContext, this.searchEngine, this.context, this.source) { - oldFile = source.fullName; + MoveFileRefactoringImpl(ResourceProvider resourceProvider, this.searchEngine, + this.context, this.source, this.oldFile) + : resourceProvider = resourceProvider, + pathContext = resourceProvider.pathContext { + if (source != null) { + oldFile = source.fullName; + } } @override @@ -56,6 +64,45 @@ @override Future<SourceChange> createChange() async { + // move file + if (source != null) { + return _createFileChange(); + } + // rename project + if (oldFile != null) { + Resource projectFolder = resourceProvider.getResource(oldFile); + if (projectFolder is Folder && projectFolder.exists) { + Resource pubspecFile = projectFolder.getChild('pubspec.yaml'); + if (pubspecFile is File && pubspecFile.exists) { + return _createProjectChange(projectFolder, pubspecFile); + } + } + } + // no change + return null; + } + + @override + bool requiresPreview() => false; + + /** + * Computes the URI to use to reference [newFile] from [reference]. + */ + String _computeNewUri(SourceReference reference) { + String refDir = pathContext.dirname(reference.file); + // try to keep package: URI + if (_isPackageReference(reference)) { + Source newSource = new NonExistingSource(newFile, UriKind.FILE_URI); + Uri restoredUri = context.sourceFactory.restoreUri(newSource); + if (restoredUri != null) { + return restoredUri.toString(); + } + } + // if no package: URI, prepare relative + return _getRelativeUri(newFile, refDir); + } + + Future<SourceChange> _createFileChange() async { change = new SourceChange('Update File References'); List<Source> librarySources = context.getLibrariesContaining(source); await Future.forEach(librarySources, (Source librarySource) async { @@ -84,24 +131,57 @@ return change; } - @override - bool requiresPreview() => false; - - /** - * Computes the URI to use to reference [newFile] from [reference]. - */ - String _computeNewUri(SourceReference reference) { - String refDir = pathContext.dirname(reference.file); - // try to keep package: URI - if (_isPackageReference(reference)) { - Source newSource = new NonExistingSource(newFile, UriKind.FILE_URI); - Uri restoredUri = context.sourceFactory.restoreUri(newSource); - if (restoredUri != null) { - return restoredUri.toString(); + Future<SourceChange> _createProjectChange( + Folder project, File pubspecFile) async { + change = new SourceChange('Rename project'); + String oldPackageName = pathContext.basename(oldFile); + String newPackageName = pathContext.basename(newFile); + // add pubspec.yaml change + { + // prepare "name" field value location + SourceSpan nameSpan; + { + String pubspecString = pubspecFile.readAsStringSync(); + YamlMap pubspecNode = loadYamlNode(pubspecString); + YamlNode nameNode = pubspecNode.nodes['name']; + nameSpan = nameNode.span; } + int nameOffset = nameSpan.start.offset; + int nameLength = nameSpan.length; + // add edit + change.addEdit(pubspecFile.path, pubspecFile.modificationStamp, + new SourceEdit(nameOffset, nameLength, newPackageName)); } - // if no package: URI, prepare relative - return _getRelativeUri(newFile, refDir); + // check all local libraries + for (Source librarySource in context.librarySources) { + // should be a local library + if (!project.contains(librarySource.fullName)) { + continue; + } + // we need LibraryElement + LibraryElement library = context.getLibraryElement(librarySource); + if (library == null) { + continue; + } + // update all imports + updateUriElements(List<UriReferencedElement> uriElements) { + for (UriReferencedElement element in uriElements) { + String uri = element.uri; + if (uri != null) { + String oldPrefix = 'package:$oldPackageName/';
+            if (uri.startsWith(oldPrefix)) {
+                  element.uriOffset + 1, oldPrefix.length,
+                  'package:$newPackageName/')); + } + } + } + } + updateUriElements(library.imports); + updateUriElements(library.exports); + } + // done + return change; } String _getRelativeUri(String path, String from) {  diff --git a/dart/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart b/dart/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart index 3503311..aac5275 100644 --- a/dart/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart +++ b/dart/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart  @@ -6,6 +6,7 @@ import 'package:analysis_server/src/services/correction/status.dart'; import 'package:analysis_server/src/services/correction/strings.dart'; +import 'package:analyzer/src/generated/scanner.dart'; /** * Returns the [RefactoringStatus] with severity: @@ -164,6 +165,15 @@ String message = "$desc must not be empty.";
return new RefactoringStatus.fatal(message);
}
+  // keyword
+  {
+    Keyword keyword = Keyword.keywords[identifier];
+    if (keyword != null && !keyword.isPseudoKeyword) {
+      String message = "$desc must not be a keyword."; + return new RefactoringStatus.fatal(message); + } + } + // first character int currentChar = identifier.codeUnitAt(0); if (!isLetter(currentChar) && currentChar != CHAR_UNDERSCORE && @@ -171,6 +181,7 @@ String message = "$desc must begin with $beginDesc."; return new RefactoringStatus.fatal(message); } + // other characters for (int i = 1; i < length; i++) { currentChar = identifier.codeUnitAt(i); if (!isLetterOrDigit(currentChar) && @@ -181,6 +192,7 @@ return new RefactoringStatus.fatal(message); } } + // OK return new RefactoringStatus(); }  diff --git a/dart/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart b/dart/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart index c73f98c..1a29c3e 100644 --- a/dart/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart +++ b/dart/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart  @@ -24,11 +24,11 @@ import 'package:analysis_server/src/services/refactoring/rename_local.dart'; import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart'; import 'package:analysis_server/src/services/search/search_engine.dart'; +import 'package:analyzer/file_system/file_system.dart'; import 'package:analyzer/src/generated/ast.dart'; import 'package:analyzer/src/generated/element.dart'; import 'package:analyzer/src/generated/engine.dart'; import 'package:analyzer/src/generated/source.dart'; -import 'package:path/path.dart' as pathos; /** * [Refactoring] to convert getters into normal [MethodDeclaration]s. @@ -278,10 +278,11 @@ /** * Returns a new [MoveFileRefactoring] instance. */ - factory MoveFileRefactoring(pathos.Context pathContext, - SearchEngine searchEngine, AnalysisContext context, Source source) { + factory MoveFileRefactoring(ResourceProvider resourceProvider, + SearchEngine searchEngine, AnalysisContext context, Source source, + String oldFile) { return new MoveFileRefactoringImpl( - pathContext, searchEngine, context, source); + resourceProvider, searchEngine, context, source, oldFile); } /**  diff --git a/dart/pkg/analysis_server/lib/src/socket_server.dart b/dart/pkg/analysis_server/lib/src/socket_server.dart index efeb876..e7ad5ac 100644 --- a/dart/pkg/analysis_server/lib/src/socket_server.dart +++ b/dart/pkg/analysis_server/lib/src/socket_server.dart  @@ -12,6 +12,7 @@ import 'package:analysis_server/src/services/index/local_file_index.dart'; import 'package:analyzer/file_system/physical_file_system.dart'; import 'package:analyzer/instrumentation/instrumentation.dart'; +import 'package:analyzer/plugin/plugin.dart'; import 'package:analyzer/source/pub_package_map_provider.dart'; import 'package:analyzer/src/generated/sdk_io.dart'; @@ -33,6 +34,11 @@ */ AnalysisServer analysisServer; + /** + * The plugins that are defined outside the analysis_server package. + */ + List<Plugin> userDefinedPlugins; + SocketServer(this.analysisServerOptions, this.defaultSdk, this.instrumentationService, this.serverPlugin); @@ -73,6 +79,7 @@ analysisServerOptions, defaultSdk, instrumentationService, rethrowExceptions: false); _initializeHandlers(analysisServer); + analysisServer.userDefinedPlugins = userDefinedPlugins; } /**  diff --git a/dart/pkg/analysis_server/lib/src/status/ast_writer.dart b/dart/pkg/analysis_server/lib/src/status/ast_writer.dart index 4d410d6..6cb30db 100644 --- a/dart/pkg/analysis_server/lib/src/status/ast_writer.dart +++ b/dart/pkg/analysis_server/lib/src/status/ast_writer.dart  @@ -161,6 +161,9 @@ buffer.write('..'); buffer.write(node.offset + node.length - 1); buffer.write(']</span>'); + if (node.isSynthetic) { + buffer.write(' (synthetic)'); + } buffer.write('<br>'); } }  diff --git a/dart/pkg/analysis_server/lib/starter.dart b/dart/pkg/analysis_server/lib/starter.dart index 9483fff..8d5658a 100644 --- a/dart/pkg/analysis_server/lib/starter.dart +++ b/dart/pkg/analysis_server/lib/starter.dart  @@ -4,9 +4,9 @@ library driver; -import 'package:analysis_server/plugin/plugin.dart'; import 'package:analysis_server/src/server/driver.dart'; import 'package:analyzer/instrumentation/instrumentation.dart'; +import 'package:analyzer/plugin/plugin.dart'; /** * An object that can be used to start an analysis server.  diff --git a/dart/pkg/analysis_server/pubspec.yaml b/dart/pkg/analysis_server/pubspec.yaml index 3af3854..121f148 100644 --- a/dart/pkg/analysis_server/pubspec.yaml +++ b/dart/pkg/analysis_server/pubspec.yaml  @@ -6,11 +6,12 @@ environment: sdk: '>=1.0.0 <2.0.0' dependencies: - analyzer: 0.23.0 + analyzer: 0.25.0-dev.1 args: '>=0.12.1 <0.13.0' logging: any path: any watcher: any + yaml: any dev_dependencies: html5lib: any mock: '>=0.11.0 <0.12.0'  diff --git a/dart/pkg/analysis_server/test/analysis/get_hover_test.dart b/dart/pkg/analysis_server/test/analysis/get_hover_test.dart index a39f616..d499a4c 100644 --- a/dart/pkg/analysis_server/test/analysis/get_hover_test.dart +++ b/dart/pkg/analysis_server/test/analysis/get_hover_test.dart  @@ -81,6 +81,7 @@ // element expect(hover.containingLibraryName, 'my.library'); expect(hover.containingLibraryPath, testFile); + expect(hover.containingClassDescription, isNull); expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); expect(hover.elementDescription, 'fff(int a, String b) → List<String>'); expect(hover.elementKind, 'function'); @@ -101,6 +102,7 @@ '''); return prepareHover('123').then((HoverInformation hover) { // literal, no Element + expect(hover.containingClassDescription, isNull); expect(hover.elementDescription, isNull); expect(hover.elementKind, isNull); // types @@ -125,6 +127,7 @@ // element expect(hover.containingLibraryName, 'my.library'); expect(hover.containingLibraryPath, testFile); + expect(hover.containingClassDescription, 'A'); expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); expect(hover.elementDescription, 'A.mmm(int a, String b) → List<String>'); expect(hover.elementKind, 'method'); @@ -180,6 +183,7 @@ // element expect(hover.containingLibraryName, 'my.library'); expect(hover.containingLibraryPath, testFile); + expect(hover.containingClassDescription, 'A'); expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); expect(hover.elementDescription, 'String fff'); expect(hover.elementKind, 'field');  diff --git a/dart/pkg/analysis_server/test/analysis/notification_outline_test.dart b/dart/pkg/analysis_server/test/analysis/notification_outline_test.dart index be856cd..cae3f7b 100644 --- a/dart/pkg/analysis_server/test/analysis/notification_outline_test.dart +++ b/dart/pkg/analysis_server/test/analysis/notification_outline_test.dart  @@ -60,7 +60,7 @@ test_class() { addTestFile(''' -class A { +class A<K, V> { int fa, fb; String fc; A(int i, String s); @@ -85,9 +85,10 @@ Element element_A = outline_A.element; expect(element_A.kind, ElementKind.CLASS); expect(element_A.name, "A"); + expect(element_A.typeParameters, "<K, V>"); { Location location = element_A.location; - expect(location.offset, testCode.indexOf("A {")); + expect(location.offset, testCode.indexOf("A<K, V> {")); expect(location.length, 1); } expect(element_A.parameters, null); @@ -227,6 +228,7 @@ Element element_B = outline_B.element; expect(element_B.kind, ElementKind.CLASS); expect(element_B.name, "B"); + expect(element_B.typeParameters, isNull); { Location location = element_B.location; expect(location.offset, testCode.indexOf("B {")); @@ -677,11 +679,12 @@ test_topLevel() { addTestFile(''' -typedef String FTA(int i, String s); +typedef String FTA<K, V>(int i, String s); typedef FTB(int p); -class A {} +class A<T> {} class B {} -class CTA = A with B; +class CTA<T> = A<T> with B; +class CTB = A with B; String fA(int i, String s) => null; fB(int p) => null; String get propA => null; @@ -690,16 +693,17 @@ return prepareOutline().then((_) { Outline unitOutline = outline; List<Outline> topOutlines = unitOutline.children; - expect(topOutlines, hasLength(9)); + expect(topOutlines, hasLength(10)); // FTA { Outline outline = topOutlines[0]; Element element = outline.element; expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); expect(element.name, "FTA"); + expect(element.typeParameters, "<K, V>"); { Location location = element.location; - expect(location.offset, testCode.indexOf("FTA(")); + expect(location.offset, testCode.indexOf("FTA<K, V>(")); expect(location.length, "FTA".length); } expect(element.parameters, "(int i, String s)"); @@ -711,6 +715,7 @@ Element element = outline.element; expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); expect(element.name, "FTB"); + expect(element.typeParameters, isNull); { Location location = element.location; expect(location.offset, testCode.indexOf("FTB(")); @@ -725,18 +730,28 @@ Element element = outline.element; expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); expect(element.name, "CTA"); + expect(element.typeParameters, '<T>'); { Location location = element.location; - expect(location.offset, testCode.indexOf("CTA =")); + expect(location.offset, testCode.indexOf("CTA<T> =")); expect(location.length, "CTA".length); } expect(element.parameters, isNull); expect(element.returnType, isNull); } - // fA + // CTB { Outline outline = topOutlines[5]; Element element = outline.element; + expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); + expect(element.name, 'CTB'); + expect(element.typeParameters, isNull); + expect(element.returnType, isNull); + } + // fA + { + Outline outline = topOutlines[6]; + Element element = outline.element; expect(element.kind, ElementKind.FUNCTION); expect(element.name, "fA"); { @@ -749,7 +764,7 @@ } // fB { - Outline outline = topOutlines[6]; + Outline outline = topOutlines[7]; Element element = outline.element; expect(element.kind, ElementKind.FUNCTION); expect(element.name, "fB"); @@ -763,7 +778,7 @@ } // propA { - Outline outline = topOutlines[7]; + Outline outline = topOutlines[8]; Element element = outline.element; expect(element.kind, ElementKind.GETTER); expect(element.name, "propA"); @@ -777,7 +792,7 @@ } // propB { - Outline outline = topOutlines[8]; + Outline outline = topOutlines[9]; Element element = outline.element; expect(element.kind, ElementKind.SETTER); expect(element.name, "propB");  diff --git a/dart/pkg/analysis_server/test/analysis_server_test.dart b/dart/pkg/analysis_server/test/analysis_server_test.dart index 5913930..efd1c16 100644 --- a/dart/pkg/analysis_server/test/analysis_server_test.dart +++ b/dart/pkg/analysis_server/test/analysis_server_test.dart  @@ -191,34 +191,6 @@ }); } - test_getAnalysisContext_nested() { - String dir1Path = '/dir1'; - String dir2Path = dir1Path + '/dir2'; - String filePath = dir2Path + '/file.dart'; - Folder dir1 = resourceProvider.newFolder(dir1Path); - Folder dir2 = resourceProvider.newFolder(dir2Path); - resourceProvider.newFile(filePath, 'library lib;'); - - AnalysisContext context1 = AnalysisEngine.instance.createAnalysisContext(); - AnalysisContext context2 = AnalysisEngine.instance.createAnalysisContext(); - server.folderMap[dir1] = context1; - server.folderMap[dir2] = context2; - - expect(server.getAnalysisContext(filePath), context2); - } - - test_getAnalysisContext_simple() { - String dirPath = '/dir'; - String filePath = dirPath + '/file.dart'; - Folder dir = resourceProvider.newFolder(dirPath); - resourceProvider.newFile(filePath, 'library lib;'); - - AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); - server.folderMap[dir] = context; - - expect(server.getAnalysisContext(filePath), context); - } - Future test_getAnalysisContextForSource() { // Subscribe to STATUS so we'll know when analysis is done. server.serverServices = [ServerService.STATUS].toSet(); @@ -311,25 +283,6 @@ expect(source.fullName, filePath); } - test_operationsRemovedOnContextDisposal() async { - resourceProvider.newFolder('/foo'); - resourceProvider.newFile('/foo/baz.dart', 'library lib;'); - resourceProvider.newFolder('/bar'); - resourceProvider.newFile('/bar/baz.dart', 'library lib;'); - server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); - await pumpEventQueue(); - AnalysisContext contextFoo = server.getAnalysisContext('/foo/baz.dart'); - AnalysisContext contextBar = server.getAnalysisContext('/bar/baz.dart'); - _MockServerOperation operationFoo = new _MockServerOperation(contextFoo); - _MockServerOperation operationBar = new _MockServerOperation(contextBar); - server.scheduleOperation(operationFoo); - server.scheduleOperation(operationBar); - server.setAnalysisRoots('1', ['/foo'], [], {}); - await pumpEventQueue(); - expect(operationFoo.isComplete, isTrue); - expect(operationBar.isComplete, isFalse); - } - /** * Test that having multiple analysis contexts analyze the same file doesn't * cause that file to receive duplicate notifications when it's modified. @@ -377,6 +330,25 @@ } } + test_operationsRemovedOnContextDisposal() async { + resourceProvider.newFolder('/foo'); + resourceProvider.newFile('/foo/baz.dart', 'library lib;'); + resourceProvider.newFolder('/bar'); + resourceProvider.newFile('/bar/baz.dart', 'library lib;'); + server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); + await pumpEventQueue(); + AnalysisContext contextFoo = server.getAnalysisContext('/foo/baz.dart'); + AnalysisContext contextBar = server.getAnalysisContext('/bar/baz.dart'); + _MockServerOperation operationFoo = new _MockServerOperation(contextFoo); + _MockServerOperation operationBar = new _MockServerOperation(contextBar); + server.scheduleOperation(operationFoo); + server.scheduleOperation(operationBar); + server.setAnalysisRoots('1', ['/foo'], [], {}); + await pumpEventQueue(); + expect(operationFoo.isComplete, isTrue); + expect(operationBar.isComplete, isFalse); + } + Future test_prioritySourcesChangedEvent() { resourceProvider.newFolder('/foo');  diff --git a/dart/pkg/analysis_server/test/integration/protocol_matchers.dart b/dart/pkg/analysis_server/test/integration/protocol_matchers.dart index 633c380..1909ee9 100644 --- a/dart/pkg/analysis_server/test/integration/protocol_matchers.dart +++ b/dart/pkg/analysis_server/test/integration/protocol_matchers.dart  @@ -1178,6 +1178,7 @@ * "flags": int * "parameters": optional String * "returnType": optional String + * "typeParameters": optional String * } */ final Matcher isElement = new LazyMatcher(() => new MatchesJsonObject( @@ -1188,7 +1189,8 @@ }, optionalFields: { "location": isLocation, "parameters": isString, - "returnType": isString + "returnType": isString, + "typeParameters": isString })); /** @@ -1444,6 +1446,7 @@ * "length": int * "containingLibraryPath": optional String * "containingLibraryName": optional String + * "containingClassDescription": optional String * "dartdoc": optional String * "elementDescription": optional String * "elementKind": optional String @@ -1459,6 +1462,7 @@ }, optionalFields: { "containingLibraryPath": isString, "containingLibraryName": isString, + "containingClassDescription": isString, "dartdoc": isString, "elementDescription": isString, "elementKind": isString,  diff --git a/dart/pkg/analysis_server/test/protocol_server_test.dart b/dart/pkg/analysis_server/test/protocol_server_test.dart index 8a3851b..26aae55 100644 --- a/dart/pkg/analysis_server/test/protocol_server_test.dart +++ b/dart/pkg/analysis_server/test/protocol_server_test.dart  @@ -195,24 +195,38 @@ void test_fromElement_CLASS() { engine.Source source = addSource('/test.dart', ''' @deprecated -abstract class _MyClass {}'''); +abstract class _A {} +class B<K, V> {}'''); engine.CompilationUnit unit = resolveLibraryUnit(source); - engine.ClassElement engineElement = findElementInUnit(unit, '_MyClass'); - // create notification Element - Element element = newElement_fromEngine(engineElement); - expect(element.kind, ElementKind.CLASS); - expect(element.name, '_MyClass'); { - Location location = element.location; - expect(location.file, '/test.dart'); - expect(location.offset, 27); - expect(location.length, '_MyClass'.length); - expect(location.startLine, 2); - expect(location.startColumn, 16); + engine.ClassElement engineElement = findElementInUnit(unit, '_A'); + // create notification Element + Element element = newElement_fromEngine(engineElement); + expect(element.kind, ElementKind.CLASS); + expect(element.name, '_A'); + expect(element.typeParameters, isNull); + { + Location location = element.location; + expect(location.file, '/test.dart'); + expect(location.offset, 27); + expect(location.length, '_A'.length); + expect(location.startLine, 2); + expect(location.startColumn, 16); + } + expect(element.parameters, isNull); + expect(element.flags, Element.FLAG_ABSTRACT | + Element.FLAG_DEPRECATED | + Element.FLAG_PRIVATE); } - expect(element.parameters, isNull); - expect(element.flags, - Element.FLAG_ABSTRACT | Element.FLAG_DEPRECATED | Element.FLAG_PRIVATE); + { + engine.ClassElement engineElement = findElementInUnit(unit, 'B'); + // create notification Element + Element element = newElement_fromEngine(engineElement); + expect(element.kind, ElementKind.CLASS); + expect(element.name, 'B'); + expect(element.typeParameters, '<K, V>'); + expect(element.flags, 0); + } } void test_fromElement_CONSTRUCTOR() { @@ -227,6 +241,7 @@ Element element = newElement_fromEngine(engineElement); expect(element.kind, ElementKind.CONSTRUCTOR); expect(element.name, 'myConstructor'); + expect(element.typeParameters, isNull); { Location location = element.location; expect(location.file, '/test.dart'); @@ -278,20 +293,21 @@ void test_fromElement_FUNCTION_TYPE_ALIAS() { engine.Source source = addSource('/test.dart', ''' -typedef int f(String x); +typedef int F<T>(String x); '''); engine.CompilationUnit unit = resolveLibraryUnit(source); engine.FunctionTypeAliasElement engineElement = - findElementInUnit(unit, 'f'); + findElementInUnit(unit, 'F'); // create notification Element Element element = newElement_fromEngine(engineElement); expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); - expect(element.name, 'f'); + expect(element.name, 'F'); + expect(element.typeParameters, '<T>'); { Location location = element.location; expect(location.file, '/test.dart'); expect(location.offset, 12); - expect(location.length, 'f'.length); + expect(location.length, 'F'.length); expect(location.startLine, 1); expect(location.startColumn, 13); }  diff --git a/dart/pkg/analysis_server/test/reflective_tests.dart b/dart/pkg/analysis_server/test/reflective_tests.dart index f421e6c..8180cf7 100644 --- a/dart/pkg/analysis_server/test/reflective_tests.dart +++ b/dart/pkg/analysis_server/test/reflective_tests.dart  @@ -75,7 +75,7 @@ var invocationResult = null; try { invocationResult = instanceMirror.invoke(symbol, []).reflectee; - } on NoSuchMethodError catch (e) {} + } on NoSuchMethodError {} if (invocationResult is Future) { return invocationResult; } else {  diff --git a/dart/pkg/analysis_server/test/services/completion/completion_target_test.dart b/dart/pkg/analysis_server/test/services/completion/completion_target_test.dart index 16983af..0bf95cf 100644 --- a/dart/pkg/analysis_server/test/services/completion/completion_target_test.dart +++ b/dart/pkg/analysis_server/test/services/completion/completion_target_test.dart  @@ -475,9 +475,9 @@ } test_TypeArgumentList() { - // SimpleIdentifier BinaryExpression ExpressionStatement + // TypeName TypeArgumentList TypeName addTestSource('main() { C<^> c; }'); - assertTarget('', 'C < '); + assertTarget('', '<>'); } test_TypeArgumentList2() {  diff --git a/dart/pkg/analysis_server/test/services/completion/local_computer_test.dart b/dart/pkg/analysis_server/test/services/completion/local_computer_test.dart index fed9d0f..e0aca46 100644 --- a/dart/pkg/analysis_server/test/services/completion/local_computer_test.dart +++ b/dart/pkg/analysis_server/test/services/completion/local_computer_test.dart  @@ -194,15 +194,6 @@ assertNotSuggested('x'); } - test_overrides() { - addTestSource(''' -class A {m() {}} -class B extends A {m() {^}} -'''); - expect(computeFast(), isTrue); - assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); - } - test_break_ignores_unrelated_statements() { addTestSource(''' void main() { @@ -576,6 +567,13 @@ expect(suggestion.hasNamedParameters, false); } + test_ignore_symbol_being_completed() { + addTestSource('class MyClass { } main(MC^) { }'); + expect(computeFast(), isTrue); + assertSuggestLocalClass('MyClass'); + assertNotSuggested('MC'); + } + test_InstanceCreationExpression() { addTestSource(''' class A {foo(){var f; {var x;}}} @@ -743,6 +741,15 @@ expect(suggestion.hasNamedParameters, false); } + test_overrides() { + addTestSource(''' +class A {m() {}} +class B extends A {m() {^}} +'''); + expect(computeFast(), isTrue); + assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); + } + test_shadowed_name() { addTestSource('var a; class A { var a; m() { ^ } }'); expect(computeFast(), isTrue);  diff --git a/dart/pkg/analysis_server/test/services/completion/optype_test.dart b/dart/pkg/analysis_server/test/services/completion/optype_test.dart index 897fb20..a2634b1 100644 --- a/dart/pkg/analysis_server/test/services/completion/optype_test.dart +++ b/dart/pkg/analysis_server/test/services/completion/optype_test.dart  @@ -657,6 +657,18 @@ assertOpType(typeNames: true); } + test_FunctionExpression() { + // BlockFunctionBody FunctionExpression FunctionDeclaration + addTestSource('main()^ { int b = 2; b++; b. }'); + assertOpType(); + } + + test_FunctionExpressionInvocation() { + // ArgumentList FunctionExpressionInvocation ExpressionStatement + addTestSource('main() { ((x) => x + 7)^(2) }'); + assertOpType(); + } + test_FunctionTypeAlias() { // SimpleIdentifier FunctionTypeAlias CompilationUnit addTestSource('typedef n^ ;'); @@ -982,6 +994,12 @@ assertOpType(invocation: true); } + test_PostfixExpression() { + // SimpleIdentifier PostfixExpression ForStatement + addTestSource('int x = 0; main() {ax+^+;}'); + assertOpType(returnValue: true, typeNames: true); + } + test_PrefixedIdentifier_class_const() { // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block addTestSource('main() {A.^}'); @@ -1056,6 +1074,12 @@ assertOpType(invocation: true); } + test_ThrowExpression() { + // SimpleIdentifier ThrowExpression ExpressionStatement + addTestSource('main() {throw ^;}'); + assertOpType(returnValue: true, typeNames: true); + } + test_TopLevelVariableDeclaration_typed_name() { // SimpleIdentifier VariableDeclaration VariableDeclarationList // TopLevelVariableDeclaration  diff --git a/dart/pkg/analysis_server/test/services/correction/assist_test.dart b/dart/pkg/analysis_server/test/services/correction/assist_test.dart index d3c11d0..52764fe 100644 --- a/dart/pkg/analysis_server/test/services/correction/assist_test.dart +++ b/dart/pkg/analysis_server/test/services/correction/assist_test.dart  @@ -97,6 +97,73 @@ length = 0; } + void test_addTypeAnnotation_BAD_privateType_closureParameter() { + addSource('/my_lib.dart', ''' +library my_lib; +class A {} +class _B extends A {} +foo(f(_B p)) {} +'''); + resolveTestUnit(''' +import 'my_lib.dart'; +main() { + foo((test) {}); +} + '''); + assertNoAssistAt('test)', AssistKind.ADD_TYPE_ANNOTATION); + } + + void test_addTypeAnnotation_BAD_privateType_declaredIdentifier() { + addSource('/my_lib.dart', ''' +library my_lib; +class A {} +class _B extends A {} +List<_B> getValues() => []; +'''); + resolveTestUnit(''' +import 'my_lib.dart'; +class A<T> { + main() { + for (var item in getValues()) { + } + } +} +'''); + assertNoAssistAt('var item', AssistKind.ADD_TYPE_ANNOTATION); + } + + void test_addTypeAnnotation_BAD_privateType_list() { + addSource('/my_lib.dart', ''' +library my_lib; +class A {} +class _B extends A {} +List<_B> getValues() => []; +'''); + resolveTestUnit(''' +import 'my_lib.dart'; +main() { + var v = getValues(); +} +'''); + assertNoAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION); + } + + void test_addTypeAnnotation_BAD_privateType_variable() { + addSource('/my_lib.dart', ''' +library my_lib; +class A {} +class _B extends A {} +_B getValue() => new _B(); +'''); + resolveTestUnit(''' +import 'my_lib.dart'; +main() { + var v = getValue(); +} +'''); + assertNoAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION); + } + void test_addTypeAnnotation_classField_OK_final() { resolveTestUnit(''' class A { @@ -520,6 +587,23 @@ assertNoAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION); } + void test_addTypeAnnotation_OK_privateType_sameLibrary() { + resolveTestUnit(''' +class _A {} +_A getValue() => new _A(); +main() { + var v = getValue(); +} +'''); + assertHasAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION, ''' +class _A {} +_A getValue() => new _A(); +main() { + _A v = getValue(); +} +'''); + } + void test_addTypeAnnotation_parameter_BAD_hasExplicitType() { resolveTestUnit(''' foo(f(int p)) {} @@ -846,6 +930,153 @@ assertNoAssistAt('fff()', AssistKind.CONVERT_INTO_EXPRESSION_BODY); } + void test_convertToForIndex_BAD_bodyNotBlock() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) print(item); +} +'''); + assertNoAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX); + } + + void test_convertToForIndex_BAD_doesNotDeclareVariable() { + resolveTestUnit(''' +main(List<String> items) { + String item; + for (item in items) { + print(item); + } +} +'''); + assertNoAssistAt('for (item', AssistKind.CONVERT_INTO_FOR_INDEX); + } + + void test_convertToForIndex_BAD_iterableIsNotVariable() { + resolveTestUnit(''' +main() { + for (String item in ['a', 'b', 'c']) { + print(item); + } +} +'''); + assertNoAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX); + } + + void test_convertToForIndex_BAD_iterableNotList() { + resolveTestUnit(''' +main(Iterable<String> items) { + for (String item in items) { + print(item); + } +} +'''); + assertNoAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX); + } + + void test_convertToForIndex_BAD_usesIJK() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + print(item); + int i, j, k; + } +} +'''); + assertNoAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX); + } + + void test_convertToForIndex_OK_onDeclaredIdentifier_name() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + print(item); + } +} +'''); + assertHasAssistAt('item in', AssistKind.CONVERT_INTO_FOR_INDEX, ''' +main(List<String> items) { + for (int i = 0; i < items.length; i++) { + String item = items[i]; + print(item); + } +} +'''); + } + + void test_convertToForIndex_OK_onDeclaredIdentifier_type() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + print(item); + } +} +'''); + assertHasAssistAt('tring item', AssistKind.CONVERT_INTO_FOR_INDEX, ''' +main(List<String> items) { + for (int i = 0; i < items.length; i++) { + String item = items[i]; + print(item); + } +} +'''); + } + + void test_convertToForIndex_OK_onFor() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + print(item); + } +} +'''); + assertHasAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX, ''' +main(List<String> items) { + for (int i = 0; i < items.length; i++) { + String item = items[i]; + print(item); + } +} +'''); + } + + void test_convertToForIndex_OK_usesI() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + int i = 0; + } +} +'''); + assertHasAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX, ''' +main(List<String> items) { + for (int j = 0; j < items.length; j++) { + String item = items[j]; + int i = 0; + } +} +'''); + } + + void test_convertToForIndex_OK_usesIJ() { + resolveTestUnit(''' +main(List<String> items) { + for (String item in items) { + print(item); + int i = 0, j = 1; + } +} +'''); + assertHasAssistAt('for (String', AssistKind.CONVERT_INTO_FOR_INDEX, ''' +main(List<String> items) { + for (int k = 0; k < items.length; k++) { + String item = items[k]; + print(item); + int i = 0, j = 1; + } +} +'''); + } + void test_convertToIsNot_OK_childOfIs_left() { resolveTestUnit(''' main(p) { @@ -1345,7 +1576,7 @@ assertNoAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE); } - void test_introduceLocalTestedType_OK_if() { + void test_introduceLocalTestedType_OK_if_is() { resolveTestUnit(''' class MyTypeName {} main(p) { @@ -1373,6 +1604,34 @@ assertHasAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected); } + void test_introduceLocalTestedType_OK_if_isNot() { + resolveTestUnit(''' +class MyTypeName {} +main(p) { + if (p is! MyTypeName) { + return; + } +} +'''); + String expected = ''' +class MyTypeName {} +main(p) { + if (p is! MyTypeName) { + return; + } + MyTypeName myTypeName = p; +} +'''; + assertHasAssistAt( + 'is! MyType', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected); + _assertLinkedGroup(change.linkedEditGroups[0], [ + 'myTypeName = ' + ], expectedSuggestions( + LinkedEditSuggestionKind.VARIABLE, ['myTypeName', 'typeName', 'name'])); + // another good location + assertHasAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected); + } + void test_introduceLocalTestedType_OK_while() { resolveTestUnit(''' main(p) {  diff --git a/dart/pkg/analysis_server/test/services/correction/fix_test.dart b/dart/pkg/analysis_server/test/services/correction/fix_test.dart index 339645b..aa12e4d 100644 --- a/dart/pkg/analysis_server/test/services/correction/fix_test.dart +++ b/dart/pkg/analysis_server/test/services/correction/fix_test.dart  @@ -26,7 +26,13 @@ @reflectiveTest class FixProcessorTest extends AbstractSingleUnitTest { - AnalysisErrorFilter errorFilter = null; + AnalysisErrorFilter errorFilter = (AnalysisError error) { + return error.errorCode != HintCode.UNUSED_CATCH_CLAUSE && + error.errorCode != HintCode.UNUSED_CATCH_STACK && + error.errorCode != HintCode.UNUSED_ELEMENT && + error.errorCode != HintCode.UNUSED_FIELD && + error.errorCode != HintCode.UNUSED_LOCAL_VARIABLE; + }; Fix fix; SourceChange change; @@ -97,6 +103,63 @@ verifyNoTestUnitErrors = false; } + void test_addFieldFormalParameters_hasRequiredParameter() { + resolveTestUnit(''' +class Test { + final int a; + final int b; + final int c; + Test(this.a); +} +'''); + assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, ''' +class Test { + final int a; + final int b; + final int c; + Test(this.a, this.b, this.c); +} +'''); + } + + void test_addFieldFormalParameters_noParameters() { + resolveTestUnit(''' +class Test { + final int a; + final int b; + final int c; + Test(); +} +'''); + assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, ''' +class Test { + final int a; + final int b; + final int c; + Test(this.a, this.b, this.c); +} +'''); + } + + void test_addFieldFormalParameters_noRequiredParameter() { + resolveTestUnit(''' +class Test { + final int a; + final int b; + final int c; + Test([this.c]); +} +'''); + assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, ''' +class Test { + final int a; + final int b; + final int c; + Test(this.a, this.b, [this.c]); +} +'''); + } + void test_addSync_blockFunctionBody() { resolveTestUnit(''' foo() {} @@ -287,6 +350,28 @@ _assertLinkedGroup(change.linkedEditGroups[0], ['Test v =', 'Test {']); } + void test_createConstructor_forFinalFields() { + errorFilter = (AnalysisError error) { + return error.message.contains("'a'"); + }; + resolveTestUnit(''' +class Test { + final int a; + final int b = 2; + final int c; +} +'''); + assertHasFix(FixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS, ''' +class Test { + final int a; + final int b = 2; + final int c; + + Test(this.a, this.c); +} +'''); + } + void test_createConstructor_insteadOfSyntheticDefault() { resolveTestUnit(''' class A { @@ -673,6 +758,46 @@ '''); } + void test_createField_hint() { + resolveTestUnit(''' +class A { +} +main(A a) { + var x = a; + int v = x.test; +} +'''); + assertHasFix(FixKind.CREATE_FIELD, ''' +class A { + int test; +} +main(A a) { + var x = a; + int v = x.test; +} +'''); + } + + void test_createField_hint_setter() { + resolveTestUnit(''' +class A { +} +main(A a) { + var x = a; + x.test = 0; +} +'''); + assertHasFix(FixKind.CREATE_FIELD, ''' +class A { + int test; +} +main(A a) { + var x = a; + x.test = 0; +} +'''); + } + void test_createField_importType() { addSource('/libA.dart', r''' library libA; @@ -871,6 +996,24 @@ expect(fileEdit.edits[0].replacement, contains('library my.file;')); } + void test_createFile_forPart() { + testFile = '/my/project/bin/test.dart'; + resolveTestUnit(''' +library my.lib; +part 'my_part.dart'; +'''); + AnalysisError error = _findErrorToFix(); + fix = _assertHasFix(FixKind.CREATE_FILE, error); + change = fix.change; + // validate change + List<SourceFileEdit> fileEdits = change.edits; + expect(fileEdits, hasLength(1)); + SourceFileEdit fileEdit = change.edits[0]; + expect(fileEdit.file, '/my/project/bin/my_part.dart'); + expect(fileEdit.fileStamp, -1); + expect(fileEdit.edits[0].replacement, contains('part of my.lib;')); + } + void test_createGetter_BAD_inSDK() { resolveTestUnit(''' main(List p) { @@ -880,6 +1023,26 @@ assertNoFix(FixKind.CREATE_GETTER); } + void test_createGetter_hint_getter() { + resolveTestUnit(''' +class A { +} +main(A a) { + var x = a; + int v = x.test; +} +'''); + assertHasFix(FixKind.CREATE_GETTER, ''' +class A { + int get test => null; +} +main(A a) { + var x = a; + int v = x.test; +} +'''); + } + void test_createGetter_multiLevel() { resolveTestUnit(''' class A { @@ -1748,6 +1911,71 @@ '''); } + void test_illegalAsyncReturnType_asyncLibrary_import() { + errorFilter = (AnalysisError error) { + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; + }; + resolveTestUnit(''' +library main; +int main() async { +} +'''); + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' +library main; +import 'dart:async'; +Future<int> main() async { +} +'''); + } + + void test_illegalAsyncReturnType_asyncLibrary_usePrefix() { + errorFilter = (AnalysisError error) { + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; + }; + resolveTestUnit(''' +import 'dart:async' as al; +int main() async { +} +'''); + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' +import 'dart:async' as al; +al.Future<int> main() async { +} +'''); + } + + void test_illegalAsyncReturnType_complexTypeName() { + errorFilter = (AnalysisError error) { + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; + }; + resolveTestUnit(''' +import 'dart:async'; +List<int> main() async { +} +'''); + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' +import 'dart:async'; +Future<List<int>> main() async { +} +'''); + } + + void test_illegalAsyncReturnType_void() { + errorFilter = (AnalysisError error) { + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; + }; + resolveTestUnit(''' +import 'dart:async'; +void main() async { +} +'''); + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' +import 'dart:async'; +Future main() async { +} +'''); + } + void test_importLibraryPackage_withClass() { _configureMyPkg(''' library my_lib; @@ -2217,6 +2445,46 @@ '''); } + void test_removeUnusedCatchClause() { + errorFilter = (AnalysisError error) => true; + resolveTestUnit(''' +main() { + try { + throw 42; + } on int catch (e) { + } +} +'''); + assertHasFix(FixKind.REMOVE_UNUSED_CATCH_CLAUSE, ''' +main() { + try { + throw 42; + } on int { + } +} +'''); + } + + void test_removeUnusedCatchStack() { + errorFilter = (AnalysisError error) => true; + resolveTestUnit(''' +main() { + try { + throw 42; + } catch (e, stack) { + } +} +'''); + assertHasFix(FixKind.REMOVE_UNUSED_CATCH_STACK, ''' +main() { + try { + throw 42; + } catch (e) { + } +} +'''); + } + void test_removeUnusedImport() { resolveTestUnit(''' import 'dart:math'; @@ -2656,6 +2924,84 @@ '''); } + void test_undefinedGetter_useSimilar_hint() { + resolveTestUnit(''' +class A { + int myField; +} +main(A a) { + var x = a; + print(x.myFild); +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; +} +main(A a) { + var x = a; + print(x.myField); +} +'''); + } + + void test_undefinedGetter_useSimilar_qualified() { + resolveTestUnit(''' +class A { + int myField; +} +main(A a) { + print(a.myFild); +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; +} +main(A a) { + print(a.myField); +} +'''); + } + + void test_undefinedGetter_useSimilar_qualified_static() { + resolveTestUnit(''' +class A { + static int MY_NAME = 1; +} +main() { + A.MY_NAM; +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + static int MY_NAME = 1; +} +main() { + A.MY_NAME; +} +'''); + } + + void test_undefinedGetter_useSimilar_unqualified() { + resolveTestUnit(''' +class A { + int myField; + main() { + print(myFild); + } +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; + main() { + print(myField); + } +} +'''); + } + void test_undefinedMethod_create_BAD_inSDK() { resolveTestUnit(''' main() { @@ -2846,26 +3192,26 @@ int index = 0; _assertLinkedGroup( change.linkedEditGroups[index++], ['void myUndefinedMethod(']); - _assertLinkedGroup(change.linkedEditGroups[index++], - ['myUndefinedMethod(0', 'myUndefinedMethod(int']); + _assertLinkedGroup(change.linkedEditGroups[index++], [ + 'myUndefinedMethod(0', + 'myUndefinedMethod(int' + ]); _assertLinkedGroup(change.linkedEditGroups[index++], [ 'int i' ], expectedSuggestions( LinkedEditSuggestionKind.TYPE, ['int', 'num', 'Object', 'Comparable'])); _assertLinkedGroup(change.linkedEditGroups[index++], ['i,']); - _assertLinkedGroup(change.linkedEditGroups[index++], [ - 'double d' - ], expectedSuggestions(LinkedEditSuggestionKind.TYPE, [ + _assertLinkedGroup(change.linkedEditGroups[index++], ['double d'], + expectedSuggestions(LinkedEditSuggestionKind.TYPE, [ 'double', 'num', 'Object', 'Comparable' ])); _assertLinkedGroup(change.linkedEditGroups[index++], ['d,']); - _assertLinkedGroup(change.linkedEditGroups[index++], [ - 'String s' - ], expectedSuggestions( - LinkedEditSuggestionKind.TYPE, ['String', 'Object', 'Comparable'])); + _assertLinkedGroup(change.linkedEditGroups[index++], ['String s'], + expectedSuggestions( + LinkedEditSuggestionKind.TYPE, ['String', 'Object', 'Comparable'])); _assertLinkedGroup(change.linkedEditGroups[index++], ['s)']); } @@ -2889,8 +3235,10 @@ '''); // linked positions _assertLinkedGroup(change.linkedEditGroups[0], ['int myUndefinedMethod(']); - _assertLinkedGroup(change.linkedEditGroups[1], - ['myUndefinedMethod();', 'myUndefinedMethod() {']); + _assertLinkedGroup(change.linkedEditGroups[1], [ + 'myUndefinedMethod();', + 'myUndefinedMethod() {' + ]); } void test_undefinedMethod_createUnqualified_staticFromField() { @@ -3022,6 +3370,65 @@ '''); } + void test_undefinedSetter_useSimilar_hint() { + resolveTestUnit(''' +class A { + int myField; +} +main(A a) { + var x = a; + x.myFild = 42; +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; +} +main(A a) { + var x = a; + x.myField = 42; +} +'''); + } + + void test_undefinedSetter_useSimilar_qualified() { + resolveTestUnit(''' +class A { + int myField; +} +main(A a) { + a.myFild = 42; +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; +} +main(A a) { + a.myField = 42; +} +'''); + } + + void test_undefinedSetter_useSimilar_unqualified() { + resolveTestUnit(''' +class A { + int myField; + main() { + myFild = 42; + } +} +'''); + assertHasFix(FixKind.CHANGE_TO, ''' +class A { + int myField; + main() { + myField = 42; + } +} +'''); + } + void test_useEffectiveIntegerDivision() { resolveTestUnit(''' main() { @@ -3079,11 +3486,6 @@ AnalysisError _findErrorToFix() { List<AnalysisError> errors = context.computeErrors(testSource); - errors.removeWhere((error) { - return error.errorCode == HintCode.UNUSED_ELEMENT || - error.errorCode == HintCode.UNUSED_FIELD || - error.errorCode == HintCode.UNUSED_LOCAL_VARIABLE; - }); if (errorFilter != null) { errors = errors.where(errorFilter).toList(); }  diff --git a/dart/pkg/analysis_server/test/services/correction/sort_members_test.dart b/dart/pkg/analysis_server/test/services/correction/sort_members_test.dart index b0f96a4..46ff0d7 100644 --- a/dart/pkg/analysis_server/test/services/correction/sort_members_test.dart +++ b/dart/pkg/analysis_server/test/services/correction/sort_members_test.dart  @@ -354,6 +354,37 @@ '''); } + void test_directives_comments() { + _parseTestUnit(r''' +// header +library lib; + +import 'c.dart';// c +import 'a.dart';// aa +import 'b.dart';// bbb + +/** doc */ +main() { +} +'''); + // validate change + _assertSort(r''' +// header +library lib; + +import 'a.dart'; +import 'b.dart'; +import 'c.dart'; +// c +// aa +// bbb + +/** doc */ +main() { +} +'''); + } + void test_unitMembers_class() { _parseTestUnit(r''' class C {}  diff --git a/dart/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/dart/pkg/analysis_server/test/services/refactoring/extract_method_test.dart index 13e7ed7..bec57bd 100644 --- a/dart/pkg/analysis_server/test/services/refactoring/extract_method_test.dart +++ b/dart/pkg/analysis_server/test/services/refactoring/extract_method_test.dart  @@ -860,129 +860,10 @@ '''); } - test_getExtractGetter_false_do() async { + test_getExtractGetter_expression_true_binaryExpression() async { indexTestUnit(''' main() { -// start - int v = 0; - do { - v++; - } while (v < 10); -// end - print(v); -} -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_false_for() async { - indexTestUnit(''' -main() { -// start - int v = 0; - for (int i = 0; i < 10; i++) { - v += i; - } -// end - print(v); -} -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_false_forEach() async { - indexTestUnit(''' -main() { -// start - int v = 0; - for (int i in [1, 2, 3]) { - v += i; - } -// end - print(v); -} -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_false_methodInvocation_expression() async { - indexTestUnit(''' -main() { - int v = calculateSomething() + 5; -} -int calculateSomething() => 42; -'''); - _createRefactoringForString('calculateSomething() + 5'); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_false_methodInvocation_statements() async { - indexTestUnit(''' -main() { -// start - int v = calculateSomething(); -// end - print(v); -} -int calculateSomething() => 42; -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_false_while() async { - indexTestUnit(''' -main() { -// start - int v = 0; - while (v < 10) { - v++; - } -// end - print(v); -} -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, false); - } - - test_getExtractGetter_true_simpleBlock() async { - indexTestUnit(''' -main() { -// start - int v = 1 + 2; -// end - print(v); -} -'''); - _createRefactoringForStartEndComments(); - // apply refactoring - await assertRefactoringConditionsOK(); - expect(refactoring.createGetter, true); - } - - test_getExtractGetter_true_singleExpression() async { - indexTestUnit(''' -main() { -// start - int v = 1 + 2; -// end - print(v); + print(1 + 2); } '''); _createRefactoringForString('1 + 2'); @@ -991,6 +872,70 @@ expect(refactoring.createGetter, true); } + test_getExtractGetter_expression_true_literal() async { + indexTestUnit(''' +main() { + print(42); +} +'''); + _createRefactoringForString('42'); + // apply refactoring + await assertRefactoringConditionsOK(); + expect(refactoring.createGetter, true); + } + + test_getExtractGetter_expression_true_prefixedExpression() async { + indexTestUnit(''' +main() { + print(!true); +} +'''); + _createRefactoringForString('!true'); + // apply refactoring + await assertRefactoringConditionsOK(); + expect(refactoring.createGetter, true); + } + + test_getExtractGetter_expression_true_prefixedIdentifier() async { + indexTestUnit(''' +main() { + print(myValue.isEven); +} +int get myValue => 42; +'''); + _createRefactoringForString('myValue.isEven'); + // apply refactoring + await assertRefactoringConditionsOK(); + expect(refactoring.createGetter, true); + } + + test_getExtractGetter_expression_true_propertyAccess() async { + indexTestUnit(''' +main() { + print(1.isEven); +} +'''); + _createRefactoringForString('1.isEven'); + // apply refactoring + await assertRefactoringConditionsOK(); + expect(refactoring.createGetter, true); + } + + test_getExtractGetter_statements() async { + indexTestUnit(''' +main() { +// start + int v = 0; +// end + print(v); +} +'''); + _createRefactoringForStartEndComments(); + // apply refactoring + await assertRefactoringConditionsOK(); + expect(refactoring.createGetter, false); + } + test_getRefactoringName_function() { indexTestUnit(''' main() { @@ -1045,6 +990,19 @@ expect(refactoring.lengths, unorderedEquals([5, 6])); } + test_returnType_closure() async { + indexTestUnit(''' +process(f(x)) {} +main() { + process((x) => x * 2); +} +'''); + _createRefactoringForString('(x) => x * 2'); + // do check + await refactoring.checkInitialConditions(); + expect(refactoring.returnType, ''); + } + test_returnType_expression() async { indexTestUnit(''' main() { @@ -1072,19 +1030,6 @@ expect(refactoring.returnType, 'double'); } - test_returnType_closure() async { - indexTestUnit(''' -process(f(x)) {} -main() { - process((x) => x * 2); -} -'''); - _createRefactoringForString('(x) => x * 2'); - // do check - await refactoring.checkInitialConditions(); - expect(refactoring.returnType, ''); - } - test_returnType_statements_nullMix() async { indexTestUnit(''' main(bool p) {  diff --git a/dart/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/dart/pkg/analysis_server/test/services/refactoring/move_file_test.dart index df7d396..ed220e5 100644 --- a/dart/pkg/analysis_server/test/services/refactoring/move_file_test.dart +++ b/dart/pkg/analysis_server/test/services/refactoring/move_file_test.dart  @@ -26,7 +26,7 @@ class MoveFileTest extends RefactoringTest { MoveFileRefactoring refactoring; - test_definingUnit() async { + test_file_definingUnit() async { String pathA = '/project/000/1111/a.dart'; String pathB = '/project/000/1111/b.dart'; String pathC = '/project/000/1111/22/c.dart'; @@ -62,7 +62,7 @@ '''); } - test_importedLibrary() async { + test_file_importedLibrary() async { String pathA = '/project/000/1111/a.dart'; testFile = '/project/000/1111/sub/folder/test.dart'; addSource(pathA, ''' @@ -79,7 +79,7 @@ assertNoFileChange(testFile); } - test_importedLibrary_down() async { + test_file_importedLibrary_down() async { String pathA = '/project/000/1111/a.dart'; testFile = '/project/000/1111/test.dart'; addSource(pathA, ''' @@ -96,7 +96,7 @@ assertNoFileChange(testFile); } - test_importedLibrary_package() async { + test_file_importedLibrary_package() async { // configure packages testFile = '/packages/my_pkg/aaa/test.dart'; provider.newFile(testFile, ''); @@ -124,7 +124,7 @@ assertNoFileChange(testFile); } - test_importedLibrary_up() async { + test_file_importedLibrary_up() async { String pathA = '/project/000/1111/a.dart'; testFile = '/project/000/1111/22/test.dart'; addSource(pathA, ''' @@ -141,7 +141,7 @@ assertNoFileChange(testFile); } - test_sourcedUnit() async { + test_file_sourcedUnit() async { String pathA = '/project/000/1111/a.dart'; testFile = '/project/000/1111/22/test.dart'; addSource(pathA, ''' @@ -158,7 +158,7 @@ assertNoFileChange(testFile); } - test_sourcedUnit_multipleLibraries() async { + test_file_sourcedUnit_multipleLibraries() async { String pathA = '/project/000/1111/a.dart'; String pathB = '/project/000/b.dart'; testFile = '/project/000/1111/22/test.dart'; @@ -182,6 +182,45 @@ assertNoFileChange(testFile); } + test_project() async { + String pubspecPath = '/testName/pubspec.yaml'; + String appPath = '/testName/bin/myApp.dart'; + provider.newFile(pubspecPath, ''' +name: testName +version: 0.0.1 +description: My pubspec file. +'''); + addSource('/testName/lib/myLib.dart', ''); + addSource(appPath, ''' +import 'package:testName/myLib.dart'; +export 'package:testName/myLib.dart'; +'''); + // configure Uri resolves + context.sourceFactory = new SourceFactory([ + AbstractContextTest.SDK_RESOLVER, + new PackageMapUriResolver(provider, <String, List<Folder>>{ + 'testName': [provider.getResource('/testName/lib')] + }), + resourceResolver, + ]); + // analyze + _performAnalysis(); + // perform refactoring + refactoring = new MoveFileRefactoring( + provider, searchEngine, context, null, '/testName'); + refactoring.newFile = '/newName'; + await _assertSuccessfulRefactoring(); + assertFileChangeResult(pubspecPath, ''' +name: newName +version: 0.0.1 +description: My pubspec file. +'''); + assertFileChangeResult(appPath, ''' +import 'package:newName/myLib.dart'; +export 'package:newName/myLib.dart'; +'''); + } + /** * Checks that all conditions are OK. */ @@ -192,7 +231,7 @@ void _createRefactoring(String newName) { refactoring = new MoveFileRefactoring( - provider.pathContext, searchEngine, context, testSource); + provider, searchEngine, context, testSource, null); refactoring.newFile = newName; }  diff --git a/dart/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart b/dart/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart index 04f7e03..4652eca 100644 --- a/dart/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart +++ b/dart/pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart  @@ -479,6 +479,12 @@ expectedMessage: "Method name must not be empty."); } + void test_validateMethodName_keyword() { + assertRefactoringStatus( + validateMethodName("for"), RefactoringProblemSeverity.FATAL, + expectedMessage: "Method name must not be a keyword."); + } + void test_validateMethodName_leadingBlanks() { assertRefactoringStatus( validateMethodName(" newName"), RefactoringProblemSeverity.FATAL,  diff --git a/dart/pkg/analysis_server/test/socket_server_test.dart b/dart/pkg/analysis_server/test/socket_server_test.dart index 5bc695a..5b4f5f0 100644 --- a/dart/pkg/analysis_server/test/socket_server_test.dart +++ b/dart/pkg/analysis_server/test/socket_server_test.dart  @@ -13,10 +13,10 @@ import 'package:analysis_server/src/socket_server.dart'; import 'package:analyzer/instrumentation/instrumentation.dart'; import 'package:analyzer/src/generated/sdk_io.dart'; +import 'package:analyzer/src/plugin/plugin_impl.dart'; import 'package:unittest/unittest.dart'; import 'mocks.dart'; -import 'package:analysis_server/src/plugin/plugin_impl.dart'; main() { group('SocketServer', () { @@ -44,8 +44,9 @@ expect(channel2.responsesReceived[0].error, isNotNull); expect(channel2.responsesReceived[0].error.code, equals(RequestErrorCode.SERVER_ALREADY_STARTED)); - channel2.sendRequest(new ServerShutdownParams().toRequest('0')).then( - (Response response) { + channel2 + .sendRequest(new ServerShutdownParams().toRequest('0')) + .then((Response response) { expect(response.id, equals('0')); expect(response.error, isNotNull); expect( @@ -60,8 +61,9 @@ server.createAnalysisServer(channel); channel.expectMsgCount(notificationCount: 1); expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); - return channel.sendRequest(new ServerShutdownParams().toRequest('0')).then( - (Response response) { + return channel + .sendRequest(new ServerShutdownParams().toRequest('0')) + .then((Response response) { expect(response.id, equals('0')); expect(response.error, isNull); channel.expectMsgCount(responseCount: 1, notificationCount: 1);  diff --git a/dart/pkg/analysis_server/test/test_all.dart b/dart/pkg/analysis_server/test/test_all.dart index 189af22..862b77f 100644 --- a/dart/pkg/analysis_server/test/test_all.dart +++ b/dart/pkg/analysis_server/test/test_all.dart  @@ -14,7 +14,6 @@ import 'domain_server_test.dart' as domain_server_test; import 'edit/test_all.dart' as edit_all; import 'operation/test_all.dart' as operation_test_all; -import 'plugin/test_all.dart' as plugin_test_all; import 'protocol_server_test.dart' as protocol_server_test; import 'protocol_test.dart' as protocol_test; import 'search/test_all.dart' as search_all; @@ -38,7 +37,6 @@ domain_server_test.main(); edit_all.main(); operation_test_all.main(); - plugin_test_all.main(); protocol_server_test.main(); protocol_test.main(); search_all.main();  diff --git a/dart/pkg/analysis_server/tool/spec/codegen_java_types.dart b/dart/pkg/analysis_server/tool/spec/codegen_java_types.dart index 646e5ff..e7d289e 100644 --- a/dart/pkg/analysis_server/tool/spec/codegen_java_types.dart +++ b/dart/pkg/analysis_server/tool/spec/codegen_java_types.dart  @@ -672,11 +672,11 @@ // contains(int x) // if (className == 'Occurrences') { - publicMethod('contains', () { - writeln('public boolean contains(int x) {'); + publicMethod('containsInclusive', () { + writeln('public boolean containsInclusive(int x) {'); indent(() { writeln('for (int offset : offsets) {'); - writeln(' if (offset <= x && x < offset + length) {'); + writeln(' if (offset <= x && x <= offset + length) {'); writeln(' return true;'); writeln(' }'); writeln('}');  diff --git a/dart/pkg/analysis_server/tool/spec/spec_input.html b/dart/pkg/analysis_server/tool/spec/spec_input.html index 54e0315..fa512df 100644 --- a/dart/pkg/analysis_server/tool/spec/spec_input.html +++ b/dart/pkg/analysis_server/tool/spec/spec_input.html  @@ -6,7 +6,7 @@ </head> <body> <h1>Analysis Server API Specification</h1> - <h1 style="color:#999999">Version <version>1.3.0</version></h1> + <h1 style="color:#999999">Version <version>1.5.0</version></h1> <p> This document contains a specification of the API provided by the analysis server. The API in this document is currently under @@ -2301,6 +2301,13 @@ will contain an empty string. </p> </field> + <field name="typeParameters" optional="true"> + <ref>String</ref> + <p> + The type parameter list for the element. If the element doesn't + have type parameters, this field will not be defined. + </p> + </field> </object> </type> <type name="ElementKind"> @@ -2531,6 +2538,14 @@ file. </p> </field> + <field name="containingClassDescription" optional="true"> + <ref>String</ref> + <p> + A human-readable description of the class declaring the element + being referenced. This data is omitted if there is no referenced + element, or if the element is not a class member. + </p> + </field> <field name="dartdoc" optional="true"> <ref>String</ref> <p>  diff --git a/dart/pkg/analysis_server/tool/spec/to_html.dart b/dart/pkg/analysis_server/tool/spec/to_html.dart index 68abc0c..f773e94 100644 --- a/dart/pkg/analysis_server/tool/spec/to_html.dart +++ b/dart/pkg/analysis_server/tool/spec/to_html.dart  @@ -307,7 +307,14 @@ @override void visitNotification(Notification notification) { dt('notification', () { - write(notification.longEvent); + anchor('notification_${notification.longEvent}', () {
+      });
+      write(' (');
+      link('notification_${notification.longEvent}', () { + write('#'); + }); + write(')'); }); dd(() { box(() { @@ -341,7 +348,14 @@ @override void visitRequest(Request request) { dt('request', () { - write(request.longMethod); + anchor('request_${request.longMethod}', () {
+        write(request.longMethod);
+      });
+      write(' (');
+      link('request_${request.longMethod}', () { + write('#'); + }); + write(')'); }); dd(() { box(() {  diff --git a/dart/pkg/analyzer/bin/formatter.dart b/dart/pkg/analyzer/bin/formatter.dart deleted file mode 100755 index 16769bb..0000000 --- a/dart/pkg/analyzer/bin/formatter.dart +++ /dev/null  @@ -1,260 +0,0 @@ -#!/usr/bin/env dart -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert'; -import 'dart:io'; - -import 'package:args/args.dart'; -import 'package:path/path.dart' as path; - -import 'package:analyzer/src/services/formatter_impl.dart'; - -const BINARY_NAME = 'dartfmt'; -final dartFileRegExp = new RegExp(r'^[^.].*\.dart$', caseSensitive: false);
-final argParser = _initArgParser();
-final defaultSelection = new Selection(-1, -1);
-
-var formatterSettings;
-
-CodeKind kind;
-bool machineFormat;
-bool overwriteFileContents;
-Selection selection;
-final List<String> paths = [];
-
-const HELP_FLAG = 'help';
-const KIND_FLAG = 'kind';
-const MACHINE_FLAG = 'machine';
-const WRITE_FLAG = 'write';
-const SELECTION_FLAG = 'selection';
-const TRANSFORM_FLAG = 'transform';
-const MAX_LINE_FLAG = 'max_line_length';
-const INDENT_FLAG = 'indent';
-
-
-main(args) {
-  var options = argParser.parse(args);
-  if (options['help']) {
-    _printUsage();
-    return;
-  }
-
-
-  if (options.rest.isEmpty) {
-    _formatStdin(kind);
-  } else {
-    _formatPaths(paths);
-  }
-}
-
-  kind = _parseKind(options[KIND_FLAG]);
-  machineFormat = options[MACHINE_FLAG];
-  overwriteFileContents = options[WRITE_FLAG];
-  selection = _parseSelection(options[SELECTION_FLAG]);
-  formatterSettings = new FormatterOptions(
-      codeTransforms: options[TRANSFORM_FLAG],
-      tabsForIndent: _parseTabsForIndent(options[INDENT_FLAG]),
-      spacesPerIndent: _parseSpacesPerIndent(options[INDENT_FLAG]),
-      pageWidth: _parseLineLength(options[MAX_LINE_FLAG]));
-}
-
-/// Translate the indent option into spaces per indent.
-int _parseSpacesPerIndent(String indentOption) {
-  if (indentOption == 'tab') {
-    return 1;
-  }
-  int spacesPerIndent = _toInt(indentOption);
-  if (spacesPerIndent == null) {
-    throw new FormatterException(
-        'Indentation is specified as an Integer or ' 'the value "tab".');
-  }
-  return spacesPerIndent;
-}
-
-/// Translate the indent option into tabs for indent.
-bool _parseTabsForIndent(String indentOption) => indentOption == 'tab';
-
-CodeKind _parseKind(kindOption) {
-  switch (kindOption) {
-    case 'stmt':
-      return CodeKind.STATEMENT;
-    default:
-      return CodeKind.COMPILATION_UNIT;
-  }
-}
-
-int _parseLineLength(String lengthOption) {
-  var length = _toInt(lengthOption);
-  if (length == null) {
-    var val = lengthOption.toUpperCase();
-    if (val == 'INF' || val == 'INFINITY') {
-      length = -1;
-    } else {
-      throw new FormatterException(
-          'Line length is specified as an Integer or ' 'the value "Inf".');
-    }
-  }
-  return length;
-}
-
-Selection _parseSelection(String selectionOption) {
-  if (selectionOption == null) return null;
-
-  var units = selectionOption.split(',');
-  if (units.length == 2) {
-    var offset = _toInt(units[0]);
-    var length = _toInt(units[1]);
-    if (offset != null && length != null) {
-      return new Selection(offset, length);
-    }
-  }
-  throw new FormatterException(
-      'Selections are specified as integer pairs ' '(e.g., "(offset, length)".');
-}
-
-int _toInt(str) => int.parse(str, onError: (_) => null);
-
-_formatPaths(paths) {
-  paths.forEach((path) {
-    if (FileSystemEntity.isDirectorySync(path)) {
-      _formatDirectory(new Directory(path));
-    } else {
-      _formatFile(new File(path));
-    }
-  });
-}
-
-_formatResource(resource) {
-  if (resource is Directory) {
-    _formatDirectory(resource);
-  } else if (resource is File) {
-    _formatFile(resource);
-  }
-}
-
-_formatDirectory(dir) => dir
-    .forEach((resource) => _formatResource(resource));
-
-_formatFile(file) {
-  if (_isDartFile(file)) {
-    if (_isPatchFile(file) && !paths.contains(file.path)) {
-      _log('Skipping patch file "${file.path}"'); - return; - } - try { - var rawSource = file.readAsStringSync(); - var formatted = _format(rawSource, CodeKind.COMPILATION_UNIT); - if (overwriteFileContents) { - // Only touch files files whose contents will be changed - if (rawSource != formatted) { - file.writeAsStringSync(formatted); - } - } else { - print(formatted); - } - } catch (e) { - _log('Unable to format "${file.path}": $e'); - } - } -} - -_isPatchFile(file) => file.path.endsWith('_patch.dart'); - -_isDartFile(file) => dartFileRegExp.hasMatch(path.basename(file.path)); - -_formatStdin(kind) { - var input = new StringBuffer(); - stdin.transform(new Utf8Decoder()).listen((data) => input.write(data), - onError: (error) => _log('Error reading from stdin'), - onDone: () => print(_format(input.toString(), kind))); -} - -/// Initialize the arg parser instance. -ArgParser _initArgParser() { - // NOTE: these flags are placeholders only! - var parser = new ArgParser(); - parser.addFlag(WRITE_FLAG, - abbr: 'w', - negatable: false, - help: 'Write reformatted sources to files (overwriting contents). ' - 'Do not print reformatted sources to standard output.'); - parser.addFlag(TRANSFORM_FLAG, - abbr: 't', negatable: false, help: 'Perform code transformations.'); - parser.addOption(MAX_LINE_FLAG, - abbr: 'l', defaultsTo: '80', help: 'Wrap lines longer than this length. ' - 'To never wrap, specify "Infinity" or "Inf" for short.'); - parser.addOption(INDENT_FLAG, - abbr: 'i', - defaultsTo: '2', - help: 'Specify number of spaces per indentation. ' - 'To indent using tabs, specify "--$INDENT_FLAG tab".' '--- [PROVISIONAL API].',
-      hide: true);
-      abbr: 'k',
-      defaultsTo: 'cu',
-      help: 'Specify source snippet kind ("stmt" or "cu") ' '--- [PROVISIONAL API].',
-      hide: true);
-      abbr: 's', help: 'Specify selection information as an offset,length pair '
-      '(e.g., -s "0,4").', hide: true);
-      abbr: 'm',
-      negatable: false,
-      help: 'Produce output in a format suitable for parsing.');
-      abbr: 'h', negatable: false, help: 'Print this usage information.');
-  return parser;
-}
-
-/// Displays usage information.
-_printUsage() {
-  var buffer = new StringBuffer();
-  buffer
-    ..write('$BINARY_NAME formats Dart programs.') - ..write('\n\n') - ..write('Without an explicit path,$BINARY_NAME processes the standard '
-        'input.  Given a file, it operates on that file; given a '
-        'directory, it operates on all .dart files in that directory, '
-        'recursively. (Files starting with a period are ignored.) By '
-        'default, $BINARY_NAME prints the reformatted sources to ' 'standard output.') - ..write('\n\n') - ..write('Usage:$BINARY_NAME [flags] [path...]\n\n')
-    ..write('Supported flags are:\n')
-    ..write('${argParser.usage}\n\n'); - _log(buffer.toString()); -} - -/// Format this [src], treating it as the given snippet [kind]. -String _format(src, kind) { - var formatResult = new CodeFormatter(formatterSettings).format(kind, src, - selection: selection); - if (machineFormat) { - if (formatResult.selection == null) { - formatResult.selection = defaultSelection; - } - return _toJson(formatResult); - } - return formatResult.source; -} - -_toJson(formatResult) => // Actual JSON format TBD - JSON.encode({ - 'source': formatResult.source, - 'selection': { - 'offset': formatResult.selection.offset, - 'length': formatResult.selection.length - } -}); - -/// Log the given [msg]. -_log(String msg) { - //TODO(pquitslund): add proper log support - print(msg); -}  diff --git a/dart/pkg/analyzer/lib/file_system/file_system.dart b/dart/pkg/analyzer/lib/file_system/file_system.dart index d510dbb..6fb9885 100644 --- a/dart/pkg/analyzer/lib/file_system/file_system.dart +++ b/dart/pkg/analyzer/lib/file_system/file_system.dart  @@ -24,6 +24,12 @@ * Create a new [Source] instance that serves this file. */ Source createSource([Uri uri]); + + /** + * Synchronously read the entire file contents as a [String]. + * Throws [FileSystemException] if the file does not exist. + */ + String readAsStringSync(); } /** @@ -70,18 +76,18 @@ Resource getChild(String relPath); /** - * Return a list of existing direct children [Resource]s (folders and files) - * in this folder, in no particular order. - */ - List<Resource> getChildren(); - - /** * Return a [Folder] representing a child [Resource] with the given * [relPath]. This call does not check whether a folder with the given name * exists on the filesystem--client must call the [Folder]'s exists getter * to determine whether the folder actually exists. */ Folder getChildAssumingFolder(String relPath); + + /** + * Return a list of existing direct children [Resource]s (folders and files) + * in this folder, in no particular order. + */ + List<Resource> getChildren(); } /** @@ -172,10 +178,7 @@ Uri restoreAbsolute(Source source) => source.uri; /** - * Return true if the given URI is a file URI. - * - * @param uri the URI being tested - * @return true if the given URI is a file URI + * Return true if the given [uri] is a file URI. */ static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; }  diff --git a/dart/pkg/analyzer/lib/file_system/memory_file_system.dart b/dart/pkg/analyzer/lib/file_system/memory_file_system.dart index da68f08..8d1f114 100644 --- a/dart/pkg/analyzer/lib/file_system/memory_file_system.dart +++ b/dart/pkg/analyzer/lib/file_system/memory_file_system.dart  @@ -110,17 +110,6 @@ return file; } - File updateFile(String path, String content, [int stamp]) { - path = posix.normalize(path); - newFolder(posix.dirname(path)); - _MemoryFile file = new _MemoryFile(this, path); - _pathToResource[path] = file; - _pathToContent[path] = content; - _pathToTimestamp[path] = stamp != null ? stamp : nextStamp++; - _notifyWatchers(path, ChangeType.MODIFY); - return file; - } - Folder newFolder(String path) { path = posix.normalize(path); if (!path.startsWith('/')) { @@ -145,6 +134,17 @@ } } + File updateFile(String path, String content, [int stamp]) { + path = posix.normalize(path); + newFolder(posix.dirname(path)); + _MemoryFile file = new _MemoryFile(this, path); + _pathToResource[path] = file; + _pathToContent[path] = content; + _pathToTimestamp[path] = stamp != null ? stamp : nextStamp++; + _notifyWatchers(path, ChangeType.MODIFY); + return file; + } + void _checkFileAtPath(String path) { _MemoryResource resource = _pathToResource[path]; if (resource is! _MemoryFile) { @@ -206,6 +206,11 @@ bool isOrContains(String path) { return path == this.path; } + + @override + String readAsStringSync() { + throw new FileSystemException(path, 'File could not be read'); + } } /** @@ -221,7 +226,7 @@ int get modificationStamp { int stamp = _provider._pathToTimestamp[path]; if (stamp == null) { - throw new FileSystemException(path, 'File does not exist.'); + throw new FileSystemException(path, 'File "$path" does not exist.');
}
return stamp;
}
@@ -229,7 +234,7 @@
String get _content {
String content = _provider._pathToContent[path];
if (content == null) {
-      throw new FileSystemException(path, "File does not exist");
+      throw new FileSystemException(path, 'File "$path" does not exist.'); } return content; } @@ -246,6 +251,15 @@ bool isOrContains(String path) { return path == this.path; } + + @override + String readAsStringSync() { + String content = _provider._pathToContent[path]; + if (content == null) { + throw new FileSystemException(path, 'File "$path" does not exist.');
+    }
+    return content;
+  }
}

/**
@@ -298,7 +312,7 @@
int get modificationStamp {
try {
return file.modificationStamp;
-    } on FileSystemException catch (e) {
+    } on FileSystemException {
return -1;
}
}
@@ -398,6 +412,9 @@

@override
List<Resource> getChildren() {
+    if (!exists) {
+      throw new FileSystemException(path, 'Folder does not exist.');
+    }
List<Resource> children = <Resource>[];
_provider._pathToResource.forEach((resourcePath, resource) {
if (posix.dirname(resourcePath) == path) {

diff --git a/dart/pkg/analyzer/lib/file_system/physical_file_system.dart b/dart/pkg/analyzer/lib/file_system/physical_file_system.dart
index 71c4020..2cd391a 100644
--- a/dart/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/dart/pkg/analyzer/lib/file_system/physical_file_system.dart

@@ -80,7 +80,7 @@
io.File file = _entry as io.File;
return file.lastModifiedSync().millisecondsSinceEpoch;
} on io.FileSystemException catch (exception) {
-      throw new FileSystemException(path, exception.message);
+      throw new FileSystemException(exception.path, exception.message);
}
}

@@ -98,6 +98,16 @@
bool isOrContains(String path) {
return path == this.path;
}
+
+  @override
+    try {
+      io.File file = _entry as io.File;
+    } on io.FileSystemException catch (exception) {
+      throw new FileSystemException(exception.path, exception.message);
+    }
+  }
}

/**
@@ -134,19 +144,23 @@

@override
List<Resource> getChildren() {
-    List<Resource> children = <Resource>[];
-    io.Directory directory = _entry as io.Directory;
-    List<io.FileSystemEntity> entries = directory.listSync(recursive: false);
-    int numEntries = entries.length;
-    for (int i = 0; i < numEntries; i++) {
-      io.FileSystemEntity entity = entries[i];
-      if (entity is io.Directory) {
-      } else if (entity is io.File) {
+    try {
+      List<Resource> children = <Resource>[];
+      io.Directory directory = _entry as io.Directory;
+      List<io.FileSystemEntity> entries = directory.listSync(recursive: false);
+      int numEntries = entries.length;
+      for (int i = 0; i < numEntries; i++) {
+        io.FileSystemEntity entity = entries[i];
+        if (entity is io.Directory) {
+        } else if (entity is io.File) {
+        }
}
+      return children;
+    } on io.FileSystemException catch (exception) {
+      throw new FileSystemException(exception.path, exception.message);
}
-    return children;
}

@override

diff --git a/dart/pkg/analyzer/lib/formatter.dart b/dart/pkg/analyzer/lib/formatter.dart
deleted file mode 100644
index 58de5ac..0000000
--- a/dart/pkg/analyzer/lib/formatter.dart
+++ /dev/null

@@ -1,8 +0,0 @@
-// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
-
-library formatter;
-
-export 'package:analyzer/src/services/formatter_impl.dart'
-    show CodeFormatter, FormatterOptions, FormattedSource, CodeKind;

diff --git a/dart/pkg/analyzer/lib/instrumentation/file_instrumentation.dart b/dart/pkg/analyzer/lib/instrumentation/file_instrumentation.dart
index 136ff8c..ba23b68 100644
--- a/dart/pkg/analyzer/lib/instrumentation/file_instrumentation.dart
+++ b/dart/pkg/analyzer/lib/instrumentation/file_instrumentation.dart

@@ -16,7 +16,7 @@

FileInstrumentationServer(String path) {
File file = new File(path);
-    _sink = file.openWrite(mode: FileMode.APPEND);
+    _sink = file.openWrite();
}

@override

diff --git a/dart/pkg/analyzer/lib/options.dart b/dart/pkg/analyzer/lib/options.dart
index 37e1b8a..1f7543e 100644
--- a/dart/pkg/analyzer/lib/options.dart
+++ b/dart/pkg/analyzer/lib/options.dart

@@ -27,6 +27,12 @@
final bool displayVersion;

/**
+   * Whether to strictly follow the specification when generating warnings on
+   * "call" methods (fixes dartbug.com/21938).
+   */
+  final bool enableStrictCallChecks;
+
+  /**
* Whether to treat type mismatches found during constant evaluation as
* errors.
*/
@@ -80,6 +86,7 @@
this.definedVariables = definedVariables,
disableHints = args['no-hints'],
displayVersion = args['version'],
+        enableStrictCallChecks = args['enable-strict-call-checks'],
enableTypeChecks = args['enable_type_checks'],
ignoreUnrecognizedFlags = args['ignore-unrecognized-flags'],
log = args['log'],
@@ -206,6 +213,11 @@
defaultsTo: false,
negatable: false,
hide: true)
+          help: 'Fix issue 21938',
+          defaultsTo: false,
+          negatable: false,
+          hide: true)
help: 'Log additional messages and exceptions',
defaultsTo: false,

diff --git a/dart/pkg/analysis_server/lib/plugin/plugin.dart b/dart/pkg/analyzer/lib/plugin/plugin.dart
similarity index 98%
rename from dart/pkg/analysis_server/lib/plugin/plugin.dart
rename to dart/pkg/analyzer/lib/plugin/plugin.dart
index 9df0474..c81c83c 100644
--- a/dart/pkg/analysis_server/lib/plugin/plugin.dart
+++ b/dart/pkg/analyzer/lib/plugin/plugin.dart

@@ -2,7 +2,7 @@

-library analysis_server.plugin.plugin;
+library analyzer.plugin.plugin;

/**
* A function used to register the given [extension] to the extension point with

diff --git a/dart/pkg/analyzer/lib/plugin/task.dart b/dart/pkg/analyzer/lib/plugin/task.dart
new file mode 100644
index 0000000..42c9214
--- /dev/null

@@ -0,0 +1,21 @@
+// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
+
+/**
+ * Support for client code that extends the analysis engine by adding new
+ */
+
+import 'package:analyzer/plugin/plugin.dart';
+import 'package:analyzer/src/plugin/engine_plugin.dart';
+
+/**
+ * The identifier of the extension point that allows plugins to register new
+ * analysis tasks with the analysis engine. The object used as an extension must
+ */

diff --git a/dart/pkg/analyzer/lib/src/analyzer_impl.dart b/dart/pkg/analyzer/lib/src/analyzer_impl.dart
index 2897e8b..173d18a 100644
--- a/dart/pkg/analyzer/lib/src/analyzer_impl.dart
+++ b/dart/pkg/analyzer/lib/src/analyzer_impl.dart

@@ -211,6 +211,7 @@
AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl();
contextOptions.cacheSize = _MAX_CACHE_SIZE;
contextOptions.hint = !options.disableHints;
+    contextOptions.enableStrictCallChecks = options.enableStrictCallChecks;
contextOptions.analyzeFunctionBodiesPredicate =
_analyzeFunctionBodiesPredicate;
contextOptions.generateImplicitErrors = options.showPackageWarnings;

diff --git a/dart/pkg/analyzer/lib/src/context/cache.dart b/dart/pkg/analyzer/lib/src/context/cache.dart
index f1290c0..516a895 100644
--- a/dart/pkg/analyzer/lib/src/context/cache.dart
+++ b/dart/pkg/analyzer/lib/src/context/cache.dart

@@ -235,7 +235,7 @@
* The exception that caused one or more values to have a state of
* [CacheState.ERROR].
*/
-  CaughtException exception;
+  CaughtException _exception;

/**
* A bit-encoding of boolean flags associated with this entry's target.
@@ -249,6 +249,12 @@
new HashMap<ResultDescriptor, ResultData>();

/**
+   * The exception that caused one or more values to have a state of
+   * [CacheState.ERROR].
+   */
+  CaughtException get exception => _exception;
+
+  /**
* Return true if the source was explicitly added to the context or false
* if the source was implicitly added because it was referenced by another
* source.
@@ -280,18 +286,8 @@
* Fix the state of the [exception] to match the current state of the entry.
*/
void fixExceptionState() {
-    if (hasErrorState()) {
-      if (exception == null) {
-        //
-        // This code should never be reached, but is a fail-safe in case an
-        // exception is not recorded when it should be.
-        //
-        // TODO(brianwilkerson) Log this?
-        String message = 'State set to ERROR without setting an exception';
-        exception = new CaughtException(new AnalysisException(message), null);
-      }
-    } else {
-      exception = null;
+    if (!hasErrorState()) {
+      _exception = null;
}
}

@@ -348,7 +344,28 @@
*/
void invalidateAllInformation() {
_resultMap.clear();
-    exception = null;
+    _exception = null;
+  }
+
+  /**
+   * Set the [CacheState.ERROR] state for given [descriptors], their values to
+   * the corresponding default values, and remember the [exception] that caused
+   * this state.
+   */
+  void setErrorState(
+      CaughtException exception, List<ResultDescriptor> descriptors) {
+    if (descriptors == null || descriptors.isEmpty) {
+      throw new ArgumentError('at least one descriptor is expected');
+    }
+    if (exception == null) {
+      throw new ArgumentError('an exception is expected');
+    }
+    this._exception = exception;
+    for (ResultDescriptor descriptor in descriptors) {
+      ResultData data = _getResultData(descriptor);
+      data.state = CacheState.ERROR;
+      data.value = descriptor.defaultValue;
+    }
}

/**
@@ -356,10 +373,9 @@
* given [state].
*/
void setState(ResultDescriptor descriptor, CacheState state) {
-    // TODO(brianwilkerson) Consider introducing a different method used to set
-    // the state of a list of descriptors to ERROR that could validate that an
-    // exception was also provided. (It would then be an error to use this
-    // method to set the state to ERROR.)
+    if (state == CacheState.ERROR) {
+      throw new ArgumentError('use setErrorState() to set the state to ERROR');
+    }
if (state == CacheState.VALID) {
throw new ArgumentError('use setValue() to set the state to VALID');
}
@@ -367,8 +383,7 @@
if (state == CacheState.INVALID) {
_resultMap.remove(descriptor);
} else {
-      ResultData data =
-          _resultMap.putIfAbsent(descriptor, () => new ResultData(descriptor));
+      ResultData data = _getResultData(descriptor);
data.state = state;
if (state != CacheState.IN_PROCESS) {
//
@@ -387,8 +402,7 @@
/*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/
value) {
_validateStateChange(descriptor, CacheState.VALID);
-    ResultData data =
-        _resultMap.putIfAbsent(descriptor, () => new ResultData(descriptor));
+    ResultData data = _getResultData(descriptor);
data.state = CacheState.VALID;
data.value = value == null ? descriptor.defaultValue : value;
}
@@ -406,6 +420,14 @@
bool _getFlag(int index) => BooleanArray.get(_flags, index);

/**
+   * Look up the [ResultData] of [descriptor], or add a new one if it isn't
+   * there.
+   */
+  ResultData _getResultData(ResultDescriptor descriptor) {
+    return _resultMap.putIfAbsent(descriptor, () => new ResultData(descriptor));
+  }
+
+  /**
* Set the value of the flag with the given [index] to the given [value].
*/
void _setFlag(int index, bool value) {

diff --git a/dart/pkg/analyzer/lib/src/generated/ast.dart b/dart/pkg/analyzer/lib/src/generated/ast.dart
index b69d355..f202e83 100644
--- a/dart/pkg/analyzer/lib/src/generated/ast.dart
+++ b/dart/pkg/analyzer/lib/src/generated/ast.dart

@@ -1641,6 +1641,13 @@
YieldStatement visitYieldStatement(YieldStatement node) => new YieldStatement(
cloneToken(node.yieldKeyword), cloneToken(node.star),
cloneNode(node.expression), cloneToken(node.semicolon));
+
+  /**
+   * Return a clone of the given [node].
+   */
+  static AstNode clone(AstNode node) {
+    return node.accept(new AstCloner());
+  }
}

/**
@@ -12398,7 +12405,7 @@
}
try {
node.accept(this);
-    } on NodeLocator_NodeFoundException catch (exception) {
+    } on NodeLocator_NodeFoundException {
// A node with the right source position was found.
} catch (exception, stackTrace) {
@@ -12421,7 +12428,7 @@
}
try {
node.visitChildren(this);
-    } on NodeLocator_NodeFoundException catch (exception) {
+    } on NodeLocator_NodeFoundException {
rethrow;
} catch (exception, stackTrace) {
// Ignore the exception and proceed in order to visit the rest of the
@@ -16325,15 +16332,13 @@
}
// analyze usage
if (parent is AssignmentExpression) {
-      AssignmentExpression expr = parent as AssignmentExpression;
-      if (identical(expr.leftHandSide, target) &&
-          expr.operator.type == TokenType.EQ) {
+      if (identical(parent.leftHandSide, target) &&
+          parent.operator.type == TokenType.EQ) {
return false;
}
}
if (parent is ForEachStatement) {
-      ForEachStatement stmt = parent as ForEachStatement;
-      if (identical(stmt.identifier, target)) {
+      if (identical(parent.identifier, target)) {
return false;
}
}
@@ -16370,13 +16375,13 @@
}
// analyze usage
if (parent is PrefixExpression) {
-      return (parent as PrefixExpression).operator.type.isIncrementOperator;
+      return parent.operator.type.isIncrementOperator;
} else if (parent is PostfixExpression) {
return true;
} else if (parent is AssignmentExpression) {
-      return identical((parent as AssignmentExpression).leftHandSide, target);
+      return identical(parent.leftHandSide, target);
} else if (parent is ForEachStatement) {
-      return identical((parent as ForEachStatement).identifier, target);
+      return identical(parent.identifier, target);
}
return false;
}
@@ -16742,7 +16747,7 @@
StringBuffer buffer = new StringBuffer();
try {
_appendStringValue(buffer);
-    } on IllegalArgumentException catch (exception) {
+    } on IllegalArgumentException {
return null;
}
return buffer.toString();
@@ -19514,7 +19519,7 @@
}
try {
parseUriWithException(Uri.encodeFull(uriContent));
-    } on URISyntaxException catch (exception) {
+    } on URISyntaxException {
return UriValidationCode.INVALID_URI;
}
return null;

diff --git a/dart/pkg/analyzer/lib/src/generated/constant.dart b/dart/pkg/analyzer/lib/src/generated/constant.dart
index 635431a..c5b413d 100644
--- a/dart/pkg/analyzer/lib/src/generated/constant.dart
+++ b/dart/pkg/analyzer/lib/src/generated/constant.dart

@@ -23,8 +23,7 @@
import 'utilities_dart.dart' show ParameterKind;

/**
- * Instances of the class BoolState represent the state of an object representing a boolean
- * value.
+ * The state of an object representing a boolean value.
*/
class BoolState extends InstanceState {
/**
@@ -48,9 +47,7 @@
final bool value;

/**
-   * Initialize a newly created state to represent the given value.
-   *
-   * @param value the value of this instance
+   * Initialize a newly created state to represent the given [value].
*/
BoolState(this.value);

@@ -60,11 +57,6 @@
@override
int get hashCode => value == null ? 0 : (value ? 2 : 3);

-  /**
-   * Return true if this object represents an object whose type is 'bool'.
-   *
-   * @return true if this object represents a boolean value
-   */
@override
bool get isBool => true;

@@ -145,56 +137,66 @@
String toString() => value == null ? "-unknown-" : (value ? "true" : "false");

/**
-   * Return the boolean state representing the given boolean value.
-   *
-   * @param value the value to be represented
-   * @return the boolean state representing the given boolean value
+   * Return the boolean state representing the given boolean [value].
*/
static BoolState from(bool value) =>
value ? BoolState.TRUE_STATE : BoolState.FALSE_STATE;
}

/**
- * Instances of the class ConstantEvaluator evaluate constant expressions to produce their
- * compile-time value. According to the Dart Language Specification: <blockquote> A constant
- * expression is one of the following:
+ * Instances of the class ConstantEvaluator evaluate constant expressions to
+ * produce their compile-time value. According to the Dart Language
+ * Specification:
+ * <blockquote>
+ * A constant expression is one of the following:
* * A literal number.
* * A literal boolean.
- * * A literal string where any interpolated expression is a compile-time constant that evaluates
- * to a numeric, string or boolean value or to <b>null</b>.
+ * * A literal string where any interpolated expression is a compile-time
+ *   constant that evaluates to a numeric, string or boolean value or to
+ *   <b>null</b>.
* * A literal symbol.
* * <b>null</b>.
* * A qualified reference to a static constant variable.
- * * An identifier expression that denotes a constant variable, class or type alias.
+ * * An identifier expression that denotes a constant variable, class or type
+ *   alias.
* * A constant constructor invocation.
* * A constant list literal.
* * A constant map literal.
- * * A simple or qualified identifier denoting a top-level function or a static method.
- * * A parenthesized expression <i>(e)</i> where <i>e</i> is a constant expression.
- * * An expression of the form <i>identical(e<sub>1</sub>, e<sub>2</sub>)</i> where
- * <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions and <i>identical()</i> is
- * statically bound to the predefined dart function <i>identical()</i> discussed above.
- * * An expression of one of the forms <i>e<sub>1</sub> == e<sub>2</sub></i> or <i>e<sub>1</sub>
- * != e<sub>2</sub></i> where <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions
- * that evaluate to a numeric, string or boolean value.
- * * An expression of one of the forms <i>!e</i>, <i>e<sub>1</sub> &amp;&amp; e<sub>2</sub></i> or
- * <i>e<sub>1</sub> || e<sub>2</sub></i>, where <i>e</i>, <i>e1</sub></i> and <i>e2</sub></i> are
- * constant expressions that evaluate to a boolean value.
- * * An expression of one of the forms <i>~e</i>, <i>e<sub>1</sub> ^ e<sub>2</sub></i>,
- * <i>e<sub>1</sub> &amp; e<sub>2</sub></i>, <i>e<sub>1</sub> | e<sub>2</sub></i>, <i>e<sub>1</sub>
- * &gt;&gt; e<sub>2</sub></i> or <i>e<sub>1</sub> &lt;&lt; e<sub>2</sub></i>, where <i>e</i>,
- * <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions that evaluate to an
- * integer value or to <b>null</b>.
- * * An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub> + e<sub>2</sub></i>,
- * <i>e<sub>1</sub> -e<sub>2</sub></i>, <i>e<sub>1</sub> * e<sub>2</sub></i>, <i>e<sub>1</sub> /
- * e<sub>2</sub></i>, <i>e<sub>1</sub> ~/ e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;
- * e<sub>2</sub></i>, <i>e<sub>1</sub> &lt; e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;=
- * e<sub>2</sub></i>, <i>e<sub>1</sub> &lt;= e<sub>2</sub></i> or <i>e<sub>1</sub> %
- * e<sub>2</sub></i>, where <i>e</i>, <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
- * expressions that evaluate to a numeric value or to <b>null</b>.
- * * An expression of the form <i>e<sub>1</sub> ? e<sub>2</sub> : e<sub>3</sub></i> where
- * <i>e<sub>1</sub></i>, <i>e<sub>2</sub></i> and <i>e<sub>3</sub></i> are constant expressions, and
- * <i>e<sub>1</sub></i> evaluates to a boolean value.
+ * * A simple or qualified identifier denoting a top-level function or a static
+ *   method.
+ * * A parenthesized expression <i>(e)</i> where <i>e</i> is a constant
+ *   expression.
+ * * An expression of the form <i>identical(e<sub>1</sub>, e<sub>2</sub>)</i>
+ *   where <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
+ *   expressions and <i>identical()</i> is statically bound to the predefined
+ *   dart function <i>identical()</i> discussed above.
+ * * An expression of one of the forms <i>e<sub>1</sub> == e<sub>2</sub></i> or
+ *   <i>e<sub>1</sub> != e<sub>2</sub></i> where <i>e<sub>1</sub></i> and
+ *   <i>e<sub>2</sub></i> are constant expressions that evaluate to a numeric,
+ *   string or boolean value.
+ * * An expression of one of the forms <i>!e</i>, <i>e<sub>1</sub> &amp;&amp;
+ *   e<sub>2</sub></i> or <i>e<sub>1</sub> || e<sub>2</sub></i>, where <i>e</i>,
+ *   <i>e1</sub></i> and <i>e2</sub></i> are constant expressions that evaluate
+ *   to a boolean value.
+ * * An expression of one of the forms <i>~e</i>, <i>e<sub>1</sub> ^
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> &amp; e<sub>2</sub></i>,
+ *   <i>e<sub>1</sub> | e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;&gt;
+ *   e<sub>2</sub></i> or <i>e<sub>1</sub> &lt;&lt; e<sub>2</sub></i>, where
+ *   <i>e</i>, <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
+ *   expressions that evaluate to an integer value or to <b>null</b>.
+ * * An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub> +
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> -e<sub>2</sub></i>, <i>e<sub>1</sub> *
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> / e<sub>2</sub></i>, <i>e<sub>1</sub>
+ *   ~/ e<sub>2</sub></i>, <i>e<sub>1</sub> &gt; e<sub>2</sub></i>,
+ *   <i>e<sub>1</sub> &lt; e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;=
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> &lt;= e<sub>2</sub></i> or
+ *   <i>e<sub>1</sub> % e<sub>2</sub></i>, where <i>e</i>, <i>e<sub>1</sub></i>
+ *   and <i>e<sub>2</sub></i> are constant expressions that evaluate to a
+ *   numeric value or to <b>null</b>.
+ * * An expression of the form <i>e<sub>1</sub> ? e<sub>2</sub> :
+ *   e<sub>3</sub></i> where <i>e<sub>1</sub></i>, <i>e<sub>2</sub></i> and
+ *   <i>e<sub>3</sub></i> are constant expressions, and <i>e<sub>1</sub></i>
+ *   evaluates to a boolean value.
* </blockquote>
*/
class ConstantEvaluator {
@@ -209,10 +211,9 @@
final TypeProvider _typeProvider;

/**
-   * Initialize a newly created evaluator to evaluate expressions in the given source.
-   *
-   * @param source the source containing the expression(s) that will be evaluated
-   * @param typeProvider the type provider used to access known types
+   * Initialize a newly created evaluator to evaluate expressions in the given
+   * [source]. The [typeProvider] is the type provider used to access known
+   * types.
*/
ConstantEvaluator(this._source, this._typeProvider);

@@ -229,20 +230,22 @@
}

/**
- * Instances of the class ConstantFinder are used to traverse the AST
- * structures of all of the compilation units being resolved and build tables
- * of the constant variables, constant constructors, constant constructor
- * invocations, and annotations found in those compilation units.
+ * A visitor used to traverse the AST structures of all of the compilation units
+ * being resolved and build tables of the constant variables, constant
+ * constructors, constant constructor invocations, and annotations found in
+ * those compilation units.
*/
class ConstantFinder extends RecursiveAstVisitor<Object> {
/**
-   * A table mapping constant variable elements to the declarations of those variables.
+   * A table mapping constant variable elements to the declarations of those
+   * variables.
*/
final HashMap<VariableElement, VariableDeclaration> variableMap =
new HashMap<VariableElement, VariableDeclaration>();

/**
-   * A table mapping constant constructors to the declarations of those constructors.
+   * A table mapping constant constructors to the declarations of those
+   * constructors.
*/
final HashMap<ConstructorElement, ConstructorDeclaration> constructorMap =
new HashMap<ConstructorElement, ConstructorDeclaration>();
@@ -301,11 +304,11 @@
}

/**
- * Instances of the class ConstantValueComputer compute the values of constant variables and
- * constant constructor invocations in one or more compilation units. The expected usage pattern is
- * for the compilation units to be added to this computer using the method
- * [add] and then for the method [computeValues] to be invoked
- * exactly once. Any use of an instance after invoking the method [computeValues] will
+ * An object used to compute the values of constant variables and constant
+ * constructor invocations in one or more compilation units. The expected usage
+ * pattern is for the compilation units to be added to this computer using the
+ * method [add] and then for the method [computeValues] to be invoked exactly
+ * once. Any use of an instance after invoking the method [computeValues] will
* result in unpredictable behavior.
*/
class ConstantValueComputer {
@@ -315,25 +318,29 @@
static String _DEFAULT_VALUE_PARAM = "defaultValue";

/**
-   * Source of RegExp matching declarable operator names. From sdk/lib/internal/symbol.dart.
+   * Source of RegExp matching declarable operator names.
+   * From sdk/lib/internal/symbol.dart.
*/
static String _OPERATOR_RE =
"(?:[\\-+*/%&|^]|\$\$=?|==|~/?|<[<=]?|>[>=]?|unary-)";

/**
-   * Source of RegExp matching any public identifier. From sdk/lib/internal/symbol.dart.
+   * Source of RegExp matching any public identifier.
+   * From sdk/lib/internal/symbol.dart.
*/
static String _PUBLIC_IDENTIFIER_RE =
"(?!${ConstantValueComputer._RESERVED_WORD_RE}\\b(?!\\\$))[a-zA-Z\$][\\w\$]*";

/**
-   * Source of RegExp matching Dart reserved words. From sdk/lib/internal/symbol.dart.
+   * Source of RegExp matching Dart reserved words.
+   * From sdk/lib/internal/symbol.dart.
*/
static String _RESERVED_WORD_RE =
"(?:assert|break|c(?:a(?:se|tch)|lass|on(?:st|tinue))|d(?:efault|o)|e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fns]|n(?:ew|ull)|ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|v(?:ar|oid)|w(?:hile|ith))";

/**
-   * RegExp that validates a non-empty non-private symbol. From sdk/lib/internal/symbol.dart.
+   * RegExp that validates a non-empty non-private symbol.
+   * From sdk/lib/internal/symbol.dart.
*/
static RegExp _PUBLIC_SYMBOL_PATTERN = new RegExp(
"^(?:${ConstantValueComputer._OPERATOR_RE}\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$|[.](?!\$)))+?\$");
@@ -344,14 +351,14 @@
TypeProvider typeProvider;

/**
-   * The object used to find constant variables and constant constructor invocations in the
-   * compilation units that were added.
+   * The object used to find constant variables and constant constructor
+   * invocations in the compilation units that were added.
*/
ConstantFinder _constantFinder = new ConstantFinder();

/**
-   * A graph in which the nodes are the constants, and the edges are from each constant to the other
-   * constants that are referenced by it.
+   * A graph in which the nodes are the constants, and the edges are from each
+   * constant to the other constants that are referenced by it.
*/
DirectedGraph<AstNode> referenceGraph = new DirectedGraph<AstNode>();

@@ -361,7 +368,8 @@
HashMap<VariableElement, VariableDeclaration> _variableDeclarationMap;

/**
-   * A table mapping constant constructors to the declarations of those constructors.
+   * A table mapping constant constructors to the declarations of those
+   * constructors.
*/
HashMap<ConstructorElement, ConstructorDeclaration> constructorDeclarationMap;

@@ -381,46 +389,45 @@
final DeclaredVariables _declaredVariables;

/**
-   * Initialize a newly created constant value computer.
-   *
-   * @param typeProvider the type provider used to access known types
-   * @param declaredVariables the set of variables declared on the command line using '-D'
+   * Initialize a newly created constant value computer. The [typeProvider] is
+   * the type provider used to access known types. The [declaredVariables] is
+   * the set of variables declared on the command line using '-D'.
*/
ConstantValueComputer(TypeProvider typeProvider, this._declaredVariables) {
this.typeProvider = typeProvider;
}

/**
-   * Add the constants in the given compilation unit to the list of constants whose value needs to
-   * be computed.
-   *
-   * @param unit the compilation unit defining the constants to be added
+   * Add the constants in the given compilation [unit] to the list of constants
+   * whose value needs to be computed.
*/
unit.accept(_constantFinder);
}

/**
-   * This method is called just before computing the constant value associated with an AST node.
-   * Unit tests will override this method to introduce additional error checking.
+   * This method is called just before computing the constant value associated
+   * with [constNode]. Unit tests will override this method to introduce
*/
void beforeComputeValue(AstNode constNode) {}

/**
-   * This method is called just before getting the constant initializers associated with a
-   * constructor AST node. Unit tests will override this method to introduce additional error
-   * checking.
+   * This method is called just before getting the constant initializers
+   * associated with the [constructor]. Unit tests will override this method to
+   * introduce additional error checking.
*/
void beforeGetConstantInitializers(ConstructorElement constructor) {}

/**
-   * This method is called just before getting a parameter's default value. Unit tests will override
-   * this method to introduce additional error checking.
+   * This method is called just before getting a parameter's default value. Unit
+   * tests will override this method to introduce additional error checking.
*/
void beforeGetParameterDefault(ParameterElement parameter) {}

/**
-   * Compute values for all of the constants in the compilation units that were added.
+   * Compute values for all of the constants in the compilation units that were
*/
void computeValues() {
_variableDeclarationMap = _constantFinder.variableMap;
@@ -433,8 +440,8 @@
declaration.initializer.accept(referenceFinder);
});
-    constructorDeclarationMap.forEach(
-        (ConstructorElement element, ConstructorDeclaration declaration) {
+    constructorDeclarationMap.forEach((ConstructorElement element,
+        ConstructorDeclaration declaration) {
ReferenceFinder referenceFinder = new ReferenceFinder(declaration,
referenceGraph, _variableDeclarationMap, constructorDeclarationMap);
@@ -513,8 +520,8 @@
}

/**
-   * Create the ConstantVisitor used to evaluate constants. Unit tests will override this method to
-   * introduce additional error checking.
+   * Create the ConstantVisitor used to evaluate constants. Unit tests will
+   * override this method to introduce additional error checking.
*/
ConstantVisitor createConstantVisitor(ErrorReporter errorReporter) =>
new ConstantVisitor.con1(typeProvider, errorReporter);
@@ -524,14 +531,13 @@
constructorDeclarationMap[_getConstructorBase(constructor)];

/**
-   * Check that the arguments to a call to fromEnvironment() are correct.
-   *
-   * @param arguments the AST nodes of the arguments.
-   * @param argumentValues the values of the unnamed arguments.
-   * @param namedArgumentValues the values of the named arguments.
-   * @param expectedDefaultValueType the allowed type of the "defaultValue" parameter (if present).
-   *          Note: "defaultValue" is always allowed to be null.
-   * @return true if the arguments are correct, false if there is an error.
+   * Check that the arguments to a call to fromEnvironment() are correct. The
+   * [arguments] are the AST nodes of the arguments. The [argumentValues] are
+   * the values of the unnamed arguments. The [namedArgumentValues] are the
+   * values of the named arguments. The [expectedDefaultValueType] is the
+   * allowed type of the "defaultValue" parameter (if present). Note:
+   * "defaultValue" is always allowed to be null. Return true if the arguments
+   * are correct, false if there is an error.
*/
bool _checkFromEnvironmentArguments(NodeList<Expression> arguments,
List<DartObjectImpl> argumentValues,
@@ -566,12 +572,11 @@
}

/**
-   * Check that the arguments to a call to Symbol() are correct.
-   *
-   * @param arguments the AST nodes of the arguments.
-   * @param argumentValues the values of the unnamed arguments.
-   * @param namedArgumentValues the values of the named arguments.
-   * @return true if the arguments are correct, false if there is an error.
+   * Check that the arguments to a call to Symbol() are correct. The [arguments]
+   * are the AST nodes of the arguments. The [argumentValues] are the values of
+   * the unnamed arguments. The [namedArgumentValues] are the values of the
+   * named arguments. Return true if the arguments are correct, false if
+   * there is an error.
*/
bool _checkSymbolArguments(NodeList<Expression> arguments,
List<DartObjectImpl> argumentValues,
@@ -590,9 +595,7 @@
}

/**
-   * Compute a value for the given constant.
-   *
-   * @param constNode the constant for which a value is to be computed
+   * Compute a value for the given [constNode].
*/
void _computeValueFor(AstNode constNode) {
beforeComputeValue(constNode);
@@ -701,13 +704,13 @@
}

/**
-   * Evaluate a call to fromEnvironment() on the bool, int, or String class.
-   *
-   * @param environmentValue Value fetched from the environment
-   * @param builtInDefaultValue Value that should be used as the default if no "defaultValue"
-   *          argument appears in [namedArgumentValues].
-   * @param namedArgumentValues Named parameters passed to fromEnvironment()
-   * @return A [DartObjectImpl] object corresponding to the evaluated result
+   * Evaluate a call to fromEnvironment() on the bool, int, or String class. The
+   * [environmentValue] is the value fetched from the environment. The
+   * [builtInDefaultValue] is the value that should be used as the default if no
+   * "defaultValue" argument appears in [namedArgumentValues]. The
+   * [namedArgumentValues] are the values of the named parameters passed to
+   * fromEnvironment(). Return a [DartObjectImpl] object corresponding to the
+   * evaluated result.
*/
DartObjectImpl _computeValueFromEnvironment(DartObject environmentValue,
DartObjectImpl builtInDefaultValue,
@@ -754,7 +757,7 @@
namedArgumentValues[name] =
constantVisitor._valueOf(argument.expression);
namedArgumentNodes[name] = argument;
-        argumentValues[i] = constantVisitor.null2;
+        argumentValues[i] = typeProvider.nullObject;
} else {
argumentValues[i] = constantVisitor._valueOf(argument);
argumentNodes[i] = argument;
@@ -862,11 +865,10 @@
// The parameter is an optional positional parameter for which no value
// was provided, so use the default value.
beforeGetParameterDefault(baseParameter);
-        EvaluationResultImpl evaluationResult =
-            (baseParameter as ParameterElementImpl).evaluationResult;
+        EvaluationResultImpl evaluationResult = baseParameter.evaluationResult;
if (evaluationResult == null) {
// No default was provided, so the default value is null.
-          argumentValue = constantVisitor.null2;
+          argumentValue = typeProvider.nullObject;
} else if (evaluationResult.value != null) {
argumentValue = evaluationResult.value;
}
@@ -972,13 +974,12 @@
}

/**
-   * Attempt to follow the chain of factory redirections until a constructor is reached which is not
-   * a const factory constructor.
-   *
-   * @return the constant constructor which terminates the chain of factory redirections, if the
-   *         chain terminates. If there is a problem (e.g. a redirection can't be found, or a cycle
-   *         is encountered), the chain will be followed as far as possible and then a const factory
-   *         constructor will be returned.
+   * Attempt to follow the chain of factory redirections until a constructor is
+   * reached which is not a const factory constructor. Return the constant
+   * constructor which terminates the chain of factory redirections, if the
+   * chain terminates. If there is a problem (e.g. a redirection can't be found,
+   * or a cycle is encountered), the chain will be followed as far as possible
+   * and then a const factory constructor will be returned.
*/
ConstructorElement _followConstantRedirectionChain(
ConstructorElement constructor) {
@@ -1019,14 +1020,12 @@
}

/**
-   * Generate an error indicating that the given constant is not a valid compile-time constant
-   * because it references at least one of the constants in the given cycle, each of which directly
-   * or indirectly references the constant.
-   *
-   * @param constantsInCycle the constants in the cycle that includes the given constant
-   * @param constant the constant that is not a valid compile-time constant
+   * Generate an error indicating that the given [constant] is not a valid
+   * compile-time constant because it references at least one of the constants
+   * in the given [cycle], each of which directly or indirectly references the
+   * constant.
*/
-  void _generateCycleError(List<AstNode> constantsInCycle, AstNode constant) {
+  void _generateCycleError(List<AstNode> cycle, AstNode constant) {
// TODO(brianwilkerson) Implement this.
}

@@ -1038,8 +1037,8 @@
}

/**
-   * Check if the object [obj] matches the type [type] according
-   * to runtime type checking rules.
+   * Check if the object [obj] matches the type [type] according to runtime type
+   * checking rules.
*/
bool _runtimeTypeMatch(DartObjectImpl obj, DartType type) {
if (obj.isNull) {
@@ -1052,8 +1051,8 @@
}

/**
-   * Determine whether the given string is a valid name for a public symbol (i.e. whether it is
-   * allowed for a call to the Symbol constructor).
+   * Determine whether the given string is a valid name for a public symbol
+   * (i.e. whether it is allowed for a call to the Symbol constructor).
*/
static bool isValidPublicSymbol(String name) => name.isEmpty ||
name == "void" ||
@@ -1061,9 +1060,8 @@
}

/**
- * A ConstantValueComputer_InitializerCloner is an [AstCloner] that copies the
- * necessary information from the AST to allow const constructor initializers to
- * be evaluated.
+ * An [AstCloner] that copies the necessary information from the AST to allow
+ * const constructor initializers to be evaluated.
*/
class ConstantValueComputer_InitializerCloner extends AstCloner {
// TODO(brianwilkerson) Investigate replacing uses of this class with uses of
@@ -1107,46 +1105,58 @@
}

/**
- * Instances of the class ConstantVisitor evaluate constant expressions to produce their
- * compile-time value. According to the Dart Language Specification: <blockquote> A constant
+ * A visitor used to evaluate constant expressions to produce their compile-time
+ * value. According to the Dart Language Specification: <blockquote> A constant
* expression is one of the following:
+ *
* * A literal number.
* * A literal boolean.
- * * A literal string where any interpolated expression is a compile-time constant that evaluates
- * to a numeric, string or boolean value or to <b>null</b>.
+ * * A literal string where any interpolated expression is a compile-time
+ *   constant that evaluates to a numeric, string or boolean value or to
+ *   <b>null</b>.
* * A literal symbol.
* * <b>null</b>.
* * A qualified reference to a static constant variable.
- * * An identifier expression that denotes a constant variable, class or type alias.
+ * * An identifier expression that denotes a constant variable, class or type
+ *   alias.
* * A constant constructor invocation.
* * A constant list literal.
* * A constant map literal.
- * * A simple or qualified identifier denoting a top-level function or a static method.
- * * A parenthesized expression <i>(e)</i> where <i>e</i> is a constant expression.
- * * An expression of the form <i>identical(e<sub>1</sub>, e<sub>2</sub>)</i> where
- * <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions and <i>identical()</i> is
- * statically bound to the predefined dart function <i>identical()</i> discussed above.
- * * An expression of one of the forms <i>e<sub>1</sub> == e<sub>2</sub></i> or <i>e<sub>1</sub>
- * != e<sub>2</sub></i> where <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions
- * that evaluate to a numeric, string or boolean value.
- * * An expression of one of the forms <i>!e</i>, <i>e<sub>1</sub> &amp;&amp; e<sub>2</sub></i> or
- * <i>e<sub>1</sub> || e<sub>2</sub></i>, where <i>e</i>, <i>e1</sub></i> and <i>e2</sub></i> are
- * constant expressions that evaluate to a boolean value.
- * * An expression of one of the forms <i>~e</i>, <i>e<sub>1</sub> ^ e<sub>2</sub></i>,
- * <i>e<sub>1</sub> &amp; e<sub>2</sub></i>, <i>e<sub>1</sub> | e<sub>2</sub></i>, <i>e<sub>1</sub>
- * &gt;&gt; e<sub>2</sub></i> or <i>e<sub>1</sub> &lt;&lt; e<sub>2</sub></i>, where <i>e</i>,
- * <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant expressions that evaluate to an
- * integer value or to <b>null</b>.
- * * An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub> + e<sub>2</sub></i>,
- * <i>e<sub>1</sub> - e<sub>2</sub></i>, <i>e<sub>1</sub> * e<sub>2</sub></i>, <i>e<sub>1</sub> /
- * e<sub>2</sub></i>, <i>e<sub>1</sub> ~/ e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;
- * e<sub>2</sub></i>, <i>e<sub>1</sub> &lt; e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;=
- * e<sub>2</sub></i>, <i>e<sub>1</sub> &lt;= e<sub>2</sub></i> or <i>e<sub>1</sub> %
- * e<sub>2</sub></i>, where <i>e</i>, <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
- * expressions that evaluate to a numeric value or to <b>null</b>.
- * * An expression of the form <i>e<sub>1</sub> ? e<sub>2</sub> : e<sub>3</sub></i> where
- * <i>e<sub>1</sub></i>, <i>e<sub>2</sub></i> and <i>e<sub>3</sub></i> are constant expressions, and
- * <i>e<sub>1</sub></i> evaluates to a boolean value.
+ * * A simple or qualified identifier denoting a top-level function or a static
+ *   method.
+ * * A parenthesized expression <i>(e)</i> where <i>e</i> is a constant
+ *   expression.
+ * * An expression of the form <i>identical(e<sub>1</sub>, e<sub>2</sub>)</i>
+ *   where <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
+ *   expressions and <i>identical()</i> is statically bound to the predefined
+ *   dart function <i>identical()</i> discussed above.
+ * * An expression of one of the forms <i>e<sub>1</sub> == e<sub>2</sub></i> or
+ *   <i>e<sub>1</sub> != e<sub>2</sub></i> where <i>e<sub>1</sub></i> and
+ *   <i>e<sub>2</sub></i> are constant expressions that evaluate to a numeric,
+ *   string or boolean value.
+ * * An expression of one of the forms <i>!e</i>, <i>e<sub>1</sub> &amp;&amp;
+ *   e<sub>2</sub></i> or <i>e<sub>1</sub> || e<sub>2</sub></i>, where <i>e</i>,
+ *   <i>e1</sub></i> and <i>e2</sub></i> are constant expressions that evaluate
+ *   to a boolean value.
+ * * An expression of one of the forms <i>~e</i>, <i>e<sub>1</sub> ^
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> &amp; e<sub>2</sub></i>,
+ *   <i>e<sub>1</sub> | e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;&gt;
+ *   e<sub>2</sub></i> or <i>e<sub>1</sub> &lt;&lt; e<sub>2</sub></i>, where
+ *   <i>e</i>, <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are constant
+ *   expressions that evaluate to an integer value or to <b>null</b>.
+ * * An expression of one of the forms <i>-e</i>, <i>e<sub>1</sub> +
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> - e<sub>2</sub></i>, <i>e<sub>1</sub> *
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> / e<sub>2</sub></i>, <i>e<sub>1</sub>
+ *   ~/ e<sub>2</sub></i>, <i>e<sub>1</sub> &gt; e<sub>2</sub></i>,
+ *   <i>e<sub>1</sub> &lt; e<sub>2</sub></i>, <i>e<sub>1</sub> &gt;=
+ *   e<sub>2</sub></i>, <i>e<sub>1</sub> &lt;= e<sub>2</sub></i> or
+ *   <i>e<sub>1</sub> % e<sub>2</sub></i>, where <i>e</i>, <i>e<sub>1</sub></i>
+ *   and <i>e<sub>2</sub></i> are constant expressions that evaluate to a
+ *   numeric value or to <b>null</b>.
+ * * An expression of the form <i>e<sub>1</sub> ? e<sub>2</sub> :
+ *   e<sub>3</sub></i> where <i>e<sub>1</sub></i>, <i>e<sub>2</sub></i> and
+ *   <i>e<sub>3</sub></i> are constant expressions, and <i>e<sub>1</sub></i>
+ *   evaluates to a boolean value.
* </blockquote>
*/
class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
@@ -1155,15 +1165,11 @@
*/
final TypeProvider _typeProvider;

-  /**
-   * An shared object representing the value 'null'.
-   */
-  DartObjectImpl _nullObject;
-
HashMap<String, DartObjectImpl> _lexicalEnvironment;

/**
-   * Error reporter that we use to report errors accumulated while computing the constant.
+   * Error reporter that we use to report errors accumulated while computing the
+   * constant.
*/
final ErrorReporter _errorReporter;

@@ -1173,11 +1179,9 @@
DartObjectComputer _dartObjectComputer;

/**
-   * Initialize a newly created constant visitor.
-   *
-   * @param typeProvider the type provider used to access known types
-   * @param lexicalEnvironment values which should override simpleIdentifiers, or null if no
-   *          overriding is necessary.
+   * Initialize a newly created constant visitor. The [_typeProvider] is the
+   * type provider used to access known types. The [_errorReporter] is used to
*/
ConstantVisitor.con1(this._typeProvider, this._errorReporter) {
this._lexicalEnvironment = null;
@@ -1186,11 +1190,11 @@
}

/**
-   * Initialize a newly created constant visitor.
-   *
-   * @param typeProvider the type provider used to access known types
-   * @param lexicalEnvironment values which should override simpleIdentifiers, or null if no
-   *          overriding is necessary.
+   * Initialize a newly created constant visitor. The [_typeProvider] is the
+   * type provider used to access known types. The [lexicalEnvironment] is a map
+   * containing values which should override identifiers, or null if no
+   * overriding is necessary. The [_errorReporter] is used to report errors
+   * found during evaluation.
*/
ConstantVisitor.con2(this._typeProvider,
HashMap<String, DartObjectImpl> lexicalEnvironment, this._errorReporter) {
@@ -1200,27 +1204,15 @@
}

/**
-   * Return an object representing the value 'null'.
-   *
-   * @return an object representing the value 'null'
-   */
-  DartObjectImpl get null2 {
-    if (_nullObject == null) {
-      _nullObject =
-          new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
-    }
-    return _nullObject;
-  }
-
-  /**
-   * This method is called just before retrieving an evaluation result from an AST node. Unit tests
-   * will override it to introduce additional error checking.
+   * This method is called just before retrieving an evaluation result from an
+   * AST node. Unit tests will override it to introduce additional error
+   * checking.
*/
void beforeGetEvaluationResult(AstNode node) {}

/**
* Return true if the given [element] represents the length getter in
-   * class [String].
+   * class 'String'.
*/
bool isStringLength(Element element) {
if (element is PropertyAccessorElement) {
@@ -1496,7 +1488,7 @@
}

@override
-  DartObjectImpl visitNullLiteral(NullLiteral node) => null2;
+  DartObjectImpl visitNullLiteral(NullLiteral node) => _typeProvider.nullObject;

@override
DartObjectImpl visitParenthesizedExpression(ParenthesizedExpression node) =>
@@ -1603,10 +1595,8 @@
}

/**
-   * Create an error associated with the given node.
-   *
-   * @param node the AST node associated with the error
-   * @param code the error code indicating the nature of the error
+   * Create an error associated with the given [node]. The error will have the
+   * given error [code].
*/
void _error(AstNode node, ErrorCode code) {
_errorReporter.reportErrorForNode(
@@ -1614,11 +1604,9 @@
}

/**
-   * Return the constant value of the static constant represented by the given element.
-   *
-   * @param node the node to be used if an error needs to be reported
-   * @param element the element whose value is to be returned
-   * @return the constant value of the static constant
+   * Return the constant value of the static constant represented by the given
+   * [element]. The [node] is the node to be used if an error needs to be
+   * reported.
*/
DartObjectImpl _getConstantValue(AstNode node, Element element) {
if (element is PropertyAccessorElement) {
@@ -1665,106 +1653,82 @@
}

/**
-   * Return the value of the given expression, or a representation of 'null' if the expression
-   * cannot be evaluated.
-   *
-   * @param expression the expression whose value is to be returned
-   * @return the value of the given expression
+   * Return the value of the given [expression], or a representation of 'null'
+   * if the expression cannot be evaluated.
*/
DartObjectImpl _valueOf(Expression expression) {
DartObjectImpl expressionValue = expression.accept(this);
if (expressionValue != null) {
return expressionValue;
}
-    return null2;
+    return _typeProvider.nullObject;
}
}

/**
- * The interface DartObject defines the behavior of objects that represent the state of a
- * Dart object.
+ * The state of a Dart object.
*/
abstract class DartObject {
/**
-   * Return the boolean value of this object, or null if either the value of this object is
-   * not known or this object is not of type 'bool'.
-   *
-   * @return the boolean value of this object
+   * Return the boolean value of this object, or null if either the value of
+   * this object is not known or this object is not of type 'bool'.
*/
bool get boolValue;

/**
-   * Return the floating point value of this object, or null if either the value of this
-   * object is not known or this object is not of type 'double'.
-   *
-   * @return the floating point value of this object
+   * Return the floating point value of this object, or null if either the
+   * value of this object is not known or this object is not of type 'double'.
*/
double get doubleValue;

/**
* Return true if this object's value can be represented exactly.
-   *
-   * @return true if this object's value can be represented exactly
*/
bool get hasExactValue;

/**
-   * Return the integer value of this object, or null if either the value of this object is
-   * not known or this object is not of type 'int'.
-   *
-   * @return the integer value of this object
+   * Return the integer value of this object, or null if either the value of
+   * this object is not known or this object is not of type 'int'.
*/
int get intValue;

/**
* Return true if this object represents the value 'false'.
-   *
-   * @return true if this object represents the value 'false'
*/
bool get isFalse;

/**
* Return true if this object represents the value 'null'.
-   *
-   * @return true if this object represents the value 'null'
*/
bool get isNull;

/**
* Return true if this object represents the value 'true'.
-   *
-   * @return true if this object represents the value 'true'
*/
bool get isTrue;

/**
-   * Return the string value of this object, or null if either the value of this object is
-   * not known or this object is not of type 'String'.
-   *
-   * @return the string value of this object
+   * Return the string value of this object, or null if either the value of
+   * this object is not known or this object is not of type 'String'.
*/
String get stringValue;

/**
* Return the run-time type of this object.
-   *
-   * @return the run-time type of this object
*/
ParameterizedType get type;

/**
-   * Return this object's value if it can be represented exactly, or null if either the
-   * value cannot be represented exactly or if the value is null. Clients should use
-   * [hasExactValue] to distinguish between these two cases.
-   *
-   * @return this object's value
+   * Return this object's value if it can be represented exactly, or null if
+   * either the value cannot be represented exactly or if the value is null.
+   * Clients should use [hasExactValue] to distinguish between these two cases.
*/
Object get value;
}

/**
- * Instances of the class DartObjectComputer contain methods for manipulating instances of a
- * Dart class and for collecting errors during evaluation.
+ * A utility class that contains methods for manipulating instances of a Dart
+ * class and for collecting errors during evaluation.
*/
class DartObjectComputer {
/**
@@ -1773,8 +1737,8 @@
final ErrorReporter _errorReporter;

/**
-   * The type provider. Used to create objects of the appropriate types, and to identify when an
-   * object is of a built-in type.
+   * The type provider used to create objects of the appropriate types, and to
+   * identify when an object is of a built-in type.
*/
final TypeProvider _typeProvider;

@@ -1794,10 +1758,8 @@
}

/**
-   * Return the result of applying boolean conversion to this result.
-   *
-   * @param node the node against which errors should be reported
-   * @return the result of applying boolean conversion to the given value
+   * Return the result of applying boolean conversion to the [evaluationResult].
+   * The [node] is the node against which errors should be reported.
*/
DartObjectImpl applyBooleanConversion(
AstNode node, DartObjectImpl evaluationResult) {
@@ -2085,10 +2047,9 @@
}

/**
-   * Return the result of invoking the 'length' getter on this result.
-   *
-   * @param node the node against which errors should be reported
-   * @return the result of invoking the 'length' getter on this result
+   * Return the result of invoking the 'length' getter on the
+   * [evaluationResult]. The [node] is the node against which errors should be
+   * reported.
*/
EvaluationResultImpl stringLength(
Expression node, EvaluationResultImpl evaluationResult) {
@@ -2117,7 +2078,7 @@
}

/**
- * Instances of the class DartObjectImpl represent an instance of a Dart class.
+ * An instance of a Dart class.
*/
class DartObjectImpl implements DartObject {
/**
@@ -2136,10 +2097,7 @@
final InstanceState _state;

/**
-   * Initialize a newly created object to have the given type and state.
-   *
-   * @param type the run-time type of this object
-   * @param state the state of the object
+   * Initialize a newly created object to have the given [type] and [_state].
*/
DartObjectImpl(this.type, this._state);

@@ -2177,16 +2135,12 @@

/**
* Return true if this object represents an object whose type is 'bool'.
-   *
-   * @return true if this object represents a boolean value
*/
bool get isBool => _state.isBool;

/**
-   * Return true if this object represents an object whose type is either 'bool', 'num',
-   * 'String', or 'Null'.
-   *
-   * @return true if this object represents either a boolean, numeric, string or null value
+   * Return true if this object represents an object whose type is either
+   * 'bool', 'num', 'String', or 'Null'.
*/
bool get isBoolNumStringOrNull => _state.isBoolNumStringOrNull;

@@ -2202,14 +2156,13 @@
_state is BoolState && identical((_state as BoolState).value, true);

/**
-   * Return true if this object represents an unknown value.
+   * Return true if this object represents an unknown value.
*/
bool get isUnknown => _state.isUnknown;

/**
-   * Return true if this object represents an instance of a user-defined class.
-   *
-   * @return true if this object represents an instance of a user-defined class
+   * Return true if this object represents an instance of a user-defined
+   * class.
*/
bool get isUserDefinedObject => _state is GenericState;

@@ -2234,12 +2187,12 @@
}

/**
-   * Return the result of invoking the '+' operator on this object with the given argument.
+   * Return the result of invoking the '+' operator on this object with the
+   * given [rightOperand]. The [typeProvider] is the type provider used to find
+   * known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '+' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl add(TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2257,12 +2210,12 @@
}

/**
-   * Return the result of invoking the '&' operator on this object with the given argument.
+   * Return the result of invoking the '&' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl bitAnd(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2270,22 +2223,22 @@
typeProvider.intType, _state.bitAnd(rightOperand._state));

/**
-   * Return the result of invoking the '~' operator on this object.
+   * Return the result of invoking the '~' operator on this object. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of invoking the '~' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl bitNot(TypeProvider typeProvider) =>
new DartObjectImpl(typeProvider.intType, _state.bitNot());

/**
-   * Return the result of invoking the '|' operator on this object with the given argument.
+   * Return the result of invoking the '|' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '|' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl bitOr(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2293,12 +2246,12 @@
typeProvider.intType, _state.bitOr(rightOperand._state));

/**
-   * Return the result of invoking the '^' operator on this object with the given argument.
+   * Return the result of invoking the '^' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '^' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl bitXor(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2306,12 +2259,12 @@
typeProvider.intType, _state.bitXor(rightOperand._state));

/**
-   * Return the result of invoking the ' ' operator on this object with the given argument.
+   * Return the result of invoking the ' ' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the ' ' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl concatenate(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2319,11 +2272,11 @@
typeProvider.stringType, _state.concatenate(rightOperand._state));

/**
-   * Return the result of applying boolean conversion to this object.
+   * Return the result of applying boolean conversion to this object. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of applying boolean conversion to this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl convertToBool(TypeProvider typeProvider) {
InterfaceType boolType = typeProvider.boolType;
@@ -2334,12 +2287,12 @@
}

/**
-   * Return the result of invoking the '/' operator on this object with the given argument.
+   * Return the result of invoking the '/' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '/' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for
+   * an object of this kind.
*/
DartObjectImpl divide(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2356,12 +2309,12 @@
}

/**
-   * Return the result of invoking the '==' operator on this object with the given argument.
+   * Return the result of invoking the '==' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '==' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl equalEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2383,12 +2336,12 @@
}

/**
-   * Return the result of invoking the '&gt;' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl greaterThan(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2396,24 +2349,24 @@
typeProvider.boolType, _state.greaterThan(rightOperand._state));

/**
-   * Return the result of invoking the '&gt;=' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;=' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;=' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl greaterThanOrEqual(TypeProvider typeProvider,
DartObjectImpl rightOperand) => new DartObjectImpl(
typeProvider.boolType, _state.greaterThanOrEqual(rightOperand._state));

/**
-   * Return the result of invoking the '~/' operator on this object with the given argument.
+   * Return the result of invoking the '~/' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '~/' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl integerDivide(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2422,12 +2375,8 @@

/**
* Return the result of invoking the identical function on this object with
-   * the given argument.
-   *
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the identical function on this object with
-   *         the given argument
+   * the [rightOperand]. The [typeProvider] is the type provider used to find
+   * known types.
*/
DartObjectImpl isIdentical(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2436,12 +2385,12 @@
}

/**
-   * Return the result of invoking the '&lt;' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl lessThan(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2449,12 +2398,12 @@
typeProvider.boolType, _state.lessThan(rightOperand._state));

/**
-   * Return the result of invoking the '&lt;=' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;=' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;=' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl lessThanOrEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2462,12 +2411,12 @@
typeProvider.boolType, _state.lessThanOrEqual(rightOperand._state));

/**
-   * Return the result of invoking the '&&' operator on this object with the given argument.
+   * Return the result of invoking the '&&' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&&' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl logicalAnd(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2475,22 +2424,22 @@
typeProvider.boolType, _state.logicalAnd(rightOperand._state));

/**
-   * Return the result of invoking the '!' operator on this object.
+   * Return the result of invoking the '!' operator on this object. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of invoking the '!' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl logicalNot(TypeProvider typeProvider) =>
new DartObjectImpl(typeProvider.boolType, _state.logicalNot());

/**
-   * Return the result of invoking the '||' operator on this object with the given argument.
+   * Return the result of invoking the '||' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '||' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl logicalOr(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2498,12 +2447,12 @@
typeProvider.boolType, _state.logicalOr(rightOperand._state));

/**
-   * Return the result of invoking the '-' operator on this object with the given argument.
+   * Return the result of invoking the '-' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '-' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl minus(TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.minus(rightOperand._state);
@@ -2519,11 +2468,11 @@
}

/**
-   * Return the result of invoking the '-' operator on this object.
+   * Return the result of invoking the '-' operator on this object. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of invoking the '-' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl negated(TypeProvider typeProvider) {
InstanceState result = _state.negated();
@@ -2539,12 +2488,12 @@
}

/**
-   * Return the result of invoking the '!=' operator on this object with the given argument.
+   * Return the result of invoking the '!=' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '!=' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl notEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2563,11 +2512,11 @@
}

/**
-   * Return the result of converting this object to a String.
+   * Return the result of converting this object to a 'String'. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of converting this object to a String
-   * @throws EvaluationException if the object cannot be converted to a String
+   * Throws an [EvaluationException] if the object cannot be converted to a
+   * 'String'.
*/
DartObjectImpl performToString(TypeProvider typeProvider) {
InterfaceType stringType = typeProvider.stringType;
@@ -2578,12 +2527,12 @@
}

/**
-   * Return the result of invoking the '%' operator on this object with the given argument.
+   * Return the result of invoking the '%' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '%' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl remainder(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
@@ -2601,12 +2550,12 @@
}

/**
-   * Return the result of invoking the '&lt;&lt;' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;&lt;' operator on this object with
+   * the [rightOperand]. The [typeProvider] is the type provider used to find
+   * known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;&lt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl shiftLeft(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2614,12 +2563,12 @@
typeProvider.intType, _state.shiftLeft(rightOperand._state));

/**
-   * Return the result of invoking the '&gt;&gt;' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;&gt;' operator on this object with
+   * the [rightOperand]. The [typeProvider] is the type provider used to find
+   * known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;&gt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl shiftRight(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
@@ -2627,22 +2576,22 @@
typeProvider.intType, _state.shiftRight(rightOperand._state));

/**
-   * Return the result of invoking the 'length' getter on this object.
+   * Return the result of invoking the 'length' getter on this object. The
+   * [typeProvider] is the type provider used to find known types.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of invoking the 'length' getter on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl stringLength(TypeProvider typeProvider) =>
new DartObjectImpl(typeProvider.intType, _state.stringLength());

/**
-   * Return the result of invoking the '*' operator on this object with the given argument.
+   * Return the result of invoking the '*' operator on this object with the
+   * [rightOperand]. The [typeProvider] is the type provider used to find known
+   * types.
*
-   * @param typeProvider the type provider used to find known types
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '*' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
DartObjectImpl times(TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.times(rightOperand._state);
@@ -2662,8 +2611,8 @@
}

/**
- * Instances of the class DeclaredVariables provide access to the values of variables that
- * have been defined on the command line using the -D option.
+ * An object used to provide access to the values of variables that have been
+ * defined on the command line using the -D option.
*/
class DeclaredVariables {
/**
@@ -2672,26 +2621,21 @@
HashMap<String, String> _declaredVariables = new HashMap<String, String>();

/**
-   * Define a variable with the given name to have the given value.
-   *
-   * @param variableName the name of the variable being defined
-   * @param value the value of the variable
+   * Define a variable with the given [name] to have the given [value].
*/
-  void define(String variableName, String value) {
-    _declaredVariables[variableName] = value;
+  void define(String name, String value) {
+    _declaredVariables[name] = value;
}

/**
-   * Return the value of the variable with the given name interpreted as a boolean value. If the
-   * variable is not defined (or [variableName] is null), a DartObject representing "unknown"
-   * is returned. If the value can't be parsed as a boolean, a DartObject representing null is
-   * returned.
-   *
-   * @param typeProvider the type provider used to find the type 'bool'
-   * @param variableName the name of the variable whose value is to be returned
+   * Return the value of the variable with the given [name] interpreted as a
+   * 'boolean' value. If the variable is not defined (or [name] is null), a
+   * DartObject representing "unknown" is returned. If the value cannot be
+   * parsed as a boolean, a DartObject representing 'null' is returned. The
+   * [typeProvider] is the type provider used to find the type 'bool'.
*/
-  DartObject getBool(TypeProvider typeProvider, String variableName) {
-    String value = _declaredVariables[variableName];
+  DartObject getBool(TypeProvider typeProvider, String name) {
+    String value = _declaredVariables[name];
if (value == null) {
return new DartObjectImpl(typeProvider.boolType, BoolState.UNKNOWN_VALUE);
}
@@ -2704,39 +2648,35 @@
}

/**
-   * Return the value of the variable with the given name interpreted as an integer value. If the
-   * variable is not defined (or [variableName] is null), a DartObject representing "unknown"
-   * is returned. If the value can't be parsed as an integer, a DartObject representing null is
-   * returned.
-   *
-   * @param typeProvider the type provider used to find the type 'int'
-   * @param variableName the name of the variable whose value is to be returned
+   * Return the value of the variable with the given [name] interpreted as an
+   * integer value. If the variable is not defined (or [name] is null), a
+   * DartObject representing "unknown" is returned. If the value cannot be
+   * parsed as an integer, a DartObject representing 'null' is returned.
*/
-  DartObject getInt(TypeProvider typeProvider, String variableName) {
-    String value = _declaredVariables[variableName];
+  DartObject getInt(TypeProvider typeProvider, String name) {
+    String value = _declaredVariables[name];
if (value == null) {
return new DartObjectImpl(typeProvider.intType, IntState.UNKNOWN_VALUE);
}
int bigInteger;
try {
bigInteger = int.parse(value);
-    } on FormatException catch (exception) {
+    } on FormatException {
return new DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE);
}
return new DartObjectImpl(typeProvider.intType, new IntState(bigInteger));
}

/**
-   * Return the value of the variable with the given name interpreted as a String value, or
-   * null if the variable is not defined. Return the value of the variable with the given
-   * name interpreted as a String value. If the variable is not defined (or [variableName] is
-   * null), a DartObject representing "unknown" is returned.
-   *
-   * @param typeProvider the type provider used to find the type 'String'
-   * @param variableName the name of the variable whose value is to be returned
+   * Return the value of the variable with the given [name] interpreted as a
+   * String value, or null if the variable is not defined. Return the value of
+   * the variable with the given name interpreted as a String value. If the
+   * variable is not defined (or [name] is null), a DartObject representing
+   * "unknown" is returned. The [typeProvider] is the type provider used to find
+   * the type 'String'.
*/
-  DartObject getString(TypeProvider typeProvider, String variableName) {
-    String value = _declaredVariables[variableName];
+  DartObject getString(TypeProvider typeProvider, String name) {
+    String value = _declaredVariables[name];
if (value == null) {
return new DartObjectImpl(
typeProvider.stringType, StringState.UNKNOWN_VALUE);
@@ -2746,8 +2686,7 @@
}

/**
- * Instances of the class DoubleState represent the state of an object representing a
- * double.
+ * The state of an object representing a double.
*/
class DoubleState extends NumState {
/**
@@ -2761,9 +2700,8 @@
final double value;

/**
-   * Initialize a newly created state to represent a double with the given value.
-   *
-   * @param value the value of this instance
+   * Initialize a newly created state to represent a double with the given
+   * [value].
*/
DoubleState(this.value);

@@ -3088,8 +3026,8 @@
}

/**
- * Instances of the class DynamicState represent the state of an object representing a Dart
- * object for which there is no type information.
+ * The state of an object representing a Dart object for which there is no type
+ * information.
*/
class DynamicState extends InstanceState {
/**
@@ -3241,11 +3179,8 @@
}

/**
-   * Return an object representing an unknown numeric value whose type is based on the type of the
-   * right-hand operand.
-   *
-   * @param rightOperand the operand whose type will determine the type of the result
-   * @return an object representing an unknown numeric value
+   * Return an object representing an unknown numeric value whose type is based
+   * on the type of the [rightOperand].
*/
NumState _unknownNum(InstanceState rightOperand) {
if (rightOperand is IntState) {
@@ -3258,8 +3193,7 @@
}

/**
- * Instances of the class EvaluationException represent a run-time exception that would be
- * thrown during the evaluation of Dart code.
+ * A run-time exception that would be thrown during the evaluation of Dart code.
*/
class EvaluationException extends JavaException {
/**
@@ -3268,16 +3202,13 @@
final ErrorCode errorCode;

/**
-   * Initialize a newly created exception to have the given error code.
-   *
-   * @param errorCode the error code associated with the exception
+   * Initialize a newly created exception to have the given [errorCode].
*/
EvaluationException(this.errorCode);
}

/**
- * Instances of the class EvaluationResult represent the result of attempting to evaluate an
- * expression.
+ * The result of attempting to evaluate an expression.
*/
class EvaluationResult {
/**
@@ -3286,70 +3217,65 @@
final DartObject value;

/**
-   * The errors that should be reported for the expression(s) that were evaluated.
+   * The errors that should be reported for the expression(s) that were
+   * evaluated.
*/
final List<AnalysisError> _errors;

/**
-   * Initialize a newly created result object with the given state. Clients should use one of the
-   * factory methods: [forErrors] and [forValue].
-   *
-   * @param value the value of the expression
-   * @param errors the errors that should be reported for the expression(s) that were evaluated
+   * Initialize a newly created result object with the given [value] and set of
+   * [_errors]. Clients should use one of the factory methods: [forErrors] and
+   * [forValue].
*/
EvaluationResult(this.value, this._errors);

/**
-   * Return an array containing the errors that should be reported for the expression(s) that were
-   * evaluated. If there are no such errors, the array will be empty. The array can be empty even if
-   * the expression is not a valid compile time constant if the errors would have been reported by
-   * other parts of the analysis engine.
+   * Return a list containing the errors that should be reported for the
+   * expression(s) that were evaluated. If there are no such errors, the list
+   * will be empty. The list can be empty even if the expression is not a valid
+   * compile time constant if the errors would have been reported by other parts
+   * of the analysis engine.
*/
List<AnalysisError> get errors =>
_errors == null ? AnalysisError.NO_ERRORS : _errors;

/**
-   * Return true if the expression is a compile-time constant expression that would not
-   * throw an exception when evaluated.
-   *
-   * @return true if the expression is a valid compile-time constant expression
+   * Return true if the expression is a compile-time constant expression that
+   * would not throw an exception when evaluated.
*/
bool get isValid => _errors == null;

/**
-   * Return an evaluation result representing the result of evaluating an expression that is not a
-   * compile-time constant because of the given errors.
-   *
-   * @param errors the errors that should be reported for the expression(s) that were evaluated
-   * @return the result of evaluating an expression that is not a compile-time constant
+   * Return an evaluation result representing the result of evaluating an
+   * expression that is not a compile-time constant because of the given
+   * [errors].
*/
static EvaluationResult forErrors(List<AnalysisError> errors) =>
new EvaluationResult(null, errors);

/**
-   * Return an evaluation result representing the result of evaluating an expression that is a
-   * compile-time constant that evaluates to the given value.
-   *
-   * @param value the value of the expression
-   * @return the result of evaluating an expression that is a compile-time constant
+   * Return an evaluation result representing the result of evaluating an
+   * expression that is a compile-time constant that evaluates to the given
+   * [value].
*/
static EvaluationResult forValue(DartObject value) =>
new EvaluationResult(value, null);
}

/**
- * Instances of the class InternalResult represent the result of attempting to evaluate a
- * expression.
+ * The result of attempting to evaluate a expression.
*/
class EvaluationResultImpl {
/**
-   * The errors encountered while trying to evaluate the compile time constant. These errors may or
-   * may not have prevented the expression from being a valid compile time constant.
+   * The errors encountered while trying to evaluate the compile time constant.
+   * These errors may or may not have prevented the expression from being a
+   * valid compile time constant.
*/
List<AnalysisError> _errors;

/**
-   * The value of the expression, or null if the value couldn't be computed due to errors.
+   * The value of the expression, or null if the value couldn't be computed
+   * due to errors.
*/
final DartObjectImpl value;

@@ -3384,8 +3310,7 @@
}

/**
- * Instances of the class FunctionState represent the state of an object representing a
- * function.
+ * The state of an object representing a function.
*/
class FunctionState extends InstanceState {
/**
@@ -3394,9 +3319,8 @@
final ExecutableElement _element;

/**
-   * Initialize a newly created state to represent the given function.
-   *
-   * @param element the element representing the function being modeled
+   * Initialize a newly created state to represent the function with the given
+   * [element].
*/
FunctionState(this._element);

@@ -3445,8 +3369,8 @@
}

/**
- * Instances of the class GenericState represent the state of an object representing a Dart
- * object for which there is no more specific state.
+ * The state of an object representing a Dart object for which there is no more
+ * specific state.
*/
class GenericState extends InstanceState {
/**
@@ -3466,9 +3390,8 @@
final HashMap<String, DartObjectImpl> _fieldMap;

/**
-   * Initialize a newly created state to represent a newly created object.
-   *
-   * @param fieldMap the values of the fields of this instance
+   * Initialize a newly created state to represent a newly created object. The
+   * [fieldMap] contains the values of the fields of the instance.
*/
GenericState(this._fieldMap);

@@ -3550,65 +3473,54 @@
}

/**
- * The class InstanceState defines the behavior of objects representing the state of a Dart
- * object.
+ * The state of an object representing a Dart object.
*/
abstract class InstanceState {
/**
-   * If this represents a generic dart object, return a map from its fieldnames to their values.
-   * Otherwise return null.
+   * If this represents a generic dart object, return a map from its field names
+   * to their values. Otherwise return null.
*/
HashMap<String, DartObjectImpl> get fields => null;

/**
* Return true if this object's value can be represented exactly.
-   *
-   * @return true if this object's value can be represented exactly
*/
bool get hasExactValue => false;

/**
* Return true if this object represents an object whose type is 'bool'.
-   *
-   * @return true if this object represents a boolean value
*/
bool get isBool => false;

/**
-   * Return true if this object represents an object whose type is either 'bool', 'num',
-   * 'String', or 'Null'.
-   *
-   * @return true if this object represents either a boolean, numeric, string or null value
+   * Return true if this object represents an object whose type is either
+   * 'bool', 'num', 'String', or 'Null'.
*/
bool get isBoolNumStringOrNull => false;

/**
-   * Return true if this object represents an unknown value.
+   * Return true if this object represents an unknown value.
*/
bool get isUnknown => false;

/**
* Return the name of the type of this value.
-   *
-   * @return the name of the type of this value
*/
String get typeName;

/**
-   * Return this object's value if it can be represented exactly, or null if either the
-   * value cannot be represented exactly or if the value is null. Clients should use
-   * [hasExactValue] to distinguish between these two cases.
-   *
-   * @return this object's value
+   * Return this object's value if it can be represented exactly, or null if
+   * either the value cannot be represented exactly or if the value is null.
+   * Clients should use [hasExactValue] to distinguish between these two cases.
*/
Object get value => null;

/**
-   * Return the result of invoking the '+' operator on this object with the given argument.
+   * Return the result of invoking the '+' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '+' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
if (this is StringState && rightOperand is StringState) {
@@ -3620,10 +3532,7 @@
}

/**
-   * Throw an exception if the given state does not represent a boolean value.
-   *
-   * @param state the state being tested
-   * @throws EvaluationException if the given state does not represent a boolean value
+   * Throw an exception if the given [state] does not represent a boolean value.
*/
void assertBool(InstanceState state) {
if (!(state is BoolState || state is DynamicState)) {
@@ -3632,12 +3541,8 @@
}

/**
-   * Throw an exception if the given state does not represent a boolean, numeric, string or null
-   * value.
-   *
-   * @param state the state being tested
-   * @throws EvaluationException if the given state does not represent a boolean, numeric, string or
-   *           null value
+   * Throw an exception if the given [state] does not represent a boolean,
+   * numeric, string or null value.
*/
void assertBoolNumStringOrNull(InstanceState state) {
if (!(state is BoolState ||
@@ -3653,10 +3558,8 @@
}

/**
-   * Throw an exception if the given state does not represent an integer or null value.
-   *
-   * @param state the state being tested
-   * @throws EvaluationException if the given state does not represent an integer or null value
+   * Throw an exception if the given [state] does not represent an integer or
+   * null value.
*/
void assertIntOrNull(InstanceState state) {
if (!(state is IntState ||
@@ -3668,12 +3571,8 @@
}

/**
-   * Throw an exception if the given state does not represent a boolean, numeric, string or null
-   * value.
-   *
-   * @param state the state being tested
-   * @throws EvaluationException if the given state does not represent a boolean, numeric, string or
-   *           null value
+   * Throw an exception if the given [state] does not represent a boolean,
+   * numeric, string or null value.
*/
void assertNumOrNull(InstanceState state) {
if (!(state is DoubleState ||
@@ -3686,10 +3585,7 @@
}

/**
-   * Throw an exception if the given state does not represent a String value.
-   *
-   * @param state the state being tested
-   * @throws EvaluationException if the given state does not represent a String value
+   * Throw an exception if the given [state] does not represent a String value.
*/
void assertString(InstanceState state) {
if (!(state is StringState || state is DynamicState)) {
@@ -3698,11 +3594,11 @@
}

/**
-   * Return the result of invoking the '&' operator on this object with the given argument.
+   * Return the result of invoking the '&' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState bitAnd(InstanceState rightOperand) {
assertIntOrNull(this);
@@ -3713,8 +3609,8 @@
/**
* Return the result of invoking the '~' operator on this object.
*
-   * @return the result of invoking the '~' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState bitNot() {
assertIntOrNull(this);
@@ -3722,11 +3618,11 @@
}

/**
-   * Return the result of invoking the '|' operator on this object with the given argument.
+   * Return the result of invoking the '|' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '|' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState bitOr(InstanceState rightOperand) {
assertIntOrNull(this);
@@ -3735,11 +3631,11 @@
}

/**
-   * Return the result of invoking the '^' operator on this object with the given argument.
+   * Return the result of invoking the '^' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '^' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState bitXor(InstanceState rightOperand) {
assertIntOrNull(this);
@@ -3748,11 +3644,11 @@
}

/**
-   * Return the result of invoking the ' ' operator on this object with the given argument.
+   * Return the result of invoking the ' ' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the ' ' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
StringState concatenate(InstanceState rightOperand) {
assertString(rightOperand);
@@ -3762,26 +3658,25 @@
/**
* Return the result of applying boolean conversion to this object.
*
-   * @param typeProvider the type provider used to find known types
-   * @return the result of applying boolean conversion to this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState convertToBool() => BoolState.FALSE_STATE;

/**
* Return the result of converting this object to a String.
*
-   * @return the result of converting this object to a String
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
StringState convertToString();

/**
-   * Return the result of invoking the '/' operator on this object with the given argument.
+   * Return the result of invoking the '/' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '/' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
NumState divide(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3790,20 +3685,20 @@
}

/**
-   * Return the result of invoking the '==' operator on this object with the given argument.
+   * Return the result of invoking the '==' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '==' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState equalEqual(InstanceState rightOperand);

/**
-   * Return the result of invoking the '&gt;' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState greaterThan(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3812,11 +3707,11 @@
}

/**
-   * Return the result of invoking the '&gt;=' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;=' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;=' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState greaterThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3825,11 +3720,11 @@
}

/**
-   * Return the result of invoking the '~/' operator on this object with the given argument.
+   * Return the result of invoking the '~/' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '~/' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState integerDivide(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3839,20 +3734,16 @@

/**
* Return the result of invoking the identical function on this object with
-   * the given argument.
-   *
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the identical function on this object with
-   *         the given argument
+   * the [rightOperand].
*/
BoolState isIdentical(InstanceState rightOperand);

/**
-   * Return the result of invoking the '&lt;' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState lessThan(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3861,11 +3752,11 @@
}

/**
-   * Return the result of invoking the '&lt;=' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;=' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;=' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState lessThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3874,11 +3765,11 @@
}

/**
-   * Return the result of invoking the '&&' operator on this object with the given argument.
+   * Return the result of invoking the '&&' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&&' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState logicalAnd(InstanceState rightOperand) {
assertBool(this);
@@ -3889,8 +3780,8 @@
/**
* Return the result of invoking the '!' operator on this object.
*
-   * @return the result of invoking the '!' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState logicalNot() {
assertBool(this);
@@ -3898,11 +3789,11 @@
}

/**
-   * Return the result of invoking the '||' operator on this object with the given argument.
+   * Return the result of invoking the '||' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '||' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
BoolState logicalOr(InstanceState rightOperand) {
assertBool(this);
@@ -3911,11 +3802,11 @@
}

/**
-   * Return the result of invoking the '-' operator on this object with the given argument.
+   * Return the result of invoking the '-' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '-' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
NumState minus(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3926,8 +3817,8 @@
/**
* Return the result of invoking the '-' operator on this object.
*
-   * @return the result of invoking the '-' operator on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
NumState negated() {
assertNumOrNull(this);
@@ -3935,11 +3826,11 @@
}

/**
-   * Return the result of invoking the '%' operator on this object with the given argument.
+   * Return the result of invoking the '%' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '%' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
NumState remainder(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3948,11 +3839,11 @@
}

/**
-   * Return the result of invoking the '&lt;&lt;' operator on this object with the given argument.
+   * Return the result of invoking the '&lt;&lt;' operator on this object with
+   * the [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&lt;&lt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState shiftLeft(InstanceState rightOperand) {
assertIntOrNull(this);
@@ -3961,11 +3852,11 @@
}

/**
-   * Return the result of invoking the '&gt;&gt;' operator on this object with the given argument.
+   * Return the result of invoking the '&gt;&gt;' operator on this object with
+   * the [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '&gt;&gt;' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState shiftRight(InstanceState rightOperand) {
assertIntOrNull(this);
@@ -3976,8 +3867,8 @@
/**
* Return the result of invoking the 'length' getter on this object.
*
-   * @return the result of invoking the 'length' getter on this object
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
IntState stringLength() {
assertString(this);
@@ -3985,11 +3876,11 @@
}

/**
-   * Return the result of invoking the '*' operator on this object with the given argument.
+   * Return the result of invoking the '*' operator on this object with the
+   * [rightOperand].
*
-   * @param rightOperand the right-hand operand of the operation
-   * @return the result of invoking the '*' operator on this object with the given argument
-   * @throws EvaluationException if the operator is not appropriate for an object of this kind
+   * Throws an [EvaluationException] if the operator is not appropriate for an
+   * object of this kind.
*/
NumState times(InstanceState rightOperand) {
assertNumOrNull(this);
@@ -3999,7 +3890,7 @@
}

/**
- * Instances of the class IntState represent the state of an object representing an int.
+ * The state of an object representing an int.
*/
class IntState extends NumState {
/**
@@ -4013,9 +3904,8 @@
final int value;

/**
-   * Initialize a newly created state to represent an int with the given value.
-   *
-   * @param value the value of this instance
+   * Initialize a newly created state to represent an int with the given
+   * [value].
*/
IntState(this.value);

@@ -4143,19 +4033,15 @@
NumState divide(InstanceState rightOperand) {
assertNumOrNull(rightOperand);
if (value == null) {
-      if (rightOperand is DoubleState) {
-        return DoubleState.UNKNOWN_VALUE;
-      }
-      return UNKNOWN_VALUE;
+      return DoubleState.UNKNOWN_VALUE;
}
if (rightOperand is IntState) {
int rightValue = rightOperand.value;
if (rightValue == null) {
-        return UNKNOWN_VALUE;
-      } else if (rightValue == 0) {
+        return DoubleState.UNKNOWN_VALUE;
+      } else {
return new DoubleState(value.toDouble() / rightValue.toDouble());
}
-      return new IntState(value ~/ rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
@@ -4163,7 +4049,7 @@
}
return new DoubleState(value.toDouble() / rightValue);
} else if (rightOperand is DynamicState || rightOperand is NumState) {
-      return UNKNOWN_VALUE;
+      return DoubleState.UNKNOWN_VALUE;
}
throw new EvaluationException(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
@@ -4468,8 +4354,7 @@
}

/**
- * The unique instance of the class ListState represents the state of an object representing
- * a list.
+ * The state of an object representing a list.
*/
class ListState extends InstanceState {
/**
@@ -4478,9 +4363,8 @@
final List<DartObjectImpl> _elements;

/**
-   * Initialize a newly created state to represent a list with the given elements.
-   *
-   * @param elements the elements of the list
+   * Initialize a newly created state to represent a list with the given
+   * [elements].
*/
ListState(this._elements);

@@ -4578,8 +4462,7 @@
}

/**
- * The unique instance of the class ListState represents the state of an object representing
- * a map.
+ * The state of an object representing a map.
*/
class MapState extends InstanceState {
/**
@@ -4588,9 +4471,8 @@
final HashMap<DartObjectImpl, DartObjectImpl> _entries;

/**
-   * Initialize a newly created state to represent a map with the given entries.
-   *
-   * @param entries the entries in the map
+   * Initialize a newly created state to represent a map with the given
+   * [entries].
*/
MapState(this._entries);

@@ -4690,11 +4572,11 @@
}

/**
- * The unique instance of the class NullState represents the state of the value 'null'.
+ * The state of an object representing the value 'null'.
*/
class NullState extends InstanceState {
/**
-   * An instance representing the boolean value 'true'.
+   * An instance representing the boolean value 'null'.
*/
static NullState NULL_STATE = new NullState();

@@ -4747,8 +4629,7 @@
}

/**
- * Instances of the class NumState represent the state of an object representing a number of
- * an unknown type (a 'num').
+ * The state of an object representing a number of an unknown type (a 'num').
*/
class NumState extends InstanceState {
/**
@@ -4783,7 +4664,7 @@
@override
NumState divide(InstanceState rightOperand) {
assertNumOrNull(rightOperand);
-    return UNKNOWN_VALUE;
+    return DoubleState.UNKNOWN_VALUE;
}

@override
@@ -4864,8 +4745,8 @@
}

/**
- * Instances of the class ReferenceFinder add reference information for a given variable to
- * the bi-directional mapping used to order the evaluation of constants.
+ * An object used to add reference information for a given variable to the
+ * bi-directional mapping used to order the evaluation of constants.
*/
class ReferenceFinder extends RecursiveAstVisitor<Object> {
/**
@@ -4874,8 +4755,9 @@
final AstNode _source;

/**
-   * A graph in which the nodes are the constant variables and the edges are from each variable to
-   * the other constant variables that are referenced in the head's initializer.
+   * A graph in which the nodes are the constant variables and the edges are
+   * from each variable to the other constant variables that are referenced in
*/
final DirectedGraph<AstNode> _referenceGraph;

@@ -4885,21 +4767,20 @@
final HashMap<VariableElement, VariableDeclaration> _variableDeclarationMap;

/**
-   * A table mapping constant constructors to the declarations of those constructors.
+   * A table mapping constant constructors to the declarations of those
+   * constructors.
*/
final HashMap<ConstructorElement, ConstructorDeclaration> _constructorDeclarationMap;

/**
-   * Initialize a newly created reference finder to find references from the given variable to other
-   * variables and to add those references to the given graph.
-   *
-   * @param source the element representing the variable whose initializer will be visited
-   * @param referenceGraph a graph recording which variables (heads) reference which other variables
-   *          (tails) in their initializers
-   * @param variableDeclarationMap A table mapping constant variables to the declarations of those
-   *          variables.
-   * @param constructorDeclarationMap A table mapping constant constructors to the declarations of
-   *          those constructors.
+   * Initialize a newly created reference finder to find references from a given
+   * variable to other variables and to add those references to the given graph.
+   * The [source] is the element representing the variable whose initializer
+   * will be visited. The [referenceGraph] is a graph recording which variables
+   * (heads) reference which other variables (tails) in their initializers. The
+   * [variableDeclarationMap] is a table mapping constant variables to the
+   * declarations of those variables. The [constructorDeclarationMap] is a table
+   * mapping constant constructors to the declarations of those constructors.
*/
ReferenceFinder(this._source, this._referenceGraph,
this._variableDeclarationMap, this._constructorDeclarationMap);
@@ -4934,10 +4815,9 @@
element = (element as PropertyAccessorElement).variable;
}
if (element is VariableElement) {
-      VariableElement variable = element as VariableElement;
-      if (variable.isConst) {
+      if (element.isConst) {
VariableDeclaration variableDeclaration =
-            _variableDeclarationMap[variable];
+            _variableDeclarationMap[element];
// The declaration will be null when the variable is not defined in the
// compilation units that were used to produce the
// variableDeclarationMap.  In such cases, the variable should already
@@ -4972,8 +4852,7 @@
}

/**
- * Instances of the class StringState represent the state of an object representing a
- * string.
+ * The state of an object representing a string.
*/
class StringState extends InstanceState {
/**
@@ -4987,9 +4866,7 @@
final String value;

/**
-   * Initialize a newly created state to represent the given value.
-   *
-   * @param value the value of this instance
+   * Initialize a newly created state to represent the given [value].
*/
StringState(this.value);

@@ -5068,8 +4945,7 @@
}

/**
- * Instances of the class StringState represent the state of an object representing a
- * symbol.
+ * The state of an object representing a symbol.
*/
class SymbolState extends InstanceState {
/**
@@ -5078,9 +4954,7 @@
final String value;

/**
-   * Initialize a newly created state to represent the given value.
-   *
-   * @param value the value of this instance
+   * Initialize a newly created state to represent the given [value].
*/
SymbolState(this.value);

@@ -5133,7 +5007,7 @@
}

/**
- * Instances of the class TypeState represent the state of an object representing a type.
+ * The state of an object representing a type.
*/
class TypeState extends InstanceState {
/**
@@ -5142,9 +5016,7 @@
final Element _element;

/**
-   * Initialize a newly created state to represent the given value.
-   *
-   * @param element the element representing the type being modeled
+   * Initialize a newly created state to represent the given [value].
*/
TypeState(this._element);


diff --git a/dart/pkg/analyzer/lib/src/generated/element.dart b/dart/pkg/analyzer/lib/src/generated/element.dart
index a7d8bf3..082415c 100644
--- a/dart/pkg/analyzer/lib/src/generated/element.dart
+++ b/dart/pkg/analyzer/lib/src/generated/element.dart

@@ -10,6 +10,7 @@
import 'dart:collection';

import 'package:analyzer/src/generated/utilities_general.dart';

import 'ast.dart';
import 'constant.dart' show EvaluationResultImpl;
@@ -25,54 +26,51 @@
import 'utilities_dart.dart';

/**
- * For AST nodes that could be in both the getter and setter contexts ([IndexExpression]s and
- * [SimpleIdentifier]s), the additional resolved elements are stored in the AST node, in an
- * [AuxiliaryElements]. Since resolved elements are either statically resolved or resolved
- * using propagated type information, this class is a wrapper for a pair of
- * [ExecutableElement]s, not just a single [ExecutableElement].
+ * For AST nodes that could be in both the getter and setter contexts
+ * ([IndexExpression]s and [SimpleIdentifier]s), the additional resolved
+ * elements are stored in the AST node, in an [AuxiliaryElements]. Because
+ * resolved elements are either statically resolved or resolved using propagated
+ * type information, this class is a wrapper for a pair of [ExecutableElement]s,
+ * not just a single [ExecutableElement].
*/
class AuxiliaryElements {
/**
-   * The element based on propagated type information, or null if the AST structure has not
-   * been resolved or if this identifier could not be resolved.
+   * The element based on propagated type information, or null if the AST
+   * structure has not been resolved or if the node could not be resolved.
*/
final ExecutableElement propagatedElement;

/**
-   * The element associated with this identifier based on static type information, or null
-   * if the AST structure has not been resolved or if this identifier could not be resolved.
+   * The element based on static type information, or null if the AST
+   * structure has not been resolved or if the node could not be resolved.
*/
final ExecutableElement staticElement;

/**
-   * Create the [AuxiliaryElements] with a static and propagated [ExecutableElement].
-   *
-   * @param staticElement the static element
-   * @param propagatedElement the propagated element
+   * Initialize a newly created pair to have both the [staticElement] and the
+   * [propagatedElement].
*/
AuxiliaryElements(this.staticElement, this.propagatedElement);
}

/**
- * The unique instance of the class BottomTypeImpl implements the type bottom.
+ * A [Type] that represents the type 'bottom'.
*/
class BottomTypeImpl extends TypeImpl {
/**
* The unique instance of this class.
*/
-  static BottomTypeImpl _INSTANCE = new BottomTypeImpl();
+  static BottomTypeImpl _INSTANCE = new BottomTypeImpl._();

/**
* Return the unique instance of this class.
-   *
-   * @return the unique instance of this class
*/
static BottomTypeImpl get instance => _INSTANCE;

/**
* Prevent the creation of instances of this class.
*/
-  BottomTypeImpl() : super(null, "<bottom>");
+  BottomTypeImpl._() : super(null, "<bottom>");

@override
int get hashCode => 0;
@@ -107,235 +105,196 @@
}

/**
- * The interface ClassElement defines the behavior of elements that represent a class.
+ * An element that represents a class.
*/
abstract class ClassElement implements Element {
/**
-   * Return an array containing all of the accessors (getters and setters) declared in this class.
-   *
-   * @return the accessors declared in this class
+   * Return a list containing all of the accessors (getters and setters)
+   * declared in this class.
*/
List<PropertyAccessorElement> get accessors;

/**
-   * Return an array containing all the supertypes defined for this class and its supertypes. This
-   * includes superclasses, mixins and interfaces.
-   *
-   * @return all the supertypes of this class, including mixins
+   * Return a list containing all the supertypes defined for this class and its
+   * supertypes. This includes superclasses, mixins and interfaces.
*/
List<InterfaceType> get allSupertypes;

/**
-   * Return an array containing all of the constructors declared in this class.
-   *
-   * @return the constructors declared in this class
+   * Return a list containing all of the constructors declared in this class.
*/
List<ConstructorElement> get constructors;

/**
-   * Return an array containing all of the fields declared in this class.
-   *
-   * @return the fields declared in this class
+   * Return a list containing all of the fields declared in this class.
*/
List<FieldElement> get fields;

/**
-   * Return true if this class or its superclass declares a non-final instance field.
-   *
-   * @return true if this class or its superclass declares a non-final instance field
+   * Return true if this class or its superclass declares a non-final instance
+   * field.
*/
bool get hasNonFinalField;

/**
-   * Return true if this class has reference to super (so, for example, cannot be used as a
-   * mixin).
-   *
-   * @return true if this class has reference to super
+   * Return true if this class has reference to super (so, for example, cannot
+   * be used as a mixin).
*/
bool get hasReferenceToSuper;

/**
* Return true if this class declares a static member.
-   *
-   * @return true if this class declares a static member
*/
bool get hasStaticMember;

/**
-   * Return an array containing all of the interfaces that are implemented by this class.
+   * Return a list containing all of the interfaces that are implemented by this
+   * class.
*
-   * <b>Note:</b> Because the element model represents the state of the code, it is possible for it
-   * to be semantically invalid. In particular, it is not safe to assume that the inheritance
-   * structure of a class does not contain a cycle. Clients that traverse the inheritance structure
-   * must explicitly guard against infinite loops.
-   *
-   * @return the interfaces that are implemented by this class
+   * <b>Note:</b> Because the element model represents the state of the code, it
+   * is possible for it to be semantically invalid. In particular, it is not
+   * safe to assume that the inheritance structure of a class does not contain a
+   * cycle. Clients that traverse the inheritance structure must explicitly
+   * guard against infinite loops.
*/
List<InterfaceType> get interfaces;

/**
-   * Return true if this class is abstract. A class is abstract if it has an explicit
-   * abstract modifier. Note, that this definition of <i>abstract</i> is different from
-   * <i>has unimplemented members</i>.
-   *
-   * @return true if this class is abstract
+   * Return true if this class is abstract. A class is abstract if it has an
+   * explicit abstract modifier. Note, that this definition of <i>abstract</i>
+   * is different from <i>has unimplemented members</i>.
*/
bool get isAbstract;

/**
* Return true if this class is defined by an enum declaration.
-   *
-   * @return true if this class is defined by an enum declaration
*/
bool get isEnum;

/**
-   * Return true if this class [isProxy], or if it inherits the proxy annotation
-   * from a supertype.
-   *
-   * @return true if this class defines or inherits a proxy
+   * Return true if this class [isProxy], or if it inherits the proxy
+   * annotation from a supertype.
*/
bool get isOrInheritsProxy;

/**
* Return true if this element has an annotation of the form '@proxy'.
-   *
-   * @return true if this element defines a proxy
*/
bool get isProxy;

/**
* Return true if this class is defined by a typedef construct.
-   *
-   * @return true if this class is defined by a typedef construct
*/
bool get isTypedef;

/**
-   * Return true if this class can validly be used as a mixin when defining another class.
-   * The behavior of this method is defined by the Dart Language Specification in section 9:
-   * <blockquote>It is a compile-time error if a declared or derived mixin refers to super. It is a
-   * compile-time error if a declared or derived mixin explicitly declares a constructor. It is a
-   * compile-time error if a mixin is derived from a class whose superclass is not
-   * Object.</blockquote>
-   *
-   * @return true if this class can validly be used as a mixin
+   * Return true if this class can validly be used as a mixin when defining
+   * another class. The behavior of this method is defined by the Dart Language
+   * Specification in section 9:
+   * <blockquote>
+   * It is a compile-time error if a declared or derived mixin refers to super.
+   * It is a compile-time error if a declared or derived mixin explicitly
+   * declares a constructor. It is a compile-time error if a mixin is derived
+   * from a class whose superclass is not Object.
+   * </blockquote>
*/
bool get isValidMixin;

/**
-   * Return an array containing all of the methods declared in this class.
-   *
-   * @return the methods declared in this class
+   * Return a list containing all of the methods declared in this class.
*/
List<MethodElement> get methods;

/**
-   * Return an array containing all of the mixins that are applied to the class being extended in
-   * order to derive the superclass of this class.
+   * Return a list containing all of the mixins that are applied to the class
+   * being extended in order to derive the superclass of this class.
*
-   * <b>Note:</b> Because the element model represents the state of the code, it is possible for it
-   * to be semantically invalid. In particular, it is not safe to assume that the inheritance
-   * structure of a class does not contain a cycle. Clients that traverse the inheritance structure
-   * must explicitly guard against infinite loops.
-   *
-   * @return the mixins that are applied to derive the superclass of this class
+   * <b>Note:</b> Because the element model represents the state of the code, it
+   * is possible for it to be semantically invalid. In particular, it is not
+   * safe to assume that the inheritance structure of a class does not contain a
+   * cycle. Clients that traverse the inheritance structure must explicitly
+   * guard against infinite loops.
*/
List<InterfaceType> get mixins;

/**
-   * Return the resolved [ClassDeclaration] node that declares this [ClassElement].
+   * Return the resolved [ClassDeclaration] or [EnumDeclaration] node that
+   * declares this [ClassElement].
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
-   *
-   * @return the resolved [ClassDeclaration], not null.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*/
@override
-  ClassDeclaration get node;
+  AstNode get node;

/**
-   * Return the superclass of this class, or null if the class represents the class
-   * 'Object'. All other classes will have a non-null superclass. If the superclass was not
-   * explicitly declared then the implicit superclass 'Object' will be returned.
+   * Return the superclass of this class, or null if the class represents the
+   * class 'Object'. All other classes will have a non-null superclass. If the
+   * superclass was not explicitly declared then the implicit superclass
+   * 'Object' will be returned.
*
-   * <b>Note:</b> Because the element model represents the state of the code, it is possible for it
-   * to be semantically invalid. In particular, it is not safe to assume that the inheritance
-   * structure of a class does not contain a cycle. Clients that traverse the inheritance structure
-   * must explicitly guard against infinite loops.
-   *
-   * @return the superclass of this class
+   * <b>Note:</b> Because the element model represents the state of the code, it
+   * is possible for it to be semantically invalid. In particular, it is not
+   * safe to assume that the inheritance structure of a class does not contain a
+   * cycle. Clients that traverse the inheritance structure must explicitly
+   * guard against infinite loops.
*/
InterfaceType get supertype;

/**
* Return the type defined by the class.
-   *
-   * @return the type defined by the class
*/
InterfaceType get type;

/**
-   * Return an array containing all of the type parameters declared for this class.
-   *
-   * @return the type parameters declared for this class
+   * Return a list containing all of the type parameters declared for this
+   * class.
*/
List<TypeParameterElement> get typeParameters;

/**
-   * Return the unnamed constructor declared in this class, or null if this class does not
-   * declare an unnamed constructor but does declare named constructors. The returned constructor
-   * will be synthetic if this class does not declare any constructors, in which case it will
-   * represent the default constructor for the class.
-   *
-   * @return the unnamed constructor defined in this class
+   * Return the unnamed constructor declared in this class, or null if this
+   * class does not declare an unnamed constructor but does declare named
+   * constructors. The returned constructor will be synthetic if this class does
+   * not declare any constructors, in which case it will represent the default
+   * constructor for the class.
*/
ConstructorElement get unnamedConstructor;

/**
-   * Return the field (synthetic or explicit) defined in this class that has the given name, or
-   * null if this class does not define a field with the given name.
-   *
-   * @param fieldName the name of the field to be returned
-   * @return the field with the given name that is defined in this class
+   * Return the field (synthetic or explicit) defined in this class that has the
+   * given [name], or null if this class does not define a field with the
+   * given name.
*/
-  FieldElement getField(String fieldName);
+  FieldElement getField(String name);

/**
-   * Return the element representing the getter with the given name that is declared in this class,
-   * or null if this class does not declare a getter with the given name.
-   *
-   * @param getterName the name of the getter to be returned
-   * @return the getter declared in this class with the given name
+   * Return the element representing the getter with the given [name] that is
+   * declared in this class, or null if this class does not declare a getter
+   * with the given name.
*/
-  PropertyAccessorElement getGetter(String getterName);
+  PropertyAccessorElement getGetter(String name);

/**
-   * Return the element representing the method with the given name that is declared in this class,
-   * or null if this class does not declare a method with the given name.
-   *
-   * @param methodName the name of the method to be returned
-   * @return the method declared in this class with the given name
+   * Return the element representing the method with the given [name] that is
+   * declared in this class, or null if this class does not declare a method
+   * with the given name.
*/
-  MethodElement getMethod(String methodName);
+  MethodElement getMethod(String name);

/**
-   * Return the named constructor declared in this class with the given name, or null if
-   * this class does not declare a named constructor with the given name.
-   *
-   * @param name the name of the constructor to be returned
-   * @return the element representing the specified constructor
+   * Return the named constructor declared in this class with the given [name],
+   * or null if this class does not declare a named constructor with the given
+   * name.
*/
ConstructorElement getNamedConstructor(String name);

/**
-   * Return the element representing the setter with the given name that is declared in this class,
-   * or null if this class does not declare a setter with the given name.
-   *
-   * @param setterName the name of the getter to be returned
-   * @return the setter declared in this class with the given name
+   * Return the element representing the setter with the given [name] that is
+   * declared in this class, or null if this class does not declare a setter
+   * with the given name.
*/
-  PropertyAccessorElement getSetter(String setterName);
+  PropertyAccessorElement getSetter(String name);

/**
* Determine whether the given [constructor], which exists in the superclass
@@ -344,170 +303,157 @@
bool isSuperConstructorAccessible(ConstructorElement constructor);

/**
-   * Return the element representing the method that results from looking up the given method in
-   * this class with respect to the given library, ignoring abstract methods, or null if the
-   * look up fails. The behavior of this method is defined by the Dart Language Specification in
-   * section 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>C</i> with
-   * respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * Return the element representing the method that results from looking up the
+   * given [methodName] in this class with respect to the given [library],
+   * ignoring abstract methods, or null if the look up fails. The behavior of
+   * this method is defined by the Dart Language Specification in section
+   * 16.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is: If <i>C</i> declares an instance method named <i>m</i>
+   * that is accessible to <i>L</i>, then that method is the result of the
+   * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result
+   * of the lookup is the result of looking up method <i>m</i> in <i>S</i> with
+   * respect to <i>L</i>. Otherwise, we say that the lookup has failed.
* </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in this class with respect to the given
-   *         library
*/
MethodElement lookUpConcreteMethod(String methodName, LibraryElement library);

/**
-   * Return the element representing the getter that results from looking up the given getter in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.15.1:
-   * <blockquote>The result of looking up getter (respectively setter) <i>m</i> in class <i>C</i>
-   * with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * Return the element representing the getter that results from looking up the
+   * given [getterName] in this class with respect to the given [library], or
+   * null if the look up fails. The behavior of this method is defined by the
+   * Dart Language Specification in section 16.15.2:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
+   * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an
+   * instance getter (respectively setter) named <i>m</i> that is accessible to
+   * <i>L</i>, then that getter (respectively setter) is the result of the
+   * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result
+   * of the lookup is the result of looking up getter (respectively setter)
+   * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the
+   * lookup has failed.
* </blockquote>
-   *
-   * @param getterName the name of the getter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given getter in this class with respect to the given
-   *         library
*/
PropertyAccessorElement lookUpGetter(
String getterName, LibraryElement library);

/**
-   * Return the element representing the getter that results from looking up the given getter in the
-   * superclass of this class with respect to the given library, ignoring abstract getters, or
-   * null if the look up fails. The behavior of this method is defined by the Dart Language
-   * Specification in section 12.15.1: <blockquote>The result of looking up getter (respectively
-   * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * Return the element representing the getter that results from looking up the
+   * given [getterName] in the superclass of this class with respect to the
+   * given [library], ignoring abstract getters, or null if the look up fails.
+   * The behavior of this method is defined by the Dart Language Specification
+   * in section 16.15.2:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
+   * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an
+   * instance getter (respectively setter) named <i>m</i> that is accessible to
+   * <i>L</i>, then that getter (respectively setter) is the result of the
+   * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result
+   * of the lookup is the result of looking up getter (respectively setter)
+   * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the
+   * lookup has failed.
* </blockquote>
-   *
-   * @param getterName the name of the getter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given getter in this class with respect to the given
-   *         library
*/
PropertyAccessorElement lookUpInheritedConcreteGetter(
String getterName, LibraryElement library);

/**
-   * Return the element representing the method that results from looking up the given method in the
-   * superclass of this class with respect to the given library, ignoring abstract methods, or
-   * null if the look up fails. The behavior of this method is defined by the Dart Language
-   * Specification in section 12.15.1: <blockquote> The result of looking up method <i>m</i> in
-   * class <i>C</i> with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * Return the element representing the method that results from looking up the
+   * given [methodName] in the superclass of this class with respect to the
+   * given [library], ignoring abstract methods, or null if the look up fails.
+   * The behavior of this method is defined by the Dart Language Specification
+   * in section 16.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is:  If <i>C</i> declares an instance method named
+   * <i>m</i> that is accessible to <i>L</i>, then that method is the result of
+   * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the
+   * result of the lookup is the result of looking up method <i>m</i> in
+   * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has
+   * failed.
* </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in the superclass of this class with respect
-   *         to the given library
*/
MethodElement lookUpInheritedConcreteMethod(
String methodName, LibraryElement library);

/**
-   * Return the element representing the setter that results from looking up the given setter in the
-   * superclass of this class with respect to the given library, ignoring abstract setters, or
-   * null if the look up fails. The behavior of this method is defined by the Dart Language
-   * Specification in section 12.16: <blockquote> The result of looking up getter (respectively
-   * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * Return the element representing the setter that results from looking up the
+   * given [setterName] in the superclass of this class with respect to the
+   * given [library], ignoring abstract setters, or null if the look up fails.
+   * The behavior of this method is defined by the Dart Language Specification
+   * in section 16.15.2:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
+   * <i>C</i> with respect to library <i>L</i> is:  If <i>C</i> declares an
+   * instance getter (respectively setter) named <i>m</i> that is accessible to
+   * <i>L</i>, then that getter (respectively setter) is the result of the
+   * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result
+   * of the lookup is the result of looking up getter (respectively setter)
+   * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the
+   * lookup has failed.
* </blockquote>
-   *
-   * @param setterName the name of the setter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given setter in this class with respect to the given
-   *         library
*/
PropertyAccessorElement lookUpInheritedConcreteSetter(
String setterName, LibraryElement library);

/**
-   * Return the element representing the method that results from looking up the given method in the
-   * superclass of this class with respect to the given library, or null if the look up
-   * fails. The behavior of this method is defined by the Dart Language Specification in section
-   * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>C</i> with respect
-   * to library <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * Return the element representing the method that results from looking up the
+   * given [methodName] in the superclass of this class with respect to the
+   * given [library], or null if the look up fails. The behavior of this
+   * method is defined by the Dart Language Specification in section 16.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is:  If <i>C</i> declares an instance method named
+   * <i>m</i> that is accessible to <i>L</i>, then that method is the result of
+   * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the
+   * result of the lookup is the result of looking up method <i>m</i> in
+   * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has
+   * failed.
* </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in the superclass of this class with respect
-   *         to the given library
*/
MethodElement lookUpInheritedMethod(
String methodName, LibraryElement library);

/**
-   * Return the element representing the method that results from looking up the given method in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.15.1:
-   * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> with respect to library
-   * <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * Return the element representing the method that results from looking up the
+   * given [methodName] in this class with respect to the given [library], or
+   * null if the look up fails. The behavior of this method is defined by the
+   * Dart Language Specification in section 16.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is:  If <i>C</i> declares an instance method named
+   * <i>m</i> that is accessible to <i>L</i>, then that method is the result of
+   * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the
+   * result of the lookup is the result of looking up method <i>m</i> in
+   * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has
+   * failed.
* </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in this class with respect to the given
-   *         library
*/
MethodElement lookUpMethod(String methodName, LibraryElement library);

/**
-   * Return the element representing the setter that results from looking up the given setter in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.16:
-   * <blockquote> The result of looking up getter (respectively setter) <i>m</i> in class <i>C</i>
-   * with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * Return the element representing the setter that results from looking up the
+   * given [setterName] in this class with respect to the given [library], or
+   * null if the look up fails. The behavior of this method is defined by the
+   * Dart Language Specification in section 16.15.2:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
+   * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an
+   * instance getter (respectively setter) named <i>m</i> that is accessible to
+   * <i>L</i>, then that getter (respectively setter) is the result of the
+   * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result
+   * of the lookup is the result of looking up getter (respectively setter)
+   * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the
+   * lookup has failed.
* </blockquote>
-   *
-   * @param setterName the name of the setter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given setter in this class with respect to the given
-   *         library
*/
PropertyAccessorElement lookUpSetter(
String setterName, LibraryElement library);
}

/**
- * Instances of the class ClassElementImpl implement a ClassElement.
+ * A concrete implementation of a [ClassElement].
*/
class ClassElementImpl extends ElementImpl implements ClassElement {
/**
@@ -516,39 +462,41 @@
static const List<ClassElement> EMPTY_ARRAY = const <ClassElement>[];

/**
-   * An array containing all of the accessors (getters and setters) contained in this class.
+   * A list containing all of the accessors (getters and setters) contained in
+   * this class.
*/
List<PropertyAccessorElement> _accessors =
PropertyAccessorElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the constructors contained in this class.
+   * A list containing all of the constructors contained in this class.
*/
List<ConstructorElement> _constructors = ConstructorElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the fields contained in this class.
+   * A list containing all of the fields contained in this class.
*/
List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the mixins that are applied to the class being extended in order to
-   * derive the superclass of this class.
+   * A list containing all of the mixins that are applied to the class being
+   * extended in order to derive the superclass of this class.
*/
List<InterfaceType> mixins = InterfaceType.EMPTY_ARRAY;

/**
-   * An array containing all of the interfaces that are implemented by this class.
+   * A list containing all of the interfaces that are implemented by this class.
*/
List<InterfaceType> interfaces = InterfaceType.EMPTY_ARRAY;

/**
-   * An array containing all of the methods contained in this class.
+   * A list containing all of the methods contained in this class.
*/
List<MethodElement> _methods = MethodElementImpl.EMPTY_ARRAY;

/**
-   * The superclass of the class, or null if the class does not have an explicit superclass.
+   * The superclass of the class, or null if the class does not have an
+   * explicit superclass.
*/
InterfaceType supertype;

@@ -558,31 +506,29 @@
InterfaceType type;

/**
-   * An array containing all of the type parameters defined for this class.
+   * A list containing all of the type parameters defined for this class.
*/
List<TypeParameterElement> _typeParameters =
TypeParameterElementImpl.EMPTY_ARRAY;

/**
-   * Initialize a newly created class element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * The [SourceRange] of the with clause, null if there is no one.
*/
-  ClassElementImpl(String name, int nameOffset) : super(name, nameOffset);
+  SourceRange withClauseRange;

/**
-   * Initialize a newly created class element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created class element to have the given [name] at the
+   * given [offset] in the file that contains the declaration of this element.
+   */
+  ClassElementImpl(String name, int offset) : super(name, offset);
+
+  /**
+   * Initialize a newly created class element to have the given [name].
*/
ClassElementImpl.forNode(Identifier name) : super.forNode(name);

/**
-   * Set whether this class is abstract to correspond to the given value.
-   *
-   * @param isAbstract true if the class is abstract
+   * Set whether this class is abstract.
*/
void set abstract(bool isAbstract) {
setModifier(Modifier.ABSTRACT, isAbstract);
@@ -592,9 +538,7 @@
List<PropertyAccessorElement> get accessors => _accessors;

/**
-   * Set the accessors contained in this class to the given accessors.
-   *
-   * @param accessors the accessors contained in this class
+   * Set the accessors contained in this class to the given [accessors].
*/
void set accessors(List<PropertyAccessorElement> accessors) {
for (PropertyAccessorElement accessor in accessors) {
@@ -614,9 +558,7 @@
List<ConstructorElement> get constructors => _constructors;

/**
-   * Set the constructors contained in this class to the given constructors.
-   *
-   * @param constructors the constructors contained in this class
+   * Set the constructors contained in this class to the given [constructors].
*/
void set constructors(List<ConstructorElement> constructors) {
for (ConstructorElement constructor in constructors) {
@@ -626,9 +568,7 @@
}

/**
-   * Set whether this class is defined by an enum declaration to correspond to the given value.
-   *
-   * @param isEnum true if the class is defined by an enum declaration
+   * Set whether this class is defined by an enum declaration.
*/
void set enum2(bool isEnum) {
setModifier(Modifier.ENUM, isEnum);
@@ -638,9 +578,7 @@
List<FieldElement> get fields => _fields;

/**
-   * Set the fields contained in this class to the given fields.
-   *
-   * @param fields the fields contained in this class
+   * Set the fields contained in this class to the given [fields].
*/
void set fields(List<FieldElement> fields) {
for (FieldElement field in fields) {
@@ -689,9 +627,7 @@
bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER);

/**
-   * Set whether this class references 'super' to the given value.
-   *
-   * @param isReferencedSuper true references 'super'
+   * Set whether this class references 'super'.
*/
void set hasReferenceToSuper(bool isReferencedSuper) {
setModifier(Modifier.REFERENCES_SUPER, isReferencedSuper);
@@ -745,9 +681,7 @@
List<MethodElement> get methods => _methods;

/**
-   * Set the methods contained in this class to the given methods.
-   *
-   * @param methods the methods contained in this class
+   * Set the methods contained in this class to the given [methods].
*/
void set methods(List<MethodElement> methods) {
for (MethodElement method in methods) {
@@ -767,13 +701,17 @@
}

@override
-  ClassDeclaration get node =>
-      getNodeMatching((node) => node is ClassDeclaration);
+  AstNode get node {
+    if (isEnum) {
+      return getNodeMatching((node) => node is EnumDeclaration);
+    } else {
+      return getNodeMatching(
+          (node) => node is ClassDeclaration || node is ClassTypeAlias);
+    }
+  }

/**
-   * Set whether this class is defined by a typedef construct to correspond to the given value.
-   *
-   * @param isTypedef true if the class is defined by a typedef construct
+   * Set whether this class is defined by a typedef construct.
*/
void set typedef(bool isTypedef) {
setModifier(Modifier.TYPEDEF, isTypedef);
@@ -783,9 +721,8 @@
List<TypeParameterElement> get typeParameters => _typeParameters;

/**
-   * Set the type parameters defined for this class to the given type parameters.
-   *
-   * @param typeParameters the type parameters defined for this class
+   * Set the type parameters defined for this class to the given
+   * [typeParameters].
*/
void set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement typeParameter in typeParameters) {
@@ -806,9 +743,7 @@
}

/**
-   * Set whether this class is a valid mixin to correspond to the given value.
-   *
-   * @param isValidMixin true if this class can be used as a mixin
+   * Set whether this class is a valid mixin.
*/
void set validMixin(bool isValidMixin) {
setModifier(Modifier.MIXIN, isValidMixin);
@@ -1198,125 +1133,101 @@
}

/**
- * The interface ClassMemberElement defines the behavior of elements that are contained
- * within a [ClassElement].
+ * An element that is contained within a [ClassElement].
*/
abstract class ClassMemberElement implements Element {
/**
* Return the type in which this member is defined.
-   *
-   * @return the type in which this member is defined
*/
@override
ClassElement get enclosingElement;

/**
-   * Return true if this element is a static element. A static element is an element that is
-   * not associated with a particular instance, but rather with an entire library or class.
-   *
-   * @return true if this executable element is a static element
+   * Return true if this element is a static element. A static element is an
+   * element that is not associated with a particular instance, but rather with
+   * an entire library or class.
*/
bool get isStatic;
}

/**
- * The interface CompilationUnitElement defines the behavior of elements representing a
- * compilation unit.
+ * An element representing a compilation unit.
*/
abstract class CompilationUnitElement implements Element, UriReferencedElement {
/**
-   * Return an array containing all of the top-level accessors (getters and setters) contained in
-   * this compilation unit.
-   *
-   * @return the top-level accessors contained in this compilation unit
+   * Return a list containing all of the top-level accessors (getters and
+   * setters) contained in this compilation unit.
*/
List<PropertyAccessorElement> get accessors;

/**
* Return the library in which this compilation unit is defined.
-   *
-   * @return the library in which this compilation unit is defined
*/
@override
LibraryElement get enclosingElement;

/**
-   * Return an array containing all of the enums contained in this compilation unit.
-   *
-   * @return an array containing all of the enums contained in this compilation unit
+   * Return a list containing all of the enums contained in this compilation
+   * unit.
*/
List<ClassElement> get enums;

/**
-   * Return an array containing all of the top-level functions contained in this compilation unit.
-   *
-   * @return the top-level functions contained in this compilation unit
+   * Return a list containing all of the top-level functions contained in this
+   * compilation unit.
*/
List<FunctionElement> get functions;

/**
-   * Return an array containing all of the function type aliases contained in this compilation unit.
-   *
-   * @return the function type aliases contained in this compilation unit
+   * Return a list containing all of the function type aliases contained in this
+   * compilation unit.
*/
List<FunctionTypeAliasElement> get functionTypeAliases;

/**
* Return true if this compilation unit defines a top-level function named
* loadLibrary.
-   *
-   * @return true if this compilation unit defines a top-level function named
-   *         loadLibrary
*/

/**
* Return the resolved [CompilationUnit] node that declares this element.
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
-   *
-   * @return the resolved [CompilationUnit], not null.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*/
@override
CompilationUnit get node;

/**
-   * Return an array containing all of the top-level variables contained in this compilation unit.
-   *
-   * @return the top-level variables contained in this compilation unit
+   * Return a list containing all of the top-level variables contained in this
+   * compilation unit.
*/
List<TopLevelVariableElement> get topLevelVariables;

/**
-   * Return an array containing all of the classes contained in this compilation unit.
-   *
-   * @return the classes contained in this compilation unit
+   * Return a list containing all of the classes contained in this compilation
+   * unit.
*/
List<ClassElement> get types;

/**
-   * Return the enum defined in this compilation unit that has the given name, or null if
-   * this compilation unit does not define an enum with the given name.
-   *
-   * @param enumName the name of the enum to be returned
-   * @return the enum with the given name that is defined in this compilation unit
+   * Return the enum defined in this compilation unit that has the given [name],
+   * or null if this compilation unit does not define an enum with the given
+   * name.
*/
-  ClassElement getEnum(String enumName);
+  ClassElement getEnum(String name);

/**
-   * Return the class defined in this compilation unit that has the given name, or null if
-   * this compilation unit does not define a class with the given name.
-   *
-   * @param className the name of the class to be returned
-   * @return the class with the given name that is defined in this compilation unit
+   * Return the class defined in this compilation unit that has the given
+   * [name], or null if this compilation unit does not define a class with the
+   * given name.
*/
-  ClassElement getType(String className);
+  ClassElement getType(String name);
}

/**
- * Instances of the class CompilationUnitElementImpl implement a
- * [CompilationUnitElement].
+ * A concrete implementation of a [CompilationUnitElement].
*/
class CompilationUnitElementImpl extends UriReferencedElementImpl
implements CompilationUnitElement {
@@ -1332,43 +1243,44 @@
Source source;

/**
-   * An array containing all of the top-level accessors (getters and setters) contained in this
-   * compilation unit.
+   * A list containing all of the top-level accessors (getters and setters)
+   * contained in this compilation unit.
*/
List<PropertyAccessorElement> _accessors =
PropertyAccessorElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the enums contained in this compilation unit.
+   * A list containing all of the enums contained in this compilation unit.
*/
List<ClassElement> _enums = ClassElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the top-level functions contained in this compilation unit.
+   * A list containing all of the top-level functions contained in this
+   * compilation unit.
*/
List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the function type aliases contained in this compilation unit.
+   * A list containing all of the function type aliases contained in this
+   * compilation unit.
*/
List<FunctionTypeAliasElement> _typeAliases =
FunctionTypeAliasElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the types contained in this compilation unit.
+   * A list containing all of the types contained in this compilation unit.
*/
List<ClassElement> _types = ClassElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the variables contained in this compilation unit.
+   * A list containing all of the variables contained in this compilation unit.
*/
List<TopLevelVariableElement> _variables =
TopLevelVariableElementImpl.EMPTY_ARRAY;

/**
-   * Initialize a newly created compilation unit element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created compilation unit element to have the given
+   * [name].
*/
CompilationUnitElementImpl(String name) : super(name, -1);

@@ -1376,10 +1288,8 @@
List<PropertyAccessorElement> get accessors => _accessors;

/**
-   * Set the top-level accessors (getters and setters) contained in this compilation unit to the
-   * given accessors.
-   *
-   * @param the top-level accessors (getters and setters) contained in this compilation unit
+   * Set the top-level accessors (getters and setters) contained in this
+   * compilation unit to the given [accessors].
*/
void set accessors(List<PropertyAccessorElement> accessors) {
for (PropertyAccessorElement accessor in accessors) {
@@ -1396,9 +1306,7 @@
List<ClassElement> get enums => _enums;

/**
-   * Set the enums contained in this compilation unit to the given enums.
-   *
-   * @param enums enums contained in this compilation unit
+   * Set the enums contained in this compilation unit to the given [enums].
*/
void set enums(List<ClassElement> enums) {
for (ClassElement enumDeclaration in enums) {
@@ -1411,9 +1319,8 @@
List<FunctionElement> get functions => _functions;

/**
-   * Set the top-level functions contained in this compilation unit to the given functions.
-   *
-   * @param functions the top-level functions contained in this compilation unit
+   * Set the top-level functions contained in this compilation unit to the given
+   * [functions].
*/
void set functions(List<FunctionElement> functions) {
for (FunctionElement function in functions) {
@@ -1451,9 +1358,8 @@
List<TopLevelVariableElement> get topLevelVariables => _variables;

/**
-   * Set the top-level variables contained in this compilation unit to the given variables.
-   *
-   * @param variables the top-level variables contained in this compilation unit
+   * Set the top-level variables contained in this compilation unit to the given
+   * [variables].
*/
void set topLevelVariables(List<TopLevelVariableElement> variables) {
for (TopLevelVariableElement field in variables) {
@@ -1463,9 +1369,8 @@
}

/**
-   * Set the function type aliases contained in this compilation unit to the given type aliases.
-   *
-   * @param typeAliases the function type aliases contained in this compilation unit
+   * Set the function type aliases contained in this compilation unit to the
+   * given [typeAliases].
*/
void set typeAliases(List<FunctionTypeAliasElement> typeAliases) {
for (FunctionTypeAliasElement typeAlias in typeAliases) {
@@ -1478,9 +1383,7 @@
List<ClassElement> get types => _types;

/**
-   * Set the types contained in this compilation unit to the given types.
-   *
-   * @param types types contained in this compilation unit
+   * Set the types contained in this compilation unit to the given [types].
*/
void set types(List<ClassElement> types) {
for (ClassElement type in types) {
@@ -1566,6 +1469,15 @@
return null;
}

+  /**
+   * Replace the given [from] top-level variable with [to] in this compilation unit.
+   */
+  void replaceTopLevelVariable(
+      TopLevelVariableElement from, TopLevelVariableElement to) {
+    int index = _variables.indexOf(from);
+    _variables[index] = to;
+  }
+
@override
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);
@@ -1579,8 +1491,7 @@
}

/**
- * Instances of the class ConstFieldElementImpl implement a FieldElement for a
- * 'const' field that has an initializer.
+ * A [FieldElement] for a 'const' field that has an initializer.
*/
class ConstFieldElementImpl extends FieldElementImpl {
/**
@@ -1589,18 +1500,13 @@
EvaluationResultImpl _result;

/**
-   * Initialize a newly created field element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created field element to have the given [name].
*/
ConstFieldElementImpl.con1(Identifier name) : super.forNode(name);

/**
-   * Initialize a newly created synthetic field element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created synthetic field element to have the given
+   * [name] and [offset].
*/
ConstFieldElementImpl.con2(String name, int offset) : super(name, offset);

@@ -1614,8 +1520,8 @@
}

/**
- * Instances of the class ConstLocalVariableElementImpl implement a
- * LocalVariableElement for a local 'const' variable that has an initializer.
+ * A [LocalVariableElement] for a local 'const' variable that has an
+ * initializer.
*/
class ConstLocalVariableElementImpl extends LocalVariableElementImpl {
/**
@@ -1624,9 +1530,7 @@
EvaluationResultImpl _result;

/**
-   * Initialize a newly created local variable element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created local variable element to have the given [name].
*/
ConstLocalVariableElementImpl(Identifier name) : super.forNode(name);

@@ -1640,30 +1544,24 @@
}

/**
- * The interface ConstructorElement defines the behavior of elements representing a
- * constructor or a factory method defined within a type.
+ * An element representing a constructor or a factory method defined within a
+ * class.
*/
abstract class ConstructorElement
implements ClassMemberElement, ExecutableElement {
/**
* Return true if this constructor is a const constructor.
-   *
-   * @return true if this constructor is a const constructor
*/
bool get isConst;

/**
-   * Return true if this constructor can be used as a default constructor - unnamed and has
-   * no required parameters.
-   *
-   * @return true if this constructor can be used as a default constructor.
+   * Return true if this constructor can be used as a default constructor -
+   * unnamed and has no required parameters.
*/
bool get isDefaultConstructor;

/**
* Return true if this constructor represents a factory constructor.
-   *
-   * @return true if this constructor represents a factory constructor
*/
bool get isFactory;

@@ -1677,10 +1575,8 @@
* Return the resolved [ConstructorDeclaration] node that declares this
* [ConstructorElement] .
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
-   *
-   * @return the resolved [ConstructorDeclaration], not null.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*/
@override
ConstructorDeclaration get node;
@@ -1692,17 +1588,15 @@
int get periodOffset;

/**
-   * Return the constructor to which this constructor is redirecting, or null if this
-   * constructor does not redirect to another constructor or if the library containing this
-   * constructor has not yet been resolved.
-   *
-   * @return the constructor to which this constructor is redirecting
+   * Return the constructor to which this constructor is redirecting, or null
+   * if this constructor does not redirect to another constructor or if the
+   * library containing this constructor has not yet been resolved.
*/
ConstructorElement get redirectedConstructor;
}

/**
- * Instances of the class ConstructorElementImpl implement a ConstructorElement.
+ * A concrete implementation of a [ConstructorElement].
*/
class ConstructorElementImpl extends ExecutableElementImpl
implements ConstructorElement {
@@ -1718,8 +1612,8 @@
ConstructorElement redirectedConstructor;

/**
-   * The initializers for this constructor (used for evaluating constant instance creation
-   * expressions).
+   * The initializers for this constructor (used for evaluating constant
+   * instance creation expressions).
*/
List<ConstructorInitializer> constantInitializers;

@@ -1735,25 +1629,18 @@
int nameEnd;

/**
-   * Initialize a newly created constructor element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created constructor element to have the given [name] and
+   * [offset].
*/
-  ConstructorElementImpl(String name, int nameOffset) : super(name, nameOffset);
+  ConstructorElementImpl(String name, int offset) : super(name, offset);

/**
-   * Initialize a newly created constructor element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created constructor element to have the given [name].
*/
ConstructorElementImpl.forNode(Identifier name) : super.forNode(name);

/**
-   * Set whether this constructor represents a 'const' constructor to the given value.
-   *
-   * @param isConst true if this constructor represents a 'const' constructor
+   * Set whether this constructor represents a 'const' constructor.
*/
void set const2(bool isConst) {
setModifier(Modifier.CONST, isConst);
@@ -1763,9 +1650,7 @@
ClassElement get enclosingElement => super.enclosingElement as ClassElement;

/**
-   * Set whether this constructor represents a factory method to the given value.
-   *
-   * @param isFactory true if this constructor represents a factory method
+   * Set whether this constructor represents a factory method.
*/
void set factory(bool isFactory) {
setModifier(Modifier.FACTORY, isFactory);
@@ -1833,15 +1718,13 @@
}

/**
- * Instances of the class ConstructorMember represent a constructor element defined in a
- * parameterized type where the values of the type parameters are known.
+ * A constructor element defined in a parameterized type where the values of the
+ * type parameters are known.
*/
class ConstructorMember extends ExecutableMember implements ConstructorElement {
/**
-   * Initialize a newly created element to represent a constructor of the given parameterized type.
-   *
-   * @param baseElement the element on which the parameterized element was created
-   * @param definingType the type in which the element is defined
+   * Initialize a newly created element to represent a constructor, based on the
+   * [baseElement], defined by the [definingType].
*/
ConstructorMember(ConstructorElement baseElement, InterfaceType definingType)
: super(baseElement, definingType);
@@ -1909,43 +1792,39 @@
}

/**
-   * If the given constructor's type is different when any type parameters from the defining type's
-   * declaration are replaced with the actual type arguments from the defining type, create a
-   * constructor member representing the given constructor. Return the member that was created, or
-   * the base constructor if no member was created.
-   *
-   * @param baseConstructor the base constructor for which a member might be created
-   * @param definingType the type defining the parameters and arguments to be used in the
-   *          substitution
-   * @return the constructor element that will return the correctly substituted types
+   * If the given [constructor]'s type is different when any type parameters
+   * from the defining type's declaration are replaced with the actual type
+   * arguments from the [definingType], create a constructor member representing
+   * the given constructor. Return the member that was created, or the original
+   * constructor if no member was created.
*/
static ConstructorElement from(
-      ConstructorElement baseConstructor, InterfaceType definingType) {
-    if (baseConstructor == null || definingType.typeArguments.length == 0) {
-      return baseConstructor;
+      ConstructorElement constructor, InterfaceType definingType) {
+    if (constructor == null || definingType.typeArguments.length == 0) {
+      return constructor;
}
-    FunctionType baseType = baseConstructor.type;
+    FunctionType baseType = constructor.type;
if (baseType == null) {
// TODO(brianwilkerson) We need to understand when this can happen.
-      return baseConstructor;
+      return constructor;
}
List<DartType> argumentTypes = definingType.typeArguments;
List<DartType> parameterTypes = definingType.element.type.typeArguments;
FunctionType substitutedType =
baseType.substitute2(argumentTypes, parameterTypes);
if (baseType == substitutedType) {
-      return baseConstructor;
+      return constructor;
}
// TODO(brianwilkerson) Consider caching the substituted type in the
// instance. It would use more memory but speed up some operations.
// We need to see how often the type is being re-computed.
-    return new ConstructorMember(baseConstructor, definingType);
+    return new ConstructorMember(constructor, definingType);
}
}

/**
- * Instances of the class ConstTopLevelVariableElementImpl implement a
- * TopLevelVariableElement for a top-level 'const' variable that has an initializer.
+ * A [TopLevelVariableElement] for a top-level 'const' variable that has an
+ * initializer.
*/
class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl {
/**
@@ -1954,9 +1833,8 @@
EvaluationResultImpl _result;

/**
-   * Initialize a newly created top-level variable element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created top-level variable element to have the given
+   * [name].
*/
ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name);

@@ -1970,8 +1848,7 @@
}

/**
- * The interface DartType defines the behavior of objects representing the
- * declared type of elements in the element model.
+ * The type associated with elements in the element model.
*/
abstract class DartType {
/**
@@ -2077,8 +1954,7 @@
}

/**
- * Instances of the class DefaultFieldFormalParameterElementImpl implement a
- * FieldFormalParameterElementImpl for parameters that have an initializer.
+ * A [FieldFormalParameterElementImpl] for parameters that have an initializer.
*/
class DefaultFieldFormalParameterElementImpl
extends FieldFormalParameterElementImpl {
@@ -2088,9 +1964,7 @@
EvaluationResultImpl _result;

/**
-   * Initialize a newly created parameter element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created parameter element to have the given [name].
*/
DefaultFieldFormalParameterElementImpl(Identifier name) : super(name);

@@ -2104,8 +1978,7 @@
}

/**
- * Instances of the class DefaultParameterElementImpl implement a ParameterElement
- * for parameters that have an initializer.
+ * A [ParameterElement] for parameters that have an initializer.
*/
class DefaultParameterElementImpl extends ParameterElementImpl {
/**
@@ -2114,9 +1987,7 @@
EvaluationResultImpl _result;

/**
-   * Initialize a newly created parameter element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created parameter element to have the given [name].
*/
DefaultParameterElementImpl(Identifier name) : super.forNode(name);

@@ -2130,14 +2001,11 @@
}

/**
- * Instances of the class DynamicElementImpl represent the synthetic element representing
- * the declaration of the type dynamic.
+ * The synthetic element representing the declaration of the type dynamic.
*/
class DynamicElementImpl extends ElementImpl {
/**
* Return the unique instance of this class.
-   *
-   * @return the unique instance of this class
*/
static DynamicElementImpl get instance =>
DynamicTypeImpl.instance.element as DynamicElementImpl;
@@ -2148,9 +2016,10 @@
DynamicTypeImpl type;

/**
-   * Initialize a newly created instance of this class. Instances of this class should <b>not</b> be
-   * created except as part of creating the type associated with this element. The single instance
-   * of this class should be accessed through the method [getInstance].
+   * Initialize a newly created instance of this class. Instances of this class
+   * should <b>not</b> be created except as part of creating the type associated
+   * with this element. The single instance of this class should be accessed
+   * through the method [getInstance].
*/
DynamicElementImpl() : super(Keyword.DYNAMIC.syntax, -1) {
setModifier(Modifier.SYNTHETIC, true);
@@ -2164,7 +2033,7 @@
}

/**
- * The unique instance of the class DynamicTypeImpl implements the type dynamic.
+ * The [Type] representing the type dynamic.
*/
class DynamicTypeImpl extends TypeImpl {
/**
@@ -2174,8 +2043,6 @@

/**
* Return the unique instance of this class.
-   *
-   * @return the unique instance of this class
*/
static DynamicTypeImpl get instance => _INSTANCE;

@@ -2235,32 +2102,37 @@
}

/**
- * The interface Element defines the behavior common to all of the elements in the element
- * model. Generally speaking, the element model is a semantic model of the program that represents
- * things that are declared with a name and hence can be referenced elsewhere in the code.
+ * The base class for all of the elements in the element model. Generally
+ * speaking, the element model is a semantic model of the program that
+ * represents things that are declared with a name and hence can be referenced
+ * elsewhere in the code.
*
- * There are two exceptions to the general case. First, there are elements in the element model that
- * are created for the convenience of various kinds of analysis but that do not have any
- * corresponding declaration within the source code. Such elements are marked as being
- * <i>synthetic</i>. Examples of synthetic elements include
- * * default constructors in classes that do not define any explicit constructors,
+ * There are two exceptions to the general case. First, there are elements in
+ * the element model that are created for the convenience of various kinds of
+ * analysis but that do not have any corresponding declaration within the source
+ * code. Such elements are marked as being <i>synthetic</i>. Examples of
+ * synthetic elements include
+ * * default constructors in classes that do not define any explicit
+ *   constructors,
* * getters and setters that are induced by explicit field declarations,
- * * fields that are induced by explicit declarations of getters and setters, and
+ * * fields that are induced by explicit declarations of getters and setters,
+ *   and
* * functions representing the initialization expression for a variable.
*
- * Second, there are elements in the element model that do not have a name. These correspond to
- * unnamed functions and exist in order to more accurately represent the semantic structure of the
- * program.
+ * Second, there are elements in the element model that do not have a name.
+ * These correspond to unnamed functions and exist in order to more accurately
+ * represent the semantic structure of the program.
*/
-abstract class Element {
+abstract class Element implements AnalysisTarget {
/**
* An Unicode right arrow.
*/
static final String RIGHT_ARROW = " \u2192 ";

/**
-   * A comparator that can be used to sort elements by their name offset. Elements with a smaller
-   * offset will be sorted to be before elements with a larger name offset.
+   * A comparator that can be used to sort elements by their name offset.
+   * Elements with a smaller offset will be sorted to be before elements with a
+   * larger name offset.
*/
static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement,
Element secondElement) =>
@@ -2268,27 +2140,23 @@

/**
* Return the analysis context in which this element is defined.
-   *
-   * @return the analysis context in which this element is defined
*/
AnalysisContext get context;

/**
-   * Return the display name of this element, or null if this element does not have a name.
+   * Return the display name of this element, or null if this element does not
+   * have a name.
*
-   * In most cases the name and the display name are the same. Differences though are cases such as
-   * setters where the name of some setter set f(x) is f=, instead of f.
-   *
-   * @return the display name of this element
+   * In most cases the name and the display name are the same. Differences
+   * though are cases such as setters where the name of some setter set f(x)
+   * is f=, instead of f.
*/
String get displayName;

/**
-   * Return the element that either physically or logically encloses this element. This will be
-   * null if this element is a library because libraries are the top-level elements in the
-   * model.
-   *
-   * @return the element that encloses this element
+   * Return the element that either physically or logically encloses this
+   * element. This will be null if this element is a library because libraries
+   * are the top-level elements in the model.
*/
Element get enclosingElement;

@@ -2298,224 +2166,184 @@
int get id;

/**
-   * Return true if this element has an annotation of the form '@deprecated' or
-   * '@Deprecated('..')'.
-   *
-   * @return true if this element is deprecated
+   * Return true if this element has an annotation of the form '@deprecated'
+   * or '@Deprecated('..')'.
*/
bool get isDeprecated;

/**
* Return true if this element has an annotation of the form '@override'.
-   *
-   * @return true if this element is overridden
*/
bool get isOverride;

/**
-   * Return true if this element is private. Private elements are visible only within the
-   * library in which they are declared.
-   *
-   * @return true if this element is private
+   * Return true if this element is private. Private elements are visible only
+   * within the library in which they are declared.
*/
bool get isPrivate;

/**
-   * Return true if this element is public. Public elements are visible within any library
-   * that imports the library in which they are declared.
-   *
-   * @return true if this element is public
+   * Return true if this element is public. Public elements are visible within
+   * any library that imports the library in which they are declared.
*/
bool get isPublic;

/**
-   * Return true if this element is synthetic. A synthetic element is an element that is not
-   * represented in the source code explicitly, but is implied by the source code, such as the
-   * default constructor for a class that does not explicitly define any constructors.
-   *
-   * @return true if this element is synthetic
+   * Return true if this element is synthetic. A synthetic element is an
+   * element that is not represented in the source code explicitly, but is
+   * implied by the source code, such as the default constructor for a class
+   * that does not explicitly define any constructors.
*/
bool get isSynthetic;

/**
* Return the kind of element that this is.
-   *
-   * @return the kind of this element
*/
ElementKind get kind;

/**
-   * Return the library that contains this element. This will be the element itself if it is a
-   * library element. This will be null if this element is an HTML file because HTML files
-   * are not contained in libraries.
-   *
-   * @return the library that contains this element
+   * Return the library that contains this element. This will be the element
+   * itself if it is a library element. This will be null if this element is
+   * an HTML file because HTML files are not contained in libraries.
*/
LibraryElement get library;

/**
-   * Return an object representing the location of this element in the element model. The object can
-   * be used to locate this element at a later time.
-   *
-   * @return the location of this element in the element model
+   * Return an object representing the location of this element in the element
+   * model. The object can be used to locate this element at a later time.
*/
ElementLocation get location;

/**
-   * Return an array containing all of the metadata associated with this element. The array will be
-   * empty if the element does not have any metadata or if the library containing this element has
-   * not yet been resolved.
-   *
-   * @return the metadata associated with this element
+   * Return a list containing all of the metadata associated with this element.
+   * The array will be empty if the element does not have any metadata or if the
+   * library containing this element has not yet been resolved.
*/

/**
-   * Return the name of this element, or null if this element does not have a name.
-   *
-   * @return the name of this element
+   * Return the name of this element, or null if this element does not have a
+   * name.
*/
String get name;

/**
-   * Return the offset of the name of this element in the file that contains the declaration of this
-   * element, or -1 if this element is synthetic, does not have a name, or otherwise does
-   * not have an offset.
-   *
-   * @return the offset of the name of this element
+   * Return the offset of the name of this element in the file that contains the
+   * declaration of this element, or -1 if this element is synthetic, does not
+   * have a name, or otherwise does not have an offset.
*/
int get nameOffset;

/**
-   * Return the resolved [AstNode] node that declares this [Element].
+   * Return the resolved [AstNode] node that declares this element, or null if
+   * this element is synthetic or isn't contained in a compilation unit, such as
+   * a [LibraryElement].
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*
* <b>Note:</b> This method cannot be used in an async environment.
-   *
-   * @return the resolved [AstNode], maybe null if [Element] is synthetic or
-   *         isn't contained in a compilation unit, such as a [LibraryElement].
*/
AstNode get node;

/**
-   * Return the source that contains this element, or null if this element is not contained
-   * in a source.
-   *
-   * @return the source that contains this element
+   * Return the source that contains this element, or null if this element is
+   * not contained in a source.
*/
Source get source;

/**
-   * Return the resolved [CompilationUnit] that declares this [Element].
+   * Return the resolved [CompilationUnit] that declares this element, or null
+   * if this element is synthetic.
*
-   * This method is expensive, because resolved AST might have been already evicted from cache, so
-   * parsing and resolving will be performed.
-   *
-   * @return the resolved [CompilationUnit], maybe null if synthetic [Element].
+   * This method is expensive, because resolved AST might have been already
+   * evicted from cache, so parsing and resolving will be performed.
*/
CompilationUnit get unit;

/**
-   * Use the given visitor to visit this element.
-   *
-   * @param visitor the visitor that will visit this element
-   * @return the value returned by the visitor as a result of visiting this element
+   * Use the given [visitor] to visit this element. Return the value returned by
+   * the visitor as a result of visiting this element.
*/
accept(ElementVisitor visitor);

/**
-   * Return the documentation comment for this element as it appears in the original source
-   * (complete with the beginning and ending delimiters), or null if this element does not
-   * have a documentation comment associated with it. This can be a long-running operation if the
-   * information needed to access the comment is not cached.
+   * Return the documentation comment for this element as it appears in the
+   * original source (complete with the beginning and ending delimiters), or
+   * null if this element does not have a documentation comment associated
+   * with it. This can be a long-running operation if the information needed to
+   * access the comment is not cached.
*
-   * @return this element's documentation comment
-   * @throws AnalysisException if the documentation comment could not be determined because the
-   *           analysis could not be performed
+   * Throws [AnalysisException] if the documentation comment could not be
+   * determined because the analysis could not be performed
*/
String computeDocumentationComment();

/**
-   * Return the element of the given class that most immediately encloses this element, or
-   * null if there is no enclosing element of the given class.
-   *
-   * @param elementClass the class of the element to be returned
-   * @return the element that encloses this element
+   * Return the most immediate ancestor of this element for which the
+   * [predicate] returns true, or null if there is no such ancestor. Note
+   * that this element will never be returned.
*/
Element getAncestor(Predicate<Element> predicate);

/**
-   * Return a display name for the given element that includes the path to the compilation unit in
-   * which the type is defined.
-   *
-   * @param shortName the short display name. If null, [getDisplayName] is used.
-   * @return a display name that can help distinguish between two types with the same name
+   * Return a display name for the given element that includes the path to the
+   * compilation unit in which the type is defined. If [shortName] is null
+   * then [getDisplayName] will be used as the name of this element. Otherwise
+   * the provided name will be used.
*/
+  // TODO(brianwilkerson) Make the parameter optional.
String getExtendedDisplayName(String shortName);

/**
-   * Return true if this element, assuming that it is within scope, is accessible to code in
-   * the given library. This is defined by the Dart Language Specification in section 3.2:
-   * <blockquote> A declaration <i>m</i> is accessible to library <i>L</i> if <i>m</i> is declared
-   * in <i>L</i> or if <i>m</i> is public. </blockquote>
-   *
-   * @param library the library in which a possible reference to this element would occur
-   * @return true if this element is accessible to code in the given library
+   * Return true if this element, assuming that it is within scope, is
+   * accessible to code in the given [library]. This is defined by the Dart
+   * Language Specification in section 3.2:
+   * <blockquote>
+   * A declaration <i>m</i> is accessible to library <i>L</i> if <i>m</i> is
+   * declared in <i>L</i> or if <i>m</i> is public.
+   * </blockquote>
*/
bool isAccessibleIn(LibraryElement library);

/**
-   * Use the given visitor to visit all of the children of this element. There is no guarantee of
-   * the order in which the children will be visited.
-   *
-   * @param visitor the visitor that will be used to visit the children of this element
+   * Use the given [visitor] to visit all of the children of this element. There
+   * is no guarantee of the order in which the children will be visited.
*/
void visitChildren(ElementVisitor visitor);
}

/**
- * The interface ElementAnnotation defines the behavior of objects representing a single
- * annotation associated with an element.
+ * A single annotation associated with an element.
*/
abstract class ElementAnnotation {
/**
-   * Return the element representing the field, variable, or const constructor being used as an
-   * annotation.
-   *
-   * @return the field, variable, or constructor being used as an annotation
+   * Return the element representing the field, variable, or const constructor
+   * being used as an annotation.
*/
Element get element;

/**
-   * Return true if this annotation marks the associated element as being deprecated.
-   *
-   * @return true if this annotation marks the associated element as being deprecated
+   * Return true if this annotation marks the associated element as being
+   * deprecated.
*/
bool get isDeprecated;

/**
-   * Return true if this annotation marks the associated method as being expected to
-   * override an inherited method.
-   *
-   * @return true if this annotation marks the associated method as overriding another
-   *         method
+   * Return true if this annotation marks the associated method as being
+   * expected to override an inherited method.
*/
bool get isOverride;

/**
-   * Return true if this annotation marks the associated class as implementing a proxy
-   * object.
-   *
-   * @return true if this annotation marks the associated class as implementing a proxy
-   *         object
+   * Return true if this annotation marks the associated class as implementing
+   * a proxy object.
*/
bool get isProxy;
}

/**
- * Instances of the class ElementAnnotationImpl implement an [ElementAnnotation].
+ * A concrete implementation of an [ElementAnnotation].
*/
class ElementAnnotationImpl implements ElementAnnotation {
/**
@@ -2530,23 +2358,26 @@
static String _DEPRECATED_CLASS_NAME = "Deprecated";

/**
-   * The name of the top-level variable used to mark an element as being deprecated.
+   * The name of the top-level variable used to mark an element as being
+   * deprecated.
*/
static String _DEPRECATED_VARIABLE_NAME = "deprecated";

/**
-   * The name of the top-level variable used to mark a method as being expected to override an
-   * inherited method.
+   * The name of the top-level variable used to mark a method as being expected
+   * to override an inherited method.
*/
static String _OVERRIDE_VARIABLE_NAME = "override";

/**
-   * The name of the top-level variable used to mark a class as implementing a proxy object.
+   * The name of the top-level variable used to mark a class as implementing a
+   * proxy object.
*/
static String PROXY_VARIABLE_NAME = "proxy";

/**
-   * The element representing the field, variable, or constructor being used as an annotation.
+   * The element representing the field, variable, or constructor being used as
+   * an annotation.
*/
final Element element;

@@ -2558,10 +2389,9 @@
EvaluationResultImpl evaluationResult;

/**
-   * Initialize a newly created annotation.
-   *
-   * @param element the element representing the field, variable, or constructor being used as an
-   *          annotation
+   * Initialize a newly created annotation. The given [element] is the element
+   * representing the field, variable, or constructor being used as an
+   * annotation.
*/
ElementAnnotationImpl(this.element);

@@ -2618,8 +2448,7 @@
}

/**
- * The abstract class ElementImpl implements the behavior common to objects that implement
- * an [Element].
+ * A base class for concrete implementations of an [Element].
*/
abstract class ElementImpl implements Element {
static int _NEXT_ID = 0;
@@ -2627,8 +2456,8 @@
final int id = _NEXT_ID++;

/**
-   * The enclosing element of this element, or null if this element is at the root of the
-   * element structure.
+   * The enclosing element of this element, or null if this element is at the
+   * root of the element structure.
*/
ElementImpl _enclosingElement;

@@ -2649,7 +2478,7 @@
int _modifiers = 0;

/**
-   * An array containing all of the metadata associated with this element.
+   * A list containing all of the metadata associated with this element.
*/

@@ -2664,20 +2493,15 @@
ElementLocation _cachedLocation;

/**
-   * Initialize a newly created element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created element to have the given [name] at the given
+   * [_nameOffset].
*/
ElementImpl(String name, this._nameOffset) {
this._name = StringUtilities.intern(name);
}

/**
-   * Initialize a newly created element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created element to have the given [name].
*/
ElementImpl.forNode(Identifier name)
: this(name == null ? "" : name.name, name == null ? -1 : name.offset);
@@ -2697,9 +2521,7 @@
Element get enclosingElement => _enclosingElement;

/**
-   * Set the enclosing element of this element to the given element.
-   *
-   * @param element the enclosing element of this element
+   * Set the enclosing element of this element to the given [element].
*/
void set enclosingElement(Element element) {
_enclosingElement = element as ElementImpl;
@@ -2724,10 +2546,8 @@
}

/**
-   * Return an identifier that uniquely identifies this element among the children of this element's
-   * parent.
-   *
-   * @return an identifier that uniquely identifies this element relative to its parent
+   * Return an identifier that uniquely identifies this element among the
+   * children of this element's parent.
*/
String get identifier => name;

@@ -2815,9 +2635,7 @@
}

/**
-   * Set whether this element is synthetic to correspond to the given value.
-   *
-   * @param isSynthetic true if the element is synthetic
+   * Set whether this element is synthetic.
*/
void set synthetic(bool isSynthetic) {
setModifier(Modifier.SYNTHETIC, isSynthetic);
@@ -2861,9 +2679,7 @@
}

/**
-   * Set this [Element] as an enclosing for given.
-   *
-   * @param element the element to enclose, must be [ElementImpl]
+   * Set this element as the enclosing element for given [element].
*/
void encloseElement(ElementImpl element) {
element.enclosingElement = this;
@@ -2879,11 +2695,8 @@
}

/**
-   * Return the child of this element that is uniquely identified by the given identifier, or
-   * null if there is no such child.
-   *
-   * @param identifier the identifier used to select a child
-   * @return the child of this element with the given identifier
+   * Return the child of this element that is uniquely identified by the given
+   * [identifier], or null if there is no such child.
*/
ElementImpl getChild(String identifier) => null;

@@ -2916,10 +2729,7 @@
}

/**
-   * Return true if this element has the given modifier associated with it.
-   *
-   * @param modifier the modifier being tested for
-   * @return true if this element has the given modifier associated with it
+   * Return true if this element has the given [modifier] associated with it.
*/
bool hasModifier(Modifier modifier) =>
BooleanArray.getEnum(_modifiers, modifier);
@@ -2933,10 +2743,7 @@
}

/**
-   * If the given child is not null, use the given visitor to visit it.
-   *
-   * @param child the child to be visited
-   * @param visitor the visitor to be used to visit the child
+   * If the given [child] is not null, use the given [visitor] to visit it.
*/
void safelyVisitChild(Element child, ElementVisitor visitor) {
if (child != null) {
@@ -2945,10 +2752,7 @@
}

/**
-   * Use the given visitor to visit all of the children in the given array.
-   *
-   * @param children the children to be visited
-   * @param visitor the visitor being used to visit the children
+   * Use the given [visitor] to visit all of the [children] in the given array.
*/
void safelyVisitChildren(List<Element> children, ElementVisitor visitor) {
if (children != null) {
@@ -2959,11 +2763,8 @@
}

/**
-   * Set whether the given modifier is associated with this element to correspond to the given
-   * value.
-   *
-   * @param modifier the modifier to be set
-   * @param value true if the modifier is to be associated with this element
+   * Set whether the given [modifier] is associated with this element to
+   * correspond to the given [value].
*/
void setModifier(Modifier modifier, bool value) {
_modifiers = BooleanArray.setEnum(_modifiers, modifier, value);
@@ -2983,7 +2784,8 @@
}

/**
- * The enumeration ElementKind defines the various kinds of elements in the element model.
+ * The enumeration ElementKind defines the various kinds of elements in the
+ * element model.
*/
class ElementKind extends Enum<ElementKind> {
static const ElementKind CLASS = const ElementKind('CLASS', 0, "class");
@@ -3086,19 +2888,15 @@
final String displayName;

/**
-   * Initialize a newly created element kind to have the given display name.
-   *
-   * @param displayName the name displayed in the UI for this kind of element
+   * Initialize a newly created element kind to have the given [displayName].
*/
const ElementKind(String name, int ordinal, this.displayName)
: super(name, ordinal);

/**
-   * Return the kind of the given element, or [ERROR] if the element is null. This is
-   * a utility method that can reduce the need for null checks in other places.
-   *
-   * @param element the element whose kind is to be returned
-   * @return the kind of the given element
+   * Return the kind of the given [element], or [ERROR] if the element is
+   * null. This is a utility method that can reduce the need for null checks
+   * in other places.
*/
static ElementKind of(Element element) {
if (element == null) {
@@ -3109,29 +2907,24 @@
}

/**
- * The interface ElementLocation defines the behavior of objects that represent the location
- * of an element within the element model.
+ * The location of an element within the element model.
*/
abstract class ElementLocation {
/**
-   * Return the path to the element whose location is represented by this object. Clients must not
-   * modify the returned array.
-   *
-   * @return the path to the element whose location is represented by this object
+   * Return the path to the element whose location is represented by this
+   * object. Clients must not modify the returned array.
*/
List<String> get components;

/**
-   * Return an encoded representation of this location that can be used to create a location that is
-   * equal to this location.
-   *
-   * @return an encoded representation of this location
+   * Return an encoded representation of this location that can be used to
+   * create a location that is equal to this location.
*/
String get encoding;
}

/**
- * Instances of the class ElementLocationImpl implement an [ElementLocation].
+ * A concrete implementation of an [ElementLocation].
*/
class ElementLocationImpl implements ElementLocation {
/**
@@ -3160,9 +2953,7 @@
int indexLocationId;

/**
-   * Initialize a newly created location to represent the given element.
-   *
-   * @param element the element whose location is being represented
+   * Initialize a newly created location to represent the given [element].
*/
ElementLocationImpl.con1(Element element) {
List<String> components = new List<String>();
@@ -3175,18 +2966,14 @@
}

/**
-   * Initialize a newly created location from the given encoded form.
-   *
-   * @param encoding the encoded form of a location
+   * Initialize a newly created location from the given [encoding].
*/
ElementLocationImpl.con2(String encoding) {
this._components = _decode(encoding);
}

/**
-   * Initialize a newly created location from the given components.
-   *
-   * @param components the components of a location
+   * Initialize a newly created location from the given [components].
*/
ElementLocationImpl.con3(List<String> components) {
this._components = components;
@@ -3244,10 +3031,8 @@
String toString() => encoding;

/**
-   * Decode the encoded form of a location into an array of components.
-   *
-   * @param encoding the encoded form of a location
-   * @return the components that were encoded
+   * Decode the [encoding] of a location into a list of components and return
+   * the components.
*/
List<String> _decode(String encoding) {
List<String> components = new List<String>();
@@ -3276,10 +3061,7 @@
}

/**
-   * Append an encoded form of the given component to the given builder.
-   *
-   * @param builder the builder to which the encoded component is to be appended
-   * @param component the component to be appended to the builder
+   * Append an encoded form of the given [component] to the given [buffer].
*/
void _encode(StringBuffer buffer, String component) {
int length = component.length;
@@ -3294,7 +3076,7 @@
}

/**
- * The class ElementPair is a pair of [Element]s. [Object.==] and
+ * A pair of [Element]s. [Object.==] and
* [Object.hashCode] so this class can be used in hashed data structures.
*/
class ElementPair {
@@ -3314,10 +3096,8 @@
int _cachedHashCode;

/**
-   * The sole constructor for this class, taking two [Element]s.
-   *
-   * @param first the first element
-   * @param second the second element
+   * Initialize a newly created pair of elements consisting of the [_first] and
+   * [_second] elements.
*/
ElementPair(this._first, this._second) {
_cachedHashCode = JenkinsSmiHash.hash2(_first.hashCode, _second.hashCode);
@@ -3325,8 +3105,6 @@

/**
* Return the first element.
-   *
-   * @return the first element
*/
Element get firstElt => _first;

@@ -3337,8 +3115,6 @@

/**
* Return the second element
-   *
-   * @return the second element
*/
Element get secondElt => _second;

@@ -3354,8 +3130,7 @@
}

/**
- * The interface ElementVisitor defines the behavior of objects that can be used to visit an
- * element structure.
+ * An object that can be used to visit an element structure.
*/
abstract class ElementVisitor<R> {
R visitClassElement(ClassElement element);
@@ -3404,21 +3179,17 @@
}

/**
- * The interface EmbeddedHtmlScriptElement defines the behavior of elements representing a
- * script tag in an HTML file having content that defines a Dart library.
+ * A script tag in an HTML file having content that defines a Dart library.
*/
abstract class EmbeddedHtmlScriptElement implements HtmlScriptElement {
/**
* Return the library element defined by the content of the script tag.
-   *
-   * @return the library element (not null)
*/
LibraryElement get scriptLibrary;
}

/**
- * Instances of the class EmbeddedHtmlScriptElementImpl implement an
- * [EmbeddedHtmlScriptElement].
+ * A concrete implementation of an [EmbeddedHtmlScriptElement].
*/
class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl
implements EmbeddedHtmlScriptElement {
@@ -3428,9 +3199,7 @@
LibraryElement _scriptLibrary;

/**
-   * Initialize a newly created script element to have the specified tag name and offset.
-   *
-   * @param node the XML node from which this element is derived (not null)
+   * Initialize a newly created script element to represent the given [node].
*/
EmbeddedHtmlScriptElementImpl(XmlTagNode node) : super(node);

@@ -3441,13 +3210,12 @@
LibraryElement get scriptLibrary => _scriptLibrary;

/**
-   * Set the script library defined by the script tag's content.
-   *
-   * @param scriptLibrary the library or null if none
+   * Set the script library defined by the script tag's content to the given
+   * [library].
*/
-  void set scriptLibrary(LibraryElementImpl scriptLibrary) {
-    scriptLibrary.enclosingElement = this;
-    this._scriptLibrary = scriptLibrary;
+  void set scriptLibrary(LibraryElementImpl library) {
+    library.enclosingElement = this;
+    _scriptLibrary = library;
}

@override
@@ -3461,121 +3229,114 @@
}

/**
- * The interface ExecutableElement defines the behavior of elements representing an
- * executable object, including functions, methods, constructors, getters, and setters.
+ * An element representing an executable object, including functions, methods,
+ * constructors, getters, and setters.
*/
abstract class ExecutableElement implements Element {
/**
-   * Return an array containing all of the functions defined within this executable element.
-   *
-   * @return the functions defined within this executable element
+   * Return a list containing all of the functions defined within this
+   * executable element.
*/
List<FunctionElement> get functions;

/**
-   * Return true if this executable element has body marked as being asynchronous.
-   *
-   * @return true if this executable element has body marked as being asynchronous
+   * Return true if this executable element is abstract.
+   * Executable elements are abstract if they are not external and have no body.
+   */
+  bool get isAbstract;
+
+  /**
+   * Return true if this executable element has body marked as being
+   * asynchronous.
*/
bool get isAsynchronous;

/**
-   * Return true if this executable element has a body marked as being a generator.
-   *
-   * @return true if this executable element has a body marked as being a generator
+   * Return true if this executable element has a body marked as being a
+   * generator.
*/
bool get isGenerator;

/**
-   * Return true if this executable element is an operator. The test may be based on the
-   * name of the executable element, in which case the result will be correct when the name is
-   * legal.
-   *
-   * @return true if this executable element is an operator
+   * Return true if this executable element is an operator. The test may be
+   * based on the name of the executable element, in which case the result will
+   * be correct when the name is legal.
*/
bool get isOperator;

/**
-   * Return true if this element is a static element. A static element is an element that is
-   * not associated with a particular instance, but rather with an entire library or class.
-   *
-   * @return true if this executable element is a static element
+   * Return true if this element is a static element. A static element is an
+   * element that is not associated with a particular instance, but rather with
+   * an entire library or class.
*/
bool get isStatic;

/**
-   * Return true if this executable element has a body marked as being synchronous.
-   *
-   * @return true if this executable element has a body marked as being synchronous
+   * Return true if this executable element has a body marked as being
+   * synchronous.
*/
bool get isSynchronous;

/**
-   * Return an array containing all of the labels defined within this executable element.
-   *
-   * @return the labels defined within this executable element
+   * Return a list containing all of the labels defined within this executable
+   * element.
*/
List<LabelElement> get labels;

/**
-   * Return an array containing all of the local variables defined within this executable element.
-   *
-   * @return the local variables defined within this executable element
+   * Return a list containing all of the local variables defined within this
+   * executable element.
*/
List<LocalVariableElement> get localVariables;

/**
-   * Return an array containing all of the parameters defined by this executable element.
-   *
-   * @return the parameters defined by this executable element
+   * Return a list containing all of the parameters defined by this executable
+   * element.
*/
List<ParameterElement> get parameters;

/**
* Return the return type defined by this executable element.
-   *
-   * @return the return type defined by this executable element
*/
DartType get returnType;

/**
* Return the type of function defined by this executable element.
-   *
-   * @return the type of function defined by this executable element
*/
FunctionType get type;
}

/**
- * The abstract class ExecutableElementImpl implements the behavior common to
- * ExecutableElements.
+ * A base class for concrete implementations of an [ExecutableElement].
*/
abstract class ExecutableElementImpl extends ElementImpl
implements ExecutableElement {
/**
* An empty list of executable elements.
*/
-  static const List<ExecutableElement> EMPTY_ARRAY = const <ExecutableElement>[
-  ];
+  static const List<ExecutableElement> EMPTY_ARRAY =
+      const <ExecutableElement>[];

/**
-   * An array containing all of the functions defined within this executable element.
+   * A list containing all of the functions defined within this executable
+   * element.
*/
List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the labels defined within this executable element.
+   * A list containing all of the labels defined within this executable element.
*/
List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the local variables defined within this executable element.
+   * A list containing all of the local variables defined within this executable
+   * element.
*/
List<LocalVariableElement> _localVariables =
LocalVariableElementImpl.EMPTY_ARRAY;

/**
-   * An array containing all of the parameters defined by this executable element.
+   * A list containing all of the parameters defined by this executable element.
*/
List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY;

@@ -3590,25 +3351,18 @@
FunctionType type;

/**
-   * Initialize a newly created executable element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created executable element to have the given [name] and
+   * [offset].
*/
-  ExecutableElementImpl(String name, int nameOffset) : super(name, nameOffset);
+  ExecutableElementImpl(String name, int offset) : super(name, offset);

/**
-   * Initialize a newly created executable element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created executable element to have the given [name].
*/
ExecutableElementImpl.forNode(Identifier name) : super.forNode(name);

/**
-   * Set whether this method's body is asynchronous to correspond to the given value.
-   *
-   * @param isAsynchronous true if the method's body is asynchronous
+   * Set whether this method's body is asynchronous.
*/
void set asynchronous(bool isAsynchronous) {
setModifier(Modifier.ASYNCHRONOUS, isAsynchronous);
@@ -3618,9 +3372,8 @@
List<FunctionElement> get functions => _functions;

/**
-   * Set the functions defined within this executable element to the given functions.
-   *
-   * @param functions the functions defined within this executable element
+   * Set the functions defined within this executable element to the given
+   * [functions].
*/
void set functions(List<FunctionElement> functions) {
for (FunctionElement function in functions) {
@@ -3630,15 +3383,16 @@
}

/**
-   * Set whether this method's body is a generator to correspond to the given value.
-   *
-   * @param isGenerator true if the method's body is a generator
+   * Set whether this method's body is a generator.
*/
void set generator(bool isGenerator) {
setModifier(Modifier.GENERATOR, isGenerator);
}

@override
+  bool get isAbstract => hasModifier(Modifier.ABSTRACT);
+
+  @override
bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS);

@override
@@ -3654,9 +3408,8 @@
List<LabelElement> get labels => _labels;

/**
-   * Set the labels defined within this executable element to the given labels.
-   *
-   * @param labels the labels defined within this executable element
+   * Set the labels defined within this executable element to the given
+   * [labels].
*/
void set labels(List<LabelElement> labels) {
for (LabelElement label in labels) {
@@ -3669,24 +3422,22 @@
List<LocalVariableElement> get localVariables => _localVariables;

/**
-   * Set the local variables defined within this executable element to the given variables.
-   *
-   * @param localVariables the local variables defined within this executable element
+   * Set the local variables defined within this executable element to the given
+   * [variables].
*/
-  void set localVariables(List<LocalVariableElement> localVariables) {
-    for (LocalVariableElement variable in localVariables) {
+  void set localVariables(List<LocalVariableElement> variables) {
+    for (LocalVariableElement variable in variables) {
(variable as LocalVariableElementImpl).enclosingElement = this;
}
-    this._localVariables = localVariables;
+    this._localVariables = variables;
}

@override
List<ParameterElement> get parameters => _parameters;

/**
-   * Set the parameters defined by this executable element to the given parameters.
-   *
-   * @param parameters the parameters defined by this executable element
+   * Set the parameters defined by this executable element to the given
+   * [parameters].
*/
void set parameters(List<ParameterElement> parameters) {
for (ParameterElement parameter in parameters) {
@@ -3772,17 +3523,13 @@
}

/**
- * The abstract class ExecutableMember defines the behavior common to members that represent
- * an executable element defined in a parameterized type where the values of the type parameters are
- * known.
+ * An executable element defined in a parameterized type where the values of the
+ * type parameters are known.
*/
abstract class ExecutableMember extends Member implements ExecutableElement {
/**
-   * Initialize a newly created element to represent an executable element of the given
-   * parameterized type.
-   *
-   * @param baseElement the element on which the parameterized element was created
-   * @param definingType the type in which the element is defined
+   * Initialize a newly created element to represent a constructor, based on the
+   * [baseElement], defined by the [definingType].
*/
ExecutableMember(ExecutableElement baseElement, InterfaceType definingType)
: super(baseElement, definingType);
@@ -3801,6 +3548,9 @@
}

@override
+  bool get isAbstract => baseElement.isAbstract;
+
+  @override
bool get isAsynchronous => baseElement.isAsynchronous;

@override
@@ -3863,8 +3613,7 @@
}

/**
- * The interface ExportElement defines the behavior of objects representing information
- * about a single export directive within a library.
+ * An export directive within a library.
*/
abstract class ExportElement implements Element, UriReferencedElement {
/**
@@ -3873,23 +3622,20 @@
static const List<ExportElement> EMPTY_ARRAY = const <ExportElement>[];

/**
-   * Return an array containing the combinators that were specified as part of the export directive
-   * in the order in which they were specified.
-   *
-   * @return the combinators specified in the export directive
+   * Return a list containing the combinators that were specified as part of the
+   * export directive in the order in which they were specified.
*/
List<NamespaceCombinator> get combinators;

/**
-   * Return the library that is exported from this library by this export directive.
-   *
-   * @return the library that is exported from this library
+   * Return the library that is exported from this library by this export
+   * directive.
*/
LibraryElement get exportedLibrary;
}

/**
- * Instances of the class ExportElementImpl implement an [ExportElement].
+ * A concrete implementation of an [ExportElement].
*/
class ExportElementImpl extends UriReferencedElementImpl
implements ExportElement {
@@ -3899,15 +3645,15 @@
LibraryElement exportedLibrary;

/**
-   * The combinators that were specified as part of the export directive in the order in which they
-   * were specified.
+   * The combinators that were specified as part of the export directive in the
+   * order in which they were specified.
*/
List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY;

/**
-   * Initialize a newly created export element.
+   * Initialize a newly created export element at the given [offset].
*/
-  ExportElementImpl() : super(null, -1);
+  ExportElementImpl(int offset) : super(null, offset);

@override
String get identifier => exportedLibrary.name;
@@ -3926,23 +3672,19 @@
}

/**
- * The interface ExternalHtmlScriptElement defines the behavior of elements representing a
- * script tag in an HTML file having a source attribute that references a Dart library
- * source file.
+ * A script tag in an HTML file having a source attribute that references a
+ * Dart library source file.
*/
abstract class ExternalHtmlScriptElement implements HtmlScriptElement {
/**
-   * Return the source referenced by this element, or null if this element does not
-   * reference a Dart library source file.
-   *
-   * @return the source for the external Dart library
+   * Return the source referenced by this element, or null if this element
+   * does not reference a Dart library source file.
*/
Source get scriptSource;
}

/**
- * Instances of the class ExternalHtmlScriptElementImpl implement an
- * [ExternalHtmlScriptElement].
+ * A concrete implementation of an [ExternalHtmlScriptElement].
*/
class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl
implements ExternalHtmlScriptElement {
@@ -3952,9 +3694,8 @@
Source scriptSource;

/**
-   * Initialize a newly created script element to have the specified tag name and offset.
-   *
-   * @param node the XML node from which this element is derived (not null)
+   * Initialize a newly created script element to correspond to the given
+   * [node].
*/
ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node);

@@ -3967,21 +3708,28 @@
}

/**
- * The interface FieldElement defines the behavior of elements representing a field defined
- * within a type.
+ * A field defined within a type.
*/
abstract class FieldElement
implements ClassMemberElement, PropertyInducingElement {
/**
* Return {@code true} if this element is an enum constant.
-   *
-   * @return {@code true} if this an enum constant
*/
bool get isEnumConstant;
+
+  /**
+   * Return the resolved [VariableDeclaration] or [EnumConstantDeclaration]
+   * node that declares this [FieldElement].
+   *
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
+   */
+  @override
+  AstNode get node;
}

/**
- * Instances of the class FieldElementImpl implement a FieldElement.
+ * A concrete implementation of a [FieldElement].
*/
class FieldElementImpl extends PropertyInducingElementImpl
implements FieldElement {
@@ -3991,18 +3739,13 @@
static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[];

/**
-   * Initialize a newly created synthetic field element to have the given name.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created synthetic field element to have the given [name]
+   * at the given [offset].
*/
-  FieldElementImpl(String name, int nameOffset) : super(name, nameOffset);
+  FieldElementImpl(String name, int offset) : super(name, offset);

/**
-   * Initialize a newly created field element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created field element to have the given [name].
*/
FieldElementImpl.forNode(Identifier name) : super.forNode(name);

@@ -4019,10 +3762,17 @@
@override
ElementKind get kind => ElementKind.FIELD;

+  @override
+  AstNode get node {
+    if (isEnumConstant) {
+      return getNodeMatching((node) => node is EnumConstantDeclaration);
+    } else {
+      return getNodeMatching((node) => node is VariableDeclaration);
+    }
+  }
+
/**
-   * Set whether this field is static to correspond to the given value.
-   *
-   * @param isStatic true if the field is static
+   * Set whether this field is static.
*/
void set static(bool isStatic) {
setModifier(Modifier.STATIC, isStatic);
@@ -4033,23 +3783,19 @@
}

/**
- * The interface FieldFormalParameterElement defines the behavior of elements representing a
- * field formal parameter defined within a constructor element.
+ * A field formal parameter defined within a constructor element.
*/
abstract class FieldFormalParameterElement implements ParameterElement {
/**
-   * Return the field element associated with this field formal parameter, or null if the
-   * parameter references a field that doesn't exist.
-   *
-   * @return the field element associated with this field formal parameter
+   * Return the field element associated with this field formal parameter, or
+   * null if the parameter references a field that doesn't exist.
*/
FieldElement get field;
}

/**
- * Instances of the class FieldFormalParameterElementImpl extend
- * [ParameterElementImpl] to provide the additional information of the [FieldElement]
- * associated with the parameter.
+ * A [ParameterElementImpl] that has the additional information of the
+ * [FieldElement] associated with the parameter.
*/
class FieldFormalParameterElementImpl extends ParameterElementImpl
implements FieldFormalParameterElement {
@@ -4059,9 +3805,7 @@
FieldElement field;

/**
-   * Initialize a newly created parameter element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created parameter element to have the given [name].
*/
FieldFormalParameterElementImpl(Identifier name) : super.forNode(name);

@@ -4074,16 +3818,14 @@
}

/**
- * Instances of the class FieldFormalParameterMember represent a parameter element defined
- * in a parameterized type where the values of the type parameters are known.
+ * A parameter element defined in a parameterized type where the values of the
+ * type parameters are known.
*/
class FieldFormalParameterMember extends ParameterMember
implements FieldFormalParameterElement {
/**
-   * Initialize a newly created element to represent a parameter of the given parameterized type.
-   *
-   * @param baseElement the element on which the parameterized element was created
-   * @param definingType the type in which the element is defined
+   * Initialize a newly created element to represent a constructor, based on the
+   * [baseElement], defined by the [definingType].
*/
FieldFormalParameterMember(
FieldFormalParameterElement baseElement, ParameterizedType definingType)
@@ -4104,15 +3846,13 @@
}

/**
- * Instances of the class FieldMember represent a field element defined in a parameterized
- * type where the values of the type parameters are known.
+ * A field element defined in a parameterized type where the values of the type
+ * parameters are known.
*/
class FieldMember extends VariableMember implements FieldElement {
/**
-   * Initialize a newly created element to represent a field of the given parameterized type.
-   *
-   * @param baseElement the element on which the parameterized element was created
-   * @param definingType the type in which the element is defined
+   * Initialize a newly created element to represent a constructor, based on the
+   * [baseElement], defined by the [definingType].
*/
FieldMember(FieldElement baseElement, InterfaceType definingType)
: super(baseElement, definingType);
@@ -4150,40 +3890,32 @@
String toString() => '$type$displayName';

/**
-   * If the given field's type is different when any type parameters from the defining type's
-   * declaration are replaced with the actual type arguments from the defining type, create a field
-   * member representing the given field. Return the member that was created, or the base field if
-   * no member was created.
-   *
-   * @param baseField the base field for which a member might be created
-   * @param definingType the type defining the parameters and arguments to be used in the
-   *          substitution
-   * @return the field element that will return the correctly substituted types
+   * If the given [field]'s type is different when any type parameters from the
+   * defining type's declaration are replaced with the actual type arguments
+   * from the [definingType], create a field member representing the given
+   * field. Return the member that was created, or the base field if no member
+   * was created.
*/
-  static FieldElement from(FieldElement baseField, InterfaceType definingType) {
-    if (!_isChangedByTypeSubstitution(baseField, definingType)) {
-      return baseField;
+  static FieldElement from(FieldElement field, InterfaceType definingType) {
+    if (!_isChangedByTypeSubstitution(field, definingType)) {
+      return field;
}
// TODO(brianwilkerson) Consider caching the substituted type in the
// instance. It would use more memory but speed up some operations.
// We need to see how often the type is being re-computed.
-    return new FieldMember(baseField, definingType);
+    return new FieldMember(field, definingType);
}

/**
-   * Determine whether the given field's type is changed when type parameters from the defining
-   * type's declaration are replaced with the actual type arguments from the defining type.
-   *
-   * @param baseField the base field
-   * @param definingType the type defining the parameters and arguments to be used in the
-   *          substitution
-   * @return true if the type is changed by type substitution.
+   * Determine whether the given [field]'s type is changed when type parameters
+   * from the [definingType]'s declaration are replaced with the actual type
+   * arguments from the defining type.
*/
static bool _isChangedByTypeSubstitution(
-      FieldElement baseField, InterfaceType definingType) {
+      FieldElement field, InterfaceType definingType) {
List<DartType> argumentTypes = definingType.typeArguments;
-    if (baseField != null && argumentTypes.length != 0) {
-      DartType baseType = baseField.type;
+    if (field != null && argumentTypes.length != 0) {
+      DartType baseType = field.type;
List<DartType> parameterTypes = definingType.element.type.typeArguments;
if (baseType != null) {
DartType substitutedType =
@@ -4194,7 +3926,7 @@
}
// If the field has a propagated type, then we need to check whether the
// propagated type needs substitution.
-      DartType basePropagatedType = baseField.propagatedType;
+      DartType basePropagatedType = field.propagatedType;
if (basePropagatedType != null) {
DartType substitutedPropagatedType =
basePropagatedType.substitute2(argumentTypes, parameterTypes);
@@ -4208,41 +3940,51 @@
}

/**
- * The interface FunctionElement defines the behavior of elements representing a function.
+ * A (non-method) function. This can be either a top-level function, a local
+ * function, a closure, or the initialization expression for a field or
+ * variable.
*/
abstract class FunctionElement implements ExecutableElement, LocalElement {
/**
-   * The name of the method that can be implemented by a class to allow its instances to be invoked
-   * as if they were a function.
+   * The name of the method that can be implemented by a class to allow its
+   * instances to be invoked as if they were a function.
*/
static final String CALL_METHOD_NAME = "call";

/**
-   * The name of the method that will be invoked if an attempt is made to invoke an undefined method
-   * on an object.
-   */
-  static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod";
-
-  /**
* The name of the synthetic function defined for libraries that are deferred.
*/

/**
-   * Return the resolved [FunctionDeclaration] node that declares this [FunctionElement]
-   * .
+   * The name of the function used as an entry point.
+   */
+  static const String MAIN_FUNCTION_NAME = "main";
+
+  /**
+   * The name of the method that will be invoked if an attempt is made to invoke
+   * an undefined method on an object.
+   */
+  static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod";
+
+  /**
+   * Return true if the function is an entry point, i.e. a top-level function
+   * and has the name main.
+   */
+  bool get isEntryPoint;
+
+  /**
+   * Return the resolved function declaration node that declares this element.
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
-   *
-   * @return the resolved [FunctionDeclaration], not null.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*/
@override
FunctionDeclaration get node;
}

/**
- * Instances of the class FunctionElementImpl implement a FunctionElement.
+ * A concrete implementation of a [FunctionElement].
*/
class FunctionElementImpl extends ExecutableElementImpl
implements FunctionElement {
@@ -4257,33 +3999,25 @@
int _visibleRangeOffset = 0;

/**
-   * The length of the visible range for this element, or -1 if this element does not have a
-   * visible range.
+   * The length of the visible range for this element, or -1 if this element
+   * does not have a visible range.
*/
int _visibleRangeLength = -1;

/**
-   * Initialize a newly created function element to have the given name and offset.
-   *
-   * @param name the name of this element
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created function element to have the given [name] and
+   * [offset].
*/
-  FunctionElementImpl(String name, int nameOffset) : super(name, nameOffset);
+  FunctionElementImpl(String name, int offset) : super(name, offset);

/**
-   * Initialize a newly created function element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created function element to have the given [name].
*/
FunctionElementImpl.forNode(Identifier name) : super.forNode(name);

/**
-   * Initialize a newly created function element to have no name and the given offset. This is used
-   * for function expressions, which have no name.
-   *
-   * @param nameOffset the offset of the name of this element in the file that contains the
-   *          declaration of this element
+   * Initialize a newly created function element to have no name and the given
+   * [offset]. This is used for function expressions, that have no name.
*/
FunctionElementImpl.forOffset(int nameOffset) : super("", nameOffset);

@@ -4297,6 +4031,11 @@
}

@override
+  bool get isEntryPoint {
+    return isStatic && displayName == FunctionElement.MAIN_FUNCTION_NAME;
+  }
+
+  @override
bool get isStatic => enclosingElement is CompilationUnitElement;

@override
@@ -4327,12 +4066,8 @@
}

/**
-   * Set the visible range for this element to the range starting at the given offset with the given
-   * length.
-   *
-   * @param offset the offset to the beginning of the visible range for this element
-   * @param length the length of the visible range for this element, or -1 if this element
-   *          does not have a visible range
+   * Set the visible range for this element to the range starting at the given
+   * [offset] with the given [length].
*/
void setVisibleRange(int offset, int length) {
_visibleRangeOffset = offset;
@@ -4341,114 +4076,114 @@
}

/**
- * The interface FunctionType defines the behavior common to objects representing the type
- * of a function, method, constructor, getter, or setter. Function types come in three variations:
- * <ol>
- * * The types of functions that only have required parameters. These have the general form
- * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T</i>.
- * * The types of functions with optional positional parameters. These have the general form
- * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, [T<sub>n+1</sub>, &hellip;, T<sub>n+k</sub>]) &rarr;
- * T</i>.
- * * The types of functions with named parameters. These have the general form <i>(T<sub>1</sub>,
- * &hellip;, T<sub>n</sub>, {T<sub>x1</sub> x1, &hellip;, T<sub>xk</sub> xk}) &rarr; T</i>.
- * </ol>
+ * The type of a function, method, constructor, getter, or setter. Function
+ * types come in three variations:
+ *
+ * * The types of functions that only have required parameters. These have the
+ *   general form <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T</i>.
+ * * The types of functions with optional positional parameters. These have the
+ *   general form <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, [T<sub>n+1</sub>
+ *   &hellip;, T<sub>n+k</sub>]) &rarr; T</i>.
+ * * The types of functions with named parameters. These have the general form
+ *   <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {T<sub>x1</sub> x1, &hellip;,
+ *   T<sub>xk</sub> xk}) &rarr; T</i>.
*/
abstract class FunctionType implements ParameterizedType {
/**
-   * Return a map from the names of named parameters to the types of the named parameters of this
-   * type of function. The entries in the map will be iterated in the same order as the order in
-   * which the named parameters were defined. If there were no named parameters declared then the
-   * map will be empty.
-   *
-   * @return a map from the name to the types of the named parameters of this type of function
+   * Return a map from the names of named parameters to the types of the named
+   * parameters of this type of function. The entries in the map will be
+   * iterated in the same order as the order in which the named parameters were
+   * defined. If there were no named parameters declared then the map will be
+   * empty.
*/
Map<String, DartType> get namedParameterTypes;

/**
-   * Return an array containing the types of the normal parameters of this type of function. The
-   * parameter types are in the same order as they appear in the declaration of the function.
-   *
-   * @return the types of the normal parameters of this type of function
+   * Return a list containing the types of the normal parameters of this type of
+   * function. The parameter types are in the same order as they appear in the
+   * declaration of the function.
*/
List<DartType> get normalParameterTypes;

/**
-   * Return a map from the names of optional (positional) parameters to the types of the optional
-   * parameters of this type of function. The entries in the map will be iterated in the same order
-   * as the order in which the optional parameters were defined. If there were no optional
-   * parameters declared then the map will be empty.
-   *
-   * @return a map from the name to the types of the optional parameters of this type of function
+   * Return a map from the names of optional (positional) parameters to the
+   * types of the optional parameters of this type of function. The entries in
+   * the map will be iterated in the same order as the order in which the
+   * optional parameters were defined. If there were no optional parameters
+   * declared then the map will be empty.
*/
List<DartType> get optionalParameterTypes;

/**
-   * Return an array containing the parameters elements of this type of function. The parameter
-   * types are in the same order as they appear in the declaration of the function.
-   *
-   * @return the parameters elements of this type of function
+   * Return a list containing the parameters elements of this type of function.
+   * The parameter types are in the same order as they appear in the declaration
+   * of the function.
*/
List<ParameterElement> get parameters;

/**
* Return the type of object returned by this type of function.
-   *
-   * @return the type of object returned by this type of function
*/
DartType get returnType;

/**
-   * Return true if this type is a subtype of the given type.
+   * Return true if this type is a subtype of the given [type].
*
-   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T</i> is a subtype of the
-   * function type <i>(S<sub>1</sub>, &hellip;, S<sub>n</sub>) &rarr; S</i>, if all of the following
-   * conditions are met:
+   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T</i> is
+   * a subtype of the function type <i>(S<sub>1</sub>, &hellip;, S<sub>n</sub>)
+   * &rarr; S</i>, if all of the following conditions are met:
+   *
* * Either
-   * * <i>S</i> is void, or
-   * * <i>T &hArr; S</i>.
+   *   * <i>S</i> is void, or
+   *   * <i>T &hArr; S</i>.
*
-   * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr; S<sub>i</sub></i>.
-   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, [T<sub>n+1</sub>, &hellip;,
-   * T<sub>n+k</sub>]) &rarr; T</i> is a subtype of the function type <i>(S<sub>1</sub>, &hellip;,
-   * S<sub>n</sub>, [S<sub>n+1</sub>, &hellip;, S<sub>n+m</sub>]) &rarr; S</i>, if all of the
+   * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr;
+   *   S<sub>i</sub></i>.
+   *
+   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>,
+   * [T<sub>n+1</sub>, &hellip;, T<sub>n+k</sub>]) &rarr; T</i> is a subtype of
+   * the function type <i>(S<sub>1</sub>, &hellip;, S<sub>n</sub>,
+   * [S<sub>n+1</sub>, &hellip;, S<sub>n+m</sub>]) &rarr; S</i>, if all of the
* following conditions are met:
-   * * Either
-   * * <i>S</i> is void, or
-   * * <i>T &hArr; S</i>.
*
-   * * <i>k</i> >= <i>m</i> and for all <i>i</i>, 1 <= <i>i</i> <= <i>n+m</i>, <i>T<sub>i</sub>
-   * &hArr; S<sub>i</sub></i>.
-   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {T<sub>x1</sub> x1, &hellip;,
-   * T<sub>xk</sub> xk}) &rarr; T</i> is a subtype of the function type <i>(S<sub>1</sub>, &hellip;,
-   * S<sub>n</sub>, {S<sub>y1</sub> y1, &hellip;, S<sub>ym</sub> ym}) &rarr; S</i>, if all of the
-   * following conditions are met:
* * Either
-   * * <i>S</i> is void,
-   * * or <i>T &hArr; S</i>.
+   *   * <i>S</i> is void, or
+   *   * <i>T &hArr; S</i>.
*
-   * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr; S<sub>i</sub></i>.
-   * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, &hellip;,
-   * x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>.
-   * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, &hellip;, y<sub>m</sub>}</i>,
-   * <i>y<sub>i</sub> = x<sub>j</sub> => Tj &hArr; Si</i>.
+   * * <i>k</i> >= <i>m</i> and for all <i>i</i>, 1 <= <i>i</i> <= <i>n+m</i>,
+   *   <i>T<sub>i</sub> &hArr; S<sub>i</sub></i>.
+   *
+   * A function type <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>,
+   * {T<sub>x1</sub> x1, &hellip;, T<sub>xk</sub> xk}) &rarr; T</i> is a subtype
+   * of the function type <i>(S<sub>1</sub>, &hellip;, S<sub>n</sub>,
+   * {S<sub>y1</sub> y1, &hellip;, S<sub>ym</sub> ym}) &rarr; S</i>, if all of
+   * the following conditions are met:
+   * * Either
+   *   * <i>S</i> is void,
+   *   * or <i>T &hArr; S</i>.
+   *
+   * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr;
+   *   S<sub>i</sub></i>.
+   * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>,
+   *   &hellip;, x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>.
+   * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, &hellip;,
+   *   y<sub>m</sub>}</i>, <i>y<sub>i</sub> = x<sub>j</sub> => Tj &hArr; Si</i>.
+   *
* In addition, the following subtype rules apply:
*
-   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, []) &rarr; T <: (T<sub>1</sub>, &hellip;,
-   * T<sub>n</sub>) &rarr; T.</i><br>
-   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>, &hellip;,
-   * T<sub>n</sub>, {}) &rarr; T.</i><br>
-   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {}) &rarr; T <: (T<sub>1</sub>, &hellip;,
-   * T<sub>n</sub>) &rarr; T.</i><br>
-   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>, &hellip;,
-   * T<sub>n</sub>, []) &rarr; T.</i>
+   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, []) &rarr; T <: (T<sub>1</sub>,
+   * &hellip;, T<sub>n</sub>) &rarr; T.</i><br>
+   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>,
+   * &hellip;, T<sub>n</sub>, {}) &rarr; T.</i><br>
+   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {}) &rarr; T <: (T<sub>1</sub>,
+   * &hellip;, T<sub>n</sub>) &rarr; T.</i><br>
+   * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>,
+   * &hellip;, T<sub>n</sub>, []) &rarr; T.</i>
*
-   * All functions implement the class Function. However not all function types are a
-   * subtype of Function. If an interface type <i>I</i> includes a method named
-   * call(), and the type of call() is the function type <i>F</i>, then <i>I</i> is
-   * considered to be a subtype of <i>F</i>.
-   *
-   * @param type the type being compared with this type
-   * @return true if this type is a subtype of the given type
+   * All functions implement the class Function. However not all function
+   * types are a subtype of Function. If an interface type <i>I</i> includes a
+   * method named call(), and the type of call() is the function type
+   * <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>.
*/
@override
bool isSubtypeOf(DartType type);
@@ -4458,72 +4193,55 @@
List<DartType> argumentTypes, List<DartType> parameterTypes);

/**
-   * Return the type resulting from substituting the given arguments for this type's parameters.
-   * This is fully equivalent to substitute(argumentTypes, getTypeArguments()).
-   *
-   * @param argumentTypes the actual type arguments being substituted for the type parameters
-   * @return the result of performing the substitution
+   * Return the type resulting from substituting the given [argumentTypes] for
+   * this type's parameters. This is fully equivalent to
+   * substitute(argumentTypes, getTypeArguments()).
*/
FunctionType substitute3(List<DartType> argumentTypes);
}

/**
- * The interface FunctionTypeAliasElement defines the behavior of elements representing a
- * function type alias (typedef).
+ * A function type alias (typedef).
*/
abstract class FunctionTypeAliasElement implements Element {
/**
* Return the compilation unit in which this type alias is defined.
-   *
-   * @return the compilation unit in which this type alias is defined
*/
@override
CompilationUnitElement get enclosingElement;

/**
-   * Return the resolved [FunctionTypeAlias] node that declares this
-   * [FunctionTypeAliasElement] .
+   * Return the resolved function type alias node that declares this element.
*
-   * This method is expensive, because resolved AST might be evicted from cache, so parsing and
-   * resolving will be performed.
-   *
-   * @return the resolved [FunctionTypeAlias], not null.
+   * This method is expensive, because resolved AST might be evicted from cache,
+   * so parsing and resolving will be performed.
*/
@override
FunctionTypeAlias get node;

/**
-   * Return an array containing all of the parameters defined by this type alias.
-   *
-   * @return the parameters defined by this type alias
+   * Return a list containing all of the parameters defined by this type alias.
*/
List<ParameterElement> get parameters;

/**
* Return the return type defined by this type alias.
-   *
-   * @return the return type defined by this type alias
*/
DartType get returnType;

/**
* Return the type of function defined by this type alias.
-   *
-   * @return the type of function defined by this type alias
*/
FunctionType get type;

/**
-   * Return an array containing all of the type parameters defined for this type.
-   *
-   * @return the type parameters defined for this type
+   * Return a list containing all of the type parameters defined for this type.
*/
List<TypeParameterElement> get typeParameters;
}

/**
- * Instances of the class FunctionTypeAliasElementImpl implement a
- * FunctionTypeAliasElement.
+ * A concrete implementation of a [FunctionTypeAliasElement].
*/
class FunctionTypeAliasElementImpl extends ElementImpl
implements FunctionTypeAliasElement {
@@ -4534,7 +4252,7 @@
new List<FunctionTypeAliasElement>(0);

/**
-   * An array containing all of the parameters defined by this type alias.
+   * A list containing all of the parameters defined by this type alias.
*/
List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY;

@@ -4549,7 +4267,7 @@
FunctionType type;

/**
-   * An array containing all of the type parameters defined for this type.
+   * A list containing all of the type parameters defined for this type.
*/
List<TypeParameterElement> _typeParameters =
TypeParameterElementImpl.EMPTY_ARRAY;
@@ -4565,9 +4283,7 @@
: super(name, nameOffset);

/**
-   * Initialize a newly created type alias element to have the given name.
-   *
-   * @param name the name of this element
+   * Initialize a newly created type alias element to have the given [name].
*/
FunctionTypeAliasElementImpl.forNode(Identifier name) : super.forNode(name);

@@ -4586,9 +4302,7 @@
List<ParameterElement> get parameters => _parameters;

/**
-   * Set the parameters defined by this type alias to the given parameters.
-   *
-   * @param parameters the parameters defined by this type alias
+   * Set the parameters defined by this type alias to the given [parameters].
*/
void set parameters(List<ParameterElement> parameters) {
if (parameters != null) {
@@ -4603,9 +4317,8 @@
List<TypeParameterElement> get typeParameters => _typeParameters;

/**
-   * Set the type parameters defined for this type to the given parameters.
-   *
-   * @param typeParameters the type parameters defined for this type
+   * Set the type parameters defined for this type to the given
+   * [typeParameters].
*/
void set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement typeParameter in typeParameters) {
@@ -4667,22 +4380,18 @@
}

/**
-   * Set the parameters defined by this type alias to the given parameters without becoming the
-   * parent of the parameters. This should only be used by the [TypeResolverVisitor] when
-   * creating a synthetic type alias.
-   *
-   * @param parameters the parameters defined by this type alias
+   * Set the parameters defined by this type alias to the given [parameters]
+   * without becoming the parent of the parameters. This should only be used by
+   * the [TypeResolverVisitor] when creating a synthetic type alias.
*/
void shareParameters(List<ParameterElement> parameters) {
this._parameters = parameters;
}

/**
-   * Set the type parameters defined for this type to the given parameters without becoming the
-   * parent of the parameters. This should only be used by the [TypeResolverVisitor] when
-   * creating a synthetic type alias.
-   *
-   * @param typeParameters the type parameters defined for this type
+   * Set the type parameters defined for this type to the given [typeParameters]
+   * without becoming the parent of the parameters. This should only be used by
+   * the [TypeResolverVisitor] when creating a synthetic type alias.
*/
void shareTypeParameters(List<TypeParameterElement> typeParameters) {
this._typeParameters = typeParameters;
@@ -4697,34 +4406,29 @@
}

/**
- * Instances of the class FunctionTypeImpl defines the behavior common to objects
- * representing the type of a function, method, constructor, getter, or setter.
+ * The type of a function, method, constructor, getter, or setter.
*/
class FunctionTypeImpl extends TypeImpl implements FunctionType {
/**
-   * An array containing the actual types of the type arguments.
+   * A list containing the actual types of the type arguments.
*/
List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY;

/**
-   * Initialize a newly created function type to be declared by the given element and to have the
-   * given name.
-   *
-   * @param element the element representing the declaration of the function type
+   * Initialize a newly created function type to be declared by the given
+   * [element].
*/
FunctionTypeImpl.con1(ExecutableElement element) : super(element, null);

/**
-   * Initialize a newly created function type to be declared by the given element and to have the
-   * given name.
-   *
-   * @param element the element representing the declaration of the function type
+   * Initialize a newly created function type to be declared by the given
+   * [element].
*/
FunctionTypeImpl.con2(FunctionTypeAliasElement element)
: super(element, element == null ? null : element.name);

/**
-   * @return the base parameter elements of this function element, not null.
+   * Return the base parameter elements of this function element.
*/
List<ParameterElement> get baseParameters {
Element element = this.element;
@@ -4737,8 +4441,6 @@

/**
* Return the return type defined by this function's element.
-   *
-   * @return the return type defined by this function's element
*/
DartType get baseReturnType {
Element element = this.element;
@@ -5302,14 +5004,11 @@
}

/**
-   * Return true if this type is assignable to the given type. A function type <i>T</i> may
-   * be assigned to a function type <i>S</i>, written <i>T</i> &hArr; <i>S</i>, iff <i>T</i> <:
-   * <i>S</i> (Function Types section of spec). Note that this is more restrictive than the
-   * "may be assigned to" rule for interface types.
-   *
-   *
-   * @param type the type being compared with this type
-   * @return true if this type is assignable to the given type
+   * Return true if this type is assignable to the given [type]. A function
+   * type <i>T</i> may be assigned to a function type <i>S</i>, written <i>T</i>
+   * &hArr; <i>S</i>, iff <i>T</i> <: <i>S</i> (Function Types section of spec).
+   * Note that this is more restrictive than the "may be assigned to" rule for
+   * interface types.
*/
@override
bool isAssignableTo(DartType type) =>
@@ -5339,15 +5038,12 @@
substitute2(argumentTypes, typeArguments);

/**
-   * Return true if all of the name/type pairs in the first map are equal to the
-   * corresponding name/type pairs in the second map. The maps are expected to iterate over their
-   * entries in the same order in which those entries were added to the map.
-   *
-   * @param firstTypes the first map of name/type pairs being compared
-   * @param secondTypes the second map of name/type pairs being compared
-   * @param visitedElementPairs a set of visited element pairs
-   * @return true if all of the name/type pairs in the first map are equal to the
-   *         corresponding name/type pairs in the second map
+   * Return true if all of the name/type pairs in the first map ([firstTypes])
+   * are equal to the corresponding name/type pairs in the second map
+   * ([secondTypes]). The maps are expected to iterate over their entries in the
+   * same order in which those entries were added to the map. The set of
+   * [visitedElementPairs] is used to prevent infinite recursion in the case of
+   * cyclic type structures.
*/
static bool _equals(Map<String, DartType> firstTypes,
Map<String, DartType> secondTypes, Set<ElementPair> visitedElementPairs) {
@@ -5371,35 +5067,36 @@
}

/**
- * Instances of the class GeneralizingElementVisitor implement an element visitor that will
- * recursively visit all of the elements in an element model (like instances of the class
- * [RecursiveElementVisitor]). In addition, when an element of a specific type is visited not
- * only will the visit method for that specific type of element be invoked, but additional methods
- * for the supertypes of that element will also be invoked. For example, using an instance of this
- * class to visit a [MethodElement] will cause the method
- * [visitMethodElement] to be invoked but will also cause the methods
- * [visitExecutableElement] and [visitElement] to be
- * subsequently invoked. This allows visitors to be written that visit all executable elements
- * without needing to override the visit method for each of the specific subclasses of
+ * An element visitor that will recursively visit all of the elements in an
+ * element model (like instances of the class [RecursiveElementVisitor]). In
+ * addition, when an element of a specific type is visited not only will the
+ * visit method for that specific type of element be invoked, but additional
+ * methods for the supertypes of that element will also be invoked. For example,
+ * using an instance of this class to visit a [MethodElement] will cause the
+ * method [visitMethodElement] to be invoked but will also cause the methods
+ * [visitExecutableElement] and [visitElement] to be subsequently invoked. This
+ * allows visitors to be written that visit all executable elements without
+ * needing to override the visit method for each of the specific subclasses of
* [ExecutableElement].
*
- * Note, however, that unlike many visitors, element visitors visit objects based on the interfaces
- * implemented by those elements. Because interfaces form a graph structure rather than a tree
- * structure the way classes do, and because it is generally undesirable for an object to be visited
- * more than once, this class flattens the interface graph into a pseudo-tree. In particular, this
- * class treats elements as if the element types were structured in the following way:
- *
+ * Note, however, that unlike many visitors, element visitors visit objects
+ * based on the interfaces implemented by those elements. Because interfaces
+ * form a graph structure rather than a tree structure the way classes do, and
+ * because it is generally undesirable for an object to be visited more than
+ * once, this class flattens the interface graph into a pseudo-tree. In
+ * particular, this class treats elements as if the element types were
+ * structured in the following way:
*
* <pre>
* Element
*   ClassElement
*   CompilationUnitElement
*   ExecutableElement
- *      ConstructorElement
- *      LocalElement
- *         FunctionElement
- *      MethodElement
- *      PropertyAccessorElement
+ *       ConstructorElement
+ *       LocalElement
+ *           FunctionElement
+ *       MethodElement
+ *       PropertyAccessorElement
*   ExportElement
*   HtmlElement
*   ImportElement
@@ -5411,19 +5108,19 @@
*   TypeParameterElement
*   UndefinedElement
*   VariableElement
- *      PropertyInducingElement
- *         FieldElement
- *         TopLevelVariableElement
- *      LocalElement
- *         LocalVariableElement
- *         ParameterElement
- *            FieldFormalParameterElement
+ *       PropertyInducingElement
+ *           FieldElement
+ *           TopLevelVariableElement
+ *       LocalElement
+ *           LocalVariableElement
+ *           ParameterElement
+ *               FieldFormalParameterElement
* </pre>
*
- * Subclasses that override a visit method must either invoke the overridden visit method or
- * explicitly invoke the more general visit method. Failure to do so will cause the visit methods
- * for superclasses of the element to not be invoked and will cause the children of the visited node
- * to not be visited.
+ * Subclasses that override a visit method must either invoke the overridden
+ * visit method or explicitly invoke the more general visit method. Failure to
+ * do so will cause the visit methods for superclasses of the element to not be
+ * invoked and will cause the children of the visited node to not be visited.
*/
class GeneralizingElementVisitor<R> implements ElementVisitor<R> {
@override
@@ -5533,27 +5230,24 @@
}

/**
- * The interface HideElementCombinator defines the behavior of combinators that cause some
- * of the names in a namespace to be hidden when being imported.
+ * A combinator that causes some of the names in a namespace to be hidden when
+ * being imported.
*/
abstract class HideElementCombinator implements NamespaceCombinator {
/**
-   * Return an array containing the names that are not to be made visible in the importing library
-   * even if they are defined in the imported library.
-   *
-   * @return the names from the imported library that are hidden from the importing library
+   * Return a list containing the names that are not to be made visible in the
+   * importing library even if they are defined in the imported library.
*/
List<String> get hiddenNames;
}

/**
- * Instances of the class HideElementCombinatorImpl implement a
- * [HideElementCombinator].
+ * A concrete implementation of a [HideElementCombinator].
*/
class HideElementCombinatorImpl implements HideElementCombinator {
/**
-   * The names that are not to be made visible in the importing library even if they are defined in
-   * the imported library.
+   * The names that are not to be made visible in the importing library even if
+   * they are defined in the imported library.
*/
List<String> hiddenNames = StringUtilities.EMPTY_ARRAY;

@@ -5573,21 +5267,20 @@
}

/**
- * The interface HtmlElement defines the behavior of elements representing an HTML file.
+ * An HTML file.
*/
abstract class HtmlElement implements Element {
/**
-   * Return an array containing all of the script elements contained in the HTML file. This includes
-   * scripts with libraries that are defined by the content of a script tag as well as libraries
-   * that are referenced in the {@core source} attribute of a script tag.
-   *
-   * @return the script elements in the HTML file (not null, contains no nulls)
+   * Return a list containing all of the script elements contained in the HTML
+   * file. This includes scripts with libraries that are defined by the content
+   * of a script tag as well as libraries that are referenced in the source
+   * attribute of a script tag.
*/
List<HtmlScriptElement> get scripts;
}

/**
- * Instances of the class HtmlElementImpl implement an [HtmlElement].
+ * A concrete implementation of an [HtmlElement].
*/
class HtmlElementImpl extends ElementImpl implements HtmlElement {
/**
@@ -5611,10 +5304,8 @@
Source source;

/**
-   * Initialize a newly created HTML element to have the given name.
-   *
-   * @param context the analysis context in which the HTML file is defined
-   * @param name the name of this element
+   * Initialize a newly created HTML element in the given [context] to have the
+   * given [name].
*/
HtmlElementImpl(this.context, String name) : super(name, -1);

@@ -5631,9 +5322,7 @@
List<HtmlScriptElement> get scripts => _scripts;

/**
-   * Set the scripts contained in the HTML file to the given scripts.
-   *
-   * @param scripts the scripts
+   * Set the scripts contained in the HTML file to the given [scripts].
*/
void set scripts(List<HtmlScriptElement> scripts) {
if (scripts.length == 0) {
@@ -5674,36 +5363,33 @@
}

/**
- * The interface HtmlScriptElement defines the behavior of elements representing a script
- * tag in an HTML file.
+ * A script tag in an HTML file.
*
- * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement],
+ * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement].
*/
abstract class HtmlScriptElement implements Element {}

/**
- * Instances of the class HtmlScriptElementImpl implement an [HtmlScriptElement].
+ * A concrete implementation of an [HtmlScriptElement].
*/
abstract class HtmlScriptElementImpl extends ElementImpl
implements HtmlScriptElement {
/**
* An empty list of HTML script elements.
*/
-  static const List<HtmlScriptElement> EMPTY_ARRAY = const <HtmlScriptElement>[
-  ];
+  static const List<HtmlScriptElement> EMPTY_ARRAY =
+      const <HtmlScriptElement>[];

/**
-   * Initialize a newly created script element to have the specified tag name and offset.
-   *
-   * @param node the XML node from which this element is derived (not null)
+   * Initialize a newly created script element corresponding to the given
+   * [node].
*/
HtmlScriptElementImpl(XmlTagNode node)
: super(node.tag, node.tagToken.offset);
}

/**
- * The interface ImportElement defines the behavior of objects representing information
- * about a single import directive within a library.
+ * A single import directive within a library.
*/
abstract class ImportElement implements Element, UriReferencedElement {
/**
@@ -5712,53 +5398,44 @@
static const List<ImportElement> EMPTY_ARRAY = const <ImportElement>[];

/**
-   * Return an array containing the combinators that were specified as part of the import directive
-   * in the order in which they were specified.
-   *
-   * @return the combinators specified in the import directive
+   * Return a list containing the combinators that were specified as part of the
+   * import directive in the order in which they were specified.
*/
List<NamespaceCombinator> get combinators;

/**
-   * Return the library that is imported into this library by this import directive.
-   *
-   * @return the library that is imported into this library
+   * Return the library that is imported into this library by this import
+   * directive.
*/
LibraryElement get importedLibrary;

/**
* Return true if this import is for a deferred library.
-   *
-   * @return true if this import is for a deferred library
*/
bool get isDeferred;

/**
-   * Return the prefix that was specified as part of the import directive, or null if there
-   * was no prefix specified.
-   *
-   * @return the prefix that was specified as part of the import directive
+   * Return the prefix that was specified as part of the import directive, or
+   * null if there was no prefix specified.
*/
PrefixElement get prefix;

/**
-   * Return the offset of the prefix of this import in the file that contains this import directive,
-   * or -1 if this import is synthetic, does not have a prefix, or otherwise does not have
-   * an offset.
-   *
-   * @return the offset of the prefix of this import
+   * Return the offset of the prefix of this import in the file that contains
+   * this import directive, or -1 if this import is synthetic, does not have a
+   * prefix, or otherwise does not have an offset.
*/
int get prefixOffset;
}

/**
- * Instances of the class ImportElementImpl implement an [ImportElement].
+ * A concrete implementation of an [ImportElement].
*/
class ImportElementImpl extends UriReferencedElementImpl
implements ImportElement {
/**
-   * The offset of the prefix of this import in the file that contains the this import directive, or
-   * -1 if this import is synthetic.
+   * The offset of the prefix of this import in the file that contains the this
+   * import directive, or -1 if this import is synthetic.
*/
int prefixOffset = 0;

@@ -5768,28 +5445,25 @@
LibraryElement importedLibrary;

/**
-   * The combinators that were specified as part of the import directive in the order in which they
-   * were specified.
+   * The combinators that were specified as part of the import directive in the
+   * order in which they were specified.
*/
List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY;

/**
-   * The prefix that was specified as part of the import directive, or null if there was no
-   * prefix specified.
+   * The prefix that was specified as part of the import directive, or null if
+   * there was no prefix specified.
*/
PrefixElement prefix;

/**
-   * Initialize a newly created import element.
-   *
-   * @param offset the directive offset, may be -1 if synthetic.
+   * Initialize a newly created import element at the given [offset].
+   * The offset may be -1 if the import is synthetic.
*/
ImportElementImpl(int offset) : super(null, offset);

/**
-   * Set whether this import is for a deferred library to correspond to the given value.
-   *
-   * @param isDeferred true if this import is for a deferred library
+   * Set whether this import is for a deferred library.
*/
void set deferred(bool isDeferred) {
setModifier(Modifier.DEFERRED, isDeferred);
@@ -5822,8 +5496,8 @@
}

/**
- * The interface InterfaceType defines the behavior common to objects representing the type
- * introduced by either a class or an interface, or a reference to such a type.
+ * The type introduced by either a class or an interface, or a reference to such
+ * a type.
*/
abstract class InterfaceType implements ParameterizedType {
/**
@@ -5832,9 +5506,8 @@
static const List<InterfaceType> EMPTY_ARRAY = const <InterfaceType>[];

/**
-   * Return an array containing all of the accessors (getters and setters) declared in this type.
-   *
-   * @return the accessors declared in this type
+   * Return a list containing all of the accessors (getters and setters)
+   * declared in this type.
*/
List<PropertyAccessorElement> get accessors;

@@ -5842,273 +5515,240 @@
ClassElement get element;

/**
-   * Return an array containing all of the interfaces that are implemented by this interface. Note
-   * that this is <b>not</b>, in general, equivalent to getting the interfaces from this type's
-   * element because the types returned by this method will have had their type parameters replaced.
-   *
-   * @return the interfaces that are implemented by this type
+   * Return a list containing all of the interfaces that are implemented by this
+   * interface. Note that this is <b>not</b>, in general, equivalent to getting
+   * the interfaces from this type's element because the types returned by this
+   * method will have had their type parameters replaced.
*/
List<InterfaceType> get interfaces;

/**
-   * Return an array containing all of the methods declared in this type.
-   *
-   * @return the methods declared in this type
+   * Return a list containing all of the methods declared in this type.
*/
List<MethodElement> get methods;

/**
-   * Return an array containing all of the mixins that are applied to the class being extended in
-   * order to derive the superclass of this class. Note that this is <b>not</b>, in general,
-   * equivalent to getting the mixins from this type's element because the types returned by this
-   * method will have had their type parameters replaced.
-   *
-   * @return the mixins that are applied to derive the superclass of this class
+   * Return a list containing all of the mixins that are applied to the class
+   * being extended in order to derive the superclass of this class. Note that
+   * this is <b>not</b>, in general, equivalent to getting the mixins from this
+   * type's element because the types returned by this method will have had
+   * their type parameters replaced.
*/
List<InterfaceType> get mixins;

/**
-   * Return the type representing the superclass of this type, or null if this type represents the
-   * class 'Object'. Note that this is <b>not</b>, in general, equivalent to getting the superclass
-   * from this type's element because the type returned by this method will have had it's type
-   * parameters replaced.
-   *
-   * @return the superclass of this type
+   * Return the type representing the superclass of this type, or null if this
+   * type represents the class 'Object'. Note that this is <b>not</b>, in
+   * general, equivalent to getting the superclass from this type's element
+   * because the type returned by this method will have had it's type parameters
+   * replaced.
*/
InterfaceType get superclass;

/**
-   * Return the element representing the getter with the given name that is declared in this class,
-   * or null if this class does not declare a getter with the given name.
-   *
-   * @param getterName the name of the getter to be returned
-   * @return the getter declared in this class with the given name
+   * Return the element representing the getter with the given [name] that is
+   * declared in this class, or null if this class does not declare a getter
+   * with the given name.
*/
-  PropertyAccessorElement getGetter(String getterName);
+  PropertyAccessorElement getGetter(String name);

/**
-   * Return the least upper bound of this type and the given type, or null if there is no
-   * least upper bound.
+   * Return the least upper bound of this type and the given [type], or null
+   * if there is no least upper bound.
*
-   * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the set of
-   * superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of superinterfaces of <i>J</i>
-   * and let <i>S = (I &cup; S<sub>I</sub>) &cap; (J &cup; S<sub>J</sub>)</i>. Furthermore, we
-   * define <i>S<sub>n</sub> = {T | T &isin; S &and; depth(T) = n}</i> for any finite <i>n</i>,
-   * where <i>depth(T)</i> is the number of steps in the longest inheritance path from <i>T</i> to
-   * <i>Object</i>. Let <i>q</i> be the largest number such that <i>S<sub>q</sub></i> has
-   * cardinality one. The least upper bound of <i>I</i> and <i>J</i> is the sole element of
-   * <i>S<sub>q</sub></i>.
-   *
-   * @param type the other type used to compute the least upper bound
-   * @return the least upper bound of this type and the given type
+   * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the
+   * set of superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of
+   * superinterfaces of <i>J</i> and let <i>S = (I &cup; S<sub>I</sub>) &cap;
+   * (J &cup; S<sub>J</sub>)</i>. Furthermore, we define <i>S<sub>n</sub> =
+   * {T | T &isin; S &and; depth(T) = n}</i> for any finite <i>n</i>, where
+   * <i>depth(T)</i> is the number of steps in the longest inheritance path from
+   * <i>T</i> to <i>Object</i>. Let <i>q</i> be the largest number such that
+   * <i>S<sub>q</sub></i> has cardinality one. The least upper bound of <i>I</i>
+   * and <i>J</i> is the sole element of <i>S<sub>q</sub></i>.
*/
@override
DartType getLeastUpperBound(DartType type);

/**
-   * Return the element representing the method with the given name that is declared in this class,
-   * or null if this class does not declare a method with the given name.
-   *
-   * @param methodName the name of the method to be returned
-   * @return the method declared in this class with the given name
+   * Return the element representing the method with the given [name] that is
+   * declared in this class, or null if this class does not declare a method
+   * with the given name.
*/
-  MethodElement getMethod(String methodName);
+  MethodElement getMethod(String name);

/**
-   * Return the element representing the setter with the given name that is declared in this class,
-   * or null if this class does not declare a setter with the given name.
-   *
-   * @param setterName the name of the setter to be returned
-   * @return the setter declared in this class with the given name
+   * Return the element representing the setter with the given [name] that is
+   * declared in this class, or null if this class does not declare a setter
+   * with the given name.
*/
-  PropertyAccessorElement getSetter(String setterName);
+  PropertyAccessorElement getSetter(String name);

/**
-   * Return true if this type is a direct supertype of the given type. The implicit
-   * interface of class <i>I</i> is a direct supertype of the implicit interface of class <i>J</i>
-   * iff:
+   * Return true if this type is a direct supertype of the given [type]. The
+   * implicit interface of class <i>I</i> is a direct supertype of the implicit
+   * interface of class <i>J</i> iff:
+   *
* * <i>I</i> is Object, and <i>J</i> has no extends clause.
* * <i>I</i> is listed in the extends clause of <i>J</i>.
* * <i>I</i> is listed in the implements clause of <i>J</i>.
* * <i>I</i> is listed in the with clause of <i>J</i>.
* * <i>J</i> is a mixin application of the mixin of <i>I</i>.
-   *
-   * @param type the type being compared with this type
-   * @return true if this type is a direct supertype of the given type
*/
bool isDirectSupertypeOf(InterfaceType type);

/**
-   * Return true if this type is more specific than the given type. An interface type
-   * <i>T</i> is more specific than an interface type <i>S</i>, written <i>T &laquo; S</i>, if one
-   * of the following conditions is met:
+   * Return true if this type is more specific than the given [type]. An
+   * interface type <i>T</i> is more specific than an interface type <i>S</i>,
+   * written <i>T &laquo; S</i>, if one of the following conditions is met:
+   *
* * Reflexivity: <i>T</i> is <i>S</i>.
* * <i>T</i> is bottom.
* * <i>S</i> is dynamic.
* * Direct supertype: <i>S</i> is a direct supertype of <i>T</i>.
* * <i>T</i> is a type parameter and <i>S</i> is the upper bound of <i>T</i>.
-   * * Covariance: <i>T</i> is of the form <i>I&lt;T<sub>1</sub>, &hellip;, T<sub>n</sub>&gt;</i>
-   * and S</i> is of the form <i>I&lt;S<sub>1</sub>, &hellip;, S<sub>n</sub>&gt;</i> and
-   * <i>T<sub>i</sub> &laquo; S<sub>i</sub></i>, <i>1 <= i <= n</i>.
+   * * Covariance: <i>T</i> is of the form <i>I&lt;T<sub>1</sub>, &hellip;,
+   *   T<sub>n</sub>&gt;</i> and S</i> is of the form <i>I&lt;S<sub>1</sub>,
+   *   &hellip;, S<sub>n</sub>&gt;</i> and <i>T<sub>i</sub> &laquo;
+   *   S<sub>i</sub></i>, <i>1 <= i <= n</i>.
* * Transitivity: <i>T &laquo; U</i> and <i>U &laquo; S</i>.
-   *
-   * @param type the type being compared with this type
-   * @return true if this type is more specific than the given type
*/
@override
bool isMoreSpecificThan(DartType type);

/**
-   * Return true if this type is a subtype of the given type. An interface type <i>T</i> is
-   * a subtype of an interface type <i>S</i>, written <i>T</i> <: <i>S</i>, iff
-   * <i>[bottom/dynamic]T</i> &laquo; <i>S</i> (<i>T</i> is more specific than <i>S</i>). If an
-   * interface type <i>I</i> includes a method named <i>call()</i>, and the type of <i>call()</i> is
-   * the function type <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>.
-   *
-   * @param type the type being compared with this type
-   * @return true if this type is a subtype of the given type
+   * Return true if this type is a subtype of the given [type]. An interface
+   * type <i>T</i> is a subtype of an interface type <i>S</i>, written <i>T</i>
+   * <: <i>S</i>, iff <i>[bottom/dynamic]T</i> &laquo; <i>S</i> (<i>T</i> is
+   * more specific than <i>S</i>). If an interface type <i>I</i> includes a
+   * method named <i>call()</i>, and the type of <i>call()</i> is the function
+   * type <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>.
*/
@override
bool isSubtypeOf(DartType type);

/**
-   * Return the element representing the constructor that results from looking up the given
-   * constructor in this class with respect to the given library, or null if the look up
-   * fails. The behavior of this method is defined by the Dart Language Specification in section
-   * 12.11.1: <blockquote>If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be
-   * the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<i>. Otherwise, if
-   * <i>q</i> is not defined or not accessible, a NoSuchMethodException is thrown. </blockquote>
-   *
-   * @param constructorName the name of the constructor being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given constructor in this class with respect to the given
-   *         library
-   */
-  ConstructorElement lookUpConstructor(
-      String constructorName, LibraryElement library);
-
-  /**
-   * Return the element representing the getter that results from looking up the given getter in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.15.1:
-   * <blockquote>The result of looking up getter (respectively setter) <i>m</i> in class <i>C</i>
-   * with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * Return the element representing the constructor that results from looking
+   * up the constructor with the given [name] in this class with respect to the
+   * given [library], or null if the look up fails. The behavior of this
+   * method is defined by the Dart Language Specification in section 12.11.1:
+   * <blockquote>
+   * If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be the
+   * constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<i>.
+   * Otherwise, if <i>q</i> is not defined or not accessible, a
+   * NoSuchMethodException is thrown.
* </blockquote>
-   *
-   * @param getterName the name of the getter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given getter in this class with respect to the given
-   *         library
*/
-  PropertyAccessorElement lookUpGetter(
-      String getterName, LibraryElement library);
+  ConstructorElement lookUpConstructor(String name, LibraryElement library);

/**
-   * Return the element representing the getter that results from looking up the given getter in the
-   * superclass of this class with respect to the given library, or null if the look up
-   * fails. The behavior of this method is defined by the Dart Language Specification in section
-   * 12.15.1: <blockquote>The result of looking up getter (respectively setter) <i>m</i> in class
+   * Return the element representing the getter that results from looking up the
+   * getter with the given [name] in this class with respect to the given
+   * [library], or null if the look up fails. The behavior of this method is
+   * defined by the Dart Language Specification in section 12.15.1:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
* <i>C</i> with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * * If <i>C</i> declares an instance getter (respectively setter) named
+   *   <i>m</i> that is accessible to <i>L</i>, then that getter (respectively
+   *   setter) is the result of the lookup. Otherwise, if <i>C</i> has a
+   *   superclass <i>S</i>, then the result of the lookup is the result of
+   *   looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect
+   *   to <i>L</i>. Otherwise, we say that the lookup has failed.
* </blockquote>
-   *
-   * @param getterName the name of the getter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given getter in this class with respect to the given
-   *         library
+   */
+  PropertyAccessorElement lookUpGetter(String name, LibraryElement library);
+
+  /**
+   * Return the element representing the getter that results from looking up the
+   * getter with the given [name] in the superclass of this class with respect
+   * to the given [library], or null if the look up fails. The behavior of
+   * this method is defined by the Dart Language Specification in section
+   * 12.15.1:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
+   * <i>C</i> with respect to library <i>L</i> is:
+   * * If <i>C</i> declares an instance getter (respectively setter) named
+   *   <i>m</i> that is accessible to <i>L</i>, then that getter (respectively
+   *   setter) is the result of the lookup. Otherwise, if <i>C</i> has a
+   *   superclass <i>S</i>, then the result of the lookup is the result of
+   *   looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect
+   *   to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * </blockquote>
*/
PropertyAccessorElement lookUpGetterInSuperclass(
-      String getterName, LibraryElement library);
+      String name, LibraryElement library);

/**
-   * Return the element representing the method that results from looking up the given method in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.15.1:
-   * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> with respect to library
-   * <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
+   * Return the element representing the method that results from looking up the
+   * method with the given [name] in this class with respect to the given
+   * [library], or null if the look up fails. The behavior of this method is
+   * defined by the Dart Language Specification in section 12.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is:
+   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
+   *   to <i>L</i>, then that method is the result of the lookup. Otherwise, if
+   *   <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the
+   *   result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i>
+   *   Otherwise, we say that the lookup has failed.
* </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in this class with respect to the given
-   *         library
*/
-  MethodElement lookUpMethod(String methodName, LibraryElement library);
+  MethodElement lookUpMethod(String name, LibraryElement library);

/**
-   * Return the element representing the method that results from looking up the given method in the
-   * superclass of this class with respect to the given library, or null if the look up
-   * fails. The behavior of this method is defined by the Dart Language Specification in section
-   * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>C</i> with respect
-   * to library <i>L</i> is:
-   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible to <i>L</i>, then
-   * that method is the result of the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then
-   * the result of the lookup is the result of looking up method <i>m</i> in <i>S</i> with respect
-   * to <i>L</i>. Otherwise, we say that the lookup has failed.
-   * </blockquote>
-   *
-   * @param methodName the name of the method being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given method in this class with respect to the given
-   *         library
-   */
-  MethodElement lookUpMethodInSuperclass(
-      String methodName, LibraryElement library);
-
-  /**
-   * Return the element representing the setter that results from looking up the given setter in
-   * this class with respect to the given library, or null if the look up fails. The
-   * behavior of this method is defined by the Dart Language Specification in section 12.16:
-   * <blockquote> The result of looking up getter (respectively setter) <i>m</i> in class <i>C</i>
-   * with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
+   * Return the element representing the method that results from looking up the
+   * method with the given [name] in the superclass of this class with respect
+   * to the given [library], or null if the look up fails. The behavior of
+   * this method is defined by the Dart Language Specification in section
+   * 12.15.1:
+   * <blockquote>
+   * The result of looking up method <i>m</i> in class <i>C</i> with respect to
+   * library <i>L</i> is:
+   * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
+   *   to <i>L</i>, then that method is the result of the lookup. Otherwise, if
+   * <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the
+   * result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i>.
* Otherwise, we say that the lookup has failed.
* </blockquote>
-   *
-   * @param setterName the name of the setter being looked up
-   * @param library the library with respect to which the lookup is being performed
-   * @return the result of looking up the given setter in this class with respect to the given
-   *         library
*/
-  PropertyAccessorElement lookUpSetter(
-      String setterName, LibraryElement library);
+  MethodElement lookUpMethodInSuperclass(String name, LibraryElement library);

/**
-   * Return the element representing the setter that results from looking up the given setter in the
-   * superclass of this class with respect to the given library, or null if the look up
-   * fails. The behavior of this method is defined by the Dart Language Specification in section
-   * 12.16: <blockquote> The result of looking up getter (respectively setter) <i>m</i> in class
+   * Return the element representing the setter that results from looking up the
+   * setter with the given [name] in this class with respect to the given
+   * [library], or null if the look up fails. The behavior of this method is
+   * defined by the Dart Language Specification in section 12.16:
+   * <blockquote>
+   * The result of looking up getter (respectively setter) <i>m</i> in class
* <i>C</i> with respect to library <i>L</i> is:
-   * * If <i>C</i> declares an instance getter (respectively setter) named <i>m</i> that is
-   * accessible to <i>L</i>, then that getter (respectively setter) is the result of the lookup.
-   * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the result
-   * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect to <i>L</i>.
-   * Otherwise, we say that the lookup has failed.
+   * * If <i>C</i> declares an instance getter (respectively setter) named
+   *   <i>m</i> that is accessible to <i>L</i>, then that getter (respectively