Skip to content

Commit

Permalink
Update FSH parser+lexer and antlr4 dependency (#92)
Browse files Browse the repository at this point in the history
* Update FSH parser+lexer and antlr4 dependency

Rules for alias and paramRuleSet are changed. Use new child rules to get
entity details.

Resolve with null instead of rejecting when providing definition. The
result is the same, but it avoids filling up the extension host logs.

* Remove antlr4 from dependency notes
  • Loading branch information
mint-thompson authored Sep 26, 2024
1 parent 8b87f74 commit ff0313e
Show file tree
Hide file tree
Showing 11 changed files with 10,410 additions and 9,304 deletions.
1 change: 0 additions & 1 deletion DEPENDENCY-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ As of 2024 Sept 4:
The `npm outdated` command reports some dependencies as outdated. They are not being updated at this time for the reasons given below:

- `@types/node`: Don't update until Node 22 is LTS version (currently Node 20).
- `antlr4` and `@types/antlr4`: Updating ANLTR requires additional updates. Revisit this upgrade when time permits.
- `chai`: Chai v5 is an esmodule.
31 changes: 17 additions & 14 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.1",
"@types/antlr4": "^4.7.2",
"@types/antlr4": "^4.11.6",
"@types/chai": "^4.3.19",
"@types/chai-spies": "^1.0.6",
"@types/fs-extra": "^11.0.4",
Expand All @@ -140,7 +140,7 @@
"typescript": "^5.5.4"
},
"dependencies": {
"antlr4": "~4.8.0",
"antlr4": "~4.13.2",
"axios": "^1.7.7",
"semver": "^7.6.3",
"yaml": "^2.5.0"
Expand Down
12 changes: 8 additions & 4 deletions src/FshDefinitionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class FshDefinitionProvider implements DefinitionProvider {
// Update info for all files that have been modified, but not saved
this.handleDirtyFiles();
const name = getTargetName(document, position);
resolve(this.nameInformation.get(name).map(info => info.location));
resolve(this.nameInformation.get(name)?.map(info => info.location));
} catch (e) {
reject(e);
}
Expand All @@ -231,16 +231,20 @@ function getEntityDetails(entity: any): EntityDetails {
let aliasValue: string;
// some entities work a little differently
if (entity.alias()) {
name = entity.alias().SEQUENCE()[0].getText();
name = entity.alias().name().getText();
startLine = entity.alias().start.line - 1;
aliasValue = entity.alias().SEQUENCE()[1]?.getText() ?? entity.alias().CODE()?.getText();
aliasValue = entity.alias().SEQUENCE()?.getText() ?? entity.alias().CODE()?.getText();
entityType = 'Alias';
} else if (entity.ruleSet()) {
name = entity.ruleSet().RULESET_REFERENCE().getText().trim();
startLine = entity.ruleSet().start.line - 1;
entityType = 'RuleSet';
} else if (entity.paramRuleSet()) {
const rulesetReference = entity.paramRuleSet().PARAM_RULESET_REFERENCE().getText();
const rulesetReference = entity
.paramRuleSet()
.paramRuleSetRef()
.PARAM_RULESET_REFERENCE()
.getText();
const paramListStart = rulesetReference.indexOf('(');
name = rulesetReference.slice(0, paramListStart).trim();
startLine = entity.paramRuleSet().start.line - 1;
Expand Down
172 changes: 94 additions & 78 deletions src/lang/FSH.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,97 @@ KW_SEVERITY=19
KW_USAGE=20
KW_SOURCE=21
KW_TARGET=22
KW_MOD=23
KW_MS=24
KW_SU=25
KW_TU=26
KW_NORMATIVE=27
KW_DRAFT=28
KW_FROM=29
KW_EXAMPLE=30
KW_PREFERRED=31
KW_EXTENSIBLE=32
KW_REQUIRED=33
KW_CONTAINS=34
KW_NAMED=35
KW_AND=36
KW_ONLY=37
KW_OR=38
KW_OBEYS=39
KW_TRUE=40
KW_FALSE=41
KW_INCLUDE=42
KW_EXCLUDE=43
KW_CODES=44
KW_WHERE=45
KW_VSREFERENCE=46
KW_SYSTEM=47
KW_EXACTLY=48
KW_INSERT=49
EQUAL=50
STAR=51
COLON=52
COMMA=53
ARROW=54
STRING=55
MULTILINE_STRING=56
NUMBER=57
UNIT=58
CODE=59
CONCEPT_STRING=60
DATETIME=61
TIME=62
CARD=63
REFERENCE=64
CANONICAL=65
CARET_SEQUENCE=66
REGEX=67
PARAMETER_DEF_LIST=68
BLOCK_COMMENT=69
SEQUENCE=70
WHITESPACE=71
LINE_COMMENT=72
PARAM_RULESET_REFERENCE=73
RULESET_REFERENCE=74
'?!'=23
'MS'=24
'SU'=25
'TU'=26
'N'=27
'D'=28
'from'=29
'contains'=34
'named'=35
'and'=36
'only'=37
'or'=38
'obeys'=39
'true'=40
'false'=41
'include'=42
'exclude'=43
'codes'=44
'where'=45
'valueset'=46
'system'=47
'insert'=49
'='=50
':'=52
','=53
'->'=54
KW_CONTEXT=23
KW_CHARACTERISTICS=24
KW_MOD=25
KW_MS=26
KW_SU=27
KW_TU=28
KW_NORMATIVE=29
KW_DRAFT=30
KW_FROM=31
KW_EXAMPLE=32
KW_PREFERRED=33
KW_EXTENSIBLE=34
KW_REQUIRED=35
KW_CONTAINS=36
KW_NAMED=37
KW_AND=38
KW_ONLY=39
KW_OR=40
KW_OBEYS=41
KW_TRUE=42
KW_FALSE=43
KW_INCLUDE=44
KW_EXCLUDE=45
KW_CODES=46
KW_WHERE=47
KW_VSREFERENCE=48
KW_SYSTEM=49
KW_EXACTLY=50
KW_INSERT=51
KW_CONTENTREFERENCE=52
EQUAL=53
STAR=54
COLON=55
COMMA=56
ARROW=57
STRING=58
MULTILINE_STRING=59
NUMBER=60
UNIT=61
CODE=62
CONCEPT_STRING=63
DATETIME=64
TIME=65
CARD=66
REFERENCE=67
CODEABLE_REFERENCE=68
CANONICAL=69
CARET_SEQUENCE=70
REGEX=71
BLOCK_COMMENT=72
SEQUENCE=73
WHITESPACE=74
LINE_COMMENT=75
PARAM_RULESET_REFERENCE=76
RULESET_REFERENCE=77
BRACKETED_PARAM=78
LAST_BRACKETED_PARAM=79
PLAIN_PARAM=80
LAST_PLAIN_PARAM=81
QUOTED_CONTEXT=82
LAST_QUOTED_CONTEXT=83
UNQUOTED_CONTEXT=84
LAST_UNQUOTED_CONTEXT=85
CONTEXT_WHITESPACE=86
CODE_ITEM=87
LAST_CODE_ITEM=88
CODE_LIST_WHITESPACE=89
'?!'=25
'MS'=26
'SU'=27
'TU'=28
'N'=29
'D'=30
'from'=31
'contains'=36
'named'=37
'and'=38
'only'=39
'or'=40
'obeys'=41
'true'=42
'false'=43
'include'=44
'exclude'=45
'codes'=46
'where'=47
'valueset'=48
'system'=49
'insert'=51
'contentReference'=52
'='=53
':'=55
','=56
'->'=57
Loading

0 comments on commit ff0313e

Please sign in to comment.