Commits

Nerzhul500  committed cab8007

Fixed "@" handling. Some fixes in field tests.
Every element is being tested in own file

  • Participants
  • Parent commits 82051be
  • Branches resharper7

Comments (0)

Files changed (30)

 packages
 *.Generated.*
 *.DotSettings
+*.tmp

File ReSpeller.RSTests/CSharpHighlightingsTest.cs

 using JetBrains.ReSharper.Daemon;
 using JetBrains.ReSharper.Daemon.CSharp;
 using JetBrains.Application.Settings;
+using JetBrains.ReSharper.Feature.Services.Tips;
+using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.Naming;
 using NUnit.Framework;
 using ReSpeller.Highlightings;
 
 
     protected override string RelativeTestDataPath
     {
-      get { return @"Highlightings"; }
+      get { return @"Highlightings\CSharp"; }
     }
 
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="testName"></param>
     [Test]
-    [TestCase("CSharp.cs")]
+    [TestCase("Class.cs")]
+    [TestCase("Field.cs")]
+    [TestCase("Local.cs")]
+    [TestCase("Method.cs")]
+    [TestCase("Namespace.cs")]
+    [TestCase("Property.cs")]
+    [TestCase("Comment.cs")]
     public void Test(string testName)
     {
       DoTestFiles(testName);

File ReSpeller.RSTests/ReSpeller7.0.RSTests.csproj

     <Compile Include="CSharpHighlightingsTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SpellEngine\SpellCheckerTest.cs" />
-    <None Include="test\data\Highlightings\CSharp.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="test\data\Highlightings\Xml.xml" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\ReSpeller\ReSpeller7.0.csproj">
       <Name>ReSpeller7.0</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="test\data\Highlightings\CSharp.cs.gold" />
-    <None Include="test\data\Highlightings\Xml.xml.gold" />
-  </ItemGroup>
+  <ItemGroup />
   <PropertyGroup>
     <ReSharperSdkTargets Condition=" '$(ReSharperSdkTargets)' == '' ">$(MSBuildExtensionsPath)\JetBrains\ReSharper.SDK\v7.0</ReSharperSdkTargets>
   </PropertyGroup>

File ReSpeller.RSTests/ReSpeller7.1.RSTests.csproj

     <Compile Include="CSharpHighlightingsTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SpellEngine\SpellCheckerTest.cs" />
-    <Compile Include="test\data\Highlightings\CSharp.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="test\data\Highlightings\Xml.xml" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\ReSpeller\ReSpeller7.1.csproj">
       <Name>ReSpeller7.1</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="test\data\Highlightings\CSharp.cs.gold" />
-    <None Include="test\data\Highlightings\Xml.xml.gold" />
-  </ItemGroup>
   <PropertyGroup>
     <ReSharperSdkTargets Condition=" '$(ReSharperSdkTargets)' == '' ">$(MSBuildExtensionsPath)\JetBrains\ReSharper.SDK\v7.1</ReSharperSdkTargets>
   </PropertyGroup>

File ReSpeller.RSTests/XmlHighlightingsTest.cs

 
     protected override string RelativeTestDataPath
     {
-      get { return @"Highlightings"; }
+      get { return @"Highlightings\Xml"; }
     }
 
     [Test]

File ReSpeller.RSTests/test/data/Highlightings/CSharp.cs

-namespace WrongwordNS.GoodWord
-{
-  class MyClass
-  {
-     
-  }
-}
-
-class WrongwordClass
-{
-  /// <summary>
-  /// wrongword comment
-  /// </summary>
-  public WrongwordClass()
-  {
-  }
-
-  // WRONGWORD comment
-  public static void Main()
-  {
-  	int wrongword = 0;
-  	string s = "wrongword";
-    return;
-  }
-}

File ReSpeller.RSTests/test/data/Highlightings/CSharp.cs.gold

-namespace |Wrongword|(0)NS.GoodWord
-{
-  class MyClass
-  {
-     
-  }
-}
-
-class |Wrongword|(1)Class
-{
-  /// <summary>
-  /// |wrongword|(2) comment
-  /// </summary>
-  public |Wrongword|(3)Class()
-  {
-  }
-
-  // |WRONGWORD|(4) comment
-  public static void Main()
-  {
-  	int |wrongword|(5) = 0;
-  	string s = "|wrongword|(6)";
-    return;
-  }
-}
----------------------------------------------------------
-(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
-(1): ReSharper Suggestion: Typo in identifier: "Wrongword"
-(2): ReSharper Suggestion: Typo in comment: "wrongword"
-(3): ReSharper Suggestion: Typo in identifier: "Wrongword"
-(4): ReSharper Suggestion: Typo in comment: "WRONGWORD"
-(5): ReSharper Suggestion: Typo in identifier: "wrongword"
-(6): ReSharper Suggestion: Typo in string: "wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Class.cs

+class WrongwordClass
+{
+  public WrongwordClass()
+  {
+  }
+
+}
+
+class @WrongwordClass2
+{
+  public @WrongwordClass2()
+  {
+  }
+
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Class.cs.gold

+class |Wrongword|(0)Class
+{
+  public |Wrongword|(1)Class()
+  {
+  }
+
+}
+
+class @|Wrongword|(2)Class2
+{
+  public @|Wrongword|(3)Class2()
+  {
+  }
+
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(2): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(3): ReSharper Suggestion: Typo in identifier: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Comment.cs

+// wrongword comment with myWrongword123
+
+/*
+wrongword comment with myWrongword123
+*/
+
+/// <summary>
+/// wrongword comment with myWrongword123
+/// </summary>
+/// <wrongword>asf</wrongword>
+class MyClass {}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Comment.cs.gold

+// |wrongword|(0) comment with my|Wrongword|(1)123
+
+/*
+|wrongword|(2) comment with my|Wrongword|(3)123
+*/
+
+/// <summary>
+/// |wrongword|(4) comment with my|Wrongword|(5)123
+/// </summary>
+/// <|wrongword|(6)>asf</|wrongword|(7)>
+class MyClass {}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in comment: "wrongword"
+(1): ReSharper Suggestion: Typo in comment: "Wrongword"
+(2): ReSharper Suggestion: Typo in comment: "wrongword"
+(3): ReSharper Suggestion: Typo in comment: "Wrongword"
+(4): ReSharper Suggestion: Typo in comment: "wrongword"
+(5): ReSharper Suggestion: Typo in comment: "Wrongword"
+(6): ReSharper Suggestion: Typo in comment: "wrongword"
+(7): ReSharper Suggestion: Typo in comment: "wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Field.cs

+class MyClass
+{
+  
+  private int myWrongwordField;
+
+  private string myGoodField;
+
+  private int @myFieldWrongword1;
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Field.cs.gold

+class MyClass
+{
+  
+  private int my|Wrongword|(0)Field;
+
+  private string myGoodField;
+
+  private int @myField|Wrongword|(1)1;
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Local.cs

+class MyClass
+{
+
+  public void MyMethod()
+  {
+    int @localWrongword = 5;
+    string wrongwordName = "asd";    
+  }
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Local.cs.gold

+class MyClass
+{
+
+  public void MyMethod()
+  {
+    int @local|Wrongword|(0) = 5;
+    string |wrongword|(1)Name = "asd";    
+  }
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Method.cs

+class MyClass
+{
+  public void MethWrongword123()
+  {
+  
+  }
+
+  public void @WrongwordMethod123()
+  {
+  
+  }
+
+  public void GoodMethod() 
+  {
+
+  }
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Method.cs.gold

+class MyClass
+{
+  public void Meth|Wrongword|(0)123()
+  {
+  
+  }
+
+  public void @|Wrongword|(1)Method123()
+  {
+  
+  }
+
+  public void GoodMethod() 
+  {
+
+  }
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Namespace.cs

+namespace WrongwordNS.GoodWord
+{
+}
+
+namespace GoodWord.Wrongword123
+{
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Namespace.cs.gold

+namespace |Wrongword|(0)NS.GoodWord
+{
+}
+
+namespace GoodWord.|Wrongword|(1)123
+{
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Property.cs

+class MyClass
+{
+  public int FieldWrongword123
+  {
+    get; set;
+  }
+
+  public int @Wrongword123
+  {
+    get; set;
+  }
+}

File ReSpeller.RSTests/test/data/Highlightings/CSharp/Property.cs.gold

+class MyClass
+{
+  public int Field|Wrongword|(0)123
+  {
+    get; set;
+  }
+
+  public int @|Wrongword|(1)123
+  {
+    get; set;
+  }
+}
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in identifier: "Wrongword"
+(1): ReSharper Suggestion: Typo in identifier: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/Xml.xml

-<!--comment with some wrongword and otherWrongword-->
-<config>
-  <element attr="myWrongwordAttr" other="goodAttr">
-    Some correct and wrongword text. 123WrongwordQwe
-  </element>
-  <wrongword/>
-</config>

File ReSpeller.RSTests/test/data/Highlightings/Xml.xml.gold

-<!--comment with some |wrongword|(0) and other|Wrongword|(1)-->
-<config>
-  <element attr="my|Wrongword|(2)Attr" other="goodAttr">
-    Some correct and |wrongword|(3) text. 123|Wrongword|(4)Qwe
-  </element>
-  <wrongword/>
-</config>
-
----------------------------------------------------------
-(0): ReSharper Suggestion: Typo in comment: "wrongword"
-(1): ReSharper Suggestion: Typo in comment: "Wrongword"
-(2): ReSharper Suggestion: Typo in markup attribute value: "Wrongword"
-(3): ReSharper Suggestion: Typo in markup text: "wrongword"
-(4): ReSharper Suggestion: Typo in markup text: "Wrongword"

File ReSpeller.RSTests/test/data/Highlightings/Xml/Xml.xml

+<!--comment with some wrongword and otherWrongword-->
+<config>
+  <element attr="myWrongwordAttr" other="goodAttr">
+    Some correct and wrongword text. 123WrongwordQwe
+  </element>
+  <wrongword/>
+</config>

File ReSpeller.RSTests/test/data/Highlightings/Xml/Xml.xml.gold

+<!--comment with some |wrongword|(0) and other|Wrongword|(1)-->
+<config>
+  <element attr="my|Wrongword|(2)Attr" other="goodAttr">
+    Some correct and |wrongword|(3) text. 123|Wrongword|(4)Qwe
+  </element>
+  <wrongword/>
+</config>
+
+---------------------------------------------------------
+(0): ReSharper Suggestion: Typo in comment: "wrongword"
+(1): ReSharper Suggestion: Typo in comment: "Wrongword"
+(2): ReSharper Suggestion: Typo in markup attribute value: "Wrongword"
+(3): ReSharper Suggestion: Typo in markup text: "wrongword"
+(4): ReSharper Suggestion: Typo in markup text: "Wrongword"

File ReSpeller.RSTests/test/data/Identifier.cs.tmp

-
----------------------------------------------------------

File ReSpeller.RSTests/test/data/ReverseStringAction/availability01.cs

-namespace N
-{
-  class C
-  {
-    static void Main(string[] args)
-    {
-      string s = "abc{caret}";
-    }
-  }
-}

File ReSpeller.RSTests/test/data/ReverseStringAction/execute01.cs

-namespace N
-{
-  class C
-  {
-    static void Main(string[] args)
-    {
-      string s = "abc{caret}";
-    }
-  }
-}

File ReSpeller.RSTests/test/data/ReverseStringAction/execute01.cs.gold

-namespace N
-{
-  class C
-  {
-    static void Main(string[] args)
-    {
-      string s = "cba{caret}";
-    }
-  }
-}

File ReSpeller/Analyzers/IdentifierTypoAnalyzer.cs

       DocumentRange elementRange = treeNode.GetDocumentRange();
       if (!elementRange.IsValid())
         return;
-      if (elementRange.GetText().StartsWith("@"))
-      {
-        // if name starts with @ need to change prefix
-        prefix = "@" + prefix;
-      }
 
       if (isNamespace)
       {