-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Update document highlighting to follow new pattern for embedded language extensibility. #61817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6995bb9
5525284
5478e19
e88c25e
1c7fb01
332e27b
ff32144
90049f7
0234a7b
7a41231
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,12 @@ | |
| namespace Microsoft.CodeAnalysis.Editor.CSharp.EmbeddedLanguages | ||
| { | ||
| [ExportEmbeddedLanguageBraceMatcher( | ||
| PredefinedEmbeddedLanguageBraceMatcherNames.Json, LanguageNames.CSharp, supportsUnannotatedAPIs: true, "Json"), Shared] | ||
| internal sealed class CSharpJsonEmbeddedLanguageBraceMatcher : | ||
| AbstractJsonEmbeddedLanguageBraceMatcher | ||
| PredefinedEmbeddedLanguageNames.Json, LanguageNames.CSharp, supportsUnannotatedAPIs: true, "Json"), Shared] | ||
| internal sealed class CSharpJsonBraceMatcher : AbstractJsonBraceMatcher | ||
| { | ||
| [ImportingConstructor] | ||
| [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| public CSharpJsonEmbeddedLanguageBraceMatcher() | ||
| public CSharpJsonBraceMatcher() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to a simpler and more consistent naming pattern. Instead of repeating 'EmbeddedLanguage' in teh name, we just state the name of the embedded language. Regex/Json are already clearly embedded langauges, so this cut down on verbosity everywhere. |
||
| : base(CSharpEmbeddedLanguagesProvider.Info) | ||
| { | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Composition; | ||
| using Microsoft.CodeAnalysis.CSharp.EmbeddedLanguages.LanguageServices; | ||
| using Microsoft.CodeAnalysis.DocumentHighlighting; | ||
| using Microsoft.CodeAnalysis.Features.EmbeddedLanguages.RegularExpressions.LanguageServices; | ||
| using Microsoft.CodeAnalysis.Host.Mef; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.CSharp.Features.EmbeddedLanguages | ||
| { | ||
| [ExtensionOrder(Before = PredefinedEmbeddedLanguageNames.Json)] | ||
| [ExportEmbeddedLanguageDocumentHighlighter( | ||
| PredefinedEmbeddedLanguageNames.Regex, LanguageNames.CSharp, supportsUnannotatedAPIs: true, "Regex", "Regexp"), Shared] | ||
| internal class CSharpRegexDocumentHighlighter : AbstractRegexDocumentHighlighter | ||
| { | ||
| [ImportingConstructor] | ||
| [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| public CSharpRegexDocumentHighlighter() | ||
| : base(CSharpEmbeddedLanguagesProvider.Info) | ||
| { | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.CodeAnalysis.EmbeddedLanguages; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.DocumentHighlighting | ||
| { | ||
| /// <summary> | ||
| /// Use this attribute to export a <see cref="IEmbeddedLanguageDocumentHighlighter"/>. | ||
| /// </summary> | ||
| internal class ExportEmbeddedLanguageDocumentHighlighterAttribute : ExportEmbeddedLanguageFeatureServiceAttribute | ||
| { | ||
| public ExportEmbeddedLanguageDocumentHighlighterAttribute( | ||
| string name, string language, params string[] identifiers) | ||
| : this(name, language, supportsUnannotatedAPIs: false, identifiers) | ||
| { | ||
| } | ||
|
|
||
| public ExportEmbeddedLanguageDocumentHighlighterAttribute( | ||
| string name, string language, bool supportsUnannotatedAPIs, params string[] identifiers) | ||
| : base(typeof(IEmbeddedLanguageDocumentHighlighter), name, language, supportsUnannotatedAPIs, identifiers) | ||
| { | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Collections.Immutable; | ||
| using System.Threading; | ||
| using Microsoft.CodeAnalysis.EmbeddedLanguages; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.DocumentHighlighting | ||
| { | ||
| /// <inheritdoc cref="IDocumentHighlightsService"/> | ||
| internal interface IEmbeddedLanguageDocumentHighlighter : IEmbeddedLanguageFeatureService | ||
| { | ||
| /// <inheritdoc cref="IDocumentHighlightsService.GetDocumentHighlightsAsync"/> | ||
| ImmutableArray<DocumentHighlights> GetDocumentHighlights( | ||
| Document document, | ||
| SemanticModel semanticModel, | ||
| SyntaxToken token, | ||
| int position, | ||
| HighlightingOptions options, | ||
| CancellationToken cancellationToken); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of having names for each embeded-language/feature-name pair, we just have the names of hte embedded languages once.