Module: Suggestible

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Utils::StrongMemoize
Included in:
Gitlab::Diff::Suggestion, Suggestion
Defined in:
app/services/concerns/suggestible.rb

Constant Summary collapse

MAX_LINES_CONTEXT =

This translates into limiting suggestion changes to `suggestion:-100+100`.

100.freeze

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#diff_fileObject

Raises:

  • (NotImplementedError)

30
31
32
# File 'app/services/concerns/suggestible.rb', line 30

def diff_file
  raise NotImplementedError
end

#diff_linesObject


10
11
12
13
14
# File 'app/services/concerns/suggestible.rb', line 10

def diff_lines
  strong_memoize(:diff_lines) do
    Gitlab::Diff::SuggestionDiff.new(self).diff_lines
  end
end

#fetch_from_contentObject


16
17
18
# File 'app/services/concerns/suggestible.rb', line 16

def fetch_from_content
  diff_file.new_blob_lines_between(from_line, to_line).join
end

#from_lineObject


20
21
22
23
# File 'app/services/concerns/suggestible.rb', line 20

def from_line
  real_above = [lines_above, MAX_LINES_CONTEXT].min
  [target_line - real_above, 1].max
end

#target_lineObject

Raises:

  • (NotImplementedError)

34
35
36
# File 'app/services/concerns/suggestible.rb', line 34

def target_line
  raise NotImplementedError
end

#to_lineObject


25
26
27
28
# File 'app/services/concerns/suggestible.rb', line 25

def to_line
  real_below = [lines_below, MAX_LINES_CONTEXT].min
  target_line + real_below
end