Skip to content

Commit

Permalink
Add command to display direct subclasses.
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek committed Sep 7, 2014
1 parent add8ba8 commit 0273da4
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions deft-browse/deft-browse.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,46 @@ define command inspect ($deft-commands)
implementation
inspect-dylan-object(dylan-object-name);
end;

define method print-class-subclasses
(project :: <project-object>, object)
let id = environment-object-id(project, object);
format-out("%s is not a class.\n", id.id-name);
end method;

define method print-class-subclasses
(project :: <project-object>, object == #f)
format-out("Object not found.\n");
end method;

define method print-class-subclasses
(project :: <project-object>, object :: <class-object>)
let id = environment-object-id(project, object);
let subclasses = class-direct-subclasses(project, object);
for (sc in subclasses)
let sc-id = environment-object-id(project, sc);
format-out("\t%s\n", sc-id.id-name);
end for;
end method;

define function subclasses-for-class(name :: <string>)
let project = dylan-current-project($deft-context);
if (project)
let library = project-library(project);
let object = find-environment-object(project, name,
library: library,
module: first(library-modules(project, library)));
print-class-subclasses(project, object);
else
format-out("No open project found.\n");
end if
end function;

define command subclasses ($deft-commands)
help "Display the subclasses of a class.";
simple parameter dylan-class-name :: <string>,
help: "the dylan class",
required?: #t;
implementation
subclasses-for-class(dylan-class-name);
end;

0 comments on commit 0273da4

Please sign in to comment.