mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
"save to dictionary" quickfix in form files
This commit is contained in:
+8
-6
@@ -57,18 +57,20 @@ public class FormEditorErrorCollector extends FormErrorCollector {
|
||||
|
||||
public void addError(@NotNull final String inspectionId, final IComponent component, @Nullable IProperty prop,
|
||||
@NotNull String errorMessage,
|
||||
@Nullable EditorQuickFixProvider editorQuickFixProvider) {
|
||||
EditorQuickFixProvider... editorQuickFixProviders) {
|
||||
if (myResults == null) {
|
||||
myResults = new ArrayList<ErrorInfo>();
|
||||
}
|
||||
QuickFix[] quickFixes = QuickFix.EMPTY_ARRAY;
|
||||
if (editorQuickFixProvider != null) {
|
||||
quickFixes = new QuickFix[1];
|
||||
quickFixes [0] = editorQuickFixProvider.createQuickFix(myEditor, myComponent);
|
||||
List<QuickFix> quickFixes = new ArrayList<QuickFix>();
|
||||
for (EditorQuickFixProvider provider : editorQuickFixProviders) {
|
||||
if (provider != null) {
|
||||
quickFixes.add(provider.createQuickFix(myEditor, myComponent));
|
||||
}
|
||||
}
|
||||
|
||||
final ErrorInfo errorInfo = new ErrorInfo(myComponent, prop == null ? null : prop.getName(), errorMessage,
|
||||
myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile), quickFixes);
|
||||
myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile),
|
||||
quickFixes.toArray(new QuickFix[quickFixes.size()]));
|
||||
errorInfo.setInspectionId(inspectionId);
|
||||
myResults.add(errorInfo);
|
||||
}
|
||||
|
||||
@@ -26,5 +26,5 @@ import com.intellij.uiDesigner.lw.IComponent;
|
||||
public abstract class FormErrorCollector {
|
||||
public abstract void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
|
||||
@NotNull String errorMessage,
|
||||
@Nullable EditorQuickFixProvider editorQuickFixProvider);
|
||||
EditorQuickFixProvider... editorQuickFixProvider);
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class FormFileErrorCollector extends FormErrorCollector {
|
||||
|
||||
public void addError(final String inspectionId, final IComponent component, @Nullable IProperty prop,
|
||||
@NotNull String errorMessage,
|
||||
@Nullable EditorQuickFixProvider editorQuickFixProvider) {
|
||||
EditorQuickFixProvider... editorQuickFixProviders) {
|
||||
final ProblemDescriptor problemDescriptor = myManager.createProblemDescriptor(myFile, JDOMUtil.escapeText(errorMessage),
|
||||
(LocalQuickFix)null,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, myOnTheFly);
|
||||
|
||||
+17
-4
@@ -60,12 +60,11 @@ public class FormSpellCheckingInspection extends StringDescriptorInspection {
|
||||
PlainTextSplitter.getInstance().split(value, TextRange.allOf(value), new Consumer<TextRange>() {
|
||||
@Override
|
||||
public void consume(TextRange textRange) {
|
||||
String word = textRange.substring(value);
|
||||
final String word = textRange.substring(value);
|
||||
if (manager.hasProblem(word)) {
|
||||
final List<String> suggestions = manager.getSuggestions(value);
|
||||
EditorQuickFixProvider quickFixProvider = null;
|
||||
if (suggestions.size() > 0 && prop instanceof IntroStringProperty) {
|
||||
quickFixProvider = new EditorQuickFixProvider() {
|
||||
EditorQuickFixProvider changeToProvider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(final GuiEditor editor, final RadComponent component) {
|
||||
return new PopupQuickFix<String>(editor, "Change to...", component) {
|
||||
@@ -88,8 +87,22 @@ public class FormSpellCheckingInspection extends StringDescriptorInspection {
|
||||
};
|
||||
}
|
||||
};
|
||||
EditorQuickFixProvider acceptProvider = new EditorQuickFixProvider() {
|
||||
@Override
|
||||
public QuickFix createQuickFix(final GuiEditor editor, RadComponent component) {
|
||||
return new QuickFix(editor, "Save '" + word + "' to dictionary", component) {
|
||||
@Override
|
||||
public void run() {
|
||||
manager.acceptWordAsCorrect(word, editor.getProject());
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
collector.addError(getID(), component, prop, "Typo in word '" + word + "'", changeToProvider, acceptProvider);
|
||||
}
|
||||
else {
|
||||
collector.addError(getID(), component, prop, "Typo in word '" + word + "'");
|
||||
}
|
||||
collector.addError(getID(), component, prop, "Typo in word '" + word + "'", quickFixProvider);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user