Skip to content

Commit

Permalink
Work on finding reference groups
Browse files Browse the repository at this point in the history
  • Loading branch information
epeld committed Oct 3, 2017
1 parent 57171ad commit d5cabf7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions inspect.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
% Top-Level API
%

reference_groups(ClassReferences, [G1 | Groups]) :-
reference_group(ClassReferences, G1),

% Remove the 'used' edges
% TODO

reference_groups(ClassReferences1, Groups).

reference_group(ClassReferences, Group) :-
ClassReferences = [references(ClassName, _) | _Rest],
reference_group(ClassReferences, ClassName, Group).

reference_group(ClassReferences, ClassName, Group) :-
setof(ClassName2, indirectly_references(ClassReferences, ClassName, ClassName2), DownStream),
setof(ClassName2, indirectly_references(ClassReferences, ClassName2, ClassName), UpStream),
union(DownStream, UpStream, Group).

referenced_classes(ClassContents, References) :-
referenced_class_names(ClassContents, ClassNames),
class_name(ClassContents, ThisName),
Expand All @@ -24,6 +41,14 @@
% Helpers
%

indirectly_references(AllReferences, Source, Target) :-
member(references(Source, Target), AllReferences).

indirectly_references(AllReferences, Source, Target) :-
Source \= Target, % Avoid recursion
member(references(Source, Target0), AllReferences),
indirectly_references(AllReferences, Target0, Target).

constant_class_name(ClassContents, ClassName) :-
constant_pool(ClassContents, Constants),
nth1(Index, Constants, ClassRef),
Expand Down

0 comments on commit d5cabf7

Please sign in to comment.