inspections as extension points

This commit is contained in:
Dmitry Avdeev
2011-09-30 16:47:50 +04:00
parent cb537db17e
commit cb4340a43f
11 changed files with 46 additions and 101 deletions
@@ -22,6 +22,7 @@ import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.pattern.PatternValidator;
import org.intellij.plugins.intelliLang.util.PsiUtilEx;
import org.intellij.plugins.intelliLang.util.RemoveAnnotationFix;
import org.jetbrains.annotations.NonNls;
@@ -40,7 +41,7 @@ public class InjectionNotApplicable extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.LANGUAGE_INJECTION;
return PatternValidator.LANGUAGE_INJECTION;
}
@NotNull
@@ -1,28 +0,0 @@
/*
* Copyright 2006 Sascha Weinreuter
*
* 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 org.intellij.plugins.intelliLang.inject.java.validation;
import com.intellij.codeInspection.InspectionToolProvider;
public class InspectionProvider implements InspectionToolProvider {
public static final String LANGUAGE_INJECTION = "Language Injection";
public Class[] getInspectionClasses() {
return new Class[]{UnknownLanguageID.class, LanguageMismatch.class, InjectionNotApplicable.class};
}
}
@@ -15,13 +15,13 @@
*/
package org.intellij.plugins.intelliLang.inject.java.validation;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.pattern.PatternValidator;
import org.intellij.plugins.intelliLang.util.AnnotateFix;
import org.intellij.plugins.intelliLang.util.AnnotationUtilEx;
import org.intellij.plugins.intelliLang.util.PsiUtilEx;
@@ -45,7 +45,7 @@ public class LanguageMismatch extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.LANGUAGE_INJECTION;
return PatternValidator.LANGUAGE_INJECTION;
}
@NotNull
@@ -24,6 +24,7 @@ import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
import org.intellij.plugins.intelliLang.pattern.PatternValidator;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -40,7 +41,7 @@ public class UnknownLanguageID extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.LANGUAGE_INJECTION;
return PatternValidator.LANGUAGE_INJECTION;
}
@NotNull
@@ -1,26 +0,0 @@
/*
* Copyright 2006 Sascha Weinreuter
*
* 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 org.intellij.plugins.intelliLang.pattern;
import com.intellij.codeInspection.InspectionToolProvider;
public class InspectionProvider implements InspectionToolProvider {
public static final String PATTERN_VALIDATION = "Pattern Validation";
public Class[] getInspectionClasses() {
return new Class[]{PatternValidator.class, PatternAnnotationNotApplicable.class, PatternOverriddenByNonAnnotatedMethod.class};
}
}
@@ -40,7 +40,7 @@ public class PatternAnnotationNotApplicable extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.PATTERN_VALIDATION;
return PatternValidator.PATTERN_VALIDATION;
}
@NotNull
@@ -36,7 +36,7 @@ public class PatternOverriddenByNonAnnotatedMethod extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.PATTERN_VALIDATION;
return PatternValidator.PATTERN_VALIDATION;
}
@NotNull
@@ -58,6 +58,8 @@ import java.util.regex.PatternSyntaxException;
*/
public class PatternValidator extends LocalInspectionTool {
private static final Key<CachedValue<Pattern>> COMPLIED_PATTERN = Key.create("COMPILED_PATTERN");
public static final String PATTERN_VALIDATION = "Pattern Validation";
public static final String LANGUAGE_INJECTION = "Language Injection";
public boolean CHECK_NON_CONSTANT_VALUES = true;
@@ -73,7 +75,7 @@ public class PatternValidator extends LocalInspectionTool {
@NotNull
public String getGroupDisplayName() {
return InspectionProvider.PATTERN_VALIDATION;
return PATTERN_VALIDATION;
}
@NotNull
@@ -5,9 +5,23 @@
<extensions defaultExtensionNs="com.intellij">
<compiler implementation="org.intellij.plugins.intelliLang.pattern.compiler.impl.PatternValidationCompiler"/>
<inspectionToolProvider implementation="org.intellij.plugins.intelliLang.inject.java.validation.InspectionProvider"/>
<inspectionToolProvider implementation="org.intellij.plugins.intelliLang.pattern.InspectionProvider"/>
<localInspection shortName="UnknownLanguage" displayName="Unknown Language ID" groupName="Language Injection" enabledByDefault="true"
level="ERROR" implementationClass="org.intellij.plugins.intelliLang.inject.java.validation.UnknownLanguageID"/>
<localInspection shortName="LanguageMismatch" displayName="Language Mismatch" groupName="Language Injection" enabledByDefault="true"
level="WARNING" implementationClass="org.intellij.plugins.intelliLang.inject.java.validation.LanguageMismatch"/>
<localInspection shortName="InjectionNotApplicable" displayName="Injection Annotation not applicable" groupName="Language Injection"
enabledByDefault="true" level="ERROR"
implementationClass="org.intellij.plugins.intelliLang.inject.java.validation.InjectionNotApplicable"/>
<localInspection shortName="PatternValidation" displayName="Validate Annotated Patterns" groupName="Pattern Validation"
enabledByDefault="true" level="WARNING"
implementationClass="org.intellij.plugins.intelliLang.pattern.PatternValidator"/>
<localInspection shortName="PatternNotApplicable" displayName="Pattern Annotation not applicable" groupName="Pattern Validation"
enabledByDefault="true" level="ERROR"
implementationClass="org.intellij.plugins.intelliLang.pattern.PatternAnnotationNotApplicable"/>
<localInspection shortName="PatternOverriddenByNonAnnotatedMethod" displayName="Non-annotated Method overrides @Pattern Method"
groupName="Pattern Validation" enabledByDefault="true" level="WARNING"
implementationClass="org.intellij.plugins.intelliLang.pattern.PatternOverriddenByNonAnnotatedMethod"/>
<concatenationAwareInjector implementation="org.intellij.plugins.intelliLang.inject.java.ConcatenationInjector"/>
+19 -1
View File
@@ -20,7 +20,6 @@
<extensions defaultExtensionNs="com.intellij">
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
<inspectionToolProvider implementation="com.intellij.codeInspection.JavaInspectionToolProvider"/>
<referenceProviderType key="Properties File Key Provider"
implementationClass="com.intellij.lang.properties.PropertiesReferenceProvider"/>
<psi.referenceContributor implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaReferenceContributor"/>
@@ -28,6 +27,25 @@
<lang.foldingBuilder language="JAVA" implementationClass="com.intellij.codeInspection.i18n.folding.PropertyFoldingBuilder" />
<gotoDeclarationHandler implementation="com.intellij.codeInspection.i18n.folding.I18nMessageGotoDeclarationHandler" order="FIRST"/>
<spellchecker.support implementation="com.intellij.spellchecker.JavaSpellcheckingStrategy"/>
<localInspection shortName="HardCodedStringLiteral" bundle="messages.CodeInsightBundle" key="inspection.i18n.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.javadoc.issues" enabledByDefault="false" level="WARNING"
implementationClass="com.intellij.codeInspection.i18n.I18nInspection"/>
<localInspection shortName="UnresolvedPropertyKey" bundle="messages.CodeInsightBundle"
key="inspection.unresolved.property.key.reference.name" groupName="Internationalization issues" enabledByDefault="true"
level="ERROR" implementationClass="com.intellij.codeInspection.i18n.InvalidPropertyKeyInspection"/>
<globalInspection shortName="InconsistentResourceBundle" bundle="messages.InspectionsBundle"
key="inconsistent.resource.bundle.display.name" groupBundle="messages.PropertiesBundle"
groupKey="properties.files.inspection.group.display.name" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.i18n.InconsistentResourceBundleInspection"/>
<localInspection shortName="UnusedMessageFormatParameter" bundle="messages.PropertiesBundle"
key="unused.message.format.parameter.display.name" groupKey="properties.files.inspection.group.display.name"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.lang.properties.UnusedMessageFormatParameterInspection"/>
<localInspection shortName="DuplicateStringLiteralInspection" bundle="messages.InspectionsBundle"
key="inspection.duplicates.display.name" groupName="Internationalization issues" enabledByDefault="false"
level="WARNING"
implementationClass="com.intellij.codeInspection.duplicateStringLiteral.DuplicateStringLiteralInspection"/>
</extensions>
<actions>
<action id="I18nize" class="com.intellij.codeInspection.i18n.I18nizeAction">
@@ -1,37 +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;
import com.intellij.codeInspection.duplicateStringLiteral.DuplicateStringLiteralInspection;
import com.intellij.codeInspection.i18n.I18nInspection;
import com.intellij.codeInspection.i18n.InconsistentResourceBundleInspection;
import com.intellij.codeInspection.i18n.InvalidPropertyKeyInspection;
import com.intellij.lang.properties.UnusedMessageFormatParameterInspection;
/**
* @author Maxim.Mossienko
*/
public class JavaInspectionToolProvider implements InspectionToolProvider {
public Class[] getInspectionClasses() {
return new Class[] {
I18nInspection.class,
InvalidPropertyKeyInspection.class,
InconsistentResourceBundleInspection.class,
UnusedMessageFormatParameterInspection.class,
DuplicateStringLiteralInspection.class
};
}
}