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

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

Issue 2849703002: Fix following comma detection in code completion (#29503). (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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 services.completion.contributor.dart.arglist; 5 library services.completion.contributor.dart.arglist;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/ide_options.dart'; 9 import 'package:analysis_server/src/ide_options.dart';
10 import 'package:analysis_server/src/protocol_server.dart' 10 import 'package:analysis_server/src/protocol_server.dart'
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (isFlutterWidget(element.enclosingElement) && 323 if (isFlutterWidget(element.enclosingElement) &&
324 param.name == 'children') { 324 param.name == 'children') {
325 return getDefaultStringParameterValue(param); 325 return getDefaultStringParameterValue(param);
326 } 326 }
327 } 327 }
328 } 328 }
329 return null; 329 return null;
330 } 330 }
331 331
332 bool _isFollowedByAComma(DartCompletionRequest request) { 332 bool _isFollowedByAComma(DartCompletionRequest request) {
333 // new A(^); NO
334 // new A(one: 1, ^); NO
335 // new A(^ , one: 1); YES
336 // new A(^), ... NO
337
338 var containingNode = request.target.containingNode;
333 var entity = request.target.entity; 339 var entity = request.target.entity;
334 Token token = 340 Token token =
335 entity is AstNode ? entity.endToken : entity is Token ? entity : null; 341 entity is AstNode ? entity.endToken : entity is Token ? entity : null;
336 return token?.next?.type == TokenType.COMMA; 342 return (token != containingNode?.endToken) &&
343 token?.next?.type == TokenType.COMMA;
337 } 344 }
338 345
339 bool _isInFlutterCreation(DartCompletionRequest request) { 346 bool _isInFlutterCreation(DartCompletionRequest request) {
340 AstNode containingNode = request?.target?.containingNode; 347 AstNode containingNode = request?.target?.containingNode;
341 InstanceCreationExpression newExpr = containingNode != null 348 InstanceCreationExpression newExpr = containingNode != null
342 ? identifyNewExpression(containingNode.parent) 349 ? identifyNewExpression(containingNode.parent)
343 : null; 350 : null;
344 return newExpr != null && isFlutterInstanceCreationExpression(newExpr); 351 return newExpr != null && isFlutterInstanceCreationExpression(newExpr);
345 } 352 }
346 353
347 /** 354 /**
348 * If the given [comment] is not `null`, fill the [suggestion] documentation 355 * If the given [comment] is not `null`, fill the [suggestion] documentation
349 * fields. 356 * fields.
350 */ 357 */
351 static void _setDocumentation( 358 static void _setDocumentation(
352 CompletionSuggestion suggestion, String comment) { 359 CompletionSuggestion suggestion, String comment) {
353 if (comment != null) { 360 if (comment != null) {
354 String doc = removeDartDocDelimiters(comment); 361 String doc = removeDartDocDelimiters(comment);
355 suggestion.docComplete = doc; 362 suggestion.docComplete = doc;
356 suggestion.docSummary = getDartDocSummary(doc); 363 suggestion.docSummary = getDartDocSummary(doc);
357 } 364 }
358 } 365 }
359 } 366 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698