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

Side by Side Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 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) 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 analyzer.src.dart.ast.utilities; 5 library analyzer.src.dart.ast.utilities;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 3661 matching lines...) Expand 10 before | Expand all | Expand 10 after
3672 */ 3672 */
3673 AstNode _foundNode; 3673 AstNode _foundNode;
3674 3674
3675 /** 3675 /**
3676 * Initialize a newly created locator to locate an [AstNode] by locating the 3676 * Initialize a newly created locator to locate an [AstNode] by locating the
3677 * node within an AST structure that corresponds to the given range of 3677 * node within an AST structure that corresponds to the given range of
3678 * characters (between the [startOffset] and [endOffset] in the source. 3678 * characters (between the [startOffset] and [endOffset] in the source.
3679 */ 3679 */
3680 NodeLocator(int startOffset, [int endOffset]) 3680 NodeLocator(int startOffset, [int endOffset])
3681 : this._startOffset = startOffset, 3681 : this._startOffset = startOffset,
3682 this._endOffset = endOffset == null ? startOffset : endOffset; 3682 this._endOffset = endOffset ?? startOffset;
3683 3683
3684 /** 3684 /**
3685 * Return the node that was found that corresponds to the given source range 3685 * Return the node that was found that corresponds to the given source range
3686 * or `null` if there is no such node. 3686 * or `null` if there is no such node.
3687 */ 3687 */
3688 AstNode get foundNode => _foundNode; 3688 AstNode get foundNode => _foundNode;
3689 3689
3690 /** 3690 /**
3691 * Search within the given AST [node] for an identifier representing an 3691 * Search within the given AST [node] for an identifier representing an
3692 * element in the specified source range. Return the element that was found, 3692 * element in the specified source range. Return the element that was found,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3776 3776
3777 /** 3777 /**
3778 * Initialize a newly created locator to locate the deepest [AstNode] for 3778 * Initialize a newly created locator to locate the deepest [AstNode] for
3779 * which `node.offset <= [startOffset]` and `[endOffset] < node.end`. 3779 * which `node.offset <= [startOffset]` and `[endOffset] < node.end`.
3780 * 3780 *
3781 * If [endOffset] is not provided, then it is considered the same as the 3781 * If [endOffset] is not provided, then it is considered the same as the
3782 * given [startOffset]. 3782 * given [startOffset].
3783 */ 3783 */
3784 NodeLocator2(int startOffset, [int endOffset]) 3784 NodeLocator2(int startOffset, [int endOffset])
3785 : this._startOffset = startOffset, 3785 : this._startOffset = startOffset,
3786 this._endOffset = endOffset == null ? startOffset : endOffset; 3786 this._endOffset = endOffset ?? startOffset;
3787 3787
3788 /** 3788 /**
3789 * Search within the given AST [node] and return the node that was found, 3789 * Search within the given AST [node] and return the node that was found,
3790 * or `null` if no node was found. 3790 * or `null` if no node was found.
3791 */ 3791 */
3792 AstNode searchWithin(AstNode node) { 3792 AstNode searchWithin(AstNode node) {
3793 if (node == null) { 3793 if (node == null) {
3794 return null; 3794 return null;
3795 } 3795 }
3796 try { 3796 try {
(...skipping 3986 matching lines...) Expand 10 before | Expand all | Expand 10 after
7783 * Safely visit the given [token], printing the [suffix] after the token if it 7783 * Safely visit the given [token], printing the [suffix] after the token if it
7784 * is non-`null`. 7784 * is non-`null`.
7785 */ 7785 */
7786 void _visitTokenWithSuffix(Token token, String suffix) { 7786 void _visitTokenWithSuffix(Token token, String suffix) {
7787 if (token != null) { 7787 if (token != null) {
7788 _writer.print(token.lexeme); 7788 _writer.print(token.lexeme);
7789 _writer.print(suffix); 7789 _writer.print(suffix);
7790 } 7790 }
7791 } 7791 }
7792 } 7792 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/dart/constant/evaluation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698