diff --git a/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/command/CqlCommand.java b/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/command/CqlCommand.java index 30fced7..d39eaa1 100644 --- a/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/command/CqlCommand.java +++ b/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/command/CqlCommand.java @@ -170,11 +170,12 @@ public Integer call() throws Exception { FhirContext fhirContext = FhirContext.forCached(fhirVersionEnum); IGContext igContext = null; + NpmProcessor npmProcessor = null; if (rootDir != null && igPath != null) { igContext = new IGContext(new Logger()); igContext.initializeFromIg(rootDir, igPath, toVersionNumber(fhirVersionEnum)); } else if (parentCommand != null && parentCommand.getIgContextManager() != null && rootDir != null) { - var npmProcessor = parentCommand + npmProcessor = parentCommand .getIgContextManager() .getContext(Uris.addPath(Uris.addPath(URI.create(rootDir), "input"), "cql")); if (npmProcessor != null) { @@ -182,6 +183,10 @@ public Integer call() throws Exception { } } + if (npmProcessor == null) { + npmProcessor = new NpmProcessor(igContext); + } + CqlOptions cqlOptions = CqlOptions.defaultOptions(); if (optionsPath != null) { @@ -205,24 +210,21 @@ public Integer call() throws Exception { evaluationSettings.setCqlOptions(cqlOptions); evaluationSettings.setTerminologySettings(terminologySettings); evaluationSettings.setRetrieveSettings(retrieveSettings); - evaluationSettings.setNpmProcessor(new NpmProcessor(igContext)); + evaluationSettings.setNpmProcessor(npmProcessor); for (LibraryParameter library : libraries) { // Paths are mixed types // IgStandardRepository used java nio path objects // DefaultLibraryServiceProvider used kotlin path objects // Until the language server can be ported to kotlin, the differences will exist - var libraryKotlinPath = library.libraryUrl != null - ? Path(Uris.parseOrNull(library.libraryUrl).toURL().getPath()) - : null; + var libraryUri = library.libraryUrl != null ? Uris.parseOrNull(library.libraryUrl) : null; + + var libraryKotlinPath = libraryUri != null ? Path(libraryUri.toURL().getPath()) : null; - var modelPath = library.model != null - ? Paths.get(Uris.parseOrNull(library.model.modelUrl).toURL().getPath()) - : null; + var modelPath = library.model != null ? Paths.get(Uris.parseOrNull(library.model.modelUrl)) : null; - var terminologyPath = library.terminologyUrl != null - ? Paths.get(Uris.parseOrNull(library.terminologyUrl).toURL().getPath()) - : null; + var terminologyPath = + library.terminologyUrl != null ? Paths.get(Uris.parseOrNull(library.terminologyUrl)) : null; var repository = createRepository(fhirContext, terminologyPath, modelPath); diff --git a/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/manager/CompilerOptionsManager.java b/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/manager/CompilerOptionsManager.java index 336f61a..6375820 100644 --- a/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/manager/CompilerOptionsManager.java +++ b/ls/server/src/main/java/org/opencds/cqf/cql/ls/server/manager/CompilerOptionsManager.java @@ -44,12 +44,14 @@ protected CqlCompilerOptions readOptions(URI rootUri) { CqlCompilerOptions options = null; - InputStream input = contentService.read(Uris.addPath(rootUri, "/cql-options.json")); + var optionsUri = Uris.addPath(rootUri, "/cql-options.json"); + InputStream input = contentService.read(optionsUri); if (input != null) { + // TODO: Why is this using fromFile and not fromSource? options = CqlTranslatorOptions.fromFile(Path("/cql-options.json")).getCqlCompilerOptions(); } else { - log.info("cql-options.json not found, using default options"); + log.info(String.format("%s not found, using default options", optionsUri.toString())); options = CqlTranslatorOptions.defaultOptions().getCqlCompilerOptions(); }