Sha256: 3041d83893796f91585b1e637c6b6cda9e3246601f8c1beb1b7a145a7c775dff

Contents?: true

Size: 1.94 KB

Versions: 61

Compression:

Stored size: 1.94 KB

Contents

module Bake

  class ErrorDesc
    def initialize
      @severity = 255
    end
    attr_accessor :severity
    attr_accessor :line_number
    attr_accessor :message
    attr_accessor :file_name
  end

  class ErrorParser

    SEVERITY_INFO = 0
    SEVERITY_WARNING = 1
    SEVERITY_ERROR = 2
    SEVERITY_OK = 255

    def scan(consoleOutput, proj_dir)
      raise "Use specialized classes only"
    end

    def get_severity(str)
      if str.downcase == "info" || str.downcase == "note"
        SEVERITY_INFO
      elsif str.downcase == "warning"
        SEVERITY_WARNING
      else
        SEVERITY_ERROR
      end
    end

    def get_tasking_severity(str)
      return SEVERITY_INFO if str.start_with?"R"
      return SEVERITY_WARNING if str.start_with?"W"
      return SEVERITY_ERROR  # F,E and S
    end

    def inv_severity(s)
      if s == SEVERITY_INFO
        "info"
      elsif s == SEVERITY_WARNING
        "warning"
      elsif s == SEVERITY_ERROR
        "error"
      else
        raise "Unknown severity: #{s}"
      end
    end

    # scan the output from the console line by line and return a list of ErrorDesc objects.
    # for none-error/warning lines the description object will indicate that as severity 255
    # for single line errors/warnings: description will contain severity, line-number, message and file-name
    #
    # for multi-line errors/warnings:
    #   one description object for each line, first one will contain all single line error information,
    #   all following desc.objects will just repeat the severity and include the message
    #
    def scan_lines(consoleOutput, proj_dir)
      raise "Use specialized classes only"
    end

    def makeVsError(line, d)
      if d.file_name == nil
        return line
      end

      ret = d.file_name
      ret = ret + "(" + d.line_number.to_s + ")" if (d.line_number and d.line_number > 0)
      ret = ret + ": " + inv_severity(d.severity) + ": " + d.message
      return ret
    end

  end

end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
bake-toolkit-2.37.3 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.37.2 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.37.1 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.37.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.36.1 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.36.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.35.3 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.35.2 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.35.1 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.35.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.34.4 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.34.3 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.34.2 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.34.1 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.34.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.33.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.32.0 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.31.7 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.31.5 lib/bake/toolchain/errorparser/error_parser.rb
bake-toolkit-2.31.4 lib/bake/toolchain/errorparser/error_parser.rb