Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java |
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java |
index 4e372b26e19e1d26b988c2538a75e8f813e16e6e..a08ce9a66d223e23ec2fe04e137a28339441128e 100644 |
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java |
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java |
@@ -58,13 +58,7 @@ public class NewSelectionConverter { |
* @return the associated element |
*/ |
public static Element getElementAtOffset(DartEditor editor, int caret) { |
- |
- CompilationUnit cu = editor.getInputUnit(); |
- if (cu == null) { |
- return null; |
- } |
- |
- ASTNode node = new NodeLocator(caret).searchWithin(cu); |
+ ASTNode node = getNodeAtOffset(editor, caret); |
if (node == null) { |
return null; |
} |
@@ -172,4 +166,19 @@ public class NewSelectionConverter { |
}); |
return result[0]; |
} |
+ |
+ /** |
+ * Get the {@link ASTNode} associated with the selected portion of the given editor. |
+ * |
+ * @param editor the editor |
+ * @param caret the caret position in the editor |
+ * @return the associated {@link ASTNode} |
+ */ |
+ public static ASTNode getNodeAtOffset(DartEditor editor, int caret) { |
+ CompilationUnit cu = editor.getInputUnit(); |
+ if (cu == null) { |
+ return null; |
+ } |
+ return new NodeLocator(caret).searchWithin(cu); |
+ } |
} |