spellchecker for forms (initial, no quickfixes yet)

This commit is contained in:
Dmitry Jemerov
2011-10-12 18:17:35 +02:00
parent 377e3ef617
commit 7c2e4dcf9d
6 changed files with 63 additions and 3 deletions
+2 -1
View File
@@ -8,7 +8,7 @@
<extensionPoints>
<extensionPoint name="formInspectionTool"
interface="com.intellij.uiDesigner.quickFixes.FormInspectionTool"/>
interface="com.intellij.uiDesigner.inspections.FormInspectionTool"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij.uiDesigner">
@@ -21,6 +21,7 @@
<formInspectionTool implementation="com.intellij.uiDesigner.inspections.NoButtonGroupInspection"/>
<formInspectionTool implementation="com.intellij.uiDesigner.inspections.NoScrollPaneInspection"/>
<formInspectionTool implementation="com.intellij.uiDesigner.inspections.OneButtonGroupInspection"/>
<formInspectionTool implementation="com.intellij.uiDesigner.inspections.FormSpellCheckingInspection"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">
@@ -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;
@@ -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;
@@ -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;
@@ -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<TextRange>() {
@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);
}
}
});
}
}
+1
View File
@@ -27,6 +27,7 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="java-tests" scope="TEST" />
<orderEntry type="module" module-name="platform-api" />
<orderEntry type="module" module-name="spellchecker" />
</component>
<component name="copyright">
<Base>