Compare commits

..

No commits in common. "56fb0982b411bc8a6d877fee70857f36ad16f0ca" and "82d6ce586b8ee0c89d654504a34799f56730aba9" have entirely different histories.

2 changed files with 6 additions and 42 deletions

View File

@ -2,11 +2,10 @@ example = nil
example2 = example
; func2(g_arg1 g_arg2 ?g_args1 1 ?g_argw 2) => nil
(procedure func2(arg1 arg2 @key (args 1) (argw 2) "ggng")
(procedure func2(arg1 arg2 @key (args 1) (argw 2) "gggg")
; some stuff to do
a = some_obj->field1
some_obj->field2 = 2
args = 2
)
(

View File

@ -1,6 +1,5 @@
from collections.abc import Generator
from dataclasses import dataclass, field
from itertools import chain
from logging import INFO, basicConfig, debug, error, getLogger, info, warning
from re import findall, finditer, fullmatch, match as rematch
from time import time
@ -36,7 +35,6 @@ from lsprotocol.types import (
from pygls.server import LanguageServer
from pygls.workspace import TextDocument
from skillls.builtins.common import SkillDataType
from skillls.parsing.iterative import IterativeParser, TokenParser
from .cache import Cache
@ -194,10 +192,7 @@ class SkillLanguageServer(LanguageServer):
def _parse_assigns(self, lines: list[str]) -> None:
for row, line in enumerate(lines):
for found in finditer(
r"\b([a-zA-Z_][a-zA-Z0-9_]*)((-|~)>[a-zA-Z_][a-zA-Z0-9_]*)?\s*=\s+",
line,
):
for found in finditer(r"([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s+", line):
token = found.group(1)
token_range = Range(
Position(row, found.start()),
@ -205,9 +200,9 @@ class SkillLanguageServer(LanguageServer):
)
if any(
in_range(token_range.start, ns.range)
and (token in (child.name for child in (ns.children or [])))
for ns in chain(self.lets, self.procs)
in_range(token_range.start, let.range)
and (token in (child.name for child in (let.children or [])))
for let in self.lets
):
pass
else:
@ -311,13 +306,11 @@ class SkillLanguageServer(LanguageServer):
kwargs: list[DocumentSymbol] = []
rest: list[DocumentSymbol] = []
params_start = found.end() - len(found.group(4))
warning(found.group(4))
for part in finditer(
rf"(@(option|key)(\s\(\w+\s+.+\))+|@rest \w+|\"[{''.join(dt.value for dt in SkillDataType)}]+\"|(\w+\s*))",
r"(@(option|key)(\s\(\w+\s+.+\))+|@rest \w+|(\w+\s*))",
found.group(4),
):
info(part.group(1))
if part.group(1).startswith("@rest"):
rest_var_name = part.group(1).split()[1]
rest_var_range = Range(
@ -366,31 +359,6 @@ class SkillLanguageServer(LanguageServer):
),
)
)
elif fullmatch(
rf'"[{"".join(dt.value for dt in SkillDataType)}]+"',
part.group(1),
):
if not (
len(args) + len(kwargs) + len(rest)
== len(part.group(1)) - 2
):
self.publish_diagnostics(
uri,
[
Diagnostic(
Range(start, Position(row, len(line))),
"type info length mismatches number of arguments",
severity=DiagnosticSeverity.Error,
)
],
)
return
for char, arg in zip(
part.group(1)[1:-1], chain(args, rest, kwargs)
):
typ = SkillDataType(char)
arg.detail = f"{typ.value}_"
break
else:
for arg in finditer(r"(\w+)", part.group(1)):
arg_range = Range(
@ -435,9 +403,6 @@ class SkillLanguageServer(LanguageServer):
for child in proc.children:
yield InlayHint(child.selection_range.end, "|l")
if child.detail:
yield InlayHint(child.selection_range.start, child.detail)
def _hint_globals(self) -> Generator[InlayHint, None, None]:
for glbl in self.globals:
yield InlayHint(glbl.selection_range.end, "|g")