diff options
| author | Yong He <yonghe@outlook.com> | 2025-07-29 07:35:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-29 14:35:58 +0000 |
| commit | 855b1a262f3a769d44765e78f94e566d875b9286 (patch) | |
| tree | ea41db3717f55aa5032b1f04d71729a452ec68b2 /source/slang/slang-check-expr.cpp | |
| parent | ea6f8551ad38f2bcc32b542fd52ce17f3829cbeb (diff) | |
[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
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
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<PartiallyAppliedGenericExpr>(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<MatrixExpressionType>(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<ConstantIntVal>(matrixType->getRowCount())) + suggestions.elementCount[0] = rowCount->getValue(); + if (auto colCount = as<ConstantIntVal>(matrixType->getColumnCount())) + suggestions.elementCount[1] = colCount->getValue(); + } + else if (auto tupleType = as<TupleType>(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); |
