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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/LocationData.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/LocationData.java (revision 0)
+++ dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/LocationData.java (revision 0)
@@ -0,0 +1,54 @@
+package com.google.dart.engine.internal.index.file;
+
+import com.google.dart.engine.context.AnalysisContext;
+import com.google.dart.engine.element.Element;
+import com.google.dart.engine.index.Location;
+
+/**
+ * A container with information about a {@link Location}.
+ *
+ * @coverage dart.engine.index
+ */
+public class LocationData {
+ final int elementId;
+ final int offset;
+ final int length;
+
+ public LocationData(ElementCodec elementCodec, Location location) {
+ Element element = location.getElement();
+ this.elementId = elementCodec.encode(element);
+ this.offset = location.getOffset();
+ this.length = location.getLength();
+ }
+
+ public LocationData(int elementId, int offset, int length) {
+ this.elementId = elementId;
+ this.offset = offset;
+ this.length = length;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof LocationData)) {
+ return false;
+ }
+ LocationData other = (LocationData) obj;
+ return other.elementId == elementId && other.offset == offset && other.length == length;
+ }
+
+ /**
+ * Returns a {@link Location} that is represented by this {@link LocationData}.
+ */
+ public Location getLocation(AnalysisContext context, ElementCodec elementCodec) {
+ Element element = elementCodec.decode(context, elementId);
+ if (element == null) {
+ return null;
+ }
+ return new Location(element, offset, length);
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * (31 * elementId + offset) + length;
+ }
+}
Property changes on: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/LocationData.java
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698