Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Let lame regex based code model find assign-like methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopl committed Jul 13, 2024
1 parent 890ef5e commit 8abd870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion spec/lame_regex_crystal_code_model_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ end
private class Classs
def self.method_for_testing!
end

def method_for_testing=(_bar)
end
end

describe "Nop" do
Expand All @@ -35,12 +38,14 @@ describe LameRegexCrystalCodeModel do
symbols[0].location.line.should eq(7)
symbols[1].name.should eq("self.method_for_testing!")
symbols[1].location.line.should eq(11)
symbols[2].name.should eq("method_for_testing=")
symbols[2].location.line.should eq(14)
end

it "find test cases" do
symbols = filtered_symbols(:test_case)
symbols[0].name == "test"
symbols[0].location.line.should eq(16)
symbols[0].location.line.should eq(19)
end

it "find macros" do
Expand Down
2 changes: 1 addition & 1 deletion src/lame_regex_crystal_code_model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require "./code_model"
class LameRegexCrystalCodeModel < CodeModel
Log = ::Log.for(LameRegexCrystalCodeModel)

METHOD_REGEX = /\A\s*(?:abstract |private |protected )?\s*def\s+((?:self\.)?\w[\w+\d+]*[!\?]*)/
METHOD_REGEX = /\A\s*(?:abstract |private |protected )?\s*def\s+((?:self\.)?\w[\w+\d+]*[!\?=]*)/
MACRO_REGEX = /\A\s*macro\s+(\w[\w+\d+]*[!\?]*)/
SPEC_TEST_REGEX = /\A\s*it\s*(.*)do\s*\z/

Expand Down

0 comments on commit 8abd870

Please sign in to comment.