| OLD | NEW |
| 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.index.store.codec; | 5 library services.src.index.store.codec; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/index/store/collection.dart'; | 10 import 'package:analysis_server/src/services/index/store/collection.dart'; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } else { | 196 } else { |
| 197 firstComponent = 'null'; | 197 firstComponent = 'null'; |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 String lastComponent = element.displayName; | 200 String lastComponent = element.displayName; |
| 201 int firstId = _stringCodec.encode(firstComponent); | 201 int firstId = _stringCodec.encode(firstComponent); |
| 202 int lastId = _stringCodec.encode(lastComponent); | 202 int lastId = _stringCodec.encode(lastComponent); |
| 203 return <int>[firstId, lastId]; | 203 return <int>[firstId, lastId]; |
| 204 } | 204 } |
| 205 | 205 |
| 206 static String _getComponentUnit(Element element) { | |
| 207 LibraryElement libraryElement = element.library; | |
| 208 if (libraryElement == null) { | |
| 209 return 'null'; | |
| 210 } | |
| 211 return libraryElement.definingCompilationUnit.source.fullName; | |
| 212 } | |
| 213 | |
| 214 static bool _hasLocalOffset(List<String> components) { | 206 static bool _hasLocalOffset(List<String> components) { |
| 215 for (String component in components) { | 207 for (String component in components) { |
| 216 if (component.indexOf('@') != -1) { | 208 if (component.indexOf('@') != -1) { |
| 217 return true; | 209 return true; |
| 218 } | 210 } |
| 219 } | 211 } |
| 220 return false; | 212 return false; |
| 221 } | 213 } |
| 222 | |
| 223 static String _substringBeforeAt(String str) { | |
| 224 int atOffset = str.indexOf('@'); | |
| 225 if (atOffset != -1) { | |
| 226 str = str.substring(0, atOffset); | |
| 227 } | |
| 228 return str; | |
| 229 } | |
| 230 } | 214 } |
| 231 | 215 |
| 232 | 216 |
| 233 /** | 217 /** |
| 234 * A helper that encodes/decodes [Relationship]s to/from integers. | 218 * A helper that encodes/decodes [Relationship]s to/from integers. |
| 235 */ | 219 */ |
| 236 class RelationshipCodec { | 220 class RelationshipCodec { |
| 237 final StringCodec _stringCodec; | 221 final StringCodec _stringCodec; |
| 238 | 222 |
| 239 RelationshipCodec(this._stringCodec); | 223 RelationshipCodec(this._stringCodec); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 int encode(String name) { | 259 int encode(String name) { |
| 276 int index = nameToIndex[name]; | 260 int index = nameToIndex[name]; |
| 277 if (index == null) { | 261 if (index == null) { |
| 278 index = _indexToName.length; | 262 index = _indexToName.length; |
| 279 nameToIndex[name] = index; | 263 nameToIndex[name] = index; |
| 280 _indexToName.add(name); | 264 _indexToName.add(name); |
| 281 } | 265 } |
| 282 return index; | 266 return index; |
| 283 } | 267 } |
| 284 } | 268 } |
| OLD | NEW |