@atomist/rug
Version:
TypeScript model for Atomist Rugs, see http://docs.atomist.com/
50 lines (49 loc) • 1.91 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Convenient class to wrap Java methods, hiding AST navigation.
*/
var Method = (function () {
function Method(methodDeclaration) {
var _this = this;
this.methodDeclaration = methodDeclaration;
this.annotations = [];
this.filePath = this.methodDeclaration.containingFile().path;
this.name = this.nameNode().value();
if (methodDeclaration.methodModifier) {
methodDeclaration.methodModifier
.filter(function (mm) { return mm.annotation !== undefined; })
.forEach(function (mm) {
return _this.annotations.push(new AnnotationWrapper(mm.annotation));
});
}
if (methodDeclaration.methodHeader.annotation) {
this.annotations.concat(methodDeclaration.methodHeader.annotation
.map(function (ann) { return new AnnotationWrapper(ann); }));
}
}
Method.prototype.rename = function (newName) {
this.nameNode().update(newName);
};
Method.prototype.nameNode = function () {
return this.methodDeclaration.methodHeader.methodDeclarator.Identifier;
};
return Method;
}());
exports.Method = Method;
var AnnotationWrapper = (function () {
function AnnotationWrapper(annotation) {
this.annotation = annotation;
if (this.annotation.markerAnnotation !== undefined) {
this.typeName = this.annotation.markerAnnotation.typeName.value();
}
else if (this.annotation.normalAnnotation !== undefined) {
this.typeName = this.annotation.normalAnnotation.typeName.value();
}
else {
this.typeName = this.annotation.singleElementAnnotation.typeName.value();
}
}
return AnnotationWrapper;
}());
exports.AnnotationWrapper = AnnotationWrapper;