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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java

Issue 932423002: Issue 17356. Apply selection returned from formatter to the SourceViewer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/formatter/DartFormatter.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java
index 91215baf8480ad1bd561b19bc80560ee5c87c40a..87361cb0773836f75396d3ec286645dbdc26ac81 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/editor/DartEditor.java
@@ -751,20 +751,32 @@ public abstract class DartEditor extends AbstractDecoratedTextEditor implements
console.println("Formatting " + file.getName() + " ...");
}
- final IDocument document = getSourceViewer().getDocument();
+ final ISourceViewer sourceViewer = getSourceViewer();
+ final IDocument document = sourceViewer.getDocument();
try {
- final Point[] selection = new Point[1];
+ final Point initialSelection = new Point(-1, 0);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- selection[0] = getSourceViewer().getSelectedRange();
+ Point selection = sourceViewer.getSelectedRange();
+ initialSelection.x = selection.x;
+ initialSelection.y = selection.y;
}
});
if (DartFormatter.isDartStyleEnabled()) {
- DartFormatter.DartStyleRunner.formatFile(file, selection[0], monitor);
+ final Point newSelection = DartFormatter.DartStyleRunner.formatFile(
+ file,
+ initialSelection,
+ monitor);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ sourceViewer.setSelectedRange(newSelection.x, newSelection.y);
+ }
+ });
return Status.OK_STATUS;
}
@@ -772,7 +784,7 @@ public abstract class DartEditor extends AbstractDecoratedTextEditor implements
final FormattedSource formatResult = DartFormatter.format(
unformattedSource,
- selection[0],
+ initialSelection,
monitor);
Display.getDefault().syncExec(new Runnable() {
@@ -784,10 +796,10 @@ public abstract class DartEditor extends AbstractDecoratedTextEditor implements
formatResult.changeOffset,
formatResult.changeLength,
formatResult.changeReplacement);
- getSourceViewer().revealRange(
+ sourceViewer.revealRange(
formatResult.selectionOffset,
formatResult.selectionLength);
- getSourceViewer().setSelectedRange(
+ sourceViewer.setSelectedRange(
formatResult.selectionOffset,
formatResult.selectionLength);
} catch (BadLocationException e) {
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/formatter/DartFormatter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698