Exemple #1
0
 public function build()
 {
     if (!$this->start) {
         die("DojoParameters->build() used before setting a start position");
     }
     $code = $this->package->getCode();
     $end = array($this->start[0], $this->start[1]);
     do {
         $parameter = new DojoParameter($this->package, $end[0], $end[1], $this->terminator);
         $end = $parameter->build();
         $this->parameters[] = $parameter;
     } while ($code[$end[0]][$end[1]] != $this->terminator);
     $this->setEnd($end[0], $end[1]);
     return $end;
 }
 public function build()
 {
     if (!$this->start) {
         die("DojoObject->build() used before setting a start position");
     }
     $lines = Text::chop($this->package->getCode(), $this->start[0], $this->start[1], false, false, true);
     $end = array($this->start[0], $this->start[1]);
     do {
         $lines = Text::chop($this->package->getCode(), $end[0], $end[1], false, false, true);
         foreach ($lines as $line_number => $line) {
             if (preg_match('%^\\s*}%', $line)) {
                 break;
             }
             if (preg_match('%^(\\s*)([a-zA-Z0-9_$]+|"\\s+")\\s*:%', $line, $match)) {
                 if ($end[0] != $this->start[0] && $end[1] != $this->start[1]) {
                     if ($end[0] + 1 > $line_number) {
                         continue;
                     }
                     $between_lines = Text::chop($this->package->getSource(), $end[0] + 1, 0, $line_number, strlen($match[1]), true);
                     $between_started = false;
                     $between_buffer = array();
                     foreach ($between_lines as $between_line) {
                         if ($between_started && empty($between_line)) {
                             break;
                         }
                         if (trim($between_line)) {
                             $between_started = true;
                         }
                         if ($between_started) {
                             $between_buffer[] = $between_line;
                         }
                     }
                     if ($between_started) {
                         foreach ($between_buffer as $between_line) {
                             $this->body->addBlockCommentLine($between_line);
                         }
                     }
                     $this->body->addBlockCommentBreak();
                 }
                 $end = array($line_number, strlen($match[0]));
                 if ($match[2][0] == '"' || $match[2][0] == "'") {
                     $key = trim(implode(Text::chop($this->package->getSource(), $line_number, strpos($line, '"') + 1, $line_number, strlen($match[0]) - 3, false)));
                 } else {
                     $key = $match[2];
                 }
                 break;
             }
         }
         if (!$key) {
             $end = Text::findTermination($lines, '}');
         } else {
             $parameter = new DojoParameter($this->package, $end[0], $end[1], '}');
             $end = $parameter->build();
             $this->values[$key][] = $parameter;
         }
     } while ($lines[$end[0]][$end[1]] != '}');
     $this->setEnd($end[0], $end[1]);
     return $end;
 }