Skip to content

Prepare Emitter API to go public #3621

@joshgoebel

Description

@joshgoebel

In preparation for #3619 and #3620 I'd live to review out Emitter API and rename some things to better match our own internal naming. I think the original was a bit too specific with regards to internal implementations and the new version should be a little more abstract:

Old:

  • addKeyword(text, scope)
  • addText(text)
  • addSublanguage(emitter, subLanguageName)
  • finalize()
  • openNode(scope)
  • closeNode()
  • closeAllNodes()
  • toHTML()

New:

  • addText(text)
  • startScope(scope) (or pushScope?)
  • endScope() (or popScope? or finishScope?)
  • __addSublanguage(emitter, subLanguageName) - (may stay private)
  • finalize() - thoughts on naming?
  • toHTML()

Removed:

  • addKeyword(text, scope) - pull back into an internal helper
  • closeAllNodes() - Lets just let finalize be responsible for all cleanup.

For writing custom grammar parsers one would really only need to concern themselves with 3 API calls I think:

  • addText
  • startScope
  • endScope

@wooorm I know you had plenty of thoughts on this before... it's possible I'm a little more receptive now... I do plan on reducing a API a bit if we're going public (which I recall you pushed for previously).

Metadata

Metadata

Assignees

Labels

enhancementAn enhancement or new featurehelp welcomeCould use help from communityparser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions