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

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

Issue 2411063002: Issue 27539. Check that the source is not modified between constructor and correction computing. (Closed)
Patch Set: Created 4 years, 2 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/correction/fix_internal.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.src.correction.assist; 5 library services.src.correction.assist;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; 10 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 selectionLength = dartContext.selectionLength; 80 selectionLength = dartContext.selectionLength;
81 selectionEnd = selectionOffset + selectionLength; 81 selectionEnd = selectionOffset + selectionLength;
82 } 82 }
83 83
84 /** 84 /**
85 * Returns the EOL to use for this [CompilationUnit]. 85 * Returns the EOL to use for this [CompilationUnit].
86 */ 86 */
87 String get eol => utils.endOfLine; 87 String get eol => utils.endOfLine;
88 88
89 Future<List<Assist>> compute() async { 89 Future<List<Assist>> compute() async {
90 // If the source was changed between the constructor and running
91 // this asynchronous method, it is not safe to use the unit.
92 if (analysisContext.getModificationStamp(source) != fileStamp) {
93 return const <Assist>[];
94 }
95
90 try { 96 try {
91 utils = new CorrectionUtils(unit); 97 utils = new CorrectionUtils(unit);
92 } catch (e) { 98 } catch (e) {
93 throw new CancelCorrectionException(exception: e); 99 throw new CancelCorrectionException(exception: e);
94 } 100 }
95 101
96 node = new NodeLocator(selectionOffset, selectionEnd).searchWithin(unit); 102 node = new NodeLocator(selectionOffset, selectionEnd).searchWithin(unit);
97 if (node == null) { 103 if (node == null) {
98 return assists; 104 return assists;
99 } 105 }
(...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 class _SimpleIdentifierRecursiveAstVisitor extends RecursiveAstVisitor { 2263 class _SimpleIdentifierRecursiveAstVisitor extends RecursiveAstVisitor {
2258 final _SimpleIdentifierVisitor visitor; 2264 final _SimpleIdentifierVisitor visitor;
2259 2265
2260 _SimpleIdentifierRecursiveAstVisitor(this.visitor); 2266 _SimpleIdentifierRecursiveAstVisitor(this.visitor);
2261 2267
2262 @override 2268 @override
2263 visitSimpleIdentifier(SimpleIdentifier node) { 2269 visitSimpleIdentifier(SimpleIdentifier node) {
2264 visitor(node); 2270 visitor(node);
2265 } 2271 }
2266 } 2272 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/fix_internal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698