source: Dev/trunk/src/client/util/docscripts/lib/parser/DojoFunctionCall.php

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.1 KB
Line 
1<?php
2
3require_once('DojoParameters.php');
4require_once('DojoBlock.php');
5
6class DojoFunctionCall extends DojoBlock
7{
8  private $object = 'DojoFunctionCall';
9
10  private $name;
11  private $parameters;
12
13  public function __construct($package, $line_number = false, $position = false){
14    parent::__construct($package, $line_number, $position);
15    $this->parameters = new DojoParameters($package);
16  }
17
18  public function __destruct() {
19    parent::__destruct();
20    unset($this->parameters);
21  }
22
23  public function build() {
24    if (!$this->start) {
25      return null; // FIXME: does this ever die?
26        die("DojoFunctionCall->build() used before setting a start position");
27      }
28
29      $code = $this->package->getCode();
30      $this->parameters->setStart($this->start[0], strpos($code[$this->start[0]], '(', $this->start[1]));
31      $end = $this->parameters->build();
32
33      $this->setEnd($end[0], $end[1]);
34      return $end;
35  }
36
37  public function getAssignment() {
38    $this->build();
39    $code = $this->package->getCode();
40    $line = Text::blankOutAt($code[$this->start[0]], $this->start[1]);
41    if (preg_match('%([\w_.$]+)\s*=\s*$%', $line, $match)) {
42      return $match[1];
43    }
44  }
45
46  public function removeCodeFrom($lines){
47    for($i = $this->start[0]; $i <= $this->end[0]; $i++){
48      $line = $lines[$i];
49      if ($i == $this->start[0]) {
50        $lines[$i] = Text::blankOutAt($line, $this->start[1]);
51      }
52      elseif ($i == $this->end[0]) {
53        $lines[$i] = Text::blankOutAt($line, 0, $this->end[1]);
54      }else{
55        $lines[$i] = Text::blankOut($line, $line);
56      }
57    }
58    return $lines;
59  }
60
61  public function getName(){
62    if($this->name){
63    return $this->name;
64  }
65
66    $line = Text::chop($this->package->getCode(), $this->start[0], $this->start[1], $this->start[0]);
67    $line = $line[$this->start[0]];
68    return $this->name = trim(substr($line, 0, strpos($line, '(')));
69  }
70
71  public function getParameter($pos){
72    return $this->parameters->getParameter($pos);
73  }
74
75  public function getParameters(){
76    return $this->parameters->getParameters();
77  }
78
79}
80
81?>
Note: See TracBrowser for help on using the repository browser.