adding field parse case for when there is no default field value
This commit is contained in:
11
index.js
11
index.js
@@ -32,12 +32,11 @@ window.Registry = class Registry {
|
|||||||
braceDepth -= (trimmedLine.match(/}/g) || []).length;
|
braceDepth -= (trimmedLine.match(/}/g) || []).length;
|
||||||
|
|
||||||
// Check if the line is outside any function/method (top-level within the class)
|
// Check if the line is outside any function/method (top-level within the class)
|
||||||
if (braceDepth === 1 && trimmedLine.includes('=') && !trimmedLine.startsWith('...')) {
|
if (braceDepth === 1) {
|
||||||
// Extract the field name, which is before the '=' symbol
|
// Attempt to match a class field declaration with or without initialization
|
||||||
const fieldName = trimmedLine.split('=')[0].trim();
|
const fieldMatch = trimmedLine.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*(=|;|\n|$)/);
|
||||||
// Make sure the field name doesn't include invalid characters or spaces
|
if (fieldMatch) {
|
||||||
if (!fieldName.includes(' ') && !fieldName.startsWith('this.')) {
|
fields.push(fieldMatch[1]);
|
||||||
fields.push(fieldName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user