20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/syntax_check/javascript.rb', line 20
def check(*args)
path = manifest_path(doc)
name = File.basename(path)
if t = JavaScript.thread and t.alive?
if t[:doc] and t[:doc] == doc
t.exit
SyntaxCheck.remove_syntax_error_annotations(doc.edit_view)
end
end
JavaScript.thread=Thread.new do
SyntaxCheck.remove_syntax_error_annotations(doc.edit_view)
Thread.current[:doc] = doc
begin
output = `java -cp #{rhino_path} #{main_method} #{jslint_path} #{path}`
output.each_line do |line|
if line =~ /Lint at line (\d+) character (\d+): (.*)/
SyntaxCheck::Error.new(doc, $1.to_i-1, $3).annotate
sleep 1
end
end
rescue Object => e
SyntaxCheck.message(
"An error occurred while parsing #{name}: #{e.message}",:error)
end
end
end
|