function updateDisplayPathOfMLFBNode(this, node)
% UPDATEDISPLAYPATHOFMLFBNODE Updates the display path of the MATLAB function node after the variant
% creation

% Copyright 2017-2019 The MathWorks, Inc.

% DisplayPath is how we trip the display names of results in the
% spreadsheet. An incorrect display path means, the name of the results
% will not be trimmed correctly based on the node selected.

displayPath = {node.DisplayPath};
idx = regexp(node.DisplayPath, ['/' node.Name '$']);
if ~isempty(idx)
    stableSubPath = node.DisplayPath(idx:end);
    % Remove line breaks. This path is used
    % to scope the results in UI when a tree node is selected
    % g1882836
    newPath = [node.Object.BlockIdentifier.getObject.getFullName, stableSubPath];
    displayPathForClient = fxptui.ModelHierarchy.getDisplayPathForClient(newPath);
    displayPathForClient = fxptui.removeLineBreaksFromName(displayPathForClient);    
    node.DisplayPath = [displayPath, {displayPathForClient}];
end
childNodes = node.getChildren;
for i = 1:numel(childNodes)
    this.updateDisplayPathOfMLFBNode(childNodes(i));
end