From 855b1a262f3a769d44765e78f94e566d875b9286 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 29 Jul 2025 07:35:58 -0700 Subject: [Language Server]: Show signature help on generic parameters. (#7913) * Show signature help on generic parameters. * Fix. * Update tests. * slang-test: make vvl error go through stderr. * update slang-rhi * Update slang-rhi --- source/slang/slang-check-expr.cpp | 46 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'source/slang/slang-check-expr.cpp') diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index f63d1aaeb..31b08e925 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -1796,7 +1796,7 @@ Expr* SemanticsVisitor::GetBaseExpr(Expr* expr) } else if (auto partiallyApplied = as(expr)) { - return GetBaseExpr(partiallyApplied->originalExpr); + return GetBaseExpr(partiallyApplied->baseExpr); } return nullptr; } @@ -4624,17 +4624,6 @@ Expr* SemanticsVisitor::CheckMatrixSwizzleExpr( bool anyDuplicates = false; int zeroIndexOffset = -1; - if (memberRefExpr->name == getSession()->getCompletionRequestTokenName()) - { - auto& suggestions = getLinkage()->contentAssistInfo.completionSuggestions; - suggestions.clear(); - suggestions.scopeKind = CompletionSuggestions::ScopeKind::Swizzle; - suggestions.swizzleBaseType = - memberRefExpr->baseExpression ? memberRefExpr->baseExpression->type : nullptr; - suggestions.elementCount[0] = baseElementRowCount; - suggestions.elementCount[1] = baseElementColCount; - } - String swizzleText = getText(memberRefExpr->name); auto cursor = swizzleText.begin(); @@ -4783,18 +4772,6 @@ Expr* SemanticsVisitor::checkTupleSwizzleExpr(MemberExpr* memberExpr, TupleType* if (tupleElementCount == 0) return checkGeneralMemberLookupExpr(memberExpr, baseTupleType); - if (memberExpr->name == getSession()->getCompletionRequestTokenName()) - { - auto& suggestions = getLinkage()->contentAssistInfo.completionSuggestions; - suggestions.clear(); - suggestions.scopeKind = CompletionSuggestions::ScopeKind::Swizzle; - suggestions.swizzleBaseType = - memberExpr->baseExpression ? memberExpr->baseExpression->type : nullptr; - suggestions.elementCount[0] = (Index)tupleElementCount; - suggestions.elementCount[1] = 0; - return memberExpr; - } - String swizzleText = getText(memberExpr->name); auto span = swizzleText.getUnownedSlice(); Index pos = 0; @@ -5374,6 +5351,27 @@ Expr* SemanticsVisitor::checkGeneralMemberLookupExpr(MemberExpr* expr, Type* bas suggestions.elementCount[0] = 1; suggestions.swizzleBaseType = scalarType; } + else if (auto matrixType = as(expr->baseExpression->type)) + { + auto& suggestions = getLinkage()->contentAssistInfo.completionSuggestions; + suggestions.clear(); + suggestions.scopeKind = CompletionSuggestions::ScopeKind::Swizzle; + suggestions.swizzleBaseType = matrixType; + suggestions.elementCount[0] = 0; + suggestions.elementCount[1] = 0; + if (auto rowCount = as(matrixType->getRowCount())) + suggestions.elementCount[0] = rowCount->getValue(); + if (auto colCount = as(matrixType->getColumnCount())) + suggestions.elementCount[1] = colCount->getValue(); + } + else if (auto tupleType = as(expr->baseExpression->type)) + { + auto& suggestions = getLinkage()->contentAssistInfo.completionSuggestions; + suggestions.scopeKind = CompletionSuggestions::ScopeKind::Swizzle; + suggestions.elementCount[0] = tupleType->getMemberCount(); + suggestions.elementCount[1] = 0; + suggestions.swizzleBaseType = tupleType; + } } } return createLookupResultExpr(expr->name, lookupResult, expr->baseExpression, expr->loc, expr); -- cgit v1.2.3