提交 8695781a 编写于 作者: C CyrusNajmabadi

Don't include attributes in the span of a block. We don't want to see those...

Don't include attributes in the span of a block.  We don't want to see those attributes in the indent guide tooltips.
上级 bf475922
......@@ -79,7 +79,7 @@ public static SyntaxToken GetLastInlineMethodBlockToken(SyntaxNode node)
// If the next token is a semicolon, and we aren't in the initializer of a for-loop, use that token as the end.
SyntaxToken nextToken = lastToken.GetNextToken(includeSkipped: true);
var nextToken = lastToken.GetNextToken(includeSkipped: true);
if (nextToken.Kind() != SyntaxKind.None && nextToken.Kind() == SyntaxKind.SemicolonToken)
{
var forStatement = nextToken.GetAncestor<ForStatementSyntax>();
......@@ -99,7 +99,7 @@ private static string CreateCommentBannerTextWithPrefix(string text, string pref
Contract.ThrowIfNull(text);
Contract.ThrowIfNull(prefix);
int prefixLength = prefix.Length;
var prefixLength = prefix.Length;
return prefix + " " + text.Substring(prefixLength).Trim() + " " + Ellipsis;
}
......@@ -113,7 +113,7 @@ private static string GetCommentBannerText(SyntaxTrivia comment)
}
else if (comment.IsMultiLineComment())
{
int lineBreakStart = comment.ToString().IndexOfAny(new char[] { '\r', '\n' });
var lineBreakStart = comment.ToString().IndexOfAny(new char[] { '\r', '\n' });
var text = comment.ToString();
if (lineBreakStart >= 0)
......@@ -257,13 +257,8 @@ private static string GetCommentBannerText(SyntaxTrivia comment)
string type, bool isCollapsible)
{
return CreateBlockSpan(
node,
syntaxToken,
node.GetLastToken(),
bannerText,
autoCollapse,
type,
isCollapsible);
node, syntaxToken, node.GetLastToken(),
bannerText, autoCollapse, type, isCollapsible);
}
public static BlockSpan? CreateBlockSpan(
......@@ -282,7 +277,7 @@ private static string GetCommentBannerText(SyntaxTrivia comment)
// of the next token so indentation in the tooltip is accurate.
var span = TextSpan.FromBounds(GetCollapsibleStart(startToken), endPos);
var hintSpan = TextSpan.FromBounds(node.SpanStart, endPos);
var hintSpan = GetHintSpan(node, endPos);
return CreateBlockSpan(
span,
......@@ -293,19 +288,31 @@ private static string GetCommentBannerText(SyntaxTrivia comment)
isCollapsible);
}
private static TextSpan GetHintSpan(SyntaxNode node, int endPos)
{
// Don't include attributes in the BlockSpan for a node. When the user
// hovers over the indent-guide we don't want to show them the line with
// the attributes, we want to show them the line with the start of the
// actual structure.
foreach (var child in node.ChildNodesAndTokens())
{
if (child.Kind() != SyntaxKind.AttributeList)
{
return TextSpan.FromBounds(child.SpanStart, endPos);
}
}
return TextSpan.FromBounds(node.SpanStart, endPos);
}
public static BlockSpan? CreateBlockSpan(
SyntaxNode node, SyntaxToken startToken,
SyntaxToken endToken, string bannerText, bool autoCollapse,
string type, bool isCollapsible)
{
return CreateBlockSpan(
node,
startToken,
GetCollapsibleEnd(endToken),
bannerText,
autoCollapse,
type,
isCollapsible);
node, startToken, GetCollapsibleEnd(endToken),
bannerText, autoCollapse, type, isCollapsible);
}
public static BlockSpan CreateBlockSpan(
......
......@@ -56,7 +56,7 @@ internal class DisabledTextTriviaStructureProvider : AbstractSyntaxTriviaStructu
}
var nestedIfDirectiveTrivia = 0;
for (int i = indexInParent; i < parentTriviaList.Count; i++)
for (var i = indexInParent; i < parentTriviaList.Count; i++)
{
if (parentTriviaList[i].IsKind(SyntaxKind.IfDirectiveTrivia))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册