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

Side by Side Diff: pkg/analyzer_plugin/lib/src/utilities/completion/completion_target.dart

Issue 2974533002: Guard against an AST node with no end token (issue 30089) (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
7 import 'package:analyzer/dart/ast/token.dart'; 7 import 'package:analyzer/dart/ast/token.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/ast/token.dart'; 10 import 'package:analyzer/src/dart/ast/token.dart';
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // (e.g. inside a literal string or inside a comment) are evaluated within 444 // (e.g. inside a literal string or inside a comment) are evaluated within
445 // the context of the token itself. 445 // the context of the token itself.
446 return offset <= node.offset; 446 return offset <= node.offset;
447 } 447 }
448 448
449 /** 449 /**
450 * Determine whether [token] could possibly be the [entity] for a 450 * Determine whether [token] could possibly be the [entity] for a
451 * [CompletionTarget] associated with the given [offset]. 451 * [CompletionTarget] associated with the given [offset].
452 */ 452 */
453 static bool _isCandidateToken(Token token, int offset) { 453 static bool _isCandidateToken(Token token, int offset) {
454 if (token == null) {
455 return false;
456 }
454 // A token is considered a candidate entity if the cursor offset is (a) 457 // A token is considered a candidate entity if the cursor offset is (a)
455 // before the start of the token, (b) within the token, (c) at the end of 458 // before the start of the token, (b) within the token, (c) at the end of
456 // the token and the token is a keyword or identifier, or (d) at the 459 // the token and the token is a keyword or identifier, or (d) at the
457 // location of the token and the token is zero length. 460 // location of the token and the token is zero length.
458 if (offset < token.end) { 461 if (offset < token.end) {
459 return true; 462 return true;
460 } else if (offset == token.end) { 463 } else if (offset == token.end) {
461 return token.type.isKeyword || 464 return token.type.isKeyword ||
462 token.type == TokenType.IDENTIFIER || 465 token.type == TokenType.IDENTIFIER ||
463 token.length == 0; 466 token.length == 0;
(...skipping 30 matching lines...) Expand all
494 orElse: () => null); 497 orElse: () => null);
495 paramType = param?.type; 498 paramType = param?.type;
496 } 499 }
497 } else { 500 } else {
498 paramType = param.type; 501 paramType = param.type;
499 } 502 }
500 } 503 }
501 return paramType is FunctionType || paramType is FunctionTypeAlias; 504 return paramType is FunctionType || paramType is FunctionTypeAlias;
502 } 505 }
503 } 506 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698