Sha256: 747908ec22e25687a6633e0460fdd038921a8d372e4a54f9f627ef4131a760b9

Contents?: true

Size: 1.24 KB

Versions: 19

Compression:

Stored size: 1.24 KB

Contents

Entity   = require '../entity'
Entities = require '../_entities'
Winston  = require 'winston'

module.exports = class Entities.Variable extends Entity
  @name: "Variable"

  @looksLike: (node) ->
    node.constructor.name == 'Assign' && node.value?.constructor.name == 'Value' && node.variable?.base?.value? && node.value.base.constructor.name isnt 'Call'

  @is: (node) ->
    !node.documentation?.property && !node.documentation?.mixin && super(node)

  constructor: (@environment, @file, @node) ->
    [@name, @selfish] = @fetchName()

    @constant = /^[A-Z_-]*$/.test @name

    try
      @value = @node.value.base.compile
        indent: ''

      # Workaround to replace CoffeeScript internal
      # representations with something reasonable
      @value = 'undefined' if @value == 'void 0'

    @documentation = @node.documentation
    if @environment.options.debug
      Winston.info "Creating new Variable Entity"
      Winston.info " name: " + @name
      Winston.info " documentation: " + @documentation

  inspect: ->
    {
      file:          @file.path
      name:          @name
      constant:      @constant
      value:         @value
      documentation: @documentation?.inspect()
      selfish:       @selfish
      kind:          @kind
    }

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/codo/lib/entities/variable.coffee
ela-4.1.5 node_modules/codo/lib/entities/variable.coffee
ela-4.1.4 node_modules/codo/lib/entities/variable.coffee
ela-4.1.3 node_modules/codo/lib/entities/variable.coffee
ela-4.1.2 node_modules/codo/lib/entities/variable.coffee
ela-4.1.1 node_modules/codo/lib/entities/variable.coffee
ela-4.1.0 node_modules/codo/lib/entities/variable.coffee
ela-4.0.0 node_modules/codo/lib/entities/variable.coffee
ela-3.4.3 node_modules/codo/lib/entities/variable.coffee
ela-3.4.2 node_modules/codo/lib/entities/variable.coffee
ela-3.4.0 node_modules/codo/lib/entities/variable.coffee
ela-3.3.1 node_modules/codo/lib/entities/variable.coffee
ela-3.3.0 node_modules/codo/lib/entities/variable.coffee
ela-3.2.0 node_modules/codo/lib/entities/variable.coffee
ela-3.1.1 node_modules/codo/lib/entities/variable.coffee
ela-3.1.0 node_modules/codo/lib/entities/variable.coffee
ela-3.0.0 node_modules/codo/lib/entities/variable.coffee
ela-2.0.0 node_modules/codo/lib/entities/variable.coffee
ela-1.1.0 node_modules/codo/lib/entities/variable.coffee