提交 a8251626 编写于 作者: H Heejae Chang

addressed PR feedbacks

上级 4154db45
......@@ -141,13 +141,7 @@ internal partial class BoundSequence
internal partial class BoundStatementList
{
protected override ImmutableArray<BoundNode> Children
{
get
{
System.Diagnostics.Debug.Assert(this.Kind == BoundKind.StatementList || this.Kind == BoundKind.Scope);
return StaticCast<BoundNode>.From(this.Statements);
}
}
protected override ImmutableArray<BoundNode> Children =>
(this.Kind == BoundKind.StatementList || this.Kind == BoundKind.Scope) ? StaticCast<BoundNode>.From(this.Statements) : ImmutableArray<BoundNode>.Empty;
}
}
......@@ -980,38 +980,34 @@ private CSharpSyntaxNode GetBindingRootOrInitializer(CSharpSyntaxNode node)
// if binding root is parameter, make it equal value
// we need to do this since node map doesn't contain bound node for parameter
var parameter = bindingRoot as ParameterSyntax;
if (parameter != null && parameter.Default?.FullSpan.Contains(node.Span) == true)
if (bindingRoot is ParameterSyntax parameter && parameter.Default?.FullSpan.Contains(node.Span) == true)
{
bindingRoot = parameter.Default;
return parameter.Default;
}
// if binding root is field variable declarator, make it initializer
// we need to do this since node map doesn't contain bound node for field/event variable declarator
var variableDeclarator = bindingRoot as VariableDeclaratorSyntax;
if (variableDeclarator != null && variableDeclarator.Initializer?.FullSpan.Contains(node.Span) == true)
if (bindingRoot is VariableDeclaratorSyntax variableDeclarator && variableDeclarator.Initializer?.FullSpan.Contains(node.Span) == true)
{
if (variableDeclarator.Parent?.Parent.IsKind(SyntaxKind.FieldDeclaration) == true ||
variableDeclarator.Parent?.Parent.IsKind(SyntaxKind.EventFieldDeclaration) == true)
{
bindingRoot = variableDeclarator.Initializer;
return variableDeclarator.Initializer;
}
}
// if binding root is enum member decleration, make it equal value
// we need to do this since node map doesn't contain bound node for enum member decl
var enumMember = bindingRoot as EnumMemberDeclarationSyntax;
if (enumMember != null && enumMember.EqualsValue?.FullSpan.Contains(node.Span) == true)
if (bindingRoot is EnumMemberDeclarationSyntax enumMember && enumMember.EqualsValue?.FullSpan.Contains(node.Span) == true)
{
bindingRoot = enumMember.EqualsValue;
return enumMember.EqualsValue;
}
// if binding root is property member decleration, make it equal value
// we need to do this since node map doesn't contain bound node for property initializer
var propertyMember = bindingRoot as PropertyDeclarationSyntax;
if (propertyMember != null && propertyMember.Initializer?.FullSpan.Contains(node.Span) == true)
if (bindingRoot is PropertyDeclarationSyntax propertyMember && propertyMember.Initializer?.FullSpan.Contains(node.Span) == true)
{
bindingRoot = propertyMember.Initializer;
return propertyMember.Initializer;
}
return bindingRoot;
......@@ -1336,8 +1332,6 @@ private CSharpSyntaxNode GetBindingRoot(CSharpSyntaxNode node)
{
Debug.Assert(node != null);
StatementSyntax enclosingStatement = null;
#if DEBUG
for (CSharpSyntaxNode current = node; current != this.Root; current = current.ParentOrStructuredTriviaParent)
{
......@@ -1348,10 +1342,9 @@ private CSharpSyntaxNode GetBindingRoot(CSharpSyntaxNode node)
for (CSharpSyntaxNode current = node; current != this.Root; current = current.ParentOrStructuredTriviaParent)
{
enclosingStatement = current as StatementSyntax;
if (enclosingStatement != null)
if (current is StatementSyntax)
{
return enclosingStatement;
return current;
}
}
......
......@@ -241,13 +241,14 @@ private IOperation CreateInternal(BoundNode boundNode)
private ImmutableArray<IOperation> GetIOperationChildren(BoundNode boundNode)
{
var boundNodeWithChildren = (IBoundNodeWithIOperationChildren)boundNode;
if (boundNodeWithChildren.Children.IsDefaultOrEmpty)
var children = boundNodeWithChildren.Children;
if (children.IsDefaultOrEmpty)
{
return ImmutableArray<IOperation>.Empty;
}
var builder = ArrayBuilder<IOperation>.GetInstance(boundNodeWithChildren.Children.Length);
foreach (BoundNode childNode in boundNodeWithChildren.Children)
var builder = ArrayBuilder<IOperation>.GetInstance(children.Length);
foreach (BoundNode childNode in children)
{
IOperation operation = Create(childNode);
if (operation == null)
......
......@@ -38,17 +38,17 @@ internal IArgument CreateArgumentOperation(ArgumentKind kind, IParameterSymbol p
var value = Create(expression);
// put argument syntax to argument operation
var argumentExist = value.Syntax?.Parent is ArgumentSyntax;
var argument = value.Syntax?.Parent as ArgumentSyntax;
// if argument syntax doesn't exist, this operation is implicit
return new CSharpArgument(kind,
parameter,
value,
semanticModel: _semanticModel,
syntax: argumentExist ? value.Syntax.Parent : value.Syntax,
syntax: argument ?? value.Syntax,
type: value.Type,
constantValue: default,
isImplicit: expression.WasCompilerGenerated || !argumentExist);
isImplicit: expression.WasCompilerGenerated || argument == null);
}
private IVariableDeclaration CreateVariableDeclaration(BoundLocalDeclaration boundLocalDeclaration, SyntaxNode syntax)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册