Skip to content

Commit 3924b15

Browse files
committed
Remove ElementLocator.locateWithOffset altogether.
It was needed only for the old Angular implementation support, which overlayed its own Element subclasses into normal Dart AST, for example for string literals - names of components. As we don't support this anymore, there is no need for the method. [email protected] BUG= Review URL: https://codereview.chromium.org//1370833002 .
1 parent 98340f7 commit 3924b15

File tree

5 files changed

+5
-37
lines changed

5 files changed

+5
-37
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,15 @@ class AnalysisServer {
556556
*/
557557
List<Element> getElementsAtOffset(String file, int offset) {
558558
List<AstNode> nodes = getNodesAtOffset(file, offset);
559-
return getElementsOfNodes(nodes, offset);
559+
return getElementsOfNodes(nodes);
560560
}
561561

562562
/**
563563
* Returns [Element]s of the given [nodes].
564564
*
565565
* May be empty if not resolved, but not `null`.
566566
*/
567-
List<Element> getElementsOfNodes(List<AstNode> nodes, int offset) {
567+
List<Element> getElementsOfNodes(List<AstNode> nodes) {
568568
List<Element> elements = <Element>[];
569569
for (AstNode node in nodes) {
570570
if (node is SimpleIdentifier && node.parent is LibraryIdentifier) {
@@ -573,7 +573,7 @@ class AnalysisServer {
573573
if (node is LibraryIdentifier) {
574574
node = node.parent;
575575
}
576-
Element element = ElementLocator.locateWithOffset(node, offset);
576+
Element element = ElementLocator.locate(node);
577577
if (node is SimpleIdentifier && element is PrefixElement) {
578578
element = getImportElement(node);
579579
}

pkg/analysis_server/lib/src/computer/computer_hover.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class DartUnitHoverComputer {
8383
HoverInformation hover =
8484
new HoverInformation(expression.offset, expression.length);
8585
// element
86-
Element element = ElementLocator.locateWithOffset(expression, _offset);
86+
Element element = ElementLocator.locate(expression);
8787
if (element != null) {
8888
// variable, if synthetic accessor
8989
if (element is PropertyAccessorElement) {

pkg/analysis_server/lib/src/edit/edit_domain.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class _RefactoringManager {
592592
}
593593
if (kind == RefactoringKind.RENAME) {
594594
List<AstNode> nodes = server.getNodesAtOffset(file, offset);
595-
List<Element> elements = server.getElementsOfNodes(nodes, offset);
595+
List<Element> elements = server.getElementsOfNodes(nodes);
596596
if (nodes.isNotEmpty && elements.isNotEmpty) {
597597
AstNode node = nodes[0];
598598
Element element = elements[0];

pkg/analyzer/lib/src/generated/ast.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6509,25 +6509,6 @@ class ElementLocator {
65096509
ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper();
65106510
return node.accept(mapper);
65116511
}
6512-
6513-
/**
6514-
* Return the element associated with the given [node], or `null` if there is
6515-
* no element associated with the node.
6516-
*/
6517-
static Element locateWithOffset(AstNode node, int offset) {
6518-
// TODO(brianwilkerson) 'offset' is not used. Figure out what's going on:
6519-
// whether there's a bug or whether this method is unnecessary.
6520-
if (node == null) {
6521-
return null;
6522-
}
6523-
// try to get Element from node
6524-
Element nodeElement = locate(node);
6525-
if (nodeElement != null) {
6526-
return nodeElement;
6527-
}
6528-
// no Element
6529-
return null;
6530-
}
65316512
}
65326513

65336514
/**

pkg/analyzer/test/generated/all_the_rest_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7055,19 +7055,6 @@ core.int value;''');
70557055
TopLevelVariableElement, element);
70567056
}
70577057

7058-
void test_locateWithOffset_BinaryExpression() {
7059-
AstNode id = _findNodeIn("+", "var x = 3 + 4;");
7060-
Element element = ElementLocator.locateWithOffset(id, 0);
7061-
EngineTestCase.assertInstanceOf(
7062-
(obj) => obj is MethodElement, MethodElement, element);
7063-
}
7064-
7065-
void test_locateWithOffset_StringLiteral() {
7066-
AstNode id = _findNodeIn("abc", "var x = 'abc';");
7067-
Element element = ElementLocator.locateWithOffset(id, 1);
7068-
expect(element, isNull);
7069-
}
7070-
70717058
/**
70727059
* Find the first AST node matching a pattern in the resolved AST for the given source.
70737060
*

0 commit comments

Comments
 (0)