Skip to content

Commit fcfd030

Browse files
committed
Merge branch 'feature/generate_test' of github.com:halcyon-tech/vscode-rpgle into feature/generate_test
Signed-off-by: worksofliam <[email protected]>
2 parents 78ee5b7 + 5d2c304 commit fcfd030

File tree

2 files changed

+128
-1
lines changed

2 files changed

+128
-1
lines changed

language/models/fixed.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ function calculateToken(lineNumber, startingPos, value, type) {
1414
return;
1515
}
1616

17-
if (type === `special-ind`) {
17+
switch (type) {
18+
case `special-ind`:
1819
type = `special`;
1920
resultValue = `*IN` + resultValue;
21+
break;
22+
23+
case `opcode`:
24+
// Remove extender from opcode
25+
if (resultValue.includes(`(`) && resultValue.includes(`)`)) {
26+
resultValue = resultValue.substring(0, resultValue.indexOf(`(`));
27+
}
28+
break;
2029
}
2130

2231
const frontSpaces = value.length - value.trimStart().length;

tests/suite/basics.test.ts

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,4 +1411,122 @@ test('can define on the first line', async () => {
14111411

14121412
const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: false });
14131413
expect(cache.subroutines.length).toBe(3);
1414+
});
1415+
1416+
test('fixed-format c spec', async () => {
1417+
const lines = [
1418+
` Farticle1 UF E K DISK`,
1419+
``,
1420+
` d UpdArt pr`,
1421+
` d qty 5 0 value`,
1422+
` d id like(new.ODARID)`,
1423+
``,
1424+
` D PARM1 DS`,
1425+
` * Physical file name`,
1426+
` D FNAME 10`,
1427+
` * Physical file library`,
1428+
` D LNAME 10`,
1429+
` * Member name`,
1430+
` D MNAME 10`,
1431+
` * Trigger event 1=Ins, 2=Del, 3=Upd`,
1432+
` D TEVEN 1`,
1433+
` * Trigger time 1=After, 2=Before`,
1434+
` D TTIME 1`,
1435+
` * Commit lock level`,
1436+
` D CMTLCK 1`,
1437+
` * Reserved`,
1438+
` D 3`,
1439+
` * CCSID`,
1440+
` D CCSID 10i 0`,
1441+
` * Reserved`,
1442+
` D 8`,
1443+
` * Offset to the original record`,
1444+
` D OLDOFF 10i 0`,
1445+
` * length of the original record`,
1446+
` D OLDLEN 10i 0`,
1447+
` * Offset to the original record null byte map`,
1448+
` D ONOFF 10i 0`,
1449+
` * length of the null byte map`,
1450+
` D ONLEN 10i 0`,
1451+
` * Offset to the new record`,
1452+
` D NEWOFF 10i 0`,
1453+
` * length of the new record`,
1454+
` D NEWLEN 10i 0`,
1455+
` * Offset to the new record null byte map`,
1456+
` D NNOFF 10i 0`,
1457+
` * length of the null byte map`,
1458+
` D NNLEN 10i 0`,
1459+
``,
1460+
` * Trigger Buffer Length`,
1461+
` D parm2 s 10i 0`,
1462+
``,
1463+
` * Record to be inserted or new values`,
1464+
` D NEW E DS EXTNAME(detord)`,
1465+
` D qualified`,
1466+
` D based(pn)`,
1467+
``,
1468+
` * Record to be deleted or old values`,
1469+
` D OLD E DS EXTNAME(detord)`,
1470+
` D qualified`,
1471+
` D based(po)`,
1472+
` * SET UP THE ENTRY PARAMETER LIST.`,
1473+
``,
1474+
` C *ENTRY PLIST`,
1475+
` C PARM PARM1`,
1476+
` C PARM PARM2`,
1477+
` C if %parms = 0`,
1478+
` C seton lr`,
1479+
` C return`,
1480+
` C ENDIF`,
1481+
` C select`,
1482+
` c when teven = '1'`,
1483+
` c eval pn = %addr(parm1) + newoff`,
1484+
` c callp UpdArt(new.odqty:new.odarid)`,
1485+
` c when teven = '2'`,
1486+
` c eval po = %addr(parm1) + oldoff`,
1487+
` c callp(e) addlogEntry('ORD700:Order Line deleted ' +`,
1488+
` c %char(Old.odorid) + ' ' + %char(Old.odline)`,
1489+
` c + ' article : ' + old.odarid`,
1490+
` c + ' quantity : ' + %char(old.odqty))`,
1491+
` c callp UpdArt(-Old.odqty + Old.odqtyliv:old.odarid)`,
1492+
` c when teven = '3'`,
1493+
` c eval pn = %addr(parm1) + newoff`,
1494+
` c eval po = %addr(parm1) + oldoff`,
1495+
` c if new.odarid = Old.odarid`,
1496+
` c callp UpdArt((New.odqty - Old.odqty)`,
1497+
` c - (New.odqtyLiv - Old.odqtyLiv)`,
1498+
` c :new.odarid)`,
1499+
` c else`,
1500+
` c callp UpdArt(new.odqty- new.odqtyliv:new.odarid)`,
1501+
` c callp UpdArt(-Old.odqty + Old.odqtyliv:old.odarid)`,
1502+
` c endif`,
1503+
` c endsl`,
1504+
` c return`,
1505+
``,
1506+
` P UpdArt b`,
1507+
` d UpdArt pi`,
1508+
` d qty 5 0 value`,
1509+
` d id like(new.ODARID)`,
1510+
` c if qty = 0`,
1511+
` c return`,
1512+
` c ENDIF`,
1513+
` c id chain article1`,
1514+
` c if not %found`,
1515+
` c return`,
1516+
` c ENDIF`,
1517+
` c eval ARCUSQTY += qty`,
1518+
` c update farti`,
1519+
` P UpdArt e`,
1520+
].join(`\n`);
1521+
1522+
const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: false });
1523+
expect(cache.constants.length).toBe(0);
1524+
expect(cache.procedures.length).toBe(1);
1525+
expect(cache.procedures[0].name).toBe(`UpdArt`);
1526+
expect(cache.procedures[0].subItems.length).toBe(2);
1527+
1528+
console.log(cache.variables);
1529+
expect(cache.structs.length).toBe(3);
1530+
expect(cache.variables.length).toBe(1);
1531+
14141532
});

0 commit comments

Comments
 (0)