Changeset 112011 in spip-zone


Ignore:
Timestamp:
Oct 16, 2018, 10:05:39 PM (5 weeks ago)
Author:
cedric@…
Message:

Version optimisee plus rapide du compilateur LESS, venant de https://github.com/Cerdic/less.php/tree/opt/perf1

Location:
_plugins_/less-css/trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/less-css/trunk/lesscss_fonctions.php

    r112003 r112011  
    6464                $dir = sous_repertoire (_DIR_VAR, 'cache-less');
    6565                $parser_options['cache_dir'] = sous_repertoire($dir, 'compile');
     66                //$parser_options['cache_method'] = 'serialize';
    6667                if (defined('_MEMOIZE_CACHE_LESS')
    6768                  and isset($GLOBALS['Memoization'])
     
    106107                $parser->parse($style,$url_absolue);
    107108                spip_log('lesscss_compile parse '.(isset($contexte['file'])?$contexte['file']:substr($style,0,100)).' :: '.spip_timer('lesscss_compile'), 'less');
     109                //die('ok1');
    108110                spip_timer('lesscss_compile');
    109111                $out = $parser->getCss();
     
    122124
    123125                spip_log('lesscss_compile getCSS '.(isset($contexte['file'])?$contexte['file']:substr($style,0,100)).' :: '.spip_timer('lesscss_compile'), 'less');
     126                //die('ok2');
    124127                return $out;
    125128        }
  • _plugins_/less-css/trunk/lib/Less/Environment.php

    r111999 r112011  
    1818        //public $javascriptEnabled;                    // option - whether JavaScript is enabled. if undefined, defaults to true
    1919        //public $useFileCache;                                 // browser only - whether to use the per file session cache
    20         public $currentFileInfo;                                // information about the current file - for error reporting and importing and making urls relative etc.
     20        public static $currentFileInfo;                         // information about the current file - for error reporting and importing and making urls relative etc.
    2121
    2222        public $importMultiple = false;                 // whether we are currently importing multiple copies
  • _plugins_/less-css/trunk/lib/Less/Functions.php

    r111999 r112011  
    912912                $fileSizeInKB = round( strlen($buf) / 1024 );
    913913                if( $fileSizeInKB >= $DATA_URI_MAX_KB ){
    914                         $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo);
     914                        $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo['uri_root'] );
    915915                        return $url->compile($this);
    916916                }
  • _plugins_/less-css/trunk/lib/Less/Parser.php

    r111999 r112011  
    442442                }
    443443
    444                 $previousFileInfo = $this->env->currentFileInfo;
     444                $previousFileInfo = Less_Environment::$currentFileInfo;
    445445                $uri_root = self::WinPath($uri_root);
    446446                $this->SetFileInfo($filename, $uri_root);
     
    450450
    451451                if( $previousFileInfo ){
    452                         $this->env->currentFileInfo = $previousFileInfo;
     452                        Less_Environment::$currentFileInfo = $previousFileInfo;
    453453                }
    454454
     
    466466         * @return Less_Tree_Ruleset|Less_Parser
    467467         */
    468         public function parseFile( $filename, $uri_root = '', $returnRoot = false){
     468        public function parseFile( $filename, $uri_root = '', $returnRoot = false, $reference = null){
    469469
    470470                if( !file_exists($filename) ){
     
    480480
    481481
    482                 $previousFileInfo = $this->env->currentFileInfo;
     482                $previousFileInfo = Less_Environment::$currentFileInfo;
    483483
    484484
     
    489489
    490490                $this->SetFileInfo($filename, $uri_root);
     491                if (!is_null($reference)) {
     492                        Less_Environment::$currentFileInfo['reference'] = $reference;
     493                }
    491494
    492495                self::AddParsedFile($filename);
     
    501504
    502505                if( $previousFileInfo ){
    503                         $this->env->currentFileInfo = $previousFileInfo;
     506                        Less_Environment::$currentFileInfo = $previousFileInfo;
    504507                }
    505508
     
    537540
    538541                //entry info
    539                 if( isset($this->env->currentFileInfo) ){
    540                         $currentFileInfo['entryPath'] = $this->env->currentFileInfo['entryPath'];
    541                         $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri'];
    542                         $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath'];
     542                if( isset(Less_Environment::$currentFileInfo) ){
     543                        $currentFileInfo['entryPath'] = Less_Environment::$currentFileInfo['entryPath'];
     544                        $currentFileInfo['entryUri'] = Less_Environment::$currentFileInfo['entryUri'];
     545                        $currentFileInfo['rootpath'] = Less_Environment::$currentFileInfo['rootpath'];
    543546
    544547                }else{
     
    552555                $currentFileInfo['filename'] = $filename;
    553556                $currentFileInfo['uri_root'] = $uri_root;
     557                $currentFileInfo['reference'] = null;
    554558
    555559
    556560                //inherit reference
    557                 if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){
     561                if( isset(Less_Environment::$currentFileInfo['reference']) && Less_Environment::$currentFileInfo['reference'] ){
    558562                        $currentFileInfo['reference'] = true;
    559563                }
    560564
    561                 $this->env->currentFileInfo = $currentFileInfo;
     565                Less_Environment::$currentFileInfo = $currentFileInfo;
    562566        }
    563567
     
    675679
    676680                if( $this->pos < $this->input_len ){
    677                         throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo);
     681                        throw new Less_Exception_Chunk($this->input, null, $this->furthest, Less_Environment::$currentFileInfo);
    678682                }
    679683
     
    731735
    732736
    733                 if( Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo ){
    734                         $uri = $this->env->currentFileInfo['currentUri'];
     737                if( Less_Parser::$options['sourceMap'] && Less_Environment::$currentFileInfo ){
     738                        $uri = Less_Environment::$currentFileInfo['currentUri'];
    735739                        Less_Parser::$contentsMap[$uri] = $this->input;
    736740                }
     
    876880        private function MatchReg($tok){
    877881
    878                 if( preg_match($tok, $this->input, $match, 0, $this->pos) ){
     882                if( preg_match($tok . "S", $this->input, $match, 0, $this->pos) ){
    879883                        $this->skipWhitespace(strlen($match[0]));
    880884                        return $match;
     
    913917                        $c = $this->input[$this->pos];
    914918
    915                         if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){
     919                        if( strpos( "\n\r\t ", $c ) === false ){
    916920                                break;
    917921                        }
     
    10361040                if( $this->input[$this->pos+1] === '/' ){
    10371041                        $match = $this->MatchReg('/\\G\/\/.*/');
    1038                         return $this->NewObj4('Less_Tree_Comment',array($match[0], true, $this->pos, $this->env->currentFileInfo));
     1042                        return $this->NewObj4('Less_Tree_Comment',array($match[0], true, $this->pos, Less_Environment::$currentFileInfo['reference']));
    10391043                }
    10401044
     
    10421046                $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors
    10431047                if( $comment ){
    1044                         return $this->NewObj4('Less_Tree_Comment',array($comment[0], false, $this->pos, $this->env->currentFileInfo));
     1048                        return $this->NewObj4('Less_Tree_Comment',array($comment[0], false, $this->pos, Less_Environment::$currentFileInfo['reference']));
    10451049                }
    10461050        }
     
    10941098
    10951099                $quoted = $char.$matched.$char;
    1096                 return $this->NewObj5('Less_Tree_Quoted',array($quoted, $matched, $e, $index, $this->env->currentFileInfo) );
     1100                return $this->NewObj4('Less_Tree_Quoted',array($quoted, $matched, $e, $index) );
    10971101        }
    10981102
     
    12101214
    12111215                if ($name) {
    1212                         return $this->NewObj4('Less_Tree_Call',array($name, $args, $index, $this->env->currentFileInfo) );
     1216                        return $this->NewObj3('Less_Tree_Call',array($name, $args, $index) );
    12131217                }
    12141218        }
     
    12861290
    12871291                if( isset($value->value) || $value instanceof Less_Tree_Variable ){
    1288                         return $this->NewObj2('Less_Tree_Url',array($value, $this->env->currentFileInfo));
    1289                 }
    1290 
    1291                 return $this->NewObj2('Less_Tree_Url', array( $this->NewObj1('Less_Tree_Anonymous',$value), $this->env->currentFileInfo) );
     1292                        return $this->NewObj2('Less_Tree_Url', array($value, Less_Environment::$currentFileInfo['uri_root']) );
     1293                }
     1294
     1295                return $this->NewObj2('Less_Tree_Url', array($this->NewObj1('Less_Tree_Anonymous',$value), Less_Environment::$currentFileInfo['uri_root']) );
    12921296        }
    12931297
     
    13041308                $index = $this->pos;
    13051309                if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) {
    1306                         return $this->NewObj3('Less_Tree_Variable', array( $name[0], $index, $this->env->currentFileInfo));
     1310                        return $this->NewObj2('Less_Tree_Variable', array( $name[0], $index));
    13071311                }
    13081312        }
     
    13141318
    13151319                if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){
    1316                         return $this->NewObj3('Less_Tree_Variable',array('@'.$curly[1], $index, $this->env->currentFileInfo));
     1320                        return $this->NewObj2('Less_Tree_Variable',array('@'.$curly[1], $index));
    13171321                }
    13181322        }
     
    14961500                        if( $this->parseEnd() ){
    14971501                                $this->forget();
    1498                                 return $this->NewObj5('Less_Tree_Mixin_Call', array( $elements, $args, $index, $this->env->currentFileInfo, $important));
     1502                                return $this->NewObj5('Less_Tree_Mixin_Call', array( $elements, $args, $index, Less_Environment::$currentFileInfo['reference'], $important));
    14991503                        }
    15001504                }
     
    15141518                                break;
    15151519                        }
    1516                         $elements[] = $this->NewObj4('Less_Tree_Element', array($c, $e[0], $elemIndex, $this->env->currentFileInfo));
     1520                        $elements[] = $this->NewObj3('Less_Tree_Element', array($c, $e[0], $elemIndex));
    15171521                        $c = $this->MatchChar('>');
    15181522                }
     
    18121816
    18131817                if( !is_null($e) ){
    1814                         return $this->NewObj4('Less_Tree_Element',array( $c, $e, $index, $this->env->currentFileInfo));
     1818                        return $this->NewObj3('Less_Tree_Element',array( $c, $e, $index));
    18151819                }
    18161820        }
     
    18941898
    18951899                if( $elements ){
    1896                         return $this->NewObj5('Less_Tree_Selector',array($elements, $extendList, $condition, $index, $this->env->currentFileInfo));
     1900                        return $this->NewObj5('Less_Tree_Selector',array($elements, $extendList, $condition, $index, Less_Environment::$currentFileInfo['reference']));
    18971901                }
    18981902                if( $extendList ) {
     
    20242028                        }
    20252029
    2026                         return $this->NewObj4('Less_Tree_NameValue',array( $match[1], $match[2], $index, $this->env->currentFileInfo));
     2030                        return $this->NewObj3('Less_Tree_NameValue',array( $match[1], $match[2], $index));
    20272031                }
    20282032
     
    20812085                        if( $value && $this->parseEnd() ){
    20822086                                $this->forget();
    2083                                 return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo));
     2087                                return $this->NewObj5('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule));
    20842088                        }else{
    20852089                                $this->furthest = $this->pos;
     
    21162120                $this->save();
    21172121
    2118                 $dir = $this->MatchReg('/\\G@import?\s+/');
     2122                $dir = '';
     2123                if ($this->PeekChar('@'))
     2124                        $dir = $this->MatchReg('/\\G@import?\s+/');
    21192125
    21202126                if( $dir ){
     
    21302136
    21312137                                        $this->forget();
    2132                                         return $this->NewObj5('Less_Tree_Import',array( $path, $features, $options, $this->pos, $this->env->currentFileInfo));
     2138                                        return $this->NewObj5('Less_Tree_Import',array( $path, $features, $options, $this->pos, Less_Environment::$currentFileInfo));
    21332139                                }
    21342140                        }
     
    21872193                                if ($this->MatchChar(')')) {
    21882194                                        if ($p && $e) {
    2189                                                 $r = $this->NewObj7('Less_Tree_Rule', array( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true));
     2195                                                $r = $this->NewObj6('Less_Tree_Rule', array( $p, $e, null, null, $this->pos, true));
    21902196                                                $nodes[] = $this->NewObj1('Less_Tree_Paren',$r);
    21912197                                        } elseif ($e) {
     
    22252231
    22262232        private function parseMedia() {
    2227                 if( $this->MatchReg('/\\G@media/') ){
     2233                if( $this->PeekChar('@') && $this->MatchReg('/\\G@media/') ){
    22282234                        $features = $this->parseMediaFeatures();
    22292235                        $rules = $this->parseBlock();
    22302236
    22312237                        if( is_array($rules) ){
    2232                                 return $this->NewObj4('Less_Tree_Media',array( $rules, $features, $this->pos, $this->env->currentFileInfo));
     2238                                return $this->NewObj3('Less_Tree_Media',array( $rules, $features, $this->pos));
    22332239                        }
    22342240                }
     
    23412347                if( $rules || (!$hasBlock && $value && $this->MatchChar(';'))) {
    23422348                        $this->forget();
    2343                         return $this->NewObj5('Less_Tree_Directive',array($name, $value, $rules, $index, $this->env->currentFileInfo));
     2349                        return $this->NewObj5('Less_Tree_Directive',array($name, $value, $rules, $index, Less_Environment::$currentFileInfo['reference']));
    23442350                }
    23452351
     
    26252631                                        $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s);
    26262632                                }else{
    2627                                         $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo));
     2633                                        $name[$k] = $this->NewObj2('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k]));
    26282634                                }
    26292635                        }
     
    27022708                $obj = new $class( $arg );
    27032709                if( $this->CacheEnabled() ){
    2704                         $obj->cache_string = ' new '.$class.'('.Less_Parser::ArgString($arg).')';
     2710                        $obj->cache_string = ' new '.$class.'('. (is_scalar($arg) ? var_export($arg, true) : Less_Parser::ArgString($arg)) .')';
    27052711                }
    27062712                return $obj;
     
    27722778        public static function ArgString($arg){
    27732779
    2774                 $type = gettype($arg);
    2775 
    2776                 if( $type === 'object'){
     2780                if( is_object($arg) ){
    27772781                        $string = $arg->cache_string;
    27782782                        unset($arg->cache_string);
    27792783                        return $string;
    27802784
    2781                 }elseif( $type === 'array' ){
     2785                }
     2786                elseif( is_array($arg) ){
    27822787                        $string = ' Array(';
    27832788                        foreach($arg as $k => $a){
    2784                                 $string .= var_export($k,true).' => '.self::ArgString($a).',';
     2789                                $string .= var_export($k,true).' => '.(is_scalar($a) ? var_export($a,true) : self::ArgString($a)).',';
    27852790                        }
    27862791                        return $string . ')';
     
    27912796
    27922797        public function Error($msg){
    2793                 throw new Less_Exception_Parser($msg, null, $this->furthest, $this->env->currentFileInfo);
     2798                throw new Less_Exception_Parser($msg, null, $this->furthest, Less_Environment::$currentFileInfo);
    27942799        }
    27952800
  • _plugins_/less-css/trunk/lib/Less/Tree/Anonymous.php

    r111999 r112011  
    1212        public $index;
    1313        public $mapLines;
    14         public $currentFileInfo;
    1514        public $type = 'Anonymous';
    1615
     
    1918         * @param boolean $mapLines
    2019         */
    21         public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null ){
     20        public function __construct($value, $index = null, $mapLines = null ){
    2221                $this->value = $value;
    2322                $this->index = $index;
    2423                $this->mapLines = $mapLines;
    25                 $this->currentFileInfo = $currentFileInfo;
    2624        }
    2725
    2826        public function compile(){
    29                 return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines);
     27                return new Less_Tree_Anonymous($this->value, $this->index, $this->mapLines);
    3028        }
    3129
     
    4947     */
    5048        public function genCSS( $output ){
    51                 $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines );
     49                $output->add( $this->value, Less_Environment::$currentFileInfo, $this->index, $this->mapLines );
    5250        }
    5351
  • _plugins_/less-css/trunk/lib/Less/Tree/Call.php

    r111999 r112011  
    1414    public $args;
    1515    public $index;
    16     public $currentFileInfo;
    1716    public $type = 'Call';
    1817
    19         public function __construct($name, $args, $index, $currentFileInfo = null ){
     18        public function __construct($name, $args, $index){
    2019                $this->name = $name;
    2120                $this->args = $args;
    2221                $this->index = $index;
    23                 $this->currentFileInfo = $currentFileInfo;
    2422        }
    2523
     
    7472                                try {
    7573
    76                                         $func = new Less_Functions($env, $this->currentFileInfo);
     74                                        $func = new Less_Functions($env, Less_Environment::$currentFileInfo);
    7775                                        $result = call_user_func_array( array($func,$nameLC),$args);
    7876
     
    9492
    9593
    96                 return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo );
     94                return new Less_Tree_Call( $this->name, $args, $this->index);
    9795    }
    9896
     
    102100        public function genCSS( $output ){
    103101
    104                 $output->add( $this->name . '(', $this->currentFileInfo, $this->index );
     102                $output->add( $this->name . '(', Less_Environment::$currentFileInfo, $this->index );
    105103                $args_len = count($this->args);
    106104                for($i = 0; $i < $args_len; $i++ ){
  • _plugins_/less-css/trunk/lib/Less/Tree/Comment.php

    r111999 r112011  
    1111        public $value;
    1212        public $silent;
     13        public $reference;
    1314        public $isReferenced;
    14         public $currentFileInfo;
    1515        public $type = 'Comment';
    1616
    17         public function __construct($value, $silent, $index = null, $currentFileInfo = null ){
     17        public function __construct($value, $silent, $index = null, $reference=null){
    1818                $this->value = $value;
    1919                $this->silent = !! $silent;
    20                 $this->currentFileInfo = $currentFileInfo;
     20                $this->reference = $reference;
    2121        }
    2222
     
    2626        public function genCSS( $output ){
    2727                //if( $this->debugInfo ){
    28                         //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index);
     28                        //$output->add( tree.debugInfo($env, $this), Less_Environment::$currentFileInfo, $this->index);
    2929                //}
    3030                $output->add( trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n
     
    3636
    3737        public function isSilent(){
    38                 $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) );
     38                $isReference = (isset($this->reference) && $this->reference && (!isset($this->isReferenced) || !$this->isReferenced) );
    3939                $isCompressed = Less_Parser::$options['compress'] && !preg_match('/^\/\*!/', $this->value);
    4040                return $this->silent || $isReference || $isCompressed;
  • _plugins_/less-css/trunk/lib/Less/Tree/Directive.php

    r111999 r112011  
    1313        public $rules;
    1414        public $index;
     15        public $reference;
    1516        public $isReferenced;
    16         public $currentFileInfo;
    1717        public $debugInfo;
    1818        public $type = 'Directive';
    1919
    20         public function __construct($name, $value = null, $rules, $index = null, $currentFileInfo = null, $debugInfo = null ){
     20        public function __construct($name, $value = null, $rules, $index = null, $reference = null, $debugInfo = null ){
    2121                $this->name = $name;
    2222                $this->value = $value;
     
    2727
    2828                $this->index = $index;
    29                 $this->currentFileInfo = $currentFileInfo;
     29                $this->reference = $reference;
    3030                $this->debugInfo = $debugInfo;
    3131        }
     
    4848                $value = $this->value;
    4949                $rules = $this->rules;
    50                 $output->add( $this->name, $this->currentFileInfo, $this->index );
     50                $output->add( $this->name, Less_Environment::$currentFileInfo, $this->index );
    5151                if( $this->value ){
    5252                        $output->add(' ');
     
    7373                }
    7474
    75                 return new Less_Tree_Directive( $this->name, $value, $rules, $this->index, $this->currentFileInfo, $this->debugInfo );
     75                return new Less_Tree_Directive( $this->name, $value, $rules, $this->index, $this->reference, $this->debugInfo );
    7676        }
    7777
     
    9898        }
    9999
     100        public function getIsReferenced(){
     101                return !isset($this->reference) || !$this->reference || $this->isReferenced;
     102        }
     103
    100104}
  • _plugins_/less-css/trunk/lib/Less/Tree/Element.php

    r111999 r112011  
    1212        public $value = '';
    1313        public $index;
    14         public $currentFileInfo;
    1514        public $type = 'Element';
    1615
    1716        public $value_is_object = false;
    1817
    19         public function __construct($combinator, $value, $index = null, $currentFileInfo = null ){
     18        public function __construct($combinator, $value, $index = null ){
    2019
    2120                $this->value = $value;
     
    2726
    2827                $this->index = $index;
    29                 $this->currentFileInfo = $currentFileInfo;
    3028        }
    3129
     
    3937
    4038                if( Less_Environment::$mixin_stack ){
    41                         return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index, $this->currentFileInfo );
     39                        return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index );
    4240                }
    4341
     
    5351     */
    5452        public function genCSS( $output ){
    55                 $output->add( $this->toCSS(), $this->currentFileInfo, $this->index );
     53                $output->add( $this->toCSS(), Less_Environment::$currentFileInfo, $this->index );
    5654        }
    5755
  • _plugins_/less-css/trunk/lib/Less/Tree/Import.php

    r111999 r112011  
    174174
    175175                        Less_Parser::AddParsedFile($full_path);
    176                         $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true );
     176                        $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, true );
    177177
    178178                        if( $this->features ){
     
    262262         */
    263263    public function ParseImport( $full_path, $uri, $env ){
    264 
     264                $previousReference = Less_Environment::$currentFileInfo['reference'];
    265265                $import_env = clone $env;
    266                 if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){
    267                         $import_env->currentFileInfo['reference'] = true;
     266                $reference = null;
     267                if( (isset($this->options['reference']) && $this->options['reference']) || (isset($this->currentFileInfo['reference']) && $this->currentFileInfo['reference']) ){
     268                        $reference = true;
     269                        Less_Environment::$currentFileInfo['reference'] = true;
    268270                }
    269271
     
    273275
    274276                $parser = new Less_Parser($import_env);
    275                 $root = $parser->parseFile($full_path, $uri, true);
     277                $root = $parser->parseFile($full_path, $uri, true, $reference);
    276278
    277279
     
    279281                $ruleset->evalImports($import_env);
    280282
     283                Less_Environment::$currentFileInfo['reference'] = $previousReference;
    281284                return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules;
    282285        }
  • _plugins_/less-css/trunk/lib/Less/Tree/Media.php

    r111999 r112011  
    1212        public $rules;
    1313        public $index;
    14         public $currentFileInfo;
    1514        public $isReferenced;
    1615        public $type = 'Media';
    1716
    18         public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null ){
     17        public function __construct($value = array(), $features = array(), $index = null){
    1918
    2019                $this->index = $index;
    21                 $this->currentFileInfo = $currentFileInfo;
    2220
    2321                $selectors = $this->emptySelectors();
     
    3937    public function genCSS( $output ){
    4038
    41                 $output->add( '@media ', $this->currentFileInfo, $this->index );
     39                $output->add( '@media ', Less_Environment::$currentFileInfo, $this->index );
    4240                $this->features->genCSS( $output );
    4341                Less_Tree::outputRuleset( $output, $this->rules);
     
    4745        public function compile($env) {
    4846
    49                 $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo );
     47                $media = new Less_Tree_Media(array(), array(), $this->index );
    5048
    5149                $strictMathBypass = false;
     
    8280
    8381        public function emptySelectors(){
    84                 $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo );
    85                 $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) );
     82                $el = new Less_Tree_Element('','&', $this->index);
     83                $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, Less_Environment::$currentFileInfo['reference']) );
    8684                $sels[0]->mediaEmpty = true;
    8785        return $sels;
  • _plugins_/less-css/trunk/lib/Less/Tree/Mixin/Call.php

    r111999 r112011  
    77        public $arguments;
    88        public $index;
    9         public $currentFileInfo;
     9        public $reference;
    1010
    1111        public $important;
     
    1616         *
    1717         */
    18         public function __construct($elements, $args, $index, $currentFileInfo, $important = false){
     18        public function __construct($elements, $args, $index, $reference = null, $important = false){
    1919                $this->selector = new Less_Tree_Selector($elements);
    2020                $this->arguments = $args;
    2121                $this->index = $index;
    22                 $this->currentFileInfo = $currentFileInfo;
     22                $this->reference = $reference;
    2323                $this->important = $important;
    2424        }
     
    127127                                                $rules = array_merge($rules, $mixin->evalCall($env, $args, $this->important)->rules);
    128128                                        } catch (Exception $e) {
    129                                                 //throw new Less_Exception_Compiler($e->getMessage(), $e->index, null, $this->currentFileInfo['filename']);
    130                                                 throw new Less_Exception_Compiler($e->getMessage(), null, null, $this->currentFileInfo);
     129                                                //throw new Less_Exception_Compiler($e->getMessage(), $e->index, null, Less_Environment::$currentFileInfo['filename']);
     130                                                throw new Less_Exception_Compiler($e->getMessage(), null, null, Less_Environment::$currentFileInfo);
    131131                                        }
    132132                                }
     
    134134
    135135                        if( $match ){
    136                                 if( !$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] ){
     136                                if( !isset($this->reference) or !$this->reference){
    137137                                        Less_Tree::ReferencedArray($rules);
    138138                                }
     
    143143
    144144                if( $isOneFound ){
    145                         throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo);
     145                        throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, Less_Environment::$currentFileInfo);
    146146
    147147                }else{
    148                         throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index);
     148                        throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".Less_Environment::$currentFileInfo['filename'], null, $this->index);
    149149                }
    150150
  • _plugins_/less-css/trunk/lib/Less/Tree/NameValue.php

    r111999 r112011  
    1616        public $value;
    1717        public $index;
    18         public $currentFileInfo;
    1918        public $type = 'NameValue';
    2019        public $important = '';
    2120
    22         public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){
     21        public function __construct($name, $value = null, $index = null){
    2322                $this->name = $name;
    2423                $this->value = $value;
    2524                $this->index = $index;
    26                 $this->currentFileInfo = $currentFileInfo;
    2725        }
    2826
     
    3533                        . $this->important
    3634                        . (((Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";")
    37                         , $this->currentFileInfo, $this->index);
     35                        , Less_Environment::$currentFileInfo, $this->index);
    3836        }
    3937
     
    4341
    4442        public function makeImportant(){
    45                 $new = new Less_Tree_NameValue($this->name, $this->value, $this->index, $this->currentFileInfo);
     43                $new = new Less_Tree_NameValue($this->name, $this->value, $this->index);
    4644                $new->important = ' !important';
    4745                return $new;
  • _plugins_/less-css/trunk/lib/Less/Tree/Quoted.php

    r111999 r112011  
    1212        public $quote;
    1313        public $index;
    14         public $currentFileInfo;
    1514        public $type = 'Quoted';
    1615
     
    1817         * @param string $str
    1918         */
    20         public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null ){
     19        public function __construct($str, $content = '', $escaped = false, $index = false){
    2120                $this->escaped = $escaped;
    2221                $this->value = $content;
     
    2524                }
    2625                $this->index = $index;
    27                 $this->currentFileInfo = $currentFileInfo;
    2826        }
    2927
     
    3331    public function genCSS( $output ){
    3432                if( !$this->escaped ){
    35                         $output->add( $this->quote, $this->currentFileInfo, $this->index );
     33                        $output->add( $this->quote, Less_Environment::$currentFileInfo, $this->index );
    3634        }
    3735        $output->add( $this->value );
     
    5452                if( preg_match_all('/@\{([\w-]+)\}/',$value,$matches) ){
    5553                        foreach($matches[1] as $i => $match){
    56                                 $v = new Less_Tree_Variable('@' . $match, $this->index, $this->currentFileInfo );
     54                                $v = new Less_Tree_Variable('@' . $match, $this->index);
    5755                                $v = $v->compile($env);
    5856                                $v = ($v instanceof Less_Tree_Quoted) ? $v->value : $v->toCSS();
     
    6159                }
    6260
    63                 return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo);
     61                return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index);
    6462        }
    6563
  • _plugins_/less-css/trunk/lib/Less/Tree/Rule.php

    r111999 r112011  
    1616        public $inline;
    1717        public $variable;
    18         public $currentFileInfo;
    1918        public $type = 'Rule';
    2019
     
    2221         * @param string $important
    2322         */
    24         public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null,  $inline = false){
     23        public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $inline = false){
    2524                $this->name = $name;
    2625                $this->value = ($value instanceof Less_Tree_Value || $value instanceof Less_Tree_Ruleset) ? $value : new Less_Tree_Value(array($value));
     
    2827                $this->merge = $merge;
    2928                $this->index = $index;
    30                 $this->currentFileInfo = $currentFileInfo;
    3129                $this->inline = $inline;
    3230                $this->variable = ( is_string($name) && $name[0] === '@');
     
    4240    public function genCSS( $output ){
    4341
    44                 $output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index);
     42                $output->add( $this->name . Less_Environment::$_outputMap[': '], Less_Environment::$currentFileInfo, $this->index);
    4543                try{
    4644                        $this->value->genCSS( $output);
     
    4846                }catch( Less_Exception_Parser $e ){
    4947                        $e->index = $this->index;
    50                         $e->currentFile = $this->currentFileInfo;
     48                        $e->currentFile = Less_Environment::$currentFileInfo;
    5149                        throw $e;
    5250                }
    53                 $output->add( $this->important . (($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), $this->currentFileInfo, $this->index);
     51                $output->add( $this->important . (($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), Less_Environment::$currentFileInfo, $this->index);
    5452        }
    5553
     
    7674
    7775                        if( !$this->variable && $evaldValue->type === "DetachedRuleset") {
    78                                 throw new Less_Exception_Compiler("Rulesets cannot be evaluated on a property.", null, $this->index, $this->currentFileInfo);
     76                                throw new Less_Exception_Compiler("Rulesets cannot be evaluated on a property.", null, $this->index, Less_Environment::$currentFileInfo);
    7977                        }
    8078
    8179                        if( Less_Environment::$mixin_stack ){
    82                                 $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->currentFileInfo, $this->inline);
     80                                $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->inline);
    8381                        }else{
    8482                                $this->name = $name;
     
    9088                        if( !is_numeric($e->index) ){
    9189                                $e->index = $this->index;
    92                                 $e->currentFile = $this->currentFileInfo;
     90                                $e->currentFile = Less_Environment::$currentFileInfo;
    9391                        }
    9492                        throw $e;
     
    110108
    111109    public function makeImportant(){
    112                 return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline);
     110                return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->inline);
    113111        }
    114112
  • _plugins_/less-css/trunk/lib/Less/Tree/Ruleset.php

    r111999 r112011  
    548548                                                if( $sel ){
    549549                                                        $sel[0]->elements = array_slice($sel[0]->elements,0);
    550                                                         $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo );
     550                                                        $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index );
    551551                                                }
    552552                                                $selectorsMultiplied[] = $sel;
     
    585585
    586586                                                                // join the elements so far with the first part of the parent
    587                                                                 $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, $el->index, $el->currentFileInfo);
     587                                                                $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, $el->index );
    588588
    589589                                                                $newJoinedSelector->elements = array_merge( $newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1) );
  • _plugins_/less-css/trunk/lib/Less/Tree/Selector.php

    r111999 r112011  
    1616        public $evaldCondition = false;
    1717        public $type = 'Selector';
    18         public $currentFileInfo = array();
     18        public $reference;
    1919        public $isReferenced;
    2020        public $mediaEmpty;
     
    2929         * @param boolean $isReferenced
    3030         */
    31         public function __construct( $elements, $extendList = array() , $condition = null, $index=null, $currentFileInfo=null, $isReferenced=null ){
     31        public function __construct( $elements, $extendList = array() , $condition = null, $index=null, $reference=null, $isReferenced=null){
    3232
    3333                $this->elements = $elements;
     
    3535                $this->extendList = $extendList;
    3636                $this->condition = $condition;
    37                 if( $currentFileInfo ){
    38                         $this->currentFileInfo = $currentFileInfo;
    39                 }
    4037                $this->isReferenced = $isReferenced;
     38                $this->reference = $reference;
    4139                if( !$condition ){
    4240                        $this->evaldCondition = true;
     
    5957
    6058    public function createDerived( $elements, $extendList = null, $evaldCondition = null ){
    61                 $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced);
     59                $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->reference, $this->isReferenced);
    6260                $newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition;
    6361                return $newSelector;
     
    146144
    147145                if( !$firstSelector && $this->elements[0]->combinator === "" ){
    148                         $output->add(' ', $this->currentFileInfo, $this->index);
     146                        $output->add(' ', Less_Environment::$currentFileInfo, $this->index);
    149147                }
    150148
     
    159157
    160158    public function getIsReferenced(){
    161                 return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced;
     159                return !isset($this->reference) || !$this->reference || $this->isReferenced;
    162160        }
    163161
  • _plugins_/less-css/trunk/lib/Less/Tree/Url.php

    r111999 r112011  
    1111        public $attrs;
    1212        public $value;
    13         public $currentFileInfo;
     13        public $uri_root;
    1414        public $isEvald;
    1515        public $type = 'Url';
    1616
    17         public function __construct($value, $currentFileInfo = null, $isEvald = null){
     17        public function __construct($value, $uri_root = null, $isEvald = null){
    1818                $this->value = $value;
    19                 $this->currentFileInfo = $currentFileInfo;
     19                $this->uri_root = $uri_root;
    2020                $this->isEvald = $isEvald;
    2121        }
     
    4343                        // Add the base path if the URL is relative
    4444                        if( Less_Parser::$options['relativeUrls']
    45                                 && $this->currentFileInfo
     45                                && $this->uri_root
    4646                                && is_string($val->value)
    4747                                && Less_Environment::isPathRelative($val->value)
    4848                        ){
    49                                 $rootpath = $this->currentFileInfo['uri_root'];
     49                                $rootpath = $this->uri_root;
    5050                                if ( !$val->quote ){
    5151                                        $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath );
     
    7171                }
    7272
    73                 return new Less_Tree_URL($val, $this->currentFileInfo, true);
     73                return new Less_Tree_URL($val, $this->uri_root, true);
    7474        }
    7575
  • _plugins_/less-css/trunk/lib/Less/Tree/Variable.php

    r111999 r112011  
    1111        public $name;
    1212        public $index;
    13         public $currentFileInfo;
    1413        public $evaluating = false;
    1514        public $type = 'Variable';
     
    1817     * @param string $name
    1918     */
    20     public function __construct($name, $index = null, $currentFileInfo = null) {
     19    public function __construct($name, $index = null) {
    2120        $this->name = $name;
    2221        $this->index = $index;
    23                 $this->currentFileInfo = $currentFileInfo;
    2422    }
    2523
     
    2725
    2826                if( $this->name[1] === '@' ){
    29                         $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo);
     27                        $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1);
    3028                        $name = '@' . $v->compile($env)->value;
    3129                }else{
     
    3432
    3533                if ($this->evaluating) {
    36                         throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, $this->currentFileInfo);
     34                        throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, Less_Environment::$currentFileInfo);
    3735                }
    3836
     
    4745                }
    4846
    49                 throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo);
     47                throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".Less_Environment::$currentFileInfo["filename"], null, $this->index, Less_Environment::$currentFileInfo);
    5048        }
    5149
  • _plugins_/less-css/trunk/lib/Less/Visitor/processExtends.php

    r111999 r112011  
    403403                                $match['initialCombinator'],
    404404                                $replacementSelector->elements[0]->value,
    405                                 $replacementSelector->elements[0]->index,
    406                                 $replacementSelector->elements[0]->currentFileInfo
     405                                $replacementSelector->elements[0]->index
    407406                        );
    408407
  • _plugins_/less-css/trunk/lib/Less/Visitor/toCSS.php

    r111999 r112011  
    5858
    5959        public function visitDirective( $directiveNode ){
    60                 if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){
     60                if(method_exists($directiveNode,'getIsReferenced') && !$directiveNode->getIsReferenced()) {
    6161                        return array();
    6262                }
  • _plugins_/less-css/trunk/paquet.xml

    r112002 r112011  
    22        prefix="lesscss"
    33        categorie="outil"
    4         version="1.2.3"
     4        version="1.3.0"
    55        etat="stable"
    66        compatibilite="[3.0.0;3.2.*]"
Note: See TracChangeset for help on using the changeset viewer.