sqlakit-lsp 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlakit-lsp
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: The language server for SQLAKit templates.
5
5
  Keywords: sqlalchemy,sqlakit,lsp,language-server,sql
6
6
  Author: Anton Ruhlov
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlakit-lsp"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "The language server for SQLAKit templates."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlakit-lsp"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  description = "The language server for SQLAKit templates."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -973,12 +973,24 @@ class _Assistant:
973
973
  continue
974
974
  names = alone.parameters()
975
975
  given = _rendered(alone, dialect, dict.fromkeys(names, _Example()))
976
- if names and given in (None, text.strip()):
976
+ if names and self._kept(given, call.name):
977
977
  missing = _rendered(alone, dialect, dict.fromkeys(names))
978
- if missing not in (None, text.strip()):
978
+ if not self._kept(missing, call.name):
979
979
  found.update(names)
980
980
  return found
981
981
 
982
+ def _kept(self, sql: str | None, macro: str) -> bool:
983
+ """Whether a call rendered alone could not be made, and wrote itself.
984
+
985
+ It writes itself on one line, whatever lines it was written on.
986
+ """
987
+ if sql is None:
988
+ return True
989
+ namespace = re.escape(self.project.templates.namespace)
990
+ return bool(
991
+ re.match(rf"{namespace}\.{re.escape(macro)}\s*\(", sql, re.IGNORECASE)
992
+ )
993
+
982
994
  def holds_macros(self, path: Path) -> bool:
983
995
  """Whether a file defines macros: SQL macros, or the SQL of a file macro."""
984
996
  return self._reads_macros(path) or path.resolve() in self._macro_sql
@@ -1061,7 +1073,7 @@ class _Assistant:
1061
1073
  missing = _rendered(alone, dialect, dict.fromkeys(names))
1062
1074
  # A call that cannot be made writes itself, which says nothing new.
1063
1075
  given, missing = (
1064
- None if one == text.strip() else one for one in (given, missing)
1076
+ None if self._kept(one, call.name) else one for one in (given, missing)
1065
1077
  )
1066
1078
  if not names or given == missing:
1067
1079
  one = given or missing
File without changes
File without changes