@abaplint/core
Version:
abaplint - Core API
49 lines • 2.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MethodImplementation = void 0;
const Expressions = require("../../2_statements/expressions");
const _object_oriented_1 = require("../_object_oriented");
const _scope_type_1 = require("../_scope_type");
const _reference_1 = require("../_reference");
const _syntax_input_1 = require("../_syntax_input");
class MethodImplementation {
runSyntax(node, input) {
const helper = new _object_oriented_1.ObjectOriented(input.scope);
const className = input.scope.getName();
const methodToken = node.findFirstExpression(Expressions.MethodName).getFirstToken();
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
const classDefinition = input.scope.findClassDefinition(className);
if (classDefinition === undefined) {
const message = "Class definition for \"" + className + "\" not found";
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
return;
}
const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
const start = node.getFirstToken().getStart();
if ((methodDefinition === null || methodDefinition === void 0 ? void 0 : methodDefinition.isStatic()) === false) {
input.scope.push(_scope_type_1.ScopeType.MethodInstance, methodName, start, input.filename);
input.scope.addList(classDefinition.getAttributes().getInstance());
}
input.scope.push(_scope_type_1.ScopeType.Method, methodName, start, input.filename);
// note: the scope must be pushed before returning
if (methodDefinition === undefined) {
const message = "Method definition \"" + methodName + "\" not found";
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
return;
}
input.scope.addReference(methodToken, methodDefinition, _reference_1.ReferenceType.MethodImplementationReference, input.filename);
input.scope.addList(methodDefinition.getParameters().getAll());
for (const i of helper.findInterfaces(classDefinition)) {
if (methodName.toUpperCase().startsWith(i.name.toUpperCase() + "~") === false) {
continue;
}
const idef = input.scope.findInterfaceDefinition(i.name);
if (idef === undefined) {
continue;
}
input.scope.addReference(methodToken, idef, _reference_1.ReferenceType.ObjectOrientedReference, input.filename);
}
}
}
exports.MethodImplementation = MethodImplementation;
//# sourceMappingURL=method_implementation.js.map