Skip to content

Commit

Permalink
Adding lintserver for files. Start julia, invoke lintserver on a port…
Browse files Browse the repository at this point in the history
… of your choice and then you can use something like, for example (echo filename; sleep 2) | nc -w 2 localhost portfrom bash.
  • Loading branch information
tomaskrehlik committed Feb 8, 2015
1 parent beaf2af commit 531828d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
26 changes: 25 additions & 1 deletion src/Lint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Base.Meta
using Compat

export LintMessage, LintContext, LintStack
export lintfile, lintstr, lintpkg, @lintpragma
export lintfile, lintstr, lintpkg, lintserver, @lintpragma
export test_similarity_string

const SIMILARITY_THRESHOLD = 10.0
Expand Down Expand Up @@ -245,4 +245,28 @@ function lintexpr( ex::Any, ctx::LintContext )
end
end

function lintserver(port)
server = listen(port)
while true
conn = accept(server)
@async begin
try
while true
line = readline(conn)
println(typeof(line))
println(ispath(strip(line)))
println(strip(line))
m = lintfile(strip(line), returnMsgs = true)
for i in m
write(conn, string(i))
write(conn, "\n")
end
end
catch err
print("connection ended with error $err")
end
end
end
end

end
11 changes: 8 additions & 3 deletions src/linttypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type LintMessage
message :: String
end

import Base.show
function Base.show( io::IO, m::LintMessage )
import Base.string
function string( m::LintMessage )
s = @sprintf( "%s:%d ", m.file, m.line )
s = s * @sprintf( "[%-15s] ", m.scope )
arr = [ "INFO", "WARN", "ERROR", "FATAL" ]
Expand All @@ -21,7 +21,12 @@ function Base.show( io::IO, m::LintMessage )
s = s * "\n" * (" " ^ ident) * l
end
end
print( io, s )
return s
end

import Base.show
function Base.show( io::IO, m::LintMessage )
print( io, string(m) )
end

import Base.isless
Expand Down

0 comments on commit 531828d

Please sign in to comment.