Convert the model module to Kotlin#1465
Conversation
…ctory, ModelInfoReaderProvider
|
Formatting check succeeded! |
| for (t in index.values) { | ||
| if (t is ClassType && t.label != null) { | ||
| classIndex[casify(t.label)] = t | ||
| classIndex[casify(t.label!!)] = t |
There was a problem hiding this comment.
Are we sure we want to throw an NPE here or anywhere else in this PR we use !! ?
There was a problem hiding this comment.
Ideally, no. I've been fixing the cases of these where it's reasonably straight forward to do so. In this case, the label property is mutable, meaning that it could change values between the null check (t.label != null) and the usage (t.label!!) if, for instance, the Model was shared between different threads. I looked at changing label to be immutable, but it requires a re-work of how the ClassTypes are initialized. I just decided it was a bigger change than I wanted do. I've mostly kept the APIs and usages of the classes the same, only grabbing low-hanging fruit.
...r/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java
Outdated
Show resolved
Hide resolved
|
|
||
| override fun isInstantiable(callType: DataType, context: InstantiationContext): Boolean { | ||
| return if (callType is ClassType && callType.elements.size == elements.size) { | ||
| sortedElements.zip(callType.sortedElements).all { (thisElement, thatElement) -> |
There was a problem hiding this comment.
We really need zip in Java
|
| throw RuntimeException( | ||
| java.lang.String.join( | ||
| " ", | ||
| "Multiple ModelInfoReaderProviders found on the classpath.", |
There was a problem hiding this comment.
Does Kotlin have multi-line Strings?
There was a problem hiding this comment.
Yes. I’ve not tried them though. I’ll give the a shot.
… and JavaScript. Beta version of the CQL Compiler for JavaScript. (#1462) * WIP * WIP * WIP * Working? * Fix usage of Java 17 API * Update checkstyle rules * Fix static analysis * Updates to src dirs * Fixing up missing test sourceSet * Try another way to specify the antlr directory * Third different way * Add some logging * merge master * Change toolchain resolution * Fix tests * More tweaks to animalsniffer * Fix formatting * Trying random stuff * More random stuff * Add Kotlin static analysis and formatting * More KT cleanup * WIP * Fix formatting * WIP, multi-platform * Build preliminary CQL parsing library targeting JS (#1434) * Try out jsRun * Compile Kotlin to JS with type definitions. Export parseToTree method. * Swap Gradle language from Groovy to Kotlin (#1413) * WIP * WIP * WIP * Working? * Fix usage of Java 17 API * Update checkstyle rules * Fix static analysis * Updates to src dirs * Fixing up missing test sourceSet * Try another way to specify the antlr directory * Third different way * Add some logging * merge master * Change toolchain resolution * Fix tests * More tweaks to animalsniffer * Fix formatting * Trying random stuff * More random stuff * Small improvements for Gradle build (#1418) * Removing references to idea * Fix duplicative generation * Remove references to idea project generation --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Origin/feature kotlin conventions patch (#1437) * small cleanup * fix the jvm toolchain version --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Fix static app entry point, fix build dependencies * Play within memory options * Add demo UI for CQL parser (#1439) * Add demo for the UI that uses Kotlin/JS- and Kotlin/WASM-based CQL parser * Tweak config * Update README.md * Update docs * Update docs * Update to Java 17, sync Android signature settings with FHIR SDK (#1442) * Update to Java 17, sync Android signature settings with FHIR SDK * Switch to advanced CodeQL * Tweaking source location * Try autobuilding * More tweaking the build * Kotlin Conventions Plugin (#1438) * WIP * WIP * WIP * Working? * Fix usage of Java 17 API * Update checkstyle rules * Fix static analysis * Updates to src dirs * Fixing up missing test sourceSet * Try another way to specify the antlr directory * Third different way * Add some logging * merge master * Change toolchain resolution * Fix tests * More tweaks to animalsniffer * Fix formatting * Trying random stuff * More random stuff * Add Kotlin static analysis and formatting * More KT cleanup * Origin/feature kotlin conventions patch (#1437) * small cleanup * fix the jvm toolchain version --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Fix static app entry point, fix build dependencies * Play within memory options --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Remove leading spaces from codeql.yml (#1446) * Remove redundant overrides in `Cql2ElmVisitor` and `CqlPreprocessor` (#1445) Remove redundant override * Add toolchain resolver plugins * Update Gradle to 8.11 * Refactor and Genericize Invocation hierarchy (#1444) * WIP * WIP * WIP * Working? * Fix usage of Java 17 API * Update checkstyle rules * Fix static analysis * Updates to src dirs * Fixing up missing test sourceSet * Try another way to specify the antlr directory * Third different way * Add some logging * merge master * Change toolchain resolution * Fix tests * More tweaks to animalsniffer * Fix formatting * Trying random stuff * More random stuff * Add Kotlin static analysis and formatting * More KT cleanup * Origin/feature kotlin conventions patch (#1437) * small cleanup * fix the jvm toolchain version --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Fix static app entry point, fix build dependencies * Play within memory options * Cleanup * WIP * Fix Sonar warnings * Fix error messages in `setOperands` methods (#1447) Fix error message * Test and bugfix for AnyInCodeSystemInvocation * Share more code for assertions * Add test for convert * Reframe null checks in a way sonar can understand * more updates to make Sonar happy * Docs for Invocation --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * sync versions, merge master, remove unused code * Fix typo * Fix build deprecation warnings * Don't need the xjc conventions for cql-to-elm, that's upstream * Update README.md with Java requirements * Convert Invocation hierarchy to Kotlin (#1449) * Swap invocations to Kotlin * Remove unused imports * Surpress magic number false positives * Fix unneeded constructor * Fixes for non-deterministic behavior (#1452) * WIP * WIP * WIP * Update gradle version, fix deprecations, change XJC task configuration, add foojay resolver to buildSrc * Convert cql-to-elm preprocessor Java code to Kotlin (#1450) * Rename .java to .kt * Convert cql-to-elm preprocessor Java code to Kotlin * Use builtin methods for size and length checks * Use builtin trimStart method * Use more builtin methods and vals * Cleanup * Cleanup * Couple of tweaks * More clean-up --------- Co-authored-by: JP <jonathan.i.percival@gmail.com> * Partial conversion of the `model` package to Kotlin (#1455) * WIP * WIP * WIP * merge nondeterminism fixes * WIP * Further work on kotlin conversion of model * Signature converted * More Signature updates * Update gradle version, fix deprecations, change XJC task configuration, add foojay resolver to buildSrc * further updates to signature * Move FhirLibrarySourceLoader to correct project * Kotlin for LibraryRef, InstantiationResult * FunctionHeader * Fix usage of spread operator * Version * PropertyResolution, OperatorResolution, Operator * Add Kotlin toolchain back * Small code reduction (#1456) Small suggestions * Fixes for Sonar * QueryContext * Suppress warnings on refactored code * Fixes for Sonar warnings * Make version pattern a constant --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Convert remaining cql-to-elm classes to Kotlin * Rename .java to .kt * Convert Cql2ElmVisitor to Kotlin (WIP) * Conversion of Model hierarchy to Kotlin (#1457) * Model converted * ModelImporter * More cleanup * GenericOperator and InstantiationContextImpl * Conversion Map, Operator Map * Fixups for detekt * CompiledLibrary * ResolvedIdentifierContext * Conversion * Fixes for Sonar * Fixes for Sonar * OperatorEntry * Code review feedback * Further code cleanup * Fix build errors * Fix formatting * Rev to 2.0.20 Kotlin * Convert the `model` module to Kotlin (#1465) * ChoiceType * ClassTypeElement * InstantiationContext * TupleType, TupleTypeelement, SearchType, Relationship * NamespaceInfo * ModelContext * ModelIdentifier * ModelInfoProvider, NamespaceAware, ModelInfoReader, ModelInfoReaderFactory, ModelInfoReaderProvider * small clean up * NamespaceManager, SystemModelInfoProvider * clean up * NamedType, InvalidRedeclarationException * Break out DataType interface * DataType * BaseDataType * Little bit of cleanup for choice types * Fixing Locale for string format * ClassType * ProfileType * ListType * IntervalType * TypeParameter * TupleType, ClassType * Bug fixes for classes and tuples * GenericClassSignatureParser * More cleanup of GenericClassSignatureParser * Remove unused assertion * Conversion of the `elm` module to Kotin (#1466) * ChoiceType * ClassTypeElement * InstantiationContext * TupleType, TupleTypeelement, SearchType, Relationship * NamespaceInfo * ModelContext * ModelIdentifier * ModelInfoProvider, NamespaceAware, ModelInfoReader, ModelInfoReaderFactory, ModelInfoReaderProvider * small clean up * NamespaceManager, SystemModelInfoProvider * clean up * NamedType, InvalidRedeclarationException * Break out DataType interface * DataType * BaseDataType * Little bit of cleanup for choice types * Fixing Locale for string format * ClassType * ProfileType * ListType * IntervalType * TypeParameter * TupleType, ClassType * Bug fixes for classes and tuples * GenericClassSignatureParser * More cleanup of GenericClassSignatureParser * Remove unused assertion * TrackBack * Trackable * ElmLibraryReader/Writer and factories * SimpleElmEngine, SimpleElmEvaluator * ElmVisitor interfaces * Fix spelling * LibrarySourceProvider * Fix spelling errors * BaseElmVisitor * Remove some usages of Apache commons * Clean-up of TupleType (#1467) * Clean-up of TupleType * Fix hashcode * Fix hashCode for TupleType, make error messages/types consistent, use compact syntax for single-line functions, start using string templates * Fix exception message * More cleanup * Fix compile error * Remove stray gradle build file * Rewrite String escaping (#1468) * Rewrite string escaping * Move commons dependency downstream to engine * Escape tests * More tests * ISO characters already handled * simplify map check * Break out UCUM Service into its own module (#1471) * Break out UCUM Service into its own module * Fix tests * Fix exception types * Implement `Trackable` as an extension property (#1472) * WIP * Fixes and cleanup * Fixes * Formatting * Fix memory leak * Breakout CqlTranslatorOptionsMapper into its own project. (#1473) Breakout CqlTranslatorOptionsMapper * Move clasess to Kotlin folder * Fewer hashmaps and reduced memory usage for Trackable extension properties * Tons of cleanup of warnings * More cleanup of warnings * Cleaning up more warnings * Hundreds more warnings gone * Remove usage of String.format * Move some serialization-based tests out of cql-to-elm and into elm-jaxb * Replace xjc with custom XSD Kotlin code gen (#1479) * XSD Kotlin code gen * Disable test * Small cleanup to type generation * Renable one test * Fix a couple failing tests * Fix more tests, remove more JAXB * Fix bugs, remove unecessary null checks * Clean up warnings * Fix translator version number mismatches * Remove JAXB and Jackson modules --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> * Convert model module to be multiplatform * Fix model multiplatform * Minor cleanup * Update notes on tests failures * Update .gitignore * ELM JSON reader and writer (Kotlin feature branch) (#1489) * JSON serializers for QName and BigDecimal. Initial cleanup. * Fix Sonar warnings --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> * Parsing and serializing CQL annotations in ELM XML and JSON (Kotlin feature branch) (#1493) * XML and JSON serialization for mixed content in ELM * Fix detekt checks * Convert `elm`, `elm-xmlutil`, `model-xmlutil` to Kotlin Multiplatform (Kotlin feature branch) (#1494) Convert the elm, elm-xmlutil, model-xmlutil modules to Kotlin Multiplatform. Polyfill BigDecimal with kt-math-js in JS. * Convert `cql-to-elm` to Kotlin Multiplatform (Kotlin feature branch) (#1495) * Convert cql-to-elm to Kotlin Multiplatform * Increase maxPerIterationMs in performance tests. Re-enable libraryReferences test. * Fix failing test * Use streams * Fix streaming XML reader * Use kotlinx.io * Restore original isWellKnownModelName * Bring back original Java IO * Multiplatform identityHashCode * Simplify file names * Bring back visibility modifier * CQL to ELM UI (Kotlin feature branch) (#1499) * CQL to ELM UI * Clean up next.config.ts * Upgrade XmlUtil. Apply Spotless to all .kt files. Cleanup (Kotlin feature branch) (#1500) Upgrade XmlUtil. Enable ELM XML in CQL-to-ELM UI. Apply Spotless to all .kt files. Disable WASM build. Remove unused Kotlin/WASM code. Remove unused cql-to-elm-jackson code. Remove unused cql.xsd-kotlin-gen-conventions.gradle.kts plugin. * Sync with master (Kotlin feature branch) (#1501) * Rev to 3.21.0 * Rev to 3.22.0-SNAPSHOT * #1488: Fixed MedicationNotRequested.reasonCode cardinality (#1491) * #1488: Fixed MedicationNotRequested.reasonCode cardinality * Spotlessapply * Fix filename casing issues --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> * Translator supports namespaces (#1496) * Add a default loger XXX: This might not be necessary in the end. Please review and potentially refactor out. * Add root-dir parameter, and build out NpmLibrarySourceProvider if it is present. * Fix style * #1497: Fixed Quantity sub-type casting behavior removing unit and com… (#1498) #1497: Fixed Quantity sub-type casting behavior removing unit and comparator elements from Quantity values. * Rev to 3.22.0 * Rev to 3.23.0-SNAPSHOT --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> Co-authored-by: Bryn Rhodes <brynrhodes@users.noreply.github.com> Co-authored-by: Brian Kaney <brian@vermonster.com> * Lint JS code * Regression fixes (Kotlin feature branch) (#1502) * DefaultModelInfoProvider.load() should return null when there are no candidate model files * Add @polymorphic annotation to open classes when needed. Use separate backing field for attributes with default values. * Add default deserializer for base classes. * Inject `xsi:type="usebaseclass"` when reading XML streams to support polymorphic deserialization (for which `xsi:type` is required). * Exclude dummy classes from ELM graph test * @XmlSerialName is only used on tags * Use TypeInjectingXmlReader for reading ELM and model infos. Try to fix namespace declarations. * Add round trip tests for edge cases and JSON * Regression fixes pt. 2 (Kotlin feature branch) (#1506) * DefaultModelInfoProvider.load() should return null when there are no candidate model files * Add @polymorphic annotation to open classes when needed. Use separate backing field for attributes with default values. * Add default deserializer for base classes. * Inject `xsi:type="usebaseclass"` when reading XML streams to support polymorphic deserialization (for which `xsi:type` is required). * Exclude dummy classes from ELM graph test * @XmlSerialName is only used on tags * Use TypeInjectingXmlReader for reading ELM and model infos. Try to fix namespace declarations. * Add round trip tests for edge cases and JSON * More fixes for regressions * Upgrade XmlUtil to 0.91.0-RC1 (Kotlin feature branch) (#1507) * Upgrade XmlUtil to 0.91.0-RC1. Upgrade Kotlin to 2.1.0. Enforce escaping of special characters in XML. * Disable caching in XML config * Support for Multiplatform Maven publication (#1508) * Update Maven publication settings to support 4.0.0-SNAPSHOT for multiplatform * WIP, xmlutil upgrade * Changes and fixes (Kotlin feature branch) (#1511) * Remove unused plugin * Set up detekt and fix conflict with spotless * Fix detect annotation * Add missing getCompiledLibraries() method * Simplify condition * Bring back null check * Clean up require checks * Use this.chunks for clarity * Remove unused jsTest config * Merge `model` module into `cql` module (#1518) Merge cql and model modules, we've resovled the circular dependency * Changes and fixes pt. 2 (Kotlin feature branch) (#1514) * Remove references to Jackson * Apply Spotless * KDoc * Allow using `ModelInfoReaderFactory.getReader()` in Java * Explicitly use `this.` * Bring back dependency to the signature configuration * Clean up comments * Clean up require's * Clean up comments * Remove redundant check * Remove unused private member * Remove unused private member * Fix expect/actual build warnings * Fix opt-in build warning, fix cast build warning * Fix all 'open has no effect on final class' warnings * Fix many JS exportable warnings * merge model-xmlutil and elm-xmlutil into serialization * Update package name for merged serialization library * Run XSD code gen twice to generate classes for the cql and elm modules --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> * Remove comment * Feature kotlin fix options mapper (#1524) * Remove references to Jackson * Apply Spotless * KDoc * Allow using `ModelInfoReaderFactory.getReader()` in Java * Explicitly use `this.` * Bring back dependency to the signature configuration * Clean up comments * Clean up require's * Clean up comments * Remove redundant check * Remove unused private member * Remove unused private member * Fix expect/actual build warnings * Fix opt-in build warning, fix cast build warning * Fix all 'open has no effect on final class' warnings * Fix many JS exportable warnings * merge model-xmlutil and elm-xmlutil into serialization * Update package name for merged serialization library * WIP * OptionsTest * Further work getting options working * Run XSD code gen twice to generate classes for the cql and elm modules * Reading and writing cql-options.json as CqlTranslatorOptions with unnested cqlCompilerOptions * Custom ELM library reader and writer providers can be passed in when creating the library manager and CQL translator. (#1522) * Custom ELM library reader and writer providers can be passed in when creating the library manager and CQL translator. Cleanup. * Add ELM library reader and writer providers checks --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> * Rework serialization and codegen (Kotlin feature branch) (#1538) * Rework serialization and codegen * Fix Spotless config * Code comments * Code comments * Align default namespaces with master * Kotlin multiplatform plugin always configures Java sources compilation and 'withJava()' configuration is deprecated * Fix parameter name build warnings * Fix parameter name build warnings in generated code * Fix parameter name build warnings * Fix JsExport build warnings * Add OptIn for JsonUnquotedLiteral * KDoc and visibility modifiers * Fix typo * KDoc and visibility modifiers * Narrative mixed content serialization fixes. Optimized parsing. * Narrative mixed content serialization fixes * Merge serialization project into other projects (Kotlin feature branch) (#1546) * Merge serialization project into other projects * Add multiplatform tests for QName serializers * Fix detekt errors * Upgrade ANTLR Kotlin * Fix RandomElmGraphTest * Small cleanup of the XSD to Kotlin codegen * Fix sourceSets --------- Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> * Merge master into feature-kotlin. Implement hashCode for generated Kotlin classes. Disable the cms135 test. * Use https://github.com/ionspin/kotlin-multiplatform-bignum instead of https://github.com/gciatto/kt-math for multiplatform BigDecimal * Add WASM target (Kotlin feature branch) (#1555) * Add WASM target * Add back system model info * Add missing return statements * Add web worker support. Update the demo UI. (Kotlin feature branch) (#1589) * Add web worker support * Apply spotless * Remove comments * Fix for BigDecimal serialization. Self-closing XML tags. JS compiler improvements. (Kotlin feature branch) (#1592) Fix for BigDecimal serialization. Self-closing XML tags. JS compiler improvements. * Highlight locators in CQL to ELM UI * Improvements for CQL to ELM UI * Improvements for CQL to ELM UI * Improvements for CQL to ELM UI * Gradle fix * Library manager and data processor fixes * Make return type non nullable * Fix compiler warning * Fix translator version missing in ELM * Upgrade Kotlin to version 2.2.10 * Refactor library manager factory for JS. Add compilation metrics (performance) to CQL to ELM UI. * Fix TypeScript errors * Create publishing plugin shared by KMP and Java libraries * Migrate the rest of `cql-to-elm` to KMP (Kotlin feature branch) (#1603) Multiplatform filesystem using kotlinx.io.files * Re-export kotlinx.io. Fix compiler warnings. * Update snapshot repository URL * JS-export DefaultModelInfoProvider and DefaultLibrarySourceProvider * Add package.json * Update project overview * Update project overview * Update cql-to-elm project overview * Update cql-to-elm project overview * Update package names in CQL to ELM UI * Update project overview * Only use *.g4 files in AntlrKotlinTask --------- Co-authored-by: Anton Vasetenkov <antvaset@gmail.com> Co-authored-by: Bryn Rhodes <brynrhodes@users.noreply.github.com> Co-authored-by: Brian Kaney <brian@vermonster.com>


No description provided.