I'm using IntelliJ IDEA and have it set up to open the JavaDoc for any type or member in my browser. Now it seems that IntelliJ IDEA can't guess the full URL for methods that have a generic type as parameter, when I try to to open the documentation for the method java.lang.Object.isAssignableFrom(Class<?>) it asks which of these two URLs should be opened:
file:///[...]/docs/api/java/lang/Class.html#isAssignableFrom(java.lang.Class<?>)
file:///[...]/docs/api/java/lang/Class.html#isAssignableFrom(java.lang.Class)
Are these two competing standards for encoding the type of a method with generic parameters? Can I assume that only one will be used in the future (presumably the first)?
For an added bonus: Is there a way to set up IntelliJ IDEA to automatically chose one of these forms by defaults?
Related
Can IntelliJ IDEA automatically fill the method call with variables?
Possibly using the names which are based on the names of the parameters of the method which is called and even also with possibility to extract those variables as parameters of the current method?
See the screenshots below for reference.
Before: IntelliJ knows what are the names of the parameters of the method which is being called.
After: IntelliJ created properly named variables for us.
With automatic extracting of all parameters: IntellJ can automatically extract these variables to be parameters of the current method.
It should work if there are the local variables with the same name exist in context:
See also IDEABKL-6690, IDEABKL-5496 requests.
You can also try Smart Completion: https://www.jetbrains.com/help/idea/auto-completing-code.html#smart_completion.
There is a custom plugin that seems to do the thing - https://plugins.jetbrains.com/plugin/8638-auto-filling-java-call-arguments. You can give it a try
I am using IntelliJ IDEA 15, and I noticed that (by default) Eclipse offers a much more convenient auto-completion, when it comes to writing method calls, which require multiple parameters.
Eclipse automatically fills in default parameters and allows you to quickly navigate through them by pressing Tab:
However, IntelliJ IDEA does not handle it as conveniently and makes you write them manually:
Is there a way to make IntelliJ IDEA, handle method call auto-completion in a similar way to Eclipse's, and pre-write all the parameters for you, having you just press Tab (or another key) to navigate through them? If it is not possible in original IntelliJ, is there an add-on/plugin/external tool that will improve the intelligent code completion in such cases?
Note: I am not being lazy, it just gets quite annoying, having to manually complete each parameter and put a comma after each one, when code completion should do it for you.
IntelliJ doesn't do it and AFAIK there isn't a plugin for it.
There is no solution for you (unless you built a plugin yourself, but then you'd just have another job to maintain that plugin)
The alternative is to break the habit/need for it and use IntelliJ's Code Completion shortcuts:
Ctrl+P to view possible parameters for function.
Ctrl+Shift+Space to list the possible variables that could be entered as a parameter in the respective parameter position (based on type).
This also enters a comma if another parameter is required for the function.
Hardcoding numbers/strings as parameters to a custom function wouldn't be advisable as that negates the point of the parameters. It's better practice and more common to pass in a pre-defined variable; At which point Ctrl+Shift+Space is the easiest way for Code Completion.
This would also prevent you from closing quotations and adding commas.
Also note: IntelliSense is Microsoft's Intelligent Code Completion implementation which neither IntelliJ nor Eclipse uses.
As frant.hartm states in their answer:
Unfortunately the view of Intellij developers is that this feature would be too error prone. See this issue on youtrack.
They even state that people are welcome to make a plugin that does this.
The closest thing to this AFAIK is "method parameter completion", which allows you to auto complete parameters of current method as parameters of the inner method call at once (works for methods and constructors when calling super()).
Unfortunately the view of Intellij developers is that this feature would be too error prone. See this issue on youtrack.
IDEA doesn't fill the arguments automatically. You can use Ctrl+Shift+Space for auto-completion (completion is based on type, not name) or Ctrl+Alt+Space for suggestion. Or Ctrl+P to see what arguments are accepted.
Try
Ctrl + Space
for
Basic Code Completion
And like previously was written
Ctrl + Shift + Space
for
Type Code Completion
or try the second variant TWICE. More about Auto-Completing Code is in here
I have an Eclipse plugin which has the purpose of indexing and searching XML files for custom frameworks used by the application my team develops.
There is a toolbar with several buttons on it. Each button has its own command and each command is linked to a separate handler which brings up a search dialog.
The handlers differ only by which file type they search. Currently there are ten concrete handlers and one abstract. All of the functionality is handled in the abstract class, and the concrete classes only implement an abstract "get file type" method.
Ideally I would only have one handler. This means there would need to be a way to inject the enum into the base class directly.
I looked at command parameters, but this appears to be user-facing. I need something hard-coded where the command tells the handler "use this value." I don't care if this is a constructor argument or some hard-coded parameter in plugin.xml.
Thus far I have not been able to find a way to do this. Perhaps my Google-fu is weak, perhaps I am just not seeing it.
Is there a way to specify a hard-coded parameter to a handler constructor or to call a method to set a parameter after it is constructed but before it is invoked?
Command parameters are the right way to achieve that. What are the problems you face with that? Here is an example to use the parameters
Eclipse calls the default (zero-argument) constructor when instantiating an extension point. I want to provide some arguments. I found a recommendation to use IExecutableExtension#setInitializationData but that appears to require specifying the argument values statically in XML. I need them to be dynamic. Another recommendation was to implement IExecutableExtensionFactory but that seems heavy handed. (The interface also seems pointless, as all it contains is a create() method.) I could add a method to set the values after creation but my class won't work correctly without them and they shouldn't be changed after creation, so forcing them to be provided at object creation time is preferable. This can't be a unique situation. What's the standard way of handling this?
If the arguments need to be "dynamic," where would they come from? How would Eclipse know what values to use? Extension point objects are created when the plugin is activated, so there is not much context available at that point.
I think the best option for you is to use IExecutableExtensionFactory after all. Your factory can implement IExecutableExtension to receive the XML configuration data and then be coded to create the objects based on that and any other context you can make available to it.
Depending on your needs, you could use Dynamic String Substitution Variables to insert certain context into your factory. See also Externalizing strings in plugin.xml for Eclipse plugin
Hi all i'm very new to acceleo
In my project, i have a java driver class which calls different acceleo templates. Some of the templates have parameters without any EObject type. I am calling calling initialize() and doGenerate() functions of generated java module for a template. the problems are facing are :
initialize() expects the first argument to be Ecore object and rest of parameters are as List. However as I mentioned some of the templates do not have any EObject parameters. How do I call such templates from a java application?
To work around the above problem, i adjusted my driver and templates to have dummy EObject as first parameter. Then it calls templates successfully but it won't generate any output. The templates generate output if I call them from another driver template though. However I do not want to write my driver program in MTL as it requires complex analysis of data model.
Please advice me on how can I progress in my case.
Thanks&Regards
Dhanunjaya M.
The API we expose by default through the Java class we generate alongside the "main" templates' modules and the Acceleo "facade" classes always assume that there is an EObject as first parameter of the templates that are to be called. This has been made in order to facilitate the use for most use cases (we expect this use case to be 90% of the total).
For other use cases, you will have to make use of the APIs that are behind those facades. Namely, you can create another "initialize" method that does not take an EObject as parameter for these cases when you simply don't have one. You will then need to also override the "generate(Monitor)" method so that it does not use AcceleoService.doGenerate... or any other method of AcceleoService for that matter : this is the "facade" class that I was talking about.
What you will need is to call a method that mimics what AcceleoService.doGenerate does without relying on an EObject to find the template that needs to be called. If you do not have Acceleo's SDK or sources at hand, you can take a peek at the code through github : AcceleoService#doGenerate.