Query method name as a string

Please add a new line in contextual menu to query a method “as a string” (same as query in development) in order to find methods used with quotes.

Annotation 2020-05-29 161358

Or generally, when searching for callers, for instance:
aufrufe

Then calls like New process(“myMethod”) or Execute on server(“myMethod”) should be included.

(It is clear that constructs like New process(“my”+String($n)+“thMethod”) cannot be found.)

1 Like

I have been asking for a long time to resolve this issue. Finally with 18R2 there is a hackish work-around where you can have the method reference and also get the name as a string. For example:

GET_Method_name (Formula(my_method_name ))

where GET_Method_name is

 //Extracts the method name from the formula object.

  //$0 - Method name.
  //$1 - Formula object.

C_TEXT($0)
C_OBJECT($1)

C_LONGINT($pos;$len)

$0:=$1.source
$pos:=Position("(";$0;*)
If ($pos>0)
	$0:=Substring($0;1;$pos-1)
End if 
$len:=Length($0)
Case of 
	: (Asserted($len>0)=False)
	: ($0[[$len]]=" ")  //4D Tokenizes methods with a space at the end.
	$0:=Substring($0;1;$len-1)
End case 

Thank you but too tricky :slightly_smiling_face:

The context: I had a tenth of methods to be renamed. Before renaming, I check if none of them is used with quotes "(execute method(“mymethod”)).
I want to make it quick, I don’t want to use a hammer to catch a fly :wink:
My request is a kind of shortcut for “query in development”.

Hi Bertrand,

May, as you know, this is already implemented in QST from a while and it takes care of this specification.

Patrick

Just if i understand correct and you mean like:
Find in Design / Find:Text / which:contains:“anymethodname”
(sorry when i am wrong/missunderstood)

Find in Design

Disadvantages for / Find:Text / which:contains:“anymethodname”

  • searches comments too but this is not wished
  • / Find:Text / which-options can not define exactly methodCall or exactly “methodName”…beginWith/endWith/wholeWord/contains is not enought to differ “aa” from “aaBB” (it must matches fully not any text-snippet)

Since I would rather recommend in the context menu to offer a search like
Find in Design / Find:AnyLanguageElement / which:matches:“anymethodname”
This found and sorted out what is not wished to found:

  • menuEntrys found
  • stringInQuotesMatchesFully found
  • methodCallers in 4D-Code found
  • differs between “aa” and “aaBB”
  • ignores comments

IMHO, as I had a lot of renaming to do recently… I could proceed correctly with the “find in design” - I won’t say fast, but I don’t do that every day. The real matter is things like:

$methodName:=$something+$somethingElse
execute method($methodName)

Did you know that you can, in the results dialog with the action menu, quickly select all the lines corresponding to what you want to remove (in your exemple, the menus) then with the contextual clic make a “Remove from list”.
Another way I commonly use is to export results and open in excel to perform filtering and keep a trace for documentation or a long code refactoring

1 Like

To be mentioned too, for “wan workers”: since a few versions (v16, I seem to remember), find in design runs faster, can be stopped and resumed. There is still a noticeable slow-down when it’s running (code editor window, for example), but it’s useable.

I still miss something in the results window, find in results: it would be so welcome…

What is really tricky is relying on two different ways to reference methods. You now have the ability to solve this forever and really know where every method is referenced. Prior to version 18R2 I kept every method referenced using a string in a single uncalled method. From that method I generated constants and never used “Method Name”.

I would at least recommend any place you use “Method Name” to add a reference in the method using something like the code below to find all the references.

If (False)
  Method Name
End if
2 Likes