Skip to content

Commit ca38644

Browse files
committed
executa slurp e valida arquivo
1 parent 6e9c640 commit ca38644

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/test/clojure/com/github/clojure_lsp/intellij/foo_test.clj

+24-15
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
[com.intellij.ide DataManager]
1313
[com.intellij.openapi.actionSystem ActionManager]
1414
[com.intellij.openapi.components ServiceManager]
15-
[com.intellij.openapi.wm WindowManager]
16-
[com.intellij.testFramework EditorTestUtil]))
15+
[com.intellij.openapi.editor LogicalPosition]
16+
[com.intellij.openapi.wm WindowManager]))
1717

1818
(set! *warn-on-reflection* true)
1919

@@ -22,15 +22,6 @@
2222
(let [status-bar (.. (WindowManager/getInstance) (getStatusBar project))]
2323
(.getWidget status-bar widget-id)))
2424

25-
(defn ensure-editor
26-
"Ensure the editor was created in the UI thread"
27-
[project]
28-
(let [repl-content (repl-content project)]
29-
@(app-manager/invoke-later!
30-
{:invoke-fn (fn []
31-
(.addNotify repl-content)
32-
(.getEditor repl-content true))})))
33-
3425
(defn run-editor-action [action-id project]
3526
(let [action (.getAction (ActionManager/getInstance) action-id)
3627
context (.getDataContext (DataManager/getInstance))]
@@ -52,8 +43,7 @@
5243
deps-file (.createFile fixture "deps.edn" "{}")
5344
_ (.setTestDataPath fixture "testdata")
5445
clj-file (.copyFileToProject fixture "foo.clj")
55-
project (.getProject fixture)
56-
editor (.getEditor fixture)]
46+
project (.getProject fixture)]
5747
(is (= project-name (.getName project)))
5848
(is deps-file)
5949

@@ -81,10 +71,29 @@
8171
(println (lsp-client/server-status project))
8272
(println (db/get-in project [:status]))
8373

84-
(println "editor >> ")
85-
(println editor)
74+
(let [editor (.getEditor fixture)
75+
document (.getDocument editor)
76+
offset (.getLineStartOffset document 2)
77+
caret (.getCaretModel editor)
78+
pos (.getLogicalPosition caret)
79+
new-position (LogicalPosition. 2 8)]
80+
(println "editor >> ")
81+
(println editor)
82+
(println caret)
83+
(println pos)
84+
(println (.getVisualPosition caret))
85+
(println (.getText document))
86+
@(app-manager/invoke-later!
87+
{:invoke-fn (fn []
88+
#_(.moveToOffset caret (+ offset 9))
89+
(.moveToLogicalPosition caret new-position))})
90+
(println (.getLogicalPosition caret))
91+
(println (.getVisualPosition caret)))
8692
(run-editor-action "ClojureLSP.ForwardSlurp" project)
8793

94+
(clj4intellij.test/dispatch-all)
95+
(println (-> fixture .getEditor .getDocument .getText))
96+
8897
@(app-manager/invoke-later!
8998
{:invoke-fn (fn []
9099
(let [widget (get-status-bar-widget project "ClojureLSPStatusBar")]

testdata/foo.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(ns foo)
22

3-
(println<caret>) "Oiii"
3+
(println) "Oiii"

0 commit comments

Comments
 (0)