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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/completion_target.dart

Issue 1273773005: fix completion after dot-keyword - fixes #23882 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 4 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 | pkg/analysis_server/lib/src/services/completion/optype.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'package:analyzer/src/generated/ast.dart'; 1 import 'package:analyzer/src/generated/ast.dart';
2 import 'package:analyzer/src/generated/element.dart'; 2 import 'package:analyzer/src/generated/element.dart';
3 import 'package:analyzer/src/generated/scanner.dart'; 3 import 'package:analyzer/src/generated/scanner.dart';
4 import 'package:analyzer/src/generated/utilities_dart.dart'; 4 import 'package:analyzer/src/generated/utilities_dart.dart';
5 5
6 int _computeArgIndex(AstNode containingNode, Object entity) { 6 int _computeArgIndex(AstNode containingNode, Object entity) {
7 var argList = containingNode; 7 var argList = containingNode;
8 if (argList is ArgumentList) { 8 if (argList is ArgumentList) {
9 NodeList<Expression> args = argList.arguments; 9 NodeList<Expression> args = argList.arguments;
10 for (int index = 0; index < args.length; ++index) { 10 for (int index = 0; index < args.length; ++index) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // A token is considered a candidate entity if the cursor offset is (a) 313 // A token is considered a candidate entity if the cursor offset is (a)
314 // before the start of the token, (b) within the token, (c) at the end of 314 // before the start of the token, (b) within the token, (c) at the end of
315 // the token and the token is a keyword or identifier, or (d) at the 315 // the token and the token is a keyword or identifier, or (d) at the
316 // location of the token and the token is zero length. 316 // location of the token and the token is zero length.
317 if (offset < token.end) { 317 if (offset < token.end) {
318 return true; 318 return true;
319 } else if (offset == token.end) { 319 } else if (offset == token.end) {
320 return token.type == TokenType.KEYWORD || 320 return token.type == TokenType.KEYWORD ||
321 token.type == TokenType.IDENTIFIER || 321 token.type == TokenType.IDENTIFIER ||
322 token.length == 0; 322 token.length == 0;
323 } else if (!token.isSynthetic) {
324 return false;
325 }
326 // If the current token is synthetic, then check the previous token
327 // because it may have been dropped from the parse tree
328 Token previous = token.previous;
329 if (offset < previous.end) {
330 return true;
331 } else if (offset == previous.end) {
332 return token.type == TokenType.KEYWORD ||
333 previous.type == TokenType.IDENTIFIER;
323 } else { 334 } else {
324 return false; 335 return false;
325 } 336 }
326 } 337 }
327 338
328 /** 339 /**
329 * Return `true` if the parameter is a functional parameter. 340 * Return `true` if the parameter is a functional parameter.
330 */ 341 */
331 static bool _isFunctionalParameter( 342 static bool _isFunctionalParameter(
332 List<ParameterElement> parameters, int paramIndex) { 343 List<ParameterElement> parameters, int paramIndex) {
333 if (paramIndex < parameters.length) { 344 if (paramIndex < parameters.length) {
334 ParameterElement param = parameters[paramIndex]; 345 ParameterElement param = parameters[paramIndex];
335 DartType paramType = param.type; 346 DartType paramType = param.type;
336 if (param.parameterKind == ParameterKind.NAMED) { 347 if (param.parameterKind == ParameterKind.NAMED) {
337 // TODO(danrubel) handle named parameters 348 // TODO(danrubel) handle named parameters
338 return false; 349 return false;
339 } else { 350 } else {
340 return paramType is FunctionType || paramType is FunctionTypeAlias; 351 return paramType is FunctionType || paramType is FunctionTypeAlias;
341 } 352 }
342 } 353 }
343 return false; 354 return false;
344 } 355 }
345 } 356 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/optype.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698