deakjahn / vscode-php-allfactor

Comprehensive PHP refactoring (Visual Studio Code)
https://marketplace.visualstudio.com/items?itemName=tramontana.php-allfactor
1 stars 0 forks source link

Can logs be more descriptive? #9

Open jota0222 opened 10 months ago

jota0222 commented 10 months ago

Greetings!

I'm facing an issue with the extension in my project, I have tried to reproduce it in other projects without success. It's not working at all, it just doesn't show the refactor options. The only Info I have about the issue are these logs, which tell me nothing:

[Info - 8:50:08 AM] started php-allfactor 1.3.5 [Error - 8:50:12 AM] [object Object] [Doc] [Error - 8:50:12 AM] [object Object] [Doc] [Error - 8:50:12 AM] [object Object] [Doc] [Error - 8:50:12 AM] [object Object] [Doc] [Error - 8:50:12 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:13 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:14 AM] [object Object] [Doc] [Error - 8:50:15 AM] [object Object] [DU] [Error - 8:50:15 AM] [object Object] [DU] [Error - 8:50:15 AM] [object Object] [Doc] [Error - 8:50:15 AM] [object Object] [Doc] [Error - 8:50:17 AM] [object Object] [Doc] [Error - 8:50:18 AM] [object Object] [Doc] [Error - 8:50:21 AM] [object Object] [Doc] [Error - 8:50:21 AM] [object Object] [Doc] [Error - 8:50:51 AM] name [Doc] [Error - 8:50:51 AM] array [Doc] [Error - 8:50:51 AM] name [Doc] [Error - 8:50:51 AM] array [Doc] [Error - 8:50:51 AM] name [Doc] [Error - 8:50:51 AM] original [Doc] [Error - 8:50:51 AM] name [Doc] [Error - 8:50:51 AM] original [Doc] [Error - 8:50:52 AM] source [Doc] [Error - 8:50:52 AM] source [Doc] [Error - 8:50:52 AM] type [Doc] [Error - 8:50:52 AM] type [Doc] [Error - 8:50:52 AM] TypeError: Cannot read properties of null (reading 'kind') [Analyze]

I think just by having better logs we can find the issue, at least, returning the objects in string instead of directly logging them.

If you have any suggestion to make it work for my project, I'll appreciate it.

Thanks for the help beforehand, and also many thanks for your work in this extension!

More data:

deakjahn commented 10 months ago

That's definitively a challenge. :-)

These are nodes in the analysis of PHPDoc comments (fortunately, the [Doc] tag at the end reveals that). I use the doc-parser library to parse those, so the various nodes and their toString() methods are not in my code, I just pass them to the console log.

Still, we might be able to catch the last line. This is basically a switch statement on node.kind, and the error message comes from the default branch, if something unexpected comes. But, it seems, node itself can be null and then node.kind doesn't make sense. I wonder if a simple guard if would help. It wouldn't analyze what it can't then but it shouldn't blow up.

The problem is that it was quite some time ago that I had last touched it and I don't know whether there were disturbing modifications in the code since the last publishing. It would be good if you could check a modified version without me actually publishing it blindly.

jota0222 commented 10 months ago

Thanks @deakjahn, I can indeed test it. Just tell me what to do to help you.