Comparing version 0.0.47 to 0.0.48
{ | ||
"name": "ts2uml", | ||
"version": "0.0.47", | ||
"version": "0.0.48", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,2 +18,4 @@ "use strict"; | ||
let currentMethodName = null; | ||
let blockDepth = 0; // Track the depth of nested blocks | ||
let gothrough = true; | ||
// Ensure targetLineNumber is within bounds | ||
@@ -25,2 +27,15 @@ if (targetLineNumber < 0 || targetLineNumber > lines.length) { | ||
const line = lines[i]; | ||
// Increase or decrease block depth based on opening and closing braces | ||
blockDepth += (line.match(/{/g) || []).length; | ||
blockDepth -= (line.match(/}/g) || []).length; | ||
// Skip processing if we're inside a nested block | ||
if (blockDepth < 0) { | ||
gothrough = false; | ||
continue; | ||
} | ||
; | ||
if (!gothrough) { | ||
gothrough = true; | ||
continue; | ||
} | ||
// Match class declaration, considering possible keywords like 'export' | ||
@@ -30,4 +45,5 @@ const classMatch = line.match(/(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/); | ||
currentClassName = classMatch[1]; | ||
break; | ||
break; // Stop searching once a class is found | ||
} | ||
// Match method or function declaration | ||
const methodOrFunctionMatch = line.match(/(?:async\s+)?(?:function\s+)?(?:public\s+|private\s+|protected\s+|static\s+)?\*?\s*(\w+)\s*(?:\((?:[^)]*)\))\s*(?:=>)?{/); | ||
@@ -38,3 +54,6 @@ if (!currentMethodName && methodOrFunctionMatch) { | ||
} | ||
// Return after processing all lines or reaching the target line | ||
// Adjust for cases where blockDepth might not return to 0 due to unbalanced braces | ||
if (blockDepth !== 0) { | ||
console.warn("Warning: Unbalanced braces detected. The results might not be accurate."); | ||
} | ||
return { className: currentClassName, method: currentMethodName }; | ||
@@ -41,0 +60,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44653
935