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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java

Issue 574573002: Add SourceFileEdit.time field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java
index fda7f0bd81ea25c82e5224fea9b790d455a2a048..6c4ba02244fea0303997740c67b0fe232f6627ab 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceFileEdit.java
@@ -49,6 +49,12 @@ public class SourceFileEdit {
private final String file;
/**
+ * The time in milliseconds since the "Unix epoch" when this change was created. The client may use
+ * it to make sure that the file was not changed since then, so it is safe to apply the change.
+ */
+ private final int time;
+
+ /**
* A list of the edits used to effect the change.
*/
private final List<SourceEdit> edits;
@@ -56,8 +62,9 @@ public class SourceFileEdit {
/**
* Constructor for {@link SourceFileEdit}.
*/
- public SourceFileEdit(String file, List<SourceEdit> edits) {
+ public SourceFileEdit(String file, int time, List<SourceEdit> edits) {
this.file = file;
+ this.time = time;
this.edits = edits;
}
@@ -67,6 +74,7 @@ public class SourceFileEdit {
SourceFileEdit other = (SourceFileEdit) obj;
return
ObjectUtilities.equals(other.file, file) &&
+ other.time == time &&
ObjectUtilities.equals(other.edits, edits);
}
return false;
@@ -74,8 +82,9 @@ public class SourceFileEdit {
public static SourceFileEdit fromJson(JsonObject jsonObject) {
String file = jsonObject.get("file").getAsString();
+ int time = jsonObject.get("time").getAsInt();
List<SourceEdit> edits = SourceEdit.fromJsonArray(jsonObject.get("edits").getAsJsonArray());
- return new SourceFileEdit(file, edits);
+ return new SourceFileEdit(file, time, edits);
}
public static List<SourceFileEdit> fromJsonArray(JsonArray jsonArray) {
@@ -104,10 +113,19 @@ public class SourceFileEdit {
return file;
}
+ /**
+ * The time in milliseconds since the "Unix epoch" when this change was created. The client may use
+ * it to make sure that the file was not changed since then, so it is safe to apply the change.
+ */
+ public int getTime() {
+ return time;
+ }
+
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(file);
+ builder.append(time);
builder.append(edits);
return builder.toHashCode();
}
@@ -115,6 +133,7 @@ public class SourceFileEdit {
public JsonObject toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("file", file);
+ jsonObject.addProperty("time", time);
JsonArray jsonArrayEdits = new JsonArray();
for(SourceEdit elt : edits) {
jsonArrayEdits.add(elt.toJson());
@@ -129,6 +148,8 @@ public class SourceFileEdit {
builder.append("[");
builder.append("file=");
builder.append(file + ", ");
+ builder.append("time=");
+ builder.append(time + ", ");
builder.append("edits=");
builder.append(StringUtils.join(edits, ", "));
builder.append("]");

Powered by Google App Engine
This is Rietveld 408576698