"SQL dialect is not configured" Inspection

Hello Community,

I want to create a similar code inspections like seen on this image.

That's my questions:

 

  • Can I copy the code from somewhere?
  • What class do I need to extend?
  • What's the registration for the plugin.xml?

I hope, that one of you could help me. Thanks in advance buddies! :)

 

Kind regards,

Fabian

2 comments
Comment actions Permalink



You need to implement com.intellij.codeInsight.daemon.ProjectSdkSetupValidator. You can add it to your plugin.xml via:
"<projectSdkSetupValidator implementation="io.github.intellij.dlanguage.DLangProjectDmdSetupValidator" />"

0
Comment actions Permalink

Hi 13nixonf,

Thanks for your help, but it didn't worked for me. I just found the solution, how to do such messages:

plugin.xml:

<localInspection language="MyLanguage" enabledByDefault="true" level="WARNING"
shortName="SomeInspection" displayName="Some Inspection" groupName="Inspection"
implementationClass="de.fgalinski.somePlugin.editor.inspection.SomeInspection"/>

SomeInspection.java:

package de.fgalinski.somePlugin.editor.inspection;

import com.intellij.codeInspection.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class SomeInspection extends LocalInspectionTool {
@NotNull
public String getShortName() {
return "Some Inspection";
}

@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
String message = "Some Message";
SomeInspection.MyQuickFix quickFix =
new SomeInspection.MyQuickFix();
LocalQuickFix[] quickFixes = new LocalQuickFix[]{quickFix};
return new ProblemDescriptor[]{
manager.createProblemDescriptor(
file, message, true, quickFixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING
)
};
}

public static class MyQuickFix extends IntentionAndQuickFixAction {
@NotNull
public String getName() {
return "Test";
}

@NotNull
public String getFamilyName() {
return getName();
}

public void applyFix(@NotNull Project project, PsiFile file, @Nullable Editor editor) {

}

public boolean startInWriteAction() {
return false;
}
}
}
1

Please sign in to leave a comment.