File: VBAutoCompleteTest.cs

package info (click to toggle)
mono 5.18.0.240%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,253,216 kB
  • sloc: cs: 10,925,936; xml: 2,804,987; ansic: 643,970; cpp: 120,384; perl: 59,272; asm: 21,383; sh: 20,162; makefile: 18,157; python: 4,715; pascal: 924; sql: 859; sed: 16; php: 1
file content (155 lines) | stat: -rw-r--r-- 7,459 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.

using System.Web.Razor.Generator;
using System.Web.Razor.Parser;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Resources;
using System.Web.Razor.Test.Framework;
using System.Web.Razor.Text;
using System.Web.Razor.Tokenizer.Symbols;
using Xunit;

namespace System.Web.Razor.Test.Parser.VB
{
    public class VBAutoCompleteTest : VBHtmlCodeParserTestBase
    {
        [Fact]
        public void FunctionsDirective_AutoComplete_At_EOF()
        {
            ParseBlockTest("@Functions",
                new FunctionsBlock(
                    Factory.CodeTransition("@")
                           .Accepts(AcceptedCharacters.None),
                    Factory.MetaCode("Functions")
                           .Accepts(AcceptedCharacters.None),
                    Factory.EmptyVB()
                           .AsFunctionsBody()
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)
                           {
                               AutoCompleteString = SyntaxConstants.VB.EndFunctionsKeyword
                           })),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Functions", "End Functions"),
                    1, 0, 1));
        }

        [Fact]
        public void HelperDirective_AutoComplete_At_EOF()
        {
            ParseBlockTest("@Helper Strong(value As String)",
                new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(value As String)", 8, 0, 8), headerComplete: true),
                    Factory.CodeTransition(),
                    Factory.MetaCode("Helper ")
                           .Accepts(AcceptedCharacters.None),
                    Factory.Code("Strong(value As String)")
                           .Hidden()
                           .Accepts(AcceptedCharacters.None)
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndHelperKeyword }),
                    new StatementBlock()),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
                    1, 0, 1));
        }

        [Fact]
        public void SectionDirective_AutoComplete_At_EOF()
        {
            ParseBlockTest("@Section Header",
                new SectionBlock(new SectionCodeGenerator("Header"),
                    Factory.CodeTransition(),
                    Factory.MetaCode("Section Header")
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndSectionKeyword }),
                    new MarkupBlock()),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Section", "End Section"),
                    1, 0, 1));
        }

        [Fact]
        public void VerbatimBlock_AutoComplete_At_EOF()
        {
            ParseBlockTest("@Code",
                new StatementBlock(
                    Factory.CodeTransition(),
                    Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
                    Factory.Span(SpanKind.Code, new VBSymbol(5, 0, 5, String.Empty, VBSymbolType.Unknown))
                           .With(new StatementCodeGenerator())
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndCodeKeyword })),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Code", "End Code"),
                    1, 0, 1));
        }

        [Fact]
        public void FunctionsDirective_AutoComplete_At_StartOfFile()
        {
            ParseBlockTest(@"@Functions
foo",
                new FunctionsBlock(
                    Factory.CodeTransition("@").Accepts(AcceptedCharacters.None),
                    Factory.MetaCode("Functions").Accepts(AcceptedCharacters.None),
                    Factory.Code("\r\nfoo")
                           .AsFunctionsBody()
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString)
                           {
                               AutoCompleteString = SyntaxConstants.VB.EndFunctionsKeyword
                           })),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Functions", "End Functions"),
                    1, 0, 1));
        }

        [Fact]
        public void HelperDirective_AutoComplete_At_StartOfFile()
        {
            ParseBlockTest(@"@Helper Strong(value As String)
Foo",
                new HelperBlock(new HelperCodeGenerator(new LocationTagged<string>("Strong(value As String)", 8, 0, 8), headerComplete: true),
                    Factory.CodeTransition(),
                    Factory.MetaCode("Helper ")
                           .Accepts(AcceptedCharacters.None),
                    Factory.Code("Strong(value As String)")
                           .Hidden()
                           .Accepts(AcceptedCharacters.None)
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndHelperKeyword }),
                    new StatementBlock(
                        Factory.Code("\r\nFoo").AsStatement())),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Helper", "End Helper"),
                    1, 0, 1));
        }

        [Fact]
        public void SectionDirective_AutoComplete_At_StartOfFile()
        {
            ParseBlockTest(@"@Section Header
Foo",
                new SectionBlock(new SectionCodeGenerator("Header"),
                    Factory.CodeTransition(),
                    Factory.MetaCode("Section Header")
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndSectionKeyword }),
                    new MarkupBlock(
                        Factory.Markup("\r\nFoo")
                               .With(new MarkupCodeGenerator()))),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Section", "End Section"),
                    1, 0, 1));
        }

        [Fact]
        public void VerbatimBlock_AutoComplete_At_StartOfFile()
        {
            ParseBlockTest(@"@Code
Foo",
                new StatementBlock(
                    Factory.CodeTransition(),
                    Factory.MetaCode("Code").Accepts(AcceptedCharacters.None),
                    Factory.Code("\r\nFoo")
                           .AsStatement()
                           .With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = SyntaxConstants.VB.EndCodeKeyword })),
                new RazorError(
                    String.Format(RazorResources.ParseError_BlockNotTerminated, "Code", "End Code"),
                    1, 0, 1));
        }
    }
}