1 | var __extends = (this && this.__extends) || function (d, b) {
|
2 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3 | function __() { this.constructor = d; }
|
4 | __.prototype = b.prototype;
|
5 | d.prototype = new __();
|
6 | };
|
7 | var ErrorTolerantWalker = require('./utils/ErrorTolerantWalker');
|
8 | var AstUtils = require('./utils/AstUtils');
|
9 | var Rule = (function (_super) {
|
10 | __extends(Rule, _super);
|
11 | function Rule() {
|
12 | _super.apply(this, arguments);
|
13 | }
|
14 | Rule.prototype.apply = function (sourceFile) {
|
15 | return this.applyWithWalker(new MissingVisibilityModifierWalker(sourceFile, this.getOptions()));
|
16 | };
|
17 | return Rule;
|
18 | })(Lint.Rules.AbstractRule);
|
19 | exports.Rule = Rule;
|
20 | var MissingVisibilityModifierWalker = (function (_super) {
|
21 | __extends(MissingVisibilityModifierWalker, _super);
|
22 | function MissingVisibilityModifierWalker() {
|
23 | _super.apply(this, arguments);
|
24 | }
|
25 | MissingVisibilityModifierWalker.prototype.visitPropertyDeclaration = function (node) {
|
26 | if (this.isMissingVisibilityModifier(node)) {
|
27 | var failureString = 'Field missing visibility modifier: ' + this.getFailureCodeSnippet(node);
|
28 | var failure = this.createFailure(node.getStart(), node.getWidth(), failureString);
|
29 | this.addFailure(failure);
|
30 | }
|
31 | _super.prototype.visitPropertyDeclaration.call(this, node);
|
32 | };
|
33 | MissingVisibilityModifierWalker.prototype.visitMethodDeclaration = function (node) {
|
34 | if (this.isMissingVisibilityModifier(node)) {
|
35 | var failureString = 'Method missing visibility modifier: ' + this.getFailureCodeSnippet(node);
|
36 | var failure = this.createFailure(node.getStart(), node.getWidth(), failureString);
|
37 | this.addFailure(failure);
|
38 | }
|
39 | _super.prototype.visitMethodDeclaration.call(this, node);
|
40 | };
|
41 | MissingVisibilityModifierWalker.prototype.isMissingVisibilityModifier = function (node) {
|
42 | return !(AstUtils.isPrivate(node) || AstUtils.isProtected(node) || AstUtils.isPublic(node));
|
43 | };
|
44 | MissingVisibilityModifierWalker.prototype.getFailureCodeSnippet = function (node) {
|
45 | var message = node.getText();
|
46 | if (message.indexOf('\n') > 0) {
|
47 | return message.substr(0, message.indexOf('\n'));
|
48 | }
|
49 | return message;
|
50 | };
|
51 | return MissingVisibilityModifierWalker;
|
52 | })(ErrorTolerantWalker);
|
53 |
|
\ | No newline at end of file |