class AdLint::Location

DESCRIPTION

Location identifier of tokens.

Attributes

appearance_column_no[R]
column_no[R]

VALUE

Integer – Column-no where this token appears.

fpath[R]

VALUE

Pathname – Path name of the file contains this token.

line_no[R]

VALUE

Integer – Line-no where this token appears.

Public Class Methods

new(fpath = nil, line_no = nil, column_no = nil, appearance_column_no = column_no) click to toggle source

Constructs a location identifier.

Param

fpath (Pathname) Path name of the file contains the token.

Param

line_no (Integer) Line-no where the token appears.

Param

column_no (Integer) Column-no where the token appears.

# File lib/adlint/location.rb, line 44
def initialize(fpath = nil, line_no = nil, column_no = nil,
               appearance_column_no = column_no)
  @fpath, @line_no, @column_no = fpath, line_no, column_no
  @appearance_column_no = appearance_column_no
end

Public Instance Methods

<=>(rhs) click to toggle source
# File lib/adlint/location.rb, line 81
def <=>(rhs)
  self.to_a <=> rhs.to_a
end
eql?(rhs) click to toggle source
# File lib/adlint/location.rb, line 85
def eql?(rhs)
  self == rhs
end
hash() click to toggle source
# File lib/adlint/location.rb, line 89
def hash
  to_a.hash
end
in_analysis_target?(traits) click to toggle source
# File lib/adlint/location.rb, line 64
def in_analysis_target?(traits)
  if @fpath
    under_inclusion_paths?(@fpath, traits) &&
      !under_exclusion_paths?(@fpath, traits) and
    !@fpath.identical?(traits.of_project.initial_header) &&
      !@fpath.identical?(traits.of_compiler.initial_header)
  else
    false
  end
end
inspect() click to toggle source

DESCRIPTION

Converts this location to debugging dump representation.

RETURN VALUE

StringString representation of this location identifier.

# File lib/adlint/location.rb, line 116
def inspect
  "#{@fpath ? @fpath : 'nil'}:" +
    "#{@line_no ? @line_no : 'nil'}:#{@column_no ? @column_no : 'nil'}"
end
to_a() click to toggle source

DESCRIPTION

Converts this location identifier to an array representation.

RETURN VALUE

Array< Object > – Array representation of this location identifier.

# File lib/adlint/location.rb, line 98
def to_a
  [@fpath, @line_no, @column_no]
end
to_s() click to toggle source

DESCRIPTION

Converts this location to a human readable string representation.

RETURN VALUE

StringString representation of this location identifier.

# File lib/adlint/location.rb, line 107
def to_s
  "#{@fpath}:#{@line_no}:#{@column_no}"
end

Private Instance Methods

under_exclusion_paths?(fpath, traits) click to toggle source
# File lib/adlint/location.rb, line 128
def under_exclusion_paths?(fpath, traits)
  traits.of_project.target_files.exclusion_paths.any? do |dpath|
    fpath.under?(dpath)
  end
end
under_inclusion_paths?(fpath, traits) click to toggle source
# File lib/adlint/location.rb, line 122
def under_inclusion_paths?(fpath, traits)
  traits.of_project.target_files.inclusion_paths.any? do |dpath|
    fpath.under?(dpath)
  end
end