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

Side by Side Diff: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/LocationData.java

Issue 371913004: Version 1.5.6 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.5/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 package com.google.dart.engine.internal.index.file;
2
3 import com.google.dart.engine.context.AnalysisContext;
4 import com.google.dart.engine.element.Element;
5 import com.google.dart.engine.index.Location;
6
7 /**
8 * A container with information about a {@link Location}.
9 *
10 * @coverage dart.engine.index
11 */
12 public class LocationData {
13 final int elementId;
14 final int offset;
15 final int length;
16
17 public LocationData(ElementCodec elementCodec, Location location) {
18 Element element = location.getElement();
19 this.elementId = elementCodec.encode(element);
20 this.offset = location.getOffset();
21 this.length = location.getLength();
22 }
23
24 public LocationData(int elementId, int offset, int length) {
25 this.elementId = elementId;
26 this.offset = offset;
27 this.length = length;
28 }
29
30 @Override
31 public boolean equals(Object obj) {
32 if (!(obj instanceof LocationData)) {
33 return false;
34 }
35 LocationData other = (LocationData) obj;
36 return other.elementId == elementId && other.offset == offset && other.lengt h == length;
37 }
38
39 /**
40 * Returns a {@link Location} that is represented by this {@link LocationData} .
41 */
42 public Location getLocation(AnalysisContext context, ElementCodec elementCodec ) {
43 Element element = elementCodec.decode(context, elementId);
44 if (element == null) {
45 return null;
46 }
47 return new Location(element, offset, length);
48 }
49
50 @Override
51 public int hashCode() {
52 return 31 * (31 * elementId + offset) + length;
53 }
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698