"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/first-mate/lib/injections.js" (7 Feb 2017, 2056 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var Injections, Scanner, ScopeSelector, _;
    3 
    4   _ = require('underscore-plus');
    5 
    6   Scanner = require('./scanner');
    7 
    8   ScopeSelector = require('./scope-selector');
    9 
   10   module.exports = Injections = (function() {
   11     function Injections(grammar, injections) {
   12       var pattern, patterns, regex, selector, values, _i, _len, _ref, _ref1;
   13       this.grammar = grammar;
   14       if (injections == null) {
   15         injections = {};
   16       }
   17       this.injections = [];
   18       this.scanners = {};
   19       for (selector in injections) {
   20         values = injections[selector];
   21         if (!((values != null ? (_ref = values.patterns) != null ? _ref.length : void 0 : void 0) > 0)) {
   22           continue;
   23         }
   24         patterns = [];
   25         _ref1 = values.patterns;
   26         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
   27           regex = _ref1[_i];
   28           pattern = this.grammar.createPattern(regex);
   29           patterns.push.apply(patterns, pattern.getIncludedPatterns(grammar, patterns));
   30         }
   31         this.injections.push({
   32           selector: new ScopeSelector(selector),
   33           patterns: patterns
   34         });
   35       }
   36     }
   37 
   38     Injections.prototype.getScanner = function(injection) {
   39       var scanner;
   40       if (injection.scanner != null) {
   41         return injection.scanner;
   42       }
   43       scanner = new Scanner(injection.patterns);
   44       injection.scanner = scanner;
   45       return scanner;
   46     };
   47 
   48     Injections.prototype.getScanners = function(ruleStack) {
   49       var injection, scanner, scanners, scopes, _i, _len, _ref;
   50       if (this.injections.length === 0) {
   51         return [];
   52       }
   53       scanners = [];
   54       scopes = this.grammar.scopesFromStack(ruleStack);
   55       _ref = this.injections;
   56       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
   57         injection = _ref[_i];
   58         if (!(injection.selector.matches(scopes))) {
   59           continue;
   60         }
   61         scanner = this.getScanner(injection);
   62         scanners.push(scanner);
   63       }
   64       return scanners;
   65     };
   66 
   67     return Injections;
   68 
   69   })();
   70 
   71 }).call(this);