How to use the recast.Visitor function in recast

To help you get started, we’ve selected a few recast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fivetanley / ember-cli-migrator / lib / migrator-visitor.js View on Github external
var recast = require('recast');
var namedTypes = recast.types.namedTypes;
var builders = recast.types.builders;
var Visitor = recast.Visitor;
var TypedExport = require('./typed-export');
var _ = require('lodash');

// Helper function to extract global namespace name from a member expression node
function extractMemberExpressionInfo(node) {
  var info = {};
  if (node.get('object') && node.get('object', 'object')) {
    // Need to check member expressions of the type Ember.ObjectController.extend
    info.namespace = node.get('object', 'name').value;
    info.property = node.get('property', 'name').value;
  } else if (node.get('object')) {
    // Need to check member expressions of the type App.FunMixin
    info.namespace = node.get('object').get('name').value;
    info.property = node.get('property').get('name').value;
  }
  return info;
github fivetanley / ember-cli-migrator / lib / helper-visitor.js View on Github external
var recast = require('recast');
var Visitor = recast.Visitor;
var builders = recast.types.builders;
var namedTypes = recast.types.namedTypes;

// Find the helper name
// Take the function out and rename it
// Ember.Handlebars.helper('prettyPrint', function(){
//
// })
//
// becomes
//
// function prettyPrint(){
//
// }
//
// then add the export default Ember.Handlebars.makeBoundHelper