mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
command should work, but doesnt in editor
This commit is contained in:
parent
9f240e1150
commit
7169fbb709
1 changed files with 10 additions and 15 deletions
|
@ -220,8 +220,8 @@ class LanguageServer:
|
||||||
property with type Widget, the id of the source widget in a property
|
property with type Widget, the id of the source widget in a property
|
||||||
binding, ...)"""
|
binding, ...)"""
|
||||||
open_file = self._open_files[params["textDocument"]["uri"]]
|
open_file = self._open_files[params["textDocument"]["uri"]]
|
||||||
# TODO: request only has a start Position of the reference id. how to get the end Position to get id string??
|
span_start = utils.pos_to_idx(params["position"]["line"], params["position"]["character"], open_file.text)
|
||||||
# obj_id = open_file.text[utils.pos_to_idx(params["position"]["line"], params["position"]["character"], open_file.text):].split()[0]
|
obj_id = str(tokenizer._tokenize(open_file.text[span_start:]))
|
||||||
|
|
||||||
full_range = {
|
full_range = {
|
||||||
"start": { "line": 0, "character": 0 },
|
"start": { "line": 0, "character": 0 },
|
||||||
|
@ -232,29 +232,24 @@ class LanguageServer:
|
||||||
# "end": { "line": 0, "character": 0 },
|
# "end": { "line": 0, "character": 0 },
|
||||||
# }
|
# }
|
||||||
for obj in open_file.ast.objects_by_id():
|
for obj in open_file.ast.objects_by_id():
|
||||||
# TODO: how to get the token's string representation?
|
if str(obj.tokens["id"]) == obj_id:
|
||||||
if obj.tokens["id"] == obj_id:
|
|
||||||
# TODO: get span of widget class and span of closing }
|
|
||||||
tokens = list(obj.get_semantic_tokens())
|
tokens = list(obj.get_semantic_tokens())
|
||||||
|
|
||||||
# Gets the first token of the widget object
|
# Full range starts at the position of the first token of the widget
|
||||||
position = utils.idx_to_pos(tokens[0], open_file.text)
|
position = utils.idx_to_pos(tokens[0].start, open_file.text)
|
||||||
full_range["start"]["line"] = position[0]
|
full_range["start"]["line"] = position[0]
|
||||||
full_range["start"]["character"] = position[1]
|
full_range["start"]["character"] = position[1]
|
||||||
|
|
||||||
# Goes through all the tokens (starting from the 2nd) of the widget object
|
# Goes through all the tokens (starting from the 2nd) of the widget object until ID token
|
||||||
for token in tokens[1:]:
|
for token in tokens[1:]:
|
||||||
position = utils.idx_to_pos(obj.get_semantic_tokens(), open_file.text)
|
if str(token) == obj_id:
|
||||||
full_range["end"]["line"] = position[0]
|
position = utils.idx_to_pos(token.start, open_file.text)
|
||||||
full_range["end"]["character"] = position[1] # + len(token)
|
|
||||||
|
|
||||||
# TODO: how to get the token's string representation?
|
|
||||||
if token == obj_id and id_range == None:
|
|
||||||
id_range = {
|
id_range = {
|
||||||
"start": { "line": position[0], "character": position[1] },
|
"start": { "line": position[0], "character": position[1] },
|
||||||
"end": { "line": position[0], "character": position[1] + len(obj_id) },
|
"end": { "line": position[0], "character": position[1] + len(obj_id) },
|
||||||
}
|
}
|
||||||
|
full_range["end"] = id_range["end"]
|
||||||
|
break
|
||||||
break
|
break
|
||||||
|
|
||||||
if id_range:
|
if id_range:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue