how to load intellij settings on startup - intellij-idea

In eclipse we have to extend AbstractPreferenceInitializer, and define the below lines in plugin xml, to load preference details on eclipse startup.
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.example.preferences.PreferenceInitializer">
</initializer>
</extension>
How do we do the same thing in intellij?

Persisting State of Components

Related

Cannot resolve method generated by annotation processor

I have two projects. One of them is projectA a processor for annotations. Second one, projectB use projectA as dependency. Now this processor is add toJson method to exists class before final compile. Everything works normally. When I compile projectB my projectA is run and modify exists source file and add toJson method. Also intellij auto detect this processor and automatically configure my custom processor to the processor path. But editor give error Cannot resolve method 'toJson' in 'CacheData'. How I can solve this problem?
The below image is my intellij configuration. As you see IDEA automatically detect my processor from my pom.xml but editor does not recognize the generated code
I use IntelliJ IDEA 2021.3 (Ultimate Edition), maven-3.8.1, jdk-1.8 for processor(projectA) and jdk-11 for projectB
Finally I solved my problem. It seems that current version of Intellij only supported auto generated class. But if you modify exist file with you annotation processor Intellij editor can not recognize your changes and shows as errors. Thank you very much to #mplushnikov for his lombok-intellij-plugin. I just create my own plugin for IntellIJ and add dependence. After doing this you need to override some entrance classes and add your own annotation and its processor handler and extends it from AbstractClassProcessor
Let me share some example so if anyone who has this problem can use it.
IntellIJ Plugin tutorial for beginner
The below code snippets are from my plugin.xml. First you need add some dependencies to your plugin
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.java</depends>
<depends>Lombook Plugin</depends> <!-- this is the lombok-intellij-plugin-->
Second step is adding required extensions to your plugin as below
<extensions defaultExtensionNs="com.intellij">
<!-- Add your own custom processor. because lombok plugin default search only lombok package and own annotations -->
<lang.psiAugmentProvider implementation="your_package.AugmentProviderImpl"/>
<!-- if you packaged your classes other than lombok -->
<codeInsight.externalLibraryResolver implementation="your_package.ExternalLibraryImpl"/>
<implicitUsageProvider implementation="your_package. ImplicitUsageProviderImpl"/>
<!-- Add your custom annotation processor handler and extend it from AbstractClassProcessor -->
<applicationService serviceImplementation="your_package.CustomAnnotationProcessor"/>
</extensions>
Thats it. Follow these steps, build your plugin and install it. After restart your class's methods which is generated by your own annotation will be recognized by intellij.
Implementing the class is not hard. Just look the lombok-intellij-plugin source code and copy the required file and just modified it.

eclipse rcp perspectiveExtension showInPart not visible

I want my ViewPart add to Show In group. I added perspectiveExtension and add showInPart under it, when I run/debug my plugin, my view not appears in Show In context menu group.
Here is my extension point in plugin.xml
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<showInPart
id="com.ex.views.DebugView">
</showInPart>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.ui.resourcePerspective">
<showInPart
id="com.ex.views.DebugView">
</showInPart>
</perspectiveExtension>
</extension>
Using Eclipse 4.15 (though likely also any 4.x), I had to start in a new workspace for such changes to have an effect. When debugging Eclipse (in a non-clean/old workspace), the changes had no effect.

Activate certain Maven profile in Intellij IDEA only

I'm looking for a way to activate the certain profile, which includes some dependencies and settings, related to the development mode only, when the project is opened in IDEA.
I know that you can specify the profile to be used - on project import, or in "Maven projects" tab. However it requires some interactions, which are easy to forget.
So it would be nice to instruct idea to always activate the appropriate profile, may be by providing some property or runtime configuration, or whatever.
This profile should be active only for IDEA import.
For auto-activation of the profile, you can base the activation on a system property that is only present when running through the IDEA embedded Maven:
idea.maven.embedder.version
idea.version
Example:
<profile>
<id>idea-only</id>
<activation>
<property>
<name>idea.maven.embedder.version</name>
</property>
</activation>
...
</profile>
idea.maven.embedder.version works with IDEA's bundled Maven and also works if you override that with your own locally installed version of Maven in preferences - the idea.maven.embedder.version property is always set when executed from within the IDEA when importing, generating sources, etc.
If you import a maven project in intellij, you can choose profiles in the maven tool window (usually on the right of the screen). Once these profiles are selected they will persist in the project configuration for that project and will become effective every time the project loads, until you choose to change them. These profile selections will only affect intellij and instances of maven run within intellij.
Another way to achieve this is in Intellij's maven configuration, by specifying a settings file that is specific to intellij development. This can be a copy of your standard settings, named something like intellij-settings.xml, but you can add an active profiles section to it:
<activeProfiles>
<activeProfile>intellij-specific-profile</activeProfile>
</activeProfiles>
Be sure to specify the settings file in your intellij maven config before importing the project. That way it will apply to all projects on import.

Eclipse plugin project - run command when start

When running a project plugin I want to execute a simple method (eg: System.out.println), so how where can I do this?
What I'm trying to do is create a project plugin with an activator class and insert inside the Activator constructor the method System.out.println but it is not working.
If you want something to run during the Eclipse start use the org.eclipse.ui.startup extension point:
<extension point="org.eclipse.ui.startup">
<startup class="example.StartupClass"/>
</extension>
where StartupClass implements org.eclipse.ui.IStartup

Cannot contribute extension from a fragment

I am working on a set of plugins and fragments on eclipse 4.3 (Kepler) but using the 3.x model.
One plugin contains part of the application model and has a fragment which contributes some model editors. (This seems right to me - tell me if it's unnecessarily complicated)
In the main app these editor contributions are not listed. I changed the fragment to a plugin and the editors became visible.
I could change the fragment to a plugin but this would mean that I have to expose more of the model.
I could move the fragment to the host plugin but this would mean mixing model and view (perhaps not a big deal)
Is it generally not possible to contribute from a fragment or have I done something wrong?
Here is the fragment:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<fragment>
<extension
point="org.eclipse.ui.editors">
<editor
class="com.acme.atf.device.ui.editors.NullConfigEditor"
default="false"
id="827299e9-6039-4a76-bfa6-08ef2d7f8724"
name="VariableEditor">
</editor>
<editor
class="com.acme.atf.device.ui.editors.SerialConfigEditor"
default="false"
id="cbaba4b2-8380-4ae5-9896-542cf97ca8cc"
name="SerialEditor">
</editor>
</extension>
Further information
The plugin hierarchy looks like this: (P=plugin, F=fragment)
com.acme.atf.app (P)
com.acme.atf.device (P)
com.acme.atf.device.help (F)
com.acme.atf.device.ui (F)
com.acme.atf.model (P)
com.acme.atf.core.ui (P)
An action in com.acme.atf.app attempts to load an editor (which happens to be in device.ui) which cannot be found. If I change device.uito a plugin then the editor is found.
Just managed to solve very similar problem with Eclipse 4.4.1. Unfortunately, the solution was to use clean workspace (I've imported my projects from Git).
Before that, I tried "playing" with version numbers of host and fragment, singleton flags, recreating fragment project, cleaning all projects and configuration of my RCP app. Also, I used OSGI console trying to get some additional info, but it reported only that:
Host plug-in org.aaa.bbb is in ACTIVE state (with no fragments)
Fragment bundle is in INSTALLED state (reporting "Unresolved requirement: Fragment-Host: org.aaa.bbb")
I think this is a bug and garbaged workspace (launch) configuration may be the cause. Hope this helps someone.