예제 #1
0
        public async Task HighlightEntireFile()
        {
            var code = @"
                namespace N1
                {
                    class C1 { int n = true; }
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary<string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());
            var regions = await controller.Highlight(new HighlightRequest() { FileName = "a.cs" });

            AssertSyntax(regions.Highlights, code, 0,
                Token("namespace", "keyword"),
                Token("N1", "identifier"),
                Token("{", "punctuation"),
                Token("class", "keyword"),
                Token("C1", "class name"),
                Token("{", "punctuation"),
                Token("int", "keyword"),
                Token("n", "identifier"),
                Token("=", "operator"),
                Token("true", "keyword"),
                Token(";", "punctuation"),
                Token("}", "punctuation"),
                Token("}", "punctuation"));
        }
예제 #2
0
        public async Task HighlightStringInterpolation()
        {
            var code = @"
                class C1
                {
                    string s = $""{5}"";
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());
            var regions    = await controller.Highlight(new HighlightRequest()
            {
                FileName = "a.cs"
            });

            AssertSyntax(regions.Highlights, code, 0,
                         Token("class", "keyword"),
                         Token("C1", "class name"),
                         Token("{", "punctuation"),
                         Token("string", "keyword"),
                         Token("s", "identifier"),
                         Token("=", "operator"),
                         Token("$\"", "string"),
                         Token("{", "punctuation"),
                         Token("5", "number"),
                         Token("}", "punctuation"),
                         Token("\"", "string"),
                         Token(";", "punctuation"),
                         Token("}", "punctuation"));
        }
예제 #3
0
        public async Task HighlightEntireFile()
        {
            var code = @"
                namespace N1
                {
                    class C1 { int n = true; }
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());
            var regions    = await controller.Highlight(new HighlightRequest()
            {
                FileName = "a.cs"
            });

            AssertSyntax(regions.Highlights, code, 0,
                         Token("namespace", "keyword"),
                         Token("N1", "identifier"),
                         Token("{", "punctuation"),
                         Token("class", "keyword"),
                         Token("C1", "class name"),
                         Token("{", "punctuation"),
                         Token("int", "keyword"),
                         Token("n", "identifier"),
                         Token("=", "operator"),
                         Token("true", "keyword"),
                         Token(";", "punctuation"),
                         Token("}", "punctuation"),
                         Token("}", "punctuation"));
        }
예제 #4
0
        public async Task HighlightExcludesUnwantedNames()
        {
            var code = @"
                namespace N1
                {
                    class C1 { int n = true; }
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());
            var regions    = await controller.Highlight(new HighlightRequest()
            {
                FileName = "a.cs", ExcludeClassifications = new [] { HighlightClassification.Name }
            });

            Assert.DoesNotContain(regions.Highlights, x => x.Kind.EndsWith(" name"));
        }
예제 #5
0
        public async Task HighlightStringInterpolation()
        {
            var code = @"
                class C1
                {
                    string s = $""{5}"";
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary<string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());            
            var regions = await controller.Highlight(new HighlightRequest() { FileName = "a.cs" });

            AssertSyntax(regions.Highlights, code, 0,
                Token("class", "keyword"),
                Token("C1", "class name"),
                Token("{", "punctuation"),
                Token("string", "keyword"),
                Token("s", "identifier"),
                Token("=", "operator"),
                Token("$\"", "string"),
                Token("{", "punctuation"),
                Token("5", "number"),
                Token("}", "punctuation"),
                Token("\"", "string"),
                Token(";", "punctuation"),
                Token("}", "punctuation"));
        }
예제 #6
0
        public async Task HighlightExcludesUnwantedNames()
        {
            var code = @"
                namespace N1
                {
                    class C1 { int n = true; }
                }
            ";

            var workspace = TestHelpers.CreateSimpleWorkspace(new Dictionary<string, string>
            {
                { "a.cs", code }
            });

            var controller = new OmnisharpController(workspace, new FakeOmniSharpOptions());
            var regions = await controller.Highlight(new HighlightRequest() { FileName = "a.cs", ExcludeClassifications = new [] { HighlightClassification.Name } });

            Assert.DoesNotContain(regions.Highlights, x => x.Kind.EndsWith(" name"));
        }