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

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/util.dart

Issue 1909843002: Pull the 'keyword' property into Token. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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) 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.src.correction.util; 5 library services.src.correction.util;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' 9 import 'package:analysis_server/plugin/protocol/protocol.dart'
10 show SourceChange, SourceEdit; 10 show SourceChange, SourceEdit;
11 import 'package:analysis_server/src/protocol_server.dart' 11 import 'package:analysis_server/src/protocol_server.dart'
12 show doSourceChange_addElementEdit; 12 show doSourceChange_addElementEdit;
13 import 'package:analysis_server/src/services/correction/source_range.dart'; 13 import 'package:analysis_server/src/services/correction/source_range.dart';
14 import 'package:analysis_server/src/services/correction/strings.dart'; 14 import 'package:analysis_server/src/services/correction/strings.dart';
15 import 'package:analyzer/dart/ast/ast.dart'; 15 import 'package:analyzer/dart/ast/ast.dart';
16 import 'package:analyzer/dart/ast/token.dart'; 16 import 'package:analyzer/dart/ast/token.dart';
17 import 'package:analyzer/dart/ast/visitor.dart'; 17 import 'package:analyzer/dart/ast/visitor.dart';
18 import 'package:analyzer/dart/element/element.dart'; 18 import 'package:analyzer/dart/element/element.dart';
19 import 'package:analyzer/dart/element/type.dart'; 19 import 'package:analyzer/dart/element/type.dart';
20 import 'package:analyzer/src/dart/ast/token.dart';
21 import 'package:analyzer/src/dart/ast/utilities.dart'; 20 import 'package:analyzer/src/dart/ast/utilities.dart';
22 import 'package:analyzer/src/dart/scanner/reader.dart'; 21 import 'package:analyzer/src/dart/scanner/reader.dart';
23 import 'package:analyzer/src/dart/scanner/scanner.dart'; 22 import 'package:analyzer/src/dart/scanner/scanner.dart';
24 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
25 import 'package:analyzer/src/generated/resolver.dart'; 24 import 'package:analyzer/src/generated/resolver.dart';
26 import 'package:analyzer/src/generated/source.dart'; 25 import 'package:analyzer/src/generated/source.dart';
27 import 'package:path/path.dart'; 26 import 'package:path/path.dart';
28 27
29 /** 28 /**
30 * Adds edits to the given [change] that ensure that all the [libraries] are 29 * Adds edits to the given [change] that ensure that all the [libraries] are
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 int offset = 0; 1405 int offset = 0;
1407 String prefix = ""; 1406 String prefix = "";
1408 String suffix = ""; 1407 String suffix = "";
1409 } 1408 }
1410 1409
1411 /** 1410 /**
1412 * Utilities to work with [Token]s. 1411 * Utilities to work with [Token]s.
1413 */ 1412 */
1414 class TokenUtils { 1413 class TokenUtils {
1415 /** 1414 /**
1416 * @return the first [KeywordToken] with given [Keyword], may be <code>null</c ode> if 1415 * Return the first keyword [Token] with given [Keyword], may be `null` if
Brian Wilkerson 2016/04/21 13:41:37 nit: Personally, I'd rewrite this as Return the f
1417 * not found. 1416 * not found.
1418 */ 1417 */
1419 static KeywordToken findKeywordToken(List<Token> tokens, Keyword keyword) { 1418 static Token findKeywordToken(List<Token> tokens, Keyword keyword) {
1420 for (Token token in tokens) { 1419 for (Token token in tokens) {
1421 if (token is KeywordToken) { 1420 if (token.keyword == keyword) {
1422 KeywordToken keywordToken = token; 1421 return token;
1423 if (keywordToken.keyword == keyword) {
1424 return keywordToken;
1425 }
1426 } 1422 }
1427 } 1423 }
1428 return null; 1424 return null;
1429 } 1425 }
1430 1426
1431 /** 1427 /**
1432 * @return the first [Token] with given [TokenType], may be <code>null</code> if not 1428 * @return the first [Token] with given [TokenType], may be <code>null</code> if not
1433 * found. 1429 * found.
1434 */ 1430 */
1435 static Token findToken(List<Token> tokens, TokenType type) { 1431 static Token findToken(List<Token> tokens, TokenType type) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 _InvertedCondition expr, int newOperatorPrecedence) { 1517 _InvertedCondition expr, int newOperatorPrecedence) {
1522 if (expr._precedence < newOperatorPrecedence) { 1518 if (expr._precedence < newOperatorPrecedence) {
1523 return "(${expr._source})"; 1519 return "(${expr._source})";
1524 } 1520 }
1525 return expr._source; 1521 return expr._source;
1526 } 1522 }
1527 1523
1528 static _InvertedCondition _simple(String source) => 1524 static _InvertedCondition _simple(String source) =>
1529 new _InvertedCondition(2147483647, source); 1525 new _InvertedCondition(2147483647, source);
1530 } 1526 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | pkg/analyzer/lib/dart/ast/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698