Skip to content

Commit fc3d134

Browse files
Parsing files on active pane change
1 parent 41b76db commit fc3d134

File tree

4 files changed

+22
-35
lines changed

4 files changed

+22
-35
lines changed

Test/Script.fsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
module XA =
22

33
let funky x = x + 1
4-
4+
let foo = 1
55

66
module YA =
7-
let abc = 3
8-
let aaa = XA.funky
9-
7+
let bar = XA.funky
108

9+
let foobar = YA.bar XA.foo
1110

12-
let val99 =
11+
let direct = System.IO.Directory

src/autocomplete/lib/autocomplete-handler.coffee

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class AutocompleteHandler
1313
else
1414
service = new AutocompleteService()
1515
@parsed = []
16+
17+
atom.workspace.onDidChangeActivePaneItem((pane) => @parseEditor(pane, (=> return)))
18+
19+
1620
instance = this
1721

1822
project: (s, callback) ->
@@ -31,13 +35,19 @@ class AutocompleteHandler
3135
parseP: (path) =>
3236
return (callback) => @parse path, callback
3337

38+
parseEditor: (editor, callback) ->
39+
if (editor and editor.getGrammar().name == "F#")
40+
path = editor.buffer.file.path
41+
text = editor.getText()
42+
str = "parse \"" + path + "\"\n" + text + "\n<<EOF>>\n"
43+
service.ask str, 2, callback
44+
else
45+
t = "1"
46+
callback "ERROR"
47+
3448
parseCurrent: (callback) ->
3549
editor = atom.workspace.getActiveTextEditor()
36-
path = editor.buffer.file.path
37-
text = editor.getText()
38-
str = "parse \"" + path + "\"\n" + text + "\n<<EOF>>\n"
39-
service.ask str, 2, callback
40-
50+
@parseEditor(editor, callback)
4151

4252
completion: (fn, line, col, callback) ->
4353
str = "completion \"" + fn + "\" " + line + " " + col + "\n"
@@ -77,4 +87,4 @@ class AutocompleteHandler
7787
service.toggle()
7888
if service.state == "on"
7989
service.send("outputmode json\n")
80-
#@test()
90+
@parseCurrent(=> return)

src/autocomplete/lib/autocomplete-service.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class AutocompleteService
4242
@child.stdin.write msg
4343

4444
ask: (msg, number, callback) =>
45-
#console.log "ASK: " + msg
45+
console.log "ASK: " + msg
4646
@child.stdin.write msg
4747
s = ""
4848
action = (data) =>
4949
s = s + data.toString()
5050
len = s.split(/\r\n|\r|\n/).length - 1
5151
if len == number or s.contains "\"Kind\":\"ERROR\""
52-
#console.log "RECIVED: " + s
52+
console.log "RECIVED: " + s
5353
@child.stdout.removeListener "data", action
5454
callback s
5555

src/autocomplete/lib/autocomplete-view.coffee

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)