diff --git a/plugins/ui-designer/src/META-INF/plugin.xml b/plugins/ui-designer/src/META-INF/plugin.xml index 5df2bba5ee13..86bec25ab0f4 100644 --- a/plugins/ui-designer/src/META-INF/plugin.xml +++ b/plugins/ui-designer/src/META-INF/plugin.xml @@ -8,7 +8,7 @@ + interface="com.intellij.uiDesigner.inspections.FormInspectionTool"/> @@ -21,6 +21,7 @@ + diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java index 15fb3fc0f582..1a1987c1c942 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/ErrorAnalyzer.java @@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.uiDesigner.designSurface.GuiEditor; +import com.intellij.uiDesigner.inspections.FormInspectionTool; import com.intellij.uiDesigner.lw.IButtonGroup; import com.intellij.uiDesigner.lw.IComponent; import com.intellij.uiDesigner.lw.IContainer; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java index 0161916f07f2..f984d7de76d0 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/BaseFormInspection.java @@ -33,7 +33,6 @@ import com.intellij.uiDesigner.designSurface.GuiEditor; import com.intellij.uiDesigner.lw.IComponent; import com.intellij.uiDesigner.lw.IRootContainer; import com.intellij.uiDesigner.lw.LwRootContainer; -import com.intellij.uiDesigner.quickFixes.FormInspectionTool; import com.intellij.uiDesigner.radComponents.RadComponent; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/FormInspectionTool.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormInspectionTool.java similarity index 97% rename from plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/FormInspectionTool.java rename to plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormInspectionTool.java index c0ce4ff7369a..6d567fba7a66 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/FormInspectionTool.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormInspectionTool.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.uiDesigner.quickFixes; +package com.intellij.uiDesigner.inspections; import com.intellij.psi.PsiElement; import com.intellij.uiDesigner.ErrorInfo; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java new file mode 100644 index 000000000000..f7d0607891ae --- /dev/null +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/inspections/FormSpellCheckingInspection.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2011 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.uiDesigner.inspections; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.util.TextRange; +import com.intellij.spellchecker.SpellCheckerManager; +import com.intellij.spellchecker.inspections.SplitterFactory; +import com.intellij.uiDesigner.lw.IComponent; +import com.intellij.uiDesigner.lw.IProperty; +import com.intellij.uiDesigner.lw.StringDescriptor; +import com.intellij.util.Consumer; + +/** + * @author yole + */ +public class FormSpellCheckingInspection extends StringDescriptorInspection { + public static final String SHORT_NAME = "SpellCheckingInspection"; + + public FormSpellCheckingInspection() { + super(SHORT_NAME); + } + + @Override + protected void checkStringDescriptor(Module module, + final IComponent component, + final IProperty prop, + StringDescriptor descriptor, + final FormErrorCollector collector) { + final String value = descriptor.getResolvedValue(); + if (value == null) { + return; + } + final SpellCheckerManager manager = SpellCheckerManager.getInstance(module.getProject()); + SplitterFactory.getInstance().getPlainTextSplitter().split(value, TextRange.allOf(value), new Consumer() { + @Override + public void consume(TextRange textRange) { + String word = textRange.substring(value); + if (manager.hasProblem(word)) { + collector.addError(getID(), component, prop, "Typo in word '" + word + "'", null); + } + } + }); + } +} diff --git a/plugins/ui-designer/ui-designer.iml b/plugins/ui-designer/ui-designer.iml index 3e49e4f500f4..1d3ce249f102 100644 --- a/plugins/ui-designer/ui-designer.iml +++ b/plugins/ui-designer/ui-designer.iml @@ -27,6 +27,7 @@ +