-
Notifications
You must be signed in to change notification settings - Fork 395
Fix bug with PipelineIndentationStyle.None where break instead of continue statement was used #1497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5a2e6b
6d0a4d2
6521ebd
6cf454f
8f6769f
82e993c
13c5fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
|
@@ -220,14 +220,19 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file | |
} | ||
} | ||
|
||
bool lineHasPipelineBeforeToken = LineHasPipelineBeforeToken(tokens, tokenIndex, token); | ||
if (pipelineIndentationStyle == PipelineIndentationStyle.None && PreviousLineEndedWithPipe(tokens, tokenIndex, token)) | ||
{ | ||
continue; | ||
} | ||
|
||
bool lineHasPipelineBeforeToken = LineHasPipelineBeforeToken(tokens, tokenIndex, token); | ||
AddViolation(token, tempIndentationLevel, diagnosticRecords, ref onNewLine, lineHasPipelineBeforeToken); | ||
} | ||
break; | ||
} | ||
|
||
if (pipelineIndentationStyle == PipelineIndentationStyle.None) { break; } | ||
if (pipelineIndentationStyle == PipelineIndentationStyle.None) { continue; } | ||
bergmeister marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Check if the current token matches the end of a PipelineAst | ||
PipelineAst matchingPipeLineAstEnd = MatchingPipelineAstEnd(pipelineAsts, ref minimumPipelineAstIndex, token); | ||
if (matchingPipeLineAstEnd == null) | ||
|
@@ -284,6 +289,35 @@ private static bool PipelineIsFollowedByNewlineOrLineContinuation(Token[] tokens | |
return false; | ||
} | ||
|
||
private static bool PreviousLineEndedWithPipe(Token[] tokens, int tokenIndex, Token token) | ||
{ | ||
if (tokenIndex < 2 || token.Extent.StartLineNumber == 1) | ||
{ | ||
return false; | ||
} | ||
|
||
int searchIndex = tokenIndex - 2; | ||
int searchLine; | ||
do | ||
{ | ||
searchLine = tokens[searchIndex].Extent.StartLineNumber; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! My There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I addressed your comment here by not initializing it: #1497 (comment) |
||
if (tokens[searchIndex].Kind == TokenKind.Comment) | ||
{ | ||
searchIndex--; | ||
} | ||
else if (tokens[searchIndex].Kind == TokenKind.Pipe) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
break; | ||
} | ||
} while (searchLine == token.Extent.StartLineNumber - 1 && searchIndex >= 0); | ||
bergmeister marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return false; | ||
} | ||
|
||
private static bool LineHasPipelineBeforeToken(Token[] tokens, int tokenIndex, Token token) | ||
{ | ||
int searchIndex = tokenIndex; | ||
|
Uh oh!
There was an error while loading. Please reload this page.