Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class ClassifiedResult
[ClassificationTypeNames.VerbatimStringLiteral] = SemanticHighlightClassification.VerbatimStringLiteral,
[ClassificationTypeNames.StringEscapeCharacter] = SemanticHighlightClassification.StringEscapeCharacter,
[ClassificationTypeNames.ClassName] = SemanticHighlightClassification.ClassName,
[ClassificationTypeNames.RecordName] = SemanticHighlightClassification.ClassName,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other option would be to map a separate classification for record names and have the clients deal with it. Which is fine, just need to know what to do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is fine IMHO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the only concern is that we'll need to do something different when struct records come out, but that's a concern for next year :).

[ClassificationTypeNames.DelegateName] = SemanticHighlightClassification.DelegateName,
[ClassificationTypeNames.EnumName] = SemanticHighlightClassification.EnumName,
[ClassificationTypeNames.InterfaceName] = SemanticHighlightClassification.InterfaceName,
Expand Down
40 changes: 39 additions & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/SemanticHighlightFacts.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.CodeAnalysis.Text;
using OmniSharp.Models.SemanticHighlight;
using OmniSharp.Models.V2;
Expand Down Expand Up @@ -222,6 +221,44 @@ static class C1
);
}

[Fact]
public async Task SemanticHighlightRecordName()
{
var testFile = new TestFile("a.cs", @"
R1 r1 = new R1(string.Empty, 1);
record R1(string S, int I);
");

var highlights = await GetSemanticHighlightsForFileAsync(testFile);

AssertSyntax(highlights, testFile.Content.Code, 0,
ClassName("R1"),
Local("r1"),
Operator("="),
Keyword("new"),
ClassName("R1"),
Punctuation("("),
Keyword("string"),
Operator("."),
Field("Empty", SemanticHighlightModifier.Static),
Punctuation(","),
Number("1"),
Punctuation(")"),
Punctuation(";"),

Keyword("record"),
ClassName("R1"),
Punctuation("("),
Keyword("string"),
Parameter("S"),
Punctuation(","),
Keyword("int"),
Parameter("I"),
Punctuation(")"),
Punctuation(";")
);
}

private Task<SemanticHighlightSpan[]> GetSemanticHighlightsForFileAsync(TestFile testFile)
{
return GetSemanticHighlightsAsync(testFile, range: null);
Expand Down Expand Up @@ -301,6 +338,7 @@ private static void AssertSyntax(SemanticHighlightSpan[] highlights, string code
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) ClassName(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.ClassName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Field(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.FieldName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Identifier(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.Identifier, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Parameter(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.ParameterName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) NamespaceName(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.NamespaceName, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) Keyword(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.Keyword, text, modifiers);
private static (SemanticHighlightClassification type, string text, SemanticHighlightModifier[] modifiers) ControlKeyword(string text, params SemanticHighlightModifier[] modifiers) => (SemanticHighlightClassification.ControlKeyword, text, modifiers);
Expand Down