Cleans up majority of remaining kmc-* modules to use CompilerEvent
messages instead of console.log and friends, adding
InfrastructureMessages class for kmc CLI messages.
Consolidates schema loading functions into a single `loadSchema`
function in the CompilerCallbacks interface and implementations.
Moves responsibility for instantiating NodeCompilerCallbacks out of
each individual BuildActivity and into higher level modules.
Fixes return value for failing builds.
Replaces the existing error reporting in kmc-model with CompilerEvent
style messages. Some of the existing error reporting was kinda nice, but
consistency trumps pretty here.
One downside at present is the global filename and line variables in the
model-compiler-errors.ts unit. This is fragile, and should probably be
refactored further in the future.
Where it made sense, I converted various throws into ModelCompilerError
instances. If it appeared to be an internal error, I left it as-is, but
the external API interfaces wrap all unknown exceptions and convert them
into a compiler error message, so these APIs (compileModel and
loadFromFilename) now have a guarantee that they will never throw.
At this point, all of the error messages in the model compiler are
unrecoverable -- they will halt the compile entirely. However, the
pathway is there to support recoverable errors through the normal
callbacks.reportMessage mechanisms.
The message-counting mechanism is currently missing from this, as it
belongs in the API consumer, rather than in the low-level reporting
infrastructure. This means that models with large numbers of warnings
are going to generate scads of messages for now.
Note that the _users_ of CompilerCallbacks are subject to change in the
future, once we have all the compilers using the callbacks.
Consolidates the two copies of comperr.h (they were identical) and
moves to a common folder. Updates all references to comperr.h, except
for one github commit ref.
Fixes#8443.
Will cherry-pick to stable-16.0.
The regex for matching error messages has an optional section for
the file/line detail (line 54):
```regex
^(?:(.+) \((\d+)\): )?<snip>
```
The code that parses the results did not account for this being
optional, which would cause a crash if the error message did not include
this information.
This fixes two issues:
1. `COMP_KEY` structure had padding that was not always zeroed out.
Made this explicit.
2. Rule sorting could be inconsistent when re-sorting rules that
use `+ any() > ...`, which are expanded at compile time into multiple
rules, and which ended up with identical sort keys due to lack of
precision. This relates to #8381 but only adds differentiation for
the otherwise ambiguous rule sort keys, and does not fix that issue,
which requires further investigation.
Relates to #4324 (but slightly orthogonal.)
We wanted some message classes to be handled in the lexical model editor
more cleanly, including drill-down to line of error. A few changes
required to make this work well:
1. Parse error messages from kmlmc. This is not perfect but works while
the two projects are kept in sync, which they always are for Keyman
Developer. Note that at this stage, .ts warnings are not captured in
this parser, as they are generated by tsc.
2. Drill-down in Wordlist Editor Frame to find line of error
3. Model editor reports ownership of .tsv files so they can be loaded
4. In case of model editor not open (e.g. building from project view),
the TSV standalone editor was not displaying the frame, so it never
actually worked.
5. If the text editor had never loaded, then FindError was effectively
a no-op; adds code to seek to error line after page load finishes.
6. Ensures that if we attempt to seek an error in a sub-file owned by
an editor (e.g. .tsv owned by .model.ts, .kvks owned by .kmn), that
the parent editor will be focused first. Does not verify all paths
here, just the tsv one.
Fixes#7216.
The warning message 0x209A 'The rule will never be matched because its
key code is never fired.' was being generated multiple times for a
single line because the `JavaScript_Key` function it is generated by is
used for various purposes.
This PR keeps a cache of reported key rules to ensure that the message
is reported only once for a given key rule, and also improves the
reporting to clarify which specific key is unreachable, which makes it
easier to diagnose when using `any(k)` style messages, for example:
```
lao_phonetic.kmn (237): Warning: 209A The rule will never be matched for key 'ñ' because its key code is never fired.
```
This also reduces the warning to a hint, as this should not be a
blocking issue for a keyboard, rather just a place the keyboard author
can tidy up.
If `-no-compiler-version` is specified, then we skip the embedding of
the `TSS_COMPILEDVERSION` and `TSS_KEYMANCOPYRIGHT` stores. This is
intended for use with regression test builds of keyboards when we want
to verify changes to the compiler.
This patch introduces the new export `SetCompilerOptions` in kmcmpdll,
which should make it easier to include new options like this in future
versions.
Fixes the release build where we do `nmake symbols` for developer/src,
which was failing on calls to these two sets of components. (In
windows/src, the build structure is different due to an additional layer
of folders, so we end up with no `nmake symbols` call on the common
components).
Note this also drags TextFileFormat.pas and KMDActionInterfaces.pas into
the package so have moved those into general and components folders
respectively, alongside KMDActions.pas and updated corresponding
project includes.