IntelliJ plugin : How to import settings - intellij-idea

In IntelliJ 12 (possibly earlier versions too) it is possible to import a jar with settings, previously exported.
I would like two write a plugin to specify a location where this settings jar can automatically be imported from. That would allow you to put a jar in your repository and in that way share it with your team.
With the lack of online javadocs for the open-api, I've had a hard time working out how to do this.
What class in the plugin framework will allow me to import settings?

The ImportSettingsAction is the class that provides the import action in the File menu. I bastardized it for my own purposes.

Related

Ktlint doesn't allow wildcard import? (Using IntelliJ auto import feature)

I am running a Kotlin project with ktlint maven plugin (first time user). but whenever I do a maven build. I often see the failure along the lines of
src/main/kotlin/com/myproject/model/User.kt:7:1: Wildcard import (cannot be auto-corrected)
Since I use IntelliJ, I often rely on auto import where many subpackages are grouped into a wildcard (*). Is this what ktline used to enforce good import practices?
As of version 0.34 or thereabouts you can override individual rules via EditorConfig. Add this to your .editorconfig file in the root of the project:
[*.{kt,kts}]
ktlint_no-wildcard-imports = disabled
https://pinterest.github.io/ktlint/faq/#how-do-i-globally-disable-a-rule
I was using ktlint-gradle and using the command ./gradlew ktlintCheck and my .editorconfig wasn't getting picked up. I solved it by adding this to build.gradle
ktlint {
disabledRules.set(setOf("no-wildcard-imports"))
}

Where can I find a bug collection to import into FindBugs?

I'm using the FindBugs-IDEA plugin for IntelliJ.
It finds much less bugs than our SonarQube (SonarQube uses FindBugs under the hood).
The plugin says I can Import/Export a bug collection from xml or html. Where can I find these collections?
If you want to import the same list of rules than what is configured in your SonarQube instance, you can go to "Quality Profiles > Your_Quality_Profile > Permalinks": you will find a link that you can use to download the list of Findbugs rules configured in your quality profile.
For instance, take a look at this page on Nemo: http://nemo.sonarqube.org/profiles/permalinks/169
Then, you just need to import this downloaded file in IntelliJ.
Here is a list of all the things you can check for: http://findbugs.sourceforge.net/bugDescriptions.html
You can find more info on how to use this info here: http://findbugs.sourceforge.net/manual/filter.html

Why is IntelliJ not showing the project structure?

Just tried to create a JAR with IntelliJ as always. Now IntelliJ doesn't show the project structure. It looks like this (I can't post an image, because Stackoverlow says I need "at least 10 reputation to post images"):
MyProject.iml
pom.xml
External Libraries
There are no classes or anything, that are the only files shown in tab "Project". Why? Version is 13.1.5
I checked all view options with an older project which does not have this problem after creating a jar, everthing is fine. First time that is occurs for me.
I'm using version 12.1.4
You can create a new project File -> Import Module -> and importing the older project.
Import Project also works as well.

IntelliJ IDEA and PlayFramework modules

After a lot of good comment about IDEA, I decided to give it a try. I downloaded the Community Edition and would like to use it for PlayFramework development.
I have followed official documentation and some other information gathered around, but I have not succeeded completely. When using a project with differents (play) modules, the different classes are not found.
For example when using Secure module, IDEA keeps complaining about not finding Secure.class. It has to be a classpath issue. I tried to attach Java source & classes ($PLAY/modules/secure/) in module settings (F4), class is still not found. Did I miss something?
BTW, I have done a play dependencies and play idealize, which seems to add another module Secure into project in IDEA.
Thanks,
The answer is to run the following:
play deps
play idealize
This forces the IDEA .iml project file to be refreshed with the updated class path entries for the new module (in this case Secure).
A issue I came across using IntelliJ and Playframework.
The log4j.properties file or log4j.xml file are not in classpath by default. You have to add the conf as a source folder in module settings.
You need to add the Secure module you have created in IDEA as a dependency to the main application module:
Go to File -> Project Structure
Choose the main module
Choose the Dependencies tab
Click Add -> Module Dependency
Choose the IDEA Module you created for the Play Secure module
Also make sure you have the correct source path selected for the Secure module in IDEA.

How do I add my fragment to the list of required-plugins on an existing plugin

I currently have an existing plugin, which references a class from a required plugin. I have replaced this code with a reference to a class which is part of my fragment.
I am facing two issues.
If I import my fragment as a jar file, I am not able to see the changes I have made as the plugin running as an eclipse application results in a ClassNotFoundException
To overcome this, I link an additional source (of fragment) to the existing plugin project. However, the link uses an absolute path, and makes it unfit for deployment.
I want to be able to package the plugin with the code modification and be able to "depend" on my fragment code. Is there a way I can add my fragment as a dependency?
For example:
Plugin Project I am changing : org.eclipse.*.editor
it depends on org.eclipse.*.edit
I have a fragment mydomain.*.edit which has org.eclipse.*.edit as host plugin
I want org.eclipse.*.editor to pick up mydomain.*.edit
instead of org.eclipse.*.edit
ps: I have also tried packaging the jar file for the mydomain.*.edit in the plugins directory and try and pick it up from there, it doesnt show up on the list when I click add required plugins on the dependency tab on the plugin.xml file of the org.eclipse.*.editor
Please let me know if I am not clear enough, I will try and rephrase it.
Thanks in advance!
If I understand correctly what you want to do, I don't think that it's possible. You will have to try some other way.
Plugins have dependencies on other plugins. Fragments don't exist as separate runtime entities, but only as extensions of a plugin. So your plugin can only refer to the 'editor' plugin.
Classes provided by a fragment can't (and shouldn't) be accessed directly. They can be returned by the original plugin (A) if they are implementing an executable extension provided by plugin A.
If you refer to the fragment's code from another plugin (B), the classes will be loaded by plugin B's classloader and be different from the ones that are loaded by plugin A.
What is the purpose of your fragment? Do you want to get access to internal code in plugin A? Do you want to extend an eclipse editor?
If you want to extend functionality that the original plugin is not exposing as extensible, I think the only way is to write a plugin, extend the editor class from the original plugin, register it alongside the original one and use it instead.
[Edit] Maybe this link will explain better: Eclipse FAQ
Hope this helps,
Vlad
Thanks Vlad,
Your explanation was very helpful. Unlike the extension based architecture that is truly intended for fragments, I had to modify a certain component in the editor that was not exposed as part of the extension. This modification referred to an external project I created as an fragment but could have been a normal java project packaged a jar file that I could place in the classpath of the editor.
I was able to resolve the dependency issues by placing the jar file in class path, however when I export the plugins and related plugins as jar files and place it in the dropin directory, it does not install correctly. (Nor does placing the jar files in the plugins directory)
The eclipse editor that I am trying to modify uses the EMF project. I have kept the EMF project in the workspace inorder to resolve dependencies of the editor. However when I replace the EMF jar files bundled with eclipse with the one in the workspace, the files that I want to edit are not correctly recognized.
Is there another way of doing this?