IDEA-53825 Maven artifact names are marked as typo
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Wed, 20 Feb 2013 15:33:34 +0000 (19:33 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Wed, 20 Feb 2013 15:33:56 +0000 (19:33 +0400)
plugins/maven/maven.iml
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomArtifactCoordinates.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomShortArtifactCoordinates.java
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSpellcheckerTest.java [new file with mode: 0644]
spellchecker/spellchecker.iml
spellchecker/src/META-INF/SpellCheckerPlugin.xml
spellchecker/src/com/intellij/spellchecker/xml/NoSpellchecking.java [new file with mode: 0644]
spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java [new file with mode: 0644]

index 99893724046edb417ca22b2ad2577f54046ae291..7a6231c38cef0cd708ebb7034ac66db90c758729 100644 (file)
@@ -59,6 +59,7 @@
     <orderEntry type="module" module-name="jps-model-impl" />
     <orderEntry type="module" module-name="maven-jps-plugin" />
     <orderEntry type="module" module-name="maven-artifact-resolver-m3" />
+    <orderEntry type="module" module-name="spellchecker" />
   </component>
   <component name="copyright">
     <Base>
index d016bf6c682e5667caa57c814911236e6cae16d4..977da3c80db703d62e432a72daa5257fbb684185 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.spellchecker.xml.NoSpellchecking;
 import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
 import com.intellij.util.xml.Required;
@@ -22,6 +23,7 @@ import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesVersionCo
 
 public interface MavenDomArtifactCoordinates extends MavenDomShortArtifactCoordinates {
   @Required
+  @NoSpellchecking
   @Convert(MavenArtifactCoordinatesVersionConverter.class)
   GenericDomValue<String> getVersion();
 }
index 90661675986c3577e3e7dd102c235fd8afcfd4c7..f75b3d447c59124a8f1c1987cdef82febaab700d 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.spellchecker.xml.NoSpellchecking;
 import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
 import com.intellij.util.xml.Required;
@@ -23,10 +24,12 @@ import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesGroupIdCo
 
 public interface MavenDomShortArtifactCoordinates {
   @Required
+  @NoSpellchecking
   @Convert(MavenArtifactCoordinatesGroupIdConverter.class)
   GenericDomValue<String> getGroupId();
 
   @Required
+  @NoSpellchecking
   @Convert(MavenArtifactCoordinatesArtifactIdConverter.class)
   GenericDomValue<String> getArtifactId();
 }
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSpellcheckerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenSpellcheckerTest.java
new file mode 100644 (file)
index 0000000..6b72903
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.idea.maven.dom;
+
+import com.intellij.spellchecker.inspections.SpellCheckingInspection;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenSpellcheckerTest extends MavenDomTestCase {
+
+  public void testSpell() throws Exception {
+    myFixture.enableInspections(SpellCheckingInspection.class);
+
+    createProjectPom("<groupId>test</groupId>\n" +
+                     "<artifactId>project</artifactId>\n" +
+                     "<version>1</version>\n" +
+
+                     "<description><TYPO>xxxxx</TYPO></description>\n" +
+
+                     "<dependencies>\n" +
+                     "  <dependency>\n" +
+                     "    <groupId>xxxxx</groupId>\n" +
+                     "    <artifactId>xxxxx</artifactId>\n" +
+                     "    <version>4.0</version>\n" +
+                     "    <type>pom</type>\n" +
+                     "  </dependency>\n" +
+                     "</dependencies>");
+
+    checkHighlighting();
+  }
+
+}
index d81c1984675fd56e27f2bf077c02d076a579046d..ad0f6db77fe41c68b46f9f2129ee3b5d3f55e1cc 100644 (file)
@@ -14,6 +14,7 @@
     <orderEntry type="module" module-name="platform-impl" />
     <orderEntry type="module" module-name="xml-openapi" />
     <orderEntry type="module" module-name="testFramework" scope="TEST" />
+    <orderEntry type="module" module-name="dom-openapi" />
   </component>
 </module>
 
index 3c3772bbf24423419c4073aa4b70a6979a06ff91..e9ad782766e93d789ac289bfa10f57b928d4d86f 100644 (file)
@@ -35,6 +35,7 @@
     
     <spellchecker.support language="TEXT" implementationClass="com.intellij.spellchecker.tokenizer.SpellcheckingStrategy"/>
     <spellchecker.support language="HTML" implementationClass="com.intellij.spellchecker.tokenizer.HtmlSpellcheckingStrategy"/>
+    <spellchecker.support language="XML" implementationClass="com.intellij.spellchecker.xml.XmlSpellcheckingStrategy"/>
     <spellchecker.bundledDictionaryProvider implementation="com.intellij.spellchecker.DefaultBundledDictionariesProvider"/>
 
     <projectService serviceImplementation="com.intellij.spellchecker.state.ProjectDictionaryState"/>
diff --git a/spellchecker/src/com/intellij/spellchecker/xml/NoSpellchecking.java b/spellchecker/src/com/intellij/spellchecker/xml/NoSpellchecking.java
new file mode 100644 (file)
index 0000000..b374298
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2013 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.spellchecker.xml;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author Sergey Evdokimov
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NoSpellchecking {
+
+}
diff --git a/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java
new file mode 100644 (file)
index 0000000..e08897f
--- /dev/null
@@ -0,0 +1,31 @@
+package com.intellij.spellchecker.xml;
+
+import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.psi.PsiElement;
+import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy;
+import com.intellij.util.xml.DomElement;
+import com.intellij.util.xml.DomUtil;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class XmlSpellcheckingStrategy extends SuppressibleSpellcheckingStrategy {
+
+  @Override
+  public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String name) {
+    DomElement domElement = DomUtil.getDomElement(element);
+    if (domElement != null) {
+      if (domElement.getAnnotation(NoSpellchecking.class) != null) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  @Override
+  public SuppressIntentionAction[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
+    return SuppressIntentionAction.EMPTY_ARRAY;
+  }
+}