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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java

Issue 10823372: 'Inline Method' refactoring (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java
index ea6815dc85e19e33490320d587f7be8770af7242..f07c3bd47546936e683ad882892b4f5ec8010015 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/code/ExtractUtils.java
@@ -13,6 +13,7 @@
*/
package com.google.dart.tools.internal.corext.refactoring.code;
+import com.google.common.base.CharMatcher;
import com.google.common.collect.Lists;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartBinaryExpression;
@@ -86,6 +87,18 @@ public class ExtractUtils {
}
/**
+ * @return the line prefix from the given source, i.e. basically just whitespace prefix of the
+ * given {@link String}.
+ */
+ public static String getLinesPrefix(String linesSource) {
+ int index = CharMatcher.WHITESPACE.negate().indexIn(linesSource);
+ if (index == -1) {
+ return linesSource;
+ }
+ return linesSource.substring(0, index);
+ }
+
+ /**
* @return the actual type source of the given {@link DartExpression}, may be <code>null</code> if
* can not be resolved, should be treated as <code>Dynamic</code>.
*/
@@ -427,6 +440,10 @@ public class ExtractUtils {
return getText(range.getOffset(), range.getLength());
}
+ public CompilationUnit getUnit() {
+ return unit;
+ }
+
/**
* @return the resolved {@link DartUnit}.
*/

Powered by Google App Engine
This is Rietveld 408576698