Skip to content

Commit 32369fe

Browse files
committed
perf(language-server): parse the document once per selection range request
Selection ranges built the model again for every requested position when the document had no version, so a request with many positions parsed the whole file once per position. The model is now taken once per request, which roughly halves the time of the selection range parity tests.
1 parent b76ded2 commit 32369fe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • packages/language_server/src/robotcode/language_server/robotframework/parts

‎packages/language_server/src/robotcode/language_server/robotframework/parts/selection_range.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ def __init__(self, parent: "RobotLanguageServerProtocol") -> None:
3434
def collect(self, sender: Any, document: TextDocument, positions: List[Position]) -> Optional[List[SelectionRange]]:
3535
namespace = self.parent.documents_cache.get_namespace(document)
3636
semantic_model = namespace.semantic_model
37+
model = self.parent.documents_cache.get_model(document)
3738

3839
results: List[SelectionRange] = []
3940
for position in positions:
40-
nodes = get_nodes_at_position(self.parent.documents_cache.get_model(document), position)
41+
nodes = get_nodes_at_position(model, position)
4142

4243
if not nodes:
4344
break

0 commit comments

Comments
 (0)