Skip to content

Commit f031ba9

Browse files
committed
Rename getNodeAtLineAndColumn -> getNodeAtPosition
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 420dd2c commit f031ba9

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

src/main/java/nextflow/lsp/ast/ASTNodeCache.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,12 @@ public URI getURI(ASTNode node) {
274274
}
275275

276276
/**
277-
* Get the most specific ast node at a given location in a file.
277+
* Get the most specific ast node at a given position in a file.
278278
*
279279
* @param uri
280-
* @param line
281-
* @param column
280+
* @param position
282281
*/
283-
public ASTNode getNodeAtLineAndColumn(URI uri, int line, int column) {
284-
var position = new Position(line, column);
282+
public ASTNode getNodeAtPosition(URI uri, Position position) {
285283
var nodeToRange = new HashMap<ASTNode, Range>();
286284
var nodes = nodesByURI.get(uri);
287285
if( nodes == null )
@@ -321,14 +319,13 @@ public ASTNode getNodeAtLineAndColumn(URI uri, int line, int column) {
321319
}
322320

323321
/**
324-
* Get the tree of nodes at a given location in a file.
322+
* Get the tree of nodes at a given position in a file.
325323
*
326324
* @param uri
327-
* @param line
328-
* @param column
325+
* @param position
329326
*/
330-
public List<ASTNode> getNodesAtLineAndColumn(URI uri, int line, int column) {
331-
var offsetNode = getNodeAtLineAndColumn(uri, line, column);
327+
public List<ASTNode> getNodesAtPosition(URI uri, Position position) {
328+
var offsetNode = getNodeAtPosition(uri, position);
332329
var result = new ArrayList<ASTNode>();
333330
ASTNode current = offsetNode;
334331
while( current != null ) {

src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Either<List<CompletionItem>, CompletionList> completion(TextDocumentIdent
7373
if( !ast.hasAST(uri) )
7474
return Either.forLeft(Collections.emptyList());
7575

76-
var nodeStack = ast.getNodesAtLineAndColumn(uri, position.getLine(), position.getCharacter());
76+
var nodeStack = ast.getNodesAtPosition(uri, position);
7777
if( nodeStack.isEmpty() )
7878
return Either.forLeft(TOPLEVEL_ITEMS);
7979

src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Hover hover(TextDocumentIdentifier textDocument, Position position) {
6363
}
6464

6565
var uri = URI.create(textDocument.getUri());
66-
var nodeStack = ast.getNodesAtLineAndColumn(uri, position.getLine(), position.getCharacter());
66+
var nodeStack = ast.getNodesAtPosition(uri, position);
6767
if( nodeStack.isEmpty() )
6868
return null;
6969

src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public List<CallHierarchyItem> prepare(TextDocumentIdentifier textDocument, Posi
7474
}
7575

7676
var uri = URI.create(textDocument.getUri());
77-
var offsetNode = asMethodOrCallX(ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()));
77+
var offsetNode = asMethodOrCallX(ast.getNodeAtPosition(uri, position));
7878
if( offsetNode == null )
7979
return Collections.emptyList();
8080

@@ -120,7 +120,7 @@ public List<CallHierarchyIncomingCall> incomingCalls(CallHierarchyItem item) {
120120

121121
var uri = URI.create(item.getUri());
122122
var position = item.getRange().getStart();
123-
var offsetNode = ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter());
123+
var offsetNode = ast.getNodeAtPosition(uri, position);
124124
if( offsetNode == null )
125125
return Collections.emptyList();
126126

@@ -178,7 +178,7 @@ public List<CallHierarchyOutgoingCall> outgoingCalls(CallHierarchyItem item) {
178178

179179
var uri = URI.create(item.getUri());
180180
var position = item.getRange().getStart();
181-
var offsetNode = ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter());
181+
var offsetNode = ast.getNodeAtPosition(uri, position);
182182
if( offsetNode == null )
183183
return Collections.emptyList();
184184

src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Either<List<CompletionItem>, CompletionList> completion(TextDocumentIdent
110110
if( !ast.hasAST(uri) )
111111
return Either.forLeft(Collections.emptyList());
112112

113-
var nodeStack = ast.getNodesAtLineAndColumn(uri, position.getLine(), position.getCharacter());
113+
var nodeStack = ast.getNodesAtPosition(uri, position);
114114
if( nodeStack.isEmpty() )
115115
return Either.forLeft(DECLARATION_SNIPPETS);
116116

src/main/java/nextflow/lsp/services/script/ScriptDefinitionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Either<List<? extends Location>, List<? extends LocationLink>> definition
5252
}
5353

5454
var uri = URI.create(textDocument.getUri());
55-
var offsetNode = ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter());
55+
var offsetNode = ast.getNodeAtPosition(uri, position);
5656
if( offsetNode == null )
5757
return Either.forLeft(Collections.emptyList());
5858

src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Hover hover(TextDocumentIdentifier textDocument, Position position) {
6363
}
6464

6565
var uri = URI.create(textDocument.getUri());
66-
var nodeStack = ast.getNodesAtLineAndColumn(uri, position.getLine(), position.getCharacter());
66+
var nodeStack = ast.getNodesAtPosition(uri, position);
6767
if( nodeStack.isEmpty() )
6868
return null;
6969

src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public List<? extends Location> references(TextDocumentIdentifier textDocument,
6262
}
6363

6464
var uri = URI.create(textDocument.getUri());
65-
var offsetNode = ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter());
65+
var offsetNode = ast.getNodeAtPosition(uri, position);
6666
if( offsetNode == null )
6767
return Collections.emptyList();
6868

@@ -96,7 +96,7 @@ public WorkspaceEdit rename(TextDocumentIdentifier textDocument, Position positi
9696
}
9797

9898
var uri = URI.create(textDocument.getUri());
99-
var offsetNode = ast.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter());
99+
var offsetNode = ast.getNodeAtPosition(uri, position);
100100
if( offsetNode == null )
101101
return null;
102102

0 commit comments

Comments
 (0)