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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2856463004: New tests and improvements for generics in comments parsing. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 Token injected = injectGenericCommentTypeAssign(tokenWithComment); 1931 Token injected = injectGenericCommentTypeAssign(tokenWithComment);
1932 if (!identical(injected, tokenWithComment)) { 1932 if (!identical(injected, tokenWithComment)) {
1933 Token prev = tokenToStartReplacing.previous; 1933 Token prev = tokenToStartReplacing.previous;
1934 prev.setNextWithoutSettingPrevious(injected); 1934 prev.setNextWithoutSettingPrevious(injected);
1935 tokenToStartReplacing = injected; 1935 tokenToStartReplacing = injected;
1936 tokenToStartReplacing.previous = prev; 1936 tokenToStartReplacing.previous = prev;
1937 } 1937 }
1938 return tokenToStartReplacing; 1938 return tokenToStartReplacing;
1939 } 1939 }
1940 1940
1941 @override
1942 void discardTypeReplacedWithCommentTypeAssign() {
Paul Berry 2017/05/01 18:24:42 Do we need to add a similar override to BodyBuilde
1943 pop();
1944 }
1945
1941 /// Check if the given [token] has a comment token with the given [info], 1946 /// Check if the given [token] has a comment token with the given [info],
1942 /// which should be either [TokenType.GENERIC_METHOD_TYPE_ASSIGN] or 1947 /// which should be either [TokenType.GENERIC_METHOD_TYPE_ASSIGN] or
1943 /// [TokenType.GENERIC_METHOD_TYPE_LIST]. If found, parse the comment 1948 /// [TokenType.GENERIC_METHOD_TYPE_LIST]. If found, parse the comment
1944 /// into tokens and inject into the token stream before the [token]. 1949 /// into tokens and inject into the token stream before the [token].
1945 Token _injectGenericComment(Token token, TokenType info, int prefixLen) { 1950 Token _injectGenericComment(Token token, TokenType info, int prefixLen) {
1946 if (parseGenericMethodComments) { 1951 if (parseGenericMethodComments) {
1947 CommentToken t = token.precedingCommentTokens; 1952 CommentToken t = token.precedingCommentTokens;
1948 for (; t != null; t = t.next) { 1953 for (; t != null; t = t.next) {
1949 if (t.info == info) { 1954 if (t.info == info) {
1950 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2); 1955 String code = t.lexeme.substring(prefixLen, t.lexeme.length - 2);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } else if (identical('static', s)) { 2086 } else if (identical('static', s)) {
2082 staticKeyword = token; 2087 staticKeyword = token;
2083 } else if (identical('var', s)) { 2088 } else if (identical('var', s)) {
2084 finalConstOrVarKeyword = token; 2089 finalConstOrVarKeyword = token;
2085 } else { 2090 } else {
2086 internalError('Unhandled modifier: $s'); 2091 internalError('Unhandled modifier: $s');
2087 } 2092 }
2088 } 2093 }
2089 } 2094 }
2090 } 2095 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/analysis_server.iml ('k') | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698