Created
January 21, 2019 16:10
-
-
Save controlflow/6420e61415ac7bb321163fac682cf3f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CheckRefConditionalIssues( | |
[NotNull] IConditionalTernaryExpression expression, | |
[NotNull] ICSharpExpression thenResult, | |
[NotNull] ICSharpExpression elseResult, | |
[NotNull] IHighlightingConsumer consumer) | |
{ | |
var thenRefExpression = thenResult as IRefExpression; | |
var elseRefExpression = elseResult as IRefExpression; | |
if (elseRefExpression != null && thenRefExpression == null) | |
{ | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, elseRefExpression)); | |
return; | |
} | |
if (elseRefExpression == null && thenRefExpression != null) | |
{ | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, thenRefExpression)); | |
return; | |
} | |
if (thenRefExpression != null && elseRefExpression != null) | |
{ | |
// .. | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CheckRefConditionalIssues( | |
[NotNull] IConditionalTernaryExpression expression, | |
[NotNull] ICSharpExpression thenResult, | |
[NotNull] ICSharpExpression elseResult, | |
[NotNull] IHighlightingConsumer consumer) | |
{ | |
switch (thenResult, elseResult) | |
{ | |
case (IRefExpression _, IRefExpression _): | |
// .. | |
break; | |
case (IRefExpression thenRefExpression, _): | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, thenRefExpression)); | |
return; | |
case (_, IRefExpression elseRefExpression): | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, elseRefExpression)); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment