| Index: pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| index 7580511ad0e7d1d44dadacb5129acc57205adbaa..c66655a0b81a2360846c075e3d5322179aa57cae 100644
|
| --- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| +++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| @@ -60,6 +60,17 @@ class AstBuilder extends ScopeListener {
|
| /// bodies.
|
| final bool isFullAst;
|
|
|
| + /// `true` if the `native` clause is allowed
|
| + /// in class, method, and function declarations.
|
| + ///
|
| + /// This is being replaced by the @native(...) annotation.
|
| + //
|
| + // TODO(danrubel) Move this flag to a better location
|
| + // and should only be true if either:
|
| + // * The current library is a platform library
|
| + // * The current library has an import that uses the scheme "dart-ext".
|
| + bool allowNativeClause = false;
|
| +
|
| AstBuilder(this.errorReporter, this.library, this.member, Scope scope,
|
| this.isFullAst,
|
| [Uri uri])
|
| @@ -1277,6 +1288,11 @@ class AstBuilder extends ScopeListener {
|
| className = name.lexeme;
|
| }
|
|
|
| + @override
|
| + void handleNativeClause(Token nativeToken, bool hasName) {
|
| + push(ast.nativeClause(nativeToken, hasName ? pop() : null));
|
| + }
|
| +
|
| @override
|
| void endClassDeclaration(
|
| int interfacesCount,
|
| @@ -1284,9 +1300,11 @@ class AstBuilder extends ScopeListener {
|
| Token classKeyword,
|
| Token extendsKeyword,
|
| Token implementsKeyword,
|
| + Token nativeToken,
|
| Token endToken) {
|
| debugEvent("ClassDeclaration");
|
| _ClassBody body = pop();
|
| + NativeClause nativeClause = nativeToken != null ? pop() : null;
|
| ImplementsClause implementsClause;
|
| if (implementsKeyword != null) {
|
| List<TypeName> interfaces = popList(interfacesCount);
|
| @@ -1314,7 +1332,7 @@ class AstBuilder extends ScopeListener {
|
| Token abstractKeyword = modifiers?.abstractKeyword;
|
| List<Annotation> metadata = pop();
|
| Comment comment = pop();
|
| - declarations.add(ast.classDeclaration(
|
| + ClassDeclaration classDeclaration = ast.classDeclaration(
|
| comment,
|
| metadata,
|
| abstractKeyword,
|
| @@ -1326,7 +1344,9 @@ class AstBuilder extends ScopeListener {
|
| implementsClause,
|
| body.beginToken,
|
| body.members,
|
| - body.endToken));
|
| + body.endToken);
|
| + classDeclaration.nativeClause = nativeClause;
|
| + declarations.add(classDeclaration);
|
| }
|
|
|
| @override
|
| @@ -1891,6 +1911,14 @@ class AstBuilder extends ScopeListener {
|
| errorReporter?.reportErrorForOffset(
|
| ParserErrorCode.EXPECTED_TYPE_NAME, charOffset, 1);
|
| return;
|
| + case "NATIVE_CLAUSE_SHOULD_BE_ANNOTATION":
|
| + if (!allowNativeClause) {
|
| + errorReporter?.reportErrorForOffset(
|
| + ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION,
|
| + charOffset,
|
| + 1);
|
| + }
|
| + return;
|
| case "EXPECTED_STRING_LITERAL":
|
| errorReporter?.reportErrorForOffset(
|
| ParserErrorCode.EXPECTED_STRING_LITERAL, charOffset, 1);
|
|
|