提交 a037aede 编写于 作者: T Tomas Matousek

Rename SyntaxUtilities to LambdaUtilities

上级 4579de38
......@@ -522,7 +522,7 @@ private static BoundExpression ExtractCastInvocation(BoundCall invocation)
private UnboundLambda MakePairLambda(CSharpSyntaxNode node, QueryTranslationState state, RangeVariableSymbol x1, RangeVariableSymbol x2)
{
Debug.Assert(SyntaxUtilities.IsQueryPairLambda(node));
Debug.Assert(LambdaUtilities.IsQueryPairLambda(node));
LambdaBodyFactory bodyFactory = (LambdaSymbol lambdaSymbol, ref Binder lambdaBodyBinder, DiagnosticBag d) =>
{
......@@ -683,7 +683,7 @@ private UnboundLambda MakeQueryUnboundLambda(RangeVariableMap qvm, ImmutableArra
private UnboundLambda MakeQueryUnboundLambda(CSharpSyntaxNode node, QueryUnboundLambdaState state)
{
Debug.Assert(node is ExpressionSyntax || SyntaxUtilities.IsQueryPairLambda(node));
Debug.Assert(node is ExpressionSyntax || LambdaUtilities.IsQueryPairLambda(node));
var lambda = new UnboundLambda(node, state, hasErrors: false) { WasCompilerGenerated = true };
state.SetUnboundLambda(lambda);
return lambda;
......
......@@ -49,7 +49,7 @@ public BoundLambda(CSharpSyntaxNode syntax, BoundBlock body, ImmutableArray<Diag
Debug.Assert(
syntax.IsAnonymousFunction() || // lambda expressions
syntax is ExpressionSyntax && SyntaxFacts.IsLambdaBody(syntax) || // query lambdas
SyntaxUtilities.IsQueryPairLambda(syntax) // "pair" lambdas in queries
LambdaUtilities.IsQueryPairLambda(syntax) // "pair" lambdas in queries
);
}
......
......@@ -790,7 +790,7 @@
<Compile Include="Syntax\SyntaxEquivalence.cs" />
<Compile Include="Syntax\SyntaxExtensions.cs" />
<Compile Include="Syntax\SyntaxFactory.cs" />
<Compile Include="Syntax\SyntaxUtilities.cs" />
<Compile Include="Syntax\LambdaUtilities.cs" />
<Compile Include="Syntax\SyntaxFormatter.cs" />
<Compile Include="Syntax\SyntaxKind.cs" />
<Compile Include="Syntax\SyntaxKindEqualityComparer.cs" />
......@@ -893,4 +893,4 @@
<Import Project="..\..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -82,7 +82,7 @@ private static void AssertIsClosureScopeSyntax(CSharpSyntaxNode syntaxOpt)
return;
}
if (SyntaxUtilities.IsClosureScope(syntaxOpt))
if (LambdaUtilities.IsClosureScope(syntaxOpt))
{
return;
}
......
......@@ -924,7 +924,7 @@ private void GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int closure
lambdaOrLambdaBodySyntax = anonymousFunction.Body;
isLambdaBody = true;
}
else if (SyntaxUtilities.IsQueryPairLambda(syntax))
else if (LambdaUtilities.IsQueryPairLambda(syntax))
{
// "pair" query lambdas
lambdaOrLambdaBodySyntax = syntax;
......@@ -938,7 +938,7 @@ private void GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int closure
isLambdaBody = true;
}
Debug.Assert(!isLambdaBody || SyntaxUtilities.IsLambdaBody(lambdaOrLambdaBodySyntax));
Debug.Assert(!isLambdaBody || LambdaUtilities.IsLambdaBody(lambdaOrLambdaBodySyntax));
// determine lambda ordinal and calculate syntax offset:
lambdaOrdinal = _lambdaDebugInfoBuilder.Count;
......
......@@ -443,12 +443,12 @@ public new IEnumerable<Diagnostic> GetDiagnostics()
internal sealed override SyntaxNode GetCorrespondingLambdaBody(SyntaxNode body)
{
return SyntaxUtilities.GetCorrespondingLambdaBody(body, this);
return LambdaUtilities.GetCorrespondingLambdaBody(body, this);
}
internal override SyntaxNode GetLambda()
{
return SyntaxUtilities.GetLambda(this);
return LambdaUtilities.GetLambda(this);
}
#region Directives
......
......@@ -6,7 +6,7 @@
namespace Microsoft.CodeAnalysis.CSharp
{
internal partial class SyntaxUtilities
internal static class LambdaUtilities
{
/// <summary>
/// Returns true if the specified node represents a lambda.
......
......@@ -371,7 +371,7 @@ internal static bool IsStatementExpression(CSharpSyntaxNode syntax)
/// </summary>
public static bool IsLambdaBody(SyntaxNode node)
{
return SyntaxUtilities.IsLambdaBody(node);
return LambdaUtilities.IsLambdaBody(node);
}
}
}
\ No newline at end of file
......@@ -921,7 +921,7 @@
<Compile Include="Syntax\SyntaxTreeDiagnosticEnumerator.vb" />
<Compile Include="Syntax\SyntaxTriviaFunctions.vb" />
<Compile Include="Syntax\SyntaxTriviaListBuilder.vb" />
<Compile Include="Syntax\SyntaxUtilities.vb" />
<Compile Include="Syntax\LambdaUtilities.vb" />
<Compile Include="Syntax\TypeBlockSyntax.vb" />
<Compile Include="Syntax\TypeStatementSyntax.vb" />
<Compile Include="Syntax\VisualBasicWarningStateMap.vb" />
......
......@@ -307,7 +307,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
aggregate, source.RangeVariables)
' The lambda that will contain the nested query.
Dim letSelectorLambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetAggregateLambdaBody(aggregate),
Dim letSelectorLambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetAggregateLambdaBody(aggregate),
SynthesizedLambdaKind.AggregateQueryLambda,
ImmutableArray.Create(letSelectorParam))
......@@ -432,7 +432,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
aggregate, letOperator.RangeVariables)
' This lambda only contains non-user code. We associate it with the aggregate clause itself.
Debug.Assert(SyntaxUtilities.IsNonUserCodeQueryLambda(aggregate))
Debug.Assert(LambdaUtilities.IsNonUserCodeQueryLambda(aggregate))
Dim selectSelectorLambdaSymbol = Me.CreateQueryLambdaSymbol(aggregate,
SynthesizedLambdaKind.AggregateNonUserCodeQueryLambda,
ImmutableArray.Create(selectSelectorParam))
......@@ -603,7 +603,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
fromClauseSyntax, source.RangeVariables)
' An implicit selector is an identity (x => x) function that doesn't contain any user code.
SyntaxUtilities.IsNonUserCodeQueryLambda(fromClauseSyntax)
LambdaUtilities.IsNonUserCodeQueryLambda(fromClauseSyntax)
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(fromClauseSyntax,
SynthesizedLambdaKind.FromNonUserCodeQueryLambda,
ImmutableArray.Create(param))
......@@ -675,7 +675,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
clauseSyntax, source.RangeVariables)
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetSelectLambdaBody(clauseSyntax),
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetSelectLambdaBody(clauseSyntax),
SynthesizedLambdaKind.SelectQueryLambda,
ImmutableArray.Create(param))
......@@ -821,7 +821,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
variable, source.RangeVariables)
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetLetVariableLambdaBody(variable),
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetLetVariableLambdaBody(variable),
SynthesizedLambdaKind.LetVariableQueryLambda,
ImmutableArray.Create(param))
......@@ -1053,7 +1053,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
variable, source.RangeVariables)
Dim manySelectorLambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetFromOrAggregateVariableLambdaBody(variable),
Dim manySelectorLambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetFromOrAggregateVariableLambdaBody(variable),
SynthesizedLambdaKind.FromOrAggregateVariableQueryLambda,
ImmutableArray.Create(manySelectorParam))
......@@ -1248,29 +1248,29 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Select
lambdaSyntax = clauseSyntax
Debug.Assert(SyntaxUtilities.IsNonUserCodeQueryLambda(lambdaSyntax))
Debug.Assert(LambdaUtilities.IsNonUserCodeQueryLambda(lambdaSyntax))
Else
Select Case absorbNextOperator.Kind
Case SyntaxKind.AggregateClause
Dim firstVariable = DirectCast(absorbNextOperator, AggregateClauseSyntax).Variables.First
lambdaSyntax = SyntaxUtilities.GetFromOrAggregateVariableLambdaBody(firstVariable)
lambdaSyntax = LambdaUtilities.GetFromOrAggregateVariableLambdaBody(firstVariable)
lambdaKind = SynthesizedLambdaKind.AggregateQueryLambda
Case SyntaxKind.LetClause
Dim firstVariable = DirectCast(absorbNextOperator, LetClauseSyntax).Variables.First
lambdaSyntax = SyntaxUtilities.GetLetVariableLambdaBody(firstVariable)
lambdaSyntax = LambdaUtilities.GetLetVariableLambdaBody(firstVariable)
lambdaKind = SynthesizedLambdaKind.LetVariableQueryLambda
Case SyntaxKind.SelectClause
Dim selectClause = DirectCast(absorbNextOperator, SelectClauseSyntax)
lambdaSyntax = SyntaxUtilities.GetSelectLambdaBody(selectClause)
lambdaSyntax = LambdaUtilities.GetSelectLambdaBody(selectClause)
lambdaKind = SynthesizedLambdaKind.SelectQueryLambda
Case Else
Throw ExceptionUtilities.UnexpectedValue(absorbNextOperator.Kind)
End Select
Debug.Assert(SyntaxUtilities.IsLambdaBody(lambdaSyntax))
Debug.Assert(LambdaUtilities.IsLambdaBody(lambdaSyntax))
End If
End Sub
......@@ -1920,7 +1920,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
groupBy, source.RangeVariables)
Dim itemsLambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetGroupByItemsLambdaBody(groupBy),
Dim itemsLambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetGroupByItemsLambdaBody(groupBy),
SynthesizedLambdaKind.GroupByItemsQueryLambda,
ImmutableArray.Create(itemsParam))
......@@ -1964,7 +1964,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
groupBy, source.RangeVariables)
Dim keysLambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetGroupByKeysLambdaBody(groupBy),
Dim keysLambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetGroupByKeysLambdaBody(groupBy),
SynthesizedLambdaKind.GroupByKeysQueryLambda,
ImmutableArray.Create(keysParam))
......@@ -2171,7 +2171,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim groupParam As BoundLambdaParameterSymbol = CreateQueryLambdaParameterSymbol(StringConstants.ItAnonymous, 1,
groupType, clauseSyntax)
Debug.Assert(SyntaxUtilities.IsNonUserCodeQueryLambda(clauseSyntax))
Debug.Assert(LambdaUtilities.IsNonUserCodeQueryLambda(clauseSyntax))
Dim intoLambdaSymbol = Me.CreateQueryLambdaSymbol(clauseSyntax,
SynthesizedLambdaKind.GroupNonUserCodeQueryLambda,
ImmutableArray.Create(keyParam, groupParam))
......@@ -2370,7 +2370,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
condition, source.RangeVariables)
Debug.Assert(SyntaxUtilities.IsLambdaBody(condition))
Debug.Assert(LambdaUtilities.IsLambdaBody(condition))
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(condition,
SynthesizedLambdaKind.FilterConditionQueryLambda,
ImmutableArray.Create(param))
......@@ -2621,7 +2621,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
source.CompoundVariableType,
ordering.Expression, source.RangeVariables)
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(SyntaxUtilities.GetOrderingLambdaBody(ordering),
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(LambdaUtilities.GetOrderingLambdaBody(ordering),
SynthesizedLambdaKind.OrderingQueryLambda,
ImmutableArray.Create(param))
......@@ -3340,7 +3340,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
outer.CompoundVariableType,
join, outer.RangeVariables)
Dim outerKeyLambdaSymbol = parentBinder.CreateQueryLambdaSymbol(SyntaxUtilities.GetJoinLeftLambdaBody(join),
Dim outerKeyLambdaSymbol = parentBinder.CreateQueryLambdaSymbol(LambdaUtilities.GetJoinLeftLambdaBody(join),
SynthesizedLambdaKind.JoinLeftQueryLambda,
ImmutableArray.Create(outerKeyParam))
outerKeyBinder = New QueryLambdaBinder(outerKeyLambdaSymbol, joinSelectorRangeVariables)
......@@ -3350,7 +3350,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
inner.CompoundVariableType,
join, inner.RangeVariables)
Dim innerKeyLambdaSymbol = parentBinder.CreateQueryLambdaSymbol(SyntaxUtilities.GetJoinRightLambdaBody(join),
Dim innerKeyLambdaSymbol = parentBinder.CreateQueryLambdaSymbol(LambdaUtilities.GetJoinRightLambdaBody(join),
SynthesizedLambdaKind.JoinRightQueryLambda,
ImmutableArray.Create(innerKeyParam))
......@@ -3995,7 +3995,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' its special binding and Lookup/LookupNames behavior.
Dim aggregationLambdaSymbol = Me.ContainingBinder.CreateQueryLambdaSymbol(
If(SyntaxUtilities.GetAggregationLambdaBody(functionAggregationSyntax), functionAggregationSyntax),
If(LambdaUtilities.GetAggregationLambdaBody(functionAggregationSyntax), functionAggregationSyntax),
SynthesizedLambdaKind.AggregationQueryLambda,
ImmutableArray.Create(aggregationParam))
......@@ -4342,7 +4342,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
variableType,
syntax.AsClause)
Debug.Assert(SyntaxUtilities.IsNonUserCodeQueryLambda(syntax.AsClause))
Debug.Assert(LambdaUtilities.IsNonUserCodeQueryLambda(syntax.AsClause))
Dim lambdaSymbol = Me.CreateQueryLambdaSymbol(syntax.AsClause,
SynthesizedLambdaKind.ConversionNonUserCodeQueryLambda,
ImmutableArray.Create(param))
......
......@@ -36,9 +36,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Debug.Assert(
TypeOf Syntax Is LambdaExpressionSyntax OrElse
SyntaxUtilities.IsLambdaBody(Syntax) OrElse
LambdaUtilities.IsLambdaBody(Syntax) OrElse
Syntax.IsKind(SyntaxKind.AddressOfExpression) OrElse
SyntaxUtilities.IsNonUserCodeQueryLambda(Syntax) OrElse
LambdaUtilities.IsNonUserCodeQueryLambda(Syntax) OrElse
(DelegateRelaxation And ConversionKind.DelegateRelaxationLevelMask) <> ConversionKind.DelegateRelaxationLevelNone)
End Sub
#End If
......
......@@ -114,7 +114,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
End If
If SyntaxUtilities.IsClosureScope(syntaxOpt) Then
If LambdaUtilities.IsClosureScope(syntaxOpt) Then
Return
End If
......
......@@ -926,14 +926,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim lambdaExpression = TryCast(syntax, LambdaExpressionSyntax)
If lambdaExpression IsNot Nothing Then
lambdaOrLambdaBodySyntax = SyntaxUtilities.GetLambdaExpressionLambdaBody(lambdaExpression)
lambdaOrLambdaBodySyntax = LambdaUtilities.GetLambdaExpressionLambdaBody(lambdaExpression)
isLambdaBody = True
ElseIf syntax.IsKind(SyntaxKind.AddressOfExpression) Then
' Late-bound AddressOf operator creates a display class, unlike delegate relaxations.
' EnC is not supported in this case.
lambdaOrLambdaBodySyntax = syntax
isLambdaBody = False
ElseIf SyntaxUtilities.IsNonUserCodeQueryLambda(syntax)
ElseIf LambdaUtilities.IsNonUserCodeQueryLambda(syntax)
lambdaOrLambdaBodySyntax = syntax
isLambdaBody = False
Else
......@@ -942,7 +942,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
isLambdaBody = True
End If
Debug.Assert(Not isLambdaBody OrElse SyntaxUtilities.IsLambdaBody(lambdaOrLambdaBodySyntax))
Debug.Assert(Not isLambdaBody OrElse LambdaUtilities.IsLambdaBody(lambdaOrLambdaBodySyntax))
' determine lambda ordinal and calculate syntax offset
lambdaOrdinal = _lambdaDebugInfoBuilder.Count
......
......@@ -5,7 +5,7 @@ Imports System.Runtime.InteropServices
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend NotInheritable Class SyntaxUtilities
Friend NotInheritable Class LambdaUtilities
''' <summary>
''' Returns true if the specified node represents a lambda.
......
......@@ -678,11 +678,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Friend Overrides Function GetCorrespondingLambdaBody(body As SyntaxNode) As SyntaxNode
Return SyntaxUtilities.GetCorrespondingLambdaBody(body, Me)
Return LambdaUtilities.GetCorrespondingLambdaBody(body, Me)
End Function
Friend Overrides Function GetLambda() As SyntaxNode
Return SyntaxUtilities.GetLambda(Me)
Return LambdaUtilities.GetLambda(Me)
End Function
End Class
End Namespace
......@@ -766,7 +766,7 @@ End Class
''' of the same kind is mapped to a new node that belongs to the lambda body but is
''' different from the one that represents the new body.
'''
''' This handling is done in <see cref="SyntaxUtilities.GetCorrespondingLambdaBody(SyntaxNode, SyntaxNode)"/>
''' This handling is done in <see cref="LambdaUtilities.GetCorrespondingLambdaBody(SyntaxNode, SyntaxNode)"/>
''' </summary>
<Fact>
Public Sub SelectClauseCrossMatch()
......@@ -829,7 +829,7 @@ End Class
''' of the same kind is mapped to a new node that belongs to the lambda body but is
''' different from the one that represents the new body.
'''
''' This handling is done in <see cref="SyntaxUtilities.GetCorrespondingLambdaBody(SyntaxNode, SyntaxNode)"/>
''' This handling is done in <see cref="LambdaUtilities.GetCorrespondingLambdaBody(SyntaxNode, SyntaxNode)"/>
''' </summary>
<Fact>
Public Sub JoinClauseCrossMatch()
......
......@@ -84,8 +84,8 @@
<InternalsVisibleToTest Include="Roslyn.Services.UnitTests" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Compilers\CSharp\Portable\Syntax\SyntaxUtilities.cs">
<Link>InternalUtilities\SyntaxUtilities.cs</Link>
<Compile Include="..\..\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs">
<Link>InternalUtilities\LambdaUtilities.cs</Link>
</Compile>
<Compile Include="ChangeSignature\ChangeSignatureCodeRefactoringProvider.cs" />
<Compile Include="ChangeSignature\ChangeSignatureFormattingRule.cs" />
......
......@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
using CompilerSyntaxUtilities = Microsoft.CodeAnalysis.CSharp.SyntaxUtilities;
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue
{
......@@ -290,7 +289,7 @@ protected override SyntaxNode FindStatementAndPartner(SyntaxNode declarationBody
partnerOpt = null;
}
while (node != declarationBody && !StatementSyntaxComparer.HasLabel(node) && !CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node))
while (node != declarationBody && !StatementSyntaxComparer.HasLabel(node) && !LambdaUtilities.IsLambdaBodyStatementOrExpression(node))
{
node = node.Parent;
if (partnerOpt != null)
......@@ -389,7 +388,7 @@ private static TextSpan GetActiveSpan(ForEachStatementSyntax node, ForEachPart p
internal override bool IsClosureScope(SyntaxNode node)
{
return CompilerSyntaxUtilities.IsClosureScope(node);
return LambdaUtilities.IsClosureScope(node);
}
protected override SyntaxNode FindEnclosingLambdaBody(SyntaxNode containerOpt, SyntaxNode node)
......@@ -399,7 +398,7 @@ protected override SyntaxNode FindEnclosingLambdaBody(SyntaxNode containerOpt, S
while (node != root)
{
SyntaxNode body;
if (CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node, out body))
if (LambdaUtilities.IsLambdaBodyStatementOrExpression(node, out body))
{
return body;
}
......@@ -417,7 +416,7 @@ protected override SyntaxList<SyntaxNode> GetLambdaBodyExpressionsAndStatements(
protected override SyntaxNode GetPartnerLambdaBody(SyntaxNode oldBody, SyntaxNode newLambda)
{
return CompilerSyntaxUtilities.GetCorrespondingLambdaBody(oldBody, newLambda);
return LambdaUtilities.GetCorrespondingLambdaBody(oldBody, newLambda);
}
protected override Match<SyntaxNode> ComputeTopLevelMatch(SyntaxNode oldCompilationUnit, SyntaxNode newCompilationUnit)
......@@ -880,22 +879,22 @@ private static bool IsGetterToExpressionBodyTransformation(EditKind editKind, Sy
internal override bool ContainsLambda(SyntaxNode declaration)
{
return declaration.DescendantNodes().Any(CompilerSyntaxUtilities.IsLambda);
return declaration.DescendantNodes().Any(LambdaUtilities.IsLambda);
}
internal override bool IsLambda(SyntaxNode node)
{
return CompilerSyntaxUtilities.IsLambda(node);
return LambdaUtilities.IsLambda(node);
}
internal override bool TryGetLambdaBodies(SyntaxNode node, out SyntaxNode body1, out SyntaxNode body2)
{
return CompilerSyntaxUtilities.TryGetLambdaBodies(node, out body1, out body2);
return LambdaUtilities.TryGetLambdaBodies(node, out body1, out body2);
}
internal override SyntaxNode GetLambda(SyntaxNode lambdaBody)
{
return CompilerSyntaxUtilities.GetLambda(lambdaBody);
return LambdaUtilities.GetLambda(lambdaBody);
}
#endregion
......@@ -2613,7 +2612,7 @@ protected override List<SyntaxNode> GetExceptionHandlingAncestors(SyntaxNode nod
}
// stop at lambda:
if (CompilerSyntaxUtilities.IsLambda(node))
if (LambdaUtilities.IsLambda(node))
{
return result;
}
......@@ -2776,7 +2775,7 @@ private static SyntaxNode FindContainingStatementPart(SyntaxNode node)
return node;
}
if (CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node))
if (LambdaUtilities.IsLambdaBodyStatementOrExpression(node))
{
return node;
}
......
......@@ -5,7 +5,6 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
using CompilerSyntaxUtilities = Microsoft.CodeAnalysis.CSharp.SyntaxUtilities;
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue
{
......@@ -59,7 +58,7 @@ private IEnumerable<SyntaxNode> EnumerateNonRootChildren(SyntaxNode node)
{
foreach (var child in node.ChildNodes())
{
if (CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(child))
if (LambdaUtilities.IsLambdaBodyStatementOrExpression(child))
{
continue;
}
......@@ -105,7 +104,7 @@ private IEnumerable<SyntaxNode> EnumerateRootChildren(SyntaxNode root)
private bool DescendIntoChildren(SyntaxNode node)
{
return !CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node) && !HasLabel(node);
return !LambdaUtilities.IsLambdaBodyStatementOrExpression(node) && !HasLabel(node);
}
protected internal sealed override IEnumerable<SyntaxNode> GetDescendants(SyntaxNode node)
......@@ -125,9 +124,9 @@ protected internal sealed override IEnumerable<SyntaxNode> GetDescendants(Syntax
}
// TODO: avoid allocation of closure
foreach (var descendant in node.DescendantNodes(descendIntoChildren: c => !IsLeaf(c) && (c == node || !CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(c))))
foreach (var descendant in node.DescendantNodes(descendIntoChildren: c => !IsLeaf(c) && (c == node || !LambdaUtilities.IsLambdaBodyStatementOrExpression(c))))
{
if (!CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(descendant) && HasLabel(descendant))
if (!LambdaUtilities.IsLambdaBodyStatementOrExpression(descendant) && HasLabel(descendant))
{
yield return descendant;
}
......
......@@ -6,7 +6,6 @@
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
using CompilerSyntaxUtilities = Microsoft.CodeAnalysis.CSharp.SyntaxUtilities;
namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue
{
......@@ -274,7 +273,7 @@ public static bool IsAsyncMethodOrLambda(SyntaxNode declaration)
public static ImmutableArray<SyntaxNode> GetAwaitExpressions(SyntaxNode body)
{
// skip lambda bodies:
return ImmutableArray.CreateRange(body.DescendantNodesAndSelf(CompilerSyntaxUtilities.IsNotLambda).Where(n => n.IsKind(SyntaxKind.AwaitExpression)));
return ImmutableArray.CreateRange(body.DescendantNodesAndSelf(LambdaUtilities.IsNotLambda).Where(n => n.IsKind(SyntaxKind.AwaitExpression)));
}
public static ImmutableArray<SyntaxNode> GetYieldStatements(SyntaxNode body)
......
......@@ -118,8 +118,8 @@
<Import Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Compilers\VisualBasic\Portable\Syntax\SyntaxUtilities.vb">
<Link>InternalUtilities\SyntaxUtilities.vb</Link>
<Compile Include="..\..\Compilers\VisualBasic\Portable\Syntax\LambdaUtilities.vb">
<Link>InternalUtilities\LambdaUtilities.vb</Link>
</Compile>
<Compile Include="ChangeSignature\ChangeSignatureCodeRefactoringProvider.vb" />
<Compile Include="ChangeSignature\ChangeSignatureFormattingRule.vb" />
......
......@@ -2,7 +2,6 @@
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports CompilerSyntaxUtilities = Microsoft.CodeAnalysis.VisualBasic.SyntaxUtilities
Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
......@@ -75,7 +74,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
For Each child In node.ChildNodes()
If CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(child) Then
If LambdaUtilities.IsLambdaBodyStatementOrExpression(child) Then
Continue For
End If
......@@ -103,17 +102,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End If
' TODO: avoid allocation of closure
For Each descendant In rootChild.DescendantNodes(descendIntoChildren:=Function(c) Not IsLeaf(c) AndAlso (c Is rootChild OrElse Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(c)))
If Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(descendant) AndAlso HasLabel(descendant) Then
For Each descendant In rootChild.DescendantNodes(descendIntoChildren:=Function(c) Not IsLeaf(c) AndAlso (c Is rootChild OrElse Not LambdaUtilities.IsLambdaBodyStatementOrExpression(c)))
If Not LambdaUtilities.IsLambdaBodyStatementOrExpression(descendant) AndAlso HasLabel(descendant) Then
Yield descendant
End If
Next
Next
Else
' TODO: avoid allocation of closure
Dim descendants = node.DescendantNodes(descendIntoChildren:=Function(c) Not IsLeaf(c) AndAlso (c Is node OrElse Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(c)))
Dim descendants = node.DescendantNodes(descendIntoChildren:=Function(c) Not IsLeaf(c) AndAlso (c Is node OrElse Not LambdaUtilities.IsLambdaBodyStatementOrExpression(c)))
For Each descendant In descendants
If Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(descendant) AndAlso HasLabel(descendant) Then
If Not LambdaUtilities.IsLambdaBodyStatementOrExpression(descendant) AndAlso HasLabel(descendant) Then
Yield descendant
End If
Next
......@@ -121,7 +120,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End Function
Private Function DescendIntoChildren(node As SyntaxNode) As Boolean
Return Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node) AndAlso Not HasLabel(node)
Return Not LambdaUtilities.IsLambdaBodyStatementOrExpression(node) AndAlso Not HasLabel(node)
End Function
#End Region
......
......@@ -4,14 +4,13 @@ Imports System.Collections.Immutable
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports CompilerSyntaxUtilities = Microsoft.CodeAnalysis.VisualBasic.SyntaxUtilities
Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
Friend NotInheritable Class SyntaxUtilities
<Conditional("DEBUG")>
Public Shared Sub AssertIsBody(syntax As SyntaxNode, allowLambda As Boolean)
' lambda/query
If CompilerSyntaxUtilities.IsLambdaBody(syntax) Then
If LambdaUtilities.IsLambdaBody(syntax) Then
Debug.Assert(allowLambda)
Debug.Assert(TypeOf syntax Is ExpressionSyntax OrElse TypeOf syntax Is LambdaHeaderSyntax)
Return
......@@ -152,7 +151,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
Public Shared Function GetAwaitExpressions(body As SyntaxNode) As ImmutableArray(Of SyntaxNode)
' skip lambda bodies
Return ImmutableArray.CreateRange(body.DescendantNodes(AddressOf CompilerSyntaxUtilities.IsNotLambda).
Return ImmutableArray.CreateRange(body.DescendantNodes(AddressOf LambdaUtilities.IsNotLambda).
Where(Function(n) n.IsKind(SyntaxKind.AwaitExpression)))
End Function
......
......@@ -10,7 +10,6 @@ Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports CompilerSyntaxUtilities = Microsoft.CodeAnalysis.VisualBasic.SyntaxUtilities
Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
<ExportLanguageService(GetType(IEditAndContinueAnalyzer), LanguageNames.VisualBasic), [Shared]>
......@@ -423,7 +422,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
While node IsNot declarationBody AndAlso
Not StatementSyntaxComparer.HasLabel(node) AndAlso
Not CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node)
Not LambdaUtilities.IsLambdaBodyStatementOrExpression(node)
node = node.Parent
If partnerOpt IsNot Nothing Then
......@@ -449,7 +448,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End Function
Friend Overrides Function IsClosureScope(node As SyntaxNode) As Boolean
Return CompilerSyntaxUtilities.IsClosureScope(node)
Return LambdaUtilities.IsClosureScope(node)
End Function
Protected Overrides Function FindEnclosingLambdaBody(containerOpt As SyntaxNode, node As SyntaxNode) As SyntaxNode
......@@ -457,7 +456,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
While node IsNot root
Dim body As SyntaxNode = Nothing
If CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node, body) Then
If LambdaUtilities.IsLambdaBodyStatementOrExpression(node, body) Then
Return body
End If
......@@ -468,7 +467,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End Function
Protected Overrides Function GetPartnerLambdaBody(oldBody As SyntaxNode, newLambda As SyntaxNode) As SyntaxNode
Return CompilerSyntaxUtilities.GetCorrespondingLambdaBody(oldBody, newLambda)
Return LambdaUtilities.GetCorrespondingLambdaBody(oldBody, newLambda)
End Function
Protected Overrides Function ComputeTopLevelMatch(oldCompilationUnit As SyntaxNode, newCompilationUnit As SyntaxNode) As Match(Of SyntaxNode)
......@@ -931,23 +930,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End Function
Friend Overrides Function ContainsLambda(declaration As SyntaxNode) As Boolean
Return declaration.DescendantNodes().Any(AddressOf CompilerSyntaxUtilities.IsLambda)
Return declaration.DescendantNodes().Any(AddressOf LambdaUtilities.IsLambda)
End Function
Friend Overrides Function IsLambda(node As SyntaxNode) As Boolean
Return CompilerSyntaxUtilities.IsLambda(node)
Return LambdaUtilities.IsLambda(node)
End Function
Friend Overrides Function TryGetLambdaBodies(node As SyntaxNode, ByRef body1 As SyntaxNode, ByRef body2 As SyntaxNode) As Boolean
Return CompilerSyntaxUtilities.TryGetLambdaBodies(node, body1, body2)
Return LambdaUtilities.TryGetLambdaBodies(node, body1, body2)
End Function
Friend Overrides Function GetLambda(lambdaBody As SyntaxNode) As SyntaxNode
Return CompilerSyntaxUtilities.GetLambda(lambdaBody)
Return LambdaUtilities.GetLambda(lambdaBody)
End Function
Protected Overrides Function GetLambdaBodyExpressionsAndStatements(lambdaBody As SyntaxNode) As SyntaxList(Of SyntaxNode)
Return CompilerSyntaxUtilities.GetLambdaBodyExpressionsAndStatements(lambdaBody)
Return LambdaUtilities.GetLambdaBodyExpressionsAndStatements(lambdaBody)
End Function
#End Region
......@@ -2694,7 +2693,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
End Select
' stop at lambda
If CompilerSyntaxUtilities.IsLambda(node) Then
If LambdaUtilities.IsLambda(node) Then
Exit While
End If
......@@ -2813,7 +2812,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
Return node
End Select
If CompilerSyntaxUtilities.IsLambdaBodyStatementOrExpression(node) Then
If LambdaUtilities.IsLambdaBodyStatementOrExpression(node) Then
Return node
End If
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册