inspections as extension points

This commit is contained in:
Dmitry Avdeev
2011-10-03 10:34:59 +04:00
parent b5985d9411
commit 6c9da79ca3
7 changed files with 36 additions and 75 deletions
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection;
/**
* @author yole
*/
public class PlatformInspectionToolProvider implements InspectionToolProvider {
public Class[] getInspectionClasses() {
return new Class[] {
DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection.class,
DefaultHighlightVisitorBasedInspection.SyntaxErrorInspection.class,
LossyEncodingInspection.class,
};
}
}
@@ -635,7 +635,13 @@
<applicationService serviceInterface="com.intellij.ui.debugger.extensions.PlaybackDebugger$PlaybackDebuggerState"
serviceImplementation="com.intellij.ui.debugger.extensions.PlaybackDebugger$PlaybackDebuggerState"/>
<inspectionToolProvider implementation="com.intellij.codeInspection.PlatformInspectionToolProvider"/>
<globalInspection shortName="Annotator" displayName="Annotator" groupName="General" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection$AnnotatorBasedInspection"/>
<globalInspection shortName="SyntaxError" displayName="Syntax error" groupName="General" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection$SyntaxErrorInspection"/>
<localInspection shortName="LossyEncoding" bundle="messages.InspectionsBundle" key="lossy.encoding"
groupKey="group.names.internationalization.issues" enabledByDefault="false" level="WARNING"
implementationClass="com.intellij.codeInspection.LossyEncodingInspection"/>
<applicationService serviceInterface="com.intellij.codeInsight.template.TemplateBuilderFactory"
serviceImplementation="com.intellij.codeInsight.template.TemplateBuilderFactoryImpl"/>
@@ -0,0 +1,5 @@
<html>
<body>
This inspection finds various problems in plugin.xml
</body>
</html>
@@ -15,16 +15,11 @@
*/
package org.jetbrains.idea.devkit.inspections;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.highlighting.BasicDomElementsInspection;
import com.intellij.util.xml.highlighting.DomElementAnnotationHolder;
import com.intellij.util.xml.highlighting.DomHighlightingHelper;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.devkit.DevKitBundle;
import org.jetbrains.idea.devkit.dom.Extension;
import org.jetbrains.idea.devkit.dom.IdeaPlugin;
/**
@@ -52,25 +47,4 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
public String getShortName() {
return "PluginXmlValidity";
}
@Nullable
public String getStaticDescription() {
return "<html>\n" +
"<body>\n" +
"This inspection finds various problems in plugin.xml\n" +
"</body>\n" +
"</html>";
}
protected void checkDomElement(final DomElement element, final DomElementAnnotationHolder holder, final DomHighlightingHelper helper) {
super.checkDomElement(element, holder, helper);
if (element instanceof Extension) {
Extension extension = (Extension)element;
checkExtension(extension, holder, helper);
}
}
private void checkExtension(final Extension extension, final DomElementAnnotationHolder holder, final DomHighlightingHelper helper) {
}
}
@@ -15,29 +15,15 @@
*/
package org.intellij.lang.xpath;
import org.intellij.lang.xpath.validation.inspections.*;
import com.intellij.codeInspection.InspectionToolProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import org.jetbrains.annotations.NotNull;
public class XPathSupportLoader extends FileTypeFactory implements InspectionToolProvider {
public class XPathSupportLoader extends FileTypeFactory {
private static final boolean DBG_MODE = Boolean.getBoolean("xpath-lang.register-file-type");
public Class<? extends XPathInspection>[] getInspectionClasses() {
//noinspection unchecked
return new Class[]{
CheckNodeTest.class,
ImplicitTypeConversion.class,
RedundantTypeConversion.class,
IndexZeroPredicate.class,
HardwiredNamespacePrefix.class,
};
}
public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
if (DBG_MODE || ApplicationManager.getApplication().isUnitTestMode()) {
consumer.consume(XPathFileType.XPATH, XPathFileType.XPATH.getDefaultExtension());
consumer.consume(XPathFileType.XPATH2, XPathFileType.XPATH2.getDefaultExtension());
@@ -16,12 +16,21 @@
package org.intellij.lang.xpath;
import com.intellij.util.ArrayUtil;
import org.intellij.lang.xpath.validation.inspections.*;
public class XPathHighlightingTest extends TestBase {
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new XPathSupportLoader().getInspectionClasses());
new XPathSupportLoader();
//noinspection unchecked
myFixture.enableInspections(new Class[]{
CheckNodeTest.class,
ImplicitTypeConversion.class,
RedundantTypeConversion.class,
IndexZeroPredicate.class,
HardwiredNamespacePrefix.class,
});
}
public void testPathTypeMismatch() throws Throwable {
@@ -82,7 +82,18 @@
<codeInsight.parameterInfo language="XPath" implementationClass="org.intellij.lang.xpath.XPathParameterInfoHandler" />
<fileTypeFactory implementation="org.intellij.lang.xpath.XPathSupportLoader" />
<inspectionToolProvider implementation="org.intellij.lang.xpath.XPathSupportLoader"/>
<localInspection shortName="CheckNodeTest" displayName="Check Node Test" groupName="XPath" enabledByDefault="true" level="WARNING"
implementationClass="org.intellij.lang.xpath.validation.inspections.CheckNodeTest"/>
<localInspection shortName="ImplicitTypeConversion" displayName="Implicit Type Conversion" groupName="XPath" enabledByDefault="true"
level="WARNING" implementationClass="org.intellij.lang.xpath.validation.inspections.ImplicitTypeConversion"/>
<localInspection shortName="RedundantTypeConversion" displayName="Redundant Type Conversion" groupName="XPath" enabledByDefault="true"
level="WARNING" implementationClass="org.intellij.lang.xpath.validation.inspections.RedundantTypeConversion"/>
<localInspection shortName="IndexZeroUsage" displayName="Use of index 0 in XPath predicates" groupName="XPath" enabledByDefault="true"
level="WARNING" implementationClass="org.intellij.lang.xpath.validation.inspections.IndexZeroPredicate"/>
<localInspection shortName="HardwiredNamespacePrefix" displayName="Hardwired Namespace Prefix" groupName="XPath" enabledByDefault="true"
level="WARNING" implementationClass="org.intellij.lang.xpath.validation.inspections.HardwiredNamespacePrefix"/>
<quoteHandler fileType="XPath" className="org.intellij.lang.xpath.XPathQuoteHandler" />
<quoteHandler fileType="XPath2" className="org.intellij.lang.xpath.XPathQuoteHandler" />
<completion.contributor language="XPath" implementationClass="org.intellij.lang.xpath.completion.XPathCompletionContributor" />