Class: PlatformosCheck::LanguageServer::CompletionContext
- Inherits:
-
Object
- Object
- PlatformosCheck::LanguageServer::CompletionContext
show all
- Includes:
- PositionHelper
- Defined in:
- lib/platformos_check/language_server/completion_context.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#bounded, #from_index_to_row_column, #from_row_column_to_index
Constructor Details
#initialize(storage, relative_path, line, col) ⇒ CompletionContext
Returns a new instance of CompletionContext.
10
11
12
13
14
15
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 10
def initialize(storage, relative_path, line, col)
@storage = storage
@relative_path = relative_path
@line = line
@col = col
end
|
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
8
9
10
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 8
def col
@col
end
|
#line ⇒ Object
Returns the value of attribute line.
8
9
10
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 8
def line
@line
end
|
#relative_path ⇒ Object
Returns the value of attribute relative_path.
8
9
10
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 8
def relative_path
@relative_path
end
|
#storage ⇒ Object
Returns the value of attribute storage.
8
9
10
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 8
def storage
@storage
end
|
Instance Method Details
#absolute_cursor ⇒ Object
25
26
27
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 25
def absolute_cursor
@absolute_cursor ||= from_row_column_to_index(buffer, line, col)
end
|
#buffer ⇒ Object
17
18
19
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 17
def buffer
@buffer ||= storage.read(relative_path)
end
|
#buffer_until_previous_row ⇒ Object
21
22
23
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 21
def buffer_until_previous_row
@buffer_without_current_row ||= buffer[0..absolute_cursor].lines[0...-1].join
end
|
#clone_and_overwrite(col:) ⇒ Object
49
50
51
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 49
def clone_and_overwrite(col:)
CompletionContext.new(storage, relative_path, line, col)
end
|
#content ⇒ Object
35
36
37
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 35
def content
@content ||= token&.content
end
|
#cursor ⇒ Object
29
30
31
32
33
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 29
def cursor
@cursor ||= (absolute_cursor - token&.start) || 0
rescue StandardError
0
end
|
#token ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/platformos_check/language_server/completion_context.rb', line 39
def token
@token ||= Tokens.new(buffer).find do |t|
t.start < absolute_cursor && absolute_cursor <= t.end
end
end
|