diff --git a/src/diagrams/class/svgDraw.js b/src/diagrams/class/svgDraw.js index b9d31772a..84649e46e 100644 --- a/src/diagrams/class/svgDraw.js +++ b/src/diagrams/class/svgDraw.js @@ -345,10 +345,9 @@ const buildMethodDisplay = function (parsedText) { }; const buildLegacyDisplay = function (text) { - // if for some reason we dont have any match, use old format to parse text + // if for some reason we don't have any match, use old format to parse text let displayText = ''; let cssStyle = ''; - let memberText = ''; let returnType = ''; let methodStart = text.indexOf('('); let methodEnd = text.indexOf(')'); @@ -368,26 +367,27 @@ const buildLegacyDisplay = function (text) { methodName = text.substring(1, methodStart).trim(); } - let parameters = text.substring(methodStart + 1, methodEnd); - let classifier = text.substring(methodEnd + 1, 1); + const parameters = text.substring(methodStart + 1, methodEnd); + const classifier = text.substring(methodEnd + 1, methodEnd + 2); cssStyle = parseClassifier(classifier); displayText = visibility + methodName + '(' + parseGenericTypes(parameters.trim()) + ')'; - if (methodEnd < memberText.length) { + if (methodEnd <= text.length) { returnType = text.substring(methodEnd + 2).trim(); if (returnType !== '') { returnType = ' : ' + parseGenericTypes(returnType); + displayText += returnType; } + } else { + // finally - if all else fails, just send the text back as written (other than parsing for generic types) + displayText = parseGenericTypes(text); } - } else { - // finally - if all else fails, just send the text back as written (other than parsing for generic types) - displayText = parseGenericTypes(text); } return { - displayText: displayText, - cssStyle: cssStyle, + displayText, + cssStyle, }; };