Skip to content

Commit

Permalink
Update antlr4 dependency (#1309)
Browse files Browse the repository at this point in the history
Update import paths for antlr4 classes. Remove tsconfig-paths, as it is
no longer needed for remapping. Remove @types/antlr4, since types are
now included in the main antlr4 package.

Co-authored-by: Chris Moesel <[email protected]>
  • Loading branch information
mint-thompson and cmoesel authored Jul 25, 2023
1 parent 8dc0129 commit 1aa7826
Show file tree
Hide file tree
Showing 23 changed files with 1,096 additions and 2,008 deletions.
2 changes: 1 addition & 1 deletion antlr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {
}

dependencies {
antlr "org.antlr:antlr4:4.9.3"
antlr "org.antlr:antlr4:4.13.0"
}

generateGrammarSource {
Expand Down
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module.exports = {
}
},
moduleFileExtensions: ['js', 'ts'],
moduleNameMapper: {
'^antlr4(.*)$': '<rootDir>/node_modules/antlr4/src/antlr4$1'
},
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest'
},
Expand Down
110 changes: 15 additions & 95 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@
],
"license": "Apache-2.0",
"devDependencies": {
"@types/antlr4": "~4.7.2",
"@types/diff": "^4.0.2",
"@types/fs-extra": "^8.1.0",
"@types/html-minifier-terser": "5.1.1",
"@types/ini": "^1.3.30",
"@types/jest": "^28.1.6",
"@types/json-diff": "^0.7.0",
"@types/lodash": "^4.14.149",
"@types/node": "^12.12.34",
"@types/node": "^20.4.2",
"@types/opener": "^1.4.0",
"@types/readline-sync": "^1.4.3",
"@types/sax": "^1.2.1",
Expand Down Expand Up @@ -82,7 +81,7 @@
},
"dependencies": {
"ajv": "^8.12.0",
"antlr4": "~4.9.3",
"antlr4": "~4.13.0",
"axios": "^0.21.4",
"chalk": "^3.0.0",
"commander": "^8.2.0",
Expand All @@ -99,7 +98,6 @@
"sax": "^1.2.4",
"temp": "^0.9.1",
"title-case": "^3.0.2",
"tsconfig-paths": "^3.14.1",
"valid-url": "^1.0.9",
"winston": "^3.3.3",
"yaml": "^1.9.2"
Expand Down
8 changes: 0 additions & 8 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/usr/bin/env node

import { register } from 'tsconfig-paths';
register({
baseUrl: __dirname,
paths: {
'antlr4/*': ['../node_modules/antlr4/src/antlr4/*']
}
});

import path from 'path';
import fs from 'fs-extra';
import { Command, OptionValues, Option } from 'commander';
Expand Down
11 changes: 5 additions & 6 deletions src/import/FSHErrorListener.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { TextLocation } from '../fshtypes';
import { Recognizer, Token } from 'antlr4';
import { Recognizer, Token, ErrorListener } from 'antlr4';
import { logger } from '../utils/FSHLogger';
import { ErrorListener } from 'antlr4/error';

export class FSHErrorListener extends ErrorListener {
export class FSHErrorListener extends ErrorListener<Token> {
constructor(readonly file: string) {
super();
}

syntaxError(
recognizer: Recognizer,
recognizer: Recognizer<Token>,
offendingSymbol: Token,
line: number,
column: number,
Expand All @@ -26,7 +25,7 @@ export class FSHErrorListener extends ErrorListener {
}

buildErrorMessage(
recognizer: Recognizer,
recognizer: Recognizer<Token>,
offendingSymbol: Token,
line: number,
column: number,
Expand Down Expand Up @@ -256,7 +255,7 @@ export class FSHErrorListener extends ErrorListener {
* @param token - the token ahead of the token we want returned
* @returns the previous non-WS token or undefined if there is no previous non-WS token
*/
function getPreviousNonWsToken(recognizer: Recognizer, token: Token): Token | undefined {
function getPreviousNonWsToken(recognizer: Recognizer<Token>, token: Token): Token | undefined {
if (token == null) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/import/FSHImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ import {
PathRule
} from '../fshtypes/rules';
import { splitOnPathPeriods } from '../fhirtypes/common';
import { ParserRuleContext, InputStream, CommonTokenStream } from 'antlr4';
import { ParserRuleContext, InputStream, CommonTokenStream, TerminalNode } from 'antlr4';
import { logger, switchToSecretLogger, LoggerData, restoreMainLogger } from '../utils/FSHLogger';
import { TerminalNode } from 'antlr4/tree/Tree';
import {
RequiredMetadataError,
ValueSetFilterOperatorError,
Expand Down
2 changes: 1 addition & 1 deletion src/import/generated/FSH.interp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/import/generated/FSHLexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit 1aa7826

Please sign in to comment.