Skip to content

Commit 4ed0ca3

Browse files
committed
feat: add lsp to #11
1 parent 94178f2 commit 4ed0ca3

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

fkl_parser/src/parser/parser.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ fn consume_context_map(pair: Pair<Rule>) -> ContextMapDecl {
9898
for p in pair.into_inner() {
9999
match p.as_rule() {
100100
Rule::identifier => {
101-
identify.name = p.as_str().to_string();
102101
identify.loc = Loc::from_pair(p.as_span());
102+
identify.name = p.as_str().to_string();
103103
}
104104
Rule::context_decl => {
105105
let context_decl = consume_context(p);
@@ -112,6 +112,7 @@ fn consume_context_map(pair: Pair<Rule>) -> ContextMapDecl {
112112
let mut target_type: Vec<String> = vec![];
113113

114114
for p in p.into_inner() {
115+
let loc = Loc::from_pair(p.as_span());
115116
match p.as_rule() {
116117
Rule::left_id | Rule::right_id => {
117118
let context_name = p.as_str().to_string();
@@ -121,7 +122,7 @@ fn consume_context_map(pair: Pair<Rule>) -> ContextMapDecl {
121122
domain_events: vec![],
122123
aggregates: vec![],
123124
used_domain_objects: vec![],
124-
loc: Default::default(),
125+
loc,
125126
});
126127
}
127128
Rule::rel_symbol => {
@@ -200,6 +201,7 @@ fn rel_defs(pair: Pair<Rule>) -> Vec<String> {
200201

201202
fn consume_context(pair: Pair<Rule>) -> BoundedContextDecl {
202203
let mut context = BoundedContextDecl::default();
204+
context.loc = Loc::from_pair(pair.as_span());
203205
for p in pair.into_inner() {
204206
match p.as_rule() {
205207
Rule::identifier => {
@@ -277,6 +279,7 @@ pub fn consume_use_domain_events(pair: Pair<Rule>) -> Vec<DomainEventDecl> {
277279

278280
fn consume_entity(pair: Pair<Rule>) -> EntityDecl {
279281
let mut entity = EntityDecl::default();
282+
entity.loc = Loc::from_pair(pair.as_span());
280283
for p in pair.into_inner() {
281284
match p.as_rule() {
282285
Rule::identifier => {
@@ -942,14 +945,14 @@ Context ShoppingCarContext {
942945
domain_events: vec![],
943946
aggregates: vec![],
944947
used_domain_objects: vec![],
945-
loc: Default::default(),
948+
loc: Loc(76, 87),
946949
},
947950
BoundedContextDecl {
948951
name: "ShoppingCarContext".to_string(),
949952
domain_events: vec![],
950953
aggregates: vec![],
951954
used_domain_objects: vec![],
952-
loc: Default::default(),
955+
loc: Loc(53, 71),
953956
},
954957
],
955958
relations: vec![
@@ -1016,7 +1019,7 @@ Aggregate ShoppingCart {
10161019
loc: Loc(75, 87),
10171020
}],
10181021
value_objects: vec![],
1019-
loc: Default::default(),
1022+
loc: Loc(28, 92),
10201023
}],
10211024
value_objects: vec![],
10221025
domain_events: vec![],
@@ -1227,15 +1230,15 @@ Entity SalesPerson {
12271230
fields: vec![],
12281231
},
12291232
],
1230-
loc: Default::default(),
1233+
loc: Loc(38, 265),
12311234
}],
12321235
value_objects: vec![],
12331236
domain_events: vec![],
12341237
loc: Loc(17, 269),
12351238
}
12361239
],
12371240
used_domain_objects: vec![],
1238-
loc: Default::default(),
1241+
loc: Loc(0, 271),
12391242
}));
12401243
}
12411244

@@ -1337,12 +1340,12 @@ Component SalesComponent {
13371340
VariableDefinition { name: "createdAt".to_string(), type_type: "LocalDateTime".to_string(), initializer: None, loc: Loc(156, 180) },
13381341
VariableDefinition { name: "screeningId".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(186, 205) },
13391342
VariableDefinition { name: "screeningStartTime".to_string(), type_type: "LocalDateTime".to_string(), initializer: None, loc: Loc(211, 244) },
1340-
VariableDefinition { name: "name".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(250, 262) },
1343+
VariableDefinition { name: "name".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(250, 262) },
13411344
VariableDefinition { name: "surname".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(268, 283) },
13421345
VariableDefinition { name: "tickets".to_string(), type_type: "Set<Ticket>".to_string(), initializer: None, loc: Loc(289, 309) },
13431346
VariableDefinition { name: "totalPrice".to_string(), type_type: "BigDecimal".to_string(), initializer: None, loc: Loc(315, 337) }],
13441347
value_objects: vec![],
1345-
loc: Default::default(),
1348+
loc: Loc(0, 344),
13461349
}));
13471350
}
13481351

@@ -1809,7 +1812,7 @@ env Local {
18091812
inline_doc: "".to_string(),
18101813
fields: vec![
18111814
VariableDefinition { name: "id".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(116, 126) },
1812-
VariableDefinition { name: "name".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(144, 156) },
1815+
VariableDefinition { name: "name".to_string(), type_type: "String".to_string(), initializer: None, loc: Loc(144, 156) },
18131816
],
18141817
value_objects: vec![],
18151818
loc: Loc(91, 171),
@@ -1834,7 +1837,7 @@ env Local {
18341837
},
18351838
],
18361839
value_objects: vec![],
1837-
loc: Default::default(),
1840+
loc: Loc(185, 342),
18381841
},
18391842
],
18401843
value_objects: vec![],
@@ -1844,7 +1847,7 @@ env Local {
18441847
],
18451848
domain_events: vec![],
18461849
used_domain_objects: vec![],
1847-
loc: Default::default(),
1850+
loc: Loc(30, 358),
18481851
},
18491852
],
18501853
relations: vec![],

0 commit comments

Comments
 (0)