зеркало из https://github.com/microsoft/Power-Fx.git
Make syntax localization util internal instead of private
This commit is contained in:
Родитель
de16049af3
Коммит
fd4ac1036a
|
@ -1,42 +1,42 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Microsoft.PowerFx.Core.Binding;
|
||||
using Microsoft.PowerFx.Core.Glue;
|
||||
using Microsoft.PowerFx.Syntax;
|
||||
using Microsoft.PowerFx.Types;
|
||||
|
||||
namespace Microsoft.PowerFx.Core
|
||||
{
|
||||
internal class ExpressionLocalizationHelper
|
||||
{
|
||||
internal static string ConvertExpression(string expressionText, RecordType parameters, BindingConfig bindingConfig, INameResolver resolver, IBinderGlue binderGlue, ParserOptions options, Features flags, bool toDisplay)
|
||||
{
|
||||
var targetLexer = toDisplay ? TexlLexer.GetLocalizedInstance(options?.Culture ?? CultureInfo.InvariantCulture) : TexlLexer.InvariantLexer;
|
||||
var sourceLexer = toDisplay ? TexlLexer.InvariantLexer : TexlLexer.GetLocalizedInstance(options?.Culture ?? CultureInfo.InvariantCulture);
|
||||
|
||||
var worklist = GetLocaleSpecificTokenConversions(expressionText, sourceLexer, targetLexer);
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Microsoft.PowerFx.Core.Binding;
|
||||
using Microsoft.PowerFx.Core.Glue;
|
||||
using Microsoft.PowerFx.Syntax;
|
||||
using Microsoft.PowerFx.Types;
|
||||
|
||||
namespace Microsoft.PowerFx.Core
|
||||
{
|
||||
internal class ExpressionLocalizationHelper
|
||||
{
|
||||
internal static string ConvertExpression(string expressionText, RecordType parameters, BindingConfig bindingConfig, INameResolver resolver, IBinderGlue binderGlue, ParserOptions options, Features flags, bool toDisplay)
|
||||
{
|
||||
var targetLexer = toDisplay ? TexlLexer.GetLocalizedInstance(options?.Culture ?? CultureInfo.InvariantCulture) : TexlLexer.InvariantLexer;
|
||||
var sourceLexer = toDisplay ? TexlLexer.InvariantLexer : TexlLexer.GetLocalizedInstance(options?.Culture ?? CultureInfo.InvariantCulture);
|
||||
|
||||
var worklist = GetLocaleSpecificTokenConversions(expressionText, sourceLexer, targetLexer);
|
||||
|
||||
var formula = new Formula(expressionText, toDisplay ? CultureInfo.InvariantCulture : options?.Culture ?? CultureInfo.InvariantCulture);
|
||||
|
||||
formula.EnsureParsed(options.GetParserFlags());
|
||||
|
||||
var binding = TexlBinding.Run(
|
||||
binderGlue,
|
||||
null,
|
||||
new Core.Entities.QueryOptions.DataSourceToQueryOptionsMap(),
|
||||
formula.ParseTree,
|
||||
resolver,
|
||||
bindingConfig,
|
||||
ruleScope: parameters?._type,
|
||||
updateDisplayNames: toDisplay,
|
||||
forceUpdateDisplayNames: toDisplay,
|
||||
features: flags);
|
||||
|
||||
foreach (var token in binding.NodesToReplace)
|
||||
formula.EnsureParsed(options.GetParserFlags());
|
||||
|
||||
var binding = TexlBinding.Run(
|
||||
binderGlue,
|
||||
null,
|
||||
new Core.Entities.QueryOptions.DataSourceToQueryOptionsMap(),
|
||||
formula.ParseTree,
|
||||
resolver,
|
||||
bindingConfig,
|
||||
ruleScope: parameters?._type,
|
||||
updateDisplayNames: toDisplay,
|
||||
forceUpdateDisplayNames: toDisplay,
|
||||
features: flags);
|
||||
|
||||
foreach (var token in binding.NodesToReplace)
|
||||
{
|
||||
worklist.Add(token.Key.Span, TexlLexer.EscapeName(token.Value));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace Microsoft.PowerFx.Core
|
|||
return ConvertExpression(expressionText, parameters, bindingConfig, resolver, binderGlue, new ParserOptions() { Culture = culture }, flags, toDisplay);
|
||||
}
|
||||
|
||||
private static IDictionary<Span, string> GetLocaleSpecificTokenConversions(string script, TexlLexer sourceLexer, TexlLexer targetLexer)
|
||||
internal static IDictionary<Span, string> GetLocaleSpecificTokenConversions(string script, TexlLexer sourceLexer, TexlLexer targetLexer)
|
||||
{
|
||||
var worklist = new Dictionary<Span, string>();
|
||||
|
||||
|
@ -104,4 +104,4 @@ namespace Microsoft.PowerFx.Core
|
|||
return worklist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче