jeremyvii / vs-docblockr

DocBlockr for Visual Studio Code
GNU Lesser General Public License v3.0
21 stars 8 forks source link

Multiple lines of function arguments. Reduce of empty array with no initial value #75

Closed dmitrach closed 4 years ago

dmitrach commented 4 years ago

Describe the bug Does not generate comments for multiple lines of function arguments.

To Reproduce Steps to reproduce the behavior:

  1. Go to the line before a function with multiple lines of arguments.
  2. Type /** and Enter
  3. See the error 'Reduce of empty array with no initial value' and the following comment block:
    /**
     * [description]
     */

Expected behavior It should generate a comment block.

Code

     protected function getValueKeeper(
        PrintedSheets $pricingRule, 
        CalculationVariableKeeper $calculationVariableKeeper, 
        OptionCollection $options
    ): ?ValuesOfRunningMeter {
        return '';
    }

Screenshots Снимок экрана от 2020-06-04 16-35-18

Enviroment (please complete the following information):

jeremyvii commented 4 years ago

Using /** will not work for snippets with multiple lines. You will have to select the whole function signature, open VS Code's command palette, and select the Render from selection command.

dmitrach commented 4 years ago

Oh, yes, it works! But it is inconvenient)

jeremyvii commented 4 years ago

While it may be inconvenient, unfortunately it's the most reliable option with the current architecture. VS Code doesn't provide a reliable API for extracting symbols so a language agnostic parser is used. The entire document would need to be consumed in order to determine the end of the function signature. This would be very complex to implement and could get resource expensive if a user has a syntax error.