Skip to content

Commit

Permalink
Refactor Ast.space_separated?.
Browse files Browse the repository at this point in the history
- Removed unused  `Ast.new_line?` and `Ast#new_line?` methods.
  • Loading branch information
gdotdesign committed Nov 13, 2024
1 parent e599528 commit 1461d23
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/ast.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,12 @@ module Mint
@nodes = [] of Node)
end

def main : Component?
@components.find(&.name.value.==("Main"))
end

# TODO: Use line / column instead of offset
def self.space_separated?(node1, node2)
node1.file.contents[node1.to.offset, node2.from.offset - node1.to.offset].count('\n') > 1
end

def self.new_line?(node1, node2)
node1.file.contents[node1.from.offset, node2.from.offset - node1.from.offset].includes?('\n')
(node2.from.line - node1.to.line) > 1
end

def new_line?(node1, node2)
start_position =
node1.from.offset

count =
node2.to.offset - node1.from.offset

node1.file.contents[start_position, count].includes?('\n')
def main : Component?
@components.find(&.name.value.==("Main"))
end

def merge(ast) : self
Expand Down

0 comments on commit 1461d23

Please sign in to comment.