[go: nahoru, domu]

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

feat: add getVariableName and getProcedureName to CodeGenerator #7445

Merged
merged 5 commits into from
Aug 31, 2023

Conversation

maribethb
Copy link
Contributor

The basics

The details

Resolves

Fixes #6008 and works on #7326

Proposed Changes

  • Adds getVariableName and getProcedureName APIs to CodeGenerator class.
  • Makes nameDB_ public to account for use cases not served by the above APIs.
  • Updated block-code generators to call the new APIs instead of accessing nameDB_ directly.
  • Updated the block-code generator functions for procedure definition blocks in python and php to use for...of instead of funky for loop; this improves the typing information (while these files are not in TS yet, editors are still able to use the TS information for better autosuggest)

Behavior Before Change

The only way to get these, which you need to do inside block-code generator functions, was to access the (previously protected) nameDB_ object.

Behavior After Change

  • New APIs can be used for variable and procedure names, which covers the two most common use cases for needing to access nameDB_. The advantage of these methods is that it prints a warning if nameDB_ has not been initialized, which is a common failure mode we've seen in the forums.
  • Niche use cases (developer variables, temporary variables with distinct names) can access nameDB_ directly.

Reason for Changes

Improved developer APIs and documentation

Test Coverage

Added some basic unit tests. The Names db functionality has its own tests, so just stubbed that out.

Documentation

Beka currently has a doc in progress that would touch this
cc @BeksOmega

Additional Information

@maribethb maribethb requested a review from a team as a code owner August 28, 2023 21:42
@github-actions github-actions bot added the PR: feature Adds a feature label Aug 28, 2023
@maribethb maribethb merged commit 68261e5 into google:develop Aug 31, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Address nameDB_ or add api to get name of a variable
2 participants