public void TestInheritedInnerClasses() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" public class A { public class B { public void MethodB () { } } } public class C : A { public override void MethodA (B something) { $something.$ } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("MethodB"), "method 'MethodB' not found"); }
public void TestProtectedMemberAccess2() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" class Test { protected void Test () { } } class Test2 { void Test2 () { $(new Test ()).$ } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNull(provider.Find("Test"), "method 'Test' found, but shouldn't."); }
public void TestBaseProtectedMemberAccess() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" class Test { protected void Test () { } } class Test2 : Test { void Test2 () { $base.$ } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("Test"), "method 'Test' not found."); }
public void TestLambdaExpressionCase2() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" namespace System { public class Array { public Test this[int i] { get { } set { } } } } static class ExtMethods { public static T Where<T>(this T[] t, Func<T, bool> pred) { return t; } } class Test { public void TestMethod () { Test[] en = new Test[0]; var x = en.Where (t => t != null); $x.$ } } "); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("TestMethod"), "method 'TestMethod' not found."); }
public void TestMethodAccess() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" class AClass { public AClass TestMethod () { } } class Test { void Test () { AClass a; $a.TestMethod().$ } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("TestMethod"), "method 'TestMethod ' not found."); }
public void TestNamespaceAccess() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" namespace Foo.Bar { class B { } } namespace Foo { class Test { void TestMethod () { $Bar.$ } } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("B"), "class 'B' not found"); }
public void TestInnerClassPrivateOuterMembersAccess() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" public class TestClass { void TestMethod () { } public class InnerClass { void TestMethod () { TestClass tc = new TestClass (); $tc.$ } } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("TestMethod"), "method 'TestMethod' not found"); }
public void TestImplicitGenericMethodParameter() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" public class TestClass { public static T TestMethod<T> (T t) { return t; } } public class Test { public void TestMethod () { $TestClass.TestMethod (this).$ } } "); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("TestMethod"), "method 'TestMethod' not found"); }
public void TestBug487237() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" public interface IHelper { void DoIt (); } public class Program { delegate T MyDelegate <T> (T t); static int Main () { $MyDelegate<IHelper> e = helper => helper.$ return 0; } } "); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("DoIt"), "method 'DoIt' not found."); }
public void TestExplicitResolving() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider( @" interface IMyInterface { object this [object i] { get; } } class MyClass<S, T> : IMyInterface { object IMyInterface.this[object i] { get { return null; } } public S this[T i] { get { return default(S); } } } class TestClass { void TestMethod () { MyClass<TestClass, string> myClass = new MyClass<TestClass, string> (); $myClass[""test""].$ } } "); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("TestMethod"), "method 'TestMethod' not found"); }
public void TestExternalNonStaticSubclassAccess() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider(testClass + @"} class AClass : TestClass { void TestMethod () { $this.$ } }"); Assert.IsNotNull(provider, "provider == null"); CodeCompletionBugTests.CheckProtectedObjectMembers(provider); Assert.IsNotNull(provider.Find("PubField")); Assert.IsNotNull(provider.Find("PubProperty")); Assert.IsNotNull(provider.Find("PubMethod")); Assert.IsNotNull(provider.Find("ProtField")); Assert.IsNotNull(provider.Find("ProtProperty")); Assert.IsNotNull(provider.Find("ProtMethod")); }
public void TestInternalAccessOutside() { CompletionDataList provider = CodeCompletionBugTests.CreateProvider(testClass + @" } class Test2 { void TestMethod () { TestClass tc; $tc.$ } }"); Assert.IsNotNull(provider, "provider == null"); Assert.IsNotNull(provider.Find("InternalField"), "InternalField == null"); Assert.IsNotNull(provider.Find("InternalProperty"), "InternalProperty == null"); Assert.IsNotNull(provider.Find("InternalMethod"), "InternalMethod == null"); Assert.IsNotNull(provider.Find("ProtOrInternalField"), "ProtOrInternalField == null"); Assert.IsNotNull(provider.Find("ProtOrInternalProperty"), "ProtOrInternalProperty == null"); Assert.IsNotNull(provider.Find("ProtOrInternalMethod"), "ProtOrInternalMethod == null"); }
public static void CheckObjectMembers (CompletionDataList provider) { Assert.IsNotNull (provider.Find ("Equals"), "Method 'System.Object.Equals' not found."); Assert.IsNotNull (provider.Find ("GetHashCode"), "Method 'System.Object.GetHashCode' not found."); Assert.IsNotNull (provider.Find ("GetType"), "Method 'System.Object.GetType' not found."); Assert.IsNotNull (provider.Find ("ToString"), "Method 'System.Object.ToString' not found."); }
private CompletionDataList GetCompletionData(CompletionTyp completiontype, bool onlyOne) { CompletionDataList listComplete = new CompletionDataList(); if (completiontype == CompletionTyp.includeType) { listComplete.Add(new CompletionData("lib", null, "lib", "lib://")); listComplete.Add(new CompletionData("app", null, "app", "app://")); return(listComplete); } if (MainClass.CompletedCache.ListDataKeywords != null) { foreach (CompletionData cd in MainClass.CompletedCache.ListDataKeywords) { if (cd != null) { CompletionData cdParent = listComplete.Find(cd.DisplayText); if ((cdParent == null) || (!onlyOne)) { if (completiontype != CompletionTyp.newType) { cdParent = cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description = cdParent.Description + Environment.NewLine + Environment.NewLine + cd.Description; } } } } } //Types (from doc T:) //i = 0; if (MainClass.CompletedCache.ListDataTypes != null) { foreach (CompletionData cd in MainClass.CompletedCache.ListDataTypes) { if (cd != null) { CompletionData cdParent = listComplete.Find(cd.DisplayText); if ((cdParent == null) || (!onlyOne)) { if (completiontype != CompletionTyp.dotType) { cdParent = cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description = cdParent.Description + Environment.NewLine + Environment.NewLine + cd.Description; } } } } } // M P E //Member (from doc M: ) //i = 0; if (MainClass.CompletedCache.ListDataMembers != null) { foreach (CompletionData cd in MainClass.CompletedCache.ListDataMembers) { if (cd != null) { //if (cd.DisplayText==baseWord) // i++; CompletionData cdParent = listComplete.Find(cd.DisplayText); if ((cdParent == null) || (!onlyOne)) { if (completiontype != CompletionTyp.newType) { cdParent = cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description = cdParent.Description + Environment.NewLine + Environment.NewLine + cd.Description; } } } } } //Member (from doc P:) //i = 0; if (MainClass.CompletedCache.ListDataProperties != null) { foreach (CompletionData cd in MainClass.CompletedCache.ListDataProperties) { if (cd != null) { //if (cd.DisplayText==baseWord) // i++; //if(!onlyOne) // if(cd.DisplayText=="width") // Console.WriteLine("1"); CompletionData cdParent = listComplete.Find(cd.DisplayText); if ((cdParent == null) || (!onlyOne)) { if (completiontype != CompletionTyp.newType) { cdParent = cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description = cdParent.Description + Environment.NewLine + Environment.NewLine + cd.Description; } } } } } //Member (from doc E:) //i = 0; if (MainClass.CompletedCache.ListDataEvents != null) { foreach (CompletionData cd in MainClass.CompletedCache.ListDataEvents) { if (cd != null) { //if (cd.DisplayText==baseWord) // i++; CompletionData cdParent = listComplete.Find(cd.DisplayText); if ((cdParent == null) || (!onlyOne)) { if (completiontype != CompletionTyp.newType) { cdParent = cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description = cdParent.Description + Environment.NewLine + Environment.NewLine + cd.Description; } } } } } return(listComplete); }
/// <summary> /// Vrati vsetky mozne autokompletion , do zoznamu prida aj slova zo samotneho dokumentu /// </summary> /// <returns> /// Zoznam autoCompletion slov odpovesajuci baseWord a completiontype /// </returns> public static ICompletionDataList GetCompletionData(this TextEditor editor, string baseWord, string fullWord, CompletionTyp completiontype) { string codestring = editor.Document.Text; string type = ""; string parent = ""; editor.ParseString(fullWord, out parent, out type); Regex regex = new Regex(@"\W", RegexOptions.Compiled); codestring = regex.Replace(codestring, " "); string[] list = codestring.Split(' '); CompletionDataList listComplete = new CompletionDataList(); listComplete.CompletionSelectionMode = CompletionSelectionMode.OwnTextField; if (!String.IsNullOrEmpty(type)) { //List<CompletionData> lst = MainClass.CompletedCache.AllCompletionOnlyOne.FindAll(x=>x.Parent == type); List <CompletionData> lst = MainClass.CompletedCache.AllCompletionRepeat.FindAll(x => x.Parent == type); foreach (CompletionData cd in lst) { string expres = cd.Parent + ".on"; if (cd.Signature.StartsWith(expres)) { //expres = cd.Signature.Replace(cd.Parent+".", cd.DisplayText +" = function "); expres = cd.Signature.Replace(cd.Parent + "." + cd.DisplayText, cd.DisplayText + " = function "); cd.DisplayDescription = expres + "{}"; cd.CompletionText = expres + "{" + Environment.NewLine + "}"; } } if (lst != null) { listComplete.AddRange(lst.ToArray()); } if (listComplete != null && listComplete.Count > 0) { return(listComplete); } } switch (completiontype) { case CompletionTyp.allType: { listComplete.AddRange(MainClass.CompletedCache.AllCompletionOnlyOne); break; } case CompletionTyp.newType: { listComplete.AddRange(MainClass.CompletedCache.NewCompletion); break; } case CompletionTyp.dotType: { listComplete.AddRange(MainClass.CompletedCache.DotCompletion); break; } } int i = 0; foreach (string s in list) { if (!String.IsNullOrEmpty(s.Trim())) { if (s == baseWord) { i++; } if ((listComplete.Find(s) == null) && (s.Length > 2) && ((s != baseWord) || (i == 1))) { CompletionData cd = new CompletionData(s, null, s, s); if (completiontype == CompletionTyp.newType) { if (char.ToUpper(s[0]) == s[0] && !char.IsDigit(s[0]) && !char.IsSymbol(s[0]) && char.IsLetter(s[0])) { CompletionData cdParent = listComplete.Find(cd.DisplayText); if (cdParent == null) { listComplete.Add(cd); } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.Description = cdParent.Description + Environment.NewLine + cd.Description; } } } } else { CompletionData cdParent = listComplete.Find(cd.DisplayText); if (cdParent == null) { listComplete.Add(cd); } else { if (!cdParent.Description.Contains(cd.Description)) { cdParent.Description = cdParent.Description + Environment.NewLine + cd.Description; } } } } } } return(listComplete); }
private CompletionDataList GetCompletionData(CompletionTyp completiontype, bool onlyOne ) { CompletionDataList listComplete = new CompletionDataList(); if(completiontype == CompletionTyp.includeType){ listComplete.Add(new CompletionData("lib",null,"lib","lib://")); listComplete.Add(new CompletionData("app",null,"app","app://")); return listComplete; } if(MainClass.CompletedCache.ListDataKeywords != null){ foreach (CompletionData cd in MainClass.CompletedCache.ListDataKeywords) { if ( cd != null ){ CompletionData cdParent =listComplete.Find(cd.DisplayText); if ((cdParent== null) || (!onlyOne)) { if (completiontype != CompletionTyp.newType){ cdParent =cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if(!cdParent.Description.Contains(cd.Description)){ cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description =cdParent.Description+Environment.NewLine+Environment.NewLine+ cd.Description; } } } } } //Types (from doc T:) //i = 0; if(MainClass.CompletedCache.ListDataTypes != null){ foreach (CompletionData cd in MainClass.CompletedCache.ListDataTypes) { if ( cd != null ){ CompletionData cdParent =listComplete.Find(cd.DisplayText); if ((cdParent== null) || (!onlyOne)){ if (completiontype != CompletionTyp.dotType){ cdParent =cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if(!cdParent.Description.Contains(cd.Description)){ cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description =cdParent.Description+Environment.NewLine+Environment.NewLine+ cd.Description; } } } } } // M P E //Member (from doc M: ) //i = 0; if(MainClass.CompletedCache.ListDataMembers != null){ foreach (CompletionData cd in MainClass.CompletedCache.ListDataMembers) { if ( cd != null ){ //if (cd.DisplayText==baseWord) // i++; CompletionData cdParent =listComplete.Find(cd.DisplayText); if ((cdParent== null) || (!onlyOne)){ if (completiontype != CompletionTyp.newType){ cdParent =cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } } else { if(!cdParent.Description.Contains(cd.Description)){ cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description =cdParent.Description+Environment.NewLine+Environment.NewLine+ cd.Description; } } } } } //Member (from doc P:) //i = 0; if(MainClass.CompletedCache.ListDataProperties != null){ foreach (CompletionData cd in MainClass.CompletedCache.ListDataProperties) { if ( cd != null ){ //if (cd.DisplayText==baseWord) // i++; //if(!onlyOne) // if(cd.DisplayText=="width") // Console.WriteLine("1"); CompletionData cdParent =listComplete.Find(cd.DisplayText); if ((cdParent== null) || (!onlyOne)){ if (completiontype != CompletionTyp.newType){ cdParent =cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } }else { if(!cdParent.Description.Contains(cd.Description)){ cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description =cdParent.Description+Environment.NewLine+Environment.NewLine+cd.Description; } } } } } //Member (from doc E:) //i = 0; if(MainClass.CompletedCache.ListDataEvents != null){ foreach (CompletionData cd in MainClass.CompletedCache.ListDataEvents) { if ( cd != null ){ //if (cd.DisplayText==baseWord) // i++; CompletionData cdParent =listComplete.Find(cd.DisplayText); if ((cdParent== null) || (!onlyOne)){ if (completiontype != CompletionTyp.newType){ cdParent =cd.Clone(); cdParent.OverloadedData.Add(cd.Clone()); listComplete.Add(cdParent); } }else { if(!cdParent.Description.Contains(cd.Description)){ cdParent.IsOverloaded = true; cdParent.OverloadedData.Add(cd.Clone()); cdParent.Description =cdParent.Description+Environment.NewLine+ Environment.NewLine +cd.Description; } } } } } return listComplete; }
public static void CheckStaticObjectMembers (CompletionDataList provider) { Assert.IsNotNull (provider.Find ("Equals"), "Method 'System.Object.Equals' not found."); Assert.IsNotNull (provider.Find ("ReferenceEquals"), "Method 'System.Object.ReferenceEquals' not found."); }
public static void CheckProtectedObjectMembers (CompletionDataList provider) { CheckObjectMembers (provider); Assert.IsNotNull (provider.Find ("MemberwiseClone"), "Method 'System.Object.MemberwiseClone' not found."); }
/// <summary> /// Vrati vsetky mozne autokompletion , do zoznamu prida aj slova zo samotneho dokumentu /// </summary> /// <returns> /// Zoznam autoCompletion slov odpovesajuci baseWord a completiontype /// </returns> public static ICompletionDataList GetCompletionData(this TextEditor editor ,string baseWord,string fullWord ,CompletionTyp completiontype) { string codestring = editor.Document.Text; string type = ""; string parent = ""; editor.ParseString(fullWord,out parent,out type); Regex regex = new Regex(@"\W", RegexOptions.Compiled); codestring = regex.Replace(codestring, " "); string[] list = codestring.Split(' '); CompletionDataList listComplete = new CompletionDataList(); listComplete.CompletionSelectionMode = CompletionSelectionMode.OwnTextField; if(!String.IsNullOrEmpty(type)){ //List<CompletionData> lst = MainClass.CompletedCache.AllCompletionOnlyOne.FindAll(x=>x.Parent == type); List<CompletionData> lst = MainClass.CompletedCache.AllCompletionRepeat.FindAll(x=>x.Parent == type); foreach ( CompletionData cd in lst){ string expres =cd.Parent+".on"; if(cd.Signature.StartsWith(expres) ){ //expres = cd.Signature.Replace(cd.Parent+".", cd.DisplayText +" = function "); expres = cd.Signature.Replace(cd.Parent+"."+ cd.DisplayText, cd.DisplayText +" = function "); cd.DisplayDescription =expres+"{}"; cd.CompletionText =expres+"{"+Environment.NewLine+"}"; } } if (lst != null) listComplete.AddRange(lst.ToArray()); if(listComplete != null && listComplete.Count>0){ return listComplete; } } switch (completiontype) { case CompletionTyp.allType: { listComplete.AddRange(MainClass.CompletedCache.AllCompletionOnlyOne); break; } case CompletionTyp.newType: { listComplete.AddRange(MainClass.CompletedCache.NewCompletion); break; } case CompletionTyp.dotType: { listComplete.AddRange(MainClass.CompletedCache.DotCompletion); break; } } int i = 0; foreach (string s in list) { if ( !String.IsNullOrEmpty(s.Trim()) ){ if (s==baseWord) i++; if ((listComplete.Find(s)== null) && (s.Length>2) && ( (s!= baseWord) || (i ==1) ) ){ CompletionData cd = new CompletionData(s, null, s, s); if (completiontype == CompletionTyp.newType){ if(char.ToUpper(s[0]) == s[0] && !char.IsDigit(s[0]) && !char.IsSymbol(s[0]) &&char.IsLetter(s[0]) ){ CompletionData cdParent =listComplete.Find(cd.DisplayText); if (cdParent== null){ listComplete.Add(cd); } else { if(!cdParent.Description.Contains(cd.Description)) cdParent.Description =cdParent.Description+Environment.NewLine+cd.Description; } } } else{ CompletionData cdParent =listComplete.Find(cd.DisplayText); if (cdParent== null){ listComplete.Add(cd); } else { if(!cdParent.Description.Contains(cd.Description)) cdParent.Description =cdParent.Description+Environment.NewLine+cd.Description; } } } } } return listComplete; }