AppCode inspection

Hi,

I'm trying to add my own inspection to AppCode, but as soon as my plugins is loaded, the inspection section (in preferences) stops responding (when I choose it, display is not refreshed and shows content of last selected section).
Please note it's not my first development for your tools, I have developed a bunch of custom actions, intentions and inspections for PhpStorm. Without any issue.

Here's my plugin.xml file:

<idea-plugin version="2">
  <name>Intentions</name>
  <description>A set of intentions</description>
  <version>1.0</version>
  <vendor>LP Corp.</vendor>
  <idea-version since-build="8000"/>

  <depends>com.intellij.modules.lang</depends>

  <application-components>
    <!-- Add your application components here -->
  </application-components>

  <project-components>
    <!-- Add your project components here -->
  </project-components>

  <actions>
    <!-- Add your actions here -->
  </actions>

    <extensions defaultExtensionNs="com.intellij">
        <localInspection
                implementationClass="fr.lpcorp.appcode.fmdatabase.ExecuteQueryInsteadOfExecuteUpdateInspection" displayName="displayName" groupKey="general"/>
    </extensions>
</idea-plugin>


This is how it is in its 2nd version. Note I don't know where to find parameters for the "localInspection" tag. As soon as I comment this tag and reinstall the plugin, everything works fine (but of course, no additional inspection).

The "register" intention generates the following line:

        <localInspection
                implementationClass="fr.lpcorp.appcode.fmdatabase.ExecuteQueryInsteadOfExecuteUpdateInspection"/>


And before using it, my intial line was (copied from plugin.xml of my PhpStorm plugin) :

    <extensions defaultExtensionNs="com.intellij">
      <inspectionToolProvider implementation="fr.lpcorp.appcode.fmdatabase.ExecuteQueryInsteadOfExecuteUpdateInspection"/>
    </extensions>


(Any of those 3 gives the same result).

Now, here's my Java code:

package fr.lpcorp.appcode.fmdatabase;

import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.objc.inspections.OCInspection;
import com.jetbrains.objc.psi.*;
import com.jetbrains.objc.psi.types.OCType;
import org.jetbrains.annotations.NotNull;

/**
* Created by IntelliJ IDEA.
* User: LPUser
* Date: 31/07/2012
* Time: 0:00
*/
public class ExecuteQueryInsteadOfExecuteUpdateInspection extends OCInspection {
    @NotNull
    @Override
    public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder problemsHolder, boolean isOnTheFly)
    {
        return new OCVisitor() {
        };
    }
}



Of course, it used to have a bit more code, but when seeing it would not work as expected, I removed as much code as possible.

There's nothing shown in the event log.
Also note I have already written a plugin for AppCode, which has been working fine from the beginning, but it's an action plugin.

Would you please tell me how I can get a basic useless inspection to register without breaking all inspections? :)

7 comments
Comment actions Permalink

Hi,

I see two possible problems:

1) make sure you understand rules for targeting correct product (AppCode) from http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
2) your inspection definition ("<localInspection ...") is not complete or refers to message keys without a bundle definition

You can find plenty of examples of inspection registration in any of the open-source components of IntelliJ IDEA (just search for plugin.xml files). If you have specific questions, please feel free to ask.

HTH,
Yann

0
Comment actions Permalink

Thanks, the issue is not compatibiliy.
Issue was... more :)
Now I wonder how comes my PHP inspections are working.

For those reading looking for the solution, here's what I had to do:

    <extensions defaultExtensionNs="com.intellij">
      <inspectionToolProvider implementation="fr.lpcorp.appcode.fmdatabase.LpInspectionToolProvider"/>
    </extensions>

(In plugin.xml)

And then add the class:

public class LpInspectionToolProvider implements InspectionToolProvider {
    public Class[] getInspectionClasses() {
        return new Class[] { ExecuteQueryInsteadOfExecuteUpdateInspection.class };
    }
}

And from the plugin.xml I removed all other declarations, including those autogenerated by IntelliJ.

Thanks for your time :)

I'll repeat myself, but I just love your product. I have lost several hours searching for bug, which appeared to be stupid copy/paste error. From now on, my new inspection warns me. Priceless.

0
Comment actions Permalink

Glad it works now ;-)

Note that <inspectionToolProvider> is just a different way of registering an inspection, it will work with <localInspection> as well (if configured properly)

0
Comment actions Permalink

I would be interested in how then :)
Thing is, now, with InspectionToolProvider, it works fine, while with LocalInspection, it'd "crash" AppCode inspections.So if you could tell me how, I'd be glad to know.
I'm also dumb, because in fact my PhpStorm plugin uses inspectionToolProvider!!

0
Comment actions Permalink

Jonathan,

do you have any exception in AppCode's log?
Which version of AppCode do you test your plugin with, 1.5 or 1.6 EAP?

0
Comment actions Permalink

No exception at all, nothing in event log.
Under version 1.5.7 (Build 117.764)

0
Comment actions Permalink

Jonathan,
I apologize for the late respond.

Have you managed to solve the problem with AppCode? Do you need any help?

0

Please sign in to leave a comment.