本文整理汇总了Java中com.intellij.codeInspection.QuickFix类的典型用法代码示例。如果您正苦于以下问题:Java QuickFix类的具体用法?Java QuickFix怎么用?Java QuickFix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QuickFix类属于com.intellij.codeInspection包,在下文中一共展示了QuickFix类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasQuickFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
public boolean hasQuickFixes(InspectionTree tree) {
final TreePath[] treePaths = tree.getSelectionPaths();
if (treePaths == null) return false;
for (TreePath selectionPath : treePaths) {
if (!TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
@Override
public boolean accept(final Object node) {
if (!((InspectionTreeNode)node).isValid()) return true;
if (node instanceof ProblemDescriptionNode) {
final CommonProblemDescriptor descriptor = ((ProblemDescriptionNode)node).getDescriptor();
final QuickFix[] fixes = descriptor != null ? descriptor.getFixes() : null;
return fixes == null || fixes.length == 0;
}
return true;
}
})) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:InspectionRVContentProvider.java
示例2: run
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
protected void run() {
InspectionManager inspectionManager = InspectionManager.getInstance(project);
GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
InspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspectionTool);
List<ProblemDescriptor> problemDescriptors;
try {
problemDescriptors = InspectionEngine.runInspectionOnFile(psiFile, toolWrapper, context);
} catch (IndexNotReadyException exception) {
return;
}
for (ProblemDescriptor problemDescriptor : problemDescriptors) {
QuickFix[] fixes = problemDescriptor.getFixes();
if (fixes != null) {
writeQuickFixes(problemDescriptor, fixes);
}
}
}
开发者ID:dubreuia,项目名称:intellij-plugin-save-actions,代码行数:19,代码来源:InspectionProcessor.java
示例3: applyFix
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
protected final void applyFix(Project project, CommonProblemDescriptor descriptor) {
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null && fixes.length > 0) {
for (final QuickFix fix : fixes) {
if (fix != null && (myQuickfixClass == null || fix.getClass().isAssignableFrom(myQuickfixClass))) {
final ProblemDescriptor problemDescriptor = (ProblemDescriptor)descriptor;
final PsiElement element = problemDescriptor.getPsiElement();
if (element != null && element.isValid()) {
collectFix(fix, problemDescriptor, project);
myApplicableFixFound = true;
}
break;
}
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:AbstractPerformFixesTask.java
示例4: fixReferenceProblems
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void fixReferenceProblems(@NotNull ProblemDescriptor[] problems, @NotNull Project project) {
for (ProblemDescriptor problem : problems) {
QuickFix[] fixes = problem.getFixes();
if (fixes != null) {
fixes[0].applyFix(project, problem);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaDocCommentFixer.java
示例5: wrap
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@NotNull
public static IntentionAction wrap(@NotNull ProblemDescriptor descriptor, int fixNumber) {
LOG.assertTrue(fixNumber >= 0, fixNumber);
QuickFix[] fixes = descriptor.getFixes();
LOG.assertTrue(fixes != null && fixes.length > fixNumber);
final QuickFix fix = fixes[fixNumber];
return fix instanceof IntentionAction ? (IntentionAction)fix : new QuickFixWrapper(descriptor, fixNumber);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:QuickFixWrapper.java
示例6: writeQuickFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
private void writeQuickFixes(ProblemDescriptor problemDescriptor, QuickFix[] fixes) {
for (QuickFix fix : fixes) {
if (fix != null) {
try {
fix.applyFix(project, problemDescriptor);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
}
}
开发者ID:dubreuia,项目名称:intellij-plugin-save-actions,代码行数:12,代码来源:InspectionProcessor.java
示例7: wrap
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Nonnull
public static IntentionAction wrap(@Nonnull ProblemDescriptor descriptor, int fixNumber) {
LOG.assertTrue(fixNumber >= 0, fixNumber);
QuickFix[] fixes = descriptor.getFixes();
LOG.assertTrue(fixes != null && fixes.length > fixNumber);
final QuickFix fix = fixes[fixNumber];
return fix instanceof IntentionAction ? (IntentionAction)fix : new QuickFixWrapper(descriptor, fixNumber);
}
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:QuickFixWrapper.java
示例8: fixReferenceProblems
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static void fixReferenceProblems(@NotNull ProblemDescriptor[] problems, @NotNull Project project)
{
for(ProblemDescriptor problem : problems)
{
QuickFix[] fixes = problem.getFixes();
if(fixes != null)
{
fixes[0].applyFix(project, problem);
}
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:JavaDocCommentFixer.java
示例9: getQuickFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
@Nullable
public QuickFixAction[] getQuickFixes(@NotNull final InspectionToolWrapper toolWrapper, @NotNull final InspectionTree tree) {
final TreePath[] treePaths = tree.getSelectionPaths();
if (treePaths == null) return QuickFixAction.EMPTY;
final List<RefEntity> selectedElements = new ArrayList<RefEntity>();
final Map<RefEntity, Set<QuickFix>> actions = new HashMap<RefEntity, Set<QuickFix>>();
for (TreePath selectionPath : treePaths) {
TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
@Override
public boolean accept(final Object node) {
if (!((InspectionTreeNode)node).isValid()) return true;
if (node instanceof OfflineProblemDescriptorNode) {
final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node;
final RefEntity element = descriptorNode.getElement();
selectedElements.add(element);
Set<QuickFix> quickFixes = actions.get(element);
if (quickFixes == null) {
quickFixes = new HashSet<QuickFix>();
actions.put(element, quickFixes);
}
final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor();
if (descriptor != null) {
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null) {
ContainerUtil.addAll(quickFixes, fixes);
}
}
}
else if (node instanceof RefElementNode) {
selectedElements.add(((RefElementNode)node).getElement());
}
return true;
}
});
}
if (selectedElements.isEmpty()) return null;
final RefEntity[] selectedRefElements = selectedElements.toArray(new RefEntity[selectedElements.size()]);
GlobalInspectionContextImpl context = tree.getContext();
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
return presentation.extractActiveFixes(selectedRefElements, actions);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:OfflineInspectionRVContentProvider.java
示例10: extractActiveFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Nullable
QuickFixAction[] extractActiveFixes(@NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions);
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:3,代码来源:InspectionToolPresentation.java
示例11: getQuickFix
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
public QuickFix getQuickFix(final String hint) {
return new InvertBooleanFix(InspectionGadgetsBundle.message("invert.method.quickfix"));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:BooleanMethodIsAlwaysInvertedInspection.java
示例12: getQuickFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
@Nullable
public QuickFixAction[] getQuickFixes(@NotNull final InspectionToolWrapper toolWrapper, @NotNull final InspectionTree tree) {
final TreePath[] treePaths = tree.getSelectionPaths();
final List<RefEntity> selectedElements = new ArrayList<RefEntity>();
final Map<RefEntity, Set<QuickFix>> actions = new HashMap<RefEntity, Set<QuickFix>>();
for (TreePath selectionPath : treePaths) {
TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
@Override
public boolean accept(final Object node) {
if (!((InspectionTreeNode)node).isValid()) return true;
if (node instanceof OfflineProblemDescriptorNode) {
final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node;
final RefEntity element = descriptorNode.getElement();
selectedElements.add(element);
Set<QuickFix> quickFixes = actions.get(element);
if (quickFixes == null) {
quickFixes = new HashSet<QuickFix>();
actions.put(element, quickFixes);
}
final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor();
if (descriptor != null) {
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null) {
ContainerUtil.addAll(quickFixes, fixes);
}
}
}
else if (node instanceof RefElementNode) {
selectedElements.add(((RefElementNode)node).getElement());
}
return true;
}
});
}
if (selectedElements.isEmpty()) return null;
final RefEntity[] selectedRefElements = selectedElements.toArray(new RefEntity[selectedElements.size()]);
GlobalInspectionContextImpl context = tree.getContext();
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
return presentation.extractActiveFixes(selectedRefElements, actions);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:OfflineInspectionRVContentProvider.java
示例13: iteration
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
public boolean iteration(ProgressIndicator indicator) {
final Pair<CommonProblemDescriptor, Boolean> pair = nextDescriptor();
CommonProblemDescriptor descriptor = pair.getFirst();
boolean shouldDoPostponedOperations = pair.getSecond();
if (indicator != null) {
indicator.setFraction((double)myProcessed++ / myLength);
String presentableText = "usages";
if (descriptor instanceof ProblemDescriptor) {
final PsiElement psiElement = ((ProblemDescriptor)descriptor).getPsiElement();
if (psiElement != null) {
presentableText = SymbolPresentationUtil.getSymbolPresentableText(psiElement);
}
}
indicator.setText("Processing " + presentableText);
}
final boolean[] runInReadAction = {false};
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null) {
for (QuickFix fix : fixes) {
if (!fix.startInWriteAction()) {
runInReadAction[0] = true;
} else {
runInReadAction[0] = false;
break;
}
}
}
ApplicationManager.getApplication().runWriteAction(() -> {
myDocumentManager.commitAllDocuments();
if (!runInReadAction[0]) {
applyFix(myProject, descriptor);
if (shouldDoPostponedOperations) {
myReformattingAspect.doPostponedFormatting();
}
}
});
if (runInReadAction[0]) {
applyFix(myProject, descriptor);
}
return isDone();
}
开发者ID:consulo,项目名称:consulo,代码行数:45,代码来源:PerformFixesModalTask.java
示例14: getQuickFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Override
@Nullable
public QuickFixAction[] getQuickFixes(@Nonnull final InspectionToolWrapper toolWrapper, @Nonnull final InspectionTree tree) {
final TreePath[] treePaths = tree.getSelectionPaths();
final List<RefEntity> selectedElements = new ArrayList<RefEntity>();
final Map<RefEntity, Set<QuickFix>> actions = new HashMap<RefEntity, Set<QuickFix>>();
for (TreePath selectionPath : treePaths) {
TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
@Override
public boolean accept(final Object node) {
if (!((InspectionTreeNode)node).isValid()) return true;
if (node instanceof OfflineProblemDescriptorNode) {
final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node;
final RefEntity element = descriptorNode.getElement();
selectedElements.add(element);
Set<QuickFix> quickFixes = actions.get(element);
if (quickFixes == null) {
quickFixes = new HashSet<QuickFix>();
actions.put(element, quickFixes);
}
final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor();
if (descriptor != null) {
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null) {
ContainerUtil.addAll(quickFixes, fixes);
}
}
}
else if (node instanceof RefElementNode) {
selectedElements.add(((RefElementNode)node).getElement());
}
return true;
}
});
}
if (selectedElements.isEmpty()) return null;
final RefEntity[] selectedRefElements = selectedElements.toArray(new RefEntity[selectedElements.size()]);
GlobalInspectionContextImpl context = tree.getContext();
InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
return presentation.extractActiveFixes(selectedRefElements, actions);
}
开发者ID:consulo,项目名称:consulo,代码行数:45,代码来源:OfflineInspectionRVContentProvider.java
示例15: extractActiveFixes
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
@Nullable
QuickFixAction[] extractActiveFixes(@Nonnull RefEntity[] refElements, @Nonnull Map<RefEntity, Set<QuickFix>> actions);
开发者ID:consulo,项目名称:consulo,代码行数:3,代码来源:InspectionToolPresentation.java
示例16: ignoreProblem
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
void ignoreProblem(@NotNull CommonProblemDescriptor descriptor, @NotNull QuickFix fix);
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:InspectionToolPresentation.java
示例17: collectFix
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
protected abstract void collectFix(QuickFix fix, ProblemDescriptor descriptor, Project project);
开发者ID:consulo,项目名称:consulo,代码行数:2,代码来源:AbstractPerformFixesTask.java
示例18: ignoreProblem
import com.intellij.codeInspection.QuickFix; //导入依赖的package包/类
void ignoreProblem(@Nonnull CommonProblemDescriptor descriptor, @Nonnull QuickFix fix);
开发者ID:consulo,项目名称:consulo,代码行数:2,代码来源:InspectionToolPresentation.java
注:本文中的com.intellij.codeInspection.QuickFix类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论