Skip to content

Provide more user-friendly generator APIs #7326

@BeksOmega

Description

@BeksOmega

Check for duplicates

  • I have searched for similar issues before opening a new one.

Problem

There are a bunch of methods and properties within the generator code that:

  1. Are protected, when they need to be public so they can be used by block-code generators.
  2. Have confusing names.

The following things are protected but used by generators:

  • quote_ (used by string block)
  • multiline_quote_ (used by multiline string block)
  • nameDB_ (also addressed in Address nameDB_ or add api to get name of a variable #6008)
  • definitions_ (we just cludge imports and user-defined procedures onto this object, you need to know its naming semantics to do this correctly)
  • scrub_ (needs to be called by procedure definition blocks to handle comments)

The provideFunction_ method (which is only supposed to be used for developer-defined functions) is public, but has a sad underscore in the name :/

Request

Provide an API that matches what external developers are actually trying to do.

I think it should look something like:

  • getVariableName
  • getProcedureName
  • quote
  • multilineQuote
  • addProcedure -> This should handle scrubbing and finding a name
  • addImport
  • addDeveloperFunction

Alternatives considered

Make the protected methods public so they're actually usable. But stick with the less-than-ideal API.

Additional context

Related to #6008 (should possibly supercede it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: feature requestDescribes a new feature and why it should be added

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions