Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(enum-updater): add enum updater tool #33681

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update to not add extra empty lines
  • Loading branch information
paulhcsun committed Feb 27, 2025
commit fde6057bf896b4cf8429ebad2c2b8fadaeba0c37
Original file line number Diff line number Diff line change
@@ -862,8 +862,17 @@ export class EnumLikeUpdater extends MetadataUpdater {

const newEnumValues = missingValue['missing_values'];

// Get the full text of the enum
// First get the full text
let enumText = enumDeclaration.getFullText();

// If the text starts with empty lines before the docstring (which starts with /**),
// remove only those empty lines
if (enumText.startsWith('\n') && enumText.includes('/**')) {
const docstringStart = enumText.indexOf('/**');
const leadingText = enumText.substring(0, docstringStart);
const restOfText = enumText.substring(docstringStart);
enumText = leadingText.replace(/^\n+/, '') + restOfText;
}

// Get just the enum body (everything between the curly braces)
const enumBodyStart = enumText.indexOf('{') + 1;