Skip to content

Commit c171749

Browse files
author
Bruce Hauman
committed
cleaning up leftovers for edit locations removal
1 parent 5d3ecbf commit c171749

File tree

4 files changed

+3
-53
lines changed

4 files changed

+3
-53
lines changed

src/clojure_mcp/tools/form_edit/core.clj

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -239,39 +239,6 @@
239239
{:zloc updated-zloc
240240
:similar-matches (:similar-matches find-result)})))))
241241

242-
;; Offset calculation functions for highlighting modified code
243-
244-
(defn row-col->offset
245-
"Convert row and column coordinates to a character offset in a string.
246-
247-
Arguments:
248-
- s: The source string
249-
- target-row: The target row (1-based)
250-
- target-col: The target column (1-based)
251-
252-
Returns the character offset in the string."
253-
[s target-row target-col]
254-
(loop [lines (str/split-lines s)
255-
current-row 1
256-
offset 0]
257-
(if (or (empty? lines) (>= current-row target-row))
258-
(+ offset target-col) ; Add col for 1-based index
259-
(recur (next lines)
260-
(inc current-row)
261-
(+ offset (count (first lines)) 1)))))
262-
263-
(defn zloc-offsets
264-
"Calculate character offsets for a zipper location's start and end positions.
265-
266-
Arguments:
267-
- source-str: The source code string
268-
- positions: A vector of [row col] pairs
269-
270-
Returns a vector of character offsets."
271-
[source-str positions]
272-
(mapv (fn [[row col]] (row-col->offset source-str row col))
273-
positions))
274-
275242
;; Source code formatting
276243

277244
(def default-formatting-options
@@ -604,4 +571,4 @@
604571
(defn find-and-edit-multi-sexp [zloc match-form new-form opts]
605572
(or (find-and-edit-multi-sexp* zloc match-form new-form opts)
606573
(binding [*match-clean* true]
607-
(find-and-edit-multi-sexp* zloc match-form new-form opts))))
574+
(find-and-edit-multi-sexp* zloc match-form new-form opts))))

src/clojure_mcp/tools/form_edit/pipeline.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,7 @@
447447
(cond-> {:operation operation}
448448
replace-all (assoc :all? true)))]
449449
(-> ctx
450-
(assoc ::zloc (:zloc result))
451-
(assoc ::edit-locations (:locations result)))
450+
(assoc ::zloc (:zloc result)))
452451
{::error true
453452
::message (str "Could not find form: " match-form)})
454453
(catch Exception e
@@ -498,4 +497,4 @@
498497
ctx
499498
(-> ctx
500499
save-file
501-
update-file-timestamp))))))
500+
update-file-timestamp))))))

src/clojure_mcp/tools/unified_clojure_edit/core.clj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44
without any MCP-specific code."
55
(:require
66
[clojure-mcp.sexp.match :as match]
7-
[clojure-mcp.tools.form-edit.core :as form-edit]
87
[rewrite-clj.zip :as z]
98
[rewrite-clj.parser :as p]))
109

11-
;; Re-export common utilities from form-edit.core
12-
(def format-source-string form-edit/format-source-string)
13-
(def load-file-content form-edit/load-file-content)
14-
(def save-file-content form-edit/save-file-content)
15-
(def zloc-offsets form-edit/zloc-offsets)
16-
1710
(defn find-pattern-match
1811
"Finds a pattern match in Clojure source code.
1912

test/clojure_mcp/tools/form_edit/core_test.clj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,6 @@
420420
(is (= :list (z/tag defn-zloc)))
421421
(is (str/includes? (z/string defn-zloc) "defn test")))))
422422

423-
(deftest row-col-offset-test
424-
(testing "row-col->offset correctly calculates character offsets"
425-
(let [source "Line 1\nLine 2\nLine 3"]
426-
(is (= 0 (sut/row-col->offset source 1 0)))
427-
(is (= 3 (sut/row-col->offset source 1 3)))
428-
(is (= 7 (sut/row-col->offset source 2 0)))
429-
(is (= 10 (sut/row-col->offset source 2 3)))
430-
(is (= 14 (sut/row-col->offset source 3 0))))))
431-
432423
(deftest format-source-string-test
433424
(testing "format-source-string correctly formats source code"
434425
(let [unformatted "(defn example-fn[x y] (+ x y) )"

0 commit comments

Comments
 (0)