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

Side by Side Diff: pkg/analysis_server/lib/src/protocol_server.dart

Issue 1372673003: Use Element.nameLength where possible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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 protocol.server; 5 library protocol.server;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/search/search_engine.dart' 8 import 'package:analysis_server/src/services/search/search_engine.dart'
9 as engine; 9 as engine;
10 import 'package:analyzer/src/generated/ast.dart' as engine; 10 import 'package:analyzer/src/generated/ast.dart' as engine;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 /** 207 /**
208 * Create a Location based on an [engine.Element]. 208 * Create a Location based on an [engine.Element].
209 */ 209 */
210 Location newLocation_fromElement(engine.Element element) { 210 Location newLocation_fromElement(engine.Element element) {
211 engine.AnalysisContext context = element.context; 211 engine.AnalysisContext context = element.context;
212 engine.Source source = element.source; 212 engine.Source source = element.source;
213 if (context == null || source == null) { 213 if (context == null || source == null) {
214 return null; 214 return null;
215 } 215 }
216 String name = element.displayName;
217 int offset = element.nameOffset; 216 int offset = element.nameOffset;
218 int length = name != null ? name.length : 0; 217 int length = element.nameLength;
219 if (element is engine.CompilationUnitElement) { 218 if (element is engine.CompilationUnitElement) {
220 offset = 0; 219 offset = 0;
221 length = 0; 220 length = 0;
222 } 221 }
223 engine.SourceRange range = new engine.SourceRange(offset, length); 222 engine.SourceRange range = new engine.SourceRange(offset, length);
224 return _locationForArgs(context, source, range); 223 return _locationForArgs(context, source, range);
225 } 224 }
226 225
227 /** 226 /**
228 * Create a Location based on an [engine.SearchMatch]. 227 * Create a Location based on an [engine.SearchMatch].
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (lineInfo != null) { 431 if (lineInfo != null) {
433 engine.LineInfo_Location offsetLocation = 432 engine.LineInfo_Location offsetLocation =
434 lineInfo.getLocation(range.offset); 433 lineInfo.getLocation(range.offset);
435 startLine = offsetLocation.lineNumber; 434 startLine = offsetLocation.lineNumber;
436 startColumn = offsetLocation.columnNumber; 435 startColumn = offsetLocation.columnNumber;
437 } 436 }
438 } 437 }
439 return new Location( 438 return new Location(
440 source.fullName, range.offset, range.length, startLine, startColumn); 439 source.fullName, range.offset, range.length, startLine, startColumn);
441 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698