Skip to content

Commit

Permalink
Include absolute paths in config (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Feb 21, 2024
1 parent 5cc2515 commit e7dc430
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.50.1
- Resolve self in yieldself tags
- Include absolute paths in config (#674)

## 0.50.0 - December 5, 2023
- Remove .travis.yml as its not longer used (#627)
Expand Down
2 changes: 1 addition & 1 deletion lib/solargraph/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Solargraph
VERSION = '0.50.0'
VERSION = '0.50.1'
end
11 changes: 6 additions & 5 deletions lib/solargraph/workspace/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Config

# @param directory [String]
def initialize directory = ''
@directory = directory
@directory = File.absolute_path(directory)
@raw_data = config_data
included
excluded
Expand All @@ -42,7 +42,8 @@ def excluded
end

def allow? filename
filename.start_with?(directory) &&
filename = File.absolute_path(filename, directory)
filename.start_with?(directory) &&
!excluded.include?(filename) &&
excluded_directories.none? { |d| filename.start_with?(d) }
end
Expand Down Expand Up @@ -171,7 +172,7 @@ def default_config
# @return [Array<String>]
def process_globs globs
result = globs.flat_map do |glob|
Dir[File.join directory, glob]
Dir[File.absolute_path(glob, directory)]
.map{ |f| f.gsub(/\\/, '/') }
.select { |f| File.file?(f) }
end
Expand All @@ -186,7 +187,7 @@ def process_globs globs
def process_exclusions globs
remainder = globs.select do |glob|
if glob_is_directory?(glob)
exdir = File.join(directory, glob_to_directory(glob))
exdir = File.absolute_path(glob_to_directory(glob), directory)
included.delete_if { |file| file.start_with?(exdir) }
false
else
Expand Down Expand Up @@ -224,7 +225,7 @@ def glob_to_directory glob
def excluded_directories
@raw_data['exclude']
.select { |g| glob_is_directory?(g) }
.map { |g| File.join(directory, glob_to_directory(g)) }
.map { |g| File.absolute_path(glob_to_directory(g), directory) }
end
end
end
Expand Down
Binary file added solargraph-0.50.0.gem
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/api_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class Sup

it "loads workspaces from directories" do
api_map = Solargraph::ApiMap.load('spec/fixtures/workspace')
expect(api_map.source_map('spec/fixtures/workspace/app.rb')).to be_a(Solargraph::SourceMap)
expect(api_map.source_map(File.absolute_path('spec/fixtures/workspace/app.rb'))).to be_a(Solargraph::SourceMap)
end

it "finds constants from included modules" do
Expand Down
6 changes: 4 additions & 2 deletions spec/language_server/message/text_document/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
host.prepare('spec/fixtures/workspace')
sleep 0.1 until host.libraries.all?(&:mapped?)
host.catalog
file_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(File.absolute_path('spec/fixtures/workspace/lib/other.rb'))
other_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(File.absolute_path('spec/fixtures/workspace/lib/thing.rb'))
message = Solargraph::LanguageServer::Message::TextDocument::Definition.new(host, {
'params' => {
'textDocument' => {
'uri' => 'file://spec/fixtures/workspace/lib/other.rb'
'uri' => file_uri
},
'position' => {
'line' => 4,
Expand All @@ -16,7 +18,7 @@
}
})
message.process
expect(message.result.first[:uri]).to eq('file://spec/fixtures/workspace/lib/thing.rb')
expect(message.result.first[:uri]).to eq(other_uri)
end

it 'finds definitions of require paths' do
Expand Down

0 comments on commit e7dc430

Please sign in to comment.