Class: MissingParenthesisWarning

Inherits:
TexWarning show all
Defined in:
lib/trex.rb

Instance Attribute Summary

Attributes inherited from TexWarning

#filestate, #limit

Instance Method Summary collapse

Methods inherited from TexWarning

#add_error, #empty?, #expand_input, #format_error, #format_warning_message, #handle, #has_error?, #render_line, #size, #sort, #to_s

Constructor Details

#initialize(source, limits = 10) ⇒ MissingParenthesisWarning

Returns a new instance of MissingParenthesisWarning.



846
847
848
849
850
851
852
# File 'lib/trex.rb', line 846

def initialize(source, limits=10)
    super('Missing Parenthesis',
          /File ended /, /[^! ].*/,
          limits)
    @source = source
    @sourceContents = File.read(source)
end

Instance Method Details

#extract_line(string, index, lines) ⇒ Object



854
855
856
857
858
859
860
861
862
863
864
865
866
# File 'lib/trex.rb', line 854

def extract_line(string, index, lines)
    label = self.format_warning_message(0, string)
    errorSource = Regexp.escape(lines[index - 1].strip()[0..-6])
    errorSource.gsub!('\\ ', '\s*') # make sure we can match newlines
    lineNumbers = []
    matches = @sourceContents.match(errorSource)
    (0..matches.size-1).each { |i|
        to = matches.begin(i)
        linenumber = @sourceContents[0..to].scan("\n").size + 1
        lineNumbers.push(linenumber)
    }
    lineNumbers.join(',')
end