@veecode-platform/safira-cli
Version:
Generate a microservice project from your spec.
49 lines (48 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuarkusMethodExtract = exports.SpringMethodExtract = exports.MethodExtract = void 0;
class MethodExtract {
extractMethods(classString) {
classString = classString.replace(this.getRemoveAnnotationsTemplate(), "");
return (classString.match(MethodExtract._regexExp) || []).map(exp => exp.trim().replace(/\n/g, " ").replace(/ +/g, " ").replace(";", ""));
}
getRemoveAnnotationsTemplate() {
return new RegExp(`@(${this.getRemoveAnnotationList().join("|")})\\(([^\\)]+)\\)`, "g");
}
}
exports.MethodExtract = MethodExtract;
MethodExtract._regexExp = /(^\s*)(public|protected|private|static|\s) +[\s\w,<>[\]]+\s+(\w+) *\([^)]*\) *({?|[^;])*;/gm;
class SpringMethodExtract extends MethodExtract {
constructor() {
super();
}
getRemoveAnnotationList() {
return ["PathVariable",
"RequestPart",
"RequestBody",
"RequestHeader",
"RequestParam"];
}
static get instance() {
if (!this._instance) {
this._instance = new this();
}
return this._instance;
}
}
exports.SpringMethodExtract = SpringMethodExtract;
class QuarkusMethodExtract extends MethodExtract {
constructor() {
super();
}
getRemoveAnnotationList() {
return ["HeaderParam", "PathParam", "QueryParam", "FormParam"];
}
static get instance() {
if (!this._instance) {
this._instance = new this();
}
return this._instance;
}
}
exports.QuarkusMethodExtract = QuarkusMethodExtract;