提交 b2193a2d 编写于 作者: C Cyrus Najmabadi

Refactor things between workspace/features.

上级 d88d013a
......@@ -4,7 +4,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics
{
internal static class DiagnosticCategory
{
public static readonly string Style = FeaturesResources.Style;
public static readonly string Style = WorkspacesResources.Style;
public static readonly string EditAndContinue = FeaturesResources.Edit_and_Continue2;
public static readonly string Compiler = FeaturesResources.Compiler1;
}
......
......@@ -2981,15 +2981,6 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Style.
/// </summary>
internal static string Style {
get {
return ResourceManager.GetString("Style", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Summary:.
/// </summary>
......
......@@ -733,9 +733,6 @@ Do you want to continue?</value>
<data name="Edit_and_Continue2" xml:space="preserve">
<value>Edit and Continue</value>
</data>
<data name="Style" xml:space="preserve">
<value>Style</value>
</data>
<data name="Suppress_0" xml:space="preserve">
<value>Suppress {0}</value>
</data>
......
......@@ -20,7 +20,7 @@ internal abstract class AbstractValidateEmbeddedLanguageStringDiagnosticAnalyzer
foreach (var language in embeddedLanguageProvider.GetEmbeddedLanguages())
{
var analyzer = language.GetDiagnosticAnalyzer(DiagnosticCategory.Style);
var analyzer = language.DiagnosticAnalyzer;
if (analyzer != null)
{
analyzers.Add(analyzer);
......
......@@ -1028,11 +1028,6 @@ Chcete pokračovat?</target>
<target state="translated">Upravit a pokračovat</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Styl</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Potlačit {0}</target>
......
......@@ -1028,11 +1028,6 @@ Möchten Sie fortfahren?</target>
<target state="translated">Bearbeiten und Fortfahren</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Stil</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">{0} unterdrücken</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">Editar y continuar</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Estilo</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Suprimir {0}</target>
......
......@@ -1028,11 +1028,6 @@ Voulez-vous continuer ?</target>
<target state="translated">Modifier et continuer</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Style</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Supprimer {0}</target>
......
......@@ -1028,11 +1028,6 @@ Continuare?</target>
<target state="translated">Modifica e continuazione</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Stile</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Elimina {0}</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">エディット コンティニュ</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">スタイル</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">{0} の非表示</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">편집하며 계속하기</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">스타일</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">{0}을(를) 표시하지 않음</target>
......
......@@ -1028,11 +1028,6 @@ Czy chcesz kontynuować?</target>
<target state="translated">Edytuj i kontynuuj</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Styl</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Pomiń element {0}</target>
......
......@@ -1028,11 +1028,6 @@ Deseja continuar?</target>
<target state="translated">Editar e Continuar</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Estilo</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Suprimir {0}</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">Операция "Изменить и продолжить"</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Стиль</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">Скрыть {0}</target>
......
......@@ -1028,11 +1028,6 @@ Devam etmek istiyor musunuz?</target>
<target state="translated">Düzenle ve Devam Et</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">Stil</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">{0} eylemini bastır</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">编辑并继续</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">样式</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">取消 {0}</target>
......
......@@ -1028,11 +1028,6 @@ Do you want to continue?</source>
<target state="translated">編輯並繼續</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="translated">樣式</target>
<note />
</trans-unit>
<trans-unit id="Suppress_0">
<source>Suppress {0}</source>
<target state="translated">隱藏 {0}</target>
......
......@@ -20,7 +20,6 @@ internal class JsonDiagnosticAnalyzer : IEmbeddedDiagnosticAnalyzer
private readonly DiagnosticDescriptor _descriptor;
public JsonDiagnosticAnalyzer(
string style,
int stringLiteralKind,
ISyntaxFactsService syntaxFacts,
ISemanticFactsService semanticFacts,
......@@ -31,10 +30,10 @@ internal class JsonDiagnosticAnalyzer : IEmbeddedDiagnosticAnalyzer
_semanticFacts = semanticFacts;
_virtualCharService = virtualCharService;
_descriptor = new DiagnosticDescriptor("IDE0047",
_descriptor = new DiagnosticDescriptor("JSON001",
new LocalizableResourceString(nameof(WorkspacesResources.JSON_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)),
new LocalizableResourceString(nameof(WorkspacesResources.JSON_issue_0), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)),
style,
WorkspacesResources.Style,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
......
......@@ -10,6 +10,7 @@
namespace Microsoft.CodeAnalysis.EmbeddedLanguages.Json.LanguageServices
{
using System.Diagnostics;
using static EmbeddedSyntaxHelpers;
using JsonToken = EmbeddedSyntaxToken<JsonKind>;
......@@ -19,12 +20,14 @@ internal class JsonEmbeddedClassifier : IEmbeddedClassifier
{
private static ObjectPool<Visitor> _visitorPool = new ObjectPool<Visitor>(() => new Visitor());
private readonly int _stringLiteralKind;
private readonly ISyntaxFactsService _syntaxFacts;
private readonly ISemanticFactsService _semanticFacts;
private readonly IVirtualCharService _virtualCharService;
public JsonEmbeddedClassifier(ISyntaxFactsService syntaxFacts, ISemanticFactsService semanticFacts, IVirtualCharService virtualCharService)
public JsonEmbeddedClassifier(int stringLiteralKind, ISyntaxFactsService syntaxFacts, ISemanticFactsService semanticFacts, IVirtualCharService virtualCharService)
{
_stringLiteralKind = stringLiteralKind;
_syntaxFacts = syntaxFacts;
_semanticFacts = semanticFacts;
_virtualCharService = virtualCharService;
......@@ -34,6 +37,8 @@ public JsonEmbeddedClassifier(ISyntaxFactsService syntaxFacts, ISemanticFactsSer
Workspace workspace, SyntaxToken token, SemanticModel semanticModel, ArrayBuilder<ClassifiedSpan> result,
CancellationToken cancellationToken)
{
Debug.Assert(token.RawKind == _stringLiteralKind);
if (!workspace.Options.GetOption(JsonOptions.ColorizeJsonPatterns, token.Language))
{
return;
......
......@@ -8,31 +8,18 @@ namespace Microsoft.CodeAnalysis.EmbeddedLanguages.Json.LanguageServices
{
internal class JsonEmbeddedLanguage : IEmbeddedLanguage
{
private readonly JsonEmbeddedClassifier _classifier;
private readonly int _stringLiteralKind;
private readonly ISyntaxFactsService _syntaxFacts;
private readonly ISemanticFactsService _semanticFacts;
private readonly IVirtualCharService _virtualCharService;
public JsonEmbeddedLanguage(
int stringLiteralKind,
ISyntaxFactsService syntaxFacts,
ISemanticFactsService semanticFacts,
IVirtualCharService virtualCharService)
{
_stringLiteralKind = stringLiteralKind;
_syntaxFacts = syntaxFacts;
_semanticFacts = semanticFacts;
_virtualCharService = virtualCharService;
_classifier = new JsonEmbeddedClassifier(syntaxFacts, semanticFacts, virtualCharService);
Classifier = new JsonEmbeddedClassifier(stringLiteralKind, syntaxFacts, semanticFacts, virtualCharService);
DiagnosticAnalyzer = new JsonDiagnosticAnalyzer(stringLiteralKind, syntaxFacts, semanticFacts, virtualCharService);
}
public IEmbeddedBraceMatcher BraceMatcher => JsonEmbeddedBraceMatcher.Instance;
public IEmbeddedClassifier Classifier => _classifier;
public IEmbeddedDiagnosticAnalyzer GetDiagnosticAnalyzer(string style)
=> new JsonDiagnosticAnalyzer(style, _stringLiteralKind, _syntaxFacts, _semanticFacts, _virtualCharService);
public IEmbeddedClassifier Classifier { get; }
public IEmbeddedDiagnosticAnalyzer DiagnosticAnalyzer { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices
{
internal interface IEmbeddedLanguage
{
IEmbeddedBraceMatcher BraceMatcher { get; }
IEmbeddedClassifier Classifier { get; }
IEmbeddedDiagnosticAnalyzer GetDiagnosticAnalyzer(string style);
IEmbeddedDiagnosticAnalyzer DiagnosticAnalyzer { get; }
}
}
......@@ -1557,6 +1557,15 @@ internal class WorkspacesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Style.
/// </summary>
internal static string Style {
get {
return ResourceManager.GetString("Style", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Suggestion.
/// </summary>
......
......@@ -784,4 +784,7 @@
<data name="JSON_issue_0" xml:space="preserve">
<value>JSON issue: {0}</value>
</data>
<data name="Style" xml:space="preserve">
<value>Style</value>
</data>
</root>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -1082,6 +1082,11 @@
<target state="new">JSON issue: {0}</target>
<note />
</trans-unit>
<trans-unit id="Style">
<source>Style</source>
<target state="new">Style</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册