Skip to content

Commit

Permalink
Minor Code Cleanup (#1498)
Browse files Browse the repository at this point in the history
* Remove non-existent file paths frpm package.json file list

* Remove outdated comment and update id --> path conversion

* Update ANTLR README.md
  • Loading branch information
cmoesel authored Aug 26, 2024
1 parent e91f68e commit c1c191b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
5 changes: 4 additions & 1 deletion antlr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

The FSH Grammar is defined using [ANTLR4](https://www.antlr.org/).

To edit the grammar, edit the file:
To edit the grammar, edit the files:
```
./src/main/antlr/FSH.g4
./src/main/antlr/FSHLexer.g4
./src/main/antlr/MiniFSH.g4
./src/main/antlr/MiniFSHLexer.g4
```

You may want to install the [ANTLR4 grammar syntax support](https://marketplace.visualstudio.com/items?itemName=mike-lischke.vscode-antlr4) VS Code extension to help w/ editing and debugging.
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@
"types": "dist/index.d.ts",
"files": [
"dist/**/*.{js,json,d.ts}",
"dist/ig/files/**/*",
"dist/utils/init-project/**/*",
"antlr/**/*.g4",
"dev/fixAntlr4.js"
"antlr/**/*.g4"
],
"license": "Apache-2.0",
"devDependencies": {
Expand Down
25 changes: 3 additions & 22 deletions src/fhirtypes/ElementDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,28 +310,9 @@ export class ElementDefinition {
*/
set id(id: string) {
this._privateId = id;
// After setting the id, we should re-set the path, which is based on the id
this.path = this._privateId
.split('.')
.map(s => {
// Usually the path part is just the name without the slice.
const [name] = s.split(':', 2);
// The spec is unclear on if there is an exception in parts representing
// a specific choice type, in which case, the path is the slice name (e.g., ) if the id is
// Observation.value[x]:valueQuantity, then path is Observation.valueQuantity.
// The code to make the exception is commented below, and will remain until we can clarify
// const [name, slice] = s.split(':', 2);
// if (
// slice &&
// name.endsWith('[x]') &&
// this.type &&
// this.type.some(t => slice === `${name.slice(0, -3)}${capitalize(t.code)}`)
// ) {
// return slice;
// }
return name;
})
.join('.');
// After setting the id, we should re-set the path, which is based on the id but with all
// slice names removed (e.g., Observation.component:abc.code --> Observation.component.code)
this.path = this._privateId.replace(/(\.[^.:]+):[^.]+/g, '$1');
}

validate(): ValidationError[] {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ export async function init(
configDoc.set('copyrightYear', `${new Date().getFullYear()}+`);
const projectName = configDoc.get('name');

// Write init directory out, including user made sushi-config.yaml, files in utils/init-project, and build scripts from ig/files
// Write init directory out, including user made sushi-config.yaml and files in utils/init-project
const outputDir = path.resolve('.', projectName);
const initProjectDir = path.join(__dirname, 'init-project');
if (options.autoInitialize) {
Expand Down

0 comments on commit c1c191b

Please sign in to comment.