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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/actions/NewSelectionConverter.java

Issue 84663003: Issue 4497. Show the best known type in the text hover. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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.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);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698