Author Topic: Output to search window from list of filename/line num/col num  (Read 896 times)

rowbearto

  • Senior Community Member
  • Posts: 1597
  • Hero Points: 116
Output to search window from list of filename/line num/col num
« on: September 25, 2018, 02:59:07 am »
I would like to know if it is possible to get a search window to display results from a string array of filename/line#/col# that is output from an external code analysis tool that I execute through a SlickC macro. I'd also like the ability to list the context that each file/line#/col# is in, as if I did "Find in Files", except using an external tool instead of SE to do the search.

So I'm asking for the equivalent of doing a search in SE and displaying the results in a search window with list current context, EXCEPT, instead of SE doing the search I used an external tool that returned all the locations that I want displayed in a double clickable manner showing the contents of the line, line#/column, with "list current context" enabled.

Does something like this exist already? If not, it would be a nice feature to add.
« Last Edit: September 25, 2018, 03:07:44 am by rowbearto »

rowbearto

  • Senior Community Member
  • Posts: 1597
  • Hero Points: 116
Re: Output to search window from list of filename/line num/col num
« Reply #1 on: October 09, 2018, 02:37:11 am »
I was able to accomplish this by reusing many ideas from bgsearch.e. Hopefully the underlying macros that I call upon are stable. I'm listing what I'm using in this post so SlickTeam can confirm for me if it is kosher for me to call these functions from my user macros and that they will be stable in future releases.

This functionality is really handy because I'm getting C++ find references results from an external tool (cquery which has clang parsing! https://github.com/cquery-project/cquery) and putting the results into a search window - functionality I've always wanted from SlickEdit's reference search (https://community.slickedit.com/index.php?topic=15005.0 and https://community.slickedit.com/index.php?topic=16328.0).

I made use of 'class SearchResults' from se/search/SearchResults.e and used the following member functions:

SearchResults.initialize()
SearchResults.showResults()
SearchResults.insertFileLine()
SearchResults.setContext()
SearchResults.insertContextLine()
SearchResults.setMatchLinenum()
SearchResults.insertLine()
SearchResults.done()

Additionally for showing the context of the results, I used many functions that the comments say are new to v23:

tag_search_result_context_start()
tag_search_result_context_find()
tag_search_result_context_get_contexts()
tag_search_result_context_get_info()
tag_search_result_context_end()
« Last Edit: October 09, 2018, 02:44:49 am by rowbearto »

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Output to search window from list of filename/line num/col num
« Reply #2 on: October 09, 2018, 01:56:41 pm »
The SearchResults wrapper class has most of what you need there.  Should be good using those for now, the future could always add more types of contexts to the search results.  Don't think there would be radical changes in the future, but you can't stop progress.

In Beta 5, we did a context menu command that allows for copying References and Find Symbol results to Search Results, under Contents > Send to Search Results.

rowbearto

  • Senior Community Member
  • Posts: 1597
  • Hero Points: 116
Re: Output to search window from list of filename/line num/col num
« Reply #3 on: October 09, 2018, 02:01:49 pm »
Thanks Lee for the response!

I was unaware that the Contents->Send to Search results was there. I just tried it now, definitely an improvement and allows to search the "Find references" output. But is seems like it is like "list current context" without providing the line from the file with the match. I'd like to get the line with the match displayed in the search results, almost like I did a search and it found all the lines where the reference was. This is what my macro does for the cquery output.