Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322482

Summary: [Content Assist] Parameter with default value array() appears in the CA template
Product: z_Archived Reporter: Roy Ganor <ganoro>
Component: PDTAssignee: Zhongwei Zhao <zhaozhongwei>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: gadi, petyo_tanchev
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
patch none

Description Roy Ganor CLA 2010-08-12 04:51:07 EDT
1. Use the code below
2. At the end of the file start typing Uti| and raise CA for Utils::exec

You get the following CA template (see screen-shot):
Utils::exec($cmd, $ignore_rcs)

Since the CA template shows only the mandatory parameters (i.e. those that do not have default value) and the only parameter without assignment is $cmd I suppose it is the only one that should be shown.
In the function declaration $ignore_rcs=array().



<?php
class Utils {
    static protected $snapshot_obj;
    
    /**
     * exec() - wrapper to php exec() function
     *
     * @param string $cmd - cmd to execute
     * @param boolean $return_output - whether to return the output of the command, or simply the boolean result (the default)
     * @param int $failure_severity - what is the failure severity - the higher the critical. (default=0) - if -1 passed, then will not throw exception
     * @param Staf $staf_handle - either null (default), or the staf handle to work with
     * @param array $ignore_rcs - erroneous return codes which should be ignored
     * @param boolean $fix_quotes - whether to quote fixing (default=true, relevant to staf only)
     * @return either cmd output or boolean result
     */	
    static public function exec($cmd, $staf_handle=null, $return_output=false, $failure_severity=0, $ignore_rcs=array(), $fix_quotes=true) {
        if ($staf_handle instanceof Staf) {
            $res = $staf_handle->cmd($cmd, '', false, $return_output, $ignore_rcs, $fix_quotes);
            if ($return_output) {
                $res = $staf_handle->stafcmdout_to_array($res);
            }	
            
            return $res;
        }

        $rc = 0;
        $res = array();
        $success = null; // TODO - check who expect a real false
        
        DBG2("running [$cmd] locally");
        exec($cmd, $res, $rc);
        try {
            if ($rc !== 0) {	
                if ($failure_severity >= 0 && !in_array($rc, $ignore_rcs)) {
                    $success=false;
                    throw new Exception("command [$cmd] failed with rc [$rc].");	
                }
                
                WARNING("command [$cmd] failed with rc [$rc]. ignoring as it's in the ignore_list or failure_severity was set to -1");
            }
            else {
                $success=true;
            }	
        }
        catch (Exception $e) {
            Excep::handelEx($e, $failure_severity);
            //return false; // would like to return the output - for instance in zendctl.sh status
        }
        
        if ($return_output) {
            return $res;
        }
        else {
            DBG4("command [$cmd] returned the following output: " . print_r(self::trim_array($res), true));
            return $success;	
        }

    }
}
Comment 1 Zhongwei Zhao CLA 2010-08-18 20:07:22 EDT
fixed in head and branch
Comment 2 Gadi Goldbarg CLA 2010-08-30 10:03:41 EDT
[Petyo Tanchev]
Tested on 2.2.1.v20100829
CA still outputs:
Utils::exec($cmd, $ignore_rcs)
Comment 3 Zhongwei Zhao CLA 2010-09-07 02:48:34 EDT
Created attachment 178297 [details]
patch
Comment 4 Zhongwei Zhao CLA 2010-09-07 03:06:44 EDT
fixed
Comment 5 Petyo Tanchev CLA 2010-10-06 08:56:30 EDT
Tested on 2.2.1.v20101001
Fixed