提交 cab764f2 编写于 作者: B Balaji Krishnan

simplify conditional.

上级 c9a5401a
......@@ -32,10 +32,24 @@ protected override bool IsStylePreferred(SyntaxNode declarationStatement, Semant
var stylePreferences = state.StylePreferences;
var shouldNotify = state.ShouldNotify();
return shouldNotify &&
((!stylePreferences.HasFlag(TypingStyles.VarForIntrinsic) && state.IsInIntrinsicTypeContext)
|| (!stylePreferences.HasFlag(TypingStyles.VarWhereApparent) && state.IsTypingApparentInContext)
|| (!stylePreferences.HasFlag(TypingStyles.VarWherePossible) && !(state.IsInIntrinsicTypeContext || state.IsTypingApparentInContext)));
// If notification preference is None, don't offer the suggestion.
if (!shouldNotify)
{
return false;
}
if (state.IsInIntrinsicTypeContext)
{
return !stylePreferences.HasFlag(TypingStyles.VarForIntrinsic);
}
else if (state.IsTypingApparentInContext)
{
return !stylePreferences.HasFlag(TypingStyles.VarWhereApparent);
}
else
{
return !stylePreferences.HasFlag(TypingStyles.VarWherePossible);
}
}
protected override bool TryAnalyzeVariableDeclaration(TypeSyntax typeName, SemanticModel semanticModel, OptionSet optionSet, CancellationToken cancellationToken, out TextSpan issueSpan)
......
......@@ -34,10 +34,24 @@ protected override bool IsStylePreferred(SyntaxNode declarationStatement, Semant
var stylePreferences = state.StylePreferences;
var shouldNotify = state.ShouldNotify();
return shouldNotify &&
((stylePreferences.HasFlag(TypingStyles.VarForIntrinsic) && state.IsInIntrinsicTypeContext)
|| (stylePreferences.HasFlag(TypingStyles.VarWhereApparent) && state.IsTypingApparentInContext)
|| (stylePreferences.HasFlag(TypingStyles.VarWherePossible) && !(state.IsInIntrinsicTypeContext || state.IsTypingApparentInContext)));
// If notification preference is None, don't offer the suggestion.
if (!shouldNotify)
{
return false;
}
if (state.IsInIntrinsicTypeContext)
{
return stylePreferences.HasFlag(TypingStyles.VarForIntrinsic);
}
else if (state.IsTypingApparentInContext)
{
return stylePreferences.HasFlag(TypingStyles.VarWhereApparent);
}
else
{
return stylePreferences.HasFlag(TypingStyles.VarWherePossible);
}
}
protected override bool TryAnalyzeVariableDeclaration(TypeSyntax typeName, SemanticModel semanticModel, OptionSet optionSet, CancellationToken cancellationToken, out TextSpan issueSpan)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册