Skip to content

Commit fa377e3

Browse files
committed
misc:
- add @static annotations - more easier testing for "toggle docs"
1 parent 438ae46 commit fa377e3

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/debugger/repl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using REPL.REPLCompletions
44
using JuliaInterpreter: moduleof, locals, eval_code
55
import ..Atom: @msg
66

7-
const normal_prefix = Sys.iswindows() ? "\e[33m" : "\e[38;5;166m"
7+
const normal_prefix = @static Sys.iswindows() ? "\e[33m" : "\e[38;5;166m"
88
const compiled_prefix = "\e[96m"
99

1010
function debugprompt()

src/eval.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ handle("evalall") do data
159159
end
160160

161161
handle("docs") do data
162-
@destruct [mod || "Main", word] = data
162+
@destruct [
163+
word,
164+
mod || "Main"
165+
] = data
166+
docs(word, mod)
167+
end
163168

169+
function docs(word, mod = "Main")
164170
docstring = @errs getdocs(mod, word)
165171
docstring isa EvalError && return Dict(:error => true)
166172

src/outline.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function byteoffset(text, line, col)
271271
c === '\n' && break
272272
end
273273
current_char == col && break
274-
byteoffset += VERSION >= v"1.1" ? ncodeunits(c) : ncodeunits(string(c))
274+
byteoffset += @static VERSION >= v"1.1" ? ncodeunits(c) : ncodeunits(string(c))
275275
c === '\n' && (current_line += 1)
276276
end
277277
byteoffset

src/path_matching.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const uri_regex = if Sys.iswindows()
1+
const uri_regex = @static if Sys.iswindows()
22
r"((?:(?:[a-zA-Z]:|\.\.?|\~)|(?:[^\0<>\?\|\/\s!$`&*()\[\]+'\":;])+)?(?:(?:\\|\/)(?:[^\0<>\?\|\/\s!$`&*()\[\]+'\":;])+)+)(?:\:(\d+))?"
33
else
44
r"((?:(?:\.\.?|\~)|(?:[^\0\s!$`&*()\[\]+'\":;\\])+)?(?:\/(?:[^\0\s!$`&*()\[\]+'\":;\\])+)+)(?:\:(\d+))?"
55
end
66

7-
const buildbot_regex = if Sys.iswindows()
7+
const buildbot_regex = @static if Sys.iswindows()
88
r"C:\\cygwin\home\\Admininstrator\\buildbot\\.*?(\\julia\\stdlib\\.*?\.jl)"
99
else
1010
r"\/buildworker\/worker\/.*?(\/julia\/stdlib\/.*?\.jl)"

test/eval.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
@testset "toggle docs" begin
2-
cb = 0 # callback count
3-
handle(type, word, mod = "Main") =
4-
Atom.handlemsg(Dict("type" => type,
5-
"callback" => (cb += 1)),
6-
Dict("word" => word,
7-
"mod" => mod))
8-
9-
## toggle docs
10-
112
# basic
12-
handle("docs", "push!")
13-
@test !readmsg()[3]["error"]
3+
let doc = Atom.docs("push!")
4+
@test !doc[:error]
5+
end
146

157
# context module
16-
handle("docs", "handlemsg", "Atom")
17-
@test !readmsg()[3]["error"]
8+
let doc = Atom.docs("handle", "Atom")
9+
@test !doc[:error]
10+
end
1811

1912
# keyword
20-
handle("docs", "begin", "Atom")
21-
@test !readmsg()[3]["error"]
13+
let doc = Atom.docs("begin", "Atom")
14+
@test !doc[:error]
15+
end
2216
end

0 commit comments

Comments
 (0)