/*!
 * Copyright (C) 2017 Glayzzle (BSD3 License)
 * @authors https://github.com/glayzzle/php-reflection/graphs/contributors
 * @url http://glayzzle.com
 */
'use strict';

var node = require('../data/node');
var expr = require('./expr');

/**
 * ** Extends from {@link NODE.md|:link: node} **
 *
 * Represents a constant declaration
 *
 * @public
 * @constructor Define
 * @property {String|expr} name
 * @property {expr} value {@link EXPR.md|:link:}
 * @property {Boolean|expr} caseInsensitive
 */
var Define = node.extends('define');

/**
 * @protected Consumes the current ast node
 */
Define.prototype.consume = function(ast) {
  this.name = expr.resolve(this, ast.arguments[0]);
  if (ast.arguments.length > 1) {
    this.value = expr.resolve(this, ast.arguments[1]);
  }
  if (ast.arguments.length > 2) {
    this.caseInsensitive = expr.resolve(this, ast.arguments[2]);
  } else {
    this.caseInsensitive = false;
  }
};

module.exports = Define;

@@ -169,17 +169,17 @@
 ';%0A%0Avar 
-n
+N
 ode = re
@@ -205,17 +205,17 @@
 ');%0Avar 
-e
+E
 xpr = re
@@ -505,17 +505,17 @@
 efine = 
-n
+N
 ode.exte
@@ -526,24 +526,227 @@
 'define');%0A%0A
+/**%0A * Gets the define var name%0A */%0ADefine.prototype.getName = function() %7B%0A    return this.name;%0A%7D;%0A%0A/**%0A * Gets the define value%0A */%0ADefine.prototype.getValue = function() %7B%0A    return this.value;%0A%7D;%0A%0A
 /**%0A * @prot
@@ -825,15 +825,82 @@
 ion(
-ast) %7B%0A
+file, parent, ast) %7B%0A    Node.prototype.consume.apply(this, arguments);%0A  
   th
@@ -905,25 +905,25 @@
 this.name = 
-e
+E
 xpr.resolve(
@@ -947,16 +947,49 @@
 ts%5B0%5D);%0A
+    this.indexName(this.name);%0A  
   if (as
@@ -1014,24 +1014,28 @@
  %3E 1) %7B%0A    
+  
+  
 this.value =
@@ -1031,25 +1031,25 @@
 his.value = 
-e
+E
 xpr.resolve(
@@ -1075,18 +1075,22 @@
 %5B1%5D);%0A  
+ 
+ 
 %7D%0A
+  
   if (as
@@ -1115,24 +1115,28 @@
  %3E 2) %7B%0A    
+  
+  
 this.caseIns
@@ -1184,16 +1184,18 @@
 ts%5B2%5D);%0A
+  
   %7D else
@@ -1197,16 +1197,20 @@
  else %7B%0A
+    
     this
@@ -1235,16 +1235,18 @@
  false;%0A
+  
   %7D%0A%7D;%0A%0A

migrate to new api