forked from cqframework/clinical_quality_language
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow-up items for 3.0.0-SNAPSHOT (cqframework#1178)
* State refactor WIP * WIP * WIP * WIP * Fixes for Options serialization * WIP * WIP * WIP * WIP * Sort statement list * Fix failing tests * Fix failing tests
- Loading branch information
Showing
185 changed files
with
7,435 additions
and
3,334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "automatic", | ||
"java.compile.nullAnalysis.mode": "automatic", | ||
"java.jdt.ls.vmargs": "-noverify -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication" | ||
"java.jdt.ls.vmargs": "-noverify -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication", | ||
"cSpell.words": [ | ||
"bools", | ||
"datumedge", | ||
"fhirpath", | ||
"hamcrest", | ||
"Inferencing", | ||
"qicore", | ||
"testng", | ||
"trackback" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/CompilerOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package org.cqframework.cql.cql2elm; | ||
|
||
import org.hl7.cql_annotations.r1.CqlToElmBase; | ||
import org.hl7.cql_annotations.r1.CqlToElmInfo; | ||
import org.hl7.elm.r1.Library; | ||
|
||
import java.util.EnumSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* This class provides functions for extracting and parsing CQL Compiler | ||
* Options from | ||
* a Library | ||
*/ | ||
public class CompilerOptions { | ||
|
||
private CompilerOptions() { | ||
// intentionally empty | ||
} | ||
|
||
/** | ||
* Gets the compiler options used to generate an elm Library. | ||
* | ||
* Returns null if the compiler options could not be determined. | ||
* (for example, the Library was translated without annotations) | ||
* | ||
* @param library The library to extracts the options from. | ||
* @return The set of options used to translate the library. | ||
*/ | ||
public static Set<CqlCompilerOptions.Options> getCompilerOptions(Library library) { | ||
requireNonNull(library, "library can not be null"); | ||
if (library.getAnnotation() == null || library.getAnnotation().isEmpty()) { | ||
return null; | ||
} | ||
|
||
String compilerOptions = getCompilerOptions(library.getAnnotation()); | ||
return parseCompilerOptions(compilerOptions); | ||
} | ||
|
||
private static String getCompilerOptions(List<CqlToElmBase> annotations) { | ||
for (CqlToElmBase base : annotations) { | ||
if (base instanceof CqlToElmInfo) { | ||
if (((CqlToElmInfo) base).getTranslatorOptions() != null) { | ||
return ((CqlToElmInfo) base).getTranslatorOptions(); | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Parses a string representing CQL compiler Options into an EnumSet. The | ||
* string is expected | ||
* to be a comma delimited list of values from the CqlCompiler.Options | ||
* enumeration. | ||
* For example "EnableListPromotion, EnableListDemotion". | ||
* | ||
* @param compilerOptions the string to parse | ||
* @return the set of options | ||
*/ | ||
public static Set<CqlCompilerOptions.Options> parseCompilerOptions(String compilerOptions) { | ||
if (compilerOptions == null || compilerOptions.isEmpty()) { | ||
return null; | ||
} | ||
|
||
EnumSet<CqlCompilerOptions.Options> optionSet = EnumSet.noneOf(CqlCompilerOptions.Options.class); | ||
String[] options = compilerOptions.trim().split(","); | ||
|
||
for (String option : options) { | ||
optionSet.add(CqlCompilerOptions.Options.valueOf(option)); | ||
} | ||
|
||
return optionSet; | ||
} | ||
|
||
/** | ||
* Gets the compiler version used to generate an elm Library. | ||
* | ||
* Returns null if the compiled version could not be determined. (for example, | ||
* the Library was | ||
* compiled without annotations) | ||
* | ||
* @param library The library to extracts the compiler version from. | ||
* @return The version of compiler used to compiler the library. | ||
*/ | ||
public static String getCompilerVersion(Library library) { | ||
requireNonNull(library, "library can not be null"); | ||
if (library.getAnnotation() == null || library.getAnnotation().isEmpty()) { | ||
return null; | ||
} | ||
|
||
return getCompilerVersion(library.getAnnotation()); | ||
} | ||
|
||
private static String getCompilerVersion(List<CqlToElmBase> annotations) { | ||
for (CqlToElmBase o : annotations) { | ||
if (o instanceof CqlToElmInfo) { | ||
CqlToElmInfo c = (CqlToElmInfo) o; | ||
return c.getTranslatorVersion(); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.