moved away from java-impl

This commit is contained in:
Alexey Kudravtsev
2014-05-29 13:22:54 +04:00
parent 41f2d2c1d3
commit 4bf725a53c
29 changed files with 228 additions and 186 deletions
@@ -16,10 +16,12 @@
package com.intellij.codeInsight.intention;
import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
import com.intellij.codeInspection.IntentionAndQuickFixAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -132,7 +134,8 @@ public abstract class QuickFixFactory {
@NotNull public abstract IntentionAction createRemoveParameterListFix(@NotNull PsiMethod parent);
@NotNull public abstract IntentionAction createShowModulePropertiesFix(@NotNull PsiElement element);
@NotNull public abstract IntentionAndQuickFixAction createShowModulePropertiesFix(@NotNull PsiElement element);
@NotNull public abstract IntentionAndQuickFixAction createShowModulePropertiesFix(@NotNull Module module);
@NotNull public abstract IntentionAction createIncreaseLanguageLevelFix(@NotNull LanguageLevel level);
@@ -0,0 +1,53 @@
/*
* Copyright 2000-2014 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.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
/**
* Implement this abstract class in order to provide new inspection tool functionality. The major API limitation here is
* subclasses should be stateless. Thus <code>check&lt;XXX&gt;</code> methods will be called in no particular order and
* instances of this class provided by {@link InspectionToolProvider#getInspectionClasses()} will be created on demand.
* The other important thing is problem anchors (PsiElements) reported by <code>check&lt;XXX&gt;</code> methods should
* lie under corresponding first parameter of one method.
*
* @see GlobalInspectionTool
*
* Please note that if your inspection/fixes/suppressions don't need UI components (e.g. Editor) to run, consider using
* {@link BaseJavaBatchLocalInspectionTool} instead.
*/
public abstract class BaseJavaLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements CustomSuppressableInspectionTool {
@Override
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
String shortName = getShortName();
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
throw new AssertionError("HighlightDisplayKey.find(" + shortName + ") is null. Inspection: "+getClass());
}
return SuppressManager.getInstance().createSuppressActions(key);
}
@Override
public boolean isSuppressedFor(@NotNull PsiElement element) {
return isSuppressedFor(element, this);
}
public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool);
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2000-2014 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.
*/
/*
* User: anna
* Date: 19-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.reference.RefManager;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool implements CustomSuppressableInspectionTool {
@Override
public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager,
@NotNull final GlobalInspectionContext globalContext,
@NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
return queryExternalUsagesRequests(globalContext.getRefManager(), globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT), problemDescriptionsProcessor);
}
protected boolean queryExternalUsagesRequests(@NotNull RefManager manager, @NotNull GlobalJavaInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor processor) {
return false;
}
@Override
@Nullable
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
}
@Override
public boolean isSuppressedFor(@NotNull final PsiElement element) {
return SuppressManager.getInstance().isSuppressedFor(element, getShortName());
}
}
@@ -0,0 +1,51 @@
/*
* Copyright 2000-2014 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.
*/
/*
* User: anna
* Date: 24-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiCodeBlock;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiLiteralExpression;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
public abstract class SuppressManager implements BatchSuppressManager {
public static SuppressManager getInstance() {
return ServiceManager.getService(SuppressManager.class);
}
public static boolean isSuppressedInspectionName(PsiLiteralExpression expression) {
PsiAnnotation annotation = PsiTreeUtil.getParentOfType(expression, PsiAnnotation.class, true, PsiCodeBlock.class, PsiField.class);
return annotation != null && SUPPRESS_INSPECTIONS_ANNOTATION_NAME.equals(annotation.getQualifiedName());
}
@NotNull
@Override
public SuppressQuickFix[] createBatchSuppressActions(@NotNull HighlightDisplayKey key) {
return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(key);
}
@NotNull
public abstract SuppressIntentionAction[] createSuppressActions(@NotNull HighlightDisplayKey key);
}