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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/formatter/edit/EditRecorder.java

Issue 11316129: Formatter checkpoint. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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.engine/src/com/google/dart/engine/formatter/edit/EditRecorder.java
===================================================================
--- editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/formatter/edit/EditRecorder.java (revision 15190)
+++ editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/formatter/edit/EditRecorder.java (working copy)
@@ -19,6 +19,8 @@
import static com.google.dart.engine.formatter.CodeFormatterOptions.OS_LINE_SEPARATOR;
+import java.util.List;
+
/**
* Records a sequence of edits to a source string that will cause the string to be formatted when
* applied via an {@link EditOperation}.
@@ -142,11 +144,20 @@
*
* @return the sequence of edits
*/
- public Iterable<Edit> getEdits() {
+ public List<Edit> getEdits() {
return editStore.getEdits();
}
/**
+ * Get the current source.
+ *
+ * @return the source
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
* Get the current source index.
*
* @return the sourceIndex
@@ -180,6 +191,9 @@
}
// Otherwise, replace whitespace with a newline.
int charsToReplace = countWhitespace();
+ if (isNewlineAt(sourceIndex + charsToReplace)) {
+ ++charsToReplace;
+ }
addEdit(sourceIndex, charsToReplace, NEW_LINE);
column += NEW_LINE.length();
sourceIndex += charsToReplace;
@@ -217,20 +231,19 @@
*/
public void space() {
// TODO(pquitslund) emit comments
- // If there is a space before the edit location, do nothing.
- if (isSpaceAt(sourceIndex - 1)) {
- return;
- }
- // If there is a space after the edit location, advance over it.
- if (isSpaceAt(sourceIndex)) {
- advance(1);
- return;
- }
+// // If there is a space before the edit location, do nothing.
+// if (isSpaceAt(sourceIndex - 1)) {
+// return;
+// }
+// // If there is a space after the edit location, advance over it.
+// if (isSpaceAt(sourceIndex)) {
+// advance(1);
+// return;
+// }
// Otherwise, replace spaces with a single space.
int charsToReplace = countWhitespace();
addEdit(sourceIndex, charsToReplace, SPACES[0]);
- column += 1;
- sourceIndex += charsToReplace;
+ advance(charsToReplace);
}
/**

Powered by Google App Engine
This is Rietveld 408576698