File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 22
33import abc
44from dataclasses import dataclass
5+ from pathlib import Path
56
67from sqlmesh .core .model import Model
78
@@ -43,6 +44,7 @@ class Range:
4344class TextEdit :
4445 """A text edit to apply to a file."""
4546
47+ path : Path
4648 range : Range
4749 new_text : str
4850
Original file line number Diff line number Diff line change @@ -53,12 +53,16 @@ def _create_fixes(
5353 columns = model .columns_to_types
5454 if not columns :
5555 return None
56+ path = model ._path
57+ if path is None :
58+ return None
5659 new_text = ", " .join (columns .keys ())
5760 return [
5861 Fix (
5962 title = "Replace SELECT * with explicit column list" ,
6063 edits = [
6164 TextEdit (
65+ path = path ,
6266 range = violation_range ,
6367 new_text = new_text ,
6468 )
Original file line number Diff line number Diff line change @@ -274,9 +274,13 @@ def get_code_actions(
274274 # Create code actions for each fix
275275 for fix in found_violation .fixes :
276276 # Convert our Fix to LSP TextEdits
277- text_edits = []
277+ changes : t . Dict [ str , t . List [ types . TextEdit ]] = {}
278278 for edit in fix .edits :
279- text_edits .append (
279+ uri_key = URI .from_path (edit .path ).value
280+ if uri_key not in changes :
281+ changes [uri_key ] = []
282+ # Create a TextEdit for the LSP
283+ changes [uri_key ].append (
280284 types .TextEdit (
281285 range = types .Range (
282286 start = types .Position (
@@ -297,7 +301,7 @@ def get_code_actions(
297301 title = fix .title ,
298302 kind = types .CodeActionKind .QuickFix ,
299303 diagnostics = [diagnostic ],
300- edit = types .WorkspaceEdit (changes = { params . text_document . uri : text_edits } ),
304+ edit = types .WorkspaceEdit (changes = changes ),
301305 )
302306 code_actions .append (code_action )
303307
You can’t perform that action at this time.
0 commit comments