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

Working code.

上级 b4f56155
......@@ -13,7 +13,7 @@ public CSharpBinaryExpressionWrapper()
{
}
protected override SyntaxTriviaList GetNewLineBeforeOperatorTrivia(SyntaxTriviaList newLine)
public override SyntaxTriviaList GetNewLineBeforeOperatorTrivia(SyntaxTriviaList newLine)
=> newLine;
}
}
......@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp.Editor.Wrapping.SeparatedSyntaxList;
using Microsoft.CodeAnalysis.Editor.CSharp.Wrapping.BinaryExpression;
using Microsoft.CodeAnalysis.Editor.CSharp.Wrapping.Call;
using Microsoft.CodeAnalysis.Editor.Wrapping;
namespace Microsoft.CodeAnalysis.Editor.CSharp.Wrapping
......@@ -16,7 +17,8 @@ internal class CSharpWrappingCodeRefactoringProvider : AbstractWrappingCodeRefac
ImmutableArray.Create<ISyntaxWrapper>(
new CSharpArgumentWrapper(),
new CSharpParameterWrapper(),
new CSharpBinaryExpressionWrapper());
new CSharpBinaryExpressionWrapper(),
new CSharpCallWrapper());
public CSharpWrappingCodeRefactoringProvider()
: base(s_wrappers)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression;
using Microsoft.CodeAnalysis.Editor.Wrapping.Call;
namespace Microsoft.CodeAnalysis.Editor.CSharp.Wrapping.Call
{
internal class CSharpCallWrapper : AbstractCallWrapper<
ExpressionSyntax,
NameSyntax,
MemberAccessExpressionSyntax,
InvocationExpressionSyntax,
ElementAccessExpressionSyntax,
BaseArgumentListSyntax>
{
public CSharpCallWrapper()
: base(CSharpSyntaxFactsService.Instance)
{
}
public override SyntaxTriviaList GetNewLineBeforeOperatorTrivia(SyntaxTriviaList newLine)
=> newLine;
}
}
......@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.Wrapping.BinaryExpression
{
internal partial class AbstractBinaryExpressionWrapper<TBinaryExpressionSyntax>
{
private class BinaryExpressionCodeActionComputer :
private class BinaryExpressionCodeActionComputer :
AbstractCodeActionComputer<AbstractBinaryExpressionWrapper>
{
private readonly ImmutableArray<SyntaxNodeOrToken> _exprsAndOperators;
......
......@@ -25,15 +25,15 @@ internal abstract partial class AbstractCallWrapper : AbstractSyntaxWrapper
/// <summary>
/// Finds and wraps code of the form:
/// <c>
/// expr.M1(...).P1.M2(...).P2.I1[...]
/// expr.P1.M1(...).P2.M2(...).P3.I1[...]
/// </c>
///
/// into
///
/// <c>
/// expr.M1(...).P1
/// .M2(...).P2
/// .I1[...]
/// expr.P1.M1(...)
/// .P2.M2(...)
/// .P3.I1[...]
/// </c>
/// </summary>
internal abstract partial class AbstractCallWrapper<
......@@ -92,27 +92,30 @@ internal abstract partial class AbstractCallWrapper<
// i.e. if we only have `this.Goo(...)` there's nothing to wrap. However, we can
// wrap when we have `this.Goo(...).Bar(...)`. Grab the chunks of `.Name(...)` as
// that's what we're going to be wrapping/aligning.
//
var chunks = GetChunks(node);
if (chunks.Length <= 1)
var callChunks = GetCallChunks(node);
if (callChunks.Length <= 1)
{
return null;
}
foreach (var chunk in chunks)
// If any of these chunk parts are unformattable, then we don't want to offer anything
// here as we may make formatting worse for this construct.
foreach (var callChunk in callChunks)
{
// If any of these chunk parts are unformattable, then we don't want to offer anything
// here as we may make formatting worse for this construct.
var containsUnformattableContent = await ContainsUnformattableContentAsync(
document, new SyntaxNodeOrToken[] { chunk.DotToken, chunk.Name }, cancellationToken).ConfigureAwait(false);
if (!containsUnformattableContent && chunk.ArgumentListOpt != null)
foreach (var memberChunk in callChunk.MemberChunks)
{
containsUnformattableContent = await ContainsUnformattableContentAsync(
document, new SyntaxNodeOrToken[] { chunk.ArgumentListOpt }, cancellationToken).ConfigureAwait(false);
var memberContainsUnformattableContent = await ContainsUnformattableContentAsync(
document, new SyntaxNodeOrToken[] { memberChunk.DotToken, memberChunk.Name }, cancellationToken).ConfigureAwait(false);
if (memberContainsUnformattableContent)
{
return null;
}
}
var containsUnformattableContent = await ContainsUnformattableContentAsync(
document, new SyntaxNodeOrToken[] { callChunk.ArgumentList }, cancellationToken).ConfigureAwait(false);
if (containsUnformattableContent)
{
return null;
......@@ -122,7 +125,7 @@ internal abstract partial class AbstractCallWrapper<
var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
return new CallCodeActionComputer(
this, document, sourceText, options, chunks, cancellationToken);
this, document, sourceText, options, callChunks, cancellationToken);
}
private bool IsInvocationOrElementAccessExpression(
......@@ -161,30 +164,30 @@ internal abstract partial class AbstractCallWrapper<
return false;
}
private ImmutableArray<Chunk> GetChunks(SyntaxNode node)
private ImmutableArray<CallChunk> GetCallChunks(SyntaxNode node)
{
var chunks = ArrayBuilder<Chunk>.GetInstance();
var chunks = ArrayBuilder<CallChunk>.GetInstance();
AddChunks(node, chunks);
return chunks.ToImmutableAndFree();
}
private void AddChunks(SyntaxNode node, ArrayBuilder<Chunk> chunks)
private void AddChunks(SyntaxNode node, ArrayBuilder<CallChunk> chunks)
{
if (IsInvocationOrElementAccessExpression(node, out var expression, out var argumentList) &&
expression is TMemberAccessExpressionSyntax memberAccess)
expression is TMemberAccessExpressionSyntax)
{
_syntaxFacts.GetPartsOfMemberAccessExpression(
node, out var left, out var operatorToken, out var name);
chunks.Add(new Chunk((TExpressionSyntax)left, operatorToken, (TNameSyntax)name, argumentList));
var memberChunks = ArrayBuilder<MemberChunk>.GetInstance();
var current = (TExpressionSyntax)expression;
while (current is TMemberAccessExpressionSyntax memberAccess)
{
_syntaxFacts.GetPartsOfMemberAccessExpression(
current, out var left, out var operatorToken, out var name);
memberChunks.Insert(0, new MemberChunk(operatorToken, (TNameSyntax)name));
current = (TExpressionSyntax)left;
}
AddChunks(left, chunks);
}
else if (node is TMemberAccessExpressionSyntax memberAccessExpression)
{
_syntaxFacts.GetPartsOfMemberAccessExpression(
memberAccessExpression, out var left, out var operatorToken, out var name);
chunks.Add(new Chunk((TExpressionSyntax)left, operatorToken, (TNameSyntax)name, argumentListOpt: null));
AddChunks(left, chunks);
AddChunks(current, chunks);
chunks.Add(new CallChunk(memberChunks.ToImmutableAndFree(), argumentList));
}
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.Editor.Wrapping.Call
{
internal abstract partial class AbstractCallWrapper<
......@@ -10,23 +16,45 @@ internal abstract partial class AbstractCallWrapper<
TElementAccessExpressionSyntax,
TBaseArgumentListSyntax>
{
private readonly struct Chunk
private readonly struct MemberChunk
{
// Optional as VB allows an initial dotted expression starting with <dot>
// in a `with` block.
public readonly TExpressionSyntax ExpressionOpt;
public readonly SyntaxToken DotToken;
public readonly TNameSyntax Name;
// Optional when we just have a member access expression along the way.
public readonly TBaseArgumentListSyntax ArgumentListOpt;
public Chunk(TExpressionSyntax expressionOpt, SyntaxToken dotToken, TNameSyntax name, TBaseArgumentListSyntax argumentListOpt)
public MemberChunk(SyntaxToken dotToken, TNameSyntax name)
{
ExpressionOpt = expressionOpt;
DotToken = dotToken;
Name = name;
ArgumentListOpt = argumentListOpt;
}
/// <summary>
/// The length this chunk will be once all unnecessary whitespace has been
/// removed from it.
/// </summary>
public int NormalizedLength()
=> DotToken.Width() + Name.Width();
}
private readonly struct CallChunk
{
// Optional as VB allows an initial dotted expression starting with <dot>
// in a `with` block.
public readonly ImmutableArray<MemberChunk> MemberChunks;
public readonly TBaseArgumentListSyntax ArgumentList;
public CallChunk(ImmutableArray<MemberChunk> memberChunks, TBaseArgumentListSyntax argumentList)
{
Debug.Assert(memberChunks.Length > 0);
MemberChunks = memberChunks;
ArgumentList = argumentList;
}
/// <summary>
/// The length this chunk will be once all unnecessary whitespace has been
/// removed from it.
/// </summary>
public int NormalizedLength()
=> MemberChunks.Sum(c => c.NormalizedLength()) + ArgumentList.Width();
}
}
}
......@@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Utilities;
namespace Microsoft.CodeAnalysis.Editor.Wrapping.Call
{
......@@ -24,8 +25,9 @@ internal abstract partial class AbstractCallWrapper<
private class CallCodeActionComputer :
AbstractCodeActionComputer<AbstractCallWrapper>
{
private readonly ImmutableArray<Chunk> _chunks;
private readonly ImmutableArray<CallChunk> _callChunks;
private readonly SyntaxTriviaList _indentationTrivia;
private readonly SyntaxTriviaList _newlineBeforeOperatorTrivia;
public CallCodeActionComputer(
......@@ -33,16 +35,17 @@ private class CallCodeActionComputer :
Document document,
SourceText originalSourceText,
DocumentOptionSet options,
ImmutableArray<Chunk> chunks,
ImmutableArray<CallChunk> chunks,
CancellationToken cancellationToken)
: base(service, document, originalSourceText, options, cancellationToken)
{
_chunks = chunks;
_callChunks = chunks;
var generator = SyntaxGenerator.GetGenerator(document);
var indentationString = OriginalSourceText.GetOffset(chunks[0].DotToken.SpanStart)
var indentationString = OriginalSourceText.GetOffset(chunks[0].MemberChunks[0].DotToken.SpanStart)
.CreateIndentationString(UseTabs, TabSize);
_indentationTrivia = new SyntaxTriviaList(generator.Whitespace(indentationString));
_newlineBeforeOperatorTrivia = service.GetNewLineBeforeOperatorTrivia(NewLineTrivia);
}
......@@ -50,44 +53,60 @@ protected override async Task<ImmutableArray<WrappingGroup>> ComputeWrappingGrou
=> ImmutableArray.Create(new WrappingGroup(
isInlinable: true, ImmutableArray.Create(
await GetWrapCodeActionAsync().ConfigureAwait(false),
await GetUnwrapCodeActionAsync().ConfigureAwait(false))));
await GetUnwrapCodeActionAsync().ConfigureAwait(false),
await GetWrapLongCodeActionAsync().ConfigureAwait(false))));
// Pass 0 as the wrapping column as we effectively always want to wrap each chunk
// Not just when the chunk would go past the wrapping column.
private Task<WrapItemsAction> GetWrapCodeActionAsync()
=> TryCreateCodeActionAsync(GetWrapEdits(), FeaturesResources.Wrapping, FeaturesResources.Wrap_calls);
=> TryCreateCodeActionAsync(GetWrapEdits(wrappingColumn: 0), FeaturesResources.Wrapping, FeaturesResources.Wrap_calls);
private Task<WrapItemsAction> GetUnwrapCodeActionAsync()
=> TryCreateCodeActionAsync(GetUnwrapEdits(), FeaturesResources.Wrapping, FeaturesResources.Unwrap_calls);
private ImmutableArray<Edit> GetWrapEdits()
private Task<WrapItemsAction> GetWrapLongCodeActionAsync()
=> TryCreateCodeActionAsync(GetWrapEdits(WrappingColumn), FeaturesResources.Wrapping, FeaturesResources.Wrap_long_calls);
private ImmutableArray<Edit> GetWrapEdits(int wrappingColumn)
{
var result = ArrayBuilder<Edit>.GetInstance();
for (int i = 1; i < _exprsAndOperators.Length; i += 2)
{
var left = _exprsAndOperators[i - 1].AsNode();
var opToken = _exprsAndOperators[i].AsToken();
var right = _exprsAndOperators[i + 1].AsNode();
// Deal with the first chunk (it has special behavior because we
// don't want to delete any trivia directly before it).
DeleteAllButLeadingSpacesInCallChunk(result, _callChunks[0]);
if (_preference == OperatorPlacementWhenWrappingPreference.BeginningOfLine)
// The position we're currently at. If adding the next chunk would
// make us go past our preferred wrapping column, then we will wrap
// that chunk.
var position = _indentationTrivia.FullSpan.Length + _callChunks[0].NormalizedLength();
for (var i = 1; i < _callChunks.Length; i++)
{
var callChunk = _callChunks[i];
var wrapChunk = position + callChunk.NormalizedLength() > wrappingColumn;
if (wrapChunk)
{
// convert:
// (a == b) && (c == d) to
//
// (a == b)
// && (c == d)
result.Add(Edit.UpdateBetween(left, _newlineBeforeOperatorTrivia, _indentationTrivia, opToken));
result.Add(Edit.UpdateBetween(opToken, SingleWhitespaceTrivia, NoTrivia, right));
// we're wrapping. So our position is reset to the indentation
// on the next line.
position = _indentationTrivia.FullSpan.Length;
// First, add a newline before the very first member chunk.
result.Add(Edit.UpdateBetween(
_callChunks[i - 1].ArgumentList, _newlineBeforeOperatorTrivia,
_indentationTrivia, callChunk.MemberChunks[0].DotToken));
// Now, delete all the remaining spaces in this call chunk.
DeleteAllButLeadingSpacesInCallChunk(result, callChunk);
}
else
{
// convert:
// (a == b) && (c == d) to
//
// (a == b) &&
// (c == d)
result.Add(Edit.UpdateBetween(left, SingleWhitespaceTrivia, NoTrivia, opToken));
result.Add(Edit.UpdateBetween(opToken, NewLineTrivia, _indentationTrivia, right));
// not wrapping. So just clean up this next call chunk by
// deleting all spaces.
DeleteAllSpacesInCallChunk(result, callChunk);
}
// Update position based on this chunk we just fixed up.
position += callChunk.NormalizedLength();
}
return result.ToImmutableAndFree();
......@@ -97,23 +116,75 @@ private ImmutableArray<Edit> GetUnwrapEdits()
{
var result = ArrayBuilder<Edit>.GetInstance();
foreach (var chunk in _chunks)
{
if (chunk.ExpressionOpt != null)
{
result.Add(Edit.DeleteBetween(chunk.ExpressionOpt, chunk.DotToken));
}
// Deal with the first chunk (it has special behavior because we
// don't want to delete any trivia directly before it).
DeleteAllButLeadingSpacesInCallChunk(result, _callChunks[0]);
result.Add(Edit.DeleteBetween(chunk.DotToken, chunk.Name));
// Now, handle all successive call chunks.
for (var i = 1; i < _callChunks.Length; i++)
{
var callChunk = _callChunks[i];
if (chunk.ArgumentListOpt != null)
{
result.Add(Edit.DeleteBetween(chunk.Name, chunk.ArgumentListOpt));
}
// In successive call chunks we want to delete all the spacing
// in the member chunks.
DeleteAllSpacesInCallChunk(result, callChunk);
}
return result.ToImmutableAndFree();
}
private static void DeleteAllSpacesInCallChunk(ArrayBuilder<Edit> result, CallChunk callChunk)
{
foreach (var memberChunk in callChunk.MemberChunks)
{
DeleteSpacesInMemberChunk(result, memberChunk);
}
// and then any whitespace before the arg list.
DeleteSpacesBeforeArgumentList(result, callChunk);
}
/// <summary>
/// Removes all whitespace in the spaces between the elements of this chunk.
/// However no edits will be made before the the first dot in the first member
/// chunk of this call chunk. This is useful for the very first call chunk or
/// any callchunk we're explicitly wrapping.
/// </summary>
private void DeleteAllButLeadingSpacesInCallChunk(ArrayBuilder<Edit> result, CallChunk callChunk)
{
// For the very first member chunk we have, don't make any edits prior
// to it. This is the chunk that contains the dot that we are aligning
// all wrapping to. It should never be touched.
//
// After that first member chunk, remove all whitespace between the
// other member chunks and between the arg list.
var firstCallChunk = _callChunks[0];
// For the very first name chunk in .A.B.C (i.e. `.A` just remove the spaces
// between the dot and the name.
var firstMemberChunk = firstCallChunk.MemberChunks[0];
result.Add(Edit.DeleteBetween(firstMemberChunk.DotToken, firstMemberChunk.Name));
// For all subsequence name chunks in .A.B.C (i.e. `.B.C`) remove any spaces between
// the chunk and the last chunk, and between the dot and the name.
for (var i = 1; i < firstCallChunk.MemberChunks.Length; i++)
{
var memberChunk = firstCallChunk.MemberChunks[i];
DeleteSpacesInMemberChunk(result, memberChunk);
}
DeleteSpacesBeforeArgumentList(result, firstCallChunk);
}
private static void DeleteSpacesInMemberChunk(ArrayBuilder<Edit> result, MemberChunk memberChunk)
{
result.Add(Edit.DeleteBetween(memberChunk.DotToken.GetPreviousToken(), memberChunk.DotToken));
result.Add(Edit.DeleteBetween(memberChunk.DotToken, memberChunk.Name));
}
private static void DeleteSpacesBeforeArgumentList(ArrayBuilder<Edit> result, CallChunk callChunk)
=> result.Add(Edit.DeleteBetween(callChunk.MemberChunks.Last().Name, callChunk.ArgumentList));
}
}
}
......@@ -11,7 +11,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Wrapping.BinaryExpression
MyBase.New(VisualBasicSyntaxFactsService.Instance, VisualBasicPrecedenceService.Instance)
End Sub
Protected Overrides Function GetNewLineBeforeOperatorTrivia(newLine As SyntaxTriviaList) As SyntaxTriviaList
Public Overrides Function GetNewLineBeforeOperatorTrivia(newLine As SyntaxTriviaList) As SyntaxTriviaList
Return newLine.InsertRange(0, {SyntaxFactory.WhitespaceTrivia(" "), SyntaxFactory.LineContinuationTrivia("_")})
End Function
End Class
......
......@@ -4502,6 +4502,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Wrap long calls.
/// </summary>
internal static string Wrap_long_calls {
get {
return ResourceManager.GetString("Wrap_long_calls", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Wrap long parameter list.
/// </summary>
......
......@@ -1604,4 +1604,7 @@ This version used in: {2}</value>
<data name="Wrap_calls" xml:space="preserve">
<value>Wrap calls</value>
</data>
<data name="Wrap_long_calls" xml:space="preserve">
<value>Wrap long calls</value>
</data>
</root>
\ No newline at end of file
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -252,6 +252,11 @@
<target state="new">Replace '{0}' with '{1}' </target>
<note />
</trans-unit>
<trans-unit id="Unwrap calls">
<source>Unwrap calls</source>
<target state="new">Unwrap calls</target>
<note />
</trans-unit>
<trans-unit id="Unwrap_all_arguments">
<source>Unwrap all arguments</source>
<target state="new">Unwrap all arguments</target>
......@@ -342,6 +347,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Wrap_calls">
<source>Wrap calls</source>
<target state="new">Wrap calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_every_argument">
<source>Wrap every argument</source>
<target state="new">Wrap every argument</target>
......@@ -362,6 +372,11 @@
<target state="new">Wrap long argument list</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_calls">
<source>Wrap long calls</source>
<target state="new">Wrap long calls</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_parameter_list">
<source>Wrap long parameter list</source>
<target state="new">Wrap long parameter list</target>
......
......@@ -1410,6 +1410,13 @@ public bool IsNumericLiteral(SyntaxToken token)
public bool IsCharacterLiteral(SyntaxToken token)
=> token.Kind() == SyntaxKind.CharacterLiteralToken;
public void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList)
{
var invocation = (InvocationExpressionSyntax)node;
expression = invocation.Expression;
argumentList = invocation.ArgumentList;
}
public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfInvocationExpression(SyntaxNode invocationExpression)
=> GetArgumentsOfArgumentList((invocationExpression as InvocationExpressionSyntax)?.ArgumentList);
......@@ -1545,13 +1552,11 @@ public bool IsSimpleAssignmentStatement(SyntaxNode statement)
public SyntaxNode GetNameOfMemberAccessExpression(SyntaxNode memberAccessExpression)
=> ((MemberAccessExpressionSyntax)memberAccessExpression).Name;
public SyntaxToken GetOperatorTokenOfMemberAccessExpression(SyntaxNode memberAccessExpression)
=> ((MemberAccessExpressionSyntax)memberAccessExpression).OperatorToken;
public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode name)
public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
{
var memberAccess = (MemberAccessExpressionSyntax)node;
expression = memberAccess.Expression;
operatorToken = memberAccess.OperatorToken;
name = memberAccess.Name;
}
......
......@@ -1482,10 +1482,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return DirectCast(memberAccessExpression, MemberAccessExpressionSyntax).Name
End Function
Public Function GetOperatorTokenOfMemberAccessExpression(memberAccessExpression As SyntaxNode) As SyntaxToken Implements ISyntaxFactsService.GetOperatorTokenOfMemberAccessExpression
Return DirectCast(memberAccessExpression, MemberAccessExpressionSyntax).OperatorToken
End Function
Public Function GetIdentifierOfSimpleName(node As SyntaxNode) As SyntaxToken Implements ISyntaxFactsService.GetIdentifierOfSimpleName
Return DirectCast(node, SimpleNameSyntax).Identifier
End Function
......@@ -1536,10 +1532,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return node IsNot Nothing AndAlso TryCast(node.Parent, MemberAccessExpressionSyntax)?.Expression Is node
End Function
Public Function GetExpressionOfInvocationExpression(node As SyntaxNode) As SyntaxNode Implements ISyntaxFactsService.GetExpressionOfInvocationExpression
Return DirectCast(node, InvocationExpressionSyntax).Expression
End Function
Public Function GetExpressionOfAwaitExpression(node As SyntaxNode) As SyntaxNode Implements ISyntaxFactsService.GetExpressionOfAwaitExpression
Return DirectCast(node, AwaitExpressionSyntax).Expression
End Function
......@@ -1632,9 +1624,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return DirectCast(node, UnaryExpressionSyntax).OperatorToken
End Function
Public Sub GetPartsOfMemberAccessExpression(node As SyntaxNode, ByRef expression As SyntaxNode, ByRef name As SyntaxNode) Implements ISyntaxFactsService.GetPartsOfMemberAccessExpression
Public Sub GetPartsOfMemberAccessExpression(node As SyntaxNode, ByRef expression As SyntaxNode, ByRef operatorToken As SyntaxToken, ByRef name As SyntaxNode) Implements ISyntaxFactsService.GetPartsOfMemberAccessExpression
Dim memberAccess = DirectCast(node, MemberAccessExpressionSyntax)
expression = memberAccess.Expression
operatorToken = memberAccess.OperatorToken
name = memberAccess.Name
End Sub
......@@ -1867,5 +1860,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public Function SpansPreprocessorDirective(nodes As IEnumerable(Of SyntaxNode)) As Boolean Implements ISyntaxFactsService.SpansPreprocessorDirective
Return nodes.SpansPreprocessorDirective()
End Function
Public Sub GetPartsOfInvocationExpression(node As SyntaxNode, ByRef expression As SyntaxNode, ByRef argumentList As SyntaxNode) Implements ISyntaxFactsService.GetPartsOfInvocationExpression
Dim invocation = DirectCast(node, InvocationExpressionSyntax)
expression = invocation.Expression
argumentList = invocation.ArgumentList
End Sub
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册