Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Aug 31, 2023
1 parent baf5fcb commit bc288a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions man/crystal.1
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ Show implementations for a given call. Use
to specify the cursor position. The format for the cursor position is file:line:column.
.It Cm types
Show type of main variables of file.
.It Cm unreachable
Show methods that are never called. The output is a list of lines with columns
separated by tab. The first column is the location of the def, the second column
its reference name and the third column is the length in lines.
.El
.Pp
.It
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Crystal::Command
format format project, directories and/or files
hierarchy show type hierarchy
implementations show implementations for given call in location
unreachable show code that is never used
unreachable show methods that is never called
types show type of main variables
--help, -h show this help
USAGE
Expand Down
9 changes: 6 additions & 3 deletions src/compiler/crystal/tools/unreachable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ module Crystal
end
end

# Some defs (yielding, generic or virtual owner) are separate
# instantiations and thus cannot be identified by a unique object_id. Thus
# we're looking for location to identify the base def.
# This visitor walks the entire reachable code tree and collect locations
# of all defs that are a target of a call into `@used_def_locations`.
# The locations are filtered to only those that we're interested in per
# `@includes` and `@excludes`.
# Then it traverses all types and their defs and reports those that are not
# in `@used_def_locations` (and match the filter).
class UnreachableVisitor < Visitor
@used_def_locations = Set(Location).new
@defs = [] of Def
Expand Down

0 comments on commit bc288a1

Please sign in to comment.