UNPKG

@vlocode/apex

Version:
57 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeclarationVisitor = void 0; const util_1 = require("@vlocode/util"); const syntaxTreeVisitor_1 = require("./syntaxTreeVisitor"); class DeclarationVisitor extends syntaxTreeVisitor_1.ApexSyntaxTreeVisitor { constructor(state) { super(state); } visitModifier(ctx) { this.addModifier(ctx.getText().toLowerCase()); this.visitAccessModifier(ctx); return this.state; } addModifier(modifier) { if (!this.state.modifiers) { this.state.modifiers = []; } this.state.modifiers.push(modifier); } visitAccessModifier(ctx) { if (ctx.PUBLIC()) { this.state.access = 'public'; } else if (ctx.PROTECTED()) { this.state.access = 'protected'; } else if (ctx.GLOBAL()) { this.state.access = 'global'; } else if (ctx.PRIVATE()) { this.state.access = 'private'; } else { return false; } return true; } addRef(refs, source) { if (refs === undefined || refs === null) { return; } if (!this.state.refs) { this.state.refs = []; } for (const ref of Array.isArray(refs) ? refs : [refs]) { if (ref.name === 'void') { continue; } if (!this.state.refs.find(r => (source === undefined || r.source === source) && (0, util_1.stringEquals)(r.name, ref.name, { caseInsensitive: true }))) { this.state.refs.push({ ...ref, source: source ?? ref.source }); } } } } exports.DeclarationVisitor = DeclarationVisitor; //# sourceMappingURL=declarationVisitor.js.map