Ejemplo n.º 1
0
                public override bool Matches(object actual)
                {
                    var code = actual as string;

                    if (code == null)
                    {
                        return(false);
                    }

                    code += "\n";

                    var m     = DParser.ParseString(code);
                    var cache = ResolutionTests.CreateCache();

                    (cache [0] as MutableRootPackage).AddModule(m);

                    var ed = new EditorData {
                        ModuleCode    = code,
                        CaretOffset   = code.Length - 1,
                        CaretLocation = DocumentHelper.OffsetToLocation(code, code.Length - 1),
                        SyntaxTree    = m,
                        ParseCache    = cache
                    };

                    var gen = new TestCompletionDataGen(null, null);
                    var res = CodeCompletion.GenerateCompletionData(ed, gen, 'a');

                    return(neg ? !res : res);
                }
Ejemplo n.º 2
0
        public static TestCompletionDataGen TestCompletionListContents(IEditorData ed, INode[] itemWhiteList = null, INode[] itemBlackList = null, char trigger = '\0')
        {
            var gen = new TestCompletionDataGen (itemWhiteList, itemBlackList);
            Assert.That (CodeCompletion.GenerateCompletionData (ed, gen, trigger), Is.True);

            Assert.That (gen.HasRemainingItems, Is.False, "Some items were not enlisted!");
            return gen;
        }
Ejemplo n.º 3
0
        public static TestCompletionDataGen TestCompletionListContents(IEditorData ed, INode[] itemWhiteList = null, INode[] itemBlackList = null, char trigger = '\0')
        {
            var gen = new TestCompletionDataGen(itemWhiteList, itemBlackList);

            Assert.That(CodeCompletion.GenerateCompletionData(ed, gen, trigger), Is.True);

            Assert.That(gen.HasRemainingItems, Is.False, "Some items were not enlisted!");
            return(gen);
        }
Ejemplo n.º 4
0
 public void AutoCompletion()
 {
     var code = @"module A;
     void main() {
     auto
     }";
     var ed = GenEditorData(3, 5, code);
     var g = new TestCompletionDataGen(null, null);
     Assert.That(CodeCompletion.GenerateCompletionData(ed, g, 'a', true), Is.False);
 }
Ejemplo n.º 5
0
        public void AutoCompletion()
        {
            var code = @"module A;
void main() {
auto 
}";
            var ed   = GenEditorData(3, 5, code);
            var g    = new TestCompletionDataGen(null, null);

            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, 'a', true), Is.False);
        }
Ejemplo n.º 6
0
        public void ForeachCompletion()
        {
            var code = @"module A;
void main() {
foreach( 
}";
            var ed   = GenEditorData(3, 9, code);
            var g    = new TestCompletionDataGen(null, null);

            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, 'a', true), Is.True);
        }
Ejemplo n.º 7
0
        public void NonStaticCompletion1()
        {
            var code = @"module A;
struct SomeStruct {ubyte a; static void read() {

}}
";
            var ed   = GenEditorData(3, 1, code);

            var SomeStruct = (ed.ParseCache [0] ["A"] ["SomeStruct"].First() as DClassLike);
            var a          = SomeStruct["a"].First() as DVariable;
            var read       = SomeStruct ["read"].First() as DMethod;
            var g          = new TestCompletionDataGen(new[] { read }, new[] { a });

            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, '\0', true), Is.True);
        }
Ejemplo n.º 8
0
        public void ForeachIteratorCompletion()
        {
            var code = @"module A;
void main() {Cl** ii;
foreach(i;ii)
i.
}

struct Cl { int a; }
";
            var ed   = GenEditorData(4, 3, code);

            var a = (ed.ParseCache[0]["A"]["Cl"].First() as DClassLike)["a"].First() as DVariable;

            var g = new TestCompletionDataGen(new[] { a }, null);

            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, 'a', true), Is.True);
        }
Ejemplo n.º 9
0
                public override bool Matches(object actual)
                {
                    var code = actual as string;
                    if (code == null)
                        return false;

                    code += "\n";

                    var m = DParser.ParseString (code);
                    var cache = ResolutionTests.CreateCache ();
                    cache.FirstPackage().AddModule (m);

                    var ed = new EditorData{
                        ModuleCode = code,
                        CaretOffset = code.Length-1,
                        CaretLocation = DocumentHelper.OffsetToLocation(code,code.Length-1),
                        SyntaxTree = m,
                        ParseCache = cache
                    };

                    var gen = new TestCompletionDataGen (null, null);
                    var res = CodeCompletion.GenerateCompletionData (ed, gen, 'a');

                    return neg ? !res : res;
                }
Ejemplo n.º 10
0
        public void NonStaticCompletion1()
        {
            var code = @"module A;
            struct SomeStruct {ubyte a; static void read() {

            }}
            ";
            var ed = GenEditorData(3, 1, code);

            var SomeStruct = (ed.MainPackage ["A"] ["SomeStruct"].First () as DClassLike);
            var a = SomeStruct["a"].First() as DVariable;
            var read = SomeStruct ["read"].First () as DMethod;
            var g = new TestCompletionDataGen(new[]{ read },new[]{ a });
            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, '\0', true), Is.True);
        }
Ejemplo n.º 11
0
        public void ForeachIteratorCompletion()
        {
            var code = @"module A;
            void main() {Cl** ii;
            foreach(i;ii)
            i.
            }

            struct Cl { int a; }
            ";
            var ed = GenEditorData(4, 3, code);

            var a = (ed.MainPackage["A"]["Cl"].First() as DClassLike)["a"].First() as DVariable;

            var g = new TestCompletionDataGen(new[]{ a }, null);
            Assert.That(CodeCompletion.GenerateCompletionData(ed, g, 'a', true), Is.True);
        }
Ejemplo n.º 12
0
 public void ForeachCompletion()
 {
     var code =@"module A;
     void main() {
     foreach(
     }";
     var ed = GenEditorData (3, 9, code);
     var g = new TestCompletionDataGen (null, null);
     Assert.That(CodeCompletion.GenerateCompletionData (ed, g, 'a', true), Is.True);
 }