'use strict';

var Filter = require('broccoli-filter');

function DummyFilter(inputTree, options) {
  Filter.call(this, inputTree, options);
}

DummyFilter.prototype = Object.create(Filter.prototype);
DummyFilter.prototype.constructor = DummyFilter;

DummyFilter.prototype.extensions = ['js'];
DummyFilter.prototype.targetExtension = 'js';

DummyFilter.prototype.transform = function(string, options) {
  return string.replace(/__PREPROCESSOR_REPLACEMENT_TOKEN__/, '"replacedByPreprocessor"');
};

DummyFilter.prototype.processString = function (string, relativePath) {
  return this.transform(string, {});
};

module.exports = {
  name: 'dummy-preprocessor',
  setupPreprocessorRegistry: function(type, registry) {
    if (type !== 'parent') { return; }
    var plugin = {
      name: 'dummy-preprocessor',
      ext: 'js',
      toTree: function(tree) {
        return new DummyFilter(tree, {});
      }
    };

    registry.add('js', plugin);
  }
};
