Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
95ed300
Avoid rbs pollution (#1146)
apiology Jan 13, 2026
ce12a5f
Fix 'solargraph pin --references ClassName' private method call (#1150)
apiology Jan 13, 2026
5ae5558
Improve memory efficiency of Position class (#1054)
lekemula Jan 14, 2026
4c05f28
Raise InvalidOffsetError for offsets > text (#1155)
castwide Jan 14, 2026
be2c6f5
Refactor RbsMap::Conversions
apiology Jan 18, 2026
676da4c
Release 0.58.2
castwide Jan 19, 2026
504ba73
Complete other_type_to_type transition
apiology Jan 19, 2026
608d64b
Refactor
apiology Jan 20, 2026
9b15cfb
Refactor
apiology Jan 20, 2026
5d9f761
Refactor
apiology Jan 20, 2026
46f8063
Refactor
apiology Jan 20, 2026
5d8ffc8
Refactor
apiology Jan 20, 2026
f20d95d
Refactor
apiology Jan 20, 2026
8f1bf0f
Refactor
apiology Jan 20, 2026
55f9fc4
Refactor
apiology Jan 20, 2026
468ba97
Add @sg-ignores
apiology Jan 20, 2026
fc4c5b7
Fix tuple issue
apiology Jan 21, 2026
6ec089c
Refactor
apiology Jan 21, 2026
19329ef
Tuple -> Array()
apiology Jan 22, 2026
c8079e6
Add @sg-ignore
apiology Jan 22, 2026
7e29706
Use rooted names, clarify intent
apiology Jan 22, 2026
769bd50
Refactor
apiology Jan 23, 2026
f087eed
Remove TODOs, add asserts
apiology Jan 26, 2026
6979cb7
Fix solargraph-rspec spec failure
apiology Jan 27, 2026
23e4e74
Merge remote-tracking branch 'castwide/v0.59' into 2026-01-27
apiology Jan 27, 2026
0f4c07d
Merge branch '2026-01-27' into temp_solargraph_rspec_branch
apiology Jan 27, 2026
197c2db
Fix merge
apiology Jan 27, 2026
b4f5c75
Merge branch 'temp_solargraph_rspec_branch' into refactor_rbs_convers…
apiology Jan 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ jobs:
- name: clone https://github.com/lekemula/solargraph-rspec/
run: |
cd ..
git clone https://github.com/lekemula/solargraph-rspec.git
# git clone https://github.com/lekemula/solargraph-rspec.git

# pending https://github.com/lekemula/solargraph-rspec/pull/31
git clone https://github.com/apiology/solargraph-rspec.git
cd solargraph-rspec
git checkout test_solargraph_prereleases
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage
/Makefile
/.pryrc
/.rspec-local
vendor/cache
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## 0.58.2 - January 19, 2026
- Avoid rbs pollution (#1146)
- Fix 'solargraph pin --references ClassName' private method call (#1150)
- Improve memory efficiency of Position class (#1054)
- Raise InvalidOffsetError for offsets > text (#1155)

## 0.58.1 - January 2, 2026
- Normalize line endings to LF (#1142)
- Normalize line endings to LF (#1142)

## 0.58.0 - January 1, 2026
- Faster constant resolution (#1083)
Expand Down
16 changes: 16 additions & 0 deletions lib/solargraph/pin/reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ class Reference < Base

attr_reader :generic_values

# A Reference is a pin that associates a type with another type.
# The existing type is marked as the closure. The name of the
# type we're associating with it is the 'name' field, and
# subtypes are in the 'generic_values' field.
#
# These pins are a little different - the name is a rooted name,
# which may be relative or absolute, preceded with ::, not a
# fully qualified namespace, which is implicitly in the root
# namespace and is never preceded by ::.
#
# @todo can the above be represented in a less subtle way?
# @todo consider refactoring so that we can replicate more
# complex types like Hash{String => Integer} and has both key
# types and subtypes.
#
# @param name [String] rooted name of the referenced type
# @param generic_values [Array<String>]
def initialize generic_values: [], **splat
super(**splat)
Expand Down
40 changes: 29 additions & 11 deletions lib/solargraph/position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,24 @@ def inspect
# @return [Integer]
def self.to_offset text, position
return 0 if text.empty?
text.lines[0...position.line].sum(&:length) + position.character

newline_index = -1
line = -1
last_line_index = 0

# @sg-ignore flow sensitive typing should be able to handle redefinition
while (newline_index = text.index("\n", newline_index + 1)) && line <= position.line
line += 1
break if line == position.line

# @sg-ignore oflow sensitive typing should be able to handle redefinition
line_length = newline_index - last_line_index
last_line_index = newline_index
end

last_line_index += 1 if position.line > 0
# @sg-ignore flow sensitive typing should be able to handle redefinition
last_line_index + position.character
end

# Get a numeric offset for the specified text and a position identified
Expand All @@ -73,23 +90,24 @@ def self.line_char_to_offset text, line, character

# Get a position for the specified text and offset.
#
# @raise [InvalidOffsetError] if the offset is outside the text range
#
# @param text [String]
# @param offset [Integer]
# @return [Position]
def self.from_offset text, offset
raise InvalidOffsetError if offset > text.length

cursor = 0
line = 0
# @type [Integer, nil]
character = nil
text.lines.each do |l|
line_length = l.length
char_length = l.chomp.length
if cursor + char_length >= offset
character = offset - cursor
break
end
cursor += line_length
character = offset
newline_index = -1

# @sg-ignore flow sensitive typing should be able to handle redefinition
while (newline_index = text.index("\n", newline_index + 1)) && newline_index < offset
line += 1
# @sg-ignore flow sensitive typing should be able to handle redefinition
character = offset - newline_index - 1
end
character = 0 if character.nil? and (cursor - offset).between?(0, 1)
raise InvalidOffsetError if character.nil?
Expand Down
Loading
Loading