Skip to content

Commit bb844c3

Browse files
feat: parser unit tests
1 parent ef8dae0 commit bb844c3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/utils/apex/parser/apexparser.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { ParseTreeWalker } from 'antlr4ts/tree/ParseTreeWalker';
2020
export class ApexASTParser {
2121
private apexFilePath: string;
2222
private implementsInterface: Map<string, Token>;
23-
private callsMethods: Map<string, Token[]>;
23+
// private callsMethods: Map<string, Token[]>;
2424
private interfaceName: string;
2525
private methodName: string;
26-
private className: string;
26+
// private className: string;
2727
private astListener: ApexParserListener;
2828

2929
public get implemementsInterface(): Map<string, Token> {
@@ -37,8 +37,8 @@ export class ApexASTParser {
3737
this.astListener = this.createASTListener();
3838
}
3939

40-
public parse(filePath: string): CompilationUnitContext {
41-
const fileContent = fs.readFileSync(filePath).toString();
40+
public parse(): CompilationUnitContext {
41+
const fileContent = fs.readFileSync(this.apexFilePath).toString();
4242
const lexer = new ApexLexer(new CaseInsensitiveInputStream(CharStreams.fromString(fileContent)));
4343
const tokens = new CommonTokenStream(lexer);
4444
const parser = new ApexParser(tokens);
@@ -50,8 +50,7 @@ export class ApexASTParser {
5050

5151
private createASTListener(): ApexParserListener {
5252
class ApexMigrationListener implements ApexParserListener {
53-
public constructor(private parser: ApexASTParser) { }
54-
53+
public constructor(private parser: ApexASTParser) {}
5554
public enterClassDeclaration(ctx: ClassDeclarationContext): void {
5655
const interfaceToBeSearched = this.parser.interfaceName;
5756
if (!interfaceToBeSearched) return;
@@ -68,7 +67,7 @@ export class ApexASTParser {
6867
public enterDotExpression(ctx: DotExpressionContext): void {
6968
// console.log('*********');
7069
// console.log(ctx.expression().start.text);
71-
if (ctx.dotMethodCall()) {
70+
if (ctx.dotMethodCall() && this.parser.methodName) {
7271
// console.log(ctx.dotMethodCall().anyId().Identifier().symbol.text);
7372
// ctx.dotMethodCall().expressionList().expression(1).children[0].children[0].children[0];
7473
// console.log(ctx.dotMethodCall().expressionList().expression(1).children[0]);

0 commit comments

Comments
 (0)