Last active
January 21, 2019 20:06
-
-
Save controlflow/1535b68072c13b6349bdab89d608697f 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 static bool CheckHasValidRefOperands( | |
[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 false; | |
} | |
if (elseRefExpression == null && thenRefExpression != null) | |
{ | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, thenRefExpression)); | |
return false; | |
} | |
return thenRefExpression != 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 static bool CheckHasValidRefOperands( | |
[NotNull] IConditionalTernaryExpression expression, | |
[NotNull] ICSharpExpression thenResult, | |
[NotNull] ICSharpExpression elseResult, | |
[NotNull] IHighlightingConsumer consumer) | |
{ | |
switch (thenResult, elseResult) | |
{ | |
case (IRefExpression _, IRefExpression _): | |
return true; | |
case (IRefExpression thenRefExpression, _): | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, thenRefExpression)); | |
return false; | |
case (_, IRefExpression elseRefExpression): | |
consumer.AddHighlighting(new RefConditionalNeedsTwoRefsError(expression, elseRefExpression)); | |
return false; | |
default: | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment