8000 feat(developer): update strs compiler to collect context by srl295 · Pull Request #14064 · keymanapp/keyman · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(developer): update strs compiler to collect context #14064

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

Merged
merged 8 commits into from
Jun 4, 2025

Conversation

srl295
Copy link
Member
@srl295 srl295 commented May 28, 2025
  • attempt to find an object with a context

For: #13932

@keymanapp-test-bot skip

8000
@srl295
Copy link
Member Author
srl295 commented May 29, 2025

wrong example, it was a tran example

srl295 added 2 commits May 28, 2025 20:17
- attempt to find an object with a context

For: #13932
- default state needs to be null not undefined

For: #13932
@srl295 srl295 force-pushed the feat/developer/13932-ln-more-strscompiler branch from 9d54d85 to db24750 Compare May 29, 2025 01:18
@srl295
Copy link
Member Author
srl295 commented May 29, 2025
invalid-illegal.xml - info KM05002: Building developer/src/kmc-ldml/test/fixtures/sections/strs/invalid-illegal.xml
invalid-illegal.xml - hint KM00023: File contains 2 PUA character(s), including PUA (U+E010)
invalid-illegal.xml:39 - error KM00025: File contains 5 illegal character(s), including Illegal (U+FDD0)
invalid-illegal.xml - info KM05007: developer/src/kmc-ldml/test/fixtures/sections/strs/invalid-illegal.xml failed to build.

srl295 added 3 commits May 29, 2025 09:10
…ests assertions

- remove line number information for some "simpler" uses of the compileKeyboard() test helper

For: #13932
This concludes all of the allocString() calls that aren't part of lists, sets, elements etc.

Fixes: #13932
@srl295 srl295 marked this pull request as ready for review May 30, 2025 19:47
@srl295 srl295 linked an issue May 30, 2025 that may be closed by this pull request
@srl295 srl295 requested a review from markcsinclair June 2, 2025 13:41
@srl295 srl295 self-assigned this Jun 2, 2025
@srl295 srl295 requested review from mcdurdin and SabineSIL June 2, 2025 13:41
< 10000 table class="diff-table tab-size js-diff-table" data-tab-size="8" data-paste-markdown-skip> @@ -172,6 +174,16 @@ export function checkMessages() { assert.isEmpty(compilerTestCallbacks.messages, compilerEventFormat(compilerTestCallbacks.messages)); }
/** These tests aren't prepared for line number information in messages. Remove it so that comparisons pass. */ function zapMessageMetadata() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh - yes, zap and scrub have the same function. That's what I get for a long chain of PRs.

In a future PR, I remove zapMessageMetadata() and just use scrubContextFromMessages() instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link to the other PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first commit on #14100

Copy link
Member
@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I think we need to rethink our use of x and context, because it's really ambiguous. Does compileContext or compilerContext work for you? It's really only specific to the compiler, whereas x could be anything, and context fights with the existing Keyman term.

@@ -161,6 +173,8 @@ export interface StrsOptions {
nfd?: boolean;
/** string can be stored as a single CharStrsItem, not in strs table. */
singleOk?: boolean;
/** optional context */
x?: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why named x? Also 'context' is a bit of an overloaded term, so I wonder if we can give a longer name, such as compileContext?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's x like the other parameter to m() is traditionally named o

Perhaps ObjectWithMetadata should be renamed ObjectWithCompileContext ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> #14117

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps ObjectWithMetadata should be renamed ObjectWithCompileContext ?

Yes, that sounds good to me.

It's x like the other parameter to m() is traditionally named o

See #14117 (comment)

Comment on lines +141 to +149
/** add any context from the options to this strsitem */
setContext(opts?: StrsOptions) {
// At present, there's only a single piece of context available
this._context = this._context || opts?.x;
}

get context() : any {
return this._context;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use consistent pattern here? (either both get context()/set context(), or getContext()/setContext()? (I am not a big fan of getters/setters because they hide behaviour for what looks like a simple assignment, but that's a separate story)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srl295 srl295 merged commit f4476e2 into master Jun 4, 2025
20 checks passed
@srl295 srl295 deleted the feat/developer/13932-ln-more-strscompiler branch June 4, 2025 13:37
6D4E
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Jun 4, 2025
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.58-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

feat(developer): implement line numbers in LDML StrsCompiler
3 participants
0