nikhilkalige / docblockr

DocBlockr is a package for Atom which is designed to make writing documentation faster and easier.
MIT License
406 stars 93 forks source link

Uncaught TypeError: Cannot read property '1' of null with PHP Syntax Error #162

Open codazoda opened 8 years ago

codazoda commented 8 years ago

Steps to reproduce:

Type the following code and save it into a file called bug.php.

<?php

class Example {

  private function get(number) {
    return false;
  }

}

Move just above the function and type /** and press enter. You'll get the error.

Notice that my private function has a syntax error. It should be $number instead of number, but it would be awesome if docblockr didn't throw an uncaught error here.

Atom Version: 1.4.2 System: Mac OS X 10.11.1 Thrown From: docblockr package, v0.7.3

Stack Trace

Uncaught TypeError: Cannot read property '1' of null

At /Users/joel/.atom/packages/docblockr/lib/languages/php.js:67

TypeError: Cannot read property '1' of null
    at DocsParser.PhpParser.get_arg_name (/Users/joel/.atom/packages/docblockr/lib/languages/php.js:67:19)
    at DocsParser.parse_args (/Users/joel/.atom/packages/docblockr/lib/docsparser.js:265:48)
    at DocsParser.format_function (/Users/joel/.atom/packages/docblockr/lib/docsparser.js:130:32)
    at DocsParser.parse (/Users/joel/.atom/packages/docblockr/lib/docsparser.js:44:37)
    at DocBlockrAtom.module.exports.DocBlockrAtom.parse_command (/Users/joel/.atom/packages/docblockr/lib/docblockr-worker.js:279:29)
    at atom-workspace.<anonymous> (/Users/joel/.atom/packages/docblockr/lib/docblockr-worker.js:75:16)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:536:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:359:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:97:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -3:57.1.0 core:move-up (atom-text-editor.editor.is-focused)
     -3:56.2.0 core:move-down (atom-text-editor.editor.is-focused)
 26x -3:55.6.0 core:move-left (atom-text-editor.editor.is-focused)
  5x -3:53.9.0 core:select-left (atom-text-editor.editor.is-focused)
  3x -3:51.3.0 core:backspace (atom-text-editor.editor.is-focused.autocomplete-active)
     -3:49.4.0 core:move-up (atom-text-editor.editor.is-focused)
     -3:47.6.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
     -0:04.6.0 editor:select-to-first-character-of-line (atom-text-editor.editor.is-focused)
  3x -0:04.1.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:02.4.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
     -0:02.4.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:01.7.0 docblockr:parse-tab (atom-text-editor.editor.is-focused)
     -0:01.7.0 snippets:next-tab-stop (atom-text-editor.editor.is-focused)
     -0:01.7.0 snippets:expand (atom-text-editor.editor.is-focused)
     -0:01.7.0 editor:indent (atom-text-editor.editor.is-focused)
     -0:00.5.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)

Config

{
  "core": {},
  "docblockr": {}
}

Installed Packages

# User
docblockr, v0.7.3

# Dev
No dev packages
lysz210 commented 8 years ago

You forgot the dollar prefix on the variable name. When using type declaration arguments it highlight as error but it doesn't prompt any error and build the comment correctly.

madvik commented 8 years ago

For me in php script, you insert a js script and you would add a comment on it :

<?php echo "poooo"; ?>
<script>
/**{enter}{crack-bug}
function jsfunciton(){
....
}
</script>
codazoda commented 8 years ago

My bug report is specifically about the behavior when you have a typo that results in a syntax error. Probably a low priority as a result.

madvik commented 8 years ago

When i have the bug, Atom redirected me to this bug, the same error code.

mattiekat commented 8 years ago

I have the same issue for valid code in C/C++

  1. Write a function declaration with a reference or pointer and do not name the parameter
  2. Something like void foo(int&); or void foo(int*);
  3. Try to document it with /**

Atom Version: 1.3.1 System: "Arch Linux" Thrown From: docblockr package, v0.7.3

Stack Trace

Uncaught TypeError: Cannot read property '1' of null

At /home/matthew/.atom/packages/docblockr/lib/languages/cpp.js:64

TypeError: Cannot read property '1' of null
    at DocsParser.CppParser.get_arg_name (/home/matthew/.atom/packages/docblockr/lib/languages/cpp.js:64:19)
    at DocsParser.parse_args (/home/matthew/.atom/packages/docblockr/lib/docsparser.js:265:48)
    at DocsParser.CppParser.parse_args (/home/matthew/.atom/packages/docblockr/lib/languages/cpp.js:49:44)
    at DocsParser.format_function (/home/matthew/.atom/packages/docblockr/lib/docsparser.js:130:32)
    at DocsParser.parse (/home/matthew/.atom/packages/docblockr/lib/docsparser.js:44:37)
    at DocBlockrAtom.module.exports.DocBlockrAtom.parse_command (/home/matthew/.atom/packages/docblockr/lib/docblockr-worker.js:279:29)
    at atom-workspace.<anonymous> (/home/matthew/.atom/packages/docblockr/lib/docblockr-worker.js:75:16)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:260:29)
    at /usr/share/atom/resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:536:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:359:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/usr/share/atom/resources/app.asar/src/window-event-handler.js:97:36)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -0:29 editor:newline (atom-text-editor.editor.is-focused)
  2x -0:27.4.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
     -0:23.1.0 editor:select-to-first-character-of-line (atom-text-editor.editor.is-focused)
     -0:22.7.0 core:delete (atom-text-editor.editor.is-focused)
     -0:21 docblockr:parse-enter (atom-text-editor.editor.is-focused)
     -0:04.8.0 editor:select-to-first-character-of-line (atom-text-editor.editor.is-focused)
     -0:04.5.0 core:delete (atom-text-editor.editor.is-focused)
  2x -0:03.9.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:02.5.0 core:save (atom-text-editor.editor.is-focused)
     -0:02.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)
     -0:02.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:01.3.0 snippets:next-tab-stop (atom-text-editor.editor.is-focused)
     -0:01.3.0 snippets:expand (atom-text-editor.editor.is-focused)
     -0:01.3.0 docblockr:parse-tab (atom-text-editor.editor.is-focused)
     -0:01.3.0 editor:indent (atom-text-editor.editor.is-focused)
     -0:00.3.0 docblockr:parse-enter (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-material-ui",
      "one-light-syntax"
    ]
  }
}

Installed Packages

# User
atom-material-ui, v0.8.1
docblockr, v0.7.3
file-icons, v1.6.14
hyperclick, v0.0.35
language-cpp14, v0.6.0
language-latex, v0.6.1
language-squirrel, v0.4.3
linter, v1.11.3
linter-javac, v1.5.0
linter-jshint, v2.0.2
pdf-view, v0.39.0

# Dev
No dev packages
jordwalke commented 8 years ago

I have seen this too. Is this plugin abandoned?

jasperkennis commented 8 years ago

I'm getting this error when I call the WrapLines command.

StefanHamminga commented 7 years ago

Just got this error while documenting a C++ member function declaration.

docblockr version: 0.8.4

The snippet of code causing the issue:

class DukThread {
public:
    DukThread ();

    /** <- crash here */
    void eval (const std::string& script,
               const boost::function<void (std::string&)>& onSuccess,
               const boost::function<void (std::string&)>& onError = [](std::string& result){ std::cerr << "DukThread " << result << std::endl; });
...
}
sgtcoolguy commented 7 years ago

I'd also receive this error for C++ header code on a function using un-named parameters.

MoritzKn commented 7 years ago

This error appears in various cases, but Atom sends everyone to this issue. If you see this error, Atom sends you to this page and your problem is not yet covert: please open a new issue and describe the behavior that lead to the error.

Problems described in this issue

Edit: I thought blocking an Issue would limit access to participants but it removes access for all users, so I won't do that.

MoritzKn commented 7 years ago

222 addresses the WrapLines error.

MoritzKn commented 7 years ago

The Error with unnamed function parameters in C++ was fixed by @jeremyvii. Version v0.8.6 released the fix.

MoritzKn commented 7 years ago

The Wrap Lines Error was fixed by #222

jordwalke commented 7 years ago

This did not seem to fix it for me. I'm still seeing this same error, even after upgrading.

MoritzKn commented 7 years ago

@jordwalke As described in my comment above, this issue describes multiple errors. Some off them got fixed, some didn't. What particular problem did you experience?

jordwalke commented 7 years ago

The wrap lines error still occurs with the same message in the OP.

MoritzKn commented 7 years ago

@jordwalke This problem is not fixed yet. See my comment.

H-s-O commented 5 years ago

Still happens to this day.