mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Inspections
This commit is contained in:
+1
-1
@@ -518,7 +518,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
@Override
|
||||
public void loadInspections(ProgressIndicator progress) {
|
||||
if (myRootComponent != null) {
|
||||
ErrorAnalyzer.load(myXmlFile, myRootComponent, progress);
|
||||
ErrorAnalyzer.load(getProject(), myXmlFile, myRootComponent, progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
-29
@@ -22,12 +22,16 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.SuppressIntentionAction;
|
||||
import com.intellij.codeInspection.ex.DisableInspectionToolAction;
|
||||
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
|
||||
import com.intellij.designer.inspection.AbstractQuickFixManager;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.inspection.QuickFix;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadComponentVisitor;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -42,7 +46,7 @@ import java.util.List;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class ErrorAnalyzer {
|
||||
public static void load(XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) {
|
||||
public static void load(final Project project, final XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) {
|
||||
ErrorInfo.clear(rootComponent);
|
||||
|
||||
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
|
||||
@@ -69,8 +73,8 @@ public final class ErrorAnalyzer {
|
||||
HighlightDisplayKey key = HighlightDisplayKey.find(inspection.getShortName());
|
||||
|
||||
if (key != null) {
|
||||
PsiElement startElement = xmlFile.findElementAt(range.getStartOffset());
|
||||
PsiElement endElement = xmlFile.findElementAt(range.getEndOffset() - 1);
|
||||
final PsiElement startElement = xmlFile.findElementAt(range.getStartOffset());
|
||||
final PsiElement endElement = xmlFile.findElementAt(range.getEndOffset() - 1);
|
||||
|
||||
if (startElement != null && endElement != null && !inspection.isSuppressedFor(startElement)) {
|
||||
Pair<RadComponent, String> componentInfo = findComponent(rootComponent, startElement);
|
||||
@@ -79,52 +83,51 @@ public final class ErrorAnalyzer {
|
||||
|
||||
List<QuickFix> designerFixes = errorInfo.getQuickFixes();
|
||||
|
||||
for (AndroidLintQuickFix fix : inspection.public_getQuickFixes(message)) {
|
||||
for (final AndroidLintQuickFix fix : inspection.public_getQuickFixes(message)) {
|
||||
if (fix.isApplicable(startElement, endElement, false)) {
|
||||
designerFixes.add(new QuickFix(fix.getName(), null) {
|
||||
designerFixes.add(new QuickFix(fix.getName(), AbstractQuickFixManager.ICON) {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
System.out.println("00000000");
|
||||
// TODO: Auto-generated method stub
|
||||
public void run() {
|
||||
fix.apply(startElement, endElement, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (IntentionAction intention : inspection.getIntentions(startElement, endElement)) {
|
||||
designerFixes.add(new QuickFix(intention.getText(), null) {
|
||||
for (final IntentionAction intention : inspection.getIntentions(startElement, endElement)) {
|
||||
designerFixes.add(new QuickFix(intention.getText(), AbstractQuickFixManager.ICON) {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
System.out.println("1111111");
|
||||
// TODO: Auto-generated method stub
|
||||
public void run() {
|
||||
intention.invoke(project, null, xmlFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
designerFixes.add(new QuickFix("Disable inspection", null) {
|
||||
final DisableInspectionToolAction disableAction = new DisableInspectionToolAction(key);
|
||||
designerFixes.add(new QuickFix("Disable inspection", disableAction.getIcon(0)) {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
System.out.println("22222");
|
||||
// TODO: Auto-generated method stub
|
||||
}
|
||||
});
|
||||
designerFixes.add(new QuickFix("Edit '" + inspection.getDisplayName() + "' inspection settings", null) {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
System.out.println("3333333");
|
||||
// TODO: Auto-generated method stub
|
||||
public void run() {
|
||||
disableAction.invoke(project, null, xmlFile);
|
||||
}
|
||||
});
|
||||
|
||||
final EditInspectionToolsSettingsAction editSettingsAction = new EditInspectionToolsSettingsAction(key);
|
||||
designerFixes
|
||||
.add(new QuickFix("Edit '" + inspection.getDisplayName() + "' inspection settings", editSettingsAction.getIcon(0)) {
|
||||
@Override
|
||||
public void run() {
|
||||
editSettingsAction.invoke(project, null, xmlFile);
|
||||
}
|
||||
});
|
||||
|
||||
SuppressIntentionAction[] suppressActions = inspection.getSuppressActions(startElement);
|
||||
if (suppressActions != null) {
|
||||
for (SuppressIntentionAction action : suppressActions) {
|
||||
for (final SuppressIntentionAction action : suppressActions) {
|
||||
if (action.isAvailable(xmlFile.getProject(), null, startElement)) {
|
||||
designerFixes.add(new QuickFix("Suppress: " + action.getText(), action.getIcon(0)) {
|
||||
designerFixes.add(new QuickFix(action.getText(), action.getIcon(0)) {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
System.out.println("4444444");
|
||||
// TODO: Auto-generated method stub
|
||||
public void run() {
|
||||
action.invoke(project, null, startElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-2
@@ -18,6 +18,7 @@ package com.intellij.designer.inspection;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
@@ -270,6 +271,11 @@ public abstract class AbstractQuickFixManager {
|
||||
public boolean hasSubstep(ErrorInfo selectedValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoSelectionEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class SecondStep extends BaseListPopupStep<QuickFix> {
|
||||
@@ -301,7 +307,7 @@ public abstract class AbstractQuickFixManager {
|
||||
myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
value.run();
|
||||
ApplicationManager.getApplication().runWriteAction(value);
|
||||
}
|
||||
}, "Run '" + value.getName() + "' QuickFix", true);
|
||||
}
|
||||
@@ -316,7 +322,7 @@ public abstract class AbstractQuickFixManager {
|
||||
private static final Icon INTENTION_ICON = IconLoader.getIcon("/actions/realIntentionBulb.png");
|
||||
private static final Icon ARROW_ICON = IconLoader.getIcon("/general/arrowDown.png");
|
||||
private static final Icon INACTIVE_ARROW_ICON = new EmptyIcon(ARROW_ICON.getIconWidth(), ARROW_ICON.getIconHeight());
|
||||
private static final Icon ICON = IconLoader.findIcon("/actions/intentionBulb.png");
|
||||
public static final Icon ICON = IconLoader.findIcon("/actions/intentionBulb.png");
|
||||
|
||||
private class InspectionHint extends JLabel {
|
||||
private final RowIcon myInactiveIcon;
|
||||
|
||||
+1
-3
@@ -20,7 +20,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class QuickFix {
|
||||
public abstract class QuickFix implements Runnable {
|
||||
private final String myName;
|
||||
private final Icon myIcon;
|
||||
|
||||
@@ -36,6 +36,4 @@ public abstract class QuickFix {
|
||||
public final Icon getIcon() {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public abstract void run() throws Exception;
|
||||
}
|
||||
+16
-12
@@ -215,6 +215,10 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
}
|
||||
|
||||
Property property = myProperties.get(row);
|
||||
if (property.getParent() != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ErrorInfo errorInfo : ErrorInfo.get(myComponents.get(0))) {
|
||||
if (property.getName().equals(errorInfo.getPropertyName())) {
|
||||
return errorInfo;
|
||||
@@ -223,6 +227,18 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent event) {
|
||||
int row = rowAtPoint(event.getPoint());
|
||||
if (row != -1) {
|
||||
ErrorInfo errorInfo = getErrorInfoForRow(row);
|
||||
if (errorInfo != null) {
|
||||
return errorInfo.getName();
|
||||
}
|
||||
}
|
||||
return super.getToolTipText(event);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -648,18 +664,6 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
Messages.getErrorIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent event) {
|
||||
int row = rowAtPoint(event.getPoint());
|
||||
if (row != -1) {
|
||||
ErrorInfo errorInfo = getErrorInfoForRow(row);
|
||||
if (errorInfo != null) {
|
||||
return errorInfo.getName();
|
||||
}
|
||||
}
|
||||
return super.getToolTipText(event);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user