Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorKrolic committed Aug 2, 2023
1 parent a204e2e commit fd2bc8b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature;
using static Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature.ChangeSignatureDialogViewModel;
Expand Down Expand Up @@ -56,7 +55,5 @@ public override SymbolDisplayPart[] GeneratePreviewDisplayParts(AddedParameterVi
public override bool IsTypeNameValid(string typeName) => !SyntaxFactory.ParseTypeName(typeName, options: s_langVersionLatestParseOptions).ContainsDiagnostics;

public override SyntaxNode GetTypeNode(string typeName) => SyntaxFactory.ParseTypeName(typeName);

public override bool IsVoidTypeSyntax(SyntaxNode node) => node is PredefinedTypeSyntax(kind: SyntaxKind.VoidKeyword);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ private void SetCurrentTypeTextAndUpdateBindingStatus(string typeName)
TypeIsEmptyImage = Visibility.Collapsed;

var languageService = Document.GetRequiredLanguageService<IChangeSignatureViewModelFactoryService>();
var typeNode = languageService.GetTypeNode(typeName);
TypeSymbol = _semanticModel.GetSpeculativeTypeInfo(PositionForTypeBinding, typeNode, SpeculativeBindingOption.BindAsTypeOrNamespace).Type;
TypeSymbol = _semanticModel.GetSpeculativeTypeInfo(PositionForTypeBinding, languageService.GetTypeNode(typeName), SpeculativeBindingOption.BindAsTypeOrNamespace).Type;

if (languageService.IsVoidTypeSyntax(typeNode) || TypeSymbol is { SpecialType: SpecialType.System_Void })
if (TypeSymbol is { SpecialType: SpecialType.System_Void })
{
_isVoidParameterType = true;
TypeDoesNotParseOrInvalidTypeImage = Visibility.Visible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ public abstract SymbolDisplayPart[] GeneratePreviewDisplayParts(
public abstract bool IsTypeNameValid(string typeName);

public abstract SyntaxNode GetTypeNode(string typeName);

public abstract bool IsVoidTypeSyntax(SyntaxNode node);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ internal interface IChangeSignatureViewModelFactoryService : ILanguageService
bool IsTypeNameValid(string typeName);

SyntaxNode GetTypeNode(string typeName);

bool IsVoidTypeSyntax(SyntaxNode node);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,5 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ChangeSignature
Public Overrides Function GetTypeNode(typeName As String) As SyntaxNode
Return SyntaxFactory.ParseTypeName(typeName)
End Function

Public Overrides Function IsVoidTypeSyntax(node As SyntaxNode) As Boolean
' VB doesn't have a concept of 'void' type syntax since it represents void-returning methods as 'Sub's
Return False
End Function
End Class
End Namespace

0 comments on commit fd2bc8b

Please sign in to comment.