Version 0.5.2.0 .
svn merge -r 22069:22191 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: http://dart.googlecode.com/svn/trunk@22194 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/analyzer_experimental/lib/src/generated/ast.dart b/pkg/analyzer_experimental/lib/src/generated/ast.dart
index 6f7fd37..044f2fb 100644
--- a/pkg/analyzer_experimental/lib/src/generated/ast.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/ast.dart
@@ -1478,7 +1478,7 @@
* cascadeSection ::=
* '..' (cascadeSelector arguments*) (assignableSelector arguments*)* (assignmentOperator expressionWithoutCascade)?
* cascadeSelector ::=
- * '[ ' expression '] '
+ * '\[ ' expression '\] '
* | identifier
* </pre>
* @coverage dart.engine.ast
@@ -1960,7 +1960,7 @@
this._withClause = becomeParentOf(withClause2);
}
void visitChildren(ASTVisitor<Object> visitor) {
- safelyVisitChild(documentationComment, visitor);
+ super.visitChildren(visitor);
safelyVisitChild(_name, visitor);
safelyVisitChild(_typeParameters, visitor);
safelyVisitChild(_extendsClause, visitor);
@@ -2349,7 +2349,7 @@
* found within a documentation comment.
* <pre>
* commentReference ::=
- * '[' 'new'? {@link Identifier identifier} ']'
+ * '\[' 'new'? {@link Identifier identifier} '\]'
* </pre>
* @coverage dart.engine.ast
*/
@@ -5003,7 +5003,7 @@
* optionalPositionalFormalParameters
* | namedFormalParameters
* optionalPositionalFormalParameters ::=
- * '[' {@link DefaultFormalParameter positionalFormalParameter} (',' {@link DefaultFormalParameter positionalFormalParameter})* ']'
+ * '\[' {@link DefaultFormalParameter positionalFormalParameter} (',' {@link DefaultFormalParameter positionalFormalParameter})* '\]'
* namedFormalParameters ::=
* '{' {@link DefaultFormalParameter namedFormalParameter} (',' {@link DefaultFormalParameter namedFormalParameter})* '}'
* </pre>
@@ -5019,11 +5019,11 @@
*/
NodeList<FormalParameter> _parameters;
/**
- * The left square bracket ('[') or left curly brace ('{') introducing the optional parameters.
+ * The left square bracket ('\[') or left curly brace ('{') introducing the optional parameters.
*/
Token _leftDelimiter;
/**
- * The right square bracket (']') or right curly brace ('}') introducing the optional parameters.
+ * The right square bracket ('\]') or right curly brace ('}') introducing the optional parameters.
*/
Token _rightDelimiter;
/**
@@ -5072,9 +5072,9 @@
}
Token get endToken => _rightParenthesis;
/**
- * Return the left square bracket ('[') or left curly brace ('{') introducing the optional
+ * Return the left square bracket ('\[') or left curly brace ('{') introducing the optional
* parameters.
- * @return the left square bracket ('[') or left curly brace ('{') introducing the optional
+ * @return the left square bracket ('\[') or left curly brace ('{') introducing the optional
* parameters
*/
Token get leftDelimiter => _leftDelimiter;
@@ -5089,9 +5089,9 @@
*/
NodeList<FormalParameter> get parameters => _parameters;
/**
- * Return the right square bracket (']') or right curly brace ('}') introducing the optional
+ * Return the right square bracket ('\]') or right curly brace ('}') introducing the optional
* parameters.
- * @return the right square bracket (']') or right curly brace ('}') introducing the optional
+ * @return the right square bracket ('\]') or right curly brace ('}') introducing the optional
* parameters
*/
Token get rightDelimiter => _rightDelimiter;
@@ -5101,7 +5101,7 @@
*/
Token get rightParenthesis => _rightParenthesis;
/**
- * Set the left square bracket ('[') or left curly brace ('{') introducing the optional parameters
+ * Set the left square bracket ('\[') or left curly brace ('{') introducing the optional parameters
* to the given token.
* @param bracket the left delimiter introducing the optional parameters
*/
@@ -5116,7 +5116,7 @@
_leftParenthesis = parenthesis;
}
/**
- * Set the right square bracket (']') or right curly brace ('}') introducing the optional
+ * Set the right square bracket ('\]') or right curly brace ('}') introducing the optional
* parameters to the given token.
* @param bracket the right delimiter introducing the optional parameters
*/
@@ -5234,6 +5234,16 @@
*/
TypeName get returnType => _returnType;
/**
+ * Return {@code true} if this function declares a getter.
+ * @return {@code true} if this function declares a getter
+ */
+ bool isGetter() => _propertyKeyword != null && identical(((_propertyKeyword as KeywordToken)).keyword, Keyword.GET);
+ /**
+ * Return {@code true} if this function declares a setter.
+ * @return {@code true} if this function declares a setter
+ */
+ bool isSetter() => _propertyKeyword != null && identical(((_propertyKeyword as KeywordToken)).keyword, Keyword.SET);
+ /**
* Set the token representing the 'external' keyword to the given token.
* @param externalKeyword the token representing the 'external' keyword
*/
@@ -6079,7 +6089,7 @@
/**
* Instances of the class {@code IndexExpression} represent an index expression.
* <pre>
- * indexExpression ::={@link Expression target} '[' {@link Expression index} ']'
+ * indexExpression ::={@link Expression target} '\[' {@link Expression index} '\]'
* </pre>
* @coverage dart.engine.ast
*/
@@ -6228,7 +6238,7 @@
* <p>
* Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
* they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
- * @return {@code true} if this expression is in a context where the operator '[]' will be invoked
+ * @return {@code true} if this expression is in a context where the operator '\[\]' will be invoked
*/
bool inGetterContext() {
ASTNode parent2 = parent;
@@ -6245,7 +6255,7 @@
* <p>
* Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
* they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
- * @return {@code true} if this expression is in a context where the operator '[]=' will be
+ * @return {@code true} if this expression is in a context where the operator '\[\]=' will be
* invoked
*/
bool inSetterContext() {
@@ -7015,7 +7025,7 @@
* Instances of the class {@code ListLiteral} represent a list literal.
* <pre>
* listLiteral ::=
- * 'const'? ('<' {@link TypeName type} '>')? '[' ({@link Expression expressionList} ','?)? ']'
+ * 'const'? ('<' {@link TypeName type} '>')? '\[' ({@link Expression expressionList} ','?)? '\]'
* </pre>
* @coverage dart.engine.ast
*/
@@ -11483,7 +11493,24 @@
Element visitCompilationUnit(CompilationUnit node) => node.element;
Element visitConstructorDeclaration(ConstructorDeclaration node) => node.element;
Element visitFunctionDeclaration(FunctionDeclaration node) => node.element;
- Element visitIdentifier(Identifier node) => node.element;
+ Element visitIdentifier(Identifier node) {
+ ASTNode parent2 = node.parent;
+ if (parent2 is ConstructorDeclaration) {
+ ConstructorDeclaration decl = parent2 as ConstructorDeclaration;
+ Identifier returnType2 = decl.returnType;
+ if (identical(returnType2, node)) {
+ SimpleIdentifier name2 = decl.name;
+ if (name2 != null) {
+ return name2.element;
+ }
+ Element element2 = node.element;
+ if (element2 is ClassElement) {
+ return ((element2 as ClassElement)).unnamedConstructor;
+ }
+ }
+ }
+ return node.element;
+ }
Element visitImportDirective(ImportDirective node) => node.element;
Element visitIndexExpression(IndexExpression node) => node.element;
Element visitInstanceCreationExpression(InstanceCreationExpression node) => node.element;
@@ -13096,134 +13123,134 @@
* results or properties associated with the nodes.
*/
class ASTCloner implements ASTVisitor<ASTNode> {
- AdjacentStrings visitAdjacentStrings(AdjacentStrings node) => new AdjacentStrings.full(clone2(node.strings));
- Annotation visitAnnotation(Annotation node) => new Annotation.full(node.atSign, clone(node.name), node.period, clone(node.constructorName), clone(node.arguments));
- ArgumentDefinitionTest visitArgumentDefinitionTest(ArgumentDefinitionTest node) => new ArgumentDefinitionTest.full(node.question, clone(node.identifier));
- ArgumentList visitArgumentList(ArgumentList node) => new ArgumentList.full(node.leftParenthesis, clone2(node.arguments), node.rightParenthesis);
- AsExpression visitAsExpression(AsExpression node) => new AsExpression.full(clone(node.expression), node.asOperator, clone(node.type));
- ASTNode visitAssertStatement(AssertStatement node) => new AssertStatement.full(node.keyword, node.leftParenthesis, clone(node.condition), node.rightParenthesis, node.semicolon);
- AssignmentExpression visitAssignmentExpression(AssignmentExpression node) => new AssignmentExpression.full(clone(node.leftHandSide), node.operator, clone(node.rightHandSide));
- BinaryExpression visitBinaryExpression(BinaryExpression node) => new BinaryExpression.full(clone(node.leftOperand), node.operator, clone(node.rightOperand));
- Block visitBlock(Block node) => new Block.full(node.leftBracket, clone2(node.statements), node.rightBracket);
- BlockFunctionBody visitBlockFunctionBody(BlockFunctionBody node) => new BlockFunctionBody.full(clone(node.block));
+ AdjacentStrings visitAdjacentStrings(AdjacentStrings node) => new AdjacentStrings.full(clone3(node.strings));
+ Annotation visitAnnotation(Annotation node) => new Annotation.full(node.atSign, clone2(node.name), node.period, clone2(node.constructorName), clone2(node.arguments));
+ ArgumentDefinitionTest visitArgumentDefinitionTest(ArgumentDefinitionTest node) => new ArgumentDefinitionTest.full(node.question, clone2(node.identifier));
+ ArgumentList visitArgumentList(ArgumentList node) => new ArgumentList.full(node.leftParenthesis, clone3(node.arguments), node.rightParenthesis);
+ AsExpression visitAsExpression(AsExpression node) => new AsExpression.full(clone2(node.expression), node.asOperator, clone2(node.type));
+ ASTNode visitAssertStatement(AssertStatement node) => new AssertStatement.full(node.keyword, node.leftParenthesis, clone2(node.condition), node.rightParenthesis, node.semicolon);
+ AssignmentExpression visitAssignmentExpression(AssignmentExpression node) => new AssignmentExpression.full(clone2(node.leftHandSide), node.operator, clone2(node.rightHandSide));
+ BinaryExpression visitBinaryExpression(BinaryExpression node) => new BinaryExpression.full(clone2(node.leftOperand), node.operator, clone2(node.rightOperand));
+ Block visitBlock(Block node) => new Block.full(node.leftBracket, clone3(node.statements), node.rightBracket);
+ BlockFunctionBody visitBlockFunctionBody(BlockFunctionBody node) => new BlockFunctionBody.full(clone2(node.block));
BooleanLiteral visitBooleanLiteral(BooleanLiteral node) => new BooleanLiteral.full(node.literal, node.value);
- BreakStatement visitBreakStatement(BreakStatement node) => new BreakStatement.full(node.keyword, clone(node.label), node.semicolon);
- CascadeExpression visitCascadeExpression(CascadeExpression node) => new CascadeExpression.full(clone(node.target), clone2(node.cascadeSections));
- CatchClause visitCatchClause(CatchClause node) => new CatchClause.full(node.onKeyword, clone(node.exceptionType), node.catchKeyword, node.leftParenthesis, clone(node.exceptionParameter), node.comma, clone(node.stackTraceParameter), node.rightParenthesis, clone(node.body));
- ClassDeclaration visitClassDeclaration(ClassDeclaration node) => new ClassDeclaration.full(clone(node.documentationComment), clone2(node.metadata), node.abstractKeyword, node.classKeyword, clone(node.name), clone(node.typeParameters), clone(node.extendsClause), clone(node.withClause), clone(node.implementsClause), node.leftBracket, clone2(node.members), node.rightBracket);
- ClassTypeAlias visitClassTypeAlias(ClassTypeAlias node) => new ClassTypeAlias.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.name), clone(node.typeParameters), node.equals, node.abstractKeyword, clone(node.superclass), clone(node.withClause), clone(node.implementsClause), node.semicolon);
+ BreakStatement visitBreakStatement(BreakStatement node) => new BreakStatement.full(node.keyword, clone2(node.label), node.semicolon);
+ CascadeExpression visitCascadeExpression(CascadeExpression node) => new CascadeExpression.full(clone2(node.target), clone3(node.cascadeSections));
+ CatchClause visitCatchClause(CatchClause node) => new CatchClause.full(node.onKeyword, clone2(node.exceptionType), node.catchKeyword, node.leftParenthesis, clone2(node.exceptionParameter), node.comma, clone2(node.stackTraceParameter), node.rightParenthesis, clone2(node.body));
+ ClassDeclaration visitClassDeclaration(ClassDeclaration node) => new ClassDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), node.abstractKeyword, node.classKeyword, clone2(node.name), clone2(node.typeParameters), clone2(node.extendsClause), clone2(node.withClause), clone2(node.implementsClause), node.leftBracket, clone3(node.members), node.rightBracket);
+ ClassTypeAlias visitClassTypeAlias(ClassTypeAlias node) => new ClassTypeAlias.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.name), clone2(node.typeParameters), node.equals, node.abstractKeyword, clone2(node.superclass), clone2(node.withClause), clone2(node.implementsClause), node.semicolon);
Comment visitComment(Comment node) {
if (node.isDocumentation()) {
- return Comment.createDocumentationComment2(node.tokens, clone2(node.references));
+ return Comment.createDocumentationComment2(node.tokens, clone3(node.references));
} else if (node.isBlock()) {
return Comment.createBlockComment(node.tokens);
}
return Comment.createEndOfLineComment(node.tokens);
}
- CommentReference visitCommentReference(CommentReference node) => new CommentReference.full(node.newKeyword, clone(node.identifier));
+ CommentReference visitCommentReference(CommentReference node) => new CommentReference.full(node.newKeyword, clone2(node.identifier));
CompilationUnit visitCompilationUnit(CompilationUnit node) {
- CompilationUnit clone22 = new CompilationUnit.full(node.beginToken, clone(node.scriptTag), clone2(node.directives), clone2(node.declarations), node.endToken);
- clone22.lineInfo = node.lineInfo;
- clone22.parsingErrors = node.parsingErrors;
- clone22.resolutionErrors = node.resolutionErrors;
- return clone22;
+ CompilationUnit clone = new CompilationUnit.full(node.beginToken, clone2(node.scriptTag), clone3(node.directives), clone3(node.declarations), node.endToken);
+ clone.lineInfo = node.lineInfo;
+ clone.parsingErrors = node.parsingErrors;
+ clone.resolutionErrors = node.resolutionErrors;
+ return clone;
}
- ConditionalExpression visitConditionalExpression(ConditionalExpression node) => new ConditionalExpression.full(clone(node.condition), node.question, clone(node.thenExpression), node.colon, clone(node.elseExpression));
- ConstructorDeclaration visitConstructorDeclaration(ConstructorDeclaration node) => new ConstructorDeclaration.full(clone(node.documentationComment), clone2(node.metadata), node.externalKeyword, node.constKeyword, node.factoryKeyword, clone(node.returnType), node.period, clone(node.name), clone(node.parameters), node.separator, clone2(node.initializers), clone(node.redirectedConstructor), clone(node.body));
- ConstructorFieldInitializer visitConstructorFieldInitializer(ConstructorFieldInitializer node) => new ConstructorFieldInitializer.full(node.keyword, node.period, clone(node.fieldName), node.equals, clone(node.expression));
- ConstructorName visitConstructorName(ConstructorName node) => new ConstructorName.full(clone(node.type), node.period, clone(node.name));
- ContinueStatement visitContinueStatement(ContinueStatement node) => new ContinueStatement.full(node.keyword, clone(node.label), node.semicolon);
- DeclaredIdentifier visitDeclaredIdentifier(DeclaredIdentifier node) => new DeclaredIdentifier.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.type), clone(node.identifier));
- DefaultFormalParameter visitDefaultFormalParameter(DefaultFormalParameter node) => new DefaultFormalParameter.full(clone(node.parameter), node.kind, node.separator, clone(node.defaultValue));
- DoStatement visitDoStatement(DoStatement node) => new DoStatement.full(node.doKeyword, clone(node.body), node.whileKeyword, node.leftParenthesis, clone(node.condition), node.rightParenthesis, node.semicolon);
+ ConditionalExpression visitConditionalExpression(ConditionalExpression node) => new ConditionalExpression.full(clone2(node.condition), node.question, clone2(node.thenExpression), node.colon, clone2(node.elseExpression));
+ ConstructorDeclaration visitConstructorDeclaration(ConstructorDeclaration node) => new ConstructorDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), node.externalKeyword, node.constKeyword, node.factoryKeyword, clone2(node.returnType), node.period, clone2(node.name), clone2(node.parameters), node.separator, clone3(node.initializers), clone2(node.redirectedConstructor), clone2(node.body));
+ ConstructorFieldInitializer visitConstructorFieldInitializer(ConstructorFieldInitializer node) => new ConstructorFieldInitializer.full(node.keyword, node.period, clone2(node.fieldName), node.equals, clone2(node.expression));
+ ConstructorName visitConstructorName(ConstructorName node) => new ConstructorName.full(clone2(node.type), node.period, clone2(node.name));
+ ContinueStatement visitContinueStatement(ContinueStatement node) => new ContinueStatement.full(node.keyword, clone2(node.label), node.semicolon);
+ DeclaredIdentifier visitDeclaredIdentifier(DeclaredIdentifier node) => new DeclaredIdentifier.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.type), clone2(node.identifier));
+ DefaultFormalParameter visitDefaultFormalParameter(DefaultFormalParameter node) => new DefaultFormalParameter.full(clone2(node.parameter), node.kind, node.separator, clone2(node.defaultValue));
+ DoStatement visitDoStatement(DoStatement node) => new DoStatement.full(node.doKeyword, clone2(node.body), node.whileKeyword, node.leftParenthesis, clone2(node.condition), node.rightParenthesis, node.semicolon);
DoubleLiteral visitDoubleLiteral(DoubleLiteral node) => new DoubleLiteral.full(node.literal, node.value);
EmptyFunctionBody visitEmptyFunctionBody(EmptyFunctionBody node) => new EmptyFunctionBody.full(node.semicolon);
EmptyStatement visitEmptyStatement(EmptyStatement node) => new EmptyStatement.full(node.semicolon);
- ExportDirective visitExportDirective(ExportDirective node) => new ExportDirective.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.uri), clone2(node.combinators), node.semicolon);
- ExpressionFunctionBody visitExpressionFunctionBody(ExpressionFunctionBody node) => new ExpressionFunctionBody.full(node.functionDefinition, clone(node.expression), node.semicolon);
- ExpressionStatement visitExpressionStatement(ExpressionStatement node) => new ExpressionStatement.full(clone(node.expression), node.semicolon);
- ExtendsClause visitExtendsClause(ExtendsClause node) => new ExtendsClause.full(node.keyword, clone(node.superclass));
- FieldDeclaration visitFieldDeclaration(FieldDeclaration node) => new FieldDeclaration.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.fields), node.semicolon);
- FieldFormalParameter visitFieldFormalParameter(FieldFormalParameter node) => new FieldFormalParameter.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.type), node.thisToken, node.period, clone(node.identifier));
- ForEachStatement visitForEachStatement(ForEachStatement node) => new ForEachStatement.full(node.forKeyword, node.leftParenthesis, clone(node.loopVariable), node.inKeyword, clone(node.iterator), node.rightParenthesis, clone(node.body));
- FormalParameterList visitFormalParameterList(FormalParameterList node) => new FormalParameterList.full(node.leftParenthesis, clone2(node.parameters), node.leftDelimiter, node.rightDelimiter, node.rightParenthesis);
- ForStatement visitForStatement(ForStatement node) => new ForStatement.full(node.forKeyword, node.leftParenthesis, clone(node.variables), clone(node.initialization), node.leftSeparator, clone(node.condition), node.rightSeparator, clone2(node.updaters), node.rightParenthesis, clone(node.body));
- FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) => new FunctionDeclaration.full(clone(node.documentationComment), clone2(node.metadata), node.externalKeyword, clone(node.returnType), node.propertyKeyword, clone(node.name), clone(node.functionExpression));
- FunctionDeclarationStatement visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => new FunctionDeclarationStatement.full(clone(node.functionDeclaration));
- FunctionExpression visitFunctionExpression(FunctionExpression node) => new FunctionExpression.full(clone(node.parameters), clone(node.body));
- FunctionExpressionInvocation visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => new FunctionExpressionInvocation.full(clone(node.function), clone(node.argumentList));
- FunctionTypeAlias visitFunctionTypeAlias(FunctionTypeAlias node) => new FunctionTypeAlias.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.returnType), clone(node.name), clone(node.typeParameters), clone(node.parameters), node.semicolon);
- FunctionTypedFormalParameter visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => new FunctionTypedFormalParameter.full(clone(node.documentationComment), clone2(node.metadata), clone(node.returnType), clone(node.identifier), clone(node.parameters));
- HideCombinator visitHideCombinator(HideCombinator node) => new HideCombinator.full(node.keyword, clone2(node.hiddenNames));
- IfStatement visitIfStatement(IfStatement node) => new IfStatement.full(node.ifKeyword, node.leftParenthesis, clone(node.condition), node.rightParenthesis, clone(node.thenStatement), node.elseKeyword, clone(node.elseStatement));
- ImplementsClause visitImplementsClause(ImplementsClause node) => new ImplementsClause.full(node.keyword, clone2(node.interfaces));
- ImportDirective visitImportDirective(ImportDirective node) => new ImportDirective.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.uri), node.asToken, clone(node.prefix), clone2(node.combinators), node.semicolon);
+ ExportDirective visitExportDirective(ExportDirective node) => new ExportDirective.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.uri), clone3(node.combinators), node.semicolon);
+ ExpressionFunctionBody visitExpressionFunctionBody(ExpressionFunctionBody node) => new ExpressionFunctionBody.full(node.functionDefinition, clone2(node.expression), node.semicolon);
+ ExpressionStatement visitExpressionStatement(ExpressionStatement node) => new ExpressionStatement.full(clone2(node.expression), node.semicolon);
+ ExtendsClause visitExtendsClause(ExtendsClause node) => new ExtendsClause.full(node.keyword, clone2(node.superclass));
+ FieldDeclaration visitFieldDeclaration(FieldDeclaration node) => new FieldDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.fields), node.semicolon);
+ FieldFormalParameter visitFieldFormalParameter(FieldFormalParameter node) => new FieldFormalParameter.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.type), node.thisToken, node.period, clone2(node.identifier));
+ ForEachStatement visitForEachStatement(ForEachStatement node) => new ForEachStatement.full(node.forKeyword, node.leftParenthesis, clone2(node.loopVariable), node.inKeyword, clone2(node.iterator), node.rightParenthesis, clone2(node.body));
+ FormalParameterList visitFormalParameterList(FormalParameterList node) => new FormalParameterList.full(node.leftParenthesis, clone3(node.parameters), node.leftDelimiter, node.rightDelimiter, node.rightParenthesis);
+ ForStatement visitForStatement(ForStatement node) => new ForStatement.full(node.forKeyword, node.leftParenthesis, clone2(node.variables), clone2(node.initialization), node.leftSeparator, clone2(node.condition), node.rightSeparator, clone3(node.updaters), node.rightParenthesis, clone2(node.body));
+ FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) => new FunctionDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), node.externalKeyword, clone2(node.returnType), node.propertyKeyword, clone2(node.name), clone2(node.functionExpression));
+ FunctionDeclarationStatement visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => new FunctionDeclarationStatement.full(clone2(node.functionDeclaration));
+ FunctionExpression visitFunctionExpression(FunctionExpression node) => new FunctionExpression.full(clone2(node.parameters), clone2(node.body));
+ FunctionExpressionInvocation visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => new FunctionExpressionInvocation.full(clone2(node.function), clone2(node.argumentList));
+ FunctionTypeAlias visitFunctionTypeAlias(FunctionTypeAlias node) => new FunctionTypeAlias.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.returnType), clone2(node.name), clone2(node.typeParameters), clone2(node.parameters), node.semicolon);
+ FunctionTypedFormalParameter visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => new FunctionTypedFormalParameter.full(clone2(node.documentationComment), clone3(node.metadata), clone2(node.returnType), clone2(node.identifier), clone2(node.parameters));
+ HideCombinator visitHideCombinator(HideCombinator node) => new HideCombinator.full(node.keyword, clone3(node.hiddenNames));
+ IfStatement visitIfStatement(IfStatement node) => new IfStatement.full(node.ifKeyword, node.leftParenthesis, clone2(node.condition), node.rightParenthesis, clone2(node.thenStatement), node.elseKeyword, clone2(node.elseStatement));
+ ImplementsClause visitImplementsClause(ImplementsClause node) => new ImplementsClause.full(node.keyword, clone3(node.interfaces));
+ ImportDirective visitImportDirective(ImportDirective node) => new ImportDirective.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.uri), node.asToken, clone2(node.prefix), clone3(node.combinators), node.semicolon);
IndexExpression visitIndexExpression(IndexExpression node) {
Token period2 = node.period;
if (period2 == null) {
- return new IndexExpression.forTarget_full(clone(node.array), node.leftBracket, clone(node.index), node.rightBracket);
+ return new IndexExpression.forTarget_full(clone2(node.array), node.leftBracket, clone2(node.index), node.rightBracket);
} else {
- return new IndexExpression.forCascade_full(period2, node.leftBracket, clone(node.index), node.rightBracket);
+ return new IndexExpression.forCascade_full(period2, node.leftBracket, clone2(node.index), node.rightBracket);
}
}
- InstanceCreationExpression visitInstanceCreationExpression(InstanceCreationExpression node) => new InstanceCreationExpression.full(node.keyword, clone(node.constructorName), clone(node.argumentList));
+ InstanceCreationExpression visitInstanceCreationExpression(InstanceCreationExpression node) => new InstanceCreationExpression.full(node.keyword, clone2(node.constructorName), clone2(node.argumentList));
IntegerLiteral visitIntegerLiteral(IntegerLiteral node) => new IntegerLiteral.full(node.literal, node.value);
- InterpolationExpression visitInterpolationExpression(InterpolationExpression node) => new InterpolationExpression.full(node.leftBracket, clone(node.expression), node.rightBracket);
+ InterpolationExpression visitInterpolationExpression(InterpolationExpression node) => new InterpolationExpression.full(node.leftBracket, clone2(node.expression), node.rightBracket);
InterpolationString visitInterpolationString(InterpolationString node) => new InterpolationString.full(node.contents, node.value);
- IsExpression visitIsExpression(IsExpression node) => new IsExpression.full(clone(node.expression), node.isOperator, node.notOperator, clone(node.type));
- Label visitLabel(Label node) => new Label.full(clone(node.label), node.colon);
- LabeledStatement visitLabeledStatement(LabeledStatement node) => new LabeledStatement.full(clone2(node.labels), clone(node.statement));
- LibraryDirective visitLibraryDirective(LibraryDirective node) => new LibraryDirective.full(clone(node.documentationComment), clone2(node.metadata), node.libraryToken, clone(node.name), node.semicolon);
- LibraryIdentifier visitLibraryIdentifier(LibraryIdentifier node) => new LibraryIdentifier.full(clone2(node.components));
- ListLiteral visitListLiteral(ListLiteral node) => new ListLiteral.full(node.modifier, clone(node.typeArguments), node.leftBracket, clone2(node.elements), node.rightBracket);
- MapLiteral visitMapLiteral(MapLiteral node) => new MapLiteral.full(node.modifier, clone(node.typeArguments), node.leftBracket, clone2(node.entries), node.rightBracket);
- MapLiteralEntry visitMapLiteralEntry(MapLiteralEntry node) => new MapLiteralEntry.full(clone(node.key), node.separator, clone(node.value));
- MethodDeclaration visitMethodDeclaration(MethodDeclaration node) => new MethodDeclaration.full(clone(node.documentationComment), clone2(node.metadata), node.externalKeyword, node.modifierKeyword, clone(node.returnType), node.propertyKeyword, node.operatorKeyword, clone(node.name), clone(node.parameters), clone(node.body));
- MethodInvocation visitMethodInvocation(MethodInvocation node) => new MethodInvocation.full(clone(node.target), node.period, clone(node.methodName), clone(node.argumentList));
- NamedExpression visitNamedExpression(NamedExpression node) => new NamedExpression.full(clone(node.name), clone(node.expression));
- NativeFunctionBody visitNativeFunctionBody(NativeFunctionBody node) => new NativeFunctionBody.full(node.nativeToken, clone(node.stringLiteral), node.semicolon);
+ IsExpression visitIsExpression(IsExpression node) => new IsExpression.full(clone2(node.expression), node.isOperator, node.notOperator, clone2(node.type));
+ Label visitLabel(Label node) => new Label.full(clone2(node.label), node.colon);
+ LabeledStatement visitLabeledStatement(LabeledStatement node) => new LabeledStatement.full(clone3(node.labels), clone2(node.statement));
+ LibraryDirective visitLibraryDirective(LibraryDirective node) => new LibraryDirective.full(clone2(node.documentationComment), clone3(node.metadata), node.libraryToken, clone2(node.name), node.semicolon);
+ LibraryIdentifier visitLibraryIdentifier(LibraryIdentifier node) => new LibraryIdentifier.full(clone3(node.components));
+ ListLiteral visitListLiteral(ListLiteral node) => new ListLiteral.full(node.modifier, clone2(node.typeArguments), node.leftBracket, clone3(node.elements), node.rightBracket);
+ MapLiteral visitMapLiteral(MapLiteral node) => new MapLiteral.full(node.modifier, clone2(node.typeArguments), node.leftBracket, clone3(node.entries), node.rightBracket);
+ MapLiteralEntry visitMapLiteralEntry(MapLiteralEntry node) => new MapLiteralEntry.full(clone2(node.key), node.separator, clone2(node.value));
+ MethodDeclaration visitMethodDeclaration(MethodDeclaration node) => new MethodDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), node.externalKeyword, node.modifierKeyword, clone2(node.returnType), node.propertyKeyword, node.operatorKeyword, clone2(node.name), clone2(node.parameters), clone2(node.body));
+ MethodInvocation visitMethodInvocation(MethodInvocation node) => new MethodInvocation.full(clone2(node.target), node.period, clone2(node.methodName), clone2(node.argumentList));
+ NamedExpression visitNamedExpression(NamedExpression node) => new NamedExpression.full(clone2(node.name), clone2(node.expression));
+ NativeFunctionBody visitNativeFunctionBody(NativeFunctionBody node) => new NativeFunctionBody.full(node.nativeToken, clone2(node.stringLiteral), node.semicolon);
NullLiteral visitNullLiteral(NullLiteral node) => new NullLiteral.full(node.literal);
- ParenthesizedExpression visitParenthesizedExpression(ParenthesizedExpression node) => new ParenthesizedExpression.full(node.leftParenthesis, clone(node.expression), node.rightParenthesis);
- PartDirective visitPartDirective(PartDirective node) => new PartDirective.full(clone(node.documentationComment), clone2(node.metadata), node.partToken, clone(node.uri), node.semicolon);
- PartOfDirective visitPartOfDirective(PartOfDirective node) => new PartOfDirective.full(clone(node.documentationComment), clone2(node.metadata), node.partToken, node.ofToken, clone(node.libraryName), node.semicolon);
- PostfixExpression visitPostfixExpression(PostfixExpression node) => new PostfixExpression.full(clone(node.operand), node.operator);
- PrefixedIdentifier visitPrefixedIdentifier(PrefixedIdentifier node) => new PrefixedIdentifier.full(clone(node.prefix), node.period, clone(node.identifier));
- PrefixExpression visitPrefixExpression(PrefixExpression node) => new PrefixExpression.full(node.operator, clone(node.operand));
- PropertyAccess visitPropertyAccess(PropertyAccess node) => new PropertyAccess.full(clone(node.target), node.operator, clone(node.propertyName));
- RedirectingConstructorInvocation visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) => new RedirectingConstructorInvocation.full(node.keyword, node.period, clone(node.constructorName), clone(node.argumentList));
+ ParenthesizedExpression visitParenthesizedExpression(ParenthesizedExpression node) => new ParenthesizedExpression.full(node.leftParenthesis, clone2(node.expression), node.rightParenthesis);
+ PartDirective visitPartDirective(PartDirective node) => new PartDirective.full(clone2(node.documentationComment), clone3(node.metadata), node.partToken, clone2(node.uri), node.semicolon);
+ PartOfDirective visitPartOfDirective(PartOfDirective node) => new PartOfDirective.full(clone2(node.documentationComment), clone3(node.metadata), node.partToken, node.ofToken, clone2(node.libraryName), node.semicolon);
+ PostfixExpression visitPostfixExpression(PostfixExpression node) => new PostfixExpression.full(clone2(node.operand), node.operator);
+ PrefixedIdentifier visitPrefixedIdentifier(PrefixedIdentifier node) => new PrefixedIdentifier.full(clone2(node.prefix), node.period, clone2(node.identifier));
+ PrefixExpression visitPrefixExpression(PrefixExpression node) => new PrefixExpression.full(node.operator, clone2(node.operand));
+ PropertyAccess visitPropertyAccess(PropertyAccess node) => new PropertyAccess.full(clone2(node.target), node.operator, clone2(node.propertyName));
+ RedirectingConstructorInvocation visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) => new RedirectingConstructorInvocation.full(node.keyword, node.period, clone2(node.constructorName), clone2(node.argumentList));
RethrowExpression visitRethrowExpression(RethrowExpression node) => new RethrowExpression.full(node.keyword);
- ReturnStatement visitReturnStatement(ReturnStatement node) => new ReturnStatement.full(node.keyword, clone(node.expression), node.semicolon);
+ ReturnStatement visitReturnStatement(ReturnStatement node) => new ReturnStatement.full(node.keyword, clone2(node.expression), node.semicolon);
ScriptTag visitScriptTag(ScriptTag node) => new ScriptTag.full(node.scriptTag);
- ShowCombinator visitShowCombinator(ShowCombinator node) => new ShowCombinator.full(node.keyword, clone2(node.shownNames));
- SimpleFormalParameter visitSimpleFormalParameter(SimpleFormalParameter node) => new SimpleFormalParameter.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.type), clone(node.identifier));
+ ShowCombinator visitShowCombinator(ShowCombinator node) => new ShowCombinator.full(node.keyword, clone3(node.shownNames));
+ SimpleFormalParameter visitSimpleFormalParameter(SimpleFormalParameter node) => new SimpleFormalParameter.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.type), clone2(node.identifier));
SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) => new SimpleIdentifier.full(node.token);
SimpleStringLiteral visitSimpleStringLiteral(SimpleStringLiteral node) => new SimpleStringLiteral.full(node.literal, node.value);
- StringInterpolation visitStringInterpolation(StringInterpolation node) => new StringInterpolation.full(clone2(node.elements));
- SuperConstructorInvocation visitSuperConstructorInvocation(SuperConstructorInvocation node) => new SuperConstructorInvocation.full(node.keyword, node.period, clone(node.constructorName), clone(node.argumentList));
+ StringInterpolation visitStringInterpolation(StringInterpolation node) => new StringInterpolation.full(clone3(node.elements));
+ SuperConstructorInvocation visitSuperConstructorInvocation(SuperConstructorInvocation node) => new SuperConstructorInvocation.full(node.keyword, node.period, clone2(node.constructorName), clone2(node.argumentList));
SuperExpression visitSuperExpression(SuperExpression node) => new SuperExpression.full(node.keyword);
- SwitchCase visitSwitchCase(SwitchCase node) => new SwitchCase.full(clone2(node.labels), node.keyword, clone(node.expression), node.colon, clone2(node.statements));
- SwitchDefault visitSwitchDefault(SwitchDefault node) => new SwitchDefault.full(clone2(node.labels), node.keyword, node.colon, clone2(node.statements));
- SwitchStatement visitSwitchStatement(SwitchStatement node) => new SwitchStatement.full(node.keyword, node.leftParenthesis, clone(node.expression), node.rightParenthesis, node.leftBracket, clone2(node.members), node.rightBracket);
+ SwitchCase visitSwitchCase(SwitchCase node) => new SwitchCase.full(clone3(node.labels), node.keyword, clone2(node.expression), node.colon, clone3(node.statements));
+ SwitchDefault visitSwitchDefault(SwitchDefault node) => new SwitchDefault.full(clone3(node.labels), node.keyword, node.colon, clone3(node.statements));
+ SwitchStatement visitSwitchStatement(SwitchStatement node) => new SwitchStatement.full(node.keyword, node.leftParenthesis, clone2(node.expression), node.rightParenthesis, node.leftBracket, clone3(node.members), node.rightBracket);
ThisExpression visitThisExpression(ThisExpression node) => new ThisExpression.full(node.keyword);
- ThrowExpression visitThrowExpression(ThrowExpression node) => new ThrowExpression.full(node.keyword, clone(node.expression));
- TopLevelVariableDeclaration visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => new TopLevelVariableDeclaration.full(clone(node.documentationComment), clone2(node.metadata), clone(node.variables), node.semicolon);
- TryStatement visitTryStatement(TryStatement node) => new TryStatement.full(node.tryKeyword, clone(node.body), clone2(node.catchClauses), node.finallyKeyword, clone(node.finallyClause));
- TypeArgumentList visitTypeArgumentList(TypeArgumentList node) => new TypeArgumentList.full(node.leftBracket, clone2(node.arguments), node.rightBracket);
- TypeName visitTypeName(TypeName node) => new TypeName.full(clone(node.name), clone(node.typeArguments));
- TypeParameter visitTypeParameter(TypeParameter node) => new TypeParameter.full(clone(node.documentationComment), clone2(node.metadata), clone(node.name), node.keyword, clone(node.bound));
- TypeParameterList visitTypeParameterList(TypeParameterList node) => new TypeParameterList.full(node.leftBracket, clone2(node.typeParameters), node.rightBracket);
- VariableDeclaration visitVariableDeclaration(VariableDeclaration node) => new VariableDeclaration.full(clone(node.documentationComment), clone2(node.metadata), clone(node.name), node.equals, clone(node.initializer));
- VariableDeclarationList visitVariableDeclarationList(VariableDeclarationList node) => new VariableDeclarationList.full(clone(node.documentationComment), clone2(node.metadata), node.keyword, clone(node.type), clone2(node.variables));
- VariableDeclarationStatement visitVariableDeclarationStatement(VariableDeclarationStatement node) => new VariableDeclarationStatement.full(clone(node.variables), node.semicolon);
- WhileStatement visitWhileStatement(WhileStatement node) => new WhileStatement.full(node.keyword, node.leftParenthesis, clone(node.condition), node.rightParenthesis, clone(node.body));
- WithClause visitWithClause(WithClause node) => new WithClause.full(node.withKeyword, clone2(node.mixinTypes));
- ASTNode clone(ASTNode node) {
+ ThrowExpression visitThrowExpression(ThrowExpression node) => new ThrowExpression.full(node.keyword, clone2(node.expression));
+ TopLevelVariableDeclaration visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => new TopLevelVariableDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), clone2(node.variables), node.semicolon);
+ TryStatement visitTryStatement(TryStatement node) => new TryStatement.full(node.tryKeyword, clone2(node.body), clone3(node.catchClauses), node.finallyKeyword, clone2(node.finallyClause));
+ TypeArgumentList visitTypeArgumentList(TypeArgumentList node) => new TypeArgumentList.full(node.leftBracket, clone3(node.arguments), node.rightBracket);
+ TypeName visitTypeName(TypeName node) => new TypeName.full(clone2(node.name), clone2(node.typeArguments));
+ TypeParameter visitTypeParameter(TypeParameter node) => new TypeParameter.full(clone2(node.documentationComment), clone3(node.metadata), clone2(node.name), node.keyword, clone2(node.bound));
+ TypeParameterList visitTypeParameterList(TypeParameterList node) => new TypeParameterList.full(node.leftBracket, clone3(node.typeParameters), node.rightBracket);
+ VariableDeclaration visitVariableDeclaration(VariableDeclaration node) => new VariableDeclaration.full(clone2(node.documentationComment), clone3(node.metadata), clone2(node.name), node.equals, clone2(node.initializer));
+ VariableDeclarationList visitVariableDeclarationList(VariableDeclarationList node) => new VariableDeclarationList.full(clone2(node.documentationComment), clone3(node.metadata), node.keyword, clone2(node.type), clone3(node.variables));
+ VariableDeclarationStatement visitVariableDeclarationStatement(VariableDeclarationStatement node) => new VariableDeclarationStatement.full(clone2(node.variables), node.semicolon);
+ WhileStatement visitWhileStatement(WhileStatement node) => new WhileStatement.full(node.keyword, node.leftParenthesis, clone2(node.condition), node.rightParenthesis, clone2(node.body));
+ WithClause visitWithClause(WithClause node) => new WithClause.full(node.withKeyword, clone3(node.mixinTypes));
+ ASTNode clone2(ASTNode node) {
if (node == null) {
return null;
}
return node.accept(this) as ASTNode;
}
- List clone2(NodeList nodes) {
+ List clone3(NodeList nodes) {
List clonedNodes = new List();
for (ASTNode node in nodes) {
clonedNodes.add((node.accept(this) as ASTNode));
diff --git a/pkg/analyzer_experimental/lib/src/generated/constant.dart b/pkg/analyzer_experimental/lib/src/generated/constant.dart
index 67dfbdb..8d86663 100644
--- a/pkg/analyzer_experimental/lib/src/generated/constant.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/constant.dart
@@ -96,7 +96,7 @@
List<AnalysisError> _errors;
/**
* Initialize a newly created result object with the given state. Clients should use one of the
- * factory methods: {@link #forErrors(AnalysisError[])} and {@link #forValue(Object)}.
+ * factory methods: {@link #forErrors(AnalysisError\[\])} and {@link #forValue(Object)}.
* @param value the value of the expression
* @param errors the errors that should be reported for the expression(s) that were evaluated
*/
@@ -632,9 +632,9 @@
* @param errorCode the error code for the error to be generated
*/
ErrorResult.con1(ASTNode node, ErrorCode errorCode) {
- _jtd_constructor_162_impl(node, errorCode);
+ _jtd_constructor_168_impl(node, errorCode);
}
- _jtd_constructor_162_impl(ASTNode node, ErrorCode errorCode) {
+ _jtd_constructor_168_impl(ASTNode node, ErrorCode errorCode) {
_errors.add(new ErrorResult_ErrorData(node, errorCode));
}
/**
@@ -644,9 +644,9 @@
* @param secondResult the second set of results being merged
*/
ErrorResult.con2(ErrorResult firstResult, ErrorResult secondResult) {
- _jtd_constructor_163_impl(firstResult, secondResult);
+ _jtd_constructor_169_impl(firstResult, secondResult);
}
- _jtd_constructor_163_impl(ErrorResult firstResult, ErrorResult secondResult) {
+ _jtd_constructor_169_impl(ErrorResult firstResult, ErrorResult secondResult) {
_errors.addAll(firstResult._errors);
_errors.addAll(secondResult._errors);
}
diff --git a/pkg/analyzer_experimental/lib/src/generated/element.dart b/pkg/analyzer_experimental/lib/src/generated/element.dart
index 0dd5369..3f0a671 100644
--- a/pkg/analyzer_experimental/lib/src/generated/element.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/element.dart
@@ -123,6 +123,22 @@
*/
bool isValidMixin();
/**
+ * Return the executable element representing the method, getter or setter that results from
+ * looking up the given member in this class with respect to the given library, or {@code null} if
+ * the look up fails. This method is used to determine what member the passed name is inherited
+ * from. The behavior of this method is defined by the Dart Language Specification in section
+ * 8.1.1: Let <i>C</i> be a class declared in library <i>L</i> with superclass <i>S</i> and let
+ * <i>C</i> declare an instance member <i>m</i>, and assume <i>S</i> declares an instance member
+ * </i>m'</i> with the same name as m. Then <i>m</i> overrides m'</i> iff <i>m'</i> is accessible
+ * to <i>L</i>, <i>m</i> has the same name as <i>m'</i> and neither <i>m</i> nor <i>m'</i> are
+ * fields.
+ * @param memberName the name of the member being looked up
+ * @param library the library with respect to which the lookup is being performed
+ * @return the result of looking up the given member in this class with respect to the given
+ * library
+ */
+ ExecutableElement lookUpExecutable(String memberName, 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 {@code null} if the look up fails. The
* behavior of this method is defined by the Dart Language Specification in section 12.15.1:
@@ -283,6 +299,16 @@
*/
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 {@code 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
+ */
+ String computeDocumentationComment();
+ /**
* Return the element of the given class that most immediately encloses this element, or{@code 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
@@ -397,11 +423,31 @@
final String __name;
final int __ordinal;
int get ordinal => __ordinal;
+ /**
+ * Return the kind of the given element, or {@link #ERROR} if the element is {@code 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
+ */
+ static ElementKind of(Element element) {
+ if (element == null) {
+ return ERROR;
+ }
+ return element.kind;
+ }
+ /**
+ * The name displayed in the UI for this kind of element.
+ */
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
+ */
ElementKind(this.__name, this.__ordinal, String displayName) {
this._displayName = displayName;
}
/**
+ * Return the name displayed in the UI for this kind of element.
* @return the name of this {@link ElementKind} to display in UI.
*/
String get displayName => _displayName;
@@ -1354,6 +1400,21 @@
}
List<ConstructorElement> get constructors => _constructors;
/**
+ * Return the executable elemement representing the getter, setter or method with the given name
+ * that is declared in this class, or {@code null} if this class does not declare a member with
+ * the given name.
+ * @param memberName the name of the getter to be returned
+ * @return the member declared in this class with the given name
+ */
+ ExecutableElement getExecutable(String memberName) {
+ for (PropertyAccessorElement accessor in _accessors) {
+ if (accessor.name == memberName) {
+ return accessor;
+ }
+ }
+ return getMethod(memberName);
+ }
+ /**
* Given some name, this returns the {@link FieldElement} with the matching name, if there is no
* such field, then {@code null} is returned.
* @param name some name to lookup a field element with
@@ -1438,6 +1499,29 @@
bool isAbstract() => hasModifier(Modifier.ABSTRACT);
bool isTypedef() => hasModifier(Modifier.TYPEDEF);
bool isValidMixin() => hasModifier(Modifier.MIXIN);
+ ExecutableElement lookUpExecutable(String memberName, LibraryElement library) {
+ ExecutableElement element = getExecutable(memberName);
+ if (element != null && element.isAccessibleIn(library)) {
+ return element;
+ }
+ for (InterfaceType mixin in _mixins) {
+ ClassElement mixinElement = mixin.element;
+ if (mixinElement != null) {
+ ClassElementImpl mixinElementImpl = mixinElement as ClassElementImpl;
+ element = mixinElementImpl.getExecutable(memberName);
+ if (element != null && element.isAccessibleIn(library)) {
+ return element;
+ }
+ }
+ }
+ if (_supertype != null) {
+ ClassElement supertypeElement = _supertype.element;
+ if (supertypeElement != null) {
+ return supertypeElement.lookUpExecutable(memberName, library);
+ }
+ }
+ return null;
+ }
PropertyAccessorElement lookUpGetter(String getterName, LibraryElement library) {
PropertyAccessorElement element = getGetter(getterName);
if (element != null && element.isAccessibleIn(library)) {
@@ -1455,10 +1539,7 @@
if (_supertype != null) {
ClassElement supertypeElement = _supertype.element;
if (supertypeElement != null) {
- element = supertypeElement.lookUpGetter(getterName, library);
- if (element != null && element.isAccessibleIn(library)) {
- return element;
- }
+ return supertypeElement.lookUpGetter(getterName, library);
}
}
return null;
@@ -1480,10 +1561,7 @@
if (_supertype != null) {
ClassElement supertypeElement = _supertype.element;
if (supertypeElement != null) {
- element = supertypeElement.lookUpMethod(methodName, library);
- if (element != null && element.isAccessibleIn(library)) {
- return element;
- }
+ return supertypeElement.lookUpMethod(methodName, library);
}
}
return null;
@@ -1505,10 +1583,7 @@
if (_supertype != null) {
ClassElement supertypeElement = _supertype.element;
if (supertypeElement != null) {
- element = supertypeElement.lookUpSetter(setterName, library);
- if (element != null && element.isAccessibleIn(library)) {
- return element;
- }
+ return supertypeElement.lookUpSetter(setterName, library);
}
}
return null;
@@ -2021,10 +2096,10 @@
* @param name the name of this element
*/
ElementImpl.con1(Identifier name2) {
- _jtd_constructor_188_impl(name2);
+ _jtd_constructor_189_impl(name2);
}
- _jtd_constructor_188_impl(Identifier name2) {
- _jtd_constructor_189_impl(name2 == null ? "" : name2.name, name2 == null ? -1 : name2.offset);
+ _jtd_constructor_189_impl(Identifier name2) {
+ _jtd_constructor_190_impl(name2 == null ? "" : name2.name, name2 == null ? -1 : name2.offset);
}
/**
* Initialize a newly created element to have the given name.
@@ -2033,12 +2108,19 @@
* declaration of this element
*/
ElementImpl.con2(String name2, int nameOffset2) {
- _jtd_constructor_189_impl(name2, nameOffset2);
+ _jtd_constructor_190_impl(name2, nameOffset2);
}
- _jtd_constructor_189_impl(String name2, int nameOffset2) {
+ _jtd_constructor_190_impl(String name2, int nameOffset2) {
this._name = StringUtilities.intern(name2);
this._nameOffset = nameOffset2;
}
+ String computeDocumentationComment() {
+ AnalysisContext context2 = context;
+ if (context2 == null) {
+ return null;
+ }
+ return context2.computeDocumentationComment(this);
+ }
bool operator ==(Object object) => object != null && object.runtimeType == runtimeType && ((object as Element)).location == location;
Element getAncestor(Type elementClass) {
Element ancestor = _enclosingElement;
@@ -2208,9 +2290,9 @@
* @param element the element whose location is being represented
*/
ElementLocationImpl.con1(Element element) {
- _jtd_constructor_190_impl(element);
+ _jtd_constructor_191_impl(element);
}
- _jtd_constructor_190_impl(Element element) {
+ _jtd_constructor_191_impl(Element element) {
List<String> components = new List<String>();
Element ancestor = element;
while (ancestor != null) {
@@ -2224,9 +2306,9 @@
* @param encoding the encoded form of a location
*/
ElementLocationImpl.con2(String encoding) {
- _jtd_constructor_191_impl(encoding);
+ _jtd_constructor_192_impl(encoding);
}
- _jtd_constructor_191_impl(String encoding) {
+ _jtd_constructor_192_impl(String encoding) {
this._components = decode(encoding);
}
bool operator ==(Object object) {
@@ -2365,9 +2447,9 @@
* @param name the name of this element
*/
ExecutableElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_193_impl(name);
+ _jtd_constructor_194_impl(name);
}
- _jtd_constructor_193_impl(Identifier name) {
+ _jtd_constructor_194_impl(Identifier name) {
}
/**
* Initialize a newly created executable element to have the given name.
@@ -2376,9 +2458,9 @@
* declaration of this element
*/
ExecutableElementImpl.con2(String name, int nameOffset) : super.con2(name, nameOffset) {
- _jtd_constructor_194_impl(name, nameOffset);
+ _jtd_constructor_195_impl(name, nameOffset);
}
- _jtd_constructor_194_impl(String name, int nameOffset) {
+ _jtd_constructor_195_impl(String name, int nameOffset) {
}
ElementImpl getChild(String identifier2) {
for (ExecutableElement function in _functions) {
@@ -2522,6 +2604,7 @@
builder.append("export ");
((_exportedLibrary as LibraryElementImpl)).appendTo(builder);
}
+ String get identifier => _exportedLibrary.name;
}
/**
* Instances of the class {@code ExternalHtmlScriptElementImpl} implement an{@link ExternalHtmlScriptElement}.
@@ -2563,18 +2646,18 @@
* @param name the name of this element
*/
FieldElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_197_impl(name);
+ _jtd_constructor_198_impl(name);
}
- _jtd_constructor_197_impl(Identifier name) {
+ _jtd_constructor_198_impl(Identifier name) {
}
/**
* Initialize a newly created synthetic field element to have the given name.
* @param name the name of this element
*/
FieldElementImpl.con2(String name) : super.con2(name) {
- _jtd_constructor_198_impl(name);
+ _jtd_constructor_199_impl(name);
}
- _jtd_constructor_198_impl(String name) {
+ _jtd_constructor_199_impl(String name) {
}
accept(ElementVisitor visitor) => visitor.visitFieldElement(this);
ClassElement get enclosingElement => super.enclosingElement as ClassElement;
@@ -2635,9 +2718,9 @@
* Initialize a newly created synthetic function element.
*/
FunctionElementImpl() : super.con2("", -1) {
- _jtd_constructor_200_impl();
+ _jtd_constructor_201_impl();
}
- _jtd_constructor_200_impl() {
+ _jtd_constructor_201_impl() {
synthetic = true;
}
/**
@@ -2645,9 +2728,9 @@
* @param name the name of this element
*/
FunctionElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_201_impl(name);
+ _jtd_constructor_202_impl(name);
}
- _jtd_constructor_201_impl(Identifier name) {
+ _jtd_constructor_202_impl(Identifier name) {
}
/**
* Initialize a newly created function element to have no name and the given offset. This is used
@@ -2656,9 +2739,9 @@
* declaration of this element
*/
FunctionElementImpl.con2(int nameOffset) : super.con2("", nameOffset) {
- _jtd_constructor_202_impl(nameOffset);
+ _jtd_constructor_203_impl(nameOffset);
}
- _jtd_constructor_202_impl(int nameOffset) {
+ _jtd_constructor_203_impl(int nameOffset) {
}
accept(ElementVisitor visitor) => visitor.visitFunctionElement(this);
String get identifier => name;
@@ -2979,6 +3062,7 @@
builder.append("import ");
((_importedLibrary as LibraryElementImpl)).appendTo(builder);
}
+ String get identifier => "${_importedLibrary.name}:${(_prefix == null ? "" : _prefix.name)}";
}
/**
* Instances of the class {@code LabelElementImpl} implement a {@code LabelElement}.
@@ -3103,6 +3187,16 @@
return part as CompilationUnitElementImpl;
}
}
+ for (ImportElement importElement in _imports) {
+ if (((importElement as ImportElementImpl)).identifier == identifier2) {
+ return importElement as ImportElementImpl;
+ }
+ }
+ for (ExportElement exportElement in _exports) {
+ if (((exportElement as ExportElementImpl)).identifier == identifier2) {
+ return exportElement as ExportElementImpl;
+ }
+ }
return null;
}
AnalysisContext get context => _context;
@@ -3317,9 +3411,9 @@
* @param name the name of this element
*/
MethodElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_211_impl(name);
+ _jtd_constructor_212_impl(name);
}
- _jtd_constructor_211_impl(Identifier name) {
+ _jtd_constructor_212_impl(Identifier name) {
}
/**
* Initialize a newly created method element to have the given name.
@@ -3328,9 +3422,9 @@
* declaration of this element
*/
MethodElementImpl.con2(String name, int nameOffset) : super.con2(name, nameOffset) {
- _jtd_constructor_212_impl(name, nameOffset);
+ _jtd_constructor_213_impl(name, nameOffset);
}
- _jtd_constructor_212_impl(String name, int nameOffset) {
+ _jtd_constructor_213_impl(String name, int nameOffset) {
}
accept(ElementVisitor visitor) => visitor.visitMethodElement(this);
ClassElement get enclosingElement => super.enclosingElement as ClassElement;
@@ -3421,6 +3515,7 @@
_conflictingElements = computeConflictingElements(firstElement, secondElement);
}
accept(ElementVisitor visitor) => visitor.visitMultiplyDefinedElement(this);
+ String computeDocumentationComment() => null;
Element getAncestor(Type elementClass) => null;
List<Element> get conflictingElements => _conflictingElements;
AnalysisContext get context => _context;
@@ -3645,9 +3740,9 @@
* @param name the name of this element
*/
PropertyAccessorElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_217_impl(name);
+ _jtd_constructor_218_impl(name);
}
- _jtd_constructor_217_impl(Identifier name) {
+ _jtd_constructor_218_impl(Identifier name) {
}
/**
* Initialize a newly created synthetic property accessor element to be associated with the given
@@ -3655,9 +3750,9 @@
* @param variable the variable with which this access is associated
*/
PropertyAccessorElementImpl.con2(PropertyInducingElementImpl variable2) : super.con2(variable2.name, -1) {
- _jtd_constructor_218_impl(variable2);
+ _jtd_constructor_219_impl(variable2);
}
- _jtd_constructor_218_impl(PropertyInducingElementImpl variable2) {
+ _jtd_constructor_219_impl(PropertyInducingElementImpl variable2) {
this._variable = variable2;
synthetic = true;
}
@@ -3722,18 +3817,18 @@
* @param name the name of this element
*/
PropertyInducingElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_219_impl(name);
+ _jtd_constructor_220_impl(name);
}
- _jtd_constructor_219_impl(Identifier name) {
+ _jtd_constructor_220_impl(Identifier name) {
}
/**
* Initialize a newly created synthetic element to have the given name.
* @param name the name of this element
*/
PropertyInducingElementImpl.con2(String name) : super.con2(name, -1) {
- _jtd_constructor_220_impl(name);
+ _jtd_constructor_221_impl(name);
}
- _jtd_constructor_220_impl(String name) {
+ _jtd_constructor_221_impl(String name) {
synthetic = true;
}
PropertyAccessorElement get getter => _getter;
@@ -3804,18 +3899,18 @@
* @param name the name of this element
*/
TopLevelVariableElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_222_impl(name);
+ _jtd_constructor_223_impl(name);
}
- _jtd_constructor_222_impl(Identifier name) {
+ _jtd_constructor_223_impl(Identifier name) {
}
/**
* Initialize a newly created synthetic top-level variable element to have the given name.
* @param name the name of this element
*/
TopLevelVariableElementImpl.con2(String name) : super.con2(name) {
- _jtd_constructor_223_impl(name);
+ _jtd_constructor_224_impl(name);
}
- _jtd_constructor_223_impl(String name) {
+ _jtd_constructor_224_impl(String name) {
}
accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this);
ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE;
@@ -3894,9 +3989,9 @@
* @param name the name of this element
*/
VariableElementImpl.con1(Identifier name) : super.con1(name) {
- _jtd_constructor_225_impl(name);
+ _jtd_constructor_226_impl(name);
}
- _jtd_constructor_225_impl(Identifier name) {
+ _jtd_constructor_226_impl(Identifier name) {
}
/**
* Initialize a newly created variable element to have the given name.
@@ -3905,9 +4000,9 @@
* declaration of this element
*/
VariableElementImpl.con2(String name, int nameOffset) : super.con2(name, nameOffset) {
- _jtd_constructor_226_impl(name, nameOffset);
+ _jtd_constructor_227_impl(name, nameOffset);
}
- _jtd_constructor_226_impl(String name, int nameOffset) {
+ _jtd_constructor_227_impl(String name, int nameOffset) {
}
/**
* Return the result of evaluating this variable's initializer as a compile-time constant
@@ -4081,6 +4176,7 @@
this._baseElement = baseElement;
this._definingType = definingType;
}
+ String computeDocumentationComment() => _baseElement.computeDocumentationComment();
Element getAncestor(Type elementClass) => baseElement.getAncestor(elementClass);
/**
* Return the element on which the parameterized element was created.
@@ -4512,9 +4608,9 @@
* @param element the element representing the declaration of the function type
*/
FunctionTypeImpl.con1(ExecutableElement element) : super(element, element == null ? null : element.name) {
- _jtd_constructor_290_impl(element);
+ _jtd_constructor_291_impl(element);
}
- _jtd_constructor_290_impl(ExecutableElement element) {
+ _jtd_constructor_291_impl(ExecutableElement element) {
}
/**
* Initialize a newly created function type to be declared by the given element and to have the
@@ -4522,9 +4618,9 @@
* @param element the element representing the declaration of the function type
*/
FunctionTypeImpl.con2(FunctionTypeAliasElement element) : super(element, element == null ? null : element.name) {
- _jtd_constructor_291_impl(element);
+ _jtd_constructor_292_impl(element);
}
- _jtd_constructor_291_impl(FunctionTypeAliasElement element) {
+ _jtd_constructor_292_impl(FunctionTypeAliasElement element) {
}
bool operator ==(Object object) {
if (object is! FunctionTypeImpl) {
@@ -4805,6 +4901,59 @@
return set;
}
/**
+ * Return the intersection of the given sets of types, where intersection is based on the equality
+ * of the elements of the types rather than on the equality of the types themselves. In cases
+ * where two non-equal types have equal elements, which only happens when the class is
+ * parameterized, the type that is added to the intersection is the base type with type arguments
+ * that are the least upper bound of the type arguments of the two types.
+ * @param first the first set of types to be intersected
+ * @param second the second set of types to be intersected
+ * @return the intersection of the given sets of types
+ */
+ static List<InterfaceType> intersection(Set<InterfaceType> first, Set<InterfaceType> second) {
+ Map<ClassElement, InterfaceType> firstMap = new Map<ClassElement, InterfaceType>();
+ for (InterfaceType firstType in first) {
+ firstMap[firstType.element] = firstType;
+ }
+ Set<InterfaceType> result = new Set<InterfaceType>();
+ for (InterfaceType secondType in second) {
+ InterfaceType firstType = firstMap[secondType.element];
+ if (firstType != null) {
+ javaSetAdd(result, leastUpperBound(firstType, secondType));
+ }
+ }
+ return new List.from(result);
+ }
+ /**
+ * Return the "least upper bound" of the given types under the assumption that the types have the
+ * same element and differ only in terms of the type arguments. The resulting type is composed by
+ * using the least upper bound of the corresponding type arguments.
+ * @param firstType the first type
+ * @param secondType the second type
+ * @return the "least upper bound" of the given types
+ */
+ static InterfaceType leastUpperBound(InterfaceType firstType, InterfaceType secondType) {
+ if (firstType == secondType) {
+ return firstType;
+ }
+ List<Type2> firstArguments = firstType.typeArguments;
+ List<Type2> secondArguments = secondType.typeArguments;
+ int argumentCount = firstArguments.length;
+ if (argumentCount == 0) {
+ return firstType;
+ }
+ List<Type2> lubArguments = new List<Type2>(argumentCount);
+ for (int i = 0; i < argumentCount; i++) {
+ lubArguments[i] = firstArguments[i].getLeastUpperBound(secondArguments[i]);
+ if (lubArguments[i] == null) {
+ lubArguments[i] = DynamicTypeImpl.instance;
+ }
+ }
+ InterfaceTypeImpl lub = new InterfaceTypeImpl.con1(firstType.element);
+ lub.typeArguments = lubArguments;
+ return lub;
+ }
+ /**
* An array containing the actual types of the type arguments.
*/
List<Type2> _typeArguments = TypeImpl.EMPTY_ARRAY;
@@ -4813,9 +4962,9 @@
* @param element the element representing the declaration of the type
*/
InterfaceTypeImpl.con1(ClassElement element) : super(element, element.name) {
- _jtd_constructor_292_impl(element);
+ _jtd_constructor_293_impl(element);
}
- _jtd_constructor_292_impl(ClassElement element) {
+ _jtd_constructor_293_impl(ClassElement element) {
}
/**
* Initialize a newly created type to have the given name. This constructor should only be used in
@@ -4823,9 +4972,9 @@
* @param name the name of the type
*/
InterfaceTypeImpl.con2(String name) : super(null, name) {
- _jtd_constructor_293_impl(name);
+ _jtd_constructor_294_impl(name);
}
- _jtd_constructor_293_impl(String name) {
+ _jtd_constructor_294_impl(String name) {
}
bool operator ==(Object object) {
if (object is! InterfaceTypeImpl) {
@@ -4850,27 +4999,25 @@
}
return typedInterfaces;
}
- Type2 getLeastUpperBound(Type2 type2) {
+ Type2 getLeastUpperBound(Type2 type) {
Type2 dynamicType = DynamicTypeImpl.instance;
- if (identical(this, dynamicType) || identical(type2, dynamicType)) {
+ if (identical(this, dynamicType) || identical(type, dynamicType)) {
return dynamicType;
}
- if (type2 == null || type2 is! InterfaceType) {
+ if (type is! InterfaceType) {
return null;
}
InterfaceType i = this;
- InterfaceType j = type2 as InterfaceType;
+ InterfaceType j = type as InterfaceType;
Set<InterfaceType> si = computeSuperinterfaceSet(i);
Set<InterfaceType> sj = computeSuperinterfaceSet(j);
- javaSetAdd(si, i.element.type);
- javaSetAdd(sj, j.element.type);
- si.retainAll(sj);
- Set<InterfaceType> s = si;
- List<InterfaceType> sn = new List.from(s);
- List<int> depths = new List<int>.filled(sn.length, 0);
+ javaSetAdd(si, i);
+ javaSetAdd(sj, j);
+ List<InterfaceType> s = intersection(si, sj);
+ List<int> depths = new List<int>.filled(s.length, 0);
int maxDepth = 0;
- for (int n = 0; n < sn.length; n++) {
- depths[n] = computeLongestInheritancePathToObject(sn[n]);
+ for (int n = 0; n < s.length; n++) {
+ depths[n] = computeLongestInheritancePathToObject(s[n]);
if (depths[n] > maxDepth) {
maxDepth = depths[n];
}
@@ -4885,7 +5032,7 @@
}
}
if (numberOfTypesAtMaxDepth == 1) {
- return sn[indexOfLeastUpperBound];
+ return s[indexOfLeastUpperBound];
}
}
return null;
@@ -5052,6 +5199,12 @@
if (element != null && element.isAccessibleIn(library)) {
return element;
}
+ for (InterfaceType mixin in supertype.mixins) {
+ element = mixin.getGetter(getterName);
+ if (element != null && element.isAccessibleIn(library)) {
+ return element;
+ }
+ }
supertype = supertype.superclass;
}
return null;
@@ -5073,6 +5226,12 @@
if (element != null && element.isAccessibleIn(library)) {
return element;
}
+ for (InterfaceType mixin in supertype.mixins) {
+ element = mixin.getMethod(methodName);
+ if (element != null && element.isAccessibleIn(library)) {
+ return element;
+ }
+ }
supertype = supertype.superclass;
}
return null;
@@ -5094,6 +5253,12 @@
if (element != null && element.isAccessibleIn(library)) {
return element;
}
+ for (InterfaceType mixin in supertype.mixins) {
+ element = mixin.getSetter(setterName);
+ if (element != null && element.isAccessibleIn(library)) {
+ return element;
+ }
+ }
supertype = supertype.superclass;
}
return null;
@@ -5281,7 +5446,7 @@
* <li>The types of functions that only have required parameters. These have the general form
* <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>.</li>
* <li>The types of functions with optional positional parameters. These have the general form
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub>n+k</sub>]) →
+ * <i>(T<sub>1</sub>, …, T<sub>n</sub>, \[T<sub>n+1</sub>, …, T<sub>n+k</sub>\]) →
* T</i>.</li>
* <li>The types of functions with named positional parameters. These have the general form
* <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, T<sub>xk</sub> xk})
@@ -5341,9 +5506,9 @@
* </li>
* <li>For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<sub>i</sub></i>.</li>
* </ul>
- * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …,
- * T<sub>n+k</sub>]) → T</i> is a subtype of the function type <i>(S<sub>1</sub>, …,
- * S<sub>n</sub>, [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>, if all of the
+ * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, \[T<sub>n+1</sub>, …,
+ * T<sub>n+k</sub>\]) → T</i> is a subtype of the function type <i>(S<sub>1</sub>, …,
+ * S<sub>n</sub>, \[S<sub>n+1</sub>, …, S<sub>n+m</sub>\]) → S</i>, if all of the
* following conditions are met:
* <ul>
* <li>Either
@@ -5374,14 +5539,14 @@
* </ul>
* In addition, the following subtype rules apply:
* <p>
- * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>, …,
+ * <i>(T<sub>1</sub>, …, T<sub>n</sub>, \[\]) → T <: (T<sub>1</sub>, …,
* T<sub>n</sub>) → T.</i><br>
* <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, …,
* T<sub>n</sub>, {}) → T.</i><br>
* <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>, …,
* T<sub>n</sub>) → T.</i><br>
* <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, …,
- * T<sub>n</sub>, []) → T.</i>
+ * T<sub>n</sub>, \[\]) → T.</i>
* <p>
* All functions implement the class {@code Function}. However not all function types are a
* subtype of {@code Function}. If an interface type <i>I</i> includes a method named{@code call()}, and the type of {@code call()} is the function type <i>F</i>, then <i>I</i> is
@@ -5512,7 +5677,7 @@
/**
* Return {@code 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> « <i>S</i> (<i>T</i> is more specific than <i>S</i>). If an
+ * <i>\[bottom/dynamic\]T</i> « <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
@@ -5660,7 +5825,7 @@
/**
* Return the type resulting from substituting the given arguments for the given parameters in
* this type. The specification defines this operation in section 2: <blockquote> The notation
- * <i>[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ..., y<sub>n</sub>]E</i> denotes a copy of
+ * <i>\[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ..., y<sub>n</sub>\]E</i> denotes a copy of
* <i>E</i> in which all occurrences of <i>y<sub>i</sub>, 1 <= i <= n</i> have been replaced with
* <i>x<sub>i</sub></i>.</blockquote> Note that, contrary to the specification, this method will
* not create a copy of this type if no substitutions were required, but will return this type
diff --git a/pkg/analyzer_experimental/lib/src/generated/engine.dart b/pkg/analyzer_experimental/lib/src/generated/engine.dart
index 66f945b..fca4fef 100644
--- a/pkg/analyzer_experimental/lib/src/generated/engine.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/engine.dart
@@ -143,6 +143,17 @@
*/
void applyChanges(ChangeSet changeSet);
/**
+ * Return the documentation comment for the given element as it appears in the original source
+ * (complete with the beginning and ending delimiters), or {@code null} if the 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.
+ * @param element the element whose documentation comment is to be returned
+ * @return the element's documentation comment
+ * @throws AnalysisException if the documentation comment could not be determined because the
+ * analysis could not be performed
+ */
+ String computeDocumentationComment(Element element);
+ /**
* Return an array containing all of the errors associated with the given source. If the errors
* are not already known then the source will be analyzed in order to determine the errors
* associated with it.
@@ -602,6 +613,989 @@
}
}
/**
+ * The interface {@code DartEntry} defines the behavior of objects that maintain the information
+ * cached by an analysis context about an individual Dart file.
+ * @coverage dart.engine
+ */
+abstract class DartEntry implements SourceEntry {
+ /**
+ * The data descriptor representing the library element for the library. This data is only
+ * available for Dart files that are the defining compilation unit of a library.
+ */
+ static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElement>("DartEntry.ELEMENT");
+ /**
+ * The data descriptor representing the list of included parts. This data is only available for
+ * Dart files that are the defining compilation unit of a library.
+ */
+ static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<Source>>("DartEntry.INCLUDED_PARTS");
+ /**
+ * The data descriptor representing the client flag. This data is only available for Dart files
+ * that are the defining compilation unit of a library.
+ */
+ static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS_CLIENT");
+ /**
+ * The data descriptor representing the launchable flag. This data is only available for Dart
+ * files that are the defining compilation unit of a library.
+ */
+ static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE");
+ /**
+ * The data descriptor representing the errors resulting from parsing the source.
+ */
+ static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<List<AnalysisError>>("DartEntry.PARSE_ERRORS");
+ /**
+ * The data descriptor representing the parsed AST structure.
+ */
+ static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT");
+ /**
+ * The data descriptor representing the public namespace of the library. This data is only
+ * available for Dart files that are the defining compilation unit of a library.
+ */
+ static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE");
+ /**
+ * The data descriptor representing the errors resulting from resolving the source.
+ */
+ static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescriptor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS");
+ /**
+ * The data descriptor representing the resolved AST structure.
+ */
+ static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT");
+ /**
+ * The data descriptor representing the source kind.
+ */
+ static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind>("DartEntry.SOURCE_KIND");
+ /**
+ * Return all of the errors associated with the compilation unit that are currently cached.
+ * @return all of the errors associated with the compilation unit
+ */
+ List<AnalysisError> get allErrors;
+ /**
+ * Return a valid parsed compilation unit, either an unresolved AST structure or the result of
+ * resolving the AST structure in the context of some library, or {@code null} if there is no
+ * parsed compilation unit available.
+ * @return a valid parsed compilation unit
+ */
+ CompilationUnit get anyParsedCompilationUnit;
+ /**
+ * Return the result of resolving the compilation unit as part of any library, or {@code null} if
+ * there is no cached resolved compilation unit.
+ * @return any resolved compilation unit
+ */
+ CompilationUnit get anyResolvedCompilationUnit;
+ /**
+ * Return the state of the data represented by the given descriptor in the context of the given
+ * library.
+ * @param descriptor the descriptor representing the data whose state is to be returned
+ * @param librarySource the source of the defining compilation unit of the library that is the
+ * context for the data
+ * @return the value of the data represented by the given descriptor and library
+ */
+ CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource);
+ /**
+ * Return the value of the data represented by the given descriptor in the context of the given
+ * library, or {@code null} if the data represented by the descriptor is not in the cache.
+ * @param descriptor the descriptor representing which data is to be returned
+ * @param librarySource the source of the defining compilation unit of the library that is the
+ * context for the data
+ * @return the value of the data represented by the given descriptor and library
+ */
+ Object getValue2(DataDescriptor descriptor, Source librarySource);
+ DartEntryImpl get writableCopy;
+}
+/**
+ * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}.
+ * @coverage dart.engine
+ */
+class DartEntryImpl extends SourceEntryImpl implements DartEntry {
+ /**
+ * The state of the cached source kind.
+ */
+ CacheState _sourceKindState = CacheState.INVALID;
+ /**
+ * The kind of this source.
+ */
+ SourceKind _sourceKind = SourceKind.UNKNOWN;
+ /**
+ * The state of the cached parsed compilation unit.
+ */
+ CacheState _parsedUnitState = CacheState.INVALID;
+ /**
+ * The parsed compilation unit, or {@code null} if the parsed compilation unit is not currently
+ * cached.
+ */
+ CompilationUnit _parsedUnit;
+ /**
+ * The state of the cached parse errors.
+ */
+ CacheState _parseErrorsState = CacheState.INVALID;
+ /**
+ * The errors produced while scanning and parsing the compilation unit, or {@code null} if the
+ * errors are not currently cached.
+ */
+ List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
+ /**
+ * The state of the cached list of included parts.
+ */
+ CacheState _includedPartsState = CacheState.INVALID;
+ /**
+ * The list of parts included in the library, or {@code null} if the list is not currently cached.
+ * The list will be empty if the Dart file is a part rather than a library.
+ */
+ List<Source> _includedParts = Source.EMPTY_ARRAY;
+ /**
+ * The source for the defining compilation unit of the library that contains this unit, or{@code null} if this unit is contained in multiple libraries. (If this unit is the defining
+ * compilation unit for it's library, then this will be the source for this unit.)
+ */
+ Source _librarySource;
+ /**
+ * The information known as a result of resolving this compilation unit as part of the library
+ * that contains this unit, or {@code null} if this unit is contained in multiple libraries.
+ */
+ DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionState();
+ /**
+ * A table mapping the sources of the libraries containing this compilation unit to the
+ * information known as a result of resolving this compilation unit as part of the library, or{@code null} if this unit is contained in a single library.
+ */
+ Map<Source, DartEntryImpl_ResolutionState> _resolutionMap;
+ /**
+ * The state of the cached library element.
+ */
+ CacheState _elementState = CacheState.INVALID;
+ /**
+ * The element representing the library, or {@code null} if the element is not currently cached.
+ */
+ LibraryElement _element;
+ /**
+ * The state of the cached public namespace.
+ */
+ CacheState _publicNamespaceState = CacheState.INVALID;
+ /**
+ * The public namespace of the library, or {@code null} if the namespace is not currently cached.
+ */
+ Namespace _publicNamespace;
+ /**
+ * The state of the cached client/ server flag.
+ */
+ CacheState _clientServerState = CacheState.INVALID;
+ /**
+ * The state of the cached launchable flag.
+ */
+ CacheState _launchableState = CacheState.INVALID;
+ /**
+ * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT_CODE}.
+ */
+ int _bitmask = 0;
+ /**
+ * Mask indicating that this library is launchable: that the file has a main method.
+ */
+ static int _LAUNCHABLE = 1 << 1;
+ /**
+ * Mask indicating that the library is client code: that the library depends on the html library.
+ * If the library is not "client code", then it is referenced as "server code".
+ */
+ static int _CLIENT_CODE = 1 << 2;
+ /**
+ * Initialize a newly created cache entry to be empty.
+ */
+ DartEntryImpl() : super() {
+ }
+ /**
+ * Record the fact that we are about to parse the compilation unit by marking the results of
+ * parsing as being in progress.
+ */
+ void aboutToParse() {
+ setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS);
+ _parsedUnitState = CacheState.IN_PROCESS;
+ _parseErrorsState = CacheState.IN_PROCESS;
+ }
+ List<AnalysisError> get allErrors {
+ List<AnalysisError> errors = new List<AnalysisError>();
+ for (AnalysisError error in _parseErrors) {
+ errors.add(error);
+ }
+ if (_resolutionMap == null) {
+ for (AnalysisError error in _resolutionState._resolutionErrors) {
+ errors.add(error);
+ }
+ } else {
+ for (DartEntryImpl_ResolutionState state in _resolutionMap.values) {
+ for (AnalysisError error in state._resolutionErrors) {
+ errors.add(error);
+ }
+ }
+ }
+ if (errors.length == 0) {
+ return AnalysisError.NO_ERRORS;
+ }
+ return new List.from(errors);
+ }
+ CompilationUnit get anyParsedCompilationUnit {
+ if (identical(_parsedUnitState, CacheState.VALID)) {
+ return _parsedUnit;
+ }
+ if (_resolutionMap == null) {
+ return _resolutionState._resolvedUnit;
+ } else {
+ for (DartEntryImpl_ResolutionState state in _resolutionMap.values) {
+ if (identical(state._resolvedUnitState, CacheState.VALID)) {
+ return state._resolvedUnit;
+ }
+ }
+ }
+ return null;
+ }
+ CompilationUnit get anyResolvedCompilationUnit {
+ for (DartEntryImpl_ResolutionState state in _resolutionMap.values) {
+ if (identical(state._resolvedUnitState, CacheState.VALID)) {
+ return state._resolvedUnit;
+ }
+ }
+ return null;
+ }
+ SourceKind get kind => _sourceKind;
+ CacheState getState(DataDescriptor<Object> descriptor) {
+ if (identical(descriptor, DartEntry.ELEMENT)) {
+ return _elementState;
+ } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
+ return _includedPartsState;
+ } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
+ return _clientServerState;
+ } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
+ return _launchableState;
+ } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
+ return _parseErrorsState;
+ } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
+ return _parsedUnitState;
+ } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
+ return _publicNamespaceState;
+ } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
+ return _sourceKindState;
+ } else {
+ return super.getState(descriptor);
+ }
+ }
+ CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource) {
+ if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
+ if (_resolutionMap == null) {
+ return _resolutionState._resolutionErrorsState;
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource];
+ if (state != null) {
+ return state._resolutionErrorsState;
+ }
+ }
+ } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
+ if (_resolutionMap == null) {
+ return _resolutionState._resolvedUnitState;
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource];
+ if (state != null) {
+ return state._resolvedUnitState;
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ return CacheState.INVALID;
+ }
+ Object getValue(DataDescriptor descriptor) {
+ if (identical(descriptor, DartEntry.ELEMENT)) {
+ return _element as Object;
+ } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
+ return _includedParts as Object;
+ } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
+ return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object;
+ } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
+ return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object;
+ } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
+ return _parseErrors as Object;
+ } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
+ return _parsedUnit as Object;
+ } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
+ return _publicNamespace as Object;
+ } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
+ return _sourceKind as Object;
+ }
+ return super.getValue(descriptor);
+ }
+ Object getValue2(DataDescriptor descriptor, Source librarySource2) {
+ if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
+ if (_resolutionMap == null) {
+ if (librarySource2 == this._librarySource) {
+ return _resolutionState._resolutionErrors as Object;
+ } else {
+ return AnalysisError.NO_ERRORS as Object;
+ }
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2];
+ if (state != null) {
+ return state._resolutionErrors as Object;
+ }
+ }
+ } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
+ if (_resolutionMap == null) {
+ if (librarySource2 == this._librarySource) {
+ return _resolutionState._resolvedUnit as Object;
+ } else {
+ return null;
+ }
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2];
+ if (state != null) {
+ return state._resolvedUnit as Object;
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ return null;
+ }
+ DartEntryImpl get writableCopy {
+ DartEntryImpl copy = new DartEntryImpl();
+ copy.copyFrom(this);
+ return copy;
+ }
+ /**
+ * Invalidate all of the resolution information associated with the compilation unit.
+ */
+ void invalidateAllResolutionInformation() {
+ if (_resolutionMap == null) {
+ _resolutionState.invalidateAllResolutionInformation();
+ } else {
+ for (DartEntryImpl_ResolutionState state in _resolutionMap.values) {
+ state.invalidateAllResolutionInformation();
+ }
+ }
+ _elementState = CacheState.INVALID;
+ _element = null;
+ _publicNamespaceState = CacheState.INVALID;
+ _publicNamespace = null;
+ _launchableState = CacheState.INVALID;
+ _clientServerState = CacheState.INVALID;
+ _bitmask = 0;
+ }
+ /**
+ * Remove any resolution information associated with this compilation unit being part of the given
+ * library, presumably because it is no longer part of the library.
+ * @param librarySource the source of the defining compilation unit of the library that used to
+ * contain this part but no longer does
+ */
+ void removeResolution(Source librarySource2) {
+ if (_resolutionMap == null) {
+ if (librarySource2 == this._librarySource) {
+ _resolutionState.invalidateAllResolutionInformation();
+ this._librarySource = null;
+ }
+ } else {
+ _resolutionMap.remove(librarySource2);
+ if (_resolutionMap.length == 1) {
+ MapEntry<Source, DartEntryImpl_ResolutionState> entry = new JavaIterator(getMapEntrySet(_resolutionMap)).next();
+ this._librarySource = entry.getKey();
+ _resolutionState = entry.getValue();
+ _resolutionMap = null;
+ }
+ }
+ }
+ /**
+ * Set the results of parsing the compilation unit at the given time to the given values.
+ * @param modificationStamp the earliest time at which the source was last modified before the
+ * parsing was started
+ * @param lineInfo the line information resulting from parsing the compilation unit
+ * @param unit the AST structure resulting from parsing the compilation unit
+ * @param errors the parse errors resulting from parsing the compilation unit
+ */
+ void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit unit, List<AnalysisError> errors) {
+ if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
+ setValue(SourceEntry.LINE_INFO, lineInfo);
+ }
+ if (_parsedUnitState != CacheState.VALID) {
+ _parsedUnit = unit;
+ }
+ if (_parseErrorsState != CacheState.VALID) {
+ _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors;
+ }
+ }
+ void setState(DataDescriptor<Object> descriptor, CacheState state) {
+ if (identical(descriptor, DartEntry.ELEMENT)) {
+ _element = updatedValue(state, _element, null);
+ _elementState = state;
+ } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
+ _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY);
+ _includedPartsState = state;
+ } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
+ _bitmask = updatedValue2(state, _bitmask, _CLIENT_CODE);
+ _clientServerState = state;
+ } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
+ _bitmask = updatedValue2(state, _bitmask, _LAUNCHABLE);
+ _launchableState = state;
+ } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
+ _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS);
+ _parseErrorsState = state;
+ } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
+ _parsedUnit = updatedValue(state, _parsedUnit, null);
+ _parsedUnitState = state;
+ } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
+ _publicNamespace = updatedValue(state, _publicNamespace, null);
+ _publicNamespaceState = state;
+ } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
+ _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN);
+ _sourceKindState = state;
+ } else {
+ super.setState(descriptor, state);
+ }
+ }
+ /**
+ * Set the state of the data represented by the given descriptor in the context of the given
+ * library to the given state.
+ * @param descriptor the descriptor representing the data whose state is to be set
+ * @param librarySource the source of the defining compilation unit of the library that is the
+ * context for the data
+ * @param state the new state of the data represented by the given descriptor
+ */
+ void setState2(DataDescriptor<Object> descriptor, Source librarySource2, CacheState state) {
+ if (_resolutionMap == null && this._librarySource != librarySource2) {
+ _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>();
+ _resolutionMap[this._librarySource] = _resolutionState;
+ this._librarySource = null;
+ _resolutionState = null;
+ }
+ if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
+ if (_resolutionMap == null) {
+ _resolutionState._resolutionErrors = updatedValue(state, _resolutionState._resolutionErrors, AnalysisError.NO_ERRORS);
+ _resolutionState._resolutionErrorsState = state;
+ } else {
+ DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySource2];
+ if (resolutionState == null) {
+ resolutionState = new DartEntryImpl_ResolutionState();
+ _resolutionMap[librarySource2] = resolutionState;
+ }
+ resolutionState._resolutionErrors = updatedValue(state, resolutionState._resolutionErrors, AnalysisError.NO_ERRORS);
+ resolutionState._resolutionErrorsState = state;
+ }
+ } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
+ if (_resolutionMap == null) {
+ _resolutionState._resolvedUnit = updatedValue(state, _resolutionState._resolvedUnit, null);
+ _resolutionState._resolvedUnitState = state;
+ } else {
+ DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySource2];
+ if (resolutionState == null) {
+ resolutionState = new DartEntryImpl_ResolutionState();
+ _resolutionMap[librarySource2] = resolutionState;
+ }
+ resolutionState._resolvedUnit = updatedValue(state, resolutionState._resolvedUnit, null);
+ resolutionState._resolvedUnitState = state;
+ }
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ }
+ void setValue(DataDescriptor descriptor, Object value) {
+ if (identical(descriptor, DartEntry.ELEMENT)) {
+ _element = value as LibraryElement;
+ _elementState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
+ _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Source>);
+ _includedPartsState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
+ if (((value as bool))) {
+ _bitmask |= _CLIENT_CODE;
+ } else {
+ _bitmask &= ~_CLIENT_CODE;
+ }
+ _clientServerState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
+ if (((value as bool))) {
+ _bitmask |= _LAUNCHABLE;
+ } else {
+ _bitmask &= ~_LAUNCHABLE;
+ }
+ _launchableState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
+ _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
+ _parseErrorsState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
+ _parsedUnit = value as CompilationUnit;
+ _parsedUnitState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
+ _publicNamespace = value as Namespace;
+ _publicNamespaceState = CacheState.VALID;
+ } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
+ _sourceKind = value as SourceKind;
+ _sourceKindState = CacheState.VALID;
+ } else {
+ super.setValue(descriptor, value);
+ }
+ }
+ /**
+ * Set the value of the data represented by the given descriptor in the context of the given
+ * library to the given value, and set the state of that data to {@link CacheState#VALID}.
+ * @param descriptor the descriptor representing which data is to have its value set
+ * @param librarySource the source of the defining compilation unit of the library that is the
+ * context for the data
+ * @param value the new value of the data represented by the given descriptor and library
+ */
+ void setValue2(DataDescriptor descriptor, Source librarySource2, Object value) {
+ if (_resolutionMap == null) {
+ if (this._librarySource == null) {
+ this._librarySource = librarySource2;
+ } else if (librarySource2 != this._librarySource) {
+ _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>();
+ _resolutionMap[this._librarySource] = _resolutionState;
+ this._librarySource = null;
+ _resolutionState = null;
+ }
+ }
+ if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
+ if (_resolutionMap == null) {
+ _resolutionState._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
+ _resolutionState._resolutionErrorsState = CacheState.VALID;
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2];
+ if (state != null) {
+ state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
+ state._resolutionErrorsState = CacheState.VALID;
+ }
+ }
+ } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
+ if (_resolutionMap == null) {
+ _resolutionState._resolvedUnit = value as CompilationUnit;
+ _resolutionState._resolvedUnitState = CacheState.VALID;
+ } else {
+ DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2];
+ if (state != null) {
+ state._resolvedUnit = value as CompilationUnit;
+ state._resolvedUnitState = CacheState.VALID;
+ }
+ }
+ }
+ }
+ void copyFrom(SourceEntryImpl entry) {
+ super.copyFrom(entry);
+ DartEntryImpl other = entry as DartEntryImpl;
+ _sourceKindState = other._sourceKindState;
+ _sourceKind = other._sourceKind;
+ _parsedUnitState = other._parsedUnitState;
+ _parsedUnit = other._parsedUnit;
+ _parseErrorsState = other._parseErrorsState;
+ _parseErrors = other._parseErrors;
+ _includedPartsState = other._includedPartsState;
+ _includedParts = other._includedParts;
+ if (other._resolutionMap == null) {
+ _librarySource = other._librarySource;
+ DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionState();
+ newState.copyFrom(_resolutionState);
+ _resolutionState = newState;
+ } else {
+ _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>();
+ for (MapEntry<Source, DartEntryImpl_ResolutionState> mapEntry in getMapEntrySet(other._resolutionMap)) {
+ DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionState();
+ newState.copyFrom(mapEntry.getValue());
+ _resolutionMap[mapEntry.getKey()] = newState;
+ }
+ }
+ _elementState = other._elementState;
+ _element = other._element;
+ _publicNamespaceState = other._publicNamespaceState;
+ _publicNamespace = other._publicNamespace;
+ _clientServerState = other._clientServerState;
+ _launchableState = other._launchableState;
+ _bitmask = other._bitmask;
+ }
+ /**
+ * Given that one of the flags is being transitioned to the given state, return the value of the
+ * flags that should be kept in the cache.
+ * @param state the state to which the data is being transitioned
+ * @param currentValue the value of the flags before the transition
+ * @param bitMask the mask used to access the bit whose state is being set
+ * @return the value of the data that should be kept in the cache
+ */
+ int updatedValue2(CacheState state, int currentValue, int bitMask) {
+ if (identical(state, CacheState.VALID)) {
+ throw new IllegalArgumentException("Use setValue() to set the state to VALID");
+ } else if (identical(state, CacheState.IN_PROCESS)) {
+ return currentValue;
+ }
+ return currentValue &= ~bitMask;
+ }
+}
+/**
+ * Instances of the class {@code ResolutionState} represent the information produced by resolving
+ * a compilation unit as part of a specific library.
+ */
+class DartEntryImpl_ResolutionState {
+ /**
+ * The state of the cached resolved compilation unit.
+ */
+ CacheState _resolvedUnitState = CacheState.INVALID;
+ /**
+ * The resolved compilation unit, or {@code null} if the resolved compilation unit is not
+ * currently cached.
+ */
+ CompilationUnit _resolvedUnit;
+ /**
+ * The state of the cached resolution errors.
+ */
+ CacheState _resolutionErrorsState = CacheState.INVALID;
+ /**
+ * The errors produced while resolving the compilation unit, or {@code null} if the errors are
+ * not currently cached.
+ */
+ List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
+ /**
+ * Initialize a newly created resolution state.
+ */
+ DartEntryImpl_ResolutionState() : super() {
+ }
+ /**
+ * Set this state to be exactly like the given state.
+ * @param other the state to be copied
+ */
+ void copyFrom(DartEntryImpl_ResolutionState other) {
+ _resolvedUnitState = other._resolvedUnitState;
+ _resolvedUnit = other._resolvedUnit;
+ _resolutionErrorsState = other._resolutionErrorsState;
+ _resolutionErrors = other._resolutionErrors;
+ }
+ /**
+ * Invalidate all of the resolution information associated with the compilation unit.
+ */
+ void invalidateAllResolutionInformation() {
+ _resolvedUnitState = CacheState.INVALID;
+ _resolvedUnit = null;
+ _resolutionErrorsState = CacheState.INVALID;
+ _resolutionErrors = AnalysisError.NO_ERRORS;
+ }
+}
+/**
+ * Instances of the class {@code DataDescriptor} are immutable constants representing data that can
+ * be stored in the cache.
+ */
+class DataDescriptor<E> {
+ /**
+ * The name of the descriptor, used for debugging purposes.
+ */
+ String _name;
+ /**
+ * Initialize a newly created descriptor to have the given name.
+ * @param name the name of the descriptor
+ */
+ DataDescriptor(String name) {
+ this._name = name;
+ }
+ String toString() => _name;
+}
+/**
+ * The interface {@code HtmlEntry} defines the behavior of objects that maintain the information
+ * cached by an analysis context about an individual HTML file.
+ * @coverage dart.engine
+ */
+abstract class HtmlEntry implements SourceEntry {
+ /**
+ * The data descriptor representing the HTML element.
+ */
+ static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT");
+ /**
+ * The data descriptor representing the parsed AST structure.
+ */
+ static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("HtmlEntry.PARSED_UNIT");
+ /**
+ * The data descriptor representing the list of referenced libraries.
+ */
+ static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES");
+ /**
+ * The data descriptor representing the errors resulting from resolving the source.
+ */
+ static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
+ /**
+ * The data descriptor representing the resolved AST structure.
+ */
+ static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>("HtmlEntry.RESOLVED_UNIT");
+ HtmlEntryImpl get writableCopy;
+}
+/**
+ * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}.
+ * @coverage dart.engine
+ */
+class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
+ /**
+ * The state of the cached parsed (but not resolved) HTML unit.
+ */
+ CacheState _parsedUnitState = CacheState.INVALID;
+ /**
+ * The parsed HTML unit, or {@code null} if the parsed HTML unit is not currently cached.
+ */
+ HtmlUnit _parsedUnit;
+ /**
+ * The state of the cached resolution errors.
+ */
+ CacheState _resolutionErrorsState = CacheState.INVALID;
+ /**
+ * The errors produced while resolving the compilation unit, or {@code null} if the errors are not
+ * currently cached.
+ */
+ List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
+ /**
+ * The state of the cached parsed and resolved HTML unit.
+ */
+ CacheState _resolvedUnitState = CacheState.INVALID;
+ /**
+ * The resolved HTML unit, or {@code null} if the resolved HTML unit is not currently cached.
+ */
+ HtmlUnit _resolvedUnit;
+ /**
+ * The state of the cached list of referenced libraries.
+ */
+ CacheState _referencedLibrariesState = CacheState.INVALID;
+ /**
+ * The list of libraries referenced in the HTML, or {@code null} if the list is not currently
+ * cached. Note that this list does not include libraries defined directly within the HTML file.
+ */
+ List<Source> _referencedLibraries = Source.EMPTY_ARRAY;
+ /**
+ * The state of the cached HTML element.
+ */
+ CacheState _elementState = CacheState.INVALID;
+ /**
+ * The element representing the HTML file, or {@code null} if the element is not currently cached.
+ */
+ HtmlElement _element;
+ /**
+ * Initialize a newly created cache entry to be empty.
+ */
+ HtmlEntryImpl() : super() {
+ }
+ SourceKind get kind => SourceKind.HTML;
+ CacheState getState(DataDescriptor<Object> descriptor) {
+ if (identical(descriptor, HtmlEntry.ELEMENT)) {
+ return _elementState;
+ } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
+ return _parsedUnitState;
+ } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
+ return _referencedLibrariesState;
+ } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
+ return _resolutionErrorsState;
+ } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
+ return _resolvedUnitState;
+ }
+ return super.getState(descriptor);
+ }
+ Object getValue(DataDescriptor descriptor) {
+ if (identical(descriptor, HtmlEntry.ELEMENT)) {
+ return _element as Object;
+ } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
+ return _parsedUnit as Object;
+ } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
+ return _referencedLibraries as Object;
+ } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
+ return _resolutionErrors as Object;
+ } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
+ return _resolvedUnit as Object;
+ }
+ return super.getValue(descriptor);
+ }
+ HtmlEntryImpl get writableCopy {
+ HtmlEntryImpl copy = new HtmlEntryImpl();
+ copy.copyFrom(this);
+ return copy;
+ }
+ void setState(DataDescriptor<Object> descriptor, CacheState state) {
+ if (identical(descriptor, HtmlEntry.ELEMENT)) {
+ _element = updatedValue(state, _element, null);
+ _elementState = state;
+ } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
+ _parsedUnit = updatedValue(state, _parsedUnit, null);
+ _parsedUnitState = state;
+ } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
+ _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EMPTY_ARRAY);
+ _referencedLibrariesState = state;
+ } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
+ _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.NO_ERRORS);
+ _resolutionErrorsState = state;
+ } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
+ _resolvedUnit = updatedValue(state, _resolvedUnit, null);
+ _resolvedUnitState = state;
+ } else {
+ super.setState(descriptor, state);
+ }
+ }
+ void setValue(DataDescriptor descriptor, Object value) {
+ if (identical(descriptor, HtmlEntry.ELEMENT)) {
+ _element = value as HtmlElement;
+ _elementState = CacheState.VALID;
+ } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
+ _parsedUnit = value as HtmlUnit;
+ _parsedUnitState = CacheState.VALID;
+ } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
+ _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<Source>);
+ _referencedLibrariesState = CacheState.VALID;
+ } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
+ _resolutionErrors = value as List<AnalysisError>;
+ _resolutionErrorsState = CacheState.VALID;
+ } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
+ _resolvedUnit = value as HtmlUnit;
+ _resolvedUnitState = CacheState.VALID;
+ } else {
+ super.setValue(descriptor, value);
+ }
+ }
+ void copyFrom(SourceEntryImpl entry) {
+ super.copyFrom(entry);
+ HtmlEntryImpl other = entry as HtmlEntryImpl;
+ _parsedUnitState = other._parsedUnitState;
+ _parsedUnit = other._parsedUnit;
+ _referencedLibrariesState = other._referencedLibrariesState;
+ _referencedLibraries = other._referencedLibraries;
+ _resolutionErrors = other._resolutionErrors;
+ _resolutionErrorsState = other._resolutionErrorsState;
+ _resolvedUnitState = other._resolvedUnitState;
+ _resolvedUnit = other._resolvedUnit;
+ _elementState = other._elementState;
+ _element = other._element;
+ }
+}
+/**
+ * The interface {@code SourceEntry} defines the behavior of objects that maintain the information
+ * cached by an analysis context about an individual source, no matter what kind of source it is.
+ * <p>
+ * Source entries should be treated as if they were immutable unless a writable copy of the entry
+ * has been obtained and has not yet been made visible to other threads.
+ * @coverage dart.engine
+ */
+abstract class SourceEntry {
+ /**
+ * The data descriptor representing the line information.
+ */
+ static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO");
+ /**
+ * Return the kind of the source, or {@code null} if the kind is not currently cached.
+ * @return the kind of the source
+ */
+ SourceKind get kind;
+ /**
+ * Return the most recent time at which the state of the source matched the state represented by
+ * this entry.
+ * @return the modification time of this entry
+ */
+ int get modificationTime;
+ /**
+ * Return the state of the data represented by the given descriptor.
+ * @param descriptor the descriptor representing the data whose state is to be returned
+ * @return the state of the data represented by the given descriptor
+ */
+ CacheState getState(DataDescriptor<Object> descriptor);
+ /**
+ * Return the value of the data represented by the given descriptor, or {@code null} if the data
+ * represented by the descriptor is not in the cache.
+ * @param descriptor the descriptor representing which data is to be returned
+ * @return the value of the data represented by the given descriptor
+ */
+ Object getValue(DataDescriptor descriptor);
+ /**
+ * Return a new entry that is initialized to the same state as this entry but that can be
+ * modified.
+ * @return a writable copy of this entry
+ */
+ SourceEntryImpl get writableCopy;
+}
+/**
+ * Instances of the abstract class {@code SourceEntryImpl} implement the behavior common to all{@link SourceEntry source entries}.
+ * @coverage dart.engine
+ */
+abstract class SourceEntryImpl implements SourceEntry {
+ /**
+ * The most recent time at which the state of the source matched the state represented by this
+ * entry.
+ */
+ int _modificationTime = 0;
+ /**
+ * The state of the cached line information.
+ */
+ CacheState _lineInfoState = CacheState.INVALID;
+ /**
+ * The line information computed for the source, or {@code null} if the line information is not
+ * currently cached.
+ */
+ LineInfo _lineInfo;
+ /**
+ * Initialize a newly created cache entry to be empty.
+ */
+ SourceEntryImpl() : super() {
+ }
+ int get modificationTime => _modificationTime;
+ CacheState getState(DataDescriptor<Object> descriptor) {
+ if (identical(descriptor, SourceEntry.LINE_INFO)) {
+ return _lineInfoState;
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ }
+ Object getValue(DataDescriptor descriptor) {
+ if (identical(descriptor, SourceEntry.LINE_INFO)) {
+ return _lineInfo as Object;
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ }
+ /**
+ * Set the most recent time at which the state of the source matched the state represented by this
+ * entry to the given time.
+ * @param time the new modification time of this entry
+ */
+ void set modificationTime(int time) {
+ _modificationTime = time;
+ }
+ /**
+ * Set the state of the data represented by the given descriptor to the given state.
+ * @param descriptor the descriptor representing the data whose state is to be set
+ * @param the new state of the data represented by the given descriptor
+ */
+ void setState(DataDescriptor<Object> descriptor, CacheState state) {
+ if (identical(descriptor, SourceEntry.LINE_INFO)) {
+ _lineInfo = updatedValue(state, _lineInfo, null);
+ _lineInfoState = state;
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ }
+ /**
+ * Set the value of the data represented by the given descriptor to the given value.
+ * @param descriptor the descriptor representing the data whose value is to be set
+ * @param value the new value of the data represented by the given descriptor
+ */
+ void setValue(DataDescriptor descriptor, Object value) {
+ if (identical(descriptor, SourceEntry.LINE_INFO)) {
+ _lineInfo = value as LineInfo;
+ _lineInfoState = CacheState.VALID;
+ } else {
+ throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
+ }
+ }
+ /**
+ * Copy the information from the given cache entry.
+ * @param entry the cache entry from which information will be copied
+ */
+ void copyFrom(SourceEntryImpl entry) {
+ _modificationTime = entry._modificationTime;
+ _lineInfoState = entry._lineInfoState;
+ _lineInfo = entry._lineInfo;
+ }
+ /**
+ * Given that some data is being transitioned to the given state, return the value that should be
+ * kept in the cache.
+ * @param state the state to which the data is being transitioned
+ * @param currentValue the value of the data before the transition
+ * @param defaultValue the value to be used if the current value is to be removed from the cache
+ * @return the value of the data that should be kept in the cache
+ */
+ Object updatedValue(CacheState state, Object currentValue, Object defaultValue) {
+ if (identical(state, CacheState.VALID)) {
+ throw new IllegalArgumentException("Use setValue() to set the state to VALID");
+ } else if (identical(state, CacheState.IN_PROCESS)) {
+ return currentValue;
+ }
+ return defaultValue;
+ }
+}
+/**
* Instances of the class {@code AnalysisContextImpl} implement an {@link AnalysisContext analysis
* context}.
* @coverage dart.engine
@@ -614,7 +1608,7 @@
/**
* A table mapping the sources known to the context to the information known about the source.
*/
- Map<Source, SourceInfo> _sourceMap = new Map<Source, SourceInfo>();
+ Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>();
/**
* A table mapping sources to the change notices that are waiting to be returned related to that
* source.
@@ -652,7 +1646,7 @@
*/
AnalysisContextImpl() : super() {
}
- void addSourceInfo(Source source, SourceInfo info) {
+ void addSourceInfo(Source source, SourceEntry info) {
_sourceMap[source] = info;
}
void applyChanges(ChangeSet changeSet) {
@@ -664,8 +1658,11 @@
for (SourceContainer container in changeSet.removedContainers) {
addSourcesInContainer(removedSources, container);
}
+ bool addedDartSource = false;
for (Source source in changeSet.added3) {
- sourceAvailable(source);
+ if (sourceAvailable(source)) {
+ addedDartSource = true;
+ }
}
for (Source source in changeSet.changed3) {
sourceChanged(source);
@@ -673,20 +1670,76 @@
for (Source source in removedSources) {
sourceRemoved(source);
}
+ if (addedDartSource) {
+ for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) {
+ if (!mapEntry.getKey().isInSystemLibrary() && mapEntry.getValue() is DartEntry) {
+ ((mapEntry.getValue() as DartEntryImpl)).invalidateAllResolutionInformation();
+ }
+ }
+ }
}
}
+ String computeDocumentationComment(Element element) {
+ if (element == null) {
+ return null;
+ }
+ Source source2 = element.source;
+ if (source2 == null) {
+ return null;
+ }
+ List<CharSequence> contentHolder = new List<CharSequence>(1);
+ try {
+ source2.getContents(new Source_ContentReceiver_5(contentHolder));
+ } catch (exception) {
+ throw new AnalysisException.con2("Could not get contents of ${source2.fullName}", exception);
+ }
+ if (contentHolder[0] == null) {
+ return null;
+ }
+ CompilationUnit unit = parseCompilationUnit(source2);
+ if (unit == null) {
+ return null;
+ }
+ NodeLocator locator = new NodeLocator.con1(element.nameOffset);
+ ASTNode nameNode = locator.searchWithin(unit);
+ while (nameNode != null) {
+ if (nameNode is AnnotatedNode) {
+ Comment comment = ((nameNode as AnnotatedNode)).documentationComment;
+ if (comment == null) {
+ return null;
+ }
+ int offset2 = comment.offset;
+ return contentHolder[0].subSequence(offset2, offset2 + comment.length).toString();
+ }
+ nameNode = nameNode.parent;
+ }
+ return null;
+ }
List<AnalysisError> computeErrors(Source source) {
{
- CompilationUnitInfo info = getCompilationUnitInfo(source);
- if (info == null) {
- return AnalysisError.NO_ERRORS;
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
+ if (parseErrorsState != CacheState.VALID && parseErrorsState != CacheState.ERROR) {
+ parseCompilationUnit(source);
+ }
+ List<Source> libraries = getLibrariesContaining(source);
+ for (Source librarySource in libraries) {
+ CacheState resolutionErrorsState = dartEntry.getState2(DartEntry.RESOLUTION_ERRORS, librarySource);
+ if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState != CacheState.ERROR) {
+ }
+ }
+ return dartEntry.allErrors;
+ } else if (sourceEntry is HtmlEntry) {
+ HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
+ CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTION_ERRORS);
+ if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState != CacheState.ERROR) {
+ computeHtmlElement(source);
+ }
+ return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS);
}
- if (info.hasInvalidParseErrors()) {
- parseCompilationUnit(source);
- }
- if (info.hasInvalidResolutionErrors()) {
- }
- return info.allErrors;
+ return AnalysisError.NO_ERRORS;
}
}
HtmlElement computeHtmlElement(Source source) {
@@ -694,36 +1747,45 @@
return null;
}
{
- HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(source);
- if (htmlUnitInfo == null) {
+ HtmlEntry htmlEntry = getHtmlEntry(source);
+ if (htmlEntry == null) {
return null;
}
- HtmlElement element2 = htmlUnitInfo.element;
- if (element2 == null) {
- HtmlUnit unit = htmlUnitInfo.resolvedUnit;
+ HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT);
+ if (element == null) {
+ HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
if (unit == null) {
- unit = htmlUnitInfo.parsedUnit;
+ unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
if (unit == null) {
unit = parseHtmlUnit(source);
}
}
- HtmlUnitBuilder builder = new HtmlUnitBuilder(this);
- element2 = builder.buildHtmlElement2(source, unit);
- htmlUnitInfo.resolvedUnit = unit;
- htmlUnitInfo.element = element2;
+ RecordingErrorListener listener = new RecordingErrorListener();
+ HtmlUnitBuilder builder = new HtmlUnitBuilder(this, listener);
+ element = builder.buildHtmlElement2(source, unit);
+ List<AnalysisError> resolutionErrors = listener.getErrors2(source);
+ HtmlEntryImpl htmlCopy = (htmlEntry as HtmlEntryImpl);
+ htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit);
+ htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors);
+ htmlCopy.setValue(HtmlEntry.ELEMENT, element);
+ getNotice(source).setErrors(resolutionErrors, htmlCopy.getValue(SourceEntry.LINE_INFO));
}
- return element2;
+ return element;
}
}
SourceKind computeKindOf(Source source) {
{
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry == null) {
return SourceKind.UNKNOWN;
- } else if (identical(sourceInfo, DartInfo.pendingInstance)) {
- sourceInfo = internalComputeKindOf(source);
+ } else if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND);
+ if (sourceKindState != CacheState.VALID && sourceKindState != CacheState.ERROR) {
+ internalComputeKindOf(source);
+ }
}
- return sourceInfo.kind;
+ return sourceEntry.kind;
}
}
LibraryElement computeLibraryElement(Source source) {
@@ -731,65 +1793,59 @@
return null;
}
{
- LibraryInfo libraryInfo = getLibraryInfo(source);
- if (libraryInfo == null) {
+ DartEntry dartEntry = getDartEntry(source);
+ if (dartEntry == null) {
return null;
}
- LibraryElement element2 = libraryInfo.element;
- if (element2 == null) {
+ LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT);
+ if (element == null) {
if (computeKindOf(source) != SourceKind.LIBRARY) {
- return null;
+ throw new AnalysisException.con1("Cannot compute library element for non-library: ${source.fullName}");
}
LibraryResolver resolver = new LibraryResolver.con1(this);
try {
- element2 = resolver.resolveLibrary(source, true);
- if (element2 != null) {
- libraryInfo.element = element2;
+ element = resolver.resolveLibrary(source, true);
+ if (element != null) {
+ ((dartEntry as DartEntryImpl)).setValue(DartEntry.ELEMENT, element);
}
} on AnalysisException catch (exception) {
AnalysisEngine.instance.logger.logError2("Could not resolve the library ${source.fullName}", exception);
}
}
- return element2;
+ return element;
}
}
LineInfo computeLineInfo(Source source) {
{
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry == null) {
return null;
}
- LineInfo lineInfo2 = sourceInfo.lineInfo;
- if (lineInfo2 == null) {
- if (identical(sourceInfo, DartInfo.pendingInstance)) {
- sourceInfo = internalComputeKindOf(source);
- }
- if (sourceInfo is HtmlUnitInfo) {
+ LineInfo lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO);
+ if (lineInfo == null) {
+ if (sourceEntry is HtmlEntry) {
parseHtmlUnit(source);
- lineInfo2 = sourceInfo.lineInfo;
- } else if (sourceInfo is CompilationUnitInfo) {
+ lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO);
+ } else if (sourceEntry is DartEntry) {
parseCompilationUnit(source);
- lineInfo2 = sourceInfo.lineInfo;
+ lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO);
}
}
- return lineInfo2;
+ return lineInfo;
}
}
CompilationUnit computeResolvableCompilationUnit(Source source) {
{
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source);
- if (compilationUnitInfo == null) {
+ DartEntry dartEntry = getDartEntry(source);
+ if (dartEntry == null) {
return null;
}
- CompilationUnit unit = compilationUnitInfo.parsedCompilationUnit;
- if (unit == null) {
- unit = compilationUnitInfo.resolvedCompilationUnit;
- }
+ CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
if (unit != null) {
return unit.accept(new ASTCloner()) as CompilationUnit;
}
- unit = internalParseCompilationUnit(compilationUnitInfo, source);
- compilationUnitInfo.clearParsedUnit();
+ unit = internalParseCompilationUnit(((dartEntry as DartEntryImpl)), source);
+ ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
return unit;
}
}
@@ -797,11 +1853,11 @@
InternalAnalysisContext extractContextInto(SourceContainer container, InternalAnalysisContext newContext) {
List<Source> sourcesToRemove = new List<Source>();
{
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
Source source = entry.getKey();
if (container.contains(source)) {
sourcesToRemove.add(source);
- newContext.addSourceInfo(source, entry.getValue().copy());
+ newContext.addSourceInfo(source, entry.getValue().writableCopy);
}
}
}
@@ -828,19 +1884,22 @@
}
AnalysisErrorInfo getErrors(Source source) {
{
- SourceInfo info = getSourceInfo(source);
- if (info is CompilationUnitInfo) {
- CompilationUnitInfo compilationUnitInfo = info as CompilationUnitInfo;
- return new AnalysisErrorInfoImpl(compilationUnitInfo.allErrors, compilationUnitInfo.lineInfo);
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_INFO));
+ } else if (sourceEntry is HtmlEntry) {
+ HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
+ return new AnalysisErrorInfoImpl(htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS), htmlEntry.getValue(SourceEntry.LINE_INFO));
}
- return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, info.lineInfo);
+ return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, sourceEntry.getValue(SourceEntry.LINE_INFO));
}
}
HtmlElement getHtmlElement(Source source) {
{
- SourceInfo info = getSourceInfo(source);
- if (info is HtmlUnitInfo) {
- return ((info as HtmlUnitInfo)).element;
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry is HtmlEntry) {
+ return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT);
}
return null;
}
@@ -852,9 +1911,10 @@
if (getKindOf(source) == SourceKind.LIBRARY) {
} else if (getKindOf(source) == SourceKind.PART) {
List<Source> librarySources = getLibrariesContaining(source);
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
if (identical(entry.getValue().kind, SourceKind.HTML)) {
- if (containsAny(((entry.getValue() as HtmlUnitInfo)).librarySources, librarySources)) {
+ List<Source> referencedLibraries = ((entry.getValue() as HtmlEntry)).getValue(HtmlEntry.REFERENCED_LIBRARIES);
+ if (containsAny(referencedLibraries, librarySources)) {
htmlSources.add(entry.getKey());
}
}
@@ -871,20 +1931,20 @@
List<Source> get htmlSources => getSources(SourceKind.HTML);
SourceKind getKindOf(Source source) {
{
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry == null) {
return SourceKind.UNKNOWN;
}
- return sourceInfo.kind;
+ return sourceEntry.kind;
}
}
List<Source> get launchableClientLibrarySources {
List<Source> sources = new List<Source>();
{
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
Source source = entry.getKey();
- SourceInfo info = entry.getValue();
- if (identical(info.kind, SourceKind.LIBRARY) && !source.isInSystemLibrary()) {
+ SourceEntry sourceEntry = entry.getValue();
+ if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemLibrary()) {
sources.add(source);
}
}
@@ -894,10 +1954,10 @@
List<Source> get launchableServerLibrarySources {
List<Source> sources = new List<Source>();
{
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
Source source = entry.getKey();
- SourceInfo info = entry.getValue();
- if (identical(info.kind, SourceKind.LIBRARY) && !source.isInSystemLibrary()) {
+ SourceEntry sourceEntry = entry.getValue();
+ if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemLibrary()) {
sources.add(source);
}
}
@@ -907,9 +1967,9 @@
List<Source> getLibrariesContaining(Source source) {
{
List<Source> librarySources = new List<Source>();
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
if (identical(entry.getValue().kind, SourceKind.LIBRARY)) {
- if (contains(((entry.getValue() as LibraryInfo)).unitSources, source)) {
+ if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.INCLUDED_PARTS), source)) {
librarySources.add(entry.getKey());
}
}
@@ -922,9 +1982,9 @@
}
LibraryElement getLibraryElement(Source source) {
{
- SourceInfo info = getSourceInfo(source);
- if (info is LibraryInfo) {
- return ((info as LibraryInfo)).element;
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry is DartEntry) {
+ return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT);
}
return null;
}
@@ -932,9 +1992,9 @@
List<Source> get librarySources => getSources(SourceKind.LIBRARY);
LineInfo getLineInfo(Source source) {
{
- SourceInfo info = getSourceInfo(source);
- if (info != null) {
- return info.lineInfo;
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry != null) {
+ return sourceEntry.getValue(SourceEntry.LINE_INFO);
}
return null;
}
@@ -942,26 +2002,26 @@
Namespace getPublicNamespace(LibraryElement library) {
Source source2 = library.definingCompilationUnit.source;
{
- LibraryInfo libraryInfo = getLibraryInfo(source2);
- if (libraryInfo == null) {
+ DartEntry dartEntry = getDartEntry(source2);
+ if (dartEntry == null) {
return null;
}
- Namespace namespace = libraryInfo.publicNamespace;
+ Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
if (namespace == null) {
NamespaceBuilder builder = new NamespaceBuilder();
namespace = builder.createPublicNamespace(library);
- libraryInfo.publicNamespace = namespace;
+ ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
}
return namespace;
}
}
Namespace getPublicNamespace2(Source source) {
{
- LibraryInfo libraryInfo = getLibraryInfo(source);
- if (libraryInfo == null) {
+ DartEntry dartEntry = getDartEntry(source);
+ if (dartEntry == null) {
return null;
}
- Namespace namespace = libraryInfo.publicNamespace;
+ Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
if (namespace == null) {
LibraryElement library = computeLibraryElement(source);
if (library == null) {
@@ -969,7 +2029,7 @@
}
NamespaceBuilder builder = new NamespaceBuilder();
namespace = builder.createPublicNamespace(library);
- libraryInfo.publicNamespace = namespace;
+ ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
}
return namespace;
}
@@ -983,43 +2043,47 @@
CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source librarySource) {
{
accessed(unitSource);
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(unitSource);
- if (compilationUnitInfo == null) {
+ DartEntry dartEntry = getDartEntry(unitSource);
+ if (dartEntry == null) {
return null;
}
- return compilationUnitInfo.resolvedCompilationUnit;
+ return dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource);
}
}
SourceFactory get sourceFactory => _sourceFactory;
bool isClientLibrary(Source librarySource) {
- SourceInfo sourceInfo = getSourceInfo(librarySource);
- if (sourceInfo is LibraryInfo) {
- LibraryInfo libraryInfo = sourceInfo as LibraryInfo;
- if (libraryInfo.hasInvalidLaunchable() || libraryInfo.hasInvalidClientServer()) {
+ SourceEntry sourceEntry = getSourceEntry(librarySource);
+ if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT);
+ CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE);
+ if (identical(isClientState, CacheState.INVALID) || identical(isClientState, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || identical(isLaunchableState, CacheState.ERROR)) {
return false;
}
- return libraryInfo.isLaunchable() && libraryInfo.isClient();
+ return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartEntry.IS_LAUNCHABLE);
}
return false;
}
bool isServerLibrary(Source librarySource) {
- SourceInfo sourceInfo = getSourceInfo(librarySource);
- if (sourceInfo is LibraryInfo) {
- LibraryInfo libraryInfo = sourceInfo as LibraryInfo;
- if (libraryInfo.hasInvalidLaunchable() || libraryInfo.hasInvalidClientServer()) {
+ SourceEntry sourceEntry = getSourceEntry(librarySource);
+ if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT);
+ CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE);
+ if (identical(isClientState, CacheState.INVALID) || identical(isClientState, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || identical(isLaunchableState, CacheState.ERROR)) {
return false;
}
- return libraryInfo.isLaunchable() && libraryInfo.isServer();
+ return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartEntry.IS_LAUNCHABLE);
}
return false;
}
void mergeContext(AnalysisContext context) {
{
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(((context as AnalysisContextImpl))._sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(((context as AnalysisContextImpl))._sourceMap)) {
Source newSource = entry.getKey();
- SourceInfo existingInfo = getSourceInfo(newSource);
- if (existingInfo == null) {
- _sourceMap[newSource] = entry.getValue().copy();
+ SourceEntry existingEntry = getSourceEntry(newSource);
+ if (existingEntry == null) {
+ _sourceMap[newSource] = entry.getValue().writableCopy;
} else {
}
}
@@ -1028,16 +2092,13 @@
CompilationUnit parseCompilationUnit(Source source) {
{
accessed(source);
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source);
- if (compilationUnitInfo == null) {
+ DartEntry dartEntry = getDartEntry(source);
+ if (dartEntry == null) {
return null;
}
- CompilationUnit unit = compilationUnitInfo.resolvedCompilationUnit;
+ CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
if (unit == null) {
- unit = compilationUnitInfo.parsedCompilationUnit;
- if (unit == null) {
- unit = internalParseCompilationUnit(compilationUnitInfo, source);
- }
+ unit = internalParseCompilationUnit((dartEntry as DartEntryImpl), source);
}
return unit;
}
@@ -1045,19 +2106,19 @@
HtmlUnit parseHtmlUnit(Source source) {
{
accessed(source);
- HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(source);
- if (htmlUnitInfo == null) {
+ HtmlEntry htmlEntry = getHtmlEntry(source);
+ if (htmlEntry == null) {
return null;
}
- HtmlUnit unit = htmlUnitInfo.resolvedUnit;
+ HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
if (unit == null) {
- unit = htmlUnitInfo.parsedUnit;
+ unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
if (unit == null) {
HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source));
unit = result.htmlUnit;
- htmlUnitInfo.lineInfo = new LineInfo(result.lineStarts);
- htmlUnitInfo.parsedUnit = unit;
- htmlUnitInfo.librarySources = getLibrarySources2(source, unit);
+ ((htmlEntry as HtmlEntryImpl)).setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineStarts));
+ ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.PARSED_UNIT, unit);
+ ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(source, unit));
}
}
return unit;
@@ -1082,38 +2143,38 @@
for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) {
Source librarySource = entry.getKey();
LibraryElement library = entry.getValue();
- LibraryInfo libraryInfo = getLibraryInfo(librarySource);
- if (libraryInfo != null) {
- libraryInfo.element = library;
- libraryInfo.launchable = library.entryPoint != null;
- libraryInfo.client = isClient(library, htmlSource, new Set<LibraryElement>());
+ DartEntryImpl dartEntry = getDartEntry(librarySource) as DartEntryImpl;
+ if (dartEntry != null) {
+ dartEntry.setValue(DartEntry.ELEMENT, library);
+ dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
+ dartEntry.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set<LibraryElement>()));
List<Source> unitSources = new List<Source>();
unitSources.add(librarySource);
for (CompilationUnitElement part in library.parts) {
Source partSource = part.source;
unitSources.add(partSource);
}
- libraryInfo.unitSources = new List.from(unitSources);
+ dartEntry.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources));
}
}
}
}
- void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInfo lineInfo2) {
+ void recordResolutionErrors(Source source, Source librarySource, List<AnalysisError> errors, LineInfo lineInfo) {
{
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source);
- if (compilationUnitInfo != null) {
- compilationUnitInfo.lineInfo = lineInfo2;
- compilationUnitInfo.resolutionErrors = errors;
+ DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl;
+ if (dartEntry != null) {
+ dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
+ dartEntry.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, errors);
}
- getNotice(source).setErrors(compilationUnitInfo.allErrors, lineInfo2);
+ getNotice(source).setErrors(dartEntry.allErrors, lineInfo);
}
}
- void recordResolvedCompilationUnit(Source source, CompilationUnit unit) {
+ void recordResolvedCompilationUnit(Source source, Source librarySource, CompilationUnit unit) {
{
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source);
- if (compilationUnitInfo != null) {
- compilationUnitInfo.resolvedCompilationUnit = unit;
- compilationUnitInfo.clearParsedUnit();
+ DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl;
+ if (dartEntry != null) {
+ dartEntry.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit);
+ dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
getNotice(source).compilationUnit = unit;
}
}
@@ -1127,16 +2188,16 @@
CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySource) {
{
accessed(unitSource);
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(unitSource);
- if (compilationUnitInfo == null) {
+ DartEntry dartEntry = getDartEntry(unitSource);
+ if (dartEntry == null) {
return null;
}
- CompilationUnit unit = compilationUnitInfo.resolvedCompilationUnit;
+ CompilationUnit unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource);
if (unit == null) {
disableCacheRemoval();
try {
LibraryElement libraryElement = computeLibraryElement(librarySource);
- unit = compilationUnitInfo.resolvedCompilationUnit;
+ unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource);
if (unit == null && libraryElement != null) {
Source coreLibrarySource = libraryElement.context.sourceFactory.forUri(DartSdk.DART_CORE);
LibraryElement coreElement = computeLibraryElement(coreLibrarySource);
@@ -1154,7 +2215,7 @@
ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter);
unitAST.accept(constantVerifier);
unitAST.resolutionErrors = errorListener.errors;
- compilationUnitInfo.resolvedCompilationUnit = unitAST;
+ ((dartEntry as DartEntryImpl)).setValue2(DartEntry.RESOLVED_UNIT, librarySource, unitAST);
unit = unitAST;
}
} finally {
@@ -1167,16 +2228,16 @@
HtmlUnit resolveHtmlUnit(Source unitSource) {
{
accessed(unitSource);
- HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(unitSource);
- if (htmlUnitInfo == null) {
+ HtmlEntry htmlEntry = getHtmlEntry(unitSource);
+ if (htmlEntry == null) {
return null;
}
- HtmlUnit unit = htmlUnitInfo.resolvedUnit;
+ HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
if (unit == null) {
disableCacheRemoval();
try {
computeHtmlElement(unitSource);
- unit = htmlUnitInfo.resolvedUnit;
+ unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
if (unit == null) {
unit = parseHtmlUnit(unitSource);
}
@@ -1205,20 +2266,11 @@
}
factory.context = this;
_sourceFactory = factory;
- for (SourceInfo sourceInfo in _sourceMap.values) {
- if (sourceInfo is HtmlUnitInfo) {
- ((sourceInfo as HtmlUnitInfo)).invalidateResolvedUnit();
- } else if (sourceInfo is CompilationUnitInfo) {
- CompilationUnitInfo compilationUnitInfo = sourceInfo as CompilationUnitInfo;
- compilationUnitInfo.invalidateResolvedUnit();
- compilationUnitInfo.invalidateResolutionErrors();
- if (sourceInfo is LibraryInfo) {
- LibraryInfo libraryInfo = sourceInfo as LibraryInfo;
- libraryInfo.invalidateElement();
- libraryInfo.invalidatePublicNamespace();
- libraryInfo.invalidateLaunchable();
- libraryInfo.invalidateClientServer();
- }
+ for (SourceEntry sourceEntry in _sourceMap.values) {
+ if (sourceEntry is HtmlEntry) {
+ ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID);
+ } else if (sourceEntry is DartEntry) {
+ ((sourceEntry as DartEntryImpl)).invalidateAllResolutionInformation();
}
}
}
@@ -1246,13 +2298,15 @@
}
if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) {
Source removedSource = _recentlyUsed.removeAt(0);
- SourceInfo sourceInfo = _sourceMap[removedSource];
- if (sourceInfo is HtmlUnitInfo) {
- ((sourceInfo as HtmlUnitInfo)).clearParsedUnit();
- ((sourceInfo as HtmlUnitInfo)).clearResolvedUnit();
- } else if (sourceInfo is CompilationUnitInfo) {
- ((sourceInfo as CompilationUnitInfo)).clearParsedUnit();
- ((sourceInfo as CompilationUnitInfo)).clearResolvedUnit();
+ SourceEntry sourceEntry = _sourceMap[removedSource];
+ if (sourceEntry is HtmlEntry) {
+ ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
+ ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED);
+ } else if (sourceEntry is DartEntry) {
+ ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
+ for (Source librarySource in getLibrariesContaining(source)) {
+ ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.FLUSHED);
+ }
}
}
_recentlyUsed.add(source);
@@ -1305,16 +2359,16 @@
* @param source the source for which an information object is being created
* @return the source information object that was created
*/
- SourceInfo createSourceInfo(Source source) {
+ SourceEntry createSourceEntry(Source source) {
String name = source.shortName;
if (AnalysisEngine.isHtmlFileName(name)) {
- HtmlUnitInfo info = new HtmlUnitInfo();
- _sourceMap[source] = info;
- return info;
+ HtmlEntry htmlEntry = new HtmlEntryImpl();
+ _sourceMap[source] = htmlEntry;
+ return htmlEntry;
} else if (AnalysisEngine.isDartFileName(name)) {
- DartInfo info = DartInfo.pendingInstance;
- _sourceMap[source] = info;
- return info;
+ DartEntry dartEntry = new DartEntryImpl();
+ _sourceMap[source] = dartEntry;
+ return dartEntry;
}
return null;
}
@@ -1335,13 +2389,15 @@
if (_cacheRemovalCount == 0) {
while (_recentlyUsed.length >= _MAX_CACHE_SIZE) {
Source removedSource = _recentlyUsed.removeAt(0);
- SourceInfo sourceInfo = _sourceMap[removedSource];
- if (sourceInfo is HtmlUnitInfo) {
- ((sourceInfo as HtmlUnitInfo)).clearParsedUnit();
- ((sourceInfo as HtmlUnitInfo)).clearResolvedUnit();
- } else if (sourceInfo is CompilationUnitInfo) {
- ((sourceInfo as CompilationUnitInfo)).clearParsedUnit();
- ((sourceInfo as CompilationUnitInfo)).clearResolvedUnit();
+ SourceEntry sourceEntry = _sourceMap[removedSource];
+ if (sourceEntry is HtmlEntry) {
+ ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
+ ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED);
+ } else if (sourceEntry is DartEntry) {
+ ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
+ for (Source librarySource in getLibrariesContaining(removedSource)) {
+ ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.FLUSHED);
+ }
}
}
}
@@ -1377,19 +2433,14 @@
* @param source the source for which information is being sought
* @return the compilation unit information associated with the given source
*/
- CompilationUnitInfo getCompilationUnitInfo(Source source) {
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
- sourceInfo = new CompilationUnitInfo();
- _sourceMap[source] = sourceInfo;
- return sourceInfo as CompilationUnitInfo;
- } else if (sourceInfo is CompilationUnitInfo) {
- return sourceInfo as CompilationUnitInfo;
- } else if (identical(sourceInfo, DartInfo.pendingInstance)) {
- sourceInfo = internalComputeKindOf(source);
- if (sourceInfo is CompilationUnitInfo) {
- return sourceInfo as CompilationUnitInfo;
- }
+ DartEntry getDartEntry(Source source) {
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry == null) {
+ sourceEntry = new DartEntryImpl();
+ _sourceMap[source] = sourceEntry;
+ return sourceEntry as DartEntry;
+ } else if (sourceEntry is DartEntry) {
+ return sourceEntry as DartEntry;
}
return null;
}
@@ -1404,40 +2455,14 @@
* @param source the source for which information is being sought
* @return the HTML unit information associated with the given source
*/
- HtmlUnitInfo getHtmlUnitInfo(Source source) {
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
- sourceInfo = new HtmlUnitInfo();
- _sourceMap[source] = sourceInfo;
- return sourceInfo as HtmlUnitInfo;
- } else if (sourceInfo is HtmlUnitInfo) {
- return sourceInfo as HtmlUnitInfo;
- }
- return null;
- }
- /**
- * Return the library information associated with the given source, or {@code null} if the source
- * is not known to this context. This method should be used to access the library information
- * rather than accessing the library map directly because sources in the SDK are implicitly part
- * of every analysis context and are therefore only added to the map when first accessed.
- * <p>
- * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
- * @param source the source for which information is being sought
- * @return the library information associated with the given source
- */
- LibraryInfo getLibraryInfo(Source source) {
- SourceInfo sourceInfo = getSourceInfo(source);
- if (sourceInfo == null) {
- sourceInfo = new LibraryInfo();
- _sourceMap[source] = sourceInfo;
- return sourceInfo as LibraryInfo;
- } else if (sourceInfo is LibraryInfo) {
- return sourceInfo as LibraryInfo;
- } else if (identical(sourceInfo, DartInfo.pendingInstance)) {
- sourceInfo = internalComputeKindOf(source);
- if (sourceInfo is LibraryInfo) {
- return sourceInfo as LibraryInfo;
- }
+ HtmlEntry getHtmlEntry(Source source) {
+ SourceEntry sourceEntry = getSourceEntry(source);
+ if (sourceEntry == null) {
+ sourceEntry = new HtmlEntryImpl();
+ _sourceMap[source] = sourceEntry;
+ return sourceEntry as HtmlEntry;
+ } else if (sourceEntry is HtmlEntry) {
+ return sourceEntry as HtmlEntry;
}
return null;
}
@@ -1478,12 +2503,12 @@
* @param source the source for which information is being sought
* @return the source information associated with the given source
*/
- SourceInfo getSourceInfo(Source source) {
- SourceInfo sourceInfo = _sourceMap[source];
- if (sourceInfo == null) {
- sourceInfo = createSourceInfo(source);
+ SourceEntry getSourceEntry(Source source) {
+ SourceEntry sourceEntry = _sourceMap[source];
+ if (sourceEntry == null) {
+ sourceEntry = createSourceEntry(source);
}
- return sourceInfo;
+ return sourceEntry;
}
/**
* Return an array containing all of the sources known to this context that have the given kind.
@@ -1493,7 +2518,7 @@
List<Source> getSources(SourceKind kind2) {
List<Source> sources = new List<Source>();
{
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
if (identical(entry.getValue().kind, kind2)) {
sources.add(entry.getKey());
}
@@ -1520,13 +2545,11 @@
}
/**
* Compute the kind of the given source. This method should only be invoked when the kind is not
- * already known. In such a case the source is currently being represented by a {@link DartInfo}.
- * After this method has run the source will be represented by a new information object that is
- * appropriate to the computed kind of the source.
+ * already known.
* @param source the source for which a kind is to be computed
* @return the new source info that was created to represent the source
*/
- SourceInfo internalComputeKindOf(Source source) {
+ DartEntry internalComputeKindOf(Source source) {
try {
accessed(source);
RecordingErrorListener errorListener = new RecordingErrorListener();
@@ -1537,24 +2560,26 @@
List<AnalysisError> errors = errorListener.getErrors2(source);
unit.parsingErrors = errors;
unit.lineInfo = lineInfo;
- CompilationUnitInfo sourceInfo;
+ DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl;
if (hasPartOfDirective(unit)) {
- sourceInfo = new CompilationUnitInfo();
+ dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
} else {
- sourceInfo = new LibraryInfo();
+ dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
}
- sourceInfo.lineInfo = lineInfo;
- sourceInfo.parsedCompilationUnit = unit;
- sourceInfo.parseErrors = errors;
- _sourceMap[source] = sourceInfo;
- return sourceInfo;
+ dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
+ dartEntry.setValue(DartEntry.PARSED_UNIT, unit);
+ dartEntry.setValue(DartEntry.PARSE_ERRORS, errors);
+ return dartEntry;
} on AnalysisException catch (exception) {
- DartInfo sourceInfo = DartInfo.errorInstance;
- _sourceMap[source] = sourceInfo;
- return sourceInfo;
+ DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl;
+ dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.ERROR);
+ dartEntry.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
+ dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.ERROR);
+ dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR);
+ return dartEntry;
}
}
- CompilationUnit internalParseCompilationUnit(CompilationUnitInfo compilationUnitInfo, Source source) {
+ CompilationUnit internalParseCompilationUnit(DartEntryImpl dartEntry, Source source) {
accessed(source);
RecordingErrorListener errorListener = new RecordingErrorListener();
AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorListener);
@@ -1564,9 +2589,16 @@
List<AnalysisError> errors = errorListener.getErrors2(source);
unit.parsingErrors = errors;
unit.lineInfo = lineInfo;
- compilationUnitInfo.lineInfo = lineInfo;
- compilationUnitInfo.parsedCompilationUnit = unit;
- compilationUnitInfo.parseErrors = errors;
+ if (identical(dartEntry.getState(DartEntry.SOURCE_KIND), CacheState.INVALID)) {
+ if (hasPartOfDirective(unit)) {
+ dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
+ } else {
+ dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
+ }
+ }
+ dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
+ dartEntry.setValue(DartEntry.PARSED_UNIT, unit);
+ dartEntry.setValue(DartEntry.PARSE_ERRORS, errors);
return unit;
}
AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListener errorListener) {
@@ -1583,21 +2615,16 @@
* In response to a change to at least one of the compilation units in the given library,
* invalidate any results that are dependent on the result of resolving that library.
* @param librarySource the source of the library being invalidated
- * @param libraryInfo the information for the library being invalidated
+ * @param libraryEntry the cache entry for the library being invalidated
*/
- void invalidateLibraryResolution(Source librarySource, LibraryInfo libraryInfo) {
- if (libraryInfo != null) {
- libraryInfo.invalidateElement();
- libraryInfo.invalidateLaunchable();
- libraryInfo.invalidatePublicNamespace();
- libraryInfo.invalidateResolutionErrors();
- libraryInfo.invalidateResolvedUnit();
- for (Source unitSource in libraryInfo.unitSources) {
- CompilationUnitInfo partInfo = getCompilationUnitInfo(unitSource);
- partInfo.invalidateResolutionErrors();
- partInfo.invalidateResolvedUnit();
+ void invalidateLibraryResolution(Source librarySource, DartEntryImpl libraryEntry) {
+ if (libraryEntry != null) {
+ for (Source unitSource in libraryEntry.getValue(DartEntry.INCLUDED_PARTS)) {
+ DartEntryImpl partEntry = getDartEntry(unitSource) as DartEntryImpl;
+ partEntry.invalidateAllResolutionInformation();
}
- libraryInfo.invalidateUnitSources();
+ libraryEntry.invalidateAllResolutionInformation();
+ libraryEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID);
}
}
/**
@@ -1634,59 +2661,56 @@
* @return {@code true} if work was done, implying that there might be more work to be done
*/
bool performSingleAnalysisTask() {
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
- SourceInfo sourceInfo = entry.getValue();
- if (identical(sourceInfo, DartInfo.pendingInstance)) {
- internalComputeKindOf(entry.getKey());
- return true;
- }
- }
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
- SourceInfo sourceInfo = entry.getValue();
- if (sourceInfo is CompilationUnitInfo) {
- CompilationUnitInfo unitInfo = sourceInfo as CompilationUnitInfo;
- if (unitInfo.hasInvalidParsedUnit()) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
+ SourceEntry sourceEntry = entry.getValue();
+ if (sourceEntry is DartEntry) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT);
+ if (identical(parsedUnitState, CacheState.INVALID)) {
try {
parseCompilationUnit(entry.getKey());
} on AnalysisException catch (exception) {
- unitInfo.parsedCompilationUnit = null;
+ ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.ERROR);
AnalysisEngine.instance.logger.logError2("Could not parse ${entry.getKey().fullName}", exception);
}
return true;
}
- } else if (sourceInfo is HtmlUnitInfo) {
- HtmlUnitInfo unitInfo = sourceInfo as HtmlUnitInfo;
- if (unitInfo.hasInvalidParsedUnit()) {
+ } else if (sourceEntry is HtmlEntry) {
+ HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
+ CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT);
+ if (identical(parsedUnitState, CacheState.INVALID)) {
try {
parseHtmlUnit(entry.getKey());
} on AnalysisException catch (exception) {
- unitInfo.parsedUnit = null;
+ ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
AnalysisEngine.instance.logger.logError2("Could not parse ${entry.getKey().fullName}", exception);
}
return true;
}
}
}
- for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
- SourceInfo sourceInfo = entry.getValue();
- if (sourceInfo is LibraryInfo) {
- LibraryInfo libraryInfo = sourceInfo as LibraryInfo;
- if (libraryInfo.hasInvalidElement()) {
+ for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
+ SourceEntry sourceEntry = entry.getValue();
+ if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIBRARY)) {
+ DartEntry dartEntry = sourceEntry as DartEntry;
+ CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
+ if (identical(elementState, CacheState.INVALID)) {
try {
computeLibraryElement(entry.getKey());
} on AnalysisException catch (exception) {
- libraryInfo.element = null;
+ ((dartEntry as DartEntryImpl)).setState(DartEntry.ELEMENT, CacheState.ERROR);
AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.getKey().fullName}", exception);
}
return true;
}
- } else if (sourceInfo is HtmlUnitInfo) {
- HtmlUnitInfo unitInfo = sourceInfo as HtmlUnitInfo;
- if (unitInfo.hasInvalidResolvedUnit()) {
+ } else if (sourceEntry is HtmlEntry) {
+ HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
+ CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT);
+ if (identical(resolvedUnitState, CacheState.INVALID)) {
try {
resolveHtmlUnit(entry.getKey());
} on AnalysisException catch (exception) {
- unitInfo.resolvedUnit = null;
+ ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR);
AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.getKey().fullName}", exception);
}
return true;
@@ -1705,37 +2729,46 @@
return scanner.result;
}
/**
+ * Create an entry for the newly added source. Return {@code true} if the new source is a Dart
+ * file.
+ * <p>
* <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
* @param source the source that has been added
+ * @return {@code true} if the new source is a Dart file
*/
- void sourceAvailable(Source source) {
- SourceInfo existingInfo = _sourceMap[source];
- if (existingInfo == null) {
- createSourceInfo(source);
+ bool sourceAvailable(Source source) {
+ SourceEntry sourceEntry = _sourceMap[source];
+ if (sourceEntry == null) {
+ sourceEntry = createSourceEntry(source);
}
+ return sourceEntry is DartEntry;
}
/**
* <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
* @param source the source that has been changed
*/
void sourceChanged(Source source) {
- SourceInfo sourceInfo = _sourceMap[source];
- if (sourceInfo is HtmlUnitInfo) {
- HtmlUnitInfo htmlUnitInfo = sourceInfo as HtmlUnitInfo;
- htmlUnitInfo.invalidateElement();
- htmlUnitInfo.invalidateLineInfo();
- htmlUnitInfo.invalidateParsedUnit();
- htmlUnitInfo.invalidateResolvedUnit();
- } else if (sourceInfo is LibraryInfo) {
- LibraryInfo libraryInfo = sourceInfo as LibraryInfo;
- invalidateLibraryResolution(source, libraryInfo);
- _sourceMap[source] = DartInfo.pendingInstance;
- } else if (sourceInfo is CompilationUnitInfo) {
- for (Source librarySource in getLibrariesContaining(source)) {
- LibraryInfo libraryInfo = getLibraryInfo(librarySource);
- invalidateLibraryResolution(librarySource, libraryInfo);
+ SourceEntry sourceEntry = _sourceMap[source];
+ if (sourceEntry is HtmlEntry) {
+ HtmlEntryImpl htmlEntry = sourceEntry as HtmlEntryImpl;
+ htmlEntry.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
+ htmlEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
+ htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID);
+ htmlEntry.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID);
+ htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID);
+ } else if (sourceEntry is DartEntry) {
+ DartEntryImpl dartEntry = sourceEntry as DartEntryImpl;
+ List<Source> containingLibraries = getLibrariesContaining(source);
+ invalidateLibraryResolution(source, dartEntry);
+ dartEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID);
+ dartEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
+ dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID);
+ dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.INVALID);
+ dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.INVALID);
+ for (Source librarySource in containingLibraries) {
+ DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImpl;
+ invalidateLibraryResolution(librarySource, libraryEntry);
}
- _sourceMap[source] = DartInfo.pendingInstance;
}
}
/**
@@ -1743,11 +2776,11 @@
* @param source the source that has been deleted
*/
void sourceRemoved(Source source) {
- CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source);
- if (compilationUnitInfo != null) {
+ DartEntry dartEntry = getDartEntry(source);
+ if (dartEntry != null) {
for (Source librarySource in getLibrariesContaining(source)) {
- LibraryInfo libraryInfo = getLibraryInfo(librarySource);
- invalidateLibraryResolution(librarySource, libraryInfo);
+ DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImpl;
+ invalidateLibraryResolution(librarySource, libraryEntry);
}
}
_sourceMap.remove(source);
@@ -1775,6 +2808,16 @@
AnalysisContextImpl_ScanResult() : super() {
}
}
+class Source_ContentReceiver_5 implements Source_ContentReceiver {
+ List<CharSequence> contentHolder;
+ Source_ContentReceiver_5(this.contentHolder);
+ void accept(CharBuffer contents, int modificationTime) {
+ contentHolder[0] = contents;
+ }
+ void accept2(String contents, int modificationTime) {
+ contentHolder[0] = new CharSequence(contents);
+ }
+}
class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> {
final AnalysisContextImpl AnalysisContextImpl_this;
Source htmlSource;
@@ -1859,20 +2902,56 @@
*/
class CacheState implements Comparable<CacheState> {
/**
- * A state representing the fact that the data was up-to-date but flushed from the cache in order
- * to control memory usage.
+ * The data is not in the cache and the last time an attempt was made to compute the data an
+ * exception occurred, making it pointless to attempt.
+ * <p>
+ * Valid Transitions:
+ * <ul>
+ * <li>{@link #INVALID} if a source was modified that might cause the data to be computable</li>
+ * </ul>
*/
- static final CacheState FLUSHED = new CacheState('FLUSHED', 0);
+ static final CacheState ERROR = new CacheState('ERROR', 0);
/**
- * A state representing the fact that the data was removed from the cache because it was invalid
- * and needs to be recomputed.
+ * The data is not in the cache because it was flushed from the cache in order to control memory
+ * usage. If the data is recomputed, results do not need to be reported.
+ * <p>
+ * Valid Transitions:
+ * <ul>
+ * <li>{@link #IN_PROCESS} if the data is being recomputed</li>
+ * <li>{@link #INVALID} if a source was modified that causes the data to need to be recomputed</li>
+ * </ul>
*/
- static final CacheState INVALID = new CacheState('INVALID', 1);
+ static final CacheState FLUSHED = new CacheState('FLUSHED', 1);
/**
- * A state representing the fact that the data is in the cache and valid.
+ * The data might or might not be in the cache but is in the process of being recomputed.
+ * <p>
+ * Valid Transitions:
+ * <ul>
+ * <li>{@link #ERROR} if an exception occurred while trying to compute the data</li>
+ * <li>{@link #VALID} if the data was successfully computed and stored in the cache</li>
+ * </ul>
*/
- static final CacheState VALID = new CacheState('VALID', 2);
- static final List<CacheState> values = [FLUSHED, INVALID, VALID];
+ static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2);
+ /**
+ * The data is not in the cache and needs to be recomputed so that results can be reported.
+ * <p>
+ * Valid Transitions:
+ * <ul>
+ * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</li>
+ * </ul>
+ */
+ static final CacheState INVALID = new CacheState('INVALID', 3);
+ /**
+ * The data is in the cache and up-to-date.
+ * <p>
+ * Valid Transitions:
+ * <ul>
+ * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage</li>
+ * <li>{@link #INVALID} if a source was modified in such a way as to invalidate the previous data</li>
+ * </ul>
+ */
+ static final CacheState VALID = new CacheState('VALID', 4);
+ static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, VALID];
final String __name;
final int __ordinal;
int get ordinal => __ordinal;
@@ -1958,262 +3037,6 @@
}
}
/**
- * Instances of the class {@code CompilationUnitInfo} maintain the information cached by an analysis
- * context about an individual compilation unit.
- * @coverage dart.engine
- */
-class CompilationUnitInfo extends SourceInfo {
- /**
- * The state of the cached parsed compilation unit.
- */
- CacheState _parsedUnitState = CacheState.INVALID;
- /**
- * The parsed compilation unit, or {@code null} if the parsed compilation unit is not currently
- * cached.
- */
- CompilationUnit _parsedUnit;
- /**
- * The state of the cached resolved compilation unit.
- */
- CacheState _resolvedUnitState = CacheState.INVALID;
- /**
- * The resolved compilation unit, or {@code null} if the resolved compilation unit is not
- * currently cached.
- */
- CompilationUnit _resolvedUnit;
- /**
- * The state of the cached parse errors.
- */
- CacheState _parseErrorsState = CacheState.INVALID;
- /**
- * The errors produced while scanning and parsing the compilation unit, or {@code null} if the
- * errors are not currently cached.
- */
- List<AnalysisError> _parseErrors;
- /**
- * The state of the cached resolution errors.
- */
- CacheState _resolutionErrorsState = CacheState.INVALID;
- /**
- * The errors produced while resolving the compilation unit, or {@code null} if the errors are not
- * currently cached.
- */
- List<AnalysisError> _resolutionErrors;
- /**
- * Initialize a newly created information holder to be empty.
- */
- CompilationUnitInfo() : super() {
- }
- /**
- * Remove the parsed compilation unit from the cache.
- */
- void clearParsedUnit() {
- _parsedUnit = null;
- _parsedUnitState = CacheState.FLUSHED;
- }
- /**
- * Remove the parse errors from the cache.
- */
- void clearParseErrors() {
- _parseErrors = null;
- _parseErrorsState = CacheState.FLUSHED;
- }
- /**
- * Remove the resolution errors from the cache.
- */
- void clearResolutionErrors() {
- _resolutionErrors = null;
- _resolutionErrorsState = CacheState.FLUSHED;
- }
- /**
- * Remove the resolved compilation unit from the cache.
- */
- void clearResolvedUnit() {
- _resolvedUnit = null;
- _resolvedUnitState = CacheState.FLUSHED;
- }
- CompilationUnitInfo copy() {
- CompilationUnitInfo copy = new CompilationUnitInfo();
- copy.copyFrom(this);
- return copy;
- }
- /**
- * Return all of the errors associated with the compilation unit.
- * @return all of the errors associated with the compilation unit
- */
- List<AnalysisError> get allErrors {
- if (_parseErrors == null) {
- if (_resolutionErrors == null) {
- return null;
- }
- return _resolutionErrors;
- } else if (_resolutionErrors == null) {
- return _parseErrors;
- }
- int parseCount = _parseErrors.length;
- int resolutionCount = _resolutionErrors.length;
- List<AnalysisError> errors = new List<AnalysisError>(parseCount + resolutionCount);
- JavaSystem.arraycopy(_parseErrors, 0, errors, 0, parseCount);
- JavaSystem.arraycopy(_resolutionErrors, 0, errors, parseCount, resolutionCount);
- return errors;
- }
- SourceKind get kind => SourceKind.PART;
- /**
- * Return the parsed compilation unit, or {@code null} if the parsed compilation unit is not
- * currently cached.
- * @return the parsed compilation unit
- */
- CompilationUnit get parsedCompilationUnit => _parsedUnit;
- /**
- * Return the errors produced while scanning and parsing the compilation unit, or {@code null} if
- * the errors are not currently cached.
- * @return the errors produced while scanning and parsing the compilation unit
- */
- List<AnalysisError> get parseErrors => _parseErrors;
- /**
- * Return the errors produced while resolving the compilation unit, or {@code null} if the errors
- * are not currently cached.
- * @return the errors produced while resolving the compilation unit
- */
- List<AnalysisError> get resolutionErrors => _resolutionErrors;
- /**
- * Return the resolved compilation unit, or {@code null} if the resolved compilation unit is not
- * currently cached.
- * @return the resolved compilation unit
- */
- CompilationUnit get resolvedCompilationUnit => _resolvedUnit;
- /**
- * Return {@code true} if the parsed compilation unit needs to be recomputed.
- * @return {@code true} if the parsed compilation unit needs to be recomputed
- */
- bool hasInvalidParsedUnit() => identical(_parsedUnitState, CacheState.INVALID);
- /**
- * Return {@code true} if the parse errors needs to be recomputed.
- * @return {@code true} if the parse errors needs to be recomputed
- */
- bool hasInvalidParseErrors() => identical(_parseErrorsState, CacheState.INVALID);
- /**
- * Return {@code true} if the resolution errors needs to be recomputed.
- * @return {@code true} if the resolution errors needs to be recomputed
- */
- bool hasInvalidResolutionErrors() => identical(_resolutionErrorsState, CacheState.INVALID);
- /**
- * Return {@code true} if the resolved compilation unit needs to be recomputed.
- * @return {@code true} if the resolved compilation unit needs to be recomputed
- */
- bool hasInvalidResolvedUnit() => identical(_resolvedUnitState, CacheState.INVALID);
- /**
- * Mark the parsed compilation unit as needing to be recomputed.
- */
- void invalidateParsedUnit() {
- _parsedUnitState = CacheState.INVALID;
- _parsedUnit = null;
- }
- /**
- * Mark the parse errors as needing to be recomputed.
- */
- void invalidateParseErrors() {
- _parseErrorsState = CacheState.INVALID;
- _parseErrors = null;
- }
- /**
- * Mark the resolution errors as needing to be recomputed.
- */
- void invalidateResolutionErrors() {
- _resolutionErrorsState = CacheState.INVALID;
- _resolutionErrors = null;
- }
- /**
- * Mark the resolved compilation unit as needing to be recomputed.
- */
- void invalidateResolvedUnit() {
- _resolvedUnitState = CacheState.INVALID;
- _resolvedUnit = null;
- }
- /**
- * Set the parsed compilation unit to the given compilation unit.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the parsed compilation unit. Use
- * either {@link #clear} or {@link #invalidate}.
- * @param unit the parsed compilation unit
- */
- void set parsedCompilationUnit(CompilationUnit unit) {
- _parsedUnit = unit;
- _parsedUnitState = CacheState.VALID;
- }
- /**
- * Set the errors produced while scanning and parsing the compilation unit to the given errors.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the parse errors. Use either{@link #clear} or {@link #invalidate}.
- * @param errors the errors produced while scanning and parsing the compilation unit
- */
- void set parseErrors(List<AnalysisError> errors) {
- _parseErrors = errors;
- _parseErrorsState = CacheState.VALID;
- }
- /**
- * Set the errors produced while resolving the compilation unit to the given errors.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the resolution errors. Use either{@link #clear} or {@link #invalidate}.
- * @param errors the errors produced while resolving the compilation unit
- */
- void set resolutionErrors(List<AnalysisError> errors) {
- _resolutionErrors = errors;
- _resolutionErrorsState = CacheState.VALID;
- }
- /**
- * Set the resolved compilation unit to the given compilation unit.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the resolved compilation unit. Use
- * either {@link #clear} or {@link #invalidate}.
- * @param unit the resolved compilation unit
- */
- void set resolvedCompilationUnit(CompilationUnit unit) {
- _resolvedUnit = unit;
- _resolvedUnitState = CacheState.VALID;
- }
- void copyFrom(SourceInfo info) {
- super.copyFrom(info);
- }
-}
-/**
- * Instances of the class {@code DartInfo} acts as a placeholder for Dart compilation units that
- * have not yet had their kind computed.
- * @coverage dart.engine
- */
-class DartInfo extends SourceInfo {
- /**
- * The instance of this class used to represent a compilation unit for which an attempt was made
- * to compute the kind but the kind could not be computed.
- */
- static DartInfo _ErrorInstance = new DartInfo();
- /**
- * The instance of this class used to represent a compilation unit for which no attempt has been
- * made to compute the kind.
- */
- static DartInfo _PendingInstance = new DartInfo();
- /**
- * Return an instance of this class representing a compilation unit for which an attempt was made
- * to compute the kind but the kind could not be computed.
- * @return an instance of this class used to indicate that the computation of the kind resulted in
- * an error and there is no point trying again
- */
- static DartInfo get errorInstance => _ErrorInstance;
- /**
- * Return an instance of this class representing a compilation unit for which no attempt has been
- * made to compute the kind.
- * @return an instance of this class used to indicate that the computation of the kind is pending
- */
- static DartInfo get pendingInstance => _PendingInstance;
- /**
- * Prevent the creation of instances of this class.
- */
- DartInfo() : super() {
- }
- DartInfo copy() => this;
- SourceKind get kind => SourceKind.UNKNOWN;
-}
-/**
* Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link AnalysisContextImplanalysis context} to delegate sources to the appropriate analysis context. For instance, if the
* source is in a system library then the analysis context from the {@link DartSdk} is used.
* @coverage dart.engine
@@ -2231,7 +3054,7 @@
*/
DelegatingAnalysisContextImpl() : super() {
}
- void addSourceInfo(Source source, SourceInfo info) {
+ void addSourceInfo(Source source, SourceEntry info) {
if (source.isInSystemLibrary()) {
_sdkAnalysisContext.addSourceInfo(source, info);
} else {
@@ -2398,18 +3221,18 @@
super.recordLibraryElements(elementMap);
}
}
- void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInfo lineInfo) {
+ void recordResolutionErrors(Source source, Source librarySource, List<AnalysisError> errors, LineInfo lineInfo) {
if (source.isInSystemLibrary()) {
- _sdkAnalysisContext.recordResolutionErrors(source, errors, lineInfo);
+ _sdkAnalysisContext.recordResolutionErrors(source, librarySource, errors, lineInfo);
} else {
- super.recordResolutionErrors(source, errors, lineInfo);
+ super.recordResolutionErrors(source, librarySource, errors, lineInfo);
}
}
- void recordResolvedCompilationUnit(Source source, CompilationUnit unit) {
+ void recordResolvedCompilationUnit(Source source, Source librarySource, CompilationUnit unit) {
if (source.isInSystemLibrary()) {
- _sdkAnalysisContext.recordResolvedCompilationUnit(source, unit);
+ _sdkAnalysisContext.recordResolvedCompilationUnit(source, librarySource, unit);
} else {
- super.recordResolvedCompilationUnit(source, unit);
+ super.recordResolvedCompilationUnit(source, librarySource, unit);
}
}
CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) {
@@ -2445,183 +3268,16 @@
DartSdk sdk = factory.dartSdk;
if (sdk != null) {
_sdkAnalysisContext = sdk.context as InternalAnalysisContext;
+ if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) {
+ _sdkAnalysisContext = null;
+ throw new IllegalStateException("The context provided by an SDK cannot itself be a delegating analysis context");
+ }
} else {
throw new IllegalStateException("SourceFactorys provided to DelegatingAnalysisContextImpls must have a DartSdk associated with the provided SourceFactory.");
}
}
}
/**
- * Instances of the class {@code HtmlUnitInfo} maintain the information cached by an analysis
- * context about an individual HTML file.
- * @coverage dart.engine
- */
-class HtmlUnitInfo extends SourceInfo {
- /**
- * The state of the cached parsed (but not resolved) HTML unit.
- */
- CacheState _parsedUnitState = CacheState.INVALID;
- /**
- * The parsed HTML unit, or {@code null} if the parsed HTML unit is not currently cached.
- */
- HtmlUnit _parsedUnit;
- /**
- * The state of the cached parsed and resolved HTML unit.
- */
- CacheState _resolvedUnitState = CacheState.INVALID;
- /**
- * The resolved HTML unit, or {@code null} if the resolved HTML unit is not currently cached.
- */
- HtmlUnit _resolvedUnit;
- /**
- * The state of the cached HTML element.
- */
- CacheState _elementState = CacheState.INVALID;
- /**
- * The element representing the HTML file, or {@code null} if the element is not currently cached.
- */
- HtmlElement _element;
- /**
- * The state of the cached library sources.
- */
- CacheState _librarySourcesState = CacheState.INVALID;
- /**
- * The sources of libraries referenced by this HTML file.
- */
- List<Source> _librarySources = Source.EMPTY_ARRAY;
- /**
- * Initialize a newly created information holder to be empty.
- */
- HtmlUnitInfo() : super() {
- }
- /**
- * Remove the parsed HTML unit from the cache.
- */
- void clearParsedUnit() {
- _parsedUnit = null;
- _parsedUnitState = CacheState.FLUSHED;
- }
- /**
- * Remove the resolved HTML unit from the cache.
- */
- void clearResolvedUnit() {
- _resolvedUnit = null;
- _resolvedUnitState = CacheState.FLUSHED;
- }
- HtmlUnitInfo copy() {
- HtmlUnitInfo copy = new HtmlUnitInfo();
- copy.copyFrom(this);
- return copy;
- }
- /**
- * Return the element representing the HTML file, or {@code null} if the element is not currently
- * cached.
- * @return the element representing the HTML file
- */
- HtmlElement get element => _element;
- SourceKind get kind => SourceKind.HTML;
- /**
- * Return the sources of libraries referenced by this HTML file.
- * @return the sources of libraries referenced by this HTML file
- */
- List<Source> get librarySources => _librarySources;
- /**
- * Return the parsed HTML unit, or {@code null} if the parsed HTML unit is not currently cached.
- * @return the parsed HTML unit
- */
- HtmlUnit get parsedUnit => _parsedUnit;
- /**
- * Return the resolved HTML unit, or {@code null} if the resolved HTML unit is not currently
- * cached.
- * @return the resolved HTML unit
- */
- HtmlUnit get resolvedUnit => _resolvedUnit;
- /**
- * Return {@code true} if the HTML element needs to be recomputed.
- * @return {@code true} if the HTML element needs to be recomputed
- */
- bool hasInvalidElement() => identical(_elementState, CacheState.INVALID);
- /**
- * Return {@code true} if the parsed HTML unit needs to be recomputed.
- * @return {@code true} if the parsed HTML unit needs to be recomputed
- */
- bool hasInvalidParsedUnit() => identical(_parsedUnitState, CacheState.INVALID);
- /**
- * Return {@code true} if the resolved HTML unit needs to be recomputed.
- * @return {@code true} if the resolved HTML unit needs to be recomputed
- */
- bool hasInvalidResolvedUnit() => identical(_resolvedUnitState, CacheState.INVALID);
- /**
- * Mark the HTML element as needing to be recomputed.
- */
- void invalidateElement() {
- _elementState = CacheState.INVALID;
- _element = null;
- }
- /**
- * Mark the library sources as needing to be recomputed.
- */
- void invalidateLibrarySources() {
- _librarySourcesState = CacheState.INVALID;
- _librarySources = Source.EMPTY_ARRAY;
- }
- /**
- * Mark the parsed HTML unit as needing to be recomputed.
- */
- void invalidateParsedUnit() {
- _parsedUnitState = CacheState.INVALID;
- _parsedUnit = null;
- }
- /**
- * Mark the resolved HTML unit as needing to be recomputed.
- */
- void invalidateResolvedUnit() {
- invalidateElement();
- _resolvedUnitState = CacheState.INVALID;
- _resolvedUnit = null;
- }
- /**
- * Set the element representing the HTML file to the given element.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the element. Use either{@link #clearElement()} or {@link #invalidateElement()}.
- * @param element the element representing the HTML file
- */
- void set element(HtmlElement element2) {
- this._element = element2;
- _elementState = CacheState.VALID;
- }
- /**
- * Set the sources of libraries referenced by this HTML file to the given sources.
- * @param sources the sources of libraries referenced by this HTML file
- */
- void set librarySources(List<Source> sources) {
- _librarySources = sources;
- _librarySourcesState = CacheState.VALID;
- }
- /**
- * Set the parsed HTML unit to the given HTML unit.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the HTML unit. Use either{@link #clearParsedUnit()} or {@link #invalidateParsedUnit()}.
- * @param unit the result of parsing the source as an HTML unit
- */
- void set parsedUnit(HtmlUnit unit) {
- _parsedUnit = unit;
- _parsedUnitState = CacheState.VALID;
- }
- /**
- * Set the resolved HTML unit to the given HTML unit.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the HTML unit. Use either{@link #clearResolvedUnit()} or {@link #invalidateResolvedUnit()}.
- * @param unit the result of resolving the source as an HTML unit
- */
- void set resolvedUnit(HtmlUnit unit) {
- _resolvedUnit = unit;
- _resolvedUnitState = CacheState.VALID;
- }
- void copyFrom(SourceInfo info) {
- super.copyFrom(info);
- }
-}
-/**
* Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@link AnalysisContext analysis context} by recording instrumentation data and delegating to
* another analysis context to do the non-instrumentation work.
* @coverage dart.engine
@@ -2647,10 +3303,10 @@
* Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@link AnalysisContextImpl} as the basis context.
*/
InstrumentedAnalysisContextImpl() {
- _jtd_constructor_175_impl();
+ _jtd_constructor_178_impl();
}
- _jtd_constructor_175_impl() {
- _jtd_constructor_176_impl(new AnalysisContextImpl());
+ _jtd_constructor_178_impl() {
+ _jtd_constructor_179_impl(new AnalysisContextImpl());
}
/**
* Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis context, aka the
@@ -2658,12 +3314,12 @@
* @param context some {@link InstrumentedAnalysisContext} to wrap and instrument
*/
InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) {
- _jtd_constructor_176_impl(context);
+ _jtd_constructor_179_impl(context);
}
- _jtd_constructor_176_impl(InternalAnalysisContext context) {
+ _jtd_constructor_179_impl(InternalAnalysisContext context) {
_basis = context;
}
- void addSourceInfo(Source source, SourceInfo info) {
+ void addSourceInfo(Source source, SourceEntry info) {
_basis.addSourceInfo(source, info);
}
void applyChanges(ChangeSet changeSet) {
@@ -2675,6 +3331,15 @@
instrumentation.log();
}
}
+ String computeDocumentationComment(Element element) {
+ InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-computeDocumentationComment");
+ try {
+ instrumentation.metric3("contextId", _contextId);
+ return _basis.computeDocumentationComment(element);
+ } finally {
+ instrumentation.log();
+ }
+ }
List<AnalysisError> computeErrors(Source source) {
InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-computeErrors");
try {
@@ -2983,11 +3648,11 @@
void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
_basis.recordLibraryElements(elementMap);
}
- void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInfo lineInfo) {
- _basis.recordResolutionErrors(source, errors, lineInfo);
+ void recordResolutionErrors(Source source, Source librarySource, List<AnalysisError> errors, LineInfo lineInfo) {
+ _basis.recordResolutionErrors(source, librarySource, errors, lineInfo);
}
- void recordResolvedCompilationUnit(Source source, CompilationUnit unit) {
- _basis.recordResolvedCompilationUnit(source, unit);
+ void recordResolvedCompilationUnit(Source source, Source librarySource, CompilationUnit unit) {
+ _basis.recordResolvedCompilationUnit(source, librarySource, unit);
}
CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement library) {
InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-resolveCompilationUnit");
@@ -3063,7 +3728,7 @@
* @param source the source to be added
* @param info the information about the source
*/
- void addSourceInfo(Source source, SourceInfo info);
+ void addSourceInfo(Source source, SourceEntry info);
/**
* Return an AST structure corresponding to the given source, but ensure that the structure has
* not already been resolved and will not be resolved by any other threads or in any other
@@ -3108,245 +3773,20 @@
* Give the resolution errors and line info associated with the given source, add the information
* to the cache.
* @param source the source with which the information is associated
+ * @param librarySource the source of the defining compilation unit of the library in which the
+ * source was resolved
* @param errors the resolution errors associated with the source
* @param lineInfo the line information associated with the source
*/
- void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInfo lineInfo);
+ void recordResolutionErrors(Source source, Source librarySource, List<AnalysisError> errors, LineInfo lineInfo);
/**
* Give the resolved compilation unit associated with the given source, add the unit to the cache.
* @param source the source with which the unit is associated
+ * @param librarySource the source of the defining compilation unit of the library in which the
+ * source was resolved
* @param unit the compilation unit associated with the source
*/
- void recordResolvedCompilationUnit(Source source, CompilationUnit unit);
-}
-/**
- * Instances of the class {@code LibraryInfo} maintain the information cached by an analysis context
- * about an individual library.
- * @coverage dart.engine
- */
-class LibraryInfo extends CompilationUnitInfo {
- /**
- * Mask indicating that this library is launchable: that the file has a main method.
- */
- static int _LAUNCHABLE = 1 << 1;
- /**
- * Mask indicating that the library is client code: that the library depends on the html library.
- * If the library is not "client code", then it is referenced as "server code".
- */
- static int _CLIENT_CODE = 1 << 2;
- /**
- * The state of the cached library element.
- */
- CacheState _elementState = CacheState.INVALID;
- /**
- * The element representing the library, or {@code null} if the element is not currently cached.
- */
- LibraryElement _element;
- /**
- * The state of the cached unit sources.
- */
- CacheState _unitSourcesState = CacheState.INVALID;
- /**
- * The sources of the compilation units that compose the library, including both the defining
- * compilation unit and any parts.
- */
- List<Source> _unitSources = Source.EMPTY_ARRAY;
- /**
- * The state of the cached public namespace.
- */
- CacheState _publicNamespaceState = CacheState.INVALID;
- /**
- * The public namespace of the library, or {@code null} if the namespace is not currently cached.
- */
- Namespace _publicNamespace;
- /**
- * The state of the cached client/ server flag.
- */
- CacheState _clientServerState = CacheState.INVALID;
- /**
- * The state of the cached launchable flag.
- */
- CacheState _launchableState = CacheState.INVALID;
- /**
- * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT_CODE}.
- */
- int _bitmask = 0;
- /**
- * Initialize a newly created information holder to be empty.
- */
- LibraryInfo() : super() {
- }
- /**
- * Remove the library element from the cache.
- */
- void clearElement() {
- _element = null;
- _elementState = CacheState.FLUSHED;
- }
- /**
- * Remove the public namespace from the cache.
- */
- void clearPublicNamespace() {
- _publicNamespace = null;
- _publicNamespaceState = CacheState.FLUSHED;
- }
- LibraryInfo copy() {
- LibraryInfo copy = new LibraryInfo();
- copy.copyFrom(this);
- return copy;
- }
- /**
- * Return the element representing the library, or {@code null} if the element is not currently
- * cached.
- * @return the element representing the library
- */
- LibraryElement get element => _element;
- SourceKind get kind => SourceKind.LIBRARY;
- /**
- * Return the public namespace of the library, or {@code null} if the namespace is not currently
- * cached.
- * @return the public namespace of the library
- */
- Namespace get publicNamespace => _publicNamespace;
- /**
- * Return the sources of the compilation units that compose the library, including both the
- * defining compilation unit and any parts.
- * @return the sources of the compilation units that compose the library
- */
- List<Source> get unitSources => _unitSources;
- /**
- * Return {@code true} if the client/ server flag needs to be recomputed.
- * @return {@code true} if the client/ server flag needs to be recomputed
- */
- bool hasInvalidClientServer() => identical(_clientServerState, CacheState.INVALID);
- /**
- * Return {@code true} if the library element needs to be recomputed.
- * @return {@code true} if the library element needs to be recomputed
- */
- bool hasInvalidElement() => identical(_elementState, CacheState.INVALID);
- /**
- * Return {@code true} if the launchable flag needs to be recomputed.
- * @return {@code true} if the launchable flag needs to be recomputed
- */
- bool hasInvalidLaunchable() => identical(_launchableState, CacheState.INVALID);
- /**
- * Return {@code true} if the public namespace needs to be recomputed.
- * @return {@code true} if the public namespace needs to be recomputed
- */
- bool hasInvalidPublicNamespace() => identical(_publicNamespaceState, CacheState.INVALID);
- /**
- * Mark the client/ server flag as needing to be recomputed.
- */
- void invalidateClientServer() {
- _clientServerState = CacheState.INVALID;
- _bitmask &= ~_CLIENT_CODE;
- }
- /**
- * Mark the library element as needing to be recomputed.
- */
- void invalidateElement() {
- _elementState = CacheState.INVALID;
- _element = null;
- }
- /**
- * Mark the launchable flag as needing to be recomputed.
- */
- void invalidateLaunchable() {
- _launchableState = CacheState.INVALID;
- _bitmask &= ~_LAUNCHABLE;
- }
- /**
- * Mark the public namespace as needing to be recomputed.
- */
- void invalidatePublicNamespace() {
- _publicNamespaceState = CacheState.INVALID;
- _publicNamespace = null;
- }
- /**
- * Mark the compilation unit sources as needing to be recomputed.
- */
- void invalidateUnitSources() {
- _unitSourcesState = CacheState.INVALID;
- _unitSources = Source.EMPTY_ARRAY;
- }
- /**
- * Return {@code true} if this library is client based code: the library depends on the html
- * library.
- * @return {@code true} if this library is client based code: the library depends on the html
- * library
- */
- bool isClient() => (_bitmask & _CLIENT_CODE) != 0;
- /**
- * Return {@code true} if this library is launchable: the file includes a main method.
- * @return {@code true} if this library is launchable: the file includes a main method
- */
- bool isLaunchable() => (_bitmask & _LAUNCHABLE) != 0;
- /**
- * Return {@code true} if this library is server based code: the library does not depends on the
- * html library.
- * @return {@code true} if this library is server based code: the library does not depends on the
- * html library
- */
- bool isServer() => (_bitmask & _CLIENT_CODE) == 0;
- /**
- * Sets the value of the client/ server flag.
- * <p>
- * <b>Note:</b> Do not use this method to invalidate the flag, use{@link #invalidateClientServer()}.
- * @param isClient the new value of the client flag
- */
- void set client(bool isClient) {
- if (isClient) {
- _bitmask |= _CLIENT_CODE;
- } else {
- _bitmask &= ~_CLIENT_CODE;
- }
- _clientServerState = CacheState.VALID;
- }
- /**
- * Set the element representing the library to the given element.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the element. Use either{@link #clearElement()} or {@link #invalidateElement()}.
- * @param element the element representing the library
- */
- void set element(LibraryElement element2) {
- this._element = element2;
- _elementState = CacheState.VALID;
- }
- /**
- * Sets the value of the launchable flag.
- * <p>
- * <b>Note:</b> Do not use this method to invalidate the flag, use {@link #invalidateLaunchable()}.
- * @param isClient the new value of the client flag
- */
- void set launchable(bool launchable2) {
- if (launchable2) {
- _bitmask |= _LAUNCHABLE;
- } else {
- _bitmask &= ~_LAUNCHABLE;
- }
- _launchableState = CacheState.VALID;
- }
- /**
- * Set the public namespace of the library to the given namespace.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the element. Use either{@link #clearPublicNamespace()} or {@link #invalidatePublicNamespace()}.
- * @param namespace the public namespace of the library
- */
- void set publicNamespace(Namespace namespace) {
- _publicNamespace = namespace;
- _publicNamespaceState = CacheState.VALID;
- }
- /**
- * Set the sources of the compilation units that compose the library to the given sources.
- * @param sources the sources of the compilation units that compose the library
- */
- void set unitSources(List<Source> sources) {
- _unitSourcesState = CacheState.VALID;
- _unitSources = sources;
- }
- void copyFrom(SourceInfo info) {
- super.copyFrom(info);
- }
+ void recordResolvedCompilationUnit(Source source, Source librarySource, CompilationUnit unit);
}
/**
* Instances of the class {@code RecordingErrorListener} implement an error listener that will
@@ -3470,80 +3910,6 @@
}
}
/**
- * Instances of the class {@code SourceInfo} maintain the information cached by an analysis context
- * about an individual source.
- * @coverage dart.engine
- */
-abstract class SourceInfo {
- /**
- * The state of the cached line information.
- */
- CacheState _lineInfoState = CacheState.INVALID;
- /**
- * The line information computed for the source, or {@code null} if the line information is not
- * currently cached.
- */
- LineInfo _lineInfo;
- /**
- * Initialize a newly created information holder to be empty.
- */
- SourceInfo() : super() {
- }
- /**
- * Remove the line information from the cache.
- */
- void clearLineInfo() {
- _lineInfo = null;
- _lineInfoState = CacheState.FLUSHED;
- }
- /**
- * Return a copy of this information holder.
- * @return a copy of this information holder
- */
- SourceInfo copy();
- /**
- * Return the kind of the source, or {@code null} if the kind is not currently cached.
- * @return the kind of the source
- */
- SourceKind get kind;
- /**
- * Return the line information computed for the source, or {@code null} if the line information is
- * not currently cached.
- * @return the line information computed for the source
- */
- LineInfo get lineInfo => _lineInfo;
- /**
- * Return {@code true} if the line information needs to be recomputed.
- * @return {@code true} if the line information needs to be recomputed
- */
- bool hasInvalidLineInfo() => identical(_lineInfoState, CacheState.INVALID);
- /**
- * Mark the line information as needing to be recomputed.
- */
- void invalidateLineInfo() {
- _lineInfoState = CacheState.INVALID;
- _lineInfo = null;
- }
- /**
- * Set the line information for the source to the given line information.
- * <p>
- * <b>Note:</b> Do not use this method to clear or invalidate the element. Use either{@link #clearLineInfo()} or {@link #invalidateLineInfo()}.
- * @param info the line information for the source
- */
- void set lineInfo(LineInfo info) {
- _lineInfo = info;
- _lineInfoState = CacheState.VALID;
- }
- /**
- * Copy the information from the given information holder.
- * @param info the information holder from which information will be copied
- */
- void copyFrom(SourceInfo info) {
- _lineInfoState = info._lineInfoState;
- _lineInfo = info._lineInfo;
- }
-}
-/**
* The interface {@code Logger} defines the behavior of objects that can be used to receive
* information about errors within the analysis engine. Implementations usually write this
* information to a file, but can also record the information for later use (such as during testing)
diff --git a/pkg/analyzer_experimental/lib/src/generated/error.dart b/pkg/analyzer_experimental/lib/src/generated/error.dart
index 177546d..1f684c9 100644
--- a/pkg/analyzer_experimental/lib/src/generated/error.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/error.dart
@@ -107,7 +107,7 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError(ErrorCode errorCode, ASTNode node, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, arguments));
}
/**
* Report an error with the given error code and arguments.
@@ -116,7 +116,7 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError2(ErrorCode errorCode, Token token, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, arguments));
}
/**
* Set the source to be used when reporting errors. Setting the source to {@code null} will cause
@@ -499,8 +499,8 @@
static final CompileTimeErrorCode DUPLICATE_MEMBER_NAME_INSTANCE_STATIC = new CompileTimeErrorCode('DUPLICATE_MEMBER_NAME_INSTANCE_STATIC', 24, "");
/**
* 12.14.2 Binding Actuals to Formals: It is a compile-time error if <i>q<sub>i</sub> =
- * q<sub>j</sub></i> for any <i>i != j</i> [where <i>q<sub>i</sub></i> is the label for a named
- * argument].
+ * q<sub>j</sub></i> for any <i>i != j</i> \[where <i>q<sub>i</sub></i> is the label for a named
+ * argument\].
*/
static final CompileTimeErrorCode DUPLICATE_NAMED_ARGUMENT = new CompileTimeErrorCode('DUPLICATE_NAMED_ARGUMENT', 25, "");
/**
@@ -552,18 +552,18 @@
/**
* 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It is a compile time
* error if more than one initializer corresponding to a given instance variable appears in
- * <i>k</i>’s list.
+ * <i>k</i>'s list.
*/
static final CompileTimeErrorCode FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS = new CompileTimeErrorCode('FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS', 30, "The field '%s' cannot be initialized twice in the same constructor");
/**
* 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It is a compile time
- * error if <i>k</i>’s initializer list contains an initializer for a final variable <i>f</i>
+ * error if <i>k</i>'s initializer list contains an initializer for a final variable <i>f</i>
* whose declaration includes an initialization expression.
*/
static final CompileTimeErrorCode FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION = new CompileTimeErrorCode('FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION', 31, "Values cannot be set in the constructor if they are final, and have already been set");
/**
* 7.6.1 Generative Constructors: Let <i>k</i> be a generative constructor. It is a compile time
- * error if <i>k</i>’s initializer list contains an initializer for a variable that is initialized
+ * error if <i>k</i>'s initializer list contains an initializer for a variable that is initialized
* by means of an initializing formal of <i>k</i>.
*/
static final CompileTimeErrorCode FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER = new CompileTimeErrorCode('FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER', 32, "Fields cannot be initialized in both the parameter list and the initializers");
@@ -577,7 +577,7 @@
* at its point of declaration is also initialized in a constructor.
* @param name the name of the field in question
*/
- static final CompileTimeErrorCode FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR = new CompileTimeErrorCode('FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR', 34, "'%s' is final and was given a value when it was declared, so it cannot be set to a new value");
+ static final CompileTimeErrorCode FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR = new CompileTimeErrorCode('FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR', 34, "'%s' is final and was given a value when it was declared, so it cannot be set to a new value");
/**
* 5 Variables: It is a compile-time error if a final instance variable that has is initialized by
* means of an initializing formal of a constructor is also initialized elsewhere in the same
@@ -702,8 +702,9 @@
*/
static final CompileTimeErrorCode INVALID_OVERRIDE_NAMED = new CompileTimeErrorCode('INVALID_OVERRIDE_NAMED', 53, "");
/**
- * 7.1 Instance Methods: It is a compile-time error if an instance method m1 overrides an instance
- * member <i>m2</i> and <i>m1</i> has fewer optional positional parameters than <i>m2</i>.
+ * 7.1 Instance Methods: It is a compile-time error if an instance method <i>m1</i> overrides an
+ * instance member <i>m2</i> and <i>m1</i> has fewer optional positional parameters than
+ * <i>m2</i>.
*/
static final CompileTimeErrorCode INVALID_OVERRIDE_POSITIONAL = new CompileTimeErrorCode('INVALID_OVERRIDE_POSITIONAL', 54, "");
/**
@@ -726,13 +727,15 @@
/**
* 12.6 Lists: It is a compile time error if the type argument of a constant list literal includes
* a type parameter.
+ * @name the name of the type parameter
*/
- static final CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_LIST = new CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_LIST', 58, "");
+ static final CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_LIST = new CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_LIST', 58, "Constant list literals cannot include a type parameter as a type argument, such as '%s'");
/**
* 12.7 Maps: It is a compile time error if the type arguments of a constant map literal include a
* type parameter.
+ * @name the name of the type parameter
*/
- static final CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_MAP = new CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_MAP', 59, "");
+ static final CompileTimeErrorCode INVALID_TYPE_ARGUMENT_IN_CONST_MAP = new CompileTimeErrorCode('INVALID_TYPE_ARGUMENT_IN_CONST_MAP', 59, "Constant map literals cannot include a type parameter as a type argument, such as '%s'");
/**
* 14.2 Exports: It is a compile-time error if the compilation unit found at the specified URI is
* not a library declaration.
@@ -858,7 +861,7 @@
/**
* 7.1.1 Operators: It is a compile-time error to declare an optional parameter in an operator.
*/
- static final CompileTimeErrorCode OPTIONAL_PARAMETER_IN_OPERATOR = new CompileTimeErrorCode('OPTIONAL_PARAMETER_IN_OPERATOR', 80, "");
+ static final CompileTimeErrorCode OPTIONAL_PARAMETER_IN_OPERATOR = new CompileTimeErrorCode('OPTIONAL_PARAMETER_IN_OPERATOR', 80, "Optional parameters are not allowed when defining an operator");
/**
* 8 Interfaces: It is a compile-time error if an interface member <i>m1</i> overrides an
* interface member <i>m2</i> and <i>m1</i> does not declare all the named parameters declared by
@@ -884,9 +887,9 @@
static final CompileTimeErrorCode PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER = new CompileTimeErrorCode('PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER', 84, "");
/**
* 6.2.2 Optional Formals: It is a compile-time error if the name of a named optional parameter
- * begins with an ‘_’ character.
+ * begins with an '_' character.
*/
- static final CompileTimeErrorCode PRIVATE_OPTIONAL_PARAMETER = new CompileTimeErrorCode('PRIVATE_OPTIONAL_PARAMETER', 85, "");
+ static final CompileTimeErrorCode PRIVATE_OPTIONAL_PARAMETER = new CompileTimeErrorCode('PRIVATE_OPTIONAL_PARAMETER', 85, "Named optional parameters cannot start with an underscore");
/**
* 12.1 Constants: It is a compile-time error if the value of a compile-time constant expression
* depends on itself.
@@ -908,7 +911,7 @@
static final CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE = new CompileTimeErrorCode('RECURSIVE_INTERFACE_INHERITANCE', 89, "");
/**
* 7.6.2 Factories: It is a compile-time error if <i>k</i> is prefixed with the const modifier but
- * <i>k’</i> is not a constant constructor.
+ * <i>k'</i> is not a constant constructor.
*/
static final CompileTimeErrorCode REDIRECT_TO_NON_CONST_CONSTRUCTOR = new CompileTimeErrorCode('REDIRECT_TO_NON_CONST_CONSTRUCTOR', 90, "");
/**
@@ -930,7 +933,7 @@
* 13.11 Return: It is a compile-time error if a return statement of the form <i>return e;</i>
* appears in a generative constructor.
*/
- static final CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR = new CompileTimeErrorCode('RETURN_IN_GENERATIVE_CONSTRUCTOR', 94, "");
+ static final CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR = new CompileTimeErrorCode('RETURN_IN_GENERATIVE_CONSTRUCTOR', 94, "Constructors cannot return a value");
/**
* 6.1 Function Declarations: It is a compile-time error to preface a function declaration with
* the built-in identifier static.
@@ -995,18 +998,19 @@
*/
static final CompileTimeErrorCode URI_WITH_INTERPOLATION = new CompileTimeErrorCode('URI_WITH_INTERPOLATION', 102, "URIs cannot use string interpolation");
/**
- * 7.1.1 Operators: It is a compile-time error if the arity of the user-declared operator []= is
+ * 7.1.1 Operators: It is a compile-time error if the arity of the user-declared operator \[\]= is
* not 2. It is a compile time error if the arity of a user-declared operator with one of the
- * names: <, >, <=, >=, ==, +, /, ~/, *, %, |, ^, &, <<, >>, [] is not 1.
+ * names: <, >, <=, >=, ==, +, /, ~/, *, %, |, ^, &, <<, >>, \[\] is not 1.
* It is a compile time error if the arity of the user-declared operator - is not 0 or 1. It is a
* compile time error if the arity of the user-declared operator ~ is not 0.
*/
static final CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR = new CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR', 103, "");
/**
- * 7.3 Setters: It is a compile-time error if a setter’s formal parameter list does not include
+ * 7.3 Setters: It is a compile-time error if a setter's formal parameter list does not include
* exactly one required formal parameter <i>p</i>.
+ * @param numberOfParameters the number of parameters found in the setter
*/
- static final CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER = new CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER', 104, "");
+ static final CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER = new CompileTimeErrorCode('WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER', 104, "Setters should declare exactly one parameter, %d found");
/**
* 12.11 Instance Creation: It is a compile-time error if a constructor of a generic type with
* <i>n</i> type parameters invoked by a new expression or a constant object expression is passed
@@ -1086,7 +1090,7 @@
*/
static final StaticWarningCode CAST_TO_NON_TYPE = new StaticWarningCode('CAST_TO_NON_TYPE', 3, "");
/**
- * 16.1.2 Comments: A token of the form <i>[new c](uri)</i> will be replaced by a link in the
+ * 16.1.2 Comments: A token of the form <i>\[new c\](uri)</i> will be replaced by a link in the
* formatted output. The link will point at the constructor named <i>c</i> in <i>L</i>. The title
* of the link will be <i>c</i>. It is a static warning if uri is not the URI of a dart library
* <i>L</i>, or if <i>c</i> is not the name of a constructor of a class declared in the exported
@@ -1094,7 +1098,7 @@
*/
static final StaticWarningCode COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE = new StaticWarningCode('COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE', 4, "");
/**
- * 16.1.2 Comments: A token of the form <i>[id](uri)</i> will be replaced by a link in the
+ * 16.1.2 Comments: A token of the form <i>\[id\](uri)</i> will be replaced by a link in the
* formatted output. The link will point at the declaration named <i>id</i> in <i>L</i>. The title
* of the link will be <i>id</i>. It is a static warning if uri is not the URI of a dart library
* <i>L</i>, or if <i>id</i> is not a name declared in the exported namespace of <i>L</i>.
@@ -1111,7 +1115,7 @@
*/
static final StaticWarningCode COMMENT_REFERENCE_UNDECLARED_IDENTIFIER = new StaticWarningCode('COMMENT_REFERENCE_UNDECLARED_IDENTIFIER', 7, "");
/**
- * 16.1.2 Comments: A token of the form <i>[id](uri)</i> will be replaced by a link in the
+ * 16.1.2 Comments: A token of the form <i>\[id\](uri)</i> will be replaced by a link in the
* formatted output. The link will point at the declaration named <i>id</i> in <i>L</i>. The title
* of the link will be <i>id</i>. It is a static warning if uri is not the URI of a dart library
* <i>L</i>, or if <i>id</i> is not a name declared in the exported namespace of <i>L</i>.
@@ -1121,7 +1125,7 @@
* 7.4 Abstract Instance Members: It is a static warning if an abstract member is declared or
* inherited in a concrete class.
*/
- static final StaticWarningCode CONCRETE_CLASS_WITH_ABSTRACT_MEMBER = new StaticWarningCode('CONCRETE_CLASS_WITH_ABSTRACT_MEMBER', 9, "");
+ static final StaticWarningCode CONCRETE_CLASS_WITH_ABSTRACT_MEMBER = new StaticWarningCode('CONCRETE_CLASS_WITH_ABSTRACT_MEMBER', 9, "'%s' must have a method body because '%s' is not abstract");
/**
* 7.2 Getters: It is a static warning if a class <i>C</i> declares an instance getter named
* <i>v</i> and an accessible static member named <i>v</i> or <i>v=</i> is declared in a
@@ -1157,8 +1161,10 @@
/**
* 7.6.1 Generative Constructors: An initializing formal has the form <i>this.id</i>. It is a
* static warning if the static type of <i>id</i> is not assignable to <i>T<sub>id</sub></i>.
+ * @param parameterType the name of the type of the field formal parameter
+ * @param fieldType the name of the type of the field
*/
- static final StaticWarningCode FIELD_INITIALIZER_WITH_INVALID_TYPE = new StaticWarningCode('FIELD_INITIALIZER_WITH_INVALID_TYPE', 16, "");
+ static final StaticWarningCode FIELD_INITIALIZER_WITH_INVALID_TYPE = new StaticWarningCode('FIELD_INITIALIZER_WITH_INVALID_TYPE', 16, "The parameter type '%s' is incompatable with the field type '%s'");
/**
* 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m < h</i> or if <i>m >
* n</i>.
@@ -1246,7 +1252,7 @@
*/
static final StaticWarningCode NON_TYPE_IN_CATCH_CLAUSE = new StaticWarningCode('NON_TYPE_IN_CATCH_CLAUSE', 31, "");
/**
- * 7.1.1 Operators: It is a static warning if the return type of the user-declared operator []= is
+ * 7.1.1 Operators: It is a static warning if the return type of the user-declared operator \[\]= is
* explicitly declared and not void.
*/
static final StaticWarningCode NON_VOID_RETURN_FOR_OPERATOR = new StaticWarningCode('NON_VOID_RETURN_FOR_OPERATOR', 32, "");
@@ -1274,7 +1280,7 @@
*/
static final StaticWarningCode PART_OF_DIFFERENT_LIBRARY = new StaticWarningCode('PART_OF_DIFFERENT_LIBRARY', 36, "Expected this library to be part of '%s', not '%s'");
/**
- * 7.6.2 Factories: It is a static warning if the function type of <i>k’</i> is not a subtype of
+ * 7.6.2 Factories: It is a static warning if the function type of <i>k'</i> is not a subtype of
* the type of <i>k</i>.
*/
static final StaticWarningCode REDIRECT_TO_INVALID_RETURN_TYPE = new StaticWarningCode('REDIRECT_TO_INVALID_RETURN_TYPE', 37, "");
@@ -1298,7 +1304,7 @@
* <li>The return type of <i>f</i> may not be assigned to void.
* </ol>
*/
- static final StaticWarningCode RETURN_WITHOUT_VALUE = new StaticWarningCode('RETURN_WITHOUT_VALUE', 40, "");
+ static final StaticWarningCode RETURN_WITHOUT_VALUE = new StaticWarningCode('RETURN_WITHOUT_VALUE', 40, "Missing return value after 'return'");
/**
* 13.9 Switch: It is a static warning if the type of <i>e</i> may not be assigned to the type of
* <i>e<sub>k</sub></i>.
@@ -1312,20 +1318,24 @@
*/
static final StaticWarningCode UNDEFINED_CLASS = new StaticWarningCode('UNDEFINED_CLASS', 42, "Undefined class '%s'");
/**
+ * Same as {@link #UNDEFINED_CLASS}, but to catch using "boolean" instead of "bool".
+ */
+ static final StaticWarningCode UNDEFINED_CLASS_BOOLEAN = new StaticWarningCode('UNDEFINED_CLASS_BOOLEAN', 43, "Undefined class 'boolean'; did you mean 'bool'?");
+ /**
* 12.17 Getter Invocation: It is a static warning if there is no class <i>C</i> in the enclosing
* lexical scope of <i>i</i>, or if <i>C</i> does not declare, implicitly or explicitly, a getter
* named <i>m</i>.
* @param getterName the name of the getter
* @param enclosingType the name of the enclosing type where the getter is being looked for
*/
- static final StaticWarningCode UNDEFINED_GETTER = new StaticWarningCode('UNDEFINED_GETTER', 43, "There is no such getter '%s' in '%s'");
+ static final StaticWarningCode UNDEFINED_GETTER = new StaticWarningCode('UNDEFINED_GETTER', 44, "There is no such getter '%s' in '%s'");
/**
* 12.30 Identifier Reference: It is as static warning if an identifier expression of the form
* <i>id</i> occurs inside a top level or static function (be it function, method, getter, or
* setter) or variable initializer and there is no declaration <i>d</i> with name <i>id</i> in the
* lexical scope enclosing the expression.
*/
- static final StaticWarningCode UNDEFINED_IDENTIFIER = new StaticWarningCode('UNDEFINED_IDENTIFIER', 44, "Undefined name '%s'");
+ static final StaticWarningCode UNDEFINED_IDENTIFIER = new StaticWarningCode('UNDEFINED_IDENTIFIER', 45, "Undefined name '%s'");
/**
* 12.30 Identifier Reference: It is as static warning if an identifier expression of the form
* <i>id</i> occurs inside a top level or static function (be it function, method, getter, or
@@ -1334,7 +1344,7 @@
* @param operator the name of the operator
* @param enclosingType the name of the enclosing type where the operator is being looked for
*/
- static final StaticWarningCode UNDEFINED_OPERATOR = new StaticWarningCode('UNDEFINED_OPERATOR', 45, "There is no such operator '%s' in '%s'");
+ static final StaticWarningCode UNDEFINED_OPERATOR = new StaticWarningCode('UNDEFINED_OPERATOR', 46, "There is no such operator '%s' in '%s'");
/**
* 12.18 Assignment: It is as static warning if an assignment of the form <i>v = e</i> occurs
* inside a top level or static function (be it function, method, getter, or setter) or variable
@@ -1347,15 +1357,15 @@
* @param setterName the name of the getter
* @param enclosingType the name of the enclosing type where the setter is being looked for
*/
- static final StaticWarningCode UNDEFINED_SETTER = new StaticWarningCode('UNDEFINED_SETTER', 46, "There is no such setter '%s' in '%s'");
+ static final StaticWarningCode UNDEFINED_SETTER = new StaticWarningCode('UNDEFINED_SETTER', 47, "There is no such setter '%s' in '%s'");
/**
* 12.15.3 Static Invocation: It is a static warning if <i>C</i> does not declare a static method
* or getter <i>m</i>.
* @param methodName the name of the method
* @param enclosingType the name of the enclosing type where the method is being looked for
*/
- static final StaticWarningCode UNDEFINED_STATIC_METHOD_OR_GETTER = new StaticWarningCode('UNDEFINED_STATIC_METHOD_OR_GETTER', 47, "There is no such static method '%s' in '%s'");
- static final List<StaticWarningCode> values = [ARGUMENT_TYPE_NOT_ASSIGNABLE, ASSIGNMENT_TO_FINAL, CASE_BLOCK_NOT_TERMINATED, CAST_TO_NON_TYPE, COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE, COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE, COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR, COMMENT_REFERENCE_UNDECLARED_IDENTIFIER, COMMENT_REFERENCE_URI_NOT_LIBRARY, CONCRETE_CLASS_WITH_ABSTRACT_MEMBER, CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER, CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER, CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER, CONFLICTING_STATIC_SETTER_AND_INSTANCE_GETTER, CONST_WITH_ABSTRACT_CLASS, EQUAL_KEYS_IN_MAP, FIELD_INITIALIZER_WITH_INVALID_TYPE, INCORRECT_NUMBER_OF_ARGUMENTS, INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC, INVALID_FACTORY_NAME, INVALID_OVERRIDE_GETTER_TYPE, INVALID_OVERRIDE_RETURN_TYPE, INVALID_OVERRIDE_SETTER_RETURN_TYPE, INVOCATION_OF_NON_FUNCTION, MISMATCHED_GETTER_AND_SETTER_TYPES, NEW_WITH_ABSTRACT_CLASS, NEW_WITH_NON_TYPE, NEW_WITH_UNDEFINED_CONSTRUCTOR, NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER, NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_METHOD, NON_TYPE, NON_TYPE_IN_CATCH_CLAUSE, NON_VOID_RETURN_FOR_OPERATOR, NON_VOID_RETURN_FOR_SETTER, OVERRIDE_NOT_SUBTYPE, OVERRIDE_WITH_DIFFERENT_DEFAULT, PART_OF_DIFFERENT_LIBRARY, REDIRECT_TO_INVALID_RETURN_TYPE, REDIRECT_TO_MISSING_CONSTRUCTOR, REDIRECT_TO_NON_CLASS, RETURN_WITHOUT_VALUE, SWITCH_EXPRESSION_NOT_ASSIGNABLE, UNDEFINED_CLASS, UNDEFINED_GETTER, UNDEFINED_IDENTIFIER, UNDEFINED_OPERATOR, UNDEFINED_SETTER, UNDEFINED_STATIC_METHOD_OR_GETTER];
+ static final StaticWarningCode UNDEFINED_STATIC_METHOD_OR_GETTER = new StaticWarningCode('UNDEFINED_STATIC_METHOD_OR_GETTER', 48, "There is no such static method '%s' in '%s'");
+ static final List<StaticWarningCode> values = [ARGUMENT_TYPE_NOT_ASSIGNABLE, ASSIGNMENT_TO_FINAL, CASE_BLOCK_NOT_TERMINATED, CAST_TO_NON_TYPE, COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE, COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE, COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR, COMMENT_REFERENCE_UNDECLARED_IDENTIFIER, COMMENT_REFERENCE_URI_NOT_LIBRARY, CONCRETE_CLASS_WITH_ABSTRACT_MEMBER, CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER, CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER, CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER, CONFLICTING_STATIC_SETTER_AND_INSTANCE_GETTER, CONST_WITH_ABSTRACT_CLASS, EQUAL_KEYS_IN_MAP, FIELD_INITIALIZER_WITH_INVALID_TYPE, INCORRECT_NUMBER_OF_ARGUMENTS, INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC, INVALID_FACTORY_NAME, INVALID_OVERRIDE_GETTER_TYPE, INVALID_OVERRIDE_RETURN_TYPE, INVALID_OVERRIDE_SETTER_RETURN_TYPE, INVOCATION_OF_NON_FUNCTION, MISMATCHED_GETTER_AND_SETTER_TYPES, NEW_WITH_ABSTRACT_CLASS, NEW_WITH_NON_TYPE, NEW_WITH_UNDEFINED_CONSTRUCTOR, NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER, NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_METHOD, NON_TYPE, NON_TYPE_IN_CATCH_CLAUSE, NON_VOID_RETURN_FOR_OPERATOR, NON_VOID_RETURN_FOR_SETTER, OVERRIDE_NOT_SUBTYPE, OVERRIDE_WITH_DIFFERENT_DEFAULT, PART_OF_DIFFERENT_LIBRARY, REDIRECT_TO_INVALID_RETURN_TYPE, REDIRECT_TO_MISSING_CONSTRUCTOR, REDIRECT_TO_NON_CLASS, RETURN_WITHOUT_VALUE, SWITCH_EXPRESSION_NOT_ASSIGNABLE, UNDEFINED_CLASS, UNDEFINED_CLASS_BOOLEAN, UNDEFINED_GETTER, UNDEFINED_IDENTIFIER, UNDEFINED_OPERATOR, UNDEFINED_SETTER, UNDEFINED_STATIC_METHOD_OR_GETTER];
final String __name;
final int __ordinal;
int get ordinal => __ordinal;
@@ -1397,6 +1407,46 @@
}
}
/**
+ * The enumeration {@code HtmlWarningCode} defines the error codes used for warnings in HTML files.
+ * The convention for this class is for the name of the error code to indicate the problem that
+ * caused the error to be generated and for the error message to explain what is wrong and, when
+ * appropriate, how the problem can be corrected.
+ * @coverage dart.engine.error
+ */
+class HtmlWarningCode implements Comparable<HtmlWarningCode>, ErrorCode {
+ /**
+ * An error code indicating that the value of the 'src' attribute of a Dart script tag is not a
+ * valid URI.
+ */
+ static final HtmlWarningCode INVALID_URI = new HtmlWarningCode('INVALID_URI', 0, "");
+ /**
+ * An error code indicating that the value of the 'src' attribute of a Dart script tag references
+ * a file that does not exist.
+ */
+ static final HtmlWarningCode URI_DOES_NOT_EXIST = new HtmlWarningCode('URI_DOES_NOT_EXIST', 1, "");
+ static final List<HtmlWarningCode> values = [INVALID_URI, URI_DOES_NOT_EXIST];
+ final String __name;
+ final int __ordinal;
+ int get ordinal => __ordinal;
+ /**
+ * The message template used to create the message to be displayed for this error.
+ */
+ String _message;
+ /**
+ * Initialize a newly created error code to have the given type and message.
+ * @param message the message template used to create the message to be displayed for the error
+ */
+ HtmlWarningCode(this.__name, this.__ordinal, String message) {
+ this._message = message;
+ }
+ ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
+ String get message => _message;
+ ErrorType get type => ErrorType.STATIC_WARNING;
+ bool needsRecompilation() => false;
+ int compareTo(HtmlWarningCode other) => __ordinal - other.__ordinal;
+ String toString() => __name;
+}
+/**
* The enumeration {@code StaticTypeWarningCode} defines the error codes used for static type
* warnings. The convention for this class is for the name of the error code to indicate the problem
* that caused the error to be generated and for the error message to explain what is wrong and,
@@ -1489,7 +1539,7 @@
*/
static final StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT = new StaticTypeWarningCode('NON_TYPE_AS_TYPE_ARGUMENT', 6, "");
/**
- * 7.6.2 Factories: It is a static type warning if any of the type arguments to <i>k’</i> are not
+ * 7.6.2 Factories: It is a static type warning if any of the type arguments to <i>k'</i> are not
* subtypes of the bounds of the corresponding formal type parameters of type.
*/
static final StaticTypeWarningCode REDIRECT_WITH_INVALID_TYPE_PARAMETERS = new StaticTypeWarningCode('REDIRECT_WITH_INVALID_TYPE_PARAMETERS', 7, "");
@@ -1516,11 +1566,11 @@
* <p>
* 15.8 Parameterized Types: If <i>S</i> is the static type of a member <i>m</i> of <i>G</i>, then
* the static type of the member <i>m</i> of <i>G<A<sub>1</sub>, … A<sub>n</sub>></i>
- * is <i>[A<sub>1</sub>, …, A<sub>n</sub>/T<sub>1</sub>, …, T<sub>n</sub>]S</i>
+ * is <i>\[A<sub>1</sub>, …, A<sub>n</sub>/T<sub>1</sub>, …, T<sub>n</sub>\]S</i>
* where <i>T<sub>1</sub>, … T<sub>n</sub></i> are the formal type parameters of <i>G</i>.
* Let <i>B<sub>i</sub></i> be the bounds of <i>T<sub>i</sub>, 1 <= i <= n</i>. It is a
- * static type warning if <i>A<sub>i</sub></i> is not a subtype of <i>[A<sub>1</sub>, …,
- * A<sub>n</sub>/T<sub>1</sub>, …, T<sub>n</sub>]B<sub>i</sub>, 1 <= i <= n</i>.
+ * static type warning if <i>A<sub>i</sub></i> is not a subtype of <i>\[A<sub>1</sub>, …,
+ * A<sub>n</sub>/T<sub>1</sub>, …, T<sub>n</sub>\]B<sub>i</sub>, 1 <= i <= n</i>.
*/
static final StaticTypeWarningCode TYPE_ARGUMENT_VIOLATES_BOUNDS = new StaticTypeWarningCode('TYPE_ARGUMENT_VIOLATES_BOUNDS', 10, "");
/**
diff --git a/pkg/analyzer_experimental/lib/src/generated/html.dart b/pkg/analyzer_experimental/lib/src/generated/html.dart
index 58f2161..0c0d3cf 100644
--- a/pkg/analyzer_experimental/lib/src/generated/html.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/html.dart
@@ -43,10 +43,10 @@
* @param offset the offset from the beginning of the file to the first character in the token
*/
Token.con1(TokenType type, int offset) {
- _jtd_constructor_150_impl(type, offset);
+ _jtd_constructor_151_impl(type, offset);
}
- _jtd_constructor_150_impl(TokenType type, int offset) {
- _jtd_constructor_151_impl(type, offset, type.lexeme);
+ _jtd_constructor_151_impl(TokenType type, int offset) {
+ _jtd_constructor_152_impl(type, offset, type.lexeme);
}
/**
* Initialize a newly created token.
@@ -55,9 +55,9 @@
* @param value the lexeme represented by this token (not {@code null})
*/
Token.con2(TokenType type2, int offset2, String value2) {
- _jtd_constructor_151_impl(type2, offset2, value2);
+ _jtd_constructor_152_impl(type2, offset2, value2);
}
- _jtd_constructor_151_impl(TokenType type2, int offset2, String value2) {
+ _jtd_constructor_152_impl(TokenType type2, int offset2, String value2) {
this._type = type2;
this._value = StringUtilities.intern(value2);
this._offset = offset2;
diff --git a/pkg/analyzer_experimental/lib/src/generated/java_core.dart b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
index 0c40a7e..3bf99ccc 100644
--- a/pkg/analyzer_experimental/lib/src/generated/java_core.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
@@ -130,7 +130,21 @@
class JavaString {
static String format(String fmt, List args) {
- return fmt;
+ var index = 0;
+ return fmt.replaceAllMapped(new RegExp(r'%(.)'), (match) {
+ switch (match.group(1)) {
+ case '%': return '%';
+ case 's':
+ if (index >= args.length) {
+ throw new MissingFormatArgumentException(match.group(0));
+ }
+ return args[index++].toString();
+ default: return match.group(1);
+ }
+ });
+ }
+ static bool startsWithBefore(String s, String other, int start) {
+ return s.indexOf(other, start) != -1;
}
}
@@ -263,6 +277,14 @@
String toString() => "IOException";
}
+class MissingFormatArgumentException implements Exception {
+ final String s;
+
+ String toString() => "MissingFormatArgumentException: $s";
+
+ MissingFormatArgumentException(this.s);
+}
+
class ListWrapper<E> extends ListBase<E> implements List<E> {
List<E> elements = new List<E>();
diff --git a/pkg/analyzer_experimental/lib/src/generated/java_junit.dart b/pkg/analyzer_experimental/lib/src/generated/java_junit.dart
index 2ff97ad..1fa994e 100644
--- a/pkg/analyzer_experimental/lib/src/generated/java_junit.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/java_junit.dart
@@ -52,8 +52,7 @@
}
/**
- * Returns a matches that matches if the value is not the same instance
- * as [object] (`!==`).
+ * Returns a matches that matches if the value is not the same instance as "object" (`!==`).
*/
Matcher notSame(expected) => new _IsNotSameAs(expected);
diff --git a/pkg/analyzer_experimental/lib/src/generated/parser.dart b/pkg/analyzer_experimental/lib/src/generated/parser.dart
index 2c0da74..42fb425 100644
--- a/pkg/analyzer_experimental/lib/src/generated/parser.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/parser.dart
@@ -431,7 +431,7 @@
* | 'super' assignableSelector
* | identifier
* assignableSelector ::=
- * '[' expression ']'
+ * '\[' expression '\]'
* | '.' identifier
* </pre>
* @param expression the expression being checked
@@ -472,6 +472,23 @@
return _currentToken;
}
/**
+ * Search the given list of ranges for a range that contains the given index. Return the range
+ * that was found, or {@code null} if none of the ranges contain the index.
+ * @param ranges the ranges to be searched
+ * @param index the index contained in the returned range
+ * @return the range that was found
+ */
+ List<int> findRange(List<List<int>> ranges, int index) {
+ for (List<int> range in ranges) {
+ if (range[0] <= index && index <= range[1]) {
+ return range;
+ } else if (index < range[0]) {
+ return null;
+ }
+ }
+ return null;
+ }
+ /**
* Advance to the next token in the token stream, making it the new current token.
* @return the token that was current before this method was invoked
*/
@@ -481,6 +498,47 @@
return token;
}
/**
+ * Return a list of the ranges of characters in the given comment string that should be treated as
+ * code blocks.
+ * @param comment the comment being processed
+ * @return the ranges of characters that should be treated as code blocks
+ */
+ List<List<int>> getCodeBlockRanges(String comment) {
+ List<List<int>> ranges = new List<List<int>>();
+ int length2 = comment.length;
+ int index = 0;
+ if (comment.startsWith("/**") || comment.startsWith("///")) {
+ index = 3;
+ }
+ while (index < length2) {
+ int currentChar = comment.codeUnitAt(index);
+ if (currentChar == 0xD || currentChar == 0xA) {
+ index = index + 1;
+ while (index < length2 && Character.isWhitespace(comment.codeUnitAt(index))) {
+ index = index + 1;
+ }
+ if (JavaString.startsWithBefore(comment, "* ", index)) {
+ int end = index + 6;
+ while (end < length2 && comment.codeUnitAt(end) != 0xD && comment.codeUnitAt(end) != 0xA) {
+ end = end + 1;
+ }
+ ranges.add(<int> [index, end]);
+ index = end;
+ }
+ } else if (JavaString.startsWithBefore(comment, "[:", index)) {
+ int end = comment.indexOf(":]", index + 2);
+ if (end < 0) {
+ end = length2;
+ }
+ ranges.add(<int> [index, end]);
+ index = end + 1;
+ } else {
+ index = index + 1;
+ }
+ }
+ return ranges;
+ }
+ /**
* Return {@code true} if the current token is the first token of a return type that is followed
* by an identifier, possibly followed by a list of type parameters, followed by a
* left-parenthesis. This is used by parseTypeAlias to determine whether or not to parse a return
@@ -572,6 +630,36 @@
return identical(type2, TokenType.EQ) || identical(type2, TokenType.COMMA) || identical(type2, TokenType.SEMICOLON) || matches3(token, Keyword.IN);
}
/**
+ * Given that we have just found bracketed text within a comment, look to see whether that text is
+ * (a) followed by a parenthesized link address, (b) followed by a colon, or (c) followed by
+ * optional whitespace and another square bracket.
+ * <p>
+ * This method uses the syntax described by the <a
+ * href="http://daringfireball.net/projects/markdown/syntax">markdown</a> project.
+ * @param comment the comment text in which the bracketed text was found
+ * @param rightIndex the index of the right bracket
+ * @return {@code true} if the bracketed text is followed by a link address
+ */
+ bool isLinkText(String comment, int rightIndex) {
+ int length2 = comment.length;
+ int index = rightIndex + 1;
+ if (index >= length2) {
+ return false;
+ }
+ int nextChar = comment.codeUnitAt(index);
+ if (nextChar == 0x28 || nextChar == 0x3A) {
+ return true;
+ }
+ while (Character.isWhitespace(nextChar)) {
+ index = index + 1;
+ if (index >= length2) {
+ return false;
+ }
+ nextChar = comment.codeUnitAt(index);
+ }
+ return nextChar == 0x5B;
+ }
+ /**
* Return {@code true} if the given token appears to be the beginning of an operator declaration.
* @param startToken the token that might be the start of an operator declaration
* @return {@code true} if the given token appears to be the beginning of an operator declaration
@@ -916,7 +1004,7 @@
* Parse an assignable selector.
* <pre>
* assignableSelector ::=
- * '[' expression ']'
+ * '\[' expression '\]'
* | '.' identifier
* </pre>
* @param prefix the expression preceding the selector
@@ -1057,7 +1145,7 @@
* cascadeSection ::=
* '..' (cascadeSelector arguments*) (assignableSelector arguments*)* cascadeAssignment?
* cascadeSelector ::=
- * '[' expression ']'
+ * '\[' expression '\]'
* | identifier
* cascadeAssignment ::=
* assignmentOperator expressionWithoutCascade
@@ -1175,6 +1263,10 @@
if (withClause != null && extendsClause == null) {
reportError5(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword, []);
}
+ if (matches2(_NATIVE) && matches4(peek(), TokenType.STRING)) {
+ advance();
+ advance();
+ }
Token leftBracket = null;
List<ClassMember> members = null;
Token rightBracket = null;
@@ -1419,32 +1511,32 @@
StringScanner scanner = new StringScanner(null, referenceSource, listener);
scanner.setSourceStart(1, 1, sourceOffset);
Token firstToken = scanner.tokenize();
- if (!errorFound[0]) {
- Token newKeyword = null;
- if (matches3(firstToken, Keyword.NEW)) {
- newKeyword = firstToken;
- firstToken = firstToken.next;
- }
- if (matchesIdentifier2(firstToken)) {
- Token secondToken = firstToken.next;
- Token thirdToken = secondToken.next;
- Token nextToken;
- Identifier identifier;
- if (matches4(secondToken, TokenType.PERIOD) && matchesIdentifier2(thirdToken)) {
- identifier = new PrefixedIdentifier.full(new SimpleIdentifier.full(firstToken), secondToken, new SimpleIdentifier.full(thirdToken));
- nextToken = thirdToken.next;
- } else {
- identifier = new SimpleIdentifier.full(firstToken);
- nextToken = firstToken.next;
- }
- if (nextToken.type != TokenType.EOF) {
- }
- return new CommentReference.full(newKeyword, identifier);
- } else if (matches3(firstToken, Keyword.THIS) || matches3(firstToken, Keyword.NULL) || matches3(firstToken, Keyword.TRUE) || matches3(firstToken, Keyword.FALSE)) {
- return null;
- } else if (matches4(firstToken, TokenType.STRING)) {
+ if (errorFound[0]) {
+ return null;
+ }
+ Token newKeyword = null;
+ if (matches3(firstToken, Keyword.NEW)) {
+ newKeyword = firstToken;
+ firstToken = firstToken.next;
+ }
+ if (matchesIdentifier2(firstToken)) {
+ Token secondToken = firstToken.next;
+ Token thirdToken = secondToken.next;
+ Token nextToken;
+ Identifier identifier;
+ if (matches4(secondToken, TokenType.PERIOD) && matchesIdentifier2(thirdToken)) {
+ identifier = new PrefixedIdentifier.full(new SimpleIdentifier.full(firstToken), secondToken, new SimpleIdentifier.full(thirdToken));
+ nextToken = thirdToken.next;
} else {
+ identifier = new SimpleIdentifier.full(firstToken);
+ nextToken = firstToken.next;
}
+ if (nextToken.type != TokenType.EOF) {
+ return null;
+ }
+ return new CommentReference.full(newKeyword, identifier);
+ } else if (matches3(firstToken, Keyword.THIS) || matches3(firstToken, Keyword.NULL) || matches3(firstToken, Keyword.TRUE) || matches3(firstToken, Keyword.FALSE)) {
+ return null;
}
} catch (exception) {
}
@@ -1454,7 +1546,7 @@
* Parse all of the comment references occurring in the given array of documentation comments.
* <pre>
* commentReference ::=
- * '[' 'new'? qualified ']' libraryReference?
+ * '\[' 'new'? qualified '\]' libraryReference?
* libraryReference ::=
* '(' stringLiteral ')'
* </pre>
@@ -1465,21 +1557,31 @@
List<CommentReference> references = new List<CommentReference>();
for (Token token in tokens) {
String comment = token.lexeme;
+ int length2 = comment.length;
+ List<List<int>> codeBlockRanges = getCodeBlockRanges(comment);
int leftIndex = comment.indexOf('[');
- while (leftIndex >= 0) {
- int rightIndex = comment.indexOf(']', leftIndex);
- if (rightIndex >= 0) {
- int firstChar = comment.codeUnitAt(leftIndex + 1);
- if (firstChar != 0x27 && firstChar != 0x22 && firstChar != 0x3A) {
- CommentReference reference = parseCommentReference(comment.substring(leftIndex + 1, rightIndex), token.offset + leftIndex + 1);
- if (reference != null) {
- references.add(reference);
+ while (leftIndex >= 0 && leftIndex + 1 < length2) {
+ List<int> range = findRange(codeBlockRanges, leftIndex);
+ if (range == null) {
+ int rightIndex = comment.indexOf(']', leftIndex);
+ if (rightIndex >= 0) {
+ int firstChar = comment.codeUnitAt(leftIndex + 1);
+ if (firstChar != 0x27 && firstChar != 0x22) {
+ if (isLinkText(comment, rightIndex)) {
+ } else {
+ CommentReference reference = parseCommentReference(comment.substring(leftIndex + 1, rightIndex), token.offset + leftIndex + 1);
+ if (reference != null) {
+ references.add(reference);
+ }
+ }
}
+ } else {
+ rightIndex = leftIndex + 1;
}
+ leftIndex = comment.indexOf('[', rightIndex);
} else {
- rightIndex = leftIndex + 1;
+ leftIndex = comment.indexOf('[', range[1] + 1);
}
- leftIndex = comment.indexOf('[', rightIndex);
}
}
return references;
@@ -2103,7 +2205,7 @@
* optionalPositionalFormalParameters
* | namedFormalParameters
* optionalPositionalFormalParameters ::=
- * '[' defaultFormalParameter (',' defaultFormalParameter)* ']'
+ * '\[' defaultFormalParameter (',' defaultFormalParameter)* '\]'
* namedFormalParameters ::=
* '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
* </pre>
@@ -2324,7 +2426,10 @@
return new BlockFunctionBody.full(parseBlock());
} else if (matches2(_NATIVE)) {
Token nativeToken = andAdvance;
- StringLiteral stringLiteral = parseStringLiteral();
+ StringLiteral stringLiteral = null;
+ if (matches5(TokenType.STRING)) {
+ stringLiteral = parseStringLiteral();
+ }
return new NativeFunctionBody.full(nativeToken, stringLiteral, expect2(TokenType.SEMICOLON));
} else {
reportError4(ParserErrorCode.MISSING_FUNCTION_BODY, []);
@@ -2655,7 +2760,7 @@
* Parse a list literal.
* <pre>
* listLiteral ::=
- * 'const'? typeArguments? '[' (expressionList ','?)? ']'
+ * 'const'? typeArguments? '\[' (expressionList ','?)? '\]'
* </pre>
* @param modifier the 'const' modifier appearing before the literal, or {@code null} if there is
* no modifier
@@ -4044,7 +4149,7 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError(ParserErrorCode errorCode, ASTNode node, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, arguments));
}
/**
* Report an error with the given error code and arguments.
@@ -4061,7 +4166,7 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError5(ParserErrorCode errorCode, Token token, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, arguments));
}
/**
* Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the
@@ -4118,7 +4223,7 @@
* optionalPositionalFormalParameters
* | namedFormalParameters
* optionalPositionalFormalParameters ::=
- * '[' defaultFormalParameter (',' defaultFormalParameter)* ']'
+ * '\[' defaultFormalParameter (',' defaultFormalParameter)* '\]'
* namedFormalParameters ::=
* '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
* </pre>
@@ -4914,9 +5019,9 @@
* @param message the message template used to create the message to be displayed for the error
*/
ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2, String message2) {
- _jtd_constructor_301_impl(___name, ___ordinal, severity2, message2);
+ _jtd_constructor_302_impl(___name, ___ordinal, severity2, message2);
}
- _jtd_constructor_301_impl(String ___name, int ___ordinal, ErrorSeverity severity2, String message2) {
+ _jtd_constructor_302_impl(String ___name, int ___ordinal, ErrorSeverity severity2, String message2) {
__name = ___name;
__ordinal = ___ordinal;
this._severity = severity2;
@@ -4927,10 +5032,10 @@
* @param message the message template used to create the message to be displayed for the error
*/
ParserErrorCode.con2(String ___name, int ___ordinal, String message) {
- _jtd_constructor_302_impl(___name, ___ordinal, message);
+ _jtd_constructor_303_impl(___name, ___ordinal, message);
}
- _jtd_constructor_302_impl(String ___name, int ___ordinal, String message) {
- _jtd_constructor_301_impl(___name, ___ordinal, ErrorSeverity.ERROR, message);
+ _jtd_constructor_303_impl(String ___name, int ___ordinal, String message) {
+ _jtd_constructor_302_impl(___name, ___ordinal, ErrorSeverity.ERROR, message);
}
ErrorSeverity get errorSeverity => _severity;
String get message => _message;
diff --git a/pkg/analyzer_experimental/lib/src/generated/resolver.dart b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
index ddfe703..fc7b84d 100644
--- a/pkg/analyzer_experimental/lib/src/generated/resolver.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
@@ -4,6 +4,7 @@
library engine.resolver;
import 'dart:collection';
+import 'dart:uri' show Uri;
import 'java_core.dart';
import 'java_engine.dart';
import 'instrumentation.dart';
@@ -568,7 +569,7 @@
((variable as FieldElementImpl)).static = matches(((node.parent.parent as FieldDeclaration)).keyword, sc.Keyword.STATIC);
}
}
- return super.visitVariableDeclaration(node);
+ return null;
}
List<Type2> createTypeVariableTypes(List<TypeVariableElement> typeVariables) {
int typeVariableCount = typeVariables.length;
@@ -793,6 +794,14 @@
*/
InternalAnalysisContext _context;
/**
+ * The error listener to which errors will be reported.
+ */
+ AnalysisErrorListener _errorListener;
+ /**
+ * The line information associated with the source for which an element is being built, or{@code null} if we are not building an element.
+ */
+ LineInfo _lineInfo;
+ /**
* The HTML element being built.
*/
HtmlElementImpl _htmlElement;
@@ -803,9 +812,11 @@
/**
* Initialize a newly created HTML unit builder.
* @param context the analysis context in which the element model will be built
+ * @param errorListener the error listener to which errors will be reported
*/
- HtmlUnitBuilder(InternalAnalysisContext context) {
+ HtmlUnitBuilder(InternalAnalysisContext context, AnalysisErrorListener errorListener) {
this._context = context;
+ this._errorListener = errorListener;
}
/**
* Build the HTML element for the given source.
@@ -821,6 +832,7 @@
* @throws AnalysisException if the analysis could not be performed
*/
HtmlElementImpl buildHtmlElement2(Source source2, ht.HtmlUnit unit) {
+ _lineInfo = _context.computeLineInfo(source2);
HtmlElementImpl result = new HtmlElementImpl(_context, source2.shortName);
result.source = source2;
_htmlElement = result;
@@ -840,30 +852,43 @@
Object visitXmlTagNode(ht.XmlTagNode node) {
if (isScriptNode(node)) {
Source htmlSource = _htmlElement.source;
- String scriptSourcePath = getScriptSourcePath(node);
+ ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
+ String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute.text;
if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath == null) {
EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl(node);
String contents = node.content;
- AnalysisErrorListener errorListener = new AnalysisErrorListener_5();
- sc.StringScanner scanner = new sc.StringScanner(null, contents, errorListener);
+ int attributeEnd2 = node.attributeEnd.end;
+ LineInfo_Location location = _lineInfo.getLocation(attributeEnd2);
+ sc.StringScanner scanner = new sc.StringScanner(htmlSource, contents, _errorListener);
+ scanner.setSourceStart(location.lineNumber, location.columnNumber, attributeEnd2);
sc.Token firstToken = scanner.tokenize();
List<int> lineStarts2 = scanner.lineStarts;
- Parser parser = new Parser(null, errorListener);
+ Parser parser = new Parser(null, _errorListener);
CompilationUnit unit = parser.parseCompilationUnit(firstToken);
+ unit.lineInfo = new LineInfo(lineStarts2);
try {
CompilationUnitBuilder builder = new CompilationUnitBuilder();
CompilationUnitElementImpl elem = builder.buildCompilationUnit(htmlSource, unit);
LibraryElementImpl library = new LibraryElementImpl(_context, null);
library.definingCompilationUnit = elem;
script.scriptLibrary = library;
- } on AnalysisException catch (e) {
- print(e);
+ } on AnalysisException catch (exception) {
+ print(exception);
}
_scripts.add(script);
} else {
ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl(node);
if (scriptSourcePath != null) {
- script.scriptSource = _context.sourceFactory.resolveUri(htmlSource, scriptSourcePath);
+ try {
+ new Uri(scriptSourcePath);
+ Source scriptSource = _context.sourceFactory.resolveUri(htmlSource, scriptSourcePath);
+ script.scriptSource = scriptSource;
+ if (!scriptSource.exists()) {
+ reportError(HtmlWarningCode.URI_DOES_NOT_EXIST, scriptAttribute.offset + 1, scriptSourcePath.length, []);
+ }
+ } on URISyntaxException catch (exception) {
+ reportError(HtmlWarningCode.INVALID_URI, scriptAttribute.offset + 1, scriptSourcePath.length, []);
+ }
}
_scripts.add(script);
}
@@ -873,15 +898,14 @@
return null;
}
/**
- * Return the value of the source attribute if it exists.
+ * Return the first source attribute for the given tag node, or {@code null} if it does not exist.
* @param node the node containing attributes
- * @return the source path or {@code null} if not defined
+ * @return the source attribute contained in the given tag
*/
- String getScriptSourcePath(ht.XmlTagNode node) {
+ ht.XmlAttributeNode getScriptSourcePath(ht.XmlTagNode node) {
for (ht.XmlAttributeNode attribute in node.attributes) {
if (attribute.name.lexeme == _SRC) {
- String text2 = attribute.text;
- return text2 != null && text2.length > 0 ? text2 : null;
+ return attribute;
}
}
return null;
@@ -908,9 +932,16 @@
}
return false;
}
-}
-class AnalysisErrorListener_5 implements AnalysisErrorListener {
- void onError(AnalysisError error) {
+ /**
+ * Report an error with the given error code at the given location. Use the given arguments to
+ * compose the error message.
+ * @param errorCode the error code of the error to be reported
+ * @param offset the offset of the first character to be highlighted
+ * @param length the number of characters to be highlighted
+ * @param arguments the arguments used to compose the error message
+ */
+ void reportError(ErrorCode errorCode, int offset, int length, List<Object> arguments) {
+ _errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, length, errorCode, arguments));
}
}
/**
@@ -1500,6 +1531,63 @@
}
return null;
}
+ Object visitCommentReference(CommentReference node) {
+ Identifier identifier2 = node.identifier;
+ if (identifier2 is SimpleIdentifier) {
+ SimpleIdentifier simpleIdentifier = identifier2 as SimpleIdentifier;
+ visitSimpleIdentifier(simpleIdentifier);
+ Element element2 = simpleIdentifier.element;
+ if (element2 != null) {
+ if (element2.library != _resolver.definingLibrary) {
+ }
+ if (node.newKeyword != null) {
+ if (element2 is ClassElement) {
+ ConstructorElement constructor = ((element2 as ClassElement)).unnamedConstructor;
+ recordResolution(simpleIdentifier, constructor);
+ } else {
+ }
+ }
+ }
+ } else if (identifier2 is PrefixedIdentifier) {
+ PrefixedIdentifier prefixedIdentifier = identifier2 as PrefixedIdentifier;
+ SimpleIdentifier prefix2 = prefixedIdentifier.prefix;
+ SimpleIdentifier name = prefixedIdentifier.identifier;
+ visitSimpleIdentifier(prefix2);
+ Element element3 = prefix2.element;
+ if (element3 != null) {
+ if (element3 is PrefixElement) {
+ element3 = _resolver.nameScope.lookup(identifier2, _resolver.definingLibrary);
+ recordResolution(name, element3);
+ return null;
+ }
+ if (element3.library != _resolver.definingLibrary) {
+ }
+ if (node.newKeyword == null) {
+ if (element3 is ClassElement) {
+ Element memberElement = lookupGetterOrMethod(((element3 as ClassElement)).type, name.name);
+ if (memberElement == null) {
+ memberElement = ((element3 as ClassElement)).getNamedConstructor(name.name);
+ }
+ if (memberElement == null) {
+ reportGetterOrSetterNotFound(prefixedIdentifier, name, element3.name);
+ } else {
+ recordResolution(name, memberElement);
+ }
+ } else {
+ }
+ } else {
+ if (element3 is ClassElement) {
+ ConstructorElement constructor = ((element3 as ClassElement)).getNamedConstructor(name.name);
+ if (constructor != null) {
+ recordResolution(name, constructor);
+ }
+ } else {
+ }
+ }
+ }
+ }
+ return null;
+ }
Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
FieldElement fieldElement = null;
SimpleIdentifier fieldName2 = node.fieldName;
@@ -1565,9 +1653,17 @@
if (!fieldElement.isSynthetic()) {
ParameterElement parameterElement = node.element;
if (parameterElement is FieldFormalParameterElementImpl) {
- ((parameterElement as FieldFormalParameterElementImpl)).field = fieldElement;
+ FieldFormalParameterElementImpl fieldFormal = parameterElement as FieldFormalParameterElementImpl;
+ fieldFormal.field = fieldElement;
+ Type2 declaredType = fieldFormal.type;
+ Type2 fieldType = fieldElement.type;
+ if (node.type == null) {
+ fieldFormal.type = fieldType;
+ }
if (fieldElement.isStatic()) {
_resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD, node, [fieldName]);
+ } else if (declaredType != null && fieldType != null && !declaredType.isAssignableTo(fieldType)) {
+ _resolver.reportError(StaticWarningCode.FIELD_INITIALIZER_WITH_INVALID_TYPE, node, [declaredType.name, fieldType.name]);
}
}
}
@@ -1732,7 +1828,9 @@
if (targetTypeName == null) {
_resolver.reportError(StaticTypeWarningCode.UNDEFINED_FUNCTION, methodName2, [methodName2.name]);
} else {
- _resolver.reportError(StaticTypeWarningCode.UNDEFINED_METHOD, methodName2, [methodName2.name, targetTypeName]);
+ if (!doesClassDeclareNoSuchMethod(targetType.element)) {
+ _resolver.reportError(StaticTypeWarningCode.UNDEFINED_METHOD, methodName2, [methodName2.name, targetTypeName]);
+ }
}
}
return null;
@@ -1890,12 +1988,15 @@
}
}
if (memberElement == null) {
- if (identifier.inSetterContext()) {
- _resolver.reportError(StaticWarningCode.UNDEFINED_SETTER, identifier, [identifier.name, targetType.name]);
- } else if (identifier.inGetterContext()) {
- _resolver.reportError(StaticWarningCode.UNDEFINED_GETTER, identifier, [identifier.name, targetType.name]);
- } else {
- _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, identifier, [identifier.name]);
+ if (!doesClassDeclareNoSuchMethod(targetType.element)) {
+ if (identifier.inSetterContext()) {
+ _resolver.reportError(StaticWarningCode.UNDEFINED_SETTER, identifier, [identifier.name, targetType.name]);
+ } else if (identifier.inGetterContext()) {
+ _resolver.reportError(StaticWarningCode.UNDEFINED_GETTER, identifier, [identifier.name, targetType.name]);
+ } else {
+ System.out.println("two ${identifier.name}");
+ _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, identifier, [identifier.name]);
+ }
}
} else {
recordResolution(identifier, memberElement);
@@ -1952,7 +2053,9 @@
}
}
if (element == null) {
- _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]);
+ if (!doesClassDeclareNoSuchMethod(enclosingClass2)) {
+ _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]);
+ }
}
recordResolution(node, element);
return null;
@@ -1994,6 +2097,27 @@
return null;
}
/**
+ * Return {@code true} if the passed {@link Element} is a {@link ClassElement} that declares a
+ * method "noSuchMethod".
+ * @param element the {@link Element} to evaluate
+ * @return {@code true} if the passed {@link Element} is a {@link ClassElement} that declares a
+ * method "noSuchMethod"
+ */
+ bool doesClassDeclareNoSuchMethod(Element element) {
+ if (element == null) {
+ return false;
+ }
+ if (element is! ClassElementImpl) {
+ return false;
+ }
+ ClassElementImpl classElement = element as ClassElementImpl;
+ MethodElement method = classElement.lookUpMethod("noSuchMethod", _resolver.definingLibrary);
+ if (method == null) {
+ return false;
+ }
+ return true;
+ }
+ /**
* Search through the array of parameters for a parameter whose name matches the given name.
* Return the parameter with the given name, or {@code null} if there is no such parameter.
* @param parameters the parameters being searched
@@ -2101,6 +2225,66 @@
return lookUpGetterInInterfaces(superclass2, getterName, visitedInterfaces);
}
/**
+ * Look up the method or getter with the given name in the given type. Return the element
+ * representing the method or getter that was found, or {@code null} if there is no method or
+ * getter with the given name.
+ * @param type the type in which the method or getter is defined
+ * @param memberName the name of the method or getter being looked up
+ * @return the element representing the method or getter that was found
+ */
+ ExecutableElement lookupGetterOrMethod(Type2 type, String memberName) {
+ type = resolveTypeVariable(type);
+ if (type is InterfaceType) {
+ InterfaceType interfaceType = type as InterfaceType;
+ ExecutableElement member = interfaceType.lookUpMethod(memberName, _resolver.definingLibrary);
+ if (member != null) {
+ return member;
+ }
+ member = interfaceType.lookUpGetter(memberName, _resolver.definingLibrary);
+ if (member != null) {
+ return member;
+ }
+ return lookUpGetterOrMethodInInterfaces(interfaceType, memberName, new Set<ClassElement>());
+ }
+ return null;
+ }
+ /**
+ * Look up the method or getter with the given name in the interfaces implemented by the given
+ * type, either directly or indirectly. Return the element representing the method or getter that
+ * was found, or {@code null} if there is no method or getter with the given name.
+ * @param targetType the type in which the method or getter might be defined
+ * @param memberName the name of the method or getter being looked up
+ * @param visitedInterfaces a set containing all of the interfaces that have been examined, used
+ * to prevent infinite recursion and to optimize the search
+ * @return the element representing the method or getter that was found
+ */
+ ExecutableElement lookUpGetterOrMethodInInterfaces(InterfaceType targetType, String memberName, Set<ClassElement> visitedInterfaces) {
+ ClassElement targetClass = targetType.element;
+ if (visitedInterfaces.contains(targetClass)) {
+ return null;
+ }
+ javaSetAdd(visitedInterfaces, targetClass);
+ ExecutableElement member = targetType.getMethod(memberName);
+ if (member != null) {
+ return member;
+ }
+ member = targetType.getGetter(memberName);
+ if (member != null) {
+ return member;
+ }
+ for (InterfaceType interfaceType in targetType.interfaces) {
+ member = lookUpGetterOrMethodInInterfaces(interfaceType, memberName, visitedInterfaces);
+ if (member != null) {
+ return member;
+ }
+ }
+ InterfaceType superclass2 = targetType.superclass;
+ if (superclass2 == null) {
+ return null;
+ }
+ return lookUpGetterInInterfaces(superclass2, memberName, visitedInterfaces);
+ }
+ /**
* Find the element corresponding to the given label node in the current label scope.
* @param parentNode the node containing the given label
* @param labelNode the node representing the label being looked up
@@ -2284,14 +2468,17 @@
}
}
/**
- * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and
- * <code>UNDEFINED_GETTER</code>.
+ * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and <code>UNDEFINED_GETTER</code>.
* @param node the prefixed identifier that gives the context to determine if the error on the
* undefined identifier is a getter or a setter
* @param identifier the identifier in the passed prefix identifier
* @param typeName the name of the type of the left hand side of the passed prefixed identifier
*/
void reportGetterOrSetterNotFound(PrefixedIdentifier node, SimpleIdentifier identifier2, String typeName) {
+ Type2 targetType = getType(node);
+ if (targetType != null && doesClassDeclareNoSuchMethod(targetType.element)) {
+ return;
+ }
bool isSetterContext = node.identifier.inSetterContext();
ErrorCode errorCode = isSetterContext ? StaticTypeWarningCode.UNDEFINED_SETTER : StaticTypeWarningCode.UNDEFINED_GETTER;
_resolver.reportError(errorCode, identifier2, [identifier2.name, typeName]);
@@ -2791,10 +2978,10 @@
* @param analysisContext the analysis context in which the library is being analyzed
*/
LibraryResolver.con1(InternalAnalysisContext analysisContext) {
- _jtd_constructor_263_impl(analysisContext);
+ _jtd_constructor_264_impl(analysisContext);
}
- _jtd_constructor_263_impl(InternalAnalysisContext analysisContext) {
- _jtd_constructor_264_impl(analysisContext, null);
+ _jtd_constructor_264_impl(InternalAnalysisContext analysisContext) {
+ _jtd_constructor_265_impl(analysisContext, null);
}
/**
* Initialize a newly created library resolver to resolve libraries within the given context.
@@ -2802,9 +2989,9 @@
* @param errorListener the listener to which analysis errors will be reported
*/
LibraryResolver.con2(InternalAnalysisContext analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
- _jtd_constructor_264_impl(analysisContext2, additionalAnalysisErrorListener);
+ _jtd_constructor_265_impl(analysisContext2, additionalAnalysisErrorListener);
}
- _jtd_constructor_264_impl(InternalAnalysisContext analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
+ _jtd_constructor_265_impl(InternalAnalysisContext analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
this._analysisContext = analysisContext2;
this._recordingErrorListener = new RecordingErrorListener();
if (additionalAnalysisErrorListener == null) {
@@ -3219,19 +3406,20 @@
void recordResults() {
Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
for (Library library in _librariesInCycles) {
- recordResults2(library.librarySource, library.definingCompilationUnit);
+ Source librarySource2 = library.librarySource;
+ recordResults2(librarySource2, librarySource2, library.definingCompilationUnit);
for (Source source in library.compilationUnitSources) {
- recordResults2(source, library.getAST(source));
+ recordResults2(source, librarySource2, library.getAST(source));
}
elementMap[library.librarySource] = library.libraryElement;
}
_analysisContext.recordLibraryElements(elementMap);
}
- void recordResults2(Source source, CompilationUnit unit) {
+ void recordResults2(Source source, Source librarySource, CompilationUnit unit) {
List<AnalysisError> errors = _recordingErrorListener.getErrors2(source);
unit.resolutionErrors = errors;
- _analysisContext.recordResolvedCompilationUnit(source, unit);
- _analysisContext.recordResolutionErrors(source, errors, unit.lineInfo);
+ _analysisContext.recordResolvedCompilationUnit(source, librarySource, unit);
+ _analysisContext.recordResolutionErrors(source, librarySource, errors, unit.lineInfo);
}
/**
* Resolve the identifiers and perform type analysis in the libraries in the current cycle.
@@ -3326,9 +3514,9 @@
* @param typeProvider the object used to access the types from the core library
*/
ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider) : super.con1(library, source, typeProvider) {
- _jtd_constructor_265_impl(library, source, typeProvider);
+ _jtd_constructor_266_impl(library, source, typeProvider);
}
- _jtd_constructor_265_impl(Library library, Source source, TypeProvider typeProvider) {
+ _jtd_constructor_266_impl(Library library, Source source, TypeProvider typeProvider) {
this._elementResolver = new ElementResolver(this);
this._typeAnalyzer = new StaticTypeAnalyzer(this);
}
@@ -3342,9 +3530,9 @@
* during resolution
*/
ResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) {
- _jtd_constructor_266_impl(definingLibrary, source, typeProvider, errorListener);
+ _jtd_constructor_267_impl(definingLibrary, source, typeProvider, errorListener);
}
- _jtd_constructor_266_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
+ _jtd_constructor_267_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
this._elementResolver = new ElementResolver(this);
this._typeAnalyzer = new StaticTypeAnalyzer(this);
}
@@ -3360,16 +3548,57 @@
if (element != null) {
Type2 type2 = node.type.type;
if (type2 != null) {
- _overrideManager.setType(element, type2);
+ override(element, getType(element), type2);
}
}
}
return null;
}
Object visitAssertStatement(AssertStatement node) {
- Expression condition2 = node.condition;
- condition2.accept(this);
- propagateTrueState(condition2);
+ super.visitAssertStatement(node);
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ propagateTrueState(node.condition);
+ }
+ return null;
+ }
+ Object visitBinaryExpression(BinaryExpression node) {
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ sc.TokenType operatorType = node.operator.type;
+ if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) {
+ Expression leftOperand2 = node.leftOperand;
+ leftOperand2.accept(this);
+ Expression rightOperand2 = node.rightOperand;
+ if (rightOperand2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateTrueState(leftOperand2);
+ rightOperand2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ } else if (identical(operatorType, sc.TokenType.BAR_BAR)) {
+ Expression leftOperand3 = node.leftOperand;
+ leftOperand3.accept(this);
+ Expression rightOperand3 = node.rightOperand;
+ if (rightOperand3 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateFalseState(leftOperand3);
+ rightOperand3.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ } else {
+ node.leftOperand.accept(this);
+ node.rightOperand.accept(this);
+ }
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
+ } else {
+ super.visitBinaryExpression(node);
+ }
return null;
}
Object visitBreakStatement(BreakStatement node) {
@@ -3389,53 +3618,65 @@
}
return null;
}
- Object visitComment(Comment node) => null;
+ Object visitCommentReference(CommentReference node) {
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
+ return null;
+ }
Object visitCompilationUnit(CompilationUnit node) {
- try {
- _overrideManager.enterScope();
- for (Directive directive in node.directives) {
- directive.accept(this);
- }
- List<CompilationUnitMember> classes = new List<CompilationUnitMember>();
- for (CompilationUnitMember declaration in node.declarations) {
- if (declaration is ClassDeclaration) {
- classes.add(declaration);
- } else {
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ for (Directive directive in node.directives) {
+ directive.accept(this);
+ }
+ List<CompilationUnitMember> classes = new List<CompilationUnitMember>();
+ for (CompilationUnitMember declaration in node.declarations) {
+ if (declaration is ClassDeclaration) {
+ classes.add(declaration);
+ } else {
+ declaration.accept(this);
+ }
+ }
+ for (CompilationUnitMember declaration in classes) {
declaration.accept(this);
}
+ } finally {
+ _overrideManager.exitScope();
}
- for (CompilationUnitMember declaration in classes) {
- declaration.accept(this);
- }
- } finally {
- _overrideManager.exitScope();
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
+ } else {
+ super.visitCompilationUnit(node);
}
return null;
}
Object visitConditionalExpression(ConditionalExpression node) {
- Expression condition2 = node.condition;
- condition2.accept(this);
- Expression thenExpression2 = node.thenExpression;
- if (thenExpression2 != null) {
- try {
- _overrideManager.enterScope();
- propagateTrueState(condition2);
- thenExpression2.accept(this);
- } finally {
- _overrideManager.exitScope();
- }
- }
- Expression elseExpression2 = node.elseExpression;
- if (elseExpression2 != null) {
- try {
- _overrideManager.enterScope();
- propagateFalseState(condition2);
- elseExpression2.accept(this);
- } finally {
- _overrideManager.exitScope();
- }
- }
if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ Expression condition2 = node.condition;
+ condition2.accept(this);
+ Expression thenExpression2 = node.thenExpression;
+ if (thenExpression2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateTrueState(condition2);
+ thenExpression2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ Expression elseExpression2 = node.elseExpression;
+ if (elseExpression2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateFalseState(condition2);
+ elseExpression2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
bool thenIsAbrupt = thenExpression2 != null && isAbruptTermination(thenExpression2);
bool elseIsAbrupt = elseExpression2 != null && isAbruptTermination(elseExpression2);
if (elseIsAbrupt && !thenIsAbrupt) {
@@ -3443,6 +3684,8 @@
} else if (thenIsAbrupt && !elseIsAbrupt) {
propagateFalseState(condition2);
}
+ } else {
+ super.visitConditionalExpression(node);
}
return null;
}
@@ -3473,33 +3716,56 @@
return null;
}
Object visitFieldDeclaration(FieldDeclaration node) {
- try {
- _overrideManager.enterScope();
- super.visitFieldDeclaration(node);
- } finally {
- Map<Element, Type2> overrides = captureOverrides(node.fields);
- _overrideManager.exitScope();
- for (MapEntry<Element, Type2> entry in getMapEntrySet(overrides)) {
- _overrideManager.setType(entry.getKey(), entry.getValue());
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitFieldDeclaration(node);
+ } finally {
+ Map<Element, Type2> overrides = captureOverrides(node.fields);
+ _overrideManager.exitScope();
+ applyOverrides(overrides);
}
+ } else {
+ super.visitFieldDeclaration(node);
+ }
+ return null;
+ }
+ Object visitForEachStatement(ForEachStatement node) {
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitForEachStatement(node);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ } else {
+ super.visitForEachStatement(node);
}
return null;
}
Object visitForStatement(ForStatement node) {
- try {
- _overrideManager.enterScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitForStatement(node);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ } else {
super.visitForStatement(node);
- } finally {
- _overrideManager.exitScope();
}
return null;
}
Object visitFunctionBody(FunctionBody node) {
- try {
- _overrideManager.enterScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitFunctionBody(node);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ } else {
super.visitFunctionBody(node);
- } finally {
- _overrideManager.exitScope();
}
return null;
}
@@ -3518,39 +3784,45 @@
ExecutableElement outerFunction = _enclosingFunction;
try {
_enclosingFunction = node.element;
- _overrideManager.enterScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ _overrideManager.enterScope();
+ }
super.visitFunctionExpression(node);
} finally {
- _overrideManager.exitScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ _overrideManager.exitScope();
+ }
_enclosingFunction = outerFunction;
}
return null;
}
Object visitHideCombinator(HideCombinator node) => null;
Object visitIfStatement(IfStatement node) {
- Expression condition2 = node.condition;
- condition2.accept(this);
- Statement thenStatement2 = node.thenStatement;
- if (thenStatement2 != null) {
- try {
- _overrideManager.enterScope();
- propagateTrueState(condition2);
- thenStatement2.accept(this);
- } finally {
- _overrideManager.exitScope();
- }
- }
- Statement elseStatement2 = node.elseStatement;
- if (elseStatement2 != null) {
- try {
- _overrideManager.enterScope();
- propagateFalseState(condition2);
- elseStatement2.accept(this);
- } finally {
- _overrideManager.exitScope();
- }
- }
if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ Expression condition2 = node.condition;
+ condition2.accept(this);
+ Statement thenStatement2 = node.thenStatement;
+ if (thenStatement2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateTrueState(condition2);
+ thenStatement2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ Statement elseStatement2 = node.elseStatement;
+ if (elseStatement2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateFalseState(condition2);
+ elseStatement2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
bool thenIsAbrupt = thenStatement2 != null && isAbruptTermination2(thenStatement2);
bool elseIsAbrupt = elseStatement2 != null && isAbruptTermination2(elseStatement2);
if (elseIsAbrupt && !thenIsAbrupt) {
@@ -3558,6 +3830,8 @@
} else if (thenIsAbrupt && !elseIsAbrupt) {
propagateFalseState(condition2);
}
+ } else {
+ super.visitIfStatement(node);
}
return null;
}
@@ -3612,37 +3886,68 @@
return null;
}
Object visitSwitchCase(SwitchCase node) {
- try {
- _overrideManager.enterScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitSwitchCase(node);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ } else {
super.visitSwitchCase(node);
- } finally {
- _overrideManager.exitScope();
}
return null;
}
Object visitSwitchDefault(SwitchDefault node) {
- try {
- _overrideManager.enterScope();
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitSwitchDefault(node);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ } else {
super.visitSwitchDefault(node);
- } finally {
- _overrideManager.exitScope();
}
return null;
}
Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
- try {
- _overrideManager.enterScope();
- super.visitTopLevelVariableDeclaration(node);
- } finally {
- Map<Element, Type2> overrides = captureOverrides(node.variables);
- _overrideManager.exitScope();
- for (MapEntry<Element, Type2> entry in getMapEntrySet(overrides)) {
- _overrideManager.setType(entry.getKey(), entry.getValue());
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ try {
+ _overrideManager.enterScope();
+ super.visitTopLevelVariableDeclaration(node);
+ } finally {
+ Map<Element, Type2> overrides = captureOverrides(node.variables);
+ _overrideManager.exitScope();
+ applyOverrides(overrides);
}
+ } else {
+ super.visitTopLevelVariableDeclaration(node);
}
return null;
}
Object visitTypeName(TypeName node) => null;
+ Object visitWhileStatement(WhileStatement node) {
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ Expression condition2 = node.condition;
+ condition2.accept(this);
+ Statement body2 = node.body;
+ if (body2 != null) {
+ try {
+ _overrideManager.enterScope();
+ propagateTrueState(condition2);
+ body2.accept(this);
+ } finally {
+ _overrideManager.exitScope();
+ }
+ }
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
+ } else {
+ super.visitWhileStatement(node);
+ }
+ return null;
+ }
/**
* Return the class element representing the class containing the current node, or {@code null} if
* the current node is not contained in a class.
@@ -3669,6 +3974,34 @@
}
return null;
}
+ void visitForEachStatementInScope(ForEachStatement node) {
+ if (StaticTypeAnalyzer.USE_TYPE_PROPAGATION) {
+ DeclaredIdentifier loopVariable2 = node.loopVariable;
+ safelyVisit(loopVariable2);
+ Expression iterator2 = node.iterator;
+ if (iterator2 != null) {
+ iterator2.accept(this);
+ if (loopVariable2 != null) {
+ LocalVariableElement loopElement = loopVariable2.element;
+ override(loopElement, loopElement.type, getIteratorElementType(iterator2));
+ }
+ }
+ safelyVisit(node.body);
+ node.accept(_elementResolver);
+ node.accept(_typeAnalyzer);
+ } else {
+ super.visitForEachStatementInScope(node);
+ }
+ }
+ /**
+ * Apply a set of overrides that were previously captured.
+ * @param overrides the overrides to be applied
+ */
+ void applyOverrides(Map<Element, Type2> overrides) {
+ for (MapEntry<Element, Type2> entry in getMapEntrySet(overrides)) {
+ _overrideManager.setType(entry.getKey(), entry.getValue());
+ }
+ }
/**
* Return a map from the elements for the variables in the given list that have their types
* overridden to the overriding type.
@@ -3693,6 +4026,44 @@
return overrides;
}
/**
+ * The given expression is the expression used to compute the iterator for a for-each statement.
+ * Attempt to compute the type of objects that will be assigned to the loop variable and return
+ * that type. Return {@code null} if the type could not be determined.
+ * @param iterator the iterator for a for-each statement
+ * @return the type of objects that will be assigned to the loop variable
+ */
+ Type2 getIteratorElementType(Expression iteratorExpression) {
+ Type2 expressionType = iteratorExpression.staticType;
+ if (expressionType is InterfaceType) {
+ PropertyAccessorElement iterator = ((expressionType as InterfaceType)).lookUpGetter("iterator", definingLibrary);
+ if (iterator == null) {
+ return null;
+ }
+ Type2 iteratorType = iterator.type.returnType;
+ if (iteratorType is InterfaceType) {
+ PropertyAccessorElement current = ((iteratorType as InterfaceType)).lookUpGetter("current", definingLibrary);
+ if (current == null) {
+ return null;
+ }
+ return current.type.returnType;
+ }
+ }
+ return null;
+ }
+ /**
+ * Return the type of the given (overridable) element.
+ * @param element the element whose type is to be returned
+ * @return the type of the given element
+ */
+ Type2 getType(Element element) {
+ if (element is LocalVariableElement) {
+ return ((element as LocalVariableElement)).type;
+ } else if (element is ParameterElement) {
+ return ((element as ParameterElement)).type;
+ }
+ return null;
+ }
+ /**
* Return {@code true} if the given expression terminates abruptly (that is, if any expression
* following the given expression will not be reached).
* @param expression the expression being tested
@@ -3726,6 +4097,27 @@
return false;
}
/**
+ * If it is appropriate to do so, override the type of the given element. Use the static type and
+ * inferred type of the element to determine whether or not it is appropriate.
+ * @param element the element whose type might be overridden
+ * @param staticType the static type of the element
+ * @param inferredType the inferred type of the element
+ */
+ void override(VariableElement element, Type2 staticType, Type2 inferredType) {
+ if (identical(inferredType, BottomTypeImpl.instance)) {
+ return;
+ }
+ if (element is PropertyInducingElement) {
+ PropertyInducingElement variable = element as PropertyInducingElement;
+ if (!variable.isConst() && !variable.isFinal()) {
+ return;
+ }
+ }
+ if (staticType == null || (inferredType != null && inferredType.isMoreSpecificThan(staticType))) {
+ _overrideManager.setType(element, inferredType);
+ }
+ }
+ /**
* Propagate any type information that results from knowing that the given condition will have
* evaluated to 'false'.
* @param condition the condition that will have evaluated to 'false'
@@ -3737,11 +4129,11 @@
if (condition is IsExpression) {
IsExpression is2 = condition as IsExpression;
if (is2.notOperator != null) {
- Element element = getOverridableElement(is2.expression);
+ VariableElement element = getOverridableElement(is2.expression);
if (element != null) {
Type2 type2 = is2.type.type;
if (type2 != null) {
- _overrideManager.setType(element, type2);
+ override(element, getType(element), type2);
}
}
}
@@ -3765,11 +4157,11 @@
if (condition is IsExpression) {
IsExpression is2 = condition as IsExpression;
if (is2.notOperator == null) {
- Element element = getOverridableElement(is2.expression);
+ VariableElement element = getOverridableElement(is2.expression);
if (element != null) {
Type2 type2 = is2.type.type;
if (type2 != null) {
- _overrideManager.setType(element, type2);
+ override(element, getType(element), type2);
}
}
}
@@ -3838,9 +4230,9 @@
* @param typeProvider the object used to access the types from the core library
*/
ScopedVisitor.con1(Library library, Source source2, TypeProvider typeProvider2) {
- _jtd_constructor_267_impl(library, source2, typeProvider2);
+ _jtd_constructor_268_impl(library, source2, typeProvider2);
}
- _jtd_constructor_267_impl(Library library, Source source2, TypeProvider typeProvider2) {
+ _jtd_constructor_268_impl(Library library, Source source2, TypeProvider typeProvider2) {
this._definingLibrary = library.libraryElement;
this._source = source2;
LibraryScope libraryScope2 = library.libraryScope;
@@ -3858,9 +4250,9 @@
* during resolution
*/
ScopedVisitor.con2(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
- _jtd_constructor_268_impl(definingLibrary2, source2, typeProvider2, errorListener2);
+ _jtd_constructor_269_impl(definingLibrary2, source2, typeProvider2, errorListener2);
}
- _jtd_constructor_268_impl(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
+ _jtd_constructor_269_impl(LibraryElement definingLibrary2, Source source2, TypeProvider typeProvider2, AnalysisErrorListener errorListener2) {
this._definingLibrary = definingLibrary2;
this._source = source2;
this._errorListener = errorListener2;
@@ -3959,7 +4351,7 @@
Scope outerNameScope = _nameScope;
_nameScope = new EnclosedScope(_nameScope);
try {
- super.visitForEachStatement(node);
+ visitForEachStatementInScope(node);
} finally {
_nameScope = outerNameScope;
_labelScope = outerLabelScope;
@@ -4115,7 +4507,7 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError(ErrorCode errorCode, ASTNode node, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.length, errorCode, arguments));
}
/**
* Report an error with the given error code and arguments.
@@ -4124,7 +4516,16 @@
* @param arguments the arguments to the error, used to compose the error message
*/
void reportError3(ErrorCode errorCode, sc.Token token, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.length, errorCode, arguments));
+ }
+ /**
+ * Visit the given statement after it's scope has been created. This replaces the normal call to
+ * the inherited visit method so that ResolverVisitor can intervene when type propagation is
+ * enabled.
+ * @param node the statement to be visited
+ */
+ void visitForEachStatementInScope(ForEachStatement node) {
+ super.visitForEachStatement(node);
}
/**
* Add scopes for each of the given labels.
@@ -4310,17 +4711,17 @@
* The static type of the expression <i>e<sub>1</sub>.v = e<sub>2</sub></i> is the static type of
* <i>e<sub>2</sub></i>.
* <p>
- * ... an assignment of the form <i>e<sub>1</sub>[e<sub>2</sub>] = e<sub>3</sub></i> ...
+ * ... an assignment of the form <i>e<sub>1</sub>\[e<sub>2</sub>\] = e<sub>3</sub></i> ...
* <p>
- * The static type of the expression <i>e<sub>1</sub>[e<sub>2</sub>] = e<sub>3</sub></i> is the
+ * The static type of the expression <i>e<sub>1</sub>\[e<sub>2</sub>\] = e<sub>3</sub></i> is the
* static type of <i>e<sub>3</sub></i>.
* <p>
* A compound assignment of the form <i>v op= e</i> is equivalent to <i>v = v op e</i>. A compound
* assignment of the form <i>C.v op= e</i> is equivalent to <i>C.v = C.v op e</i>. A compound
* assignment of the form <i>e<sub>1</sub>.v op= e<sub>2</sub></i> is equivalent to <i>((x) => x.v
* = x.v op e<sub>2</sub>)(e<sub>1</sub>)</i> where <i>x</i> is a variable that is not used in
- * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>[e<sub>2</sub>] op=
- * e<sub>3</sub></i> is equivalent to <i>((a, i) => a[i] = a[i] op e<sub>3</sub>)(e<sub>1</sub>,
+ * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>\[e<sub>2</sub>\] op=
+ * e<sub>3</sub></i> is equivalent to <i>((a, i) => a\[i\] = a\[i\] op e<sub>3</sub>)(e<sub>1</sub>,
* e<sub>2</sub>)</i> where <i>a</i> and <i>i</i> are a variables that are not used in
* <i>e<sub>3</sub></i>. </blockquote>
*/
@@ -4435,10 +4836,10 @@
}
/**
* The Dart Language Specification, 12.9: <blockquote>The static type of a function literal of the
- * form <i>(T<sub>1</sub> a<sub>1</sub>, …, T<sub>n</sub> a<sub>n</sub>, [T<sub>n+1</sub>
- * x<sub>n+1</sub> = d1, …, T<sub>n+k</sub> x<sub>n+k</sub> = dk]) => e</i> is
- * <i>(T<sub>1</sub>, …, Tn, [T<sub>n+1</sub> x<sub>n+1</sub>, …, T<sub>n+k</sub>
- * x<sub>n+k</sub>]) → T<sub>0</sub></i>, where <i>T<sub>0</sub></i> is the static type of
+ * form <i>(T<sub>1</sub> a<sub>1</sub>, …, T<sub>n</sub> a<sub>n</sub>, \[T<sub>n+1</sub>
+ * x<sub>n+1</sub> = d1, …, T<sub>n+k</sub> x<sub>n+k</sub> = dk\]) => e</i> is
+ * <i>(T<sub>1</sub>, …, Tn, \[T<sub>n+1</sub> x<sub>n+1</sub>, …, T<sub>n+k</sub>
+ * x<sub>n+k</sub>\]) → T<sub>0</sub></i>, where <i>T<sub>0</sub></i> is the static type of
* <i>e</i>. In any case where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is
* considered to have been specified as dynamic.
* <p>
@@ -4450,9 +4851,9 @@
* <= i <= n</i>, is not specified, it is considered to have been specified as dynamic.
* <p>
* The static type of a function literal of the form <i>(T<sub>1</sub> a<sub>1</sub>, …,
- * T<sub>n</sub> a<sub>n</sub>, [T<sub>n+1</sub> x<sub>n+1</sub> = d1, …, T<sub>n+k</sub>
- * x<sub>n+k</sub> = dk]) {s}</i> is <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>
- * x<sub>n+1</sub>, …, T<sub>n+k</sub> x<sub>n+k</sub>]) → dynamic</i>. In any case
+ * T<sub>n</sub> a<sub>n</sub>, \[T<sub>n+1</sub> x<sub>n+1</sub> = d1, …, T<sub>n+k</sub>
+ * x<sub>n+k</sub> = dk\]) {s}</i> is <i>(T<sub>1</sub>, …, T<sub>n</sub>, \[T<sub>n+1</sub>
+ * x<sub>n+1</sub>, …, T<sub>n+k</sub> x<sub>n+k</sub>\]) → dynamic</i>. In any case
* where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is considered to have been
* specified as dynamic.
* <p>
@@ -4486,8 +4887,8 @@
Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => recordReturnType(node, node.element);
/**
* The Dart Language Specification, 12.29: <blockquote>An assignable expression of the form
- * <i>e<sub>1</sub>[e<sub>2</sub>]</i> is evaluated as a method invocation of the operator method
- * <i>[]</i> on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.</blockquote>
+ * <i>e<sub>1</sub>\[e<sub>2</sub>\]</i> is evaluated as a method invocation of the operator method
+ * <i>\[\]</i> on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.</blockquote>
*/
Object visitIndexExpression(IndexExpression node) {
if (node.inSetterContext()) {
@@ -4532,10 +4933,10 @@
Object visitIsExpression(IsExpression node) => recordType(node, _typeProvider.boolType);
/**
* The Dart Language Specification, 12.6: <blockquote>The static type of a list literal of the
- * form <i><b>const</b> <E>[e<sub>1</sub>, …, e<sub>n</sub>]</i> or the form
- * <i><E>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is {@code List<E>}. The static
- * type a list literal of the form <i><b>const</b> [e<sub>1</sub>, …, e<sub>n</sub>]</i> or
- * the form <i>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is {@code List<dynamic>}.</blockquote>
+ * form <i><b>const</b> <E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> or the form
+ * <i><E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List<E>}. The static
+ * type a list literal of the form <i><b>const</b> \[e<sub>1</sub>, …, e<sub>n</sub>\]</i> or
+ * the form <i>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List<dynamic>}.</blockquote>
*/
Object visitListLiteral(ListLiteral node) {
TypeArgumentList typeArguments2 = node.typeArguments;
@@ -4679,7 +5080,7 @@
* A postfix expression of the form <i>e1.v++</i> is equivalent to <i>(x){var r = x.v; x.v = r +
* 1; return r}(e1)</i>.
* <p>
- * A postfix expression of the form <i>e1[e2]++</i> is equivalent to <i>(a, i){var r = a[i]; a[i]
+ * A postfix expression of the form <i>e1\[e2\]++</i> is equivalent to <i>(a, i){var r = a\[i\]; a\[i\]
* = r + 1; return r}(e1, e2)</i>
* <p>
* A postfix expression of the form <i>v--</i>, where <i>v</i> is an identifier, is equivalent to
@@ -4691,7 +5092,7 @@
* A postfix expression of the form <i>e1.v--</i> is equivalent to <i>(x){var r = x.v; x.v = r -
* 1; return r}(e1)</i>.
* <p>
- * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i){var r = a[i]; a[i]
+ * A postfix expression of the form <i>e1\[e2\]--</i> is equivalent to <i>(a, i){var r = a\[i\]; a\[i\]
* = r - 1; return r}(e1, e2)</i></blockquote>
*/
Object visitPostfixExpression(PostfixExpression node) => recordType(node, getType2(node.operand));
@@ -4758,8 +5159,8 @@
* p<sub>k</sub>: p<sub>k</sub>);}</i> if <i>m</i> has required parameters <i>r<sub>1</sub>,
* …, r<sub>n</sub></i>, and named parameters <i>p<sub>1</sub> … p<sub>k</sub></i>
* with defaults <i>d<sub>1</sub>, …, d<sub>k</sub></i>.</li>
- * <li><i>(r<sub>1</sub>, …, r<sub>n</sub>, [p<sub>1</sub> = d<sub>1</sub>, …,
- * p<sub>k</sub> = d<sub>k</sub>]){return o.m(r<sub>1</sub>, …, r<sub>n</sub>,
+ * <li><i>(r<sub>1</sub>, …, r<sub>n</sub>, \[p<sub>1</sub> = d<sub>1</sub>, …,
+ * p<sub>k</sub> = d<sub>k</sub>\]){return o.m(r<sub>1</sub>, …, r<sub>n</sub>,
* p<sub>1</sub>, …, p<sub>k</sub>);}</i> if <i>m</i> has required parameters
* <i>r<sub>1</sub>, …, r<sub>n</sub></i>, and optional positional parameters
* <i>p<sub>1</sub> … p<sub>k</sub></i> with defaults <i>d<sub>1</sub>, …,
@@ -5041,6 +5442,11 @@
}
return null;
}
+ /**
+ * Return the type of the given (overridable) element.
+ * @param element the element whose type is to be returned
+ * @return the type of the given element
+ */
Type2 getType(Element element) {
if (element is LocalVariableElement) {
return ((element as LocalVariableElement)).type;
@@ -5064,7 +5470,7 @@
/**
* Return the type that should be recorded for a node that resolved to the given accessor.
* @param accessor the accessor that the node resolved to
- * @param context if the accessor element has context [by being the RHS of a{@link PrefixedIdentifier} or {@link PropertyAccess}], and the return type of the
+ * @param context if the accessor element has context \[by being the RHS of a{@link PrefixedIdentifier} or {@link PropertyAccess}\], and the return type of the
* accessor is a parameter type, then the type of the LHS can be used to get more
* specific type information
* @return the type that should be recorded for a node that resolved to the given accessor
@@ -5138,7 +5544,7 @@
* @param inferredType the inferred type of the element
*/
void override(VariableElement element, Type2 staticType, Type2 inferredType) {
- if (identical(inferredType, BottomTypeImpl.instance) || element is! VariableElement) {
+ if (identical(inferredType, BottomTypeImpl.instance)) {
return;
}
if (element is PropertyInducingElement) {
@@ -5553,9 +5959,9 @@
* @param typeProvider the object used to access the types from the core library
*/
TypeResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider) : super.con1(library, source, typeProvider) {
- _jtd_constructor_273_impl(library, source, typeProvider);
+ _jtd_constructor_274_impl(library, source, typeProvider);
}
- _jtd_constructor_273_impl(Library library, Source source, TypeProvider typeProvider) {
+ _jtd_constructor_274_impl(Library library, Source source, TypeProvider typeProvider) {
_dynamicType = typeProvider.dynamicType;
}
/**
@@ -5568,9 +5974,9 @@
* during resolution
*/
TypeResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) {
- _jtd_constructor_274_impl(definingLibrary, source, typeProvider, errorListener);
+ _jtd_constructor_275_impl(definingLibrary, source, typeProvider, errorListener);
}
- _jtd_constructor_274_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
+ _jtd_constructor_275_impl(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
_dynamicType = typeProvider.dynamicType;
}
Object visitCatchClause(CatchClause node) {
@@ -5781,7 +6187,11 @@
} else {
simpleIdentifier = ((typeName as PrefixedIdentifier)).prefix;
}
- reportError(StaticWarningCode.UNDEFINED_CLASS, simpleIdentifier, [simpleIdentifier.name]);
+ if (simpleIdentifier.name == "boolean") {
+ reportError(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, simpleIdentifier, []);
+ } else {
+ reportError(StaticWarningCode.UNDEFINED_CLASS, simpleIdentifier, [simpleIdentifier.name]);
+ }
setElement(typeName, _dynamicType.element);
typeName.staticType = _dynamicType;
node.type = _dynamicType;
@@ -6252,16 +6662,26 @@
* @param typeElement the element representing the type alias represented by this scope
*/
FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement) : super(new EnclosedScope(enclosingScope)) {
- defineTypeParameters(typeElement);
+ defineTypeVariables(typeElement);
+ defineParameters(typeElement);
}
/**
- * Define the type parameters for the function type alias.
+ * Define the parameters for the function type alias.
* @param typeElement the element representing the type represented by this scope
*/
- void defineTypeParameters(FunctionTypeAliasElement typeElement) {
- Scope parameterScope = enclosingScope;
- for (TypeVariableElement parameter in typeElement.typeVariables) {
- parameterScope.define(parameter);
+ void defineParameters(FunctionTypeAliasElement typeElement) {
+ for (ParameterElement parameter in typeElement.parameters) {
+ define(parameter);
+ }
+ }
+ /**
+ * Define the type variables for the function type alias.
+ * @param typeElement the element representing the type represented by this scope
+ */
+ void defineTypeVariables(FunctionTypeAliasElement typeElement) {
+ Scope typeVariableScope = enclosingScope;
+ for (TypeVariableElement typeVariable in typeElement.typeVariables) {
+ typeVariableScope.define(typeVariable);
}
}
}
@@ -6297,10 +6717,10 @@
* @param onSwitchMember {@code true} if this label is associated with a {@code switch} member
*/
LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
- _jtd_constructor_279_impl(outerScope, onSwitchStatement, onSwitchMember);
+ _jtd_constructor_280_impl(outerScope, onSwitchStatement, onSwitchMember);
}
- _jtd_constructor_279_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
- _jtd_constructor_280_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
+ _jtd_constructor_280_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
+ _jtd_constructor_281_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
}
/**
* Initialize a newly created scope to represent the given label.
@@ -6309,9 +6729,9 @@
* @param element the element to which the label resolves
*/
LabelScope.con2(LabelScope outerScope2, String label2, LabelElement element2) {
- _jtd_constructor_280_impl(outerScope2, label2, element2);
+ _jtd_constructor_281_impl(outerScope2, label2, element2);
}
- _jtd_constructor_280_impl(LabelScope outerScope2, String label2, LabelElement element2) {
+ _jtd_constructor_281_impl(LabelScope outerScope2, String label2, LabelElement element2) {
this._outerScope = outerScope2;
this._label = label2;
this._element = element2;
@@ -6985,6 +7405,11 @@
*/
bool _isInSystemLibrary = false;
/**
+ * The class containing the AST nodes being visited, or {@code null} if we are not in the scope of
+ * a class.
+ */
+ ClassElement _enclosingClass;
+ /**
* The method or function that we are currently visiting, or {@code null} if we are not inside a
* method or function.
*/
@@ -7037,7 +7462,9 @@
}
}
Object visitClassDeclaration(ClassDeclaration node) {
+ ClassElement outerClass = _enclosingClass;
try {
+ _enclosingClass = node.element;
checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME);
ClassElement classElement = node.element;
if (classElement != null) {
@@ -7053,6 +7480,7 @@
return super.visitClassDeclaration(node);
} finally {
_initialFieldElementsMap = null;
+ _enclosingClass = outerClass;
}
}
Object visitClassTypeAlias(ClassTypeAlias node) {
@@ -7077,6 +7505,10 @@
_enclosingFunction = outerFunction;
}
}
+ Object visitDefaultFormalParameter(DefaultFormalParameter node) {
+ checkForPrivateOptionalParameter(node);
+ return super.visitDefaultFormalParameter(node);
+ }
Object visitDoStatement(DoStatement node) {
checkForNonBoolCondition(node.condition);
return super.visitDoStatement(node);
@@ -7133,14 +7565,41 @@
}
return super.visitInstanceCreationExpression(node);
}
+ Object visitListLiteral(ListLiteral node) {
+ if (node.modifier != null) {
+ TypeArgumentList typeArguments2 = node.typeArguments;
+ if (typeArguments2 != null) {
+ NodeList<TypeName> arguments2 = typeArguments2.arguments;
+ if (arguments2.length != 0) {
+ checkForInvalidTypeArgumentInConstTypedLiteral(arguments2, CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST);
+ }
+ }
+ }
+ return super.visitListLiteral(node);
+ }
Object visitMapLiteral(MapLiteral node) {
- checkForInvalidTypeArgumentForKey(node);
+ TypeArgumentList typeArguments2 = node.typeArguments;
+ if (typeArguments2 != null) {
+ NodeList<TypeName> arguments2 = typeArguments2.arguments;
+ if (arguments2.length != 0) {
+ checkForInvalidTypeArgumentForKey(arguments2);
+ if (node.modifier != null) {
+ checkForInvalidTypeArgumentInConstTypedLiteral(arguments2, CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP);
+ }
+ }
+ }
return super.visitMapLiteral(node);
}
Object visitMethodDeclaration(MethodDeclaration node) {
ExecutableElement previousFunction = _enclosingFunction;
try {
_enclosingFunction = node.element;
+ if (node.isSetter()) {
+ checkForWrongNumberOfParametersForSetter(node);
+ } else if (node.isOperator()) {
+ checkForOptionalParameterInOperator(node);
+ }
+ checkForConcreteClassWithAbstractMember(node);
return super.visitMethodDeclaration(node);
} finally {
_enclosingFunction = previousFunction;
@@ -7155,7 +7614,7 @@
return super.visitRethrowExpression(node);
}
Object visitReturnStatement(ReturnStatement node) {
- checkForReturnOfInvalidType(node);
+ checkForAllReturnStatementErrorCodes(node);
return super.visitReturnStatement(node);
}
Object visitSimpleFormalParameter(SimpleFormalParameter node) {
@@ -7259,6 +7718,46 @@
return foundError;
}
/**
+ * This checks that the return statement of the form <i>return e;</i> is not in a generative
+ * constructor.
+ * <p>
+ * This checks that return statements without expressions are not in a generative constructor and
+ * the return type is not assignable to {@code null}; that is, we don't have {@code return;} if
+ * the enclosing method has a return type.
+ * <p>
+ * This checks that the return type matches the type of the declared return type in the enclosing
+ * method or function.
+ * @param node the return statement to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#RETURN_IN_GENERATIVE_CONSTRUCTOR
+ * @see StaticWarningCode#RETURN_WITHOUT_VALUE
+ * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE
+ */
+ bool checkForAllReturnStatementErrorCodes(ReturnStatement node) {
+ FunctionType functionType = _enclosingFunction == null ? null : _enclosingFunction.type;
+ Type2 expectedReturnType = functionType == null ? DynamicTypeImpl.instance : functionType.returnType;
+ Expression returnExpression = node.expression;
+ bool isGenerativeConstructor = _enclosingFunction is ConstructorElement && !((_enclosingFunction as ConstructorElement)).isFactory();
+ if (returnExpression != null) {
+ if (isGenerativeConstructor) {
+ _errorReporter.reportError(CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR, returnExpression, []);
+ return true;
+ }
+ if (!expectedReturnType.isVoid()) {
+ Type2 actualReturnType = getType(returnExpression);
+ if (!actualReturnType.isAssignableTo(expectedReturnType)) {
+ _errorReporter.reportError(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [actualReturnType.name, expectedReturnType.name, _enclosingFunction.name]);
+ return true;
+ }
+ }
+ } else {
+ if (!isGenerativeConstructor && !VoidTypeImpl.instance.isAssignableTo(expectedReturnType)) {
+ _errorReporter.reportError(StaticWarningCode.RETURN_WITHOUT_VALUE, node, []);
+ }
+ }
+ return false;
+ }
+ /**
* This verifies that the passed argument definition test identifier is a parameter.
* @param node the {@link ArgumentDefinitionTest} to evaluate
* @return return {@code true} if and only if an error code is generated on the passed node
@@ -7338,6 +7837,21 @@
}
return false;
}
+ /**
+ * This verifies that the passed method declaration is abstract only if the enclosing class is
+ * also abstract.
+ * @param node the method declaration to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see StaticWarningCode#CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ */
+ bool checkForConcreteClassWithAbstractMember(MethodDeclaration node) {
+ if (node.isAbstract() && _enclosingClass != null && !_enclosingClass.isAbstract()) {
+ SimpleIdentifier methodName = node.name;
+ _errorReporter.reportError(StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER, methodName, [methodName.name, _enclosingClass.name]);
+ return true;
+ }
+ return false;
+ }
bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node) {
ConstructorElement constructorElement = node.element;
SimpleIdentifier constructorName = node.name;
@@ -7633,21 +8147,13 @@
return false;
}
/**
- * Checks to ensure that native function bodies can only in SDK code.
- * @param node the map literal to test
+ * Checks to ensure that first type argument to a map literal must be the 'String' type.
+ * @param arguments a non-{@code null}, non-empty {@link TypeName} node list from the respective{@link MapLiteral}
* @return return {@code true} if and only if an error code is generated on the passed node
* @see CompileTimeErrorCode#INVALID_TYPE_ARGUMENT_FOR_KEY
*/
- bool checkForInvalidTypeArgumentForKey(MapLiteral node) {
- TypeArgumentList typeArgumentList = node.typeArguments;
- if (typeArgumentList == null) {
- return false;
- }
- NodeList<TypeName> arguments2 = typeArgumentList.arguments;
- if (arguments2.length == 0) {
- return false;
- }
- TypeName firstArgument = arguments2[0];
+ bool checkForInvalidTypeArgumentForKey(NodeList<TypeName> arguments) {
+ TypeName firstArgument = arguments[0];
Type2 firstArgumentType = firstArgument.type;
if (firstArgumentType != null && firstArgumentType != _typeProvider.stringType) {
_errorReporter.reportError(CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_FOR_KEY, firstArgument, []);
@@ -7656,6 +8162,23 @@
return false;
}
/**
+ * Checks to ensure that the passed {@link ListLiteral} or {@link MapLiteral} does not have a type
+ * parameter as a type argument.
+ * @param arguments a non-{@code null}, non-empty {@link TypeName} node list from the respective{@link ListLiteral} or {@link MapLiteral}
+ * @param errorCode either {@link CompileTimeErrorCode#INVALID_TYPE_ARGUMENT_IN_CONST_LIST} or{@link CompileTimeErrorCode#INVALID_TYPE_ARGUMENT_IN_CONST_MAP}
+ * @return {@code true} if and only if an error code is generated on the passed node
+ */
+ bool checkForInvalidTypeArgumentInConstTypedLiteral(NodeList<TypeName> arguments, ErrorCode errorCode) {
+ bool foundError = false;
+ for (TypeName typeName in arguments) {
+ if (typeName.type is TypeVariableType) {
+ _errorReporter.reportError(errorCode, typeName, [typeName.name]);
+ foundError = true;
+ }
+ }
+ return foundError;
+ }
+ /**
* Checks to ensure that native function bodies can only in SDK code.
* @param node the native function body to test
* @return return {@code true} if and only if an error code is generated on the passed node
@@ -7707,6 +8230,48 @@
return false;
}
/**
+ * This verifies the passed operator-method declaration, does not have an optional parameter.
+ * <p>
+ * This method assumes that the method declaration was tested to be an operator declaration before
+ * being called.
+ * @param node the method declaration to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#OPTIONAL_PARAMETER_IN_OPERATOR
+ */
+ bool checkForOptionalParameterInOperator(MethodDeclaration node) {
+ FormalParameterList parameterList = node.parameters;
+ if (parameterList == null) {
+ return false;
+ }
+ bool foundError = false;
+ NodeList<FormalParameter> formalParameters = parameterList.parameters;
+ for (FormalParameter formalParameter in formalParameters) {
+ if (formalParameter.kind.isOptional()) {
+ _errorReporter.reportError(CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR, formalParameter, []);
+ foundError = true;
+ }
+ }
+ return foundError;
+ }
+ /**
+ * This checks for named optional parameters that begin with '_'.
+ * @param node the default formal parameter to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER
+ */
+ bool checkForPrivateOptionalParameter(DefaultFormalParameter node) {
+ sc.Token separator2 = node.separator;
+ if (separator2 != null && separator2.lexeme == ":") {
+ NormalFormalParameter parameter2 = node.parameter;
+ SimpleIdentifier name = parameter2.identifier;
+ if (!name.isSynthetic() && name.name.startsWith("_")) {
+ _errorReporter.reportError(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, node, []);
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
* This checks that the rethrow is inside of a catch clause.
* @param node the rethrow expression to evaluate
* @return {@code true} if and only if an error code is generated on the passed node
@@ -7720,28 +8285,8 @@
return false;
}
/**
- * This checks that the return type matches the type of the declared return type in the enclosing
- * method or function.
- * @param node the return statement to evaluate
- * @return return {@code true} if and only if an error code is generated on the passed node
- * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE
- */
- bool checkForReturnOfInvalidType(ReturnStatement node) {
- FunctionType functionType = _enclosingFunction == null ? null : _enclosingFunction.type;
- Type2 expectedReturnType = functionType == null ? null : functionType.returnType;
- Expression returnExpression = node.expression;
- if (expectedReturnType != null && !expectedReturnType.isVoid() && returnExpression != null) {
- Type2 actualReturnType = getType(returnExpression);
- if (!actualReturnType.isAssignableTo(expectedReturnType)) {
- _errorReporter.reportError(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [actualReturnType.name, expectedReturnType.name, _enclosingFunction.name]);
- return true;
- }
- }
- return false;
- }
- /**
* This verifies that the type arguments in the passed instance creation expression are all within
- * their bounds as specified by the class element where the constructor [that is being invoked] is
+ * their bounds as specified by the class element where the constructor \[that is being invoked\] is
* declared.
* @param node the instance creation expression to evaluate
* @param typeName the {@link TypeName} of the {@link ConstructorName} from the{@link InstanceCreationExpression}, this is the AST node that the error is attached to
@@ -7769,6 +8314,27 @@
return false;
}
/**
+ * This verifies if the passed setter method declaration, has only one parameter.
+ * <p>
+ * This method assumes that the method declaration was tested to be a setter before being called.
+ * @param node the method declaration to evaluate
+ * @return return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+ */
+ bool checkForWrongNumberOfParametersForSetter(MethodDeclaration node) {
+ FormalParameterList parameterList = node.parameters;
+ if (parameterList == null) {
+ return false;
+ }
+ NodeList<FormalParameter> formalParameters = parameterList.parameters;
+ int numberOfParameters = formalParameters.length;
+ if (numberOfParameters != 1) {
+ _errorReporter.reportError(CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER, node.name, [numberOfParameters]);
+ return true;
+ }
+ return false;
+ }
+ /**
* Return the type of the given expression that is to be used for type analysis.
* @param expression the expression whose type is to be returned
* @return the type of the given expression
diff --git a/pkg/analyzer_experimental/lib/src/generated/scanner.dart b/pkg/analyzer_experimental/lib/src/generated/scanner.dart
index d98b898..205e54d 100644
--- a/pkg/analyzer_experimental/lib/src/generated/scanner.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/scanner.dart
@@ -259,10 +259,10 @@
* @param syntax the lexeme for the keyword
*/
Keyword.con1(String ___name, int ___ordinal, String syntax) {
- _jtd_constructor_308_impl(___name, ___ordinal, syntax);
+ _jtd_constructor_309_impl(___name, ___ordinal, syntax);
}
- _jtd_constructor_308_impl(String ___name, int ___ordinal, String syntax) {
- _jtd_constructor_309_impl(___name, ___ordinal, syntax, false);
+ _jtd_constructor_309_impl(String ___name, int ___ordinal, String syntax) {
+ _jtd_constructor_310_impl(___name, ___ordinal, syntax, false);
}
/**
* Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
@@ -271,9 +271,9 @@
* @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword
*/
Keyword.con2(String ___name, int ___ordinal, String syntax2, bool isPseudoKeyword) {
- _jtd_constructor_309_impl(___name, ___ordinal, syntax2, isPseudoKeyword);
+ _jtd_constructor_310_impl(___name, ___ordinal, syntax2, isPseudoKeyword);
}
- _jtd_constructor_309_impl(String ___name, int ___ordinal, String syntax2, bool isPseudoKeyword) {
+ _jtd_constructor_310_impl(String ___name, int ___ordinal, String syntax2, bool isPseudoKeyword) {
__name = ___name;
__ordinal = ___ordinal;
this._syntax = syntax2;
@@ -705,7 +705,7 @@
* @param arguments any arguments needed to complete the error message
*/
void reportError(ScannerErrorCode errorCode, List<Object> arguments) {
- _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, [arguments]));
+ _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments));
}
int select(int choice, TokenType yesType, TokenType noType) {
int next = advance();
@@ -1568,7 +1568,7 @@
}
/**
* Instances of the class {@code BeginToken} represent the opening half of a grouping pair of
- * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('[').
+ * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('\[').
* @coverage dart.engine.parser
*/
class BeginToken extends Token {
@@ -1676,15 +1676,15 @@
*/
int _precedence = 0;
TokenClass.con1(String ___name, int ___ordinal) {
- _jtd_constructor_318_impl(___name, ___ordinal);
+ _jtd_constructor_319_impl(___name, ___ordinal);
}
- _jtd_constructor_318_impl(String ___name, int ___ordinal) {
- _jtd_constructor_319_impl(___name, ___ordinal, 0);
+ _jtd_constructor_319_impl(String ___name, int ___ordinal) {
+ _jtd_constructor_320_impl(___name, ___ordinal, 0);
}
TokenClass.con2(String ___name, int ___ordinal, int precedence2) {
- _jtd_constructor_319_impl(___name, ___ordinal, precedence2);
+ _jtd_constructor_320_impl(___name, ___ordinal, precedence2);
}
- _jtd_constructor_319_impl(String ___name, int ___ordinal, int precedence2) {
+ _jtd_constructor_320_impl(String ___name, int ___ordinal, int precedence2) {
__name = ___name;
__ordinal = ___ordinal;
this._precedence = precedence2;
@@ -1811,15 +1811,15 @@
*/
String _lexeme;
TokenType.con1(String ___name, int ___ordinal) {
- _jtd_constructor_320_impl(___name, ___ordinal);
+ _jtd_constructor_321_impl(___name, ___ordinal);
}
- _jtd_constructor_320_impl(String ___name, int ___ordinal) {
- _jtd_constructor_321_impl(___name, ___ordinal, TokenClass.NO_CLASS, null);
+ _jtd_constructor_321_impl(String ___name, int ___ordinal) {
+ _jtd_constructor_322_impl(___name, ___ordinal, TokenClass.NO_CLASS, null);
}
TokenType.con2(String ___name, int ___ordinal, TokenClass tokenClass2, String lexeme2) {
- _jtd_constructor_321_impl(___name, ___ordinal, tokenClass2, lexeme2);
+ _jtd_constructor_322_impl(___name, ___ordinal, tokenClass2, lexeme2);
}
- _jtd_constructor_321_impl(String ___name, int ___ordinal, TokenClass tokenClass2, String lexeme2) {
+ _jtd_constructor_322_impl(String ___name, int ___ordinal, TokenClass tokenClass2, String lexeme2) {
__name = ___name;
__ordinal = ___ordinal;
this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2;
diff --git a/pkg/analyzer_experimental/lib/src/generated/sdk.dart b/pkg/analyzer_experimental/lib/src/generated/sdk.dart
index 9ff8716..64bc958 100644
--- a/pkg/analyzer_experimental/lib/src/generated/sdk.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/sdk.dart
@@ -6,7 +6,7 @@
import 'dart:uri';
import 'java_core.dart';
import 'java_engine.dart';
-import 'source.dart' show Source, ContentCache;
+import 'source.dart' show ContentCache, Source, UriKind;
import 'engine.dart' show AnalysisContext;
/**
@@ -217,6 +217,15 @@
*/
static String DART_HTML = "dart:html";
/**
+ * Return the source representing the file with the given URI.
+ * @param contentCache the content cache used to access the contents of the mapped source
+ * @param kind the kind of URI that was originally resolved in order to produce an encoding with
+ * the given URI
+ * @param uri the URI of the file to be returned
+ * @return the source representing the specified file
+ */
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri);
+ /**
* Return the {@link AnalysisContext} used for all of the sources in this {@link DartSdk}.
* @return the {@link AnalysisContext} used for all of the sources in this {@link DartSdk}
*/
diff --git a/pkg/analyzer_experimental/lib/src/generated/sdk_io.dart b/pkg/analyzer_experimental/lib/src/generated/sdk_io.dart
index 09ac253..9c40c3b 100644
--- a/pkg/analyzer_experimental/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/sdk_io.dart
@@ -164,6 +164,7 @@
}
_analysisContext.applyChanges(changeSet);
}
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind);
AnalysisContext get context => _analysisContext;
/**
* Return the file containing the Dartium executable, or {@code null} if it does not exist.
@@ -277,7 +278,7 @@
if (library == null) {
return null;
}
- return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryDirectory, library.path), true);
+ return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryDirectory, library.path), UriKind.DART_URI);
}
/**
* Ensure that the dart VM is executable. If it is not, make it executable and log that it was
@@ -361,7 +362,7 @@
LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) {
List<bool> foundError = [false];
AnalysisErrorListener errorListener = new AnalysisErrorListener_10(foundError);
- Source source = new FileBasedSource.con2(null, librariesFile, false);
+ Source source = new FileBasedSource.con2(null, librariesFile, UriKind.FILE_URI);
StringScanner scanner = new StringScanner(source, libraryFileContents, errorListener);
Parser parser = new Parser(source, errorListener);
CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
diff --git a/pkg/analyzer_experimental/lib/src/generated/source.dart b/pkg/analyzer_experimental/lib/src/generated/source.dart
index f5f63be..83c24d0 100644
--- a/pkg/analyzer_experimental/lib/src/generated/source.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/source.dart
@@ -31,9 +31,9 @@
* @param resolvers the resolvers used to resolve absolute URI's
*/
SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) {
- _jtd_constructor_332_impl(contentCache2, resolvers2);
+ _jtd_constructor_333_impl(contentCache2, resolvers2);
}
- _jtd_constructor_332_impl(ContentCache contentCache2, List<UriResolver> resolvers2) {
+ _jtd_constructor_333_impl(ContentCache contentCache2, List<UriResolver> resolvers2) {
this._contentCache = contentCache2;
this._resolvers = resolvers2;
}
@@ -42,10 +42,10 @@
* @param resolvers the resolvers used to resolve absolute URI's
*/
SourceFactory.con2(List<UriResolver> resolvers) {
- _jtd_constructor_333_impl(resolvers);
+ _jtd_constructor_334_impl(resolvers);
}
- _jtd_constructor_333_impl(List<UriResolver> resolvers) {
- _jtd_constructor_332_impl(new ContentCache(), resolvers);
+ _jtd_constructor_334_impl(List<UriResolver> resolvers) {
+ _jtd_constructor_333_impl(new ContentCache(), resolvers);
}
/**
* Return a source object representing the given absolute URI, or {@code null} if the URI is not a
@@ -64,12 +64,33 @@
return null;
}
/**
- * Return a source object that is equal to the source object used to obtain the given encoding, or{@code null} if the argument is not a valid encoding.
+ * Return a source object that is equal to the source object used to obtain the given encoding.
* @param encoding the encoding of a source object
* @return a source object that is described by the given encoding
+ * @throws IllegalArgumentException if the argument is not a valid encoding
* @see Source#getEncoding()
*/
- Source fromEncoding(String encoding) => forUri(encoding);
+ Source fromEncoding(String encoding) {
+ if (encoding.length < 2) {
+ throw new IllegalArgumentException("Invalid encoding length");
+ }
+ UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0));
+ if (kind == null) {
+ throw new IllegalArgumentException("Invalid source kind in encoding: ${kind}");
+ }
+ try {
+ Uri uri = new Uri(encoding.substring(1));
+ for (UriResolver resolver in _resolvers) {
+ Source result = resolver.fromEncoding(_contentCache, kind, uri);
+ if (result != null) {
+ return result;
+ }
+ }
+ throw new IllegalArgumentException("No resolver for kind: ${kind}");
+ } catch (exception) {
+ throw new IllegalArgumentException("Invalid URI in encoding");
+ }
+ }
/**
* Return a cache of content used to override the default content of a source.
* @return a cache of content used to override the default content of a source
@@ -183,11 +204,22 @@
UriResolver() : super() {
}
/**
+ * If this resolver should be used for URI's of the given kind, resolve the given absolute URI.
+ * The URI does not need to have the scheme handled by this resolver if the kind matches. Return a{@link Source source} representing the file to which it was resolved, or {@code null} if it
+ * could not be resolved.
+ * @param contentCache the content cache used to access the contents of the returned source
+ * @param kind the kind of URI that was originally resolved in order to produce an encoding with
+ * the given URI
+ * @param uri the URI to be resolved
+ * @return a {@link Source source} representing the file to which given URI was resolved
+ */
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri);
+ /**
* Resolve the given absolute URI. Return a {@link Source source} representing the file to which
* it was resolved, or {@code null} if it could not be resolved.
* @param contentCache the content cache used to access the contents of the returned source
* @param uri the URI to be resolved
- * @return a {@link Source source} representing the URI to which given URI was resolved
+ * @return a {@link Source source} representing the file to which given URI was resolved
*/
Source resolveAbsolute(ContentCache contentCache, Uri uri);
}
@@ -254,6 +286,14 @@
*/
String get shortName;
/**
+ * Return the kind of URI from which this source was originally derived. If this source was
+ * created from an absolute URI, then the returned kind will reflect the scheme of the absolute
+ * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
+ * of the source against which the relative URI was resolved.
+ * @return the kind of URI from which this source was originally derived
+ */
+ UriKind get uriKind;
+ /**
* Return a hash code for this source.
* @return a hash code for this source
* @see Object#hashCode()
@@ -331,6 +371,66 @@
String toString() => __name;
}
/**
+ * The enumeration {@code UriKind} defines the different kinds of URI's that are known to the
+ * analysis engine. These are used to keep track of the kind of URI associated with a given source.
+ * @coverage dart.engine.source
+ */
+class UriKind implements Comparable<UriKind> {
+ /**
+ * A 'dart:' URI.
+ */
+ static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64);
+ /**
+ * A 'file:' URI.
+ */
+ static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66);
+ /**
+ * A 'package:' URI.
+ */
+ static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 2, 0x70);
+ static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_URI];
+ final String __name;
+ final int __ordinal;
+ int get ordinal => __ordinal;
+ /**
+ * The single character encoding used to identify this kind of URI.
+ */
+ int _encoding = 0;
+ /**
+ * Initialize a newly created URI kind to have the given encoding.
+ * @param encoding the single character encoding used to identify this kind of URI.
+ */
+ UriKind(this.__name, this.__ordinal, int encoding) {
+ this._encoding = encoding;
+ }
+ /**
+ * Return the URI kind represented by the given encoding, or {@code null} if there is no kind with
+ * the given encoding.
+ * @param encoding the single character encoding used to identify the URI kind to be returned
+ * @return the URI kind represented by the given encoding
+ */
+ static UriKind fromEncoding(int encoding) {
+ while (true) {
+ if (encoding == 0x64) {
+ return DART_URI;
+ } else if (encoding == 0x66) {
+ return FILE_URI;
+ } else if (encoding == 0x70) {
+ return PACKAGE_URI;
+ }
+ break;
+ }
+ return null;
+ }
+ /**
+ * Return the single character encoding used to identify this kind of URI.
+ * @return the single character encoding used to identify this kind of URI
+ */
+ int get encoding => _encoding;
+ int compareTo(UriKind other) => __ordinal - other.__ordinal;
+ String toString() => __name;
+}
+/**
* A source range defines an {@link Element}'s source coordinates relative to its {@link Source}.
* @coverage dart.engine.utilities
*/
@@ -355,7 +455,7 @@
this._length = length;
}
/**
- * @return {@code true} if <code>x</code> is in [offset, offset + length) interval.
+ * @return {@code true} if <code>x</code> is in \[offset, offset + length) interval.
*/
bool contains(int x) => _offset <= x && x < _offset + _length;
/**
@@ -485,6 +585,12 @@
DartUriResolver(DartSdk sdk) {
this._sdk = sdk;
}
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
+ if (identical(kind, UriKind.DART_URI)) {
+ return _sdk.fromEncoding(contentCache, kind, uri);
+ }
+ return null;
+ }
/**
* Return the {@link DartSdk} against which URIs are to be resolved.
* @return the {@link DartSdk} against which URIs are to be resolved.
diff --git a/pkg/analyzer_experimental/lib/src/generated/source_io.dart b/pkg/analyzer_experimental/lib/src/generated/source_io.dart
index 28991a4..f016564 100644
--- a/pkg/analyzer_experimental/lib/src/generated/source_io.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/source_io.dart
@@ -27,13 +27,13 @@
*/
JavaFile _file;
/**
- * The cached URI of the {@link #file}.
+ * The cached encoding for this source.
*/
- String _fileUriString;
+ String _encoding;
/**
- * A flag indicating whether this source is in one of the system libraries.
+ * The kind of URI from which this source was originally derived.
*/
- bool _inSystemLibrary = false;
+ UriKind _uriKind;
/**
* Initialize a newly created source object. The source object is assumed to not be in a system
* library.
@@ -41,25 +41,25 @@
* @param file the file represented by this source
*/
FileBasedSource.con1(ContentCache contentCache, JavaFile file) {
- _jtd_constructor_328_impl(contentCache, file);
+ _jtd_constructor_329_impl(contentCache, file);
}
- _jtd_constructor_328_impl(ContentCache contentCache, JavaFile file) {
- _jtd_constructor_329_impl(contentCache, file, false);
+ _jtd_constructor_329_impl(ContentCache contentCache, JavaFile file) {
+ _jtd_constructor_330_impl(contentCache, file, UriKind.FILE_URI);
}
/**
* Initialize a newly created source object.
* @param contentCache the content cache used to access the contents of this source
* @param file the file represented by this source
- * @param inSystemLibrary {@code true} if this source is in one of the system libraries
+ * @param flags {@code true} if this source is in one of the system libraries
*/
- FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, bool inSystemLibrary2) {
- _jtd_constructor_329_impl(contentCache2, file2, inSystemLibrary2);
+ FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) {
+ _jtd_constructor_330_impl(contentCache2, file2, uriKind2);
}
- _jtd_constructor_329_impl(ContentCache contentCache2, JavaFile file2, bool inSystemLibrary2) {
+ _jtd_constructor_330_impl(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) {
this._contentCache = contentCache2;
this._file = file2;
- this._inSystemLibrary = inSystemLibrary2;
- this._fileUriString = file2.toURI().toString();
+ this._uriKind = uriKind2;
+ this._encoding = "${uriKind2.encoding}${file2.toURI().toString()}";
}
bool operator ==(Object object) => object != null && this.runtimeType == object.runtimeType && _file == ((object as FileBasedSource))._file;
bool exists() => _contentCache.getContents(this) != null || (_file.exists() && !_file.isDirectory());
@@ -73,7 +73,7 @@
}
receiver.accept2(_file.readAsStringSync(), _file.lastModified());
}
- String get encoding => _fileUriString;
+ String get encoding => _encoding;
String get fullName => _file.getAbsolutePath();
int get modificationStamp {
int stamp = _contentCache.getModificationStamp(this);
@@ -83,12 +83,13 @@
return _file.lastModified();
}
String get shortName => _file.getName();
+ UriKind get uriKind => _uriKind;
int get hashCode => _file.hashCode;
- bool isInSystemLibrary() => _inSystemLibrary;
+ bool isInSystemLibrary() => identical(_uriKind, UriKind.DART_URI);
Source resolveRelative(Uri containedUri) {
try {
Uri resolvedUri = file.toURI().resolveUri(containedUri);
- return new FileBasedSource.con2(_contentCache, new JavaFile.fromUri(resolvedUri), isInSystemLibrary());
+ return new FileBasedSource.con2(_contentCache, new JavaFile.fromUri(resolvedUri), _uriKind);
} catch (exception) {
}
return null;
@@ -142,6 +143,12 @@
}
this._packagesDirectories = packagesDirectories;
}
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
+ if (identical(kind, UriKind.PACKAGE_URI)) {
+ return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind);
+ }
+ return null;
+ }
Source resolveAbsolute(ContentCache contentCache, Uri uri) {
if (!isPackageUri(uri)) {
return null;
@@ -168,10 +175,10 @@
for (JavaFile packagesDirectory in _packagesDirectories) {
JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path2);
if (resolvedFile.exists()) {
- return new FileBasedSource.con1(contentCache, getCanonicalFile(packagesDirectory, pkgName, relPath));
+ return new FileBasedSource.con2(contentCache, getCanonicalFile(packagesDirectory, pkgName, relPath), UriKind.PACKAGE_URI);
}
}
- return new FileBasedSource.con1(contentCache, getCanonicalFile(_packagesDirectories[0], pkgName, relPath));
+ return new FileBasedSource.con2(contentCache, getCanonicalFile(_packagesDirectories[0], pkgName, relPath), UriKind.PACKAGE_URI);
}
/**
* Answer the canonical file for the specified package.
@@ -219,19 +226,19 @@
* @param directory the directory (not {@code null})
*/
DirectoryBasedSourceContainer.con1(JavaFile directory) {
- _jtd_constructor_326_impl(directory);
+ _jtd_constructor_327_impl(directory);
}
- _jtd_constructor_326_impl(JavaFile directory) {
- _jtd_constructor_327_impl(directory.getPath());
+ _jtd_constructor_327_impl(JavaFile directory) {
+ _jtd_constructor_328_impl(directory.getPath());
}
/**
* Construct a container representing the specified path and containing any sources whose{@link Source#getFullName()} starts with the specified path.
* @param path the path (not {@code null} and not empty)
*/
DirectoryBasedSourceContainer.con2(String path2) {
- _jtd_constructor_327_impl(path2);
+ _jtd_constructor_328_impl(path2);
}
- _jtd_constructor_327_impl(String path2) {
+ _jtd_constructor_328_impl(String path2) {
this._path = appendFileSeparator(path2);
}
bool contains(Source source) => source.fullName.startsWith(_path);
@@ -242,6 +249,7 @@
*/
String get path => _path;
int get hashCode => _path.hashCode;
+ String toString() => "SourceContainer[${_path}]";
}
/**
* Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
@@ -264,6 +272,12 @@
*/
FileUriResolver() : super() {
}
+ Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
+ if (identical(kind, UriKind.FILE_URI)) {
+ return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind);
+ }
+ return null;
+ }
Source resolveAbsolute(ContentCache contentCache, Uri uri) {
if (!isFileUri(uri)) {
return null;
diff --git a/pkg/analyzer_experimental/test/generated/element_test.dart b/pkg/analyzer_experimental/test/generated/element_test.dart
index 834b925..c13d1dc 100644
--- a/pkg/analyzer_experimental/test/generated/element_test.dart
+++ b/pkg/analyzer_experimental/test/generated/element_test.dart
@@ -408,14 +408,6 @@
FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElementImpl.con1(ASTFactory.identifier3("f")));
JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType));
}
- void test_getLeastUpperBound_ignoreTypeParameters() {
- InterfaceType listType2 = _typeProvider.listType;
- InterfaceType intType2 = _typeProvider.intType;
- InterfaceType doubleType2 = _typeProvider.doubleType;
- InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
- InterfaceType listOfDoubleType = listType2.substitute5(<Type2> [doubleType2]);
- JUnitTestCase.assertEquals(listType2, listOfIntType.getLeastUpperBound(listOfDoubleType));
- }
void test_getLeastUpperBound_mixinCase() {
ClassElement classA = ElementFactory.classElement2("A", []);
ClassElement classB = ElementFactory.classElement("B", classA.type, []);
@@ -553,6 +545,20 @@
JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
}
+ void test_getLeastUpperBound_typeParameters_different() {
+ InterfaceType listType2 = _typeProvider.listType;
+ InterfaceType intType2 = _typeProvider.intType;
+ InterfaceType doubleType2 = _typeProvider.doubleType;
+ InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
+ InterfaceType listOfDoubleType = listType2.substitute5(<Type2> [doubleType2]);
+ JUnitTestCase.assertEquals(listType2.substitute5(<Type2> [_typeProvider.numType]), listOfIntType.getLeastUpperBound(listOfDoubleType));
+ }
+ void test_getLeastUpperBound_typeParameters_same() {
+ InterfaceType listType2 = _typeProvider.listType;
+ InterfaceType intType2 = _typeProvider.intType;
+ InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
+ JUnitTestCase.assertEquals(listOfIntType, listOfIntType.getLeastUpperBound(listOfIntType));
+ }
void test_getMethod_implemented() {
ClassElementImpl classA = ElementFactory.classElement2("A", []);
String methodName = "m";
@@ -1118,10 +1124,6 @@
final __test = new InterfaceTypeImplTest();
runJUnitTest(__test, __test.test_getLeastUpperBound_functionType);
});
- _ut.test('test_getLeastUpperBound_ignoreTypeParameters', () {
- final __test = new InterfaceTypeImplTest();
- runJUnitTest(__test, __test.test_getLeastUpperBound_ignoreTypeParameters);
- });
_ut.test('test_getLeastUpperBound_mixinCase', () {
final __test = new InterfaceTypeImplTest();
runJUnitTest(__test, __test.test_getLeastUpperBound_mixinCase);
@@ -1170,6 +1172,14 @@
final __test = new InterfaceTypeImplTest();
runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface4);
});
+ _ut.test('test_getLeastUpperBound_typeParameters_different', () {
+ final __test = new InterfaceTypeImplTest();
+ runJUnitTest(__test, __test.test_getLeastUpperBound_typeParameters_different);
+ });
+ _ut.test('test_getLeastUpperBound_typeParameters_same', () {
+ final __test = new InterfaceTypeImplTest();
+ runJUnitTest(__test, __test.test_getLeastUpperBound_typeParameters_same);
+ });
_ut.test('test_getMethod_implemented', () {
final __test = new InterfaceTypeImplTest();
runJUnitTest(__test, __test.test_getMethod_implemented);
@@ -1475,6 +1485,7 @@
}
return field;
}
+ static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) => new FieldFormalParameterElementImpl(name);
static FunctionElementImpl functionElement(String functionName) => functionElement4(functionName, null, null, null, null);
static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalParameters) {
@@ -1630,6 +1641,26 @@
ElementFactory() {
}
}
+class ElementKindTest extends EngineTestCase {
+ void test_of_nonNull() {
+ JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.classElement2("A", [])));
+ }
+ void test_of_null() {
+ JUnitTestCase.assertSame(ElementKind.ERROR, ElementKind.of(null));
+ }
+ static dartSuite() {
+ _ut.group('ElementKindTest', () {
+ _ut.test('test_of_nonNull', () {
+ final __test = new ElementKindTest();
+ runJUnitTest(__test, __test.test_of_nonNull);
+ });
+ _ut.test('test_of_null', () {
+ final __test = new ElementKindTest();
+ runJUnitTest(__test, __test.test_of_null);
+ });
+ });
+ }
+}
class ClassElementImplTest extends EngineTestCase {
void test_getAllSupertypes_interface() {
ClassElement classA = ElementFactory.classElement2("A", []);
@@ -1671,6 +1702,7 @@
MethodElement method = ElementFactory.methodElement(methodName, null, []);
classA.methods = <MethodElement> [method];
JUnitTestCase.assertSame(method, classA.getMethod(methodName));
+ JUnitTestCase.assertSame(method, classA.getExecutable(methodName));
}
void test_getMethod_undeclared() {
ClassElementImpl classA = ElementFactory.classElement2("A", []);
@@ -1678,6 +1710,7 @@
MethodElement method = ElementFactory.methodElement(methodName, null, []);
classA.methods = <MethodElement> [method];
JUnitTestCase.assertNull(classA.getMethod("${methodName}x"));
+ JUnitTestCase.assertNull(classA.getExecutable("${methodName}x"));
}
void test_lookUpGetter_declared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1687,6 +1720,7 @@
classA.accessors = <PropertyAccessorElement> [getter];
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library2));
+ JUnitTestCase.assertSame(getter, classA.lookUpExecutable(getterName, library2));
}
void test_lookUpGetter_inherited() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1697,12 +1731,14 @@
ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library2));
+ JUnitTestCase.assertSame(getter, classB.lookUpExecutable(getterName, library2));
}
void test_lookUpGetter_undeclared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
ClassElementImpl classA = ElementFactory.classElement2("A", []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertNull(classA.lookUpGetter("g", library2));
+ JUnitTestCase.assertNull(classA.lookUpExecutable("g", library2));
}
void test_lookUpMethod_declared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1712,6 +1748,7 @@
classA.methods = <MethodElement> [method];
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library2));
+ JUnitTestCase.assertSame(method, classA.lookUpExecutable(methodName, library2));
}
void test_lookUpMethod_inherited() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1722,12 +1759,14 @@
ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library2));
+ JUnitTestCase.assertSame(method, classB.lookUpExecutable(methodName, library2));
}
void test_lookUpMethod_undeclared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
ClassElementImpl classA = ElementFactory.classElement2("A", []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertNull(classA.lookUpMethod("m", library2));
+ JUnitTestCase.assertNull(classA.lookUpExecutable("m", library2));
}
void test_lookUpSetter_declared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1737,6 +1776,7 @@
classA.accessors = <PropertyAccessorElement> [setter];
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library2));
+ JUnitTestCase.assertSame(setter, classA.lookUpExecutable(setterName, library2));
}
void test_lookUpSetter_inherited() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
@@ -1747,12 +1787,14 @@
ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library2));
+ JUnitTestCase.assertSame(setter, classB.lookUpExecutable(setterName, library2));
}
void test_lookUpSetter_undeclared() {
LibraryElementImpl library2 = ElementFactory.library(createAnalysisContext(), "lib");
ClassElementImpl classA = ElementFactory.classElement2("A", []);
((library2.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
JUnitTestCase.assertNull(classA.lookUpSetter("s", library2));
+ JUnitTestCase.assertNull(classA.lookUpExecutable("s", library2));
}
static dartSuite() {
_ut.group('ClassElementImplTest', () {
@@ -2332,6 +2374,7 @@
bool isDartCoreFunction() => true;
}
main() {
+ ElementKindTest.dartSuite();
FunctionTypeImplTest.dartSuite();
InterfaceTypeImplTest.dartSuite();
TypeVariableTypeImplTest.dartSuite();
diff --git a/pkg/analyzer_experimental/test/generated/parser_test.dart b/pkg/analyzer_experimental/test/generated/parser_test.dart
index 0cd547e..31def04 100644
--- a/pkg/analyzer_experimental/test/generated/parser_test.dart
+++ b/pkg/analyzer_experimental/test/generated/parser_test.dart
@@ -1040,6 +1040,11 @@
JUnitTestCase.assertNull(commentAndMetadata.comment);
EngineTestCase.assertSize(0, commentAndMetadata.metadata);
}
+ void test_parseCommentAndMetadata_singleLine() {
+ CommentAndMetadata commentAndMetadata = ParserTestCase.parse5("parseCommentAndMetadata", EngineTestCase.createSource(["/// 1", "/// 2", "void"]), []);
+ JUnitTestCase.assertNotNull(commentAndMetadata.comment);
+ EngineTestCase.assertSize(0, commentAndMetadata.metadata);
+ }
void test_parseCommentReference_new_prefixed() {
CommentReference reference = ParserTestCase.parse("parseCommentReference", <Object> ["new a.b", 7], "");
PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(PrefixedIdentifier, reference.identifier);
@@ -1110,6 +1115,51 @@
JUnitTestCase.assertNotNull(reference.identifier);
JUnitTestCase.assertEquals(35, reference.offset);
}
+ void test_parseCommentReferences_skipCodeBlock_bracketed() {
+ List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3)];
+ List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
+ EngineTestCase.assertSize(1, references);
+ CommentReference reference = references[0];
+ JUnitTestCase.assertNotNull(reference);
+ JUnitTestCase.assertNotNull(reference.identifier);
+ JUnitTestCase.assertEquals(24, reference.offset);
+ }
+ void test_parseCommentReferences_skipCodeBlock_spaces() {
+ List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/**\n * a[i]\n * xxx [i] zzz\n */", 3)];
+ List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
+ EngineTestCase.assertSize(1, references);
+ CommentReference reference = references[0];
+ JUnitTestCase.assertNotNull(reference);
+ JUnitTestCase.assertNotNull(reference.identifier);
+ JUnitTestCase.assertEquals(27, reference.offset);
+ }
+ void test_parseCommentReferences_skipLinkDefinition() {
+ List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a]: http://www.google.com (Google) [b] zzz */", 3)];
+ List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
+ EngineTestCase.assertSize(1, references);
+ CommentReference reference = references[0];
+ JUnitTestCase.assertNotNull(reference);
+ JUnitTestCase.assertNotNull(reference.identifier);
+ JUnitTestCase.assertEquals(44, reference.offset);
+ }
+ void test_parseCommentReferences_skipLinked() {
+ List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a](http://www.google.com) [b] zzz */", 3)];
+ List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
+ EngineTestCase.assertSize(1, references);
+ CommentReference reference = references[0];
+ JUnitTestCase.assertNotNull(reference);
+ JUnitTestCase.assertNotNull(reference.identifier);
+ JUnitTestCase.assertEquals(35, reference.offset);
+ }
+ void test_parseCommentReferences_skipReferenceLink() {
+ List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3)];
+ List<CommentReference> references = ParserTestCase.parse("parseCommentReferences", <Object> [tokens], "");
+ EngineTestCase.assertSize(1, references);
+ CommentReference reference = references[0];
+ JUnitTestCase.assertNotNull(reference);
+ JUnitTestCase.assertNotNull(reference.identifier);
+ JUnitTestCase.assertEquals(15, reference.offset);
+ }
void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
CompilationUnit unit = ParserTestCase.parse5("parseCompilationUnit", "abstract<dynamic> _abstract = new abstract.A();", []);
JUnitTestCase.assertNull(unit.scriptTag);
@@ -4310,6 +4360,10 @@
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCommentAndMetadata_none);
});
+ _ut.test('test_parseCommentAndMetadata_singleLine', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentAndMetadata_singleLine);
+ });
_ut.test('test_parseCommentReference_new_prefixed', () {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCommentReference_new_prefixed);
@@ -4334,6 +4388,26 @@
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCommentReferences_singleLine);
});
+ _ut.test('test_parseCommentReferences_skipCodeBlock_bracketed', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentReferences_skipCodeBlock_bracketed);
+ });
+ _ut.test('test_parseCommentReferences_skipCodeBlock_spaces', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentReferences_skipCodeBlock_spaces);
+ });
+ _ut.test('test_parseCommentReferences_skipLinkDefinition', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentReferences_skipLinkDefinition);
+ });
+ _ut.test('test_parseCommentReferences_skipLinked', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentReferences_skipLinked);
+ });
+ _ut.test('test_parseCommentReferences_skipReferenceLink', () {
+ final __test = new SimpleParserTest();
+ runJUnitTest(__test, __test.test_parseCommentReferences_skipReferenceLink);
+ });
_ut.test('test_parseCompilationUnitMember_abstractAsPrefix', () {
final __test = new SimpleParserTest();
runJUnitTest(__test, __test.test_parseCompilationUnitMember_abstractAsPrefix);
@@ -8471,11 +8545,14 @@
'createSyntheticToken_1': new MethodTrampoline(1, (Parser target, arg0) => target.createSyntheticToken(arg0)),
'ensureAssignable_1': new MethodTrampoline(1, (Parser target, arg0) => target.ensureAssignable(arg0)),
'expect_1': new MethodTrampoline(1, (Parser target, arg0) => target.expect(arg0)),
+ 'findRange_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target.findRange(arg0, arg1)),
+ 'getCodeBlockRanges_1': new MethodTrampoline(1, (Parser target, arg0) => target.getCodeBlockRanges(arg0)),
'hasReturnTypeInTypeAlias_0': new MethodTrampoline(0, (Parser target) => target.hasReturnTypeInTypeAlias()),
'isFunctionDeclaration_0': new MethodTrampoline(0, (Parser target) => target.isFunctionDeclaration()),
'isFunctionExpression_1': new MethodTrampoline(1, (Parser target, arg0) => target.isFunctionExpression(arg0)),
'isHexDigit_1': new MethodTrampoline(1, (Parser target, arg0) => target.isHexDigit(arg0)),
'isInitializedVariableDeclaration_0': new MethodTrampoline(0, (Parser target) => target.isInitializedVariableDeclaration()),
+ 'isLinkText_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target.isLinkText(arg0, arg1)),
'isOperator_1': new MethodTrampoline(1, (Parser target, arg0) => target.isOperator(arg0)),
'isSwitchMember_0': new MethodTrampoline(0, (Parser target) => target.isSwitchMember()),
'lexicallyFirst_1': new MethodTrampoline(1, (Parser target, arg0) => target.lexicallyFirst(arg0)),
diff --git a/pkg/analyzer_experimental/test/generated/resolver_test.dart b/pkg/analyzer_experimental/test/generated/resolver_test.dart
index 130f6f0..829f7ff 100644
--- a/pkg/analyzer_experimental/test/generated/resolver_test.dart
+++ b/pkg/analyzer_experimental/test/generated/resolver_test.dart
@@ -25,7 +25,7 @@
class TypePropagationTest extends ResolverTestCase {
void test_as() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -40,7 +40,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_assert() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " assert (p is A);", " return p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " assert (p is A);", " return p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -54,7 +54,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_assignment() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var v;", " v = 0;", " return v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var v;", " v = 0;", " return v;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -66,7 +66,7 @@
JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType);
}
void test_assignment_afterInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var v = 0;", " v = 1.0;", " return v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;", " v = 1.0;", " return v;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -77,8 +77,23 @@
SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
JUnitTestCase.assertSame(typeProvider.doubleType, variableName.staticType);
}
+ void test_forEach() {
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(List<A> p) {", " for (var e in p) {", " return e;", " }", "}"]));
+ LibraryElement library = resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
+ InterfaceType typeA = classA.element.type;
+ FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
+ BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionBody;
+ ForEachStatement forStatement = body2.block.statements[0] as ForEachStatement;
+ ReturnStatement statement = ((forStatement.body as Block)).statements[0] as ReturnStatement;
+ SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
+ JUnitTestCase.assertSame(typeA, variableName.staticType);
+ }
void test_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var v = 0;", " return v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;", " return v;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -89,8 +104,19 @@
SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType);
}
+ void test_initializer_dereference() {
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 'String';", " v.", "}"]));
+ LibraryElement library = resolve(source, []);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
+ BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionBody;
+ ExpressionStatement statement = body2.block.statements[1] as ExpressionStatement;
+ PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier;
+ SimpleIdentifier variableName = invocation.prefix;
+ JUnitTestCase.assertSame(typeProvider.stringType, variableName.staticType);
+ }
void test_is_conditional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is A) ? p : null;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is A) ? p : null;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -105,7 +131,22 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_is_if() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " return p;", " } else {", " return null;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " return p;", " } else {", " return null;", " }", "}"]));
+ LibraryElement library = resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
+ InterfaceType typeA = classA.element.type;
+ FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
+ BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionBody;
+ IfStatement ifStatement = body2.block.statements[0] as IfStatement;
+ ReturnStatement statement = ((ifStatement.thenStatement as Block)).statements[0] as ReturnStatement;
+ SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
+ JUnitTestCase.assertSame(typeA, variableName.staticType);
+ }
+ void test_is_if_lessSpecific() {
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(A p) {", " if (p is Object) {", " return p;", " } else {", " return null;", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -120,7 +161,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_is_if_logicalAnd() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A && p != null) {", " return p;", " } else {", " return null;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A && p != null) {", " return p;", " } else {", " return null;", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -135,7 +176,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_is_postConditional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -149,7 +190,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_is_postIf() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", " }", " return p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", " }", " return p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -163,7 +204,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_is_subclass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " return p.m();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " return p.m();", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -175,8 +216,23 @@
MethodInvocation invocation = statement.expression as MethodInvocation;
JUnitTestCase.assertNotNull(invocation.methodName.element);
}
+ void test_is_while() {
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " while (p is A) {", " return p;", " }", "}"]));
+ LibraryElement library = resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ CompilationUnit unit = resolveCompilationUnit(source, library);
+ ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
+ InterfaceType typeA = classA.element.type;
+ FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
+ BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionBody;
+ WhileStatement whileStatement = body2.block.statements[0] as WhileStatement;
+ ReturnStatement statement = ((whileStatement.body as Block)).statements[0] as ReturnStatement;
+ SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
+ JUnitTestCase.assertSame(typeA, variableName.staticType);
+ }
void test_isNot_conditional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is! A) ? null : p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " return (p is! A) ? null : p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -191,7 +247,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_isNot_if() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -206,7 +262,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_isNot_if_logicalOr() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -221,7 +277,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_isNot_postConditional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -235,7 +291,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_isNot_postIf() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(var p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -249,7 +305,7 @@
JUnitTestCase.assertSame(typeA, variableName.staticType);
}
void test_query() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'dart:html';", "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["import 'dart:html';", "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
LibraryElement library = resolve(source, []);
assertNoErrors();
verify([source]);
@@ -288,10 +344,18 @@
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_assignment_afterInitializer);
});
+ _ut.test('test_forEach', () {
+ final __test = new TypePropagationTest();
+ runJUnitTest(__test, __test.test_forEach);
+ });
_ut.test('test_initializer', () {
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_initializer);
});
+ _ut.test('test_initializer_dereference', () {
+ final __test = new TypePropagationTest();
+ runJUnitTest(__test, __test.test_initializer_dereference);
+ });
_ut.test('test_isNot_conditional', () {
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_isNot_conditional);
@@ -320,6 +384,10 @@
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_is_if);
});
+ _ut.test('test_is_if_lessSpecific', () {
+ final __test = new TypePropagationTest();
+ runJUnitTest(__test, __test.test_is_if_lessSpecific);
+ });
_ut.test('test_is_if_logicalAnd', () {
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_is_if_logicalAnd);
@@ -336,6 +404,10 @@
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_is_subclass);
});
+ _ut.test('test_is_while', () {
+ final __test = new TypePropagationTest();
+ runJUnitTest(__test, __test.test_is_while);
+ });
_ut.test('test_query', () {
final __test = new TypePropagationTest();
runJUnitTest(__test, __test.test_query);
@@ -345,301 +417,354 @@
}
class NonErrorResolverTest extends ResolverTestCase {
void test_argumentDefinitionTestNonParameter_formalParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var v) {", " return ?v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(var v) {", " return ?v;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_argumentDefinitionTestNonParameter_namedParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_argumentDefinitionTestNonParameter_optionalParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f([var v]) {", " return ?v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " return ?v;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_breakWithoutLabelInSwitch() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;", " }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;", " }", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_builtInIdentifierAsType_dynamic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " dynamic x;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_caseExpressionTypeImplementsEquals_int() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int i) {", " switch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(int i) {", " switch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_caseExpressionTypeImplementsEquals_Object() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_caseExpressionTypeImplementsEquals_String() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(String s) {", " switch(s) {", " case('1') : return 1;", " default: return 0;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(String s) {", " switch(s) {", " case('1') : return 1;", " default: return 0;", " }", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_concreteClassWithAbstractMember() {
+ Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_constConstructorWithNonFinalField_constInstanceVar() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const int x = 0;", " const A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " const A() {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_constConstructorWithNonFinalField_finalInstanceVar() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " const A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " const A() {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_constConstructorWithNonFinalField_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int x;", " const A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static int x;", " const A() {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_constConstructorWithNonFinalField_syntheticField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_defaultValueInFunctionTypeAlias() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef F([x]);"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"]));
resolve(source, []);
assertErrors([]);
verify([source]);
}
void test_duplicateDefinition_emptyName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["Map _globalMap = {", " 'a' : () {},", " 'b' : () {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["Map _globalMap = {", " 'a' : () {},", " 'b' : () {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_duplicateDefinition_getter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["bool get a => true;"]));
+ Source source = addSource(EngineTestCase.createSource(["bool get a => true;"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_exportOfNonLibrary_libraryDeclared() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_exportOfNonLibrary_libraryNotDeclared() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
- addSource("/lib1.dart", EngineTestCase.createSource([""]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource([""]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_fieldInitializedByMultipleInitializers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " int y;", " A() : x = 0, y = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " int y;", " A() : x = 0, y = 0 {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_fieldInitializerOutsideConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_fieldInitializerOutsideConstructor_defaultParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A([this.x]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A([this.x]) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_finalInitializedInDeclarationAndConstructor_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x;", " A() : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 1 {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x;", " A(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_finalNotInitialized_atDeclaration() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_finalNotInitialized_fieldFormal() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_finalNotInitialized_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 0 {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_importOfNonLibrary_libraryDeclared() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
- addSource("/part.dart", EngineTestCase.createSource(["library lib1;"]));
+ Source source = addSource(EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
+ addSource2("/part.dart", EngineTestCase.createSource(["library lib1;"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_importOfNonLibrary_libraryNotDeclared() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
- addSource("/part.dart", EngineTestCase.createSource([""]));
+ Source source = addSource(EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
+ addSource2("/part.dart", EngineTestCase.createSource([""]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_inconsistentCaseExpressionTypes() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 2:", " break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 2:", " break;", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_initializingFormalForNonExistantField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_invalidAssignment() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_invalidAssignment_toDynamic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var g;", " g = () => 0;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g = () => 0;", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_invalidTypeArgumentInConstList() {
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m() {", " return <E>[]", " }", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_invalidTypeArgumentInConstMap() {
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m() {", " return <String, E>{}", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_invocationOfNonFunction_dynamic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var f;", "}", "class B extends A {", " g() {", " f();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " var f;", "}", "class B extends A {", " g() {", " f();", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_invocationOfNonFunction_getter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var g;", "}", "f() {", " A a;", " a.g();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " var g;", "}", "f() {", " A a;", " a.g();", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_invocationOfNonFunction_localVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var g;", " g();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_newWithAbstractClass_factory() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["abstract class A {", " factory A() { return new B(); }", "}", "class B implements A {", " B() {}", "}", "A f() {", " return new A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["abstract class A {", " factory A() { return new B(); }", "}", "class B implements A {", " B() {}", "}", "A f() {", " return new A();", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_nonBoolExpression_assert_bool() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " assert(true);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " assert(true);", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_nonBoolExpression_assert_functionType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_optionalParameterInOperator_required() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " operator +(p) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_rethrowOutsideCatch() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m() {", " try {} catch (e) {rethrow;}", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " try {} catch (e) {rethrow;}", " }", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_returnInGenerativeConstructor() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return; }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_returnOfInvalidType_dynamic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class TypeError {}", "class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class TypeError {}", "class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_returnOfInvalidType_subtype() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_returnOfInvalidType_supertype() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_returnWithoutValue_noReturnType() {
+ Source source = addSource(EngineTestCase.createSource(["f() { return; }"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_returnWithoutValue_void() {
+ Source source = addSource(EngineTestCase.createSource(["void f() { return; }"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_typeArgumentNotMatchingBounds_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_typeArgumentNotMatchingBounds_new() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_undefinedGetter_typeSubstitution() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<E> {", " E element;", "}", "class B extends A<List> {", " m() {", " element.last;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {", " E element;", "}", "class B extends A<List> {", " m() {", " element.last;", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_undefinedIdentifier_hide() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart' hide a;"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' hide a;"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_undefinedIdentifier_show() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
+ void test_undefinedMethod_noSuchMethod() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " noSuchMethod() {}", "}", "f() {", " (new A()).someMethod();", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ }
void test_undefinedOperator_tilde() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["const A = 3;", "const B = ~((1 << A) - 1);"]));
+ Source source = addSource(EngineTestCase.createSource(["const A = 3;", "const B = ~((1 << A) - 1);"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_wrongNumberOfParametersForSetter() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " set x(a) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
@@ -678,6 +803,10 @@
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int);
});
+ _ut.test('test_concreteClassWithAbstractMember', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
+ });
_ut.test('test_constConstructorWithNonFinalField_constInstanceVar', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_constInstanceVar);
@@ -778,6 +907,14 @@
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
});
+ _ut.test('test_invalidTypeArgumentInConstList', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
+ });
+ _ut.test('test_invalidTypeArgumentInConstMap', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
+ });
_ut.test('test_invocationOfNonFunction_dynamic', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
@@ -802,10 +939,18 @@
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType);
});
+ _ut.test('test_optionalParameterInOperator_required', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_optionalParameterInOperator_required);
+ });
_ut.test('test_rethrowOutsideCatch', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_rethrowOutsideCatch);
});
+ _ut.test('test_returnInGenerativeConstructor', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
+ });
_ut.test('test_returnOfInvalidType_dynamic', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic);
@@ -818,6 +963,14 @@
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_returnOfInvalidType_supertype);
});
+ _ut.test('test_returnWithoutValue_noReturnType', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType);
+ });
+ _ut.test('test_returnWithoutValue_void', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_returnWithoutValue_void);
+ });
_ut.test('test_typeArgumentNotMatchingBounds_const', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
@@ -838,10 +991,18 @@
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_undefinedIdentifier_show);
});
+ _ut.test('test_undefinedMethod_noSuchMethod', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_undefinedMethod_noSuchMethod);
+ });
_ut.test('test_undefinedOperator_tilde', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_undefinedOperator_tilde);
});
+ _ut.test('test_wrongNumberOfParametersForSetter', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter);
+ });
});
}
}
@@ -993,177 +1154,177 @@
}
class StaticTypeWarningCodeTest extends ResolverTestCase {
void fail_inaccessibleSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]);
verify([source]);
}
void fail_inconsistentMethodInheritance() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
verify([source]);
}
void fail_nonTypeAsTypeArgument() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
verify([source]);
}
void fail_redirectWithInvalidTypeParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.REDIRECT_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
void fail_typeArgumentViolatesBounds() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_VIOLATES_BOUNDS]);
verify([source]);
}
void test_invalidAssignment_instanceVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", "}", "f() {", " A a;", " a.x = '0';", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", "}", "f() {", " A a;", " a.x = '0';", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
void test_invalidAssignment_localVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " int x;", " x = '0';", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " x = '0';", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
void test_invalidAssignment_staticVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int x;", "}", "f() {", " A.x = '0';", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static int x;", "}", "f() {", " A.x = '0';", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
void test_invocationOfNonFunction_class() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m() {", " A();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " A();", " }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
void test_invocationOfNonFunction_localVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " int x;", " return x();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " return x();", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
verify([source]);
}
void test_invocationOfNonFunction_ordinaryInvocation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", "}", "class B {", " m() {", " A.x();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", "}", "class B {", " m() {", " A.x();", " }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
void test_invocationOfNonFunction_staticInvocation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int get g => 0;", " f() {", " A.g();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static int get g => 0;", " f() {", " A.g();", " }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
}
void test_nonBoolCondition_conditional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() { return 3 ? 2 : 1; }"]));
+ Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 : 1; }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
verify([source]);
}
void test_nonBoolCondition_do() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " do {} while (3);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " do {} while (3);", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
verify([source]);
}
void test_nonBoolCondition_if() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " if (3) return 2; else return 1;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) return 2; else return 1;", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
verify([source]);
}
void test_nonBoolCondition_while() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " while (3) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
verify([source]);
}
void test_nonBoolExpression() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " assert(0);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0);", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
verify([source]);
}
void test_returnOfInvalidType_function() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int f() { return '0'; }"]));
+ Source source = addSource(EngineTestCase.createSource(["int f() { return '0'; }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
verify([source]);
}
void test_returnOfInvalidType_localFunction() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " String m() {", " int f() { return '0'; }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " String m() {", " int f() { return '0'; }", " }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
verify([source]);
}
void test_returnOfInvalidType_method() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int f() { return '0'; }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int f() { return '0'; }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
verify([source]);
}
void test_typeArgumentNotMatchingBounds_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
verify([source]);
}
void test_typeArgumentNotMatchingBounds_new() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
verify([source]);
}
void test_undefinedFunction() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["void f() {", " g();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["void f() {", " g();", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_FUNCTION]);
}
void test_undefinedGetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"]));
+ Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]);
}
void test_undefinedGetter_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "var a = A.B;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "var a = A.B;"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]);
}
void test_undefinedMethod() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m() {", " n();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " n();", " }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]);
}
void test_undefinedSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {}", "f(T e1) { e1.m = 0; }"]));
+ Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1) { e1.m = 0; }"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]);
}
void test_undefinedSetter_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f() { A.B = 0;}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { A.B = 0;}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]);
}
void test_undefinedSuperMethod() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {", " m() { return super.m(); }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " m() { return super.m(); }", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
}
void test_wrongNumberOfTypeArguments_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<E, F> {}", "A<A> a = null;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", "A<A> a = null;"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void test_wrongNumberOfTypeArguments_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<E> {}", "A<A, A> a = null;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A, A> a = null;"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
@@ -1301,12 +1462,12 @@
}
void fail_visitFieldFormalParameter_noType() {
FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, "p");
- JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, []));
+ JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, []));
_listener.assertNoErrors();
}
void fail_visitFieldFormalParameter_type() {
FormalParameter node = ASTFactory.fieldFormalParameter(null, ASTFactory.typeName4("int", []), "p");
- JUnitTestCase.assertSame(_typeProvider.intType, resolve5(node, []));
+ JUnitTestCase.assertSame(_typeProvider.intType, resolve6(node, []));
_listener.assertNoErrors();
}
void fail_visitFunctionDeclaration() {
@@ -1425,7 +1586,7 @@
void test_visitSimpleFormalParameter_noType() {
FormalParameter node = ASTFactory.simpleFormalParameter3("p");
node.identifier.element = new ParameterElementImpl(ASTFactory.identifier3("p"));
- JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve5(node, []));
+ JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, []));
_listener.assertNoErrors();
}
void test_visitSimpleFormalParameter_type() {
@@ -1435,7 +1596,7 @@
SimpleIdentifier identifier2 = node.identifier;
ParameterElementImpl element = new ParameterElementImpl(identifier2);
identifier2.element = element;
- JUnitTestCase.assertSame(intType2, resolve5(node, [intElement]));
+ JUnitTestCase.assertSame(intType2, resolve6(node, [intElement]));
_listener.assertNoErrors();
}
void test_visitTypeName_noParameters_noArguments() {
@@ -1507,7 +1668,7 @@
* being resolved
* @return the type associated with the parameter
*/
- Type2 resolve5(FormalParameter node, List<Element> definedElements) {
+ Type2 resolve6(FormalParameter node, List<Element> definedElements) {
resolveNode(node, definedElements);
return ((node.identifier.element as ParameterElement)).type;
}
@@ -1608,12 +1769,18 @@
_sourceFactory = _analysisContext.sourceFactory;
}
/**
+ * Add a source file to the content provider.
+ * @param contents the contents to be returned by the content provider for the specified file
+ * @return the source object representing the added file
+ */
+ Source addSource(String contents) => addSource2("/test.dart", contents);
+ /**
* Add a source file to the content provider. The file path should be absolute.
* @param filePath the path of the file being added
* @param contents the contents to be returned by the content provider for the specified file
* @return the source object representing the added file
*/
- Source addSource(String filePath, String contents) {
+ Source addSource2(String filePath, String contents) {
Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUtilities2.createFile(filePath));
_sourceFactory.setContents(source, contents);
ChangeSet changeSet = new ChangeSet();
@@ -1785,726 +1952,702 @@
}
class CompileTimeErrorCodeTest extends ResolverTestCase {
void fail_ambiguousExport() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
- addSource("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
+ addSource2("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
verify([source]);
}
void fail_ambiguousImport_function() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "g() { return f(); }"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["f() {}"]));
- addSource("/lib2.dart", EngineTestCase.createSource(["f() {}"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "g() { return f(); }"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["f() {}"]));
+ addSource2("/lib2.dart", EngineTestCase.createSource(["f() {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
verify([source]);
}
void fail_ambiguousImport_typeAnnotation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "class A extends N {}"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
- addSource("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "class A extends N {}"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
+ addSource2("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
verify([source]);
}
void fail_compileTimeConstantRaisesException() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]);
verify([source]);
}
void fail_constWithNonConstantArgument() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a) {};", "}", "f(p) { return const T(p); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class T {", " T(a) {};", "}", "f(p) { return const T(p); }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
verify([source]);
}
void fail_constWithNonType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
verify([source]);
}
void fail_constWithTypeParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
verify([source]);
}
void fail_constWithUndefinedConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(x) {}", "}", "f() {", " return const A(0);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A(x) {}", "}", "f() {", " return const A(0);", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
verify([source]);
}
void fail_duplicateDefinition() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " int m = 0;", " m(a) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0;", " m(a) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([source]);
}
+ void fail_duplicateMemberError_classMembers_fields() {
+ Source librarySource = addSource(EngineTestCase.createSource(["class A {", " int a;", " int a;", "}"]));
+ resolve(librarySource, []);
+ assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ verify([librarySource]);
+ }
+ void fail_duplicateMemberError_classMembers_methods() {
+ Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {}", " m() {}", "}"]));
+ resolve(librarySource, []);
+ assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ verify([librarySource]);
+ }
+ void fail_duplicateMemberError_localFields() {
+ Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {", " int a;", " int a;", " }", "}"]));
+ resolve(librarySource, []);
+ assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
+ verify([librarySource]);
+ }
void fail_duplicateMemberName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]);
verify([source]);
}
void fail_duplicateMemberNameInstanceStatic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " static int x;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " static int x;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME_INSTANCE_STATIC]);
verify([source]);
}
void fail_duplicateNamedArgument() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f({a, a}) {}"]));
+ Source source = addSource(EngineTestCase.createSource(["f({a, a}) {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
verify([source]);
}
void fail_extendsOrImplementsDisallowedClass_extends_null() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends Null {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void fail_extendsOrImplementsDisallowedClass_implements_null() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements Null {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements Null {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void fail_finalNotInitialized_inConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void fail_getterAndMethodWithSameName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " get x -> 0;", " x(y) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " get x -> 0;", " x(y) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
verify([source]);
}
void fail_importDuplicatedLibraryName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library test;", "import 'lib1.dart';", "import 'lib2.dart';"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["library lib;"]));
- addSource("/lib2.dart", EngineTestCase.createSource(["library lib;"]));
+ Source source = addSource(EngineTestCase.createSource(["library test;", "import 'lib1.dart';", "import 'lib2.dart';"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["library lib;"]));
+ addSource2("/lib2.dart", EngineTestCase.createSource(["library lib;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME]);
verify([source]);
}
void fail_invalidConstructorName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
verify([source]);
}
void fail_invalidFactoryNameNotAClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
verify([source]);
}
void fail_invalidOverrideDefaultValue() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m([a = 0]) {}", "}", "class B extends A {", " m([a = 1]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m([a = 0]) {}", "}", "class B extends A {", " m([a = 1]) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_DEFAULT_VALUE]);
verify([source]);
}
void fail_invalidOverrideNamed() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({a}) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({a}) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_NAMED]);
verify([source]);
}
void fail_invalidOverridePositional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m([a, b]) {}", "}", "class B extends A {", " m([a]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m([a, b]) {}", "}", "class B extends A {", " m([a]) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_POSITIONAL]);
verify([source]);
}
void fail_invalidOverrideRequired() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_REQUIRED]);
verify([source]);
}
void fail_invalidReferenceToThis_staticMethod() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static m() { return this; }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static m() { return this; }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
void fail_invalidReferenceToThis_topLevelFunction() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() { return this; }"]));
+ Source source = addSource(EngineTestCase.createSource(["f() { return this; }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
void fail_invalidReferenceToThis_variableInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int x = this;"]));
+ Source source = addSource(EngineTestCase.createSource(["int x = this;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
verify([source]);
}
- void fail_invalidTypeArgumentInConstList() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<E> {", " m() {", " return const <E>[]", " }", "}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
- verify([source]);
- }
- void fail_invalidTypeArgumentInConstMap() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<E> {", " m() {", " return const <String, E>{}", " }", "}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
- verify([source]);
- }
void fail_memberWithClassName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int A = 0;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int A = 0;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
verify([source]);
}
void fail_mixinDeclaresConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() {}", "}", "class B extends Object mixin A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() {}", "}", "class B extends Object mixin A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
verify([source]);
}
void fail_mixinInheritsFromNotObject() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class C extends Object mixin B {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class C extends Object mixin B {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
verify([source]);
}
void fail_mixinOfNonClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var A;", "class B extends Object mixin A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["var A;", "class B extends Object mixin A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
void fail_mixinOfNonMixin() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_MIXIN]);
verify([source]);
}
void fail_mixinReferencesSuper() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " toString() -> super.toString();", "}", "class B extends Object mixin A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " toString() -> super.toString();", "}", "class B extends Object mixin A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
verify([source]);
}
void fail_mixinWithNonClassSuperclass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "class B extends Object mixin A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "class B extends Object mixin A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
verify([source]);
}
void fail_multipleSuperInitializers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super(), super() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super(), super() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
verify([source]);
}
void fail_nonConstantDefaultValue_named() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f({x : 2 + 3}) {}"]));
+ Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
void fail_nonConstantDefaultValue_positional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f([x = 2 + 3]) {}"]));
+ Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
verify([source]);
}
void fail_nonConstMapAsExpressionStatement() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1};", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1};", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
verify([source]);
}
void fail_nonConstMapKey() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a) {", " return const {a : 0};", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(a) {", " return const {a : 0};", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
verify([source]);
}
void fail_nonConstValueInInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static C;", " int a;", " A() : a = C {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static C;", " int a;", " A() : a = C {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
verify([source]);
}
void fail_objectCannotExtendAnotherClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]);
verify([source]);
}
- void fail_optionalParameterInOperator() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " operator +([p]) {}", "}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
- verify([source]);
- }
void fail_overrideMissingNamedParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m(a, {b}) {}", "}", "class B extends A {", " m(a) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m(a, {b}) {}", "}", "class B extends A {", " m(a) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.OVERRIDE_MISSING_NAMED_PARAMETERS]);
verify([source]);
}
void fail_overrideMissingRequiredParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.OVERRIDE_MISSING_REQUIRED_PARAMETERS]);
verify([source]);
}
void fail_prefixCollidesWithTopLevelMembers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'dart:uri' as uri;", "var uri = null;"]));
+ Source source = addSource(EngineTestCase.createSource(["import 'dart:uri' as uri;", "var uri = null;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
verify([source]);
}
- void fail_privateOptionalParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f({_p : 0}) {}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
- verify([source]);
- }
void fail_recursiveCompileTimeConstant() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["const x = y + 1;", "const y = x + 1;"]));
+ Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", "const y = x + 1;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
verify([source]);
}
void fail_recursiveFactoryRedirect() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
verify([source]);
}
void fail_recursiveFunctionTypeAlias_direct() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef F(F f);"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef F(F f);"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]);
verify([source]);
}
void fail_recursiveFunctionTypeAlias_indirect() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef F(G g);", "typedef G(F f);"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef F(G g);", "typedef G(F f);"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]);
verify([source]);
}
void fail_recursiveInterfaceInheritance_direct() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
verify([source]);
}
void fail_recursiveInterfaceInheritance_indirect() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements B {}", "class B implements A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements B {}", "class B implements A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
verify([source]);
}
void fail_redirectToNonConstConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]);
verify([source]);
}
void fail_referenceToDeclaredVariableInInitializer_getter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " int x = x + 1;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x + 1;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER]);
verify([source]);
}
void fail_referenceToDeclaredVariableInInitializer_setter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " int x = x++;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x++;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER]);
verify([source]);
}
void fail_reservedWordAsIdentifier() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int class = 2;"]));
+ Source source = addSource(EngineTestCase.createSource(["int class = 2;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RESERVED_WORD_AS_IDENTIFIER]);
verify([source]);
}
- void fail_returnInGenerativeConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() { return 0; }", "}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
- verify([source]);
- }
void fail_staticTopLevelFunction_topLevel() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["static f() {}"]));
+ Source source = addSource(EngineTestCase.createSource(["static f() {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_FUNCTION]);
verify([source]);
}
void fail_staticTopLevelVariable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["static int x;"]));
+ Source source = addSource(EngineTestCase.createSource(["static int x;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_VARIABLE]);
verify([source]);
}
void fail_superInInvalidContext_factoryConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInInvalidContext_instanceVariableInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var a;", "}", "class B extends A {", " var b = super.a;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " var a;", "}", "class B extends A {", " var b = super.a;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInInvalidContext_staticMethod() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static m() {}", "}", "class B extends A {", " static n() { return super.m(); }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static m() {}", "}", "class B extends A {", " static n() { return super.m(); }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInInvalidContext_staticVariableInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static a = 0;", "}", "class B extends A {", " static b = super.a;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static a = 0;", "}", "class B extends A {", " static b = super.a;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInInvalidContext_topLevelFunction() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " super.f();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " super.f();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInInvalidContext_variableInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var v = super.v;"]));
+ Source source = addSource(EngineTestCase.createSource(["var v = super.v;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
verify([source]);
}
void fail_superInitializerInObject() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
verify([source]);
}
void fail_typeArgumentsForNonGenericClass_creation_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return const A<int>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) {", " return const A<int>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
verify([source]);
}
void fail_typeArgumentsForNonGenericClass_creation_new() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return new A<int>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) {", " return new A<int>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
verify([source]);
}
void fail_typeArgumentsForNonGenericClass_typeCast() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return p as A<int>;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) {", " return p as A<int>;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
verify([source]);
}
void fail_undefinedConstructorInInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
verify([source]);
}
void fail_uninitializedFinalField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int i;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int i;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.UNINITIALIZED_FINAL_FIELD]);
verify([source]);
}
void fail_wrongNumberOfParametersForOperator() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " operator []=(i) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " operator []=(i) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
verify([source]);
}
- void fail_wrongNumberOfParametersForSetter_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["set x() {}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
- verify([source]);
- }
- void fail_wrongNumberOfParametersForSetter_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["set x(a, b) {}"]));
- resolve(source, []);
- assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
- verify([source]);
- }
void fail_wrongNumberOfTypeArguments_creation_const_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return const C<A>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return const C<A>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void fail_wrongNumberOfTypeArguments_creation_const_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return const C<A, A>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return const C<A, A>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void fail_wrongNumberOfTypeArguments_creation_new_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void fail_wrongNumberOfTypeArguments_creation_new_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void fail_wrongNumberOfTypeArguments_typeTest_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void fail_wrongNumberOfTypeArguments_typeTest_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
void test_argumentDefinitionTestNonParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " var v = 0;", " return ?v;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;", " return ?v;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]);
verify([source]);
}
void test_builtInIdentifierAsType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " typedef x;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, StaticWarningCode.UNDEFINED_CLASS]);
verify([source]);
}
void test_builtInIdentifierAsTypedefName_classTypeAlias() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B {}", "typedef as = A with B;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "typedef as = A with B;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
verify([source]);
}
void test_builtInIdentifierAsTypedefName_functionTypeAlias() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef bool as();"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef bool as();"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
verify([source]);
}
void test_builtInIdentifierAsTypeName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class as {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class as {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]);
verify([source]);
}
void test_builtInIdentifierAsTypeVariableName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A<as> {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A<as> {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME]);
verify([source]);
}
void test_caseExpressionTypeImplementsEquals() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", " bool operator ==(IntWrapper x) {", " return value == x.value;", " }", "}", "", "f(IntWrapper a) {", " switch(a) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", " bool operator ==(IntWrapper x) {", " return value == x.value;", " }", "}", "", "f(IntWrapper a) {", " switch(a) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
verify([source]);
}
void test_conflictingConstructorNameAndMember_field() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A.x() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A.x() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]);
verify([source]);
}
void test_conflictingConstructorNameAndMember_method() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A.x() {}", " void x() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x() {}", " void x() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]);
verify([source]);
}
void test_constConstructorWithNonFinalField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " const A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " const A() {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
verify([source]);
}
void test_constEvalThrowsException() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {", " const C() { throw null; }", "}", "f() { return const C(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class C {", " const C() { throw null; }", "}", "f() { return const C(); }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
verify([source]);
}
void test_constFormalParameter_fieldFormalParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var x;", " A(const this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " var x;", " A(const this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
verify([source]);
}
void test_constFormalParameter_simpleFormalParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(const x) {}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(const x) {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
verify([source]);
}
void test_constInitializedWithNonConstValue() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(p) {", " const C = p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
verify([source]);
}
void test_constWithInvalidTypeParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A() {}", "}", "f() { return const A<A>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const A() {}", "}", "f() { return const A<A>(); }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
void test_constWithNonConst() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]);
verify([source]);
}
void test_defaultValueInFunctionTypeAlias() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef F([x = 0]);"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
verify([source]);
}
void test_duplicateMemberError() {
- Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
- Source sourceA = addSource("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
- Source sourceB = addSource("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
+ Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
+ Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
+ Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
resolve(librarySource, [sourceA, sourceB]);
assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
verify([librarySource, sourceA, sourceB]);
}
void test_exportOfNonLibrary() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
- addSource("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
verify([source]);
}
void test_extendsNonClass_class() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "class B extends A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "class B extends A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_extends_bool() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends bool {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_extends_double() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends double {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends double {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_extends_int() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends int {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends int {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_extends_num() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends num {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends num {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_extends_String() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends String {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends String {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_implements_bool() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements bool {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements bool {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_implements_double() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements double {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements double {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_implements_int() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements int {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements int {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_implements_num() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements num {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements num {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void test_extendsOrImplementsDisallowedClass_implements_String() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements String {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements String {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
verify([source]);
}
void test_fieldInitializedByMultipleInitializers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
}
void test_fieldInitializedByMultipleInitializers_multipleInits() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1, x = 2 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1, x = 2 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
}
void test_fieldInitializedByMultipleInitializers_multipleNames() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " int y;", " A() : x = 0, x = 1, y = 0, y = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " int y;", " A() : x = 0, x = 1, y = 0, y = 1 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
}
void test_fieldInitializedInInitializerAndDeclaration_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const int x = 0;", " A() : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " A() : x = 1 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
verify([source]);
}
void test_fieldInitializedInInitializerAndDeclaration_final() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
verify([source]);
}
void test_fieldInitializedInParameterAndInitializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) : x = 1 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A(this.x) : x = 1 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
verify([source]);
}
void test_fieldInitializerOutsideConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " m(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " m(this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
verify([source]);
}
void test_fieldInitializerOutsideConstructor_defaultParameter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " m([this.x]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " m([this.x]) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
verify([source]);
@@ -2519,19 +2662,19 @@
* the broader code
*/
void test_finalInitializedInDeclarationAndConstructor_initializers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
verify([source]);
}
void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR]);
verify([source]);
}
void test_finalInitializedMultipleTimes_initializers() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
verify([source]);
@@ -2545,262 +2688,310 @@
* FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
*/
void test_finalInitializedMultipleTimes_initializingFormal_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
verify([source]);
}
void test_finalInitializedMultipleTimes_initializingFormals() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x;", " A(this.x, this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x, this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]);
verify([source]);
}
void test_finalNotInitialized_instanceField_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const F;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " const F;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_instanceField_const_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static const F;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static const F;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_instanceField_final() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final F;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " final F;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_instanceField_final_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static final F;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static final F;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_library_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["const F;"]));
+ Source source = addSource(EngineTestCase.createSource(["const F;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_library_final() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["final F;"]));
+ Source source = addSource(EngineTestCase.createSource(["final F;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_local_const() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " const int x;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " const int x;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_finalNotInitialized_local_final() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " final int x;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " final int x;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
verify([source]);
}
void test_implementsDynamic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements dynamic {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements dynamic {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
verify([source]);
}
void test_implementsNonClass_class() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "class B implements A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "class B implements A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
verify([source]);
}
void test_implementsNonClass_typedef() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "int B;", "typedef C = A implements B;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;", "typedef C = A implements B;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
verify([source]);
}
void test_implementsRepeated() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B implements A, A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "class B implements A, A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
verify([source]);
}
void test_implementsRepeated_3times() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {} class C{}", "class B implements A, A, A, A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {} class C{}", "class B implements A, A, A, A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
verify([source]);
}
void test_implementsSelf() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A implements A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPLEMENTS_SELF]);
verify([source]);
}
void test_importOfNonLibrary() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
- addSource("/part.dart", EngineTestCase.createSource(["part of lib;"]));
+ Source source = addSource(EngineTestCase.createSource(["library lib;", "import 'part.dart';"]));
+ addSource2("/part.dart", EngineTestCase.createSource(["part of lib;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
verify([source]);
}
void test_inconsistentCaseExpressionTypes() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
verify([source]);
}
void test_inconsistentCaseExpressionTypes_repeated() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " case 'b':", " break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " case 'b':", " break;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
verify([source]);
}
void test_initializerForNonExistant_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]);
}
void test_initializerForStaticField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static x;", " A() : x = 0 {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static x;", " A() : x = 0 {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
verify([source]);
}
void test_initializingFormalForNonExistantField() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A(this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIELD]);
verify([source]);
}
void test_initializingFormalForNonExistantField_notInEnclosingClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", "int x;", "}", "class B extends A {", " B(this.x) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", "int x;", "}", "class B extends A {", " B(this.x) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIELD]);
verify([source]);
}
void test_initializingFormalForNonExistantField_optional() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A([this.x]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A([this.x]) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIELD]);
verify([source]);
}
void test_initializingFormalForNonExistantField_static() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static x;", " A([this.x]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static x;", " A([this.x]) {}", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
verify([source]);
}
void test_invalidTypeArgumentForKey() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m() {", " return const <int, int>{}", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m() {", " return const <int, int>{}", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_FOR_KEY]);
verify([source]);
}
+ void test_invalidTypeArgumentInConstList() {
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m() {", " return const <E>[]", " }", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
+ verify([source]);
+ }
+ void test_invalidTypeArgumentInConstMap() {
+ Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m() {", " return const <String, E>{}", " }", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
+ verify([source]);
+ }
void test_invalidUri_export() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "export 'unknown.dart';"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "export 'unknown.dart';"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_URI]);
}
void test_invalidUri_import() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "import 'unknown.dart';"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "import 'unknown.dart';"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_URI]);
}
void test_invalidUri_part() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library L;", "part 'unknown.dart';"]));
+ Source source = addSource(EngineTestCase.createSource(["library L;", "part 'unknown.dart';"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.INVALID_URI]);
}
void test_labelInOuterScope() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, StaticWarningCode.UNDEFINED_OPERATOR]);
}
void test_labelUndefined_break() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " x: while (true) {", " break y;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " break y;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]);
}
void test_labelUndefined_continue() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " x: while (true) {", " continue y;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " continue y;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]);
}
void test_mixinOfNonClass_class() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int A;", "class B with A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["int A;", "class B with A {}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
void test_mixinOfNonClass_typedef() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "int B;", "typedef C = A with B;"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;", "typedef C = A with B;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
verify([source]);
}
void test_nativeFunctionBodyInNonSDKCode_function() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int m(a) native 'string';"]));
+ Source source = addSource(EngineTestCase.createSource(["int m(a) native 'string';"]));
resolve(source, []);
assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
verify([source]);
}
void test_nativeFunctionBodyInNonSDKCode_method() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A{", " static int m(a) native 'string';", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A{", " static int m(a) native 'string';", "}"]));
resolve(source, []);
assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
verify([source]);
}
void test_newWithInvalidTypeParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
verify([source]);
}
void test_nonConstCaseExpression() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
verify([source]);
}
void test_nonConstListElement() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a) {", " return const [a];", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(a) {", " return const [a];", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
verify([source]);
}
void test_nonConstMapValue() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a) {", " return const {'a' : a};", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(a) {", " return const {'a' : a};", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
verify([source]);
}
+ void test_optionalParameterInOperator_named() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " operator +({p}) {}", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
+ verify([source]);
+ }
+ void test_optionalParameterInOperator_positional() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " operator +([p]) {}", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
+ verify([source]);
+ }
void test_partOfNonPart() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library l1;", "part 'l2.dart';"]));
- addSource("/l2.dart", EngineTestCase.createSource(["library l2;"]));
+ Source source = addSource(EngineTestCase.createSource(["library l1;", "part 'l2.dart';"]));
+ addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.PART_OF_NON_PART]);
verify([source]);
}
+ void test_privateOptionalParameter() {
+ Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
+ verify([source]);
+ }
void test_rethrowOutsideCatch() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " rethrow;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;", "}"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
verify([source]);
}
+ void test_returnInGenerativeConstructor() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return 0; }", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
+ verify([source]);
+ }
void test_uriWithInterpolation_constant() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'stuff_\$platform.dart';"]));
+ Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$platform.dart';"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION, StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
void test_uriWithInterpolation_nonConstant() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library lib;", "part '\${'a'}.dart';"]));
+ Source source = addSource(EngineTestCase.createSource(["library lib;", "part '\${'a'}.dart';"]));
resolve(source, []);
assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
}
+ void test_wrongNumberOfParametersForSetter_tooFew() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " set x() {}", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
+ verify([source]);
+ }
+ void test_wrongNumberOfParametersForSetter_tooMany() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " set x(a, b) {}", "}"]));
+ resolve(source, []);
+ assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
+ verify([source]);
+ }
static dartSuite() {
_ut.group('CompileTimeErrorCodeTest', () {
_ut.test('test_argumentDefinitionTestNonParameter', () {
@@ -3071,6 +3262,14 @@
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_invalidTypeArgumentForKey);
});
+ _ut.test('test_invalidTypeArgumentInConstList', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
+ });
+ _ut.test('test_invalidTypeArgumentInConstMap', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
+ });
_ut.test('test_invalidUri_export', () {
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_invalidUri_export);
@@ -3127,14 +3326,30 @@
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_nonConstMapValue);
});
+ _ut.test('test_optionalParameterInOperator_named', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_optionalParameterInOperator_named);
+ });
+ _ut.test('test_optionalParameterInOperator_positional', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_optionalParameterInOperator_positional);
+ });
_ut.test('test_partOfNonPart', () {
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_partOfNonPart);
});
+ _ut.test('test_privateOptionalParameter', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_privateOptionalParameter);
+ });
_ut.test('test_rethrowOutsideCatch', () {
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_rethrowOutsideCatch);
});
+ _ut.test('test_returnInGenerativeConstructor', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
+ });
_ut.test('test_uriWithInterpolation_constant', () {
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_uriWithInterpolation_constant);
@@ -3143,6 +3358,14 @@
final __test = new CompileTimeErrorCodeTest();
runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant);
});
+ _ut.test('test_wrongNumberOfParametersForSetter_tooFew', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_tooFew);
+ });
+ _ut.test('test_wrongNumberOfParametersForSetter_tooMany', () {
+ final __test = new CompileTimeErrorCodeTest();
+ runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_tooMany);
+ });
});
}
}
@@ -3392,7 +3615,7 @@
String label = "loop";
LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(label), false, false);
ContinueStatement statement = ASTFactory.continueStatement2(label);
- JUnitTestCase.assertSame(labelElement, resolve2(statement, labelElement));
+ JUnitTestCase.assertSame(labelElement, resolve3(statement, labelElement));
_listener.assertNoErrors();
}
void test_visitContinueStatement_withoutLabel() {
@@ -3406,6 +3629,16 @@
resolveNode(directive, []);
_listener.assertNoErrors();
}
+ void test_visitFieldFormalParameter() {
+ InterfaceType intType2 = _typeProvider.intType;
+ String fieldName = "f";
+ ClassElementImpl classA = ElementFactory.classElement2("A", []);
+ classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false, false, false, intType2)];
+ FieldFormalParameter parameter = ASTFactory.fieldFormalParameter2(fieldName);
+ parameter.identifier.element = ElementFactory.fieldFormalParameter(parameter.identifier);
+ resolveInClass(parameter, classA);
+ JUnitTestCase.assertSame(intType2, parameter.element.type);
+ }
void test_visitImportDirective_noCombinators_noPrefix() {
ImportDirective directive = ASTFactory.importDirective2(null, null, []);
directive.element = ElementFactory.importFor(ElementFactory.library(_definingLibrary.context, "lib"), null, []);
@@ -3429,7 +3662,7 @@
SimpleIdentifier array = ASTFactory.identifier3("a");
array.staticType = classA.type;
IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.identifier3("i"));
- JUnitTestCase.assertSame(getter, resolve4(expression, []));
+ JUnitTestCase.assertSame(getter, resolve5(expression, []));
_listener.assertNoErrors();
}
void test_visitIndexExpression_set() {
@@ -3441,7 +3674,7 @@
array.staticType = classA.type;
IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.identifier3("i"));
ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer(0));
- JUnitTestCase.assertSame(setter, resolve4(expression, []));
+ JUnitTestCase.assertSame(setter, resolve5(expression, []));
_listener.assertNoErrors();
}
void test_visitInstanceCreationExpression_named() {
@@ -3605,7 +3838,7 @@
void test_visitSimpleIdentifier_lexicalScope() {
SimpleIdentifier node = ASTFactory.identifier3("i");
VariableElementImpl element = ElementFactory.localVariableElement(node);
- JUnitTestCase.assertSame(element, resolve3(node, [element]));
+ JUnitTestCase.assertSame(element, resolve4(node, [element]));
_listener.assertNoErrors();
}
void test_visitSimpleIdentifier_lexicalScope_field_setter() {
@@ -3692,7 +3925,7 @@
* @param labelElement the label element to be defined in the statement's label scope
* @return the element to which the statement's label was resolved
*/
- Element resolve2(ContinueStatement statement, LabelElementImpl labelElement) {
+ Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) {
resolveStatement(statement, labelElement);
return statement.label.element;
}
@@ -3704,7 +3937,7 @@
* being resolved
* @return the element to which the expression was resolved
*/
- Element resolve3(Identifier node, List<Element> definedElements) {
+ Element resolve4(Identifier node, List<Element> definedElements) {
resolveNode(node, definedElements);
return node.element;
}
@@ -3716,7 +3949,7 @@
* being resolved
* @return the element to which the expression was resolved
*/
- Element resolve4(IndexExpression node, List<Element> definedElements) {
+ Element resolve5(IndexExpression node, List<Element> definedElements) {
resolveNode(node, definedElements);
return node.element;
}
@@ -3836,6 +4069,10 @@
final __test = new ElementResolverTest();
runJUnitTest(__test, __test.test_visitExportDirective_noCombinators);
});
+ _ut.test('test_visitFieldFormalParameter', () {
+ final __test = new ElementResolverTest();
+ runJUnitTest(__test, __test.test_visitFieldFormalParameter);
+ });
_ut.test('test_visitImportDirective_noCombinators_noPrefix', () {
final __test = new ElementResolverTest();
runJUnitTest(__test, __test.test_visitImportDirective_noCombinators_noPrefix);
@@ -4015,316 +4252,335 @@
}
class StaticWarningCodeTest extends ResolverTestCase {
void fail_argumentTypeNotAssignable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
verify([source]);
}
void fail_assignmentToFinal() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["final x = 0;", "f() { x = 1; }"]));
+ Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f() { x = 1; }"]));
resolve(source, []);
assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
verify([source]);
}
void fail_caseBlockNotTerminated() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int p) {", " switch (p) {", " case 0:", " f(p);", " case 1:", " break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(int p) {", " switch (p) {", " case 0:", " f(p);", " case 1:", " break;", " }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
verify([source]);
}
void fail_castToNonType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var A = 0;", "f(String s) { var x = s as A; }"]));
+ Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(String s) { var x = s as A; }"]));
resolve(source, []);
assertErrors([StaticWarningCode.CAST_TO_NON_TYPE]);
verify([source]);
}
void fail_commentReferenceConstructorNotVisible() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE]);
verify([source]);
}
void fail_commentReferenceIdentifierNotVisible() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE]);
verify([source]);
}
void fail_commentReferenceUndeclaredConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR]);
verify([source]);
}
void fail_commentReferenceUndeclaredIdentifier() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_IDENTIFIER]);
verify([source]);
}
void fail_commentReferenceUriNotLibrary() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.COMMENT_REFERENCE_URI_NOT_LIBRARY]);
verify([source]);
}
- void fail_concreteClassWithAbstractMember() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m();", "}"]));
- resolve(source, []);
- assertErrors([StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
- verify([source]);
- }
void fail_conflictingInstanceGetterAndSuperclassMember() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
void fail_conflictingInstanceSetterAndSuperclassMember() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER]);
verify([source]);
}
void fail_conflictingStaticGetterAndInstanceSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static get x -> 0;", " set x(int p) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static get x -> 0;", " set x(int p) {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER]);
verify([source]);
}
void fail_conflictingStaticSetterAndInstanceGetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " get x -> 0;", " static set x(int p) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " get x -> 0;", " static set x(int p) {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_GETTER]);
verify([source]);
}
- void fail_fieldInitializerWithInvalidType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(String this.x) {}", "}"]));
- resolve(source, []);
- assertErrors([StaticWarningCode.FIELD_INITIALIZER_WITH_INVALID_TYPE]);
- verify([source]);
- }
void fail_incorrectNumberOfArguments_tooFew() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2);", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]);
verify([source]);
}
void fail_incorrectNumberOfArguments_tooMany() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2, 3, 4);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2, 3, 4);", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]);
verify([source]);
}
void fail_instanceMethodNameCollidesWithSuperclassStatic() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static n", "}", "class C extends A {", " void n() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static n", "}", "class C extends A {", " void n() {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC]);
verify([source]);
}
void fail_invalidFactoryName() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.INVALID_FACTORY_NAME]);
verify([source]);
}
void fail_invalidOverrideGetterType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int get g -> 0", "}", "class B extends A {", " String get g { return 'a'; }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int get g -> 0", "}", "class B extends A {", " String get g { return 'a'; }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INVALID_OVERRIDE_GETTER_TYPE]);
verify([source]);
}
void fail_invalidOverrideReturnType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int m() { return 0; }", "}", "class B extends A {", " String m() { return 'a'; }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int m() { return 0; }", "}", "class B extends A {", " String m() { return 'a'; }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INVALID_OVERRIDE_RETURN_TYPE]);
verify([source]);
}
void fail_invalidOverrideSetterReturnType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.INVALID_OVERRIDE_SETTER_RETURN_TYPE]);
verify([source]);
}
void fail_invocationOfNonFunction() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.INVOCATION_OF_NON_FUNCTION]);
verify([source]);
}
void fail_mismatchedGetterAndSetterTypes() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int get g { return 0; }", " set g(String v) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int get g { return 0; }", " set g(String v) {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
verify([source]);
}
void fail_newWithNonType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var A = 0;", "void f() {", " A a = new A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f() {", " A a = new A();", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]);
verify([source]);
}
void fail_newWithUndefinedConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(int p) {}", "}", "A f() {", " return new A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A(int p) {}", "}", "A f() {", " return new A();", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
verify([source]);
}
void fail_nonAbstractClassInheritsAbstractMember() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class I {", " m(p) {}", "}", "class C implements I {", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class I {", " m(p) {}", "}", "class C implements I {", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER]);
verify([source]);
}
void fail_nonAbstractClassInheritsAbstractMethod() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["abstract class A {", " m(p);", "}", "class C extends A {", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m(p);", "}", "class C extends A {", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_METHOD]);
verify([source]);
}
void fail_nonType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var A = 0;", "f(var p) {", " if (p is A) {", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var p) {", " if (p is A) {", " }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_TYPE]);
verify([source]);
}
void fail_nonTypeInCatchClause() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var T = 0;", "f(var p) {", " try {", " } on T catch e {", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["var T = 0;", "f(var p) {", " try {", " } on T catch e {", " }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
verify([source]);
}
void fail_nonVoidReturnForOperator() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int operator []=() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int operator []=() {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
verify([source]);
}
void fail_nonVoidReturnForSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int set x(int v) {", " var s = x;", " x = v;", " return s;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["int set x(int v) {", " var s = x;", " x = v;", " return s;", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
verify([source]);
}
void fail_overrideNotSubtype() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int m() {}", "}", "class B extends A {", " String m() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int m() {}", "}", "class B extends A {", " String m() {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.OVERRIDE_NOT_SUBTYPE]);
verify([source]);
}
void fail_overrideWithDifferentDefault() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " m([int p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m([int p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.OVERRIDE_WITH_DIFFERENT_DEFAULT]);
verify([source]);
}
void fail_redirectToInvalidReturnType() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
verify([source]);
}
void fail_redirectToMissingConstructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
verify([source]);
}
void fail_redirectToNonClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]);
verify([source]);
}
- void fail_returnWithoutValue() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int f() { return; }"]));
- resolve(source, []);
- assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]);
- verify([source]);
- }
void fail_switchExpressionNotAssignable() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int p) {", " switch (p) {", " case 'a': break;", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(int p) {", " switch (p) {", " case 'a': break;", " }", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
verify([source]);
}
void fail_undefinedGetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource([]));
+ Source source = addSource(EngineTestCase.createSource([]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_GETTER]);
verify([source]);
}
void fail_undefinedIdentifier_function() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["int a() -> b;"]));
+ Source source = addSource(EngineTestCase.createSource(["int a() -> b;"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
verify([source]);
}
void fail_undefinedSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {}", "f(var p) {", " C.m = 0;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " C.m = 0;", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_SETTER]);
verify([source]);
}
void fail_undefinedStaticMethodOrGetter_getter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m);", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
verify([source]);
}
void fail_undefinedStaticMethodOrGetter_method() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m());", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m());", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
verify([source]);
}
+ void test_concreteClassWithAbstractMember() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " m();", "}"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
+ verify([source]);
+ }
void test_constWithAbstractClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["abstract class A {", " const A() {}", "}", "void f() {", " A a = const A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["abstract class A {", " const A() {}", "}", "void f() {", " A a = const A();", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]);
verify([source]);
}
void test_equalKeysInMap() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var m = {'a' : 0, 'b' : 1, 'a' : 2};"]));
+ Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b' : 1, 'a' : 2};"]));
resolve(source, []);
assertErrors([StaticWarningCode.EQUAL_KEYS_IN_MAP]);
verify([source]);
}
+ void test_fieldInitializerWithInvalidType() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A(String this.x) {}", "}"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.FIELD_INITIALIZER_WITH_INVALID_TYPE]);
+ verify([source]);
+ }
void test_newWithAbstractClass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["abstract class A {}", "void f() {", " A a = new A();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["abstract class A {}", "void f() {", " A a = new A();", "}"]));
resolve(source, []);
assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
verify([source]);
}
void test_partOfDifferentLibrary() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["library lib;", "part 'part.dart';"]));
- addSource("/part.dart", EngineTestCase.createSource(["part of lub;"]));
+ Source source = addSource(EngineTestCase.createSource(["library lib;", "part 'part.dart';"]));
+ addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"]));
resolve(source, []);
assertErrors([StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]);
verify([source]);
}
+ void test_returnWithoutValue() {
+ Source source = addSource(EngineTestCase.createSource(["int f() { return; }"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]);
+ verify([source]);
+ }
void test_undefinedClass_instanceCreation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() { new C(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_CLASS]);
}
void test_undefinedClass_variableDeclaration() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() { C c; }"]));
+ Source source = addSource(EngineTestCase.createSource(["f() { C c; }"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_CLASS]);
}
+ void test_undefinedClassBoolean_variableDeclaration() {
+ Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
+ }
+ void test_undefinedIdentifier_commentReference() {
+ Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c] */", "class A {", "}"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER, StaticWarningCode.UNDEFINED_IDENTIFIER]);
+ }
void test_undefinedIdentifier_initializer() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["var a = b;"]));
+ Source source = addSource(EngineTestCase.createSource(["var a = b;"]));
+ resolve(source, []);
+ assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
+ }
+ void test_undefinedIdentifier_metadata() {
+ Source source = addSource(EngineTestCase.createSource(["@undefined class A {}"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
void test_undefinedIdentifier_methodInvocation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() { C.m(); }"]));
+ Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"]));
resolve(source, []);
assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
}
static dartSuite() {
_ut.group('StaticWarningCodeTest', () {
+ _ut.test('test_concreteClassWithAbstractMember', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
+ });
_ut.test('test_constWithAbstractClass', () {
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_constWithAbstractClass);
@@ -4333,6 +4589,10 @@
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_equalKeysInMap);
});
+ _ut.test('test_fieldInitializerWithInvalidType', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_fieldInitializerWithInvalidType);
+ });
_ut.test('test_newWithAbstractClass', () {
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_newWithAbstractClass);
@@ -4341,6 +4601,14 @@
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_partOfDifferentLibrary);
});
+ _ut.test('test_returnWithoutValue', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_returnWithoutValue);
+ });
+ _ut.test('test_undefinedClassBoolean_variableDeclaration', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclaration);
+ });
_ut.test('test_undefinedClass_instanceCreation', () {
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_undefinedClass_instanceCreation);
@@ -4349,10 +4617,18 @@
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration);
});
+ _ut.test('test_undefinedIdentifier_commentReference', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_undefinedIdentifier_commentReference);
+ });
_ut.test('test_undefinedIdentifier_initializer', () {
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_undefinedIdentifier_initializer);
});
+ _ut.test('test_undefinedIdentifier_metadata', () {
+ final __test = new StaticWarningCodeTest();
+ runJUnitTest(__test, __test.test_undefinedIdentifier_metadata);
+ });
_ut.test('test_undefinedIdentifier_methodInvocation', () {
final __test = new StaticWarningCodeTest();
runJUnitTest(__test, __test.test_undefinedIdentifier_methodInvocation);
@@ -4362,13 +4638,13 @@
}
class ErrorResolverTest extends ResolverTestCase {
void test_breakLabelOnSwitchMember() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " l: case 0:", " break;", " case 1:", " break l;", " }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " l: case 0:", " break;", " case 1:", " break l;", " }", " }", "}"]));
resolve(source, []);
assertErrors([ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
verify([source]);
}
void test_continueLabelOnSwitch() {
- Source source = addSource("/a.dart", EngineTestCase.createSource(["class A {", " void m(int i) {", " l: switch (i) {", " case 0:", " continue l;", " }", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " l: switch (i) {", " case 0:", " continue l;", " }", " }", "}"]));
resolve(source, []);
assertErrors([ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
verify([source]);
@@ -4416,6 +4692,14 @@
*/
InterfaceType _intType;
/**
+ * The type representing the built-in type 'Iterable'.
+ */
+ InterfaceType _iterableType;
+ /**
+ * The type representing the built-in type 'Iterator'.
+ */
+ InterfaceType _iteratorType;
+ /**
* The type representing the built-in type 'List'.
*/
InterfaceType _listType;
@@ -4485,12 +4769,31 @@
}
return _intType;
}
+ InterfaceType get iterableType {
+ if (_iterableType == null) {
+ ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable", ["E"]);
+ _iterableType = iterableElement.type;
+ Type2 eType = iterableElement.typeVariables[0].type;
+ iterableElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("iterator", false, iteratorType.substitute5(<Type2> [eType])), ElementFactory.getterElement("last", false, eType)];
+ }
+ return _iterableType;
+ }
+ InterfaceType get iteratorType {
+ if (_iteratorType == null) {
+ ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator", ["E"]);
+ _iteratorType = iteratorElement.type;
+ Type2 eType = iteratorElement.typeVariables[0].type;
+ iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("current", false, eType)];
+ }
+ return _iteratorType;
+ }
InterfaceType get listType {
if (_listType == null) {
ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]);
_listType = listElement.type;
Type2 eType = listElement.typeVariables[0].type;
- listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("last", false, eType)];
+ InterfaceType supertype = iterableType.substitute5(<Type2> [eType]);
+ listElement.supertype = supertype;
listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [_intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [_intType, eType])];
}
return _listType;
@@ -4528,7 +4831,8 @@
if (_stringType == null) {
_stringType = ElementFactory.classElement2("String", []).type;
ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
- stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("length", false, intType)];
+ stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getterElement("isEmpty", false, boolType), ElementFactory.getterElement("length", false, intType)];
+ stringElement.methods = <MethodElement> [ElementFactory.methodElement("toLowerCase", _stringType, []), ElementFactory.methodElement("toUpperCase", _stringType, [])];
}
return _stringType;
}
@@ -4574,18 +4878,19 @@
* @return the analysis context that was created
*/
static AnalysisContextImpl contextWithCore() {
- AnalysisContextImpl context = new AnalysisContextImpl();
- SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), new FileUriResolver()]);
- context.sourceFactory = sourceFactory;
+ AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl;
+ SourceFactory sourceFactory2 = sdkContext.sourceFactory;
TestTypeProvider provider = new TestTypeProvider();
CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.dart");
- Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
+ Source coreSource = sourceFactory2.forUri(DartSdk.DART_CORE);
+ sdkContext.setContents(coreSource, "");
coreUnit.source = coreSource;
coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleType.element, provider.functionType.element, provider.intType.element, provider.listType.element, provider.mapType.element, provider.numType.element, provider.objectType.element, provider.stackTraceType.element, provider.stringType.element, provider.typeType.element];
- LibraryElementImpl coreLibrary = new LibraryElementImpl(context, ASTFactory.libraryIdentifier2(["dart", "core"]));
+ LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFactory.libraryIdentifier2(["dart", "core"]));
coreLibrary.definingCompilationUnit = coreUnit;
CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_dartium.dart");
- Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
+ Source htmlSource = sourceFactory2.forUri(DartSdk.DART_HTML);
+ sdkContext.setContents(htmlSource, "");
htmlUnit.source = htmlSource;
ClassElementImpl elementElement = ElementFactory.classElement2("Element", []);
InterfaceType elementType = elementElement.type;
@@ -4597,14 +4902,15 @@
TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElement2("document");
document.type = htmlDocumentElement.type;
htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
- LibraryElementImpl htmlLibrary = new LibraryElementImpl(context, ASTFactory.libraryIdentifier2(["dart", "dom", "html"]));
+ LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFactory.libraryIdentifier2(["dart", "dom", "html"]));
htmlLibrary.definingCompilationUnit = htmlUnit;
Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
elementMap[coreSource] = coreLibrary;
elementMap[htmlSource] = htmlLibrary;
- context.setContents(coreSource, "");
- context.setContents(htmlSource, "");
- context.recordLibraryElements(elementMap);
+ sdkContext.recordLibraryElements(elementMap);
+ AnalysisContextImpl context = new DelegatingAnalysisContextImpl();
+ sourceFactory2 = new SourceFactory.con2([new DartUriResolver(sdkContext.sourceFactory.dartSdk), new FileUriResolver()]);
+ context.sourceFactory = sourceFactory2;
return context;
}
/**
@@ -4726,10 +5032,10 @@
* structures that are expected to have been resolved have an element associated with them.
*/
ResolutionVerifier() {
- _jtd_constructor_349_impl();
+ _jtd_constructor_351_impl();
}
- _jtd_constructor_349_impl() {
- _jtd_constructor_350_impl(null);
+ _jtd_constructor_351_impl() {
+ _jtd_constructor_352_impl(null);
}
/**
* Initialize a newly created verifier to verify that all of the identifiers in the visited AST
@@ -4740,9 +5046,9 @@
* therefore not cause the test to fail
*/
ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
- _jtd_constructor_350_impl(knownExceptions2);
+ _jtd_constructor_352_impl(knownExceptions2);
}
- _jtd_constructor_350_impl(Set<ASTNode> knownExceptions2) {
+ _jtd_constructor_352_impl(Set<ASTNode> knownExceptions2) {
this._knownExceptions = knownExceptions2;
}
/**
@@ -6165,86 +6471,110 @@
}
class SimpleResolverTest extends ResolverTestCase {
void fail_staticInvocation() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g(1,0);", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " static int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g(1,0);", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_class_definesCall() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int call(int x) { return x; }", "}", "int f(A a) {", " return a(0);", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int call(int x) { return x; }", "}", "int f(A a) {", " return a(0);", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_class_extends_implements() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B implements C {}", "class B {}", "class C {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends B implements C {}", "class B {}", "class C {}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_commentReference_class() {
+ Source source = addSource(EngineTestCase.createSource(["f() {}", "/** [A] [new A] [A.n] [new A.n] [m] [f] */", "class A {", " A() {}", " A.n() {}", " m() {}", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_commentReference_parameter() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() {}", " A.n() {}", " /** [e] [f] */", " m(e, f()) {}", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_commentReference_singleLine() {
+ Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A {}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_empty() {
- Source source = addSource("/test.dart", "");
+ Source source = addSource("");
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_extractedMethodAsConstant() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["abstract class Comparable<T> {", " int compareTo(T other);", " static int compare(Comparable a, Comparable b) => a.compareTo(b);", "}", "class A {", " void sort([compare = Comparable.compare]) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["abstract class Comparable<T> {", " int compareTo(T other);", " static int compare(Comparable a, Comparable b) => a.compareTo(b);", "}", "class A {", " void sort([compare = Comparable.compare]) {}", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
+ void test_fieldFormalParameter() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_forEachLoops_nonConflicting() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) {}", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_forLoops_nonConflicting() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " for (int i = 0; i < 3; i++) {", " }", " for (int i = 0; i < 3; i++) {", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " for (int i = 0; i < 3; i++) {", " }", " for (int i = 0; i < 3; i++) {", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_functionTypeAlias() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["typedef bool P(e);", "class A {", " P p;", " m(e) {", " if (p(e)) {}", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["typedef bool P(e);", "class A {", " P p;", " m(e) {", " if (p(e)) {}", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_getterAndSetterWithDifferentTypes() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int get f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toString();", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " int get f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toString();", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_importWithPrefix() {
- addSource("/two.dart", EngineTestCase.createSource(["library two;", "f(int x) {", " return x * x;", "}"]));
- Source source = addSource("/one.dart", EngineTestCase.createSource(["library one;", "import 'two.dart' as _two;", "main() {", " _two.f(0);", "}"]));
+ addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int x) {", " return x * x;", "}"]));
+ Source source = addSource2("/one.dart", EngineTestCase.createSource(["library one;", "import 'two.dart' as _two;", "main() {", " _two.f(0);", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_indexExpression_typeParameters() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " List<int> a;", " a[0];", " List<List<int>> b;", " b[0][0];", " List<List<List<int>>> c;", " c[0][0][0];", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " List<int> a;", " a[0];", " List<List<int>> b;", " b[0][0];", " List<List<List<int>>> c;", " c[0][0][0];", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_indexExpression_typeParameters_invalidAssignmentWarning() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {", " List<List<int>> b;", " b[0][0] = 'hi';", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f() {", " List<List<int>> b;", " b[0][0] = 'hi';", "}"]));
resolve(source, []);
assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
verify([source]);
}
void test_invoke_dynamicThroughGetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last;", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_isValidMixin_badSuperclass() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B {}", "class B {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A extends B {}", "class B {}"]));
LibraryElement library = resolve(source, []);
JUnitTestCase.assertNotNull(library);
CompilationUnitElement unit = library.definingCompilationUnit;
@@ -6256,7 +6586,7 @@
verify([source]);
}
void test_isValidMixin_constructor() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() {}", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " A() {}", "}"]));
LibraryElement library = resolve(source, []);
JUnitTestCase.assertNotNull(library);
CompilationUnitElement unit = library.definingCompilationUnit;
@@ -6268,7 +6598,7 @@
verify([source]);
}
void test_isValidMixin_super() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " toString() {", " return super.toString();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " toString() {", " return super.toString();", " }", "}"]));
LibraryElement library = resolve(source, []);
JUnitTestCase.assertNotNull(library);
CompilationUnitElement unit = library.definingCompilationUnit;
@@ -6280,7 +6610,7 @@
verify([source]);
}
void test_isValidMixin_valid() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {}"]));
LibraryElement library = resolve(source, []);
JUnitTestCase.assertNotNull(library);
CompilationUnitElement unit = library.definingCompilationUnit;
@@ -6291,20 +6621,26 @@
assertNoErrors();
verify([source]);
}
+ void test_method_fromSuperclassMixin() {
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", "}", "class B with A {", "}", "class C extends B {", "}", "f(C c) {", " c.m1()", "}"]));
+ resolve(source, []);
+ assertNoErrors();
+ verify([source]);
+ }
void test_methodCascades() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..m2();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..m2();", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_methodCascades_withSetter() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " String name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["class A {", " String name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
}
void test_resolveAgainstNull() {
- Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " return null == p;", "}"]));
+ Source source = addSource(EngineTestCase.createSource(["f(var p) {", " return null == p;", "}"]));
resolve(source, []);
assertNoErrors();
verify([source]);
@@ -6319,6 +6655,18 @@
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_class_extends_implements);
});
+ _ut.test('test_commentReference_class', () {
+ final __test = new SimpleResolverTest();
+ runJUnitTest(__test, __test.test_commentReference_class);
+ });
+ _ut.test('test_commentReference_parameter', () {
+ final __test = new SimpleResolverTest();
+ runJUnitTest(__test, __test.test_commentReference_parameter);
+ });
+ _ut.test('test_commentReference_singleLine', () {
+ final __test = new SimpleResolverTest();
+ runJUnitTest(__test, __test.test_commentReference_singleLine);
+ });
_ut.test('test_empty', () {
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_empty);
@@ -6327,6 +6675,10 @@
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_extractedMethodAsConstant);
});
+ _ut.test('test_fieldFormalParameter', () {
+ final __test = new SimpleResolverTest();
+ runJUnitTest(__test, __test.test_fieldFormalParameter);
+ });
_ut.test('test_forEachLoops_nonConflicting', () {
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_forEachLoops_nonConflicting);
@@ -6383,6 +6735,10 @@
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_methodCascades_withSetter);
});
+ _ut.test('test_method_fromSuperclassMixin', () {
+ final __test = new SimpleResolverTest();
+ runJUnitTest(__test, __test.test_method_fromSuperclassMixin);
+ });
_ut.test('test_resolveAgainstNull', () {
final __test = new SimpleResolverTest();
runJUnitTest(__test, __test.test_resolveAgainstNull);
diff --git a/pkg/analyzer_experimental/test/generated/test_support.dart b/pkg/analyzer_experimental/test/generated/test_support.dart
index 6e85ac9..c666db1 100644
--- a/pkg/analyzer_experimental/test/generated/test_support.dart
+++ b/pkg/analyzer_experimental/test/generated/test_support.dart
@@ -45,17 +45,17 @@
* Initialize a newly created error listener to collect errors.
*/
GatheringErrorListener() : super() {
- _jtd_constructor_347_impl();
+ _jtd_constructor_349_impl();
}
- _jtd_constructor_347_impl() {
+ _jtd_constructor_349_impl() {
}
/**
* Initialize a newly created error listener to collect errors.
*/
GatheringErrorListener.con1(String rawSource2) {
- _jtd_constructor_348_impl(rawSource2);
+ _jtd_constructor_350_impl(rawSource2);
}
- _jtd_constructor_348_impl(String rawSource2) {
+ _jtd_constructor_350_impl(String rawSource2) {
this._rawSource = rawSource2;
this._markedSource = rawSource2;
}
@@ -259,14 +259,14 @@
* @param secondError the second error being compared
* @return {@code true} if the two errors are equivalent
*/
- bool equals(AnalysisError firstError, AnalysisError secondError) => identical(firstError.errorCode, secondError.errorCode) && firstError.offset == secondError.offset && firstError.length == secondError.length && equals3(firstError.source, secondError.source);
+ bool equals3(AnalysisError firstError, AnalysisError secondError) => identical(firstError.errorCode, secondError.errorCode) && firstError.offset == secondError.offset && firstError.length == secondError.length && equals4(firstError.source, secondError.source);
/**
* Return {@code true} if the two sources are equivalent.
* @param firstSource the first source being compared
* @param secondSource the second source being compared
* @return {@code true} if the two sources are equivalent
*/
- bool equals3(Source firstSource, Source secondSource) {
+ bool equals4(Source firstSource, Source secondSource) {
if (firstSource == null) {
return secondSource == null;
} else if (secondSource == null) {
@@ -325,7 +325,7 @@
*/
bool foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) {
for (AnalysisError error in errors) {
- if (equals(error, targetError)) {
+ if (equals3(error, targetError)) {
errors.remove(error);
return true;
}
@@ -672,7 +672,7 @@
}
/**
- * Wrapper around [Function] which should be called with [target] and [arguments].
+ * Wrapper around [Function] which should be called with "target" and "arguments".
*/
class MethodTrampoline {
int parameterCount;
diff --git a/pkg/intl/lib/date_format.dart b/pkg/intl/lib/date_format.dart
index bfc9244..d12b6fa 100644
--- a/pkg/intl/lib/date_format.dart
+++ b/pkg/intl/lib/date_format.dart
@@ -105,7 +105,7 @@
* new DateFormat("yMd") -> 07/10/1996
* new DateFormat.yMMMMd("en_US") -> July 10, 1996
* new DateFormat("Hm", "en_US") -> 12:08 PM
- * new DateFormat.yMd().Hm() -> 07/10/1996 12:08 PM
+ * new DateFormat.yMd().add_Hm() -> 07/10/1996 12:08 PM
*
* Explicit Pattern Syntax: Formats can also be specified with a pattern string.
* The skeleton forms will resolve to explicit patterns of this form, but will
diff --git a/pkg/intl/lib/number_format.dart b/pkg/intl/lib/number_format.dart
index 3f642ca..c8816d8 100644
--- a/pkg/intl/lib/number_format.dart
+++ b/pkg/intl/lib/number_format.dart
@@ -8,18 +8,18 @@
* format is specified as a pattern using a subset of the ICU formatting
* patterns.
*
- * 0 - A single digit
- * # - A single digit, omitted if the value is zero
- * . - Decimal separator
- * - - Minus sign
- * , - Grouping separator
- * E - Separates mantissa and expontent
- * + - Before an exponent, indicates it should be prefixed with a plus sign.
- * % - In prefix or suffix, multiply by 100 and show as percentage
- * \u2030 - In prefix or suffix, multiply by 1000 and show as per mille
- * \u00A4 - Currency sign, replaced by currency name
- * ' - Used to quote special characters
- * ; - Used to separate the positive and negative patterns if both are present
+ * - `0` A single digit
+ * - `#` A single digit, omitted if the value is zero
+ * - `.` Decimal separator
+ * - `-` Minus sign
+ * - `,` Grouping separator
+ * - `E` Separates mantissa and expontent
+ * - `+` - Before an exponent, indicates it should be prefixed with a plus sign.
+ * - `%` - In prefix or suffix, multiply by 100 and show as percentage
+ * - `‰ (\u2030)` In prefix or suffix, multiply by 1000 and show as per mille
+ * - `¤ (\u00A4)` Currency sign, replaced by currency name
+ * - `'` Used to quote special characters
+ * - `;` Used to separate the positive and negative patterns if both are present
*
* For example,
* var f = new NumberFormat("###.0#", "en_US");
@@ -32,7 +32,7 @@
* There are also standard patterns available via the special constructors. e.g.
* var symbols = new NumberFormat.percentFormat("ar");
* There are four such constructors: decimalFormat, percentFormat,
- * scientificFormat and currencyForamt. However, at the moment,
+ * scientificFormat and currencyFormat. However, at the moment,
* scientificFormat prints only as equivalent to "#E0" and does not take
* into account significant digits. currencyFormat will always use the name
* of the currency rather than the symbol.
@@ -55,11 +55,11 @@
bool _useSignForPositiveExponent = false;
bool _useExponentialNotation = false;
- int _maximumIntegerDigits = 40;
- int _minimumIntegerDigits = 1;
- int _maximumFractionDigits = 3;
- int _minimumFractionDigits = 0;
- int _minimumExponentDigits = 0;
+ int maximumIntegerDigits = 40;
+ int minimumIntegerDigits = 1;
+ int maximumFractionDigits = 3;
+ int minimumFractionDigits = 0;
+ int minimumExponentDigits = 0;
int _multiplier = 1;
@@ -68,41 +68,6 @@
* is helpful in debugging.
*/
String _pattern;
- /**
- * Set the maximum digits printed to the left of the decimal point.
- * Normally this is computed from the pattern, but it's exposed here for
- * testing purposes and for rare cases where you want to force it explicitly.
- */
- void setMaximumIntegerDigits(int max) {
- _maximumIntegerDigits = max;
- }
-
- /**
- * Set the minimum number of digits printed to the left of the decimal point.
- * Normally this is computed from the pattern, but it's exposed here for
- * testing purposes and for rare cases where you want to force it explicitly.
- */
- void setMinimumIntegerDigits(int min) {
- _minimumIntegerDigits = min;
- }
-
- /**
- * Set the maximum number of digits printed to the right of the decimal point.
- * Normally this is computed from the pattern, but it's exposed here for
- * testing purposes and for rare cases where you want to force it explicitly.
- */
- void setMaximumFractionDigits(int max) {
- _maximumFractionDigits = max;
- }
-
- /**
- * Set the minimum digits printed to the left of the decimal point.
- * Normally this is computed from the pattern, but it's exposed here for
- * testing purposes and for rare cases where you want to force it explicitly.
- */
- void setMinimumFractionDigits(int max) {
- _minimumFractionDigits = max;
- }
/** The locale in which we print numbers. */
final String _locale;
@@ -216,27 +181,27 @@
var exponent = (log(number) / log(10)).floor();
var mantissa = number / pow(10.0, exponent);
- var minIntDigits = _minimumIntegerDigits;
- if (_maximumIntegerDigits > 1 &&
- _maximumIntegerDigits > _minimumIntegerDigits) {
+ var minIntDigits = minimumIntegerDigits;
+ if (maximumIntegerDigits > 1 &&
+ maximumIntegerDigits > minimumIntegerDigits) {
// A repeating range is defined; adjust to it as follows.
// If repeat == 3, we have 6,5,4=>3; 3,2,1=>0; 0,-1,-2=>-3;
// -3,-4,-5=>-6, etc. This takes into account that the
// exponent we have here is off by one from what we expect;
// it is for the format 0.MMMMMx10^n.
- while ((exponent % _maximumIntegerDigits) != 0) {
+ while ((exponent % maximumIntegerDigits) != 0) {
mantissa *= 10;
exponent--;
}
minIntDigits = 1;
} else {
// No repeating range is defined, use minimum integer digits.
- if (_minimumIntegerDigits < 1) {
+ if (minimumIntegerDigits < 1) {
exponent++;
mantissa /= 10;
} else {
- exponent -= _minimumIntegerDigits - 1;
- mantissa *= pow(10, _minimumIntegerDigits - 1);
+ exponent -= minimumIntegerDigits - 1;
+ mantissa *= pow(10, minimumIntegerDigits - 1);
}
}
_formatFixed(mantissa);
@@ -254,7 +219,7 @@
} else if (_useSignForPositiveExponent) {
_add(symbols.PLUS_SIGN);
}
- _pad(_minimumExponentDigits, exponent.toString());
+ _pad(minimumExponentDigits, exponent.toString());
}
/** Used to test if we have exceeded Javascript integer limits. */
@@ -265,7 +230,7 @@
*/
void _formatFixed(num number) {
// Very fussy math to get integer and fractional parts.
- var power = pow(10, _maximumFractionDigits);
+ var power = pow(10, maximumFractionDigits);
var shiftedNumber = (number * power);
// We must not roundToDouble() an int or it will lose precision. We must not
// round() a large double or it will take its loss of precision and
@@ -283,7 +248,7 @@
intValue = shiftedNumber.round() ~/ power;
fracValue = (shiftedNumber - intValue * power).floor();
}
- var fractionPresent = _minimumFractionDigits > 0 || fracValue > 0;
+ var fractionPresent = minimumFractionDigits > 0 || fracValue > 0;
// If the int part is larger than 2^52 and we're on Javascript (so it's
// really a float) it will lose precision, so pad out the rest of it
@@ -301,7 +266,7 @@
var digitLength = integerDigits.length;
if (_hasPrintableIntegerPart(intValue)) {
- _pad(_minimumIntegerDigits - digitLength);
+ _pad(minimumIntegerDigits - digitLength);
for (var i = 0; i < digitLength; i++) {
_addDigit(integerDigits[i]);
_group(digitLength, i);
@@ -322,7 +287,7 @@
var fractionCodes = fractionPart.codeUnits;
var fractionLength = fractionPart.length;
while(fractionCodes[fractionLength - 1] == _zero &&
- fractionLength > _minimumFractionDigits + 1) {
+ fractionLength > minimumFractionDigits + 1) {
fractionLength--;
}
for (var i = 1; i < fractionLength; i++) {
@@ -343,7 +308,7 @@
* a minimum number of printable digits greater than 1.
*/
bool _hasPrintableIntegerPart(int intValue) {
- return intValue > 0 || _minimumIntegerDigits > 0;
+ return intValue > 0 || minimumIntegerDigits > 0;
}
/**
@@ -607,13 +572,13 @@
}
var totalDigits = digitLeftCount + zeroDigitCount + digitRightCount;
- format._maximumFractionDigits =
+ format.maximumFractionDigits =
decimalPos >= 0 ? totalDigits - decimalPos : 0;
if (decimalPos >= 0) {
- format._minimumFractionDigits =
+ format.minimumFractionDigits =
digitLeftCount + zeroDigitCount - decimalPos;
- if (format._minimumFractionDigits < 0) {
- format._minimumFractionDigits = 0;
+ if (format.minimumFractionDigits < 0) {
+ format.minimumFractionDigits = 0;
}
}
@@ -621,15 +586,15 @@
// if there is no decimal. Note that if decimalPos<0, then digitTotalCount
// == digitLeftCount + zeroDigitCount.
var effectiveDecimalPos = decimalPos >= 0 ? decimalPos : totalDigits;
- format._minimumIntegerDigits = effectiveDecimalPos - digitLeftCount;
+ format.minimumIntegerDigits = effectiveDecimalPos - digitLeftCount;
if (format._useExponentialNotation) {
- format._maximumIntegerDigits =
- digitLeftCount + format._minimumIntegerDigits;
+ format.maximumIntegerDigits =
+ digitLeftCount + format.minimumIntegerDigits;
// In exponential display, we need to at least show something.
- if (format._maximumFractionDigits == 0 &&
- format._minimumIntegerDigits == 0) {
- format._minimumIntegerDigits = 1;
+ if (format.maximumFractionDigits == 0 &&
+ format.minimumIntegerDigits == 0) {
+ format.minimumIntegerDigits = 1;
}
}
@@ -685,7 +650,7 @@
'Multiple exponential symbols in pattern "$pattern"');
}
format._useExponentialNotation = true;
- format._minimumExponentDigits = 0;
+ format.minimumExponentDigits = 0;
// exponent pattern can have a optional '+'.
pattern.moveNext();
@@ -701,11 +666,11 @@
while (pattern.current == _PATTERN_ZERO_DIGIT) {
trunk.write(pattern.current);
pattern.moveNext();
- format._minimumExponentDigits++;
+ format.minimumExponentDigits++;
}
if ((digitLeftCount + zeroDigitCount) < 1 ||
- format._minimumExponentDigits < 1) {
+ format.minimumExponentDigits < 1) {
throw new FormatException(
'Malformed exponential pattern "$pattern"');
}
diff --git a/pkg/intl/test/number_closure_test.dart b/pkg/intl/test/number_closure_test.dart
index 8574e08..5037b0e 100644
--- a/pkg/intl/test/number_closure_test.dart
+++ b/pkg/intl/test/number_closure_test.dart
@@ -90,20 +90,20 @@
void testCustomPercentage() {
var fmt = new NumberFormat.percentPattern();
- fmt.setMaximumFractionDigits(1);
- fmt.setMinimumFractionDigits(1);
+ fmt.maximumFractionDigits = 1;
+ fmt.minimumFractionDigits = 1;
var str = fmt.format(0.1291);
expect('12.9%', str);
- fmt.setMaximumFractionDigits(2);
- fmt.setMinimumFractionDigits(1);
+ fmt.maximumFractionDigits = 2;
+ fmt.minimumFractionDigits = 1;
str = fmt.format(0.129);
expect('12.9%', str);
- fmt.setMaximumFractionDigits(2);
- fmt.setMinimumFractionDigits(1);
+ fmt.maximumFractionDigits = 2;
+ fmt.minimumFractionDigits = 1;
str = fmt.format(0.12);
expect('12.0%', str);
- fmt.setMaximumFractionDigits(2);
- fmt.setMinimumFractionDigits(1);
+ fmt.maximumFractionDigits = 2;
+ fmt.minimumFractionDigits = 1;
str = fmt.format(0.12911);
expect('12.91%', str);
}
diff --git a/pkg/pathos/lib/path.dart b/pkg/pathos/lib/path.dart
index 8d83077..80ffe72 100644
--- a/pkg/pathos/lib/path.dart
+++ b/pkg/pathos/lib/path.dart
@@ -40,7 +40,7 @@
}
/// Gets the path to the current working directory.
-String get current => new io.Directory.current().path;
+String get current => io.Directory.current.path;
/// Gets the path separator for the current platform. On Mac and Linux, this
/// is `/`. On Windows, it's `\`.
diff --git a/pkg/pathos/test/pathos_test.dart b/pkg/pathos/test/pathos_test.dart
index c820a47..2d56ee2 100644
--- a/pkg/pathos/test/pathos_test.dart
+++ b/pkg/pathos/test/pathos_test.dart
@@ -40,7 +40,7 @@
test('uses the current working directory if root is omitted', () {
var builder = new path.Builder();
- expect(builder.root, new io.Directory.current().path);
+ expect(builder.root, io.Directory.current.path);
});
test('uses the host OS if style is omitted', () {
@@ -54,6 +54,6 @@
});
test('current', () {
- expect(path.current, new io.Directory.current().path);
+ expect(path.current, io.Directory.current.path);
});
}
diff --git a/pkg/pkg.status b/pkg/pkg.status
index af3a270..53e34af 100644
--- a/pkg/pkg.status
+++ b/pkg/pkg.status
@@ -114,10 +114,6 @@
[ $compiler == dart2js ]
unittest/test/instance_test: Skip
-
-[ $compiler == dart2js && $runtime == drt ]
-intl/test/date_time_format_uninitialized_test: Pass, Fail # http://dartbug.com/9000
-
[ $compiler == dart2js && $minified ]
# The unittest package relies on getting the original (non-minified) method
# names in Invocation. You can't get that when minifying.
diff --git a/pkg/serialization/lib/src/serialization_rule.dart b/pkg/serialization/lib/src/serialization_rule.dart
index 0fc6f3e..d7560b7 100644
--- a/pkg/serialization/lib/src/serialization_rule.dart
+++ b/pkg/serialization/lib/src/serialization_rule.dart
@@ -567,6 +567,8 @@
sort([f]) => _throw();
clear() => _throw();
insert(x, y) => _throw();
+ insertAll(x, y) => _throw();
+ fillRange(x, y, [z]) => _throw();
removeAt(x) => _throw();
remove(x) => _throw();
removeLast() => _throw();
@@ -574,8 +576,10 @@
retainAll(x) => _throw();
removeWhere(x) => _throw();
retainWhere(x) => _throw();
+ replaceRange(x, y, z) => _throw();
getRange(x, y) => _throw();
- setRange(x, y, z, [a]) => _throw();
+ setRange(x, y, z, [a = 0]) => _throw();
+ setAll(x, y) => _throw();
removeRange(x, y) => _throw();
get reversed => _throw();
void set length(x) => _throw();
diff --git a/pkg/unittest/lib/mock.dart b/pkg/unittest/lib/mock.dart
index cacaec7..b6e48a4 100644
--- a/pkg/unittest/lib/mock.dart
+++ b/pkg/unittest/lib/mock.dart
@@ -108,6 +108,7 @@
library mock;
import 'dart:mirrors' show MirrorSystem;
+import 'dart:collection' show LinkedHashMap;
import 'matcher.dart';
@@ -1237,7 +1238,7 @@
final String name;
/** The set of [Behavior]s supported. */
- Map<String,Behavior> _behaviors;
+ LinkedHashMap<String,Behavior> _behaviors;
/** The [log] of calls made. Only used if [name] is null. */
LogEntryList log;
@@ -1262,7 +1263,7 @@
*/
Mock() : _throwIfNoBehavior = false, log = null, name = null {
logging = true;
- _behaviors = new Map<String,Behavior>();
+ _behaviors = new LinkedHashMap<String,Behavior>();
}
/**
@@ -1281,7 +1282,7 @@
throw new Exception("Mocks with shared logs must have a name.");
}
logging = enableLogging;
- _behaviors = new Map<String,Behavior>();
+ _behaviors = new LinkedHashMap<String,Behavior>();
}
/**
diff --git a/pkg/unittest/lib/src/config.dart b/pkg/unittest/lib/src/config.dart
index dc25771..8b5a60c 100644
--- a/pkg/unittest/lib/src/config.dart
+++ b/pkg/unittest/lib/src/config.dart
@@ -4,6 +4,18 @@
part of unittest;
+// A custom failure handler for [expect] that routes expect failures
+// to the config.
+class _ExpectFailureHandler extends DefaultFailureHandler {
+ Configuration _config;
+
+ _ExpectFailureHandler(this._config) : super();
+
+ void fail(String reason) {
+ _config.onExpectFailure(reason);
+ }
+}
+
/**
* Hooks to configure the unittest library for different platforms. This class
* implements the API in a platform-independent way. Tests that want to take
@@ -30,6 +42,29 @@
final bool autoStart = true;
/**
+ * If true (the default), throw an exception at the end if any tests failed.
+ */
+ bool throwOnTestFailures = true;
+
+ /**
+ * If true (the default), then tests will stop after the first failed
+ * [expect]. If false, failed [expect]s will not cause the test
+ * to stop (other exceptions will still terminate the test).
+ */
+ bool stopTestOnExpectFailure = true;
+
+ // If stopTestOnExpectFailure is false, we need to capture failures, which
+ // we do with this List.
+ List _testLogBuffer = new List();
+
+ /**
+ * The constructor sets up a failure handler for [expect] that redirects
+ * [expect] failures to [onExpectFailure].
+ */
+ Configuration() {
+ configureExpectFailureHandler(new _ExpectFailureHandler(this));
+ }
+ /**
* Called as soon as the unittest framework becomes initialized. This is done
* even before tests are added to the test framework. It might be used to
* determine/debug errors that occur before the test harness starts executing.
@@ -46,18 +81,48 @@
/**
* Called when each test starts. Useful to show intermediate progress on
- * a test suite.
+ * a test suite. Derived classes should call this first before their own
+ * override code.
*/
void onTestStart(TestCase testCase) {
assert(testCase != null);
+ _testLogBuffer.clear();
}
/**
* Called when each test is first completed. Useful to show intermediate
- * progress on a test suite.
+ * progress on a test suite. Derived classes should call this first
+ * before their own override code.
*/
void onTestResult(TestCase testCase) {
assert(testCase != null);
+ if (!stopTestOnExpectFailure && _testLogBuffer.length > 0) {
+ // Write the message/stack pairs up to the last pairs.
+ var reason = new StringBuffer();
+ for (var i = 0; i < _testLogBuffer.length - 2; i += 2) {
+ reason.write(_testLogBuffer[i]);
+ reason.write('\n');
+ reason.write(_formatStack(_testLogBuffer[i+1]));
+ reason.write('\n');
+ }
+ // Write the last message.
+ reason.write(_testLogBuffer[_testLogBuffer.length - 2]);
+ if (testCase.result == PASS) {
+ testCase._result = FAIL;
+ testCase._message = reason.toString();
+ // Use the last stack as the overall failure stack.
+ testCase._stackTrace =
+ _formatStack(_testLogBuffer[_testLogBuffer.length - 1]);
+ } else {
+ // Add the last stack to the message; we have a further stack
+ // caused by some other failure.
+ reason.write(_formatStack(_testLogBuffer[_testLogBuffer.length - 1]));
+ reason.write('\n');
+ // Add the existing reason to the end of the expect log to
+ // create the final message.
+ testCase._message = '${reason.toString()}\n${testCase._message}';
+ }
+ }
}
/**
@@ -78,6 +143,23 @@
}
/**
+ * Handles failures from expect(). The default in
+ * this base configuration is to throw an exception;
+ */
+ void onExpectFailure(String reason) {
+ if (stopTestOnExpectFailure) {
+ throw new TestFailure(reason);
+ } else {
+ _testLogBuffer.add(reason);
+ try {
+ throw '';
+ } catch (_, stack) {
+ _testLogBuffer.add(stack);
+ }
+ }
+ }
+
+ /**
* Called with the result of all test cases. The default implementation prints
* the result summary using the built-in [print] command. Browser tests
* commonly override this to reformat the output.
@@ -127,7 +209,9 @@
_receivePort.close();
} else {
_receivePort.close();
- throw new Exception('Some tests failed.');
+ if (throwOnTestFailures) {
+ throw new Exception('Some tests failed.');
+ }
}
}
diff --git a/pkg/unittest/lib/src/test_case.dart b/pkg/unittest/lib/src/test_case.dart
index 8e761f6..67b791e 100644
--- a/pkg/unittest/lib/src/test_case.dart
+++ b/pkg/unittest/lib/src/test_case.dart
@@ -122,6 +122,7 @@
// seems to be the more conservative approach, because
// unittest will not stop at a test failure.
var stack = getAttachedStackTrace(e);
+ if (stack == null) stack = '';
error("$description: Test setup failed: $e", "$stack");
});
} else {
@@ -148,7 +149,7 @@
// is the first time the result is being set.
void _setResult(String testResult, String messageText, String stack) {
_message = messageText;
- _stackTrace = stack;
+ _stackTrace = _formatStack(stack);
if (result == null) {
_result = testResult;
_config.onTestResult(this);
@@ -199,6 +200,7 @@
}
void fail(String messageText, [String stack = '']) {
+ assert(stack != null);
if (result != null) {
String newMessage = (result == PASS)
? 'Test failed after initially passing: $messageText'
@@ -211,6 +213,7 @@
}
void error(String messageText, [String stack = '']) {
+ assert(stack != null);
_complete(ERROR, messageText, stack);
}
diff --git a/pkg/unittest/lib/unittest.dart b/pkg/unittest/lib/unittest.dart
index b2abf069..6562509 100644
--- a/pkg/unittest/lib/unittest.dart
+++ b/pkg/unittest/lib/unittest.dart
@@ -167,8 +167,9 @@
library unittest;
import 'dart:async';
-import 'dart:isolate';
import 'dart:collection';
+import 'dart:isolate';
+import 'dart:math' show max;
import 'matcher.dart';
export 'matcher.dart';
@@ -181,8 +182,17 @@
Configuration _config;
-/** [Configuration] used by the unittest library. */
-Configuration get unittestConfiguration => _config;
+/**
+ * [Configuration] used by the unittest library. Note that if a
+ * configuration has not been set, calling this getter will create
+ * a default configuration.
+ */
+Configuration get unittestConfiguration {
+ if (_config == null) {
+ _config = new Configuration();
+ }
+ return _config;
+}
/**
* Sets the [Configuration] used by the unittest library.
@@ -214,11 +224,20 @@
final List<TestCase> testCases = new UnmodifiableListView<TestCase>(_testCases);
/**
+ * The set of tests to run can be restricted by using [solo_test] and
+ * [solo_group].
+ * As groups can be nested we use a counter to keep track of the nest level
+ * of soloing, and a flag to tell if we have seen any solo tests.
+ */
+int _soloNestingLevel = 0;
+bool _soloTestSeen = false;
+
+/**
* Setup and teardown functions for a group and its parents, the latter
* for chaining.
*/
-class GroupContext {
- final GroupContext parent;
+class _GroupContext {
+ final _GroupContext parent;
/** Description text of the current test group. */
final String _name;
@@ -273,7 +292,7 @@
? _name
: "${parent.fullName}$groupSep$_name";
- GroupContext([this.parent, this._name = '']) {
+ _GroupContext([this.parent, this._name = '']) {
_testSetup = parentSetup;
_testTeardown = parentTeardown;
}
@@ -282,8 +301,8 @@
// We use a 'dummy' context for the top level to eliminate null
// checks when querying the context. This allows us to easily
// support top-level setUp/tearDown functions as well.
-GroupContext _rootContext = new GroupContext();
-GroupContext _currentContext = _rootContext;
+final _rootContext = new _GroupContext();
+_GroupContext _currentContext = _rootContext;
int _currentTestCaseIndex = 0;
@@ -307,9 +326,6 @@
const FAIL = 'fail';
const ERROR = 'error';
-/** If set, then all other test cases will be ignored. */
-TestCase _soloTest;
-
/**
* A map that can be used to communicate state between a test driver
* or main() function and the tests, particularly when these two
@@ -326,32 +342,45 @@
*/
void test(String spec, TestFunction body) {
ensureInitialized();
- _testCases.add(new TestCase._internal(testCases.length + 1, _fullSpec(spec),
- body));
+ if (!_soloTestSeen || _soloNestingLevel > 0) {
+ var testcase = new TestCase._internal(testCases.length + 1, _fullSpec(spec),
+ body);
+ _testCases.add(testcase);
+ }
}
+/** Convenience function for skipping a test. */
+void skip_test(String spec, TestFunction body){}
+
/**
* Creates a new test case with the given description and body. The
* description will include the descriptions of any surrounding group()
* calls.
*
- * "solo_" means that this will be the only test that is run. All other tests
- * will be skipped. This is a convenience function to let you quickly isolate
- * a single test by adding "solo_" before it to temporarily disable all other
- * tests.
+ * If we use [solo_test] (or [solo_group]) instead of test, then all non-solo
+ * tests will be disabled. Note that if we use [solo_group], all tests in
+ * the group will be enabled, regardless of whether they use [test] or
+ * [solo_test], or whether they are in a nested [group] vs [solo_group]. Put
+ * another way, if there are any calls to [solo_test] or [solo_group] in a test
+ * file, all tests that are not inside a [solo_group] will be disabled unless
+ * they are [solo_test]s.
+ *
+ * [skip_test] and [skip_group] take precedence over soloing, by virtue of the
+ * fact that they are effectively no-ops.
*/
void solo_test(String spec, TestFunction body) {
- // TODO(rnystrom): Support multiple solos. If more than one test is solo-ed,
- // all of the solo-ed tests and none of the non-solo-ed ones should run.
- if (_soloTest != null) {
- throw new Exception('Only one test can be soloed right now.');
- }
-
ensureInitialized();
-
- _soloTest = new TestCase._internal(testCases.length + 1, _fullSpec(spec),
- body);
- _testCases.add(_soloTest);
+ if (!_soloTestSeen) {
+ _soloTestSeen = true;
+ // This is the first solo-ed test. Discard all tests up to now.
+ _testCases.clear();
+ }
+ ++_soloNestingLevel;
+ try {
+ test(spec, body);
+ } finally {
+ --_soloNestingLevel;
+ }
}
/** Sentinel value for [_SpreadArgsHelper]. */
@@ -583,7 +612,7 @@
*/
void group(String description, void body()) {
ensureInitialized();
- _currentContext = new GroupContext(_currentContext, description);
+ _currentContext = new _GroupContext(_currentContext, description);
try {
body();
} catch (e, trace) {
@@ -595,6 +624,25 @@
}
}
+/** Like [skip_test], but for groups. */
+void skip_group(String description, void body()) {}
+
+/** Like [solo_test], but for groups. */
+void solo_group(String description, void body()) {
+ ensureInitialized();
+ if (!_soloTestSeen) {
+ _soloTestSeen = true;
+ // This is the first solo-ed group. Discard all tests up to now.
+ _testCases.clear();
+ }
+ ++_soloNestingLevel;
+ try {
+ group(description, body);
+ } finally {
+ --_soloNestingLevel;
+ }
+}
+
/**
* Register a [setUp] function for a test [group]. This function will
* be called before each test in the group is run.
@@ -668,11 +716,6 @@
_ensureInitialized(false);
_currentTestCaseIndex = 0;
- // If we are soloing a test, remove all the others.
- if (_soloTest != null) {
- filterTests((t) => t == _soloTest);
- }
-
_config.onStart();
runAsync(() {
@@ -787,10 +830,7 @@
_uncaughtErrorMessage = null;
- if (_config == null) {
- unittestConfiguration = new Configuration();
- }
- _config.onInit();
+ unittestConfiguration.onInit();
if (configAutoStart && _config.autoStart) {
// Immediately queue the suite up. It will run after a timeout (i.e. after
@@ -800,14 +840,8 @@
}
/** Select a solo test by ID. */
-void setSoloTest(int id) {
- for (var i = 0; i < testCases.length; i++) {
- if (testCases[i].id == id) {
- _soloTest = testCases[i];
- break;
- }
- }
-}
+void setSoloTest(int id) =>
+ _testCases.retainWhere((t) => t.id == id);
/** Enable/disable a test by ID. */
void _setTestEnabledState(int testId, bool state) {
@@ -832,3 +866,80 @@
/** Signature for a test function. */
typedef dynamic TestFunction();
+
+// Stack formatting utility. Strips extraneous content from a stack trace.
+// Stack frame lines are parsed with a regexp, which has been tested
+// in Chrome, Firefox and the VM. If a line fails to be parsed it is
+// included in the output to be conservative.
+//
+// The output stack consists of everything after the call to TestCase._run.
+// If we see an 'expect' in the frame we will prune everything above that
+// as well.
+final _frameRegExp = new RegExp(
+ r'^\s*' // Skip leading spaces.
+ r'(?:' // Group of choices for the prefix.
+ r'(?:#\d+\s*)|' // Skip VM's #<frameNumber>.
+ r'(?:at )|' // Skip Firefox's 'at '.
+ r'(?:))' // Other environments have nothing here.
+ r'(.+)' // Extract the function/method.
+ r'\s*[@\(]' // Skip space and @ or (.
+ r'(' // This group of choices is for the source file.
+ r'(?:.+:\/\/.+\/[^:]*)|' // Handle file:// or http:// URLs.
+ r'(?:dart:[^:]*)|' // Handle dart:<lib>.
+ r'(?:package:[^:]*)' // Handle package:<path>
+ r'):([:\d]+)[\)]?$'); // Get the line number and optional column number.
+
+String _formatStack(stack) {
+ var lines;
+ if (stack is StackTrace) {
+ lines = stack.toString().split('\n');
+ } else if (stack is String) {
+ lines = stack.split('\n');
+ } else {
+ return stack.toString();
+ }
+
+ // Calculate the max width of first column so we can
+ // pad to align the second columns.
+ int padding = lines.fold(0, (n, line) {
+ var match = _frameRegExp.firstMatch(line);
+ if (match == null) return n;
+ return max(n, match[1].length + 1);
+ });
+
+ // We remove all entries that have a location in unittest.
+ // We strip out anything before _nextBatch too.
+ var sb = new StringBuffer();
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (line == '') continue;
+ var match = _frameRegExp.firstMatch(line);
+ if (match == null) {
+ sb.write(line);
+ sb.write('\n');
+ } else {
+ var member = match[1];
+ var location = match[2];
+ var position = match[3];
+ if (member.indexOf('TestCase._runTest') >= 0) {
+ // Don't include anything after this.
+ break;
+ } else if (member.indexOf('expect') >= 0) {
+ // It looks like this was an expect() failure;
+ // drop all the frames up to here.
+ sb.clear();
+ } else {
+ sb.write(member);
+ // Pad second column to a fixed position.
+ for (var j = 0; j <= padding - member.length; j++) {
+ sb.write(' ');
+ }
+ sb.write(location);
+ sb.write(' ');
+ sb.write(position);
+ sb.write('\n');
+ }
+ }
+ }
+ return sb.toString();
+}
diff --git a/pkg/unittest/test/mock_test.dart b/pkg/unittest/test/mock_test.dart
index 1788e82..5669f3f 100644
--- a/pkg/unittest/test/mock_test.dart
+++ b/pkg/unittest/test/mock_test.dart
@@ -661,4 +661,62 @@
expect(m.foo(alice), true);
expect(m.foo(bob), false);
});
+
+ test("Behavior ordering", () {
+ // This is distinct from value ordering, i.e.
+ //
+ // m.when(...).thenReturn(1).thenReturn(2)
+ //
+ // Here we want to test using distinct matchers being
+ // applied in order, so we have a single call that
+ // matches 3 different behaviors, and test that
+ // the behaviors are applied in the order they are
+ // defined.
+ var m = new Mock();
+ m.when(callsTo("foo")).thenReturn("A");
+ m.when(callsTo("foo", "bar")).thenReturn("B");
+ m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
+ expect(m.foo("bar", "mock"), "A");
+ expect(m.foo("bar", "mock"), "B");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ m.resetBehavior();
+
+ m.when(callsTo("foo")).thenReturn("A");
+ m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
+ m.when(callsTo("foo", "bar")).thenReturn("B");
+ expect(m.foo("bar", "mock"), "A");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ m.resetBehavior();
+
+ m.when(callsTo("foo", "bar")).thenReturn("B");
+ m.when(callsTo("foo")).thenReturn("A");
+ m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
+ expect(m.foo("bar", "mock"), "B");
+ expect(m.foo("bar", "mock"), "A");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ m.resetBehavior();
+
+ m.when(callsTo("foo", "bar")).thenReturn("B");
+ m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
+ m.when(callsTo("foo")).thenReturn("A");
+ expect(m.foo("bar", "mock"), "B");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ m.resetBehavior();
+
+ m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
+ m.when(callsTo("foo")).thenReturn("A");
+ m.when(callsTo("foo", "bar")).thenReturn("B");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ expect(m.foo("bar", "mock"), "C");
+ m.resetBehavior();
+ });
}
+
diff --git a/pkg/unittest/test/unittest_test.dart b/pkg/unittest/test/unittest_test.dart
index aa1bd97..f1d1aad 100644
--- a/pkg/unittest/test/unittest_test.dart
+++ b/pkg/unittest/test/unittest_test.dart
@@ -344,6 +344,59 @@
test('after nest', () {
expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D ");
});
+ } else if (testName == 'skipped/soloed nested groups with setup/teardown') {
+ StringBuffer s = null;
+ setUp(() {
+ if (s == null)
+ s = new StringBuffer();
+ });
+ test('top level', () {
+ s.write('A');
+ });
+ skip_test('skipped top level', () {
+ s.write('B');
+ });
+ skip_group('skipped top level group', () {
+ setUp(() {
+ s.write('C');
+ });
+ solo_test('skipped solo nested test', () {
+ s.write('D');
+ });
+ });
+ group('non-solo group', () {
+ setUp(() {
+ s.write('E');
+ });
+ test('in non-solo group', () {
+ s.write('F');
+ });
+ solo_test('solo_test in non-solo group', () {
+ s.write('G');
+ });
+ });
+ solo_group('solo group', () {
+ setUp(() {
+ s.write('H');
+ });
+ test('solo group non-solo test', () {
+ s.write('I');
+ });
+ solo_test('solo group solo test', () {
+ s.write('J');
+ });
+ group('nested non-solo group in solo group', () {
+ test('nested non-solo group non-solo test', () {
+ s.write('K');
+ });
+ solo_test('nested non-solo group solo test', () {
+ s.write('L');
+ });
+ });
+ });
+ solo_test('final', () {
+ expect(s.toString(), "EGHIHJHKHL");
+ });
}
});
}
@@ -403,7 +456,18 @@
'runTests without tests': buildStatusString(0, 0, 0, null),
'nested groups setup/teardown':
buildStatusString(2, 0, 0,
- 'level 1 level 2 level 3 level 4 level 5 level 6 inner::after nest')
+ 'level 1 level 2 level 3 level 4 level 5 level 6 inner::'
+ 'after nest'),
+ 'skipped/soloed nested groups with setup/teardown':
+ buildStatusString(6, 0, 0,
+ 'non-solo group solo_test in non-solo group::'
+ 'solo group solo group non-solo test::'
+ 'solo group solo group solo test::'
+ 'solo group nested non-solo group in solo group nested non-'
+ 'solo group non-solo test::'
+ 'solo group nested non-solo group in solo'
+ ' group nested non-solo group solo test::'
+ 'final')
};
tests.forEach((String name, String expected) {
diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc
index 86f9aee..a942b6a 100644
--- a/runtime/bin/builtin_natives.cc
+++ b/runtime/bin/builtin_natives.cc
@@ -23,6 +23,7 @@
V(Directory_Exists, 1) \
V(Directory_Create, 1) \
V(Directory_Current, 0) \
+ V(Directory_SetCurrent, 1) \
V(Directory_CreateTemp, 1) \
V(Directory_Delete, 2) \
V(Directory_Rename, 2) \
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index 3379b16..a803fca 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -566,9 +566,13 @@
const char* message) {
// Create a Dart Exception object with a message.
Dart_Handle clazz = GetDartClass(library_url, exception_name);
- Dart_Handle args[1];
- args[0] = NewString(message);
- return Dart_New(clazz, Dart_Null(), 1, args);
+ if (message != NULL) {
+ Dart_Handle args[1];
+ args[0] = NewString(message);
+ return Dart_New(clazz, Dart_Null(), 1, args);
+ } else {
+ return Dart_New(clazz, Dart_Null(), 0, NULL);
+ }
}
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index 758df5a..310cf8f 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -32,6 +32,28 @@
}
+void FUNCTION_NAME(Directory_SetCurrent)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ int argc = Dart_GetNativeArgumentCount(args);
+ Dart_Handle path;
+ if (argc == 1) {
+ path = Dart_GetNativeArgument(args, 0);
+ }
+ if (argc != 1 || !Dart_IsString(path)) {
+ Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(NULL));
+ } else {
+ if (Directory::SetCurrent(DartUtils::GetStringValue(path))) {
+ Dart_SetReturnValue(args, Dart_True());
+ } else {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
+ }
+ Dart_ExitScope();
+}
+
+
void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
static const int kExists = 1;
static const int kDoesNotExist = 0;
diff --git a/runtime/bin/directory.h b/runtime/bin/directory.h
index a8dde3d..a19d274 100644
--- a/runtime/bin/directory.h
+++ b/runtime/bin/directory.h
@@ -105,6 +105,7 @@
DirectoryListing* listing);
static ExistsResult Exists(const char* path);
static char* Current();
+ static bool SetCurrent(const char* path);
static bool Create(const char* path);
static char* CreateTemp(const char* const_template);
static bool Delete(const char* path, bool recursive);
diff --git a/runtime/bin/directory_android.cc b/runtime/bin/directory_android.cc
index 7c30274..24193f9 100644
--- a/runtime/bin/directory_android.cc
+++ b/runtime/bin/directory_android.cc
@@ -429,6 +429,12 @@
}
+bool Directory::SetCurrent(const char* path) {
+ int result = TEMP_FAILURE_RETRY(chdir(path));
+ return result == 0;
+}
+
+
bool Directory::Create(const char* dir_name) {
// Create the directory with the permissions specified by the
// process umask.
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index 67ac947..f3c1ec2 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.cc
@@ -420,6 +420,12 @@
}
+bool Directory::SetCurrent(const char* path) {
+ int result = TEMP_FAILURE_RETRY(chdir(path));
+ return result == 0;
+}
+
+
bool Directory::Create(const char* dir_name) {
// Create the directory with the permissions specified by the
// process umask.
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index 5c7b115..3a9ab04 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -420,6 +420,12 @@
}
+bool Directory::SetCurrent(const char* path) {
+ int result = TEMP_FAILURE_RETRY(chdir(path));
+ return result == 0;
+}
+
+
bool Directory::Create(const char* dir_name) {
// Create the directory with the permissions specified by the
// process umask.
diff --git a/runtime/bin/directory_patch.dart b/runtime/bin/directory_patch.dart
index 4b6ce1f..688686b 100644
--- a/runtime/bin/directory_patch.dart
+++ b/runtime/bin/directory_patch.dart
@@ -4,6 +4,7 @@
patch class _Directory {
/* patch */ static String _current() native "Directory_Current";
+ /* patch */ static _setCurrent(path) native "Directory_SetCurrent";
/* patch */ static _createTemp(String template) native "Directory_CreateTemp";
/* patch */ static int _exists(String path) native "Directory_Exists";
/* patch */ static _create(String path) native "Directory_Create";
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index dc6cd69..f0f9f935 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -425,6 +425,14 @@
}
+bool Directory::SetCurrent(const char* path) {
+ const wchar_t* system_path = StringUtils::Utf8ToWide(path);
+ bool result = SetCurrentDirectoryW(system_path) != 0;
+ free(const_cast<wchar_t*>(system_path));
+ return result;
+}
+
+
bool Directory::Create(const char* dir_name) {
const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name);
int create_status = CreateDirectoryW(system_name, NULL);
diff --git a/runtime/bin/hashmap_test.cc b/runtime/bin/hashmap_test.cc
index 23d4ad8..b51d1cf 100644
--- a/runtime/bin/hashmap_test.cc
+++ b/runtime/bin/hashmap_test.cc
@@ -7,6 +7,8 @@
#include "platform/hashmap.h"
#include "vm/unit_test.h"
+namespace dart {
+
// Default initial size of hashmaps used in these tests.
static intptr_t kInitialSize = 8;
@@ -167,3 +169,5 @@
TestSet(CollisionHash3, 50);
TestSet(CollisionHash4, 50);
}
+
+} // namespace dart
diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc
index 0b4cedd..ddaf345 100644
--- a/runtime/bin/io_natives.cc
+++ b/runtime/bin/io_natives.cc
@@ -29,6 +29,7 @@
V(Filter_End, 1) \
V(Filter_Process, 2) \
V(Filter_Processed, 2) \
+ V(InternetAddress_Fixed, 1) \
V(Platform_NumberOfProcessors, 0) \
V(Platform_OperatingSystem, 0)