BLOC - Automatic UML class diagram creator

by

 

Used to create a UML class diagram from a MATLAB object oriented program.

recursive(parentindex,nodeList,supList, finallist)
function [childindex,nodeList,supList, finallist] = recursive(parentindex,nodeList,supList, finallist)
% keyboard
indexhld = {};
indextmp = []; %clears the indextmp buffer;
%i loop is for the total number of BLOCK parents found
%ii loop is for the length of the subs found
% size(parentindex{1},2)
for i = 1:length(parentindex); %only have to build verticals for the top classes found
    
    if isa(nodeList{parentindex(i)}.Data.Sbclss,'cell') ~= 1
        %         keyboard
        nodeList{parentindex(i)}.Data.Sbclss = {nodeList{parentindex(i)}.Data.Sbclss};
    end
    
    for j = 1:length(nodeList{parentindex(i)}.Data.Sbclss) %parentindex{1}{i} is the extracted indices.
        topnode = nodeList(parentindex); %The nodes containing the parents.
        
        
        %         keyboard
        
        if isempty(topnode{i}.Data.Sbclss) == 1 % If the node does not contain a sub, continue
            %             keyboard
            
            continue
        end
        
        %         if isa(nodeList{parentindex(i)}.Data.Sub,'cell') ~= 1
        %             keyboard
        %             topnode{j}.Data.Sub = {topnode{j}.Data.Sub};
        %         end
        
        
        %         for j = 1:size(topnode{ii}.Data.Sub,2) %for the length of the sublist located in the top tier class
        for k = 1:size(supList,1) %for the length of the entire suplist (to cross compare)
            temp = supList(:,1)'; %Concatenated list of the names in supList for comparison
            if isequal(topnode{i}.Data.Sbclss(j),temp(k))
                %                 keyboard
                indextmp(end+1) = k; %the indices for located subs in the suplist
            else
                continue
            end
        end
    end
    
    %     this point of loop have finished locating the indices for the
    %     items found for one class's sublist. (broken the j loop)
%     keyboard
    indexhld = indextmp; %cell array that holds the array of indices (indicating the location of each sub in the supList) for each top class found.
end


childindex = indexhld; % The '1' in childindex should actually be the number of times its recursed.

if isempty(childindex) == 1
    %     keyboard
    return
else
    %     keyboard
    %     childindex{1} = indexhld;
    finallist(end+1) = {childindex};
    parentindex = childindex;
end

% keyboard
% finallist(end+1) = childindex;
% parentindex = childindex;
% topind = cell2mat(parentindex{1});

[childindex,nodeList,supList, finallist] = recursive(parentindex,nodeList,supList, finallist);
end

Contact us