molsonkiko / JsonToolsNppPlugin

A Notepad++ plugin providing tools for JSON like linting, querying, a tree view, and CSV conversion.
Apache License 2.0
70 stars 9 forks source link

The plugin appears to do nothing for large directories #68

Closed sgartner-cityofboise closed 4 days ago

sgartner-cityofboise commented 3 weeks ago

Hello Mark,

You suggested that I try your plugin to solve my searching problem from the NP++ forumns, so I tried your plugin and the dialog does not seem responsive. Here's what I tried: image

The file list on the right does not populate, I waited some time. There is zero indication if something is actually happening but maybe it's loading in the background? There are over 4,000 json files in the directory that I am trying to search through.

Pressing "View results in buffer" resulted in nothing at all. I tried several times and could not get the plugin to even show me a list of json files recursively within that directory and the buffer is always empty: image

I'm really unclear how you were thinking this would work. If I'm understanding your plugin, it finds all the files then combines them into one giant JSON file? Then it still searches using a text search or RE, so even assuming your tool could load in the more than 4,000 JSON files across my projects, how is that better than simply searching the files directly with a RE search in NP++ or any other text search tool? It makes me wonder what it does with the invalid JSON files it finds in the path...

After playing with it some more I was able to get your plugin to show some files for a single project directory, but I never came to an understanding why, when I was trying to select a directory from the drop list in the middle of your dialog, it kept switching from the directory I was trying to choose to the phrase, "Previously visited directories..." which makes no sense to me when I'm trying to give the dialog a directory in which I want it to search. There is no button I can hit saying "search now" or something. And whenever I choose a directory using the Choose Directory button it only puts the directory in the list, but doesn't select it, instead returning it to the default phrase. I find that very confusing.

For a single project directory with only some 30 JSON files I finally got to the results page with a combined JSON result (but when and how it decides to load the right list of files is still a bit of a mystery, not quite in my control), but even then I could not figure out how to use the regular expression to find "all quoted constant strings that ended in employeeId." Here's a couple of example errors as I was trying things: image image

I read through RemesPath documentation and it seems to be focused on searching for JSON keys. I couldn't find a syntax that seemed focused on searching the values regardless of the key.

molsonkiko commented 3 weeks ago

@sgartner-cityofboise Thanks for your thoughts. I've posted responses to some of your comments/questions below.

I will put the jist of my response to each question in italics, and my proposed change (if any) in bold.

The file list on the right does not populate, I waited some time. There is zero indication if something is actually happening but maybe it's loading in the background? There are over 4,000 json files in the directory that I am trying to search through.

I could add a progress bar. Would that help? I'm rather concerned that this could degrade performance, but there are changes that I could make to improve the performance that might be able to offset that.

Pressing "View results in buffer" resulted in nothing at all. I tried several times and could not get the plugin to even show me a list of json files recursively within that directory and the buffer is always empty:

You didn't wait long enough. You can tell that the files have been parsed when the list of files to the right is no longer empty. Presumably a progress bar would help alleviate this confusion.

If I'm understanding your plugin, it finds all the files then combines them into one giant JSON file?

Yes. The output is an object where the name of each file is mapped to its content. This object is formatted according the the global formatting settings. You can query a subset of those files using regular expressions.

Then it still searches using a text search or RE, so even assuming your tool could load in the more than 4,000 JSON files across my projects, how is that better than simply searching the files directly with a RE search in NP++ or any other text search tool?

You misunderstood. The Find/replace in JSON form in the tree view does regex/text search on each key or value separately. I think I will go back and try to clarify that in the documentation. This is potentially superior to a normal regex search because it can, for example, do a search for strings matching the regex foo\s\*bar that are children of a key containing the string foo, without having to worry about JSON formatting.

It makes me wonder what it does with the invalid JSON files it finds in the path...

You can click the View Errors button to see which files had parsing errors. This is an object mapping filenames to a string describing the error that caused parsing to fail.

There is no button I can hit saying "search now" or something. And whenever I choose a directory using the Choose Directory button it only puts the directory in the list, but doesn't select it, instead returning it to the default phrase. I find that very confusing.

I can see why you found this confusing. I will take some time to think about a better way to do this.

I read through RemesPath documentation and it seems to be focused on searching for JSON keys. I couldn't find a syntax that seemed focused on searching the values regardless of the key.

If you wanted to find all strings (but not keys) containing the substring employeeId (ignoring case), the simplest RemesPath query would be @..*[and(is_str(@), @ =~ employeeId)]. You could also use the Find/replace in JSON form, with settings as shown in the below image: image

If you wanted to do something more advanced than that, you could read through the core RemesPath documentation.

molsonkiko commented 1 week ago

My most recent commit addresses many of the issues raised by the OP's original comment.

Here's a list of some reasonable tasks related to this issue, and their completion status.

molsonkiko commented 4 days ago

@sgartner-cityofboise

Since you haven't shown any interest in sharing your further thoughts on this issue, I'm closing this. If anyone else has concerns about this form, they can raise their own issues.