Show overloads of a method in Intellij - intellij-idea

Often times I know what method to use but not what overload of that method. Is there a quick way to show all overloads of a method in Intellij?

Just use Code Completion Cmd/Ctrl+Space?
It is also possible to show overloaded constructors by enabling a hidden option. Invoke the Help | Find Action menu item and type Registry to go to the Registry. Here enable the java.completion.show.constructors option.
When you already have the complete method or constructor name, and just want to know which parameters it and its overloads accepts, use View | Parameter Info Cmd/Ctrl+P.

Related

Whenever a property or function of `Vue instance` changes , some of the methods gets executed. Please explain this behavior

https://jsfiddle.net/Arpan_Banerjee7/bfnL50vs/1/
I have shared a link of JSFiddle, you can see the demo there.
Whenever you mousemove over the last paragraph, the coordinates changes and it gets logged as expected.
But I have noticed a rather strange behavior.
I noticed that whenever the function changeCoordinates() is executed the other two functions within the method also gets executed--randomNumber() and testFunction().
Please open the dev tools>console to see the logs of testFunction().
Does all the methods execute whenever any of the methods executes?
Can you please explain this?
See https://v2.vuejs.org/v2/guide/computed.html#Computed-Caching-vs-Methods
In comparison, a method invocation will always run the function whenever a re-render happens.
So whenever your X or y values change a re-render is invoked on the page and the methods are run, since they are called from the template.
In your case it seems that "all method" are run, but that is simply because all methods are present in the template. Methods only run when explicitly activated, either by code in another method or by invocation from the template.

How to execute specific method implicitly before interacting with element in Selenium?

The application I'm automating is using jQuery and ajax calls. Hence before interacting with elements, I wait for document to be ready and all ajax calls to complete. Only then I interact with element like sendKeys(), click() etc
For this, I need to add that method (say waitForDocumentReadyAndAjaxTocomplete()) explicitly everywhere wherever element is being interacted.
Is there anyway I can call that method waitForDocumentReadyAndAjaxTocomplete() implicitly before interacting with an element?
Yes, there is a way. You can create an utility class which creates your identifier using the locator you want to use and in the method where you create the identifier you can call the waitForDocumentReadyAndAjaxTocomplete method.
Basically the utility class will handle the call and you can actually have a try catch or a polling mechanism to optimize the call to the method as suits your requirement.
This way you donot have to call the waitForDocumentReadyAndAjaxTocomplete method everytime. It will be called in your utility class.
You can use the power of PageFactory.initElements(..) where you can:
Design your bindings in Page Object pattern
Intitialize elements of your page classes using your custom ElementLocatorFactory / ElementLocator. Where you can can add waiting of your dom events before finding elements.
You can check how AjaxElementLocatorFactory is implemented. There should not be issues with following this approach sine all key methods are public so can be simply overriden.
However I guess you will have to supply #CacheLookup annotation to all your fields annotated with #FindBy

How can I access the WebDriver module from within an AcceptanceTester?

I have a test, where I an trying to change the configuration:
$this->getModule('WebDriver')->_reconfigure([...]);
This shows what I am trying to do under "Dynamic Configration": http://codeception.com/docs/06-ReusingTestCode#.VnXNjq6rTUI
Edit:
It appears that I have to call this on the moduleContainer, but this is located at:
$I->scenario->test->moduleContainer->getModule('WebDriver')->_getConfig('url');
However $test is under private access, and there is no getTest() method.
Documentation says: You may call it from a helper class and pass in all the fields you want to change.
Add reconfigure method to your Acceptance helper and call it from your test.

Finding where class constructors are called in IDEA

In Eclipse, you can focus on class XXX and press Ctrl+Alt+H, to get a call hierarchy showing everywhere that new XXX(...) is called.
In IntelliJ IDEA, I can only do this on each constructor separately, and I can't do it at all on the default constructor (invisible).
Is there a way in IDEA that I'm missing? (Ultimate 12.1.3)
If I'm understanding your question correctly - one way you can do this is to select the classname (instead of an individual constructor name) and press Alt+F7 (Find usages).
This will find all usages of that class - the "Found Usages" window that will be displayed is split up into expandable sections, one of which will be "new instance creation".
NOTE: if you can't see a New instance creation grouping, makes sure Group by usage type is enabled (the "funnel" looking icon in the screen shot below).
In IDEA 2017.2, it looks like this:

Search usages of Subclass's method

I have parent class Parent with method getToken(). And I have its child class - ChildA and ChildB, which don't override method getToken().
How I can search usages of method getToken() which used by instance of class ChildA?
Sorry for my English. Thanks!
As I spent half an hour to find the exact solution through all complicated and outdated documentations and examples, I just put the full answer using SSR here (Intellij 15.0.5):
Open SSR dialog (Edit > Find > Search Structurally...) and input template in screenshot, then click on "Edit variables..." to see the second dialog and edit the "Expression type (regexp)" as shown:
and if you want to include subclasses of ChildA too, just check the box "Apply constraint within type hierarchy" bellow the expression type:
You can add getToken() to ChildA, perform the search only for this method, then delete it. Another way is to use Structural Search and Replace.
Intellij asks about this if you use Ctrl+Alt+Shift+F7 for the search. First you have to explicitly override the method in the subclass/subinterface though, as CrazyCoder suggested.