Example #1
0
        public async Task TestCodeElementFromPointBetweenMembers()
        {
            var text             = await(GetCurrentDocument()).GetTextAsync();
            var tree             = await(GetCurrentDocument()).GetSyntaxTreeAsync();
            var position         = text.ToString().IndexOf("protected virtual string MethodB", StringComparison.Ordinal) - 1;
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint        = new MockTextPoint(virtualTreePoint, 4);

            Assert.Throws <COMException>(() =>
                                         (GetCodeModel()).CodeElementFromPoint(textPoint, vsCMElement.vsCMElementFunction));

            var element = (GetCodeModel()).CodeElementFromPoint(textPoint, vsCMElement.vsCMElementClass);

            Assert.Equal("A", element.Name);
        }
Example #2
0
        public void TestCodeElementFromPointBetweenMembers()
        {
            var text     = CurrentDocument.GetTextAsync().Result;
            var tree     = CurrentDocument.GetSyntaxTreeAsync().Result;
            var position = text.ToString().IndexOf("protected virtual string MethodB");

            position--;
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint        = new MockTextPoint(virtualTreePoint, 4);

            Assert.Throws <COMException>(() =>
                                         CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementFunction));

            var element = CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementClass);

            Assert.Equal("A", element.Name);
        }
Example #3
0
        public void TestCodeElementFromPointBetweenMembers()
        {
            var text = CurrentDocument.GetTextAsync().Result;
            var tree = CurrentDocument.GetSyntaxTreeAsync().Result;
            var position = text.ToString().IndexOf("protected virtual string MethodB", StringComparison.Ordinal) - 1;
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint = new MockTextPoint(virtualTreePoint, 4);

            Assert.Throws<COMException>(() =>
                CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementFunction));

            var element = CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementClass);
            Assert.Equal("A", element.Name);
        }
Example #4
0
 public void TestCodeElementFromPoint()
 {
     var text = CurrentDocument.GetTextAsync().Result;
     var tree = CurrentDocument.GetSyntaxTreeAsync().Result;
     var position = text.ToString().IndexOf("DynamicMethod", StringComparison.Ordinal);
     var virtualTreePoint = new VirtualTreePoint(tree, text, position);
     var textPoint = new MockTextPoint(virtualTreePoint, 4);
     var scope = vsCMElement.vsCMElementFunction;
     var element = CodeModel.CodeElementFromPoint(textPoint, scope);
     Assert.Equal("DynamicMethod", element.Name);
 }