diff --git a/microsoft/typescript-go b/microsoft/typescript-go index 51d6a1131..93841b563 160000 --- a/microsoft/typescript-go +++ b/microsoft/typescript-go @@ -1 +1 @@ -Subproject commit 51d6a11318b737067b21596e0987cbbb79c9bf69 +Subproject commit 93841b5634233e83029463e741d51b4ca359a68a diff --git a/pkg/checker/checker.go b/pkg/checker/checker.go index 78eaacf23..97d7cfc06 100644 --- a/pkg/checker/checker.go +++ b/pkg/checker/checker.go @@ -27,6 +27,7 @@ import ( "github.com/buke/typescript-go-internal/pkg/stringutil" "github.com/buke/typescript-go-internal/pkg/tsoptions" "github.com/buke/typescript-go-internal/pkg/tspath" + "github.com/zeebo/xxh3" ) // CheckMode @@ -161,23 +162,23 @@ type UnionOfUnionKey struct { id1 TypeId id2 TypeId r UnionReduction - a string + a CacheHashKey } // CachedSignatureKey type CachedSignatureKey struct { sig *Signature - key string // Type list key or one of the strings below + key CacheHashKey // Type list key or one of the special keys below } -const ( - SignatureKeyErased string = "-" - SignatureKeyCanonical string = "*" - SignatureKeyBase string = "#" - SignatureKeyInner string = "<" - SignatureKeyOuter string = ">" - SignatureKeyImplementation string = "+" +var ( + SignatureKeyErased = CacheHashKey(xxh3.HashString128("-")) + SignatureKeyCanonical = CacheHashKey(xxh3.HashString128("*")) + SignatureKeyBase = CacheHashKey(xxh3.HashString128("#")) + SignatureKeyInner = CacheHashKey(xxh3.HashString128("<")) + SignatureKeyOuter = CacheHashKey(xxh3.HashString128(">")) + SignatureKeyImplementation = CacheHashKey(xxh3.HashString128("+")) ) // StringMappingKey @@ -234,7 +235,7 @@ type IterationTypesKey struct { type FlowLoopKey struct { flowNode *ast.FlowNode - refKey string + refKey CacheHashKey } type FlowLoopInfo struct { @@ -595,13 +596,13 @@ type Checker struct { numberLiteralTypes map[jsnum.Number]*Type bigintLiteralTypes map[jsnum.PseudoBigInt]*Type enumLiteralTypes map[EnumLiteralKey]*Type - indexedAccessTypes map[string]*Type - templateLiteralTypes map[string]*Type + indexedAccessTypes map[CacheHashKey]*Type + templateLiteralTypes map[CacheHashKey]*Type stringMappingTypes map[StringMappingKey]*Type uniqueESSymbolTypes map[*ast.Symbol]*Type thisExpandoKinds map[*ast.Symbol]thisAssignmentDeclarationKind thisExpandoLocations map[*ast.Symbol]*ast.Node - subtypeReductionCache map[string][]*Type + subtypeReductionCache map[CacheHashKey][]*Type cachedTypes map[CachedTypeKey]*Type cachedSignatures map[CachedSignatureKey]*Signature undefinedProperties map[string]*ast.Symbol @@ -619,14 +620,14 @@ type Checker struct { requireSymbol *ast.Symbol unknownSymbol *ast.Symbol unresolvedSymbols map[string]*ast.Symbol - errorTypes map[string]*Type + errorTypes map[CacheHashKey]*Type globalThisSymbol *ast.Symbol resolveName func(location *ast.Node, name string, meaning ast.SymbolFlags, nameNotFoundMessage *diagnostics.Message, isUse bool, excludeGlobals bool) *ast.Symbol resolveNameForSymbolSuggestion func(location *ast.Node, name string, meaning ast.SymbolFlags, nameNotFoundMessage *diagnostics.Message, isUse bool, excludeGlobals bool) *ast.Symbol - tupleTypes map[string]*Type - unionTypes map[string]*Type + tupleTypes map[CacheHashKey]*Type + unionTypes map[CacheHashKey]*Type unionOfUnionTypes map[UnionOfUnionKey]*Type - intersectionTypes map[string]*Type + intersectionTypes map[CacheHashKey]*Type diagnostics ast.DiagnosticsCollection suggestionDiagnostics ast.DiagnosticsCollection symbolPool core.Pool[ast.Symbol] @@ -853,7 +854,7 @@ type Checker struct { ctx context.Context packagesMap map[string]bool activeMappers []*TypeMapper - activeTypeMappersCaches []map[string]*Type + activeTypeMappersCaches []map[CacheHashKey]*Type ambientModulesOnce sync.Once ambientModules []*ast.Symbol withinUnreachableCode bool @@ -896,13 +897,13 @@ func NewChecker(program Program) (*Checker, *sync.Mutex) { c.numberLiteralTypes = make(map[jsnum.Number]*Type) c.bigintLiteralTypes = make(map[jsnum.PseudoBigInt]*Type) c.enumLiteralTypes = make(map[EnumLiteralKey]*Type) - c.indexedAccessTypes = make(map[string]*Type) - c.templateLiteralTypes = make(map[string]*Type) + c.indexedAccessTypes = make(map[CacheHashKey]*Type) + c.templateLiteralTypes = make(map[CacheHashKey]*Type) c.stringMappingTypes = make(map[StringMappingKey]*Type) c.uniqueESSymbolTypes = make(map[*ast.Symbol]*Type) c.thisExpandoKinds = make(map[*ast.Symbol]thisAssignmentDeclarationKind) c.thisExpandoLocations = make(map[*ast.Symbol]*ast.Node) - c.subtypeReductionCache = make(map[string][]*Type) + c.subtypeReductionCache = make(map[CacheHashKey][]*Type) c.cachedTypes = make(map[CachedTypeKey]*Type) c.cachedSignatures = make(map[CachedSignatureKey]*Signature) c.undefinedProperties = make(map[string]*ast.Symbol) @@ -919,16 +920,16 @@ func NewChecker(program Program) (*Checker, *sync.Mutex) { c.requireSymbol = c.newSymbol(ast.SymbolFlagsProperty, "require") c.unknownSymbol = c.newSymbol(ast.SymbolFlagsProperty, "unknown") c.unresolvedSymbols = make(map[string]*ast.Symbol) - c.errorTypes = make(map[string]*Type) + c.errorTypes = make(map[CacheHashKey]*Type) c.globalThisSymbol = c.newSymbolEx(ast.SymbolFlagsModule, "globalThis", ast.CheckFlagsReadonly) c.globalThisSymbol.Exports = c.globals c.globals[c.globalThisSymbol.Name] = c.globalThisSymbol c.resolveName = c.createNameResolver().Resolve c.resolveNameForSymbolSuggestion = c.createNameResolverForSuggestion().Resolve - c.tupleTypes = make(map[string]*Type) - c.unionTypes = make(map[string]*Type) + c.tupleTypes = make(map[CacheHashKey]*Type) + c.unionTypes = make(map[CacheHashKey]*Type) c.unionOfUnionTypes = make(map[UnionOfUnionKey]*Type) - c.intersectionTypes = make(map[string]*Type) + c.intersectionTypes = make(map[CacheHashKey]*Type) c.mergedSymbols = make(map[*ast.Symbol]*ast.Symbol) c.patternForType = make(map[*Type]*ast.Node) c.contextFreeTypes = make(map[*ast.Node]*Type) @@ -985,7 +986,7 @@ func NewChecker(program Program) (*Checker, *sync.Mutex) { c.unknownEmptyObjectType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) c.unknownUnionType = c.createUnknownUnionType() c.emptyGenericType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) - c.emptyGenericType.AsObjectType().instantiations = make(map[string]*Type) + c.emptyGenericType.AsObjectType().instantiations = make(map[CacheHashKey]*Type) c.anyFunctionType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) c.anyFunctionType.objectFlags |= ObjectFlagsNonInferrableType c.noConstraintType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) @@ -13450,6 +13451,22 @@ func (c *Checker) getResolvedSymbolOrNil(node *ast.Node) *ast.Symbol { return c.symbolNodeLinks.Get(node).resolvedSymbol } +func (c *Checker) getResolvedSymbolNoDiagnostics(node *ast.Node) *ast.Symbol { + links := c.symbolNodeLinks.Get(node) + if links.resolvedSymbol != nil { + return links.resolvedSymbol + } + if links.resolvedSymbolNoDiagnostics == nil { + var symbol *ast.Symbol + if !ast.NodeIsMissing(node) { + symbol = c.resolveName(node, node.Text(), ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, + nil, !ast.IsWriteOnlyAccess(node), false /*excludeGlobals*/) + } + links.resolvedSymbolNoDiagnostics = core.OrElse(symbol, c.unknownSymbol) + } + return links.resolvedSymbolNoDiagnostics +} + func (c *Checker) getCannotFindNameDiagnosticForName(node *ast.Node) *diagnostics.Message { switch node.Text() { case "document", "console": @@ -16819,7 +16836,7 @@ func (c *Checker) getDeclaredTypeOfClassOrInterface(symbol *ast.Symbol) *Type { d.allTypeParameters = append(typeParameters, d.thisType) d.outerTypeParameterCount = len(outerTypeParameters) d.resolvedTypeArguments = d.TypeParameters() - d.instantiations = make(map[string]*Type) + d.instantiations = make(map[CacheHashKey]*Type) d.instantiations[getTypeListKey(d.resolvedTypeArguments)] = t d.target = t } @@ -16854,85 +16871,87 @@ func (c *Checker) isThislessInterface(symbol *ast.Symbol) bool { return true } -type KeyBuilder struct { - strings.Builder +func hashWrite32[T ~int32 | ~uint32](h *xxh3.Hasher, value T) { + v := uint32(value) + _, _ = h.Write([]byte{ + byte(v), + byte(v >> 8), + byte(v >> 16), + byte(v >> 24), + }) } -var base64chars = []byte{ - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '$', '%', +func hashWrite64[T ~int | ~uint | ~int64 | ~uint64](h *xxh3.Hasher, value T) { + v := uint64(value) + _, _ = h.Write([]byte{ + byte(v), + byte(v >> 8), + byte(v >> 16), + byte(v >> 24), + byte(v >> 32), + byte(v >> 40), + byte(v >> 48), + byte(v >> 56), + }) } -func (b *KeyBuilder) WriteUint64(value uint64) { - for value != 0 { - b.WriteByte(base64chars[value&0x3F]) - value >>= 6 - } +type CacheHashKey xxh3.Uint128 + +func (k CacheHashKey) IsZero() bool { + return xxh3.Uint128(k) == xxh3.Uint128{} } -func (b *KeyBuilder) WriteInt(value int) { - b.WriteUint64(uint64(int64(value))) +type keyBuilder struct { + h xxh3.Hasher } -func (b *KeyBuilder) WriteSymbolId(id ast.SymbolId) { - b.WriteUint64(uint64(id)) +func (b *keyBuilder) hash() CacheHashKey { + return CacheHashKey(b.h.Sum128()) } -func (b *KeyBuilder) WriteSymbol(s *ast.Symbol) { - b.WriteSymbolId(ast.GetSymbolId(s)) +func (b *keyBuilder) writeByte(c byte) { + _, _ = b.h.Write([]byte{c}) } -func (b *KeyBuilder) WriteTypeId(id TypeId) { - b.WriteUint64(uint64(id)) +func (b *keyBuilder) writeString(s string) { + _, _ = b.h.WriteString(s) } -func (b *KeyBuilder) WriteType(t *Type) { - b.WriteTypeId(t.id) +func (b *keyBuilder) writeInt(value int) { + hashWrite64(&b.h, value) } -func (b *KeyBuilder) WriteTypes(types []*Type) { - i := 0 - var tail bool - for i < len(types) { - startId := types[i].id - count := 1 - for i+count < len(types) && types[i+count].id == startId+TypeId(count) { - count++ - } - if tail { - b.WriteByte(',') - } - b.WriteTypeId(startId) - if count > 1 { - b.WriteByte(':') - b.WriteInt(count) - } - i += count - tail = true +func (b *keyBuilder) writeSymbol(s *ast.Symbol) { + hashWrite64(&b.h, ast.GetSymbolId(s)) +} + +func (b *keyBuilder) writeType(t *Type) { + hashWrite32(&b.h, t.id) +} + +func (b *keyBuilder) writeTypes(types []*Type) { + b.writeInt(len(types)) + for _, t := range types { + b.writeType(t) } } -func (b *KeyBuilder) WriteAlias(alias *TypeAlias) { +func (b *keyBuilder) writeAlias(alias *TypeAlias) { if alias != nil { - b.WriteByte('@') - b.WriteSymbol(alias.symbol) - if len(alias.typeArguments) != 0 { - b.WriteByte(':') - b.WriteTypes(alias.typeArguments) - } + b.writeByte(1) + b.writeSymbol(alias.symbol) + b.writeTypes(alias.typeArguments) + } else { + b.writeByte(0) } } -func (b *KeyBuilder) WriteGenericTypeReferences(source *Type, target *Type, ignoreConstraints bool) bool { +func (b *keyBuilder) writeGenericTypeReferences(source *Type, target *Type, ignoreConstraints bool) bool { var constrained bool typeParameters := make([]*Type, 0, 8) var writeTypeReference func(*Type, int) - // writeTypeReference(A) writes "111=0-12=1" - // where A.id=111 and number.id=12 writeTypeReference = func(ref *Type, depth int) { - b.WriteType(ref.Target()) + b.writeType(ref.Target()) for _, t := range ref.AsTypeReference().resolvedTypeArguments { if t.flags&TypeFlagsTypeParameter != 0 { if ignoreConstraints || t.checker.getConstraintOfTypeParameter(t) == nil { @@ -16941,193 +16960,179 @@ func (b *KeyBuilder) WriteGenericTypeReferences(source *Type, target *Type, igno index = len(typeParameters) typeParameters = append(typeParameters, t) } - b.WriteByte('=') - b.WriteInt(index) + b.writeByte('=') + b.writeInt(index) continue } constrained = true } else if depth < 4 && isTypeReferenceWithGenericArguments(t) { - b.WriteByte('<') + b.writeByte('<') writeTypeReference(t, depth+1) - b.WriteByte('>') + b.writeByte('>') continue } - b.WriteByte('-') - b.WriteType(t) + b.writeByte('-') + b.writeType(t) } } writeTypeReference(source, 0) - b.WriteByte(',') + b.writeByte(',') writeTypeReference(target, 0) return constrained } -func (b *KeyBuilder) WriteNodeId(id ast.NodeId) { - b.WriteUint64(uint64(id)) +func (b *keyBuilder) writeNodeId(id ast.NodeId) { + hashWrite64(&b.h, id) } -func (b *KeyBuilder) WriteNode(node *ast.Node) { +func (b *keyBuilder) writeNode(node *ast.Node) { if node != nil { - b.WriteNodeId(ast.GetNodeId(node)) + b.writeNodeId(ast.GetNodeId(node)) } } -func getTypeListKey(types []*Type) string { - var b KeyBuilder - b.WriteTypes(types) - return b.String() +func getTypeListKey(types []*Type) CacheHashKey { + var b keyBuilder + b.writeTypes(types) + return b.hash() } -func getAliasKey(alias *TypeAlias) string { - var b KeyBuilder - b.WriteAlias(alias) - return b.String() +func getAliasKey(alias *TypeAlias) CacheHashKey { + var b keyBuilder + b.writeAlias(alias) + return b.hash() } -func getUnionKey(types []*Type, origin *Type, alias *TypeAlias) string { - var b KeyBuilder +func getUnionKey(types []*Type, origin *Type, alias *TypeAlias) CacheHashKey { + var b keyBuilder switch { case origin == nil: - b.WriteTypes(types) + b.writeTypes(types) case origin.flags&TypeFlagsUnion != 0: - b.WriteByte('|') - b.WriteTypes(origin.Types()) + b.writeByte('|') + b.writeTypes(origin.Types()) case origin.flags&TypeFlagsIntersection != 0: - b.WriteByte('&') - b.WriteTypes(origin.Types()) + b.writeByte('&') + b.writeTypes(origin.Types()) case origin.flags&TypeFlagsIndex != 0: // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving - b.WriteByte('#') - b.WriteType(origin) - b.WriteByte('|') - b.WriteTypes(types) + b.writeByte('#') + b.writeType(origin) + b.writeByte('|') + b.writeTypes(types) default: panic("Unhandled case in getUnionKey") } - b.WriteAlias(alias) - return b.String() + b.writeAlias(alias) + return b.hash() } -func getIntersectionKey(types []*Type, flags IntersectionFlags, alias *TypeAlias) string { - var b KeyBuilder - b.WriteTypes(types) +func getIntersectionKey(types []*Type, flags IntersectionFlags, alias *TypeAlias) CacheHashKey { + var b keyBuilder + b.writeTypes(types) if flags&IntersectionFlagsNoConstraintReduction == 0 { - b.WriteAlias(alias) + b.writeAlias(alias) } else { - b.WriteByte('*') + b.writeByte('*') } - return b.String() + return b.hash() } -func getTupleKey(elementInfos []TupleElementInfo, readonly bool) string { - var b KeyBuilder +func getTupleKey(elementInfos []TupleElementInfo, readonly bool) CacheHashKey { + var b keyBuilder for _, e := range elementInfos { switch { case e.flags&ElementFlagsRequired != 0: - b.WriteByte('#') + b.writeByte('#') case e.flags&ElementFlagsOptional != 0: - b.WriteByte('?') + b.writeByte('?') case e.flags&ElementFlagsRest != 0: - b.WriteByte('.') + b.writeByte('.') default: - b.WriteByte('*') + b.writeByte('*') } if e.labeledDeclaration != nil { - b.WriteNode(e.labeledDeclaration) + b.writeNode(e.labeledDeclaration) } } if readonly { - b.WriteByte('!') + b.writeByte('!') } - return b.String() + return b.hash() } -func getTypeAliasInstantiationKey(typeArguments []*Type, alias *TypeAlias) string { +func getTypeAliasInstantiationKey(typeArguments []*Type, alias *TypeAlias) CacheHashKey { return getTypeInstantiationKey(typeArguments, alias, false) } -func getTypeInstantiationKey(typeArguments []*Type, alias *TypeAlias, singleSignature bool) string { - var b KeyBuilder - b.WriteTypes(typeArguments) - b.WriteAlias(alias) +func getTypeInstantiationKey(typeArguments []*Type, alias *TypeAlias, singleSignature bool) CacheHashKey { + var b keyBuilder + b.writeTypes(typeArguments) + b.writeAlias(alias) if singleSignature { - b.WriteByte('!') + b.writeByte('!') } - return b.String() + return b.hash() } -func getIndexedAccessKey(objectType *Type, indexType *Type, accessFlags AccessFlags, alias *TypeAlias) string { - var b KeyBuilder - b.WriteType(objectType) - b.WriteByte(',') - b.WriteType(indexType) - b.WriteByte(',') - b.WriteUint64(uint64(accessFlags)) - b.WriteAlias(alias) - return b.String() +func getIndexedAccessKey(objectType *Type, indexType *Type, accessFlags AccessFlags, alias *TypeAlias) CacheHashKey { + var b keyBuilder + b.writeType(objectType) + b.writeType(indexType) + hashWrite32(&b.h, accessFlags) + b.writeAlias(alias) + return b.hash() } -func getTemplateTypeKey(texts []string, types []*Type) string { - var b KeyBuilder - b.WriteTypes(types) - b.WriteByte('|') - for i, s := range texts { - if i != 0 { - b.WriteByte(',') - } - b.WriteInt(len(s)) +func getTemplateTypeKey(texts []string, types []*Type) CacheHashKey { + var b keyBuilder + b.writeTypes(types) + b.writeByte('|') + for _, s := range texts { + b.writeInt(len(s)) } - b.WriteByte('|') + b.writeByte('|') for _, s := range texts { - b.WriteString(s) + b.writeString(s) } - return b.String() + return b.hash() } -func getConditionalTypeKey(typeArguments []*Type, alias *TypeAlias, forConstraint bool) string { - var b KeyBuilder - b.WriteTypes(typeArguments) - b.WriteAlias(alias) +func getConditionalTypeKey(typeArguments []*Type, alias *TypeAlias, forConstraint bool) CacheHashKey { + var b keyBuilder + b.writeTypes(typeArguments) + b.writeAlias(alias) if forConstraint { - b.WriteByte('!') + b.writeByte('!') } - return b.String() + return b.hash() } -func getRelationKey(source *Type, target *Type, intersectionState IntersectionState, isIdentity bool, ignoreConstraints bool) string { +func getRelationKey(source *Type, target *Type, intersectionState IntersectionState, isIdentity bool, ignoreConstraints bool) (CacheHashKey, bool) { if isIdentity && source.id > target.id { source, target = target, source } - var b KeyBuilder + var b keyBuilder var constrained bool if isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) { - constrained = b.WriteGenericTypeReferences(source, target, ignoreConstraints) + b.writeByte('g') + constrained = b.writeGenericTypeReferences(source, target, ignoreConstraints) } else { - b.WriteType(source) - b.WriteByte(',') - b.WriteType(target) + b.writeByte('s') + b.writeType(source) + b.writeType(target) } - if intersectionState != IntersectionStateNone { - b.WriteByte(':') - b.WriteUint64(uint64(intersectionState)) - } - if constrained { - // We mark keys with type references that reference constrained type parameters such that we know - // to obtain and look for a "broadest equivalent key" in the cache. - b.WriteByte('*') - } - return b.String() + hashWrite32(&b.h, intersectionState) + return b.hash(), constrained } -func getNodeListKey(nodes []*ast.Node) string { - var b KeyBuilder - for i, n := range nodes { - if i > 0 { - b.WriteByte(',') - } - b.WriteNode(n) +func getNodeListKey(nodes []*ast.Node) CacheHashKey { + var b keyBuilder + b.writeInt(len(nodes)) + for _, n := range nodes { + b.writeNode(n) } - return b.String() + return b.hash() } func isTypeReferenceWithGenericArguments(t *Type) bool { @@ -21501,10 +21506,10 @@ func (c *Checker) instantiateTypeWithAlias(t *Type, m *TypeMapper, alias *TypeAl if index == -1 { c.pushActiveMapper(m) } - var b KeyBuilder - b.WriteType(t) - b.WriteAlias(alias) - key := b.String() + var b keyBuilder + b.writeType(t) + b.writeAlias(alias) + key := b.hash() cache := c.activeTypeMappersCaches[core.IfElse(index != -1, index, len(c.activeTypeMappersCaches)-1)] if cachedType, ok := cache[key]; ok { return cachedType @@ -21530,10 +21535,10 @@ func (c *Checker) pushActiveMapper(mapper *TypeMapper) { // The cap may contain an empty map from popActiveMapper; reuse it. c.activeTypeMappersCaches = c.activeTypeMappersCaches[:lastIndex+1] if c.activeTypeMappersCaches[lastIndex] == nil { - c.activeTypeMappersCaches[lastIndex] = make(map[string]*Type, 1) + c.activeTypeMappersCaches[lastIndex] = make(map[CacheHashKey]*Type, 1) } } else { - c.activeTypeMappersCaches = append(c.activeTypeMappersCaches, make(map[string]*Type, 1)) + c.activeTypeMappersCaches = append(c.activeTypeMappersCaches, make(map[CacheHashKey]*Type, 1)) } } @@ -21744,7 +21749,7 @@ func (c *Checker) getObjectTypeInstantiation(t *Type, m *TypeMapper, alias *Type data := target.AsObjectType() key := getTypeInstantiationKey(typeArguments, newAlias, t.objectFlags&ObjectFlagsSingleSignatureType != 0) if data.instantiations == nil { - data.instantiations = make(map[string]*Type) + data.instantiations = make(map[CacheHashKey]*Type) data.instantiations[getTypeInstantiationKey(typeParameters, target.alias, false)] = target } result := data.instantiations[key] @@ -22365,12 +22370,12 @@ func (c *Checker) getESSymbolLikeTypeForNode(node *ast.Node) *Type { if symbol != nil { uniqueType := c.uniqueESSymbolTypes[symbol] if uniqueType == nil { - var b KeyBuilder + var b strings.Builder b.WriteString(ast.InternalSymbolNamePrefix) b.WriteByte('@') b.WriteString(symbol.Name) b.WriteByte('@') - b.WriteSymbol(symbol) + b.WriteString(strconv.FormatUint(uint64(ast.GetSymbolId(symbol)), 10)) uniqueType = c.newUniqueESSymbolType(symbol, b.String()) c.uniqueESSymbolTypes[symbol] = uniqueType } @@ -23160,7 +23165,7 @@ func (c *Checker) getDeclaredTypeOfTypeAlias(symbol *ast.Symbol) *Type { // Initialize the instantiation cache for generic type aliases. The declared type corresponds to // an instantiation of the type alias with the type parameters supplied as type arguments. links.typeParameters = typeParameters - links.instantiations = make(map[string]*Type) + links.instantiations = make(map[CacheHashKey]*Type) links.instantiations[getTypeListKey(typeParameters)] = t } if t == c.intrinsicMarkerType && symbol.Name == "BuiltinIteratorReturn" { @@ -23595,7 +23600,7 @@ func (c *Checker) getTypeFromConditionalTypeNode(node *ast.Node) *Type { } links.resolvedType = c.getConditionalType(root, nil /*mapper*/, false /*forConstraint*/, nil) if outerTypeParameters != nil { - root.instantiations = make(map[string]*Type) + root.instantiations = make(map[CacheHashKey]*Type) root.instantiations[getTypeListKey(outerTypeParameters)] = links.resolvedType } } @@ -24115,7 +24120,7 @@ func (c *Checker) createTupleTargetType(elementInfos []TupleElementInfo, readonl d.thisType.AsTypeParameter().isThisType = true d.thisType.AsTypeParameter().constraint = t d.allTypeParameters = append(typeParameters, d.thisType) - d.instantiations = make(map[string]*Type) + d.instantiations = make(map[CacheHashKey]*Type) d.instantiations[getTypeListKey(d.TypeParameters())] = t d.target = t d.resolvedTypeArguments = d.TypeParameters() @@ -31053,7 +31058,7 @@ func (c *Checker) getApplicableIndexSymbol(t *Type, keyType *Type) *ast.Symbol { declarationList := core.MapNonNil(infos, func(info *IndexInfo) *ast.Node { return info.declaration }) nodeListId := getNodeListKey(declarationList) if indexSymbolLinks.filteredIndexSymbolCache == nil { - indexSymbolLinks.filteredIndexSymbolCache = make(map[string]*ast.Symbol) + indexSymbolLinks.filteredIndexSymbolCache = make(map[CacheHashKey]*ast.Symbol) } if result, ok := indexSymbolLinks.filteredIndexSymbolCache[nodeListId]; ok { return result diff --git a/pkg/checker/emitresolver.go b/pkg/checker/emitresolver.go index 770988042..da378c025 100644 --- a/pkg/checker/emitresolver.go +++ b/pkg/checker/emitresolver.go @@ -828,7 +828,7 @@ func (r *EmitResolver) getReferenceResolver() binder.ReferenceResolver { if r.referenceResolver == nil { r.referenceResolver = binder.NewReferenceResolver(r.checker.compilerOptions, binder.ReferenceResolverHooks{ ResolveName: r.checker.resolveName, - GetResolvedSymbol: r.checker.getResolvedSymbol, + GetResolvedSymbol: r.checker.getResolvedSymbolNoDiagnostics, GetMergedSymbol: r.checker.getMergedSymbol, GetParentOfSymbol: r.checker.getParentOfSymbol, GetSymbolOfDeclaration: r.checker.getSymbolOfDeclaration, diff --git a/pkg/checker/flow.go b/pkg/checker/flow.go index 08fe598c4..6cf823063 100644 --- a/pkg/checker/flow.go +++ b/pkg/checker/flow.go @@ -12,6 +12,7 @@ import ( "github.com/buke/typescript-go-internal/pkg/diagnostics" "github.com/buke/typescript-go-internal/pkg/evaluator" "github.com/buke/typescript-go-internal/pkg/scanner" + "github.com/zeebo/xxh3" ) type FlowType struct { @@ -40,7 +41,7 @@ type FlowState struct { declaredType *Type initialType *Type flowContainer *ast.Node - refKey string + refKey CacheHashKey depth int sharedFlowStart int reduceLabels []*ast.FlowReduceLabelData @@ -1288,10 +1289,10 @@ func (c *Checker) getUnionOrEvolvingArrayType(f *FlowState, types []*Type, subty } func (c *Checker) getTypeAtFlowLoopLabel(f *FlowState, flow *ast.FlowNode) FlowType { - if f.refKey == "" { + if f.refKey.IsZero() { f.refKey = c.getFlowReferenceKey(f) } - if f.refKey == "?" { + if f.refKey == nonDottedNameCacheKey { // No cache key is generated when binding patterns are in unnarrowable situations return FlowType{t: f.declaredType} } @@ -1607,19 +1608,21 @@ func (c *Checker) isMatchingReference(source *ast.Node, target *ast.Node) bool { return false } +var nonDottedNameCacheKey = CacheHashKey(xxh3.HashString128("?")) + // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the // leftmost identifier followed by zero or more property names separated by dots. -// The result is an empty string if the reference isn't a dotted name. -func (c *Checker) getFlowReferenceKey(f *FlowState) string { - var b KeyBuilder +// The result is nonDottedNameCacheKey if the reference isn't a dotted name. +func (c *Checker) getFlowReferenceKey(f *FlowState) CacheHashKey { + var b keyBuilder if c.writeFlowCacheKey(&b, f.reference, f.declaredType, f.initialType, f.flowContainer) { - return b.String() + return b.hash() } - return "?" // Reference isn't a dotted name + return nonDottedNameCacheKey // Reference isn't a dotted name } -func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType *Type, initialType *Type, flowContainer *ast.Node) bool { +func (c *Checker) writeFlowCacheKey(b *keyBuilder, node *ast.Node, declaredType *Type, initialType *Type, flowContainer *ast.Node) bool { switch node.Kind { case ast.KindIdentifier: if !ast.IsThisInTypeQuery(node) { @@ -1627,19 +1630,19 @@ func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType if symbol == c.unknownSymbol { return false } - b.WriteSymbol(symbol) + b.writeSymbol(symbol) } fallthrough case ast.KindThisKeyword: - b.WriteByte(':') - b.WriteType(declaredType) + b.writeByte(':') + b.writeType(declaredType) if initialType != declaredType { - b.WriteByte('=') - b.WriteType(initialType) + b.writeByte('=') + b.writeType(initialType) } if flowContainer != nil { - b.WriteByte('@') - b.WriteNode(flowContainer) + b.writeByte('@') + b.writeNode(flowContainer) } return true case ast.KindNonNullExpression, ast.KindParenthesizedExpression: @@ -1648,16 +1651,16 @@ func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType if !c.writeFlowCacheKey(b, node.AsQualifiedName().Left, declaredType, initialType, flowContainer) { return false } - b.WriteByte('.') - b.WriteString(node.AsQualifiedName().Right.Text()) + b.writeByte('.') + b.writeString(node.AsQualifiedName().Right.Text()) return true case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: if propName, ok := c.getAccessedPropertyName(node); ok { if !c.writeFlowCacheKey(b, node.Expression(), declaredType, initialType, flowContainer) { return false } - b.WriteByte('.') - b.WriteString(propName) + b.writeByte('.') + b.writeString(propName) return true } if ast.IsElementAccessExpression(node) && ast.IsIdentifier(node.AsElementAccessExpression().ArgumentExpression) { @@ -1666,16 +1669,16 @@ func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType if !c.writeFlowCacheKey(b, node.Expression(), declaredType, initialType, flowContainer) { return false } - b.WriteString(".@") - b.WriteSymbol(symbol) + b.writeString(".@") + b.writeSymbol(symbol) return true } } case ast.KindObjectBindingPattern, ast.KindArrayBindingPattern, ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindMethodDeclaration: - b.WriteNode(node) - b.WriteByte('#') - b.WriteType(declaredType) + b.writeNode(node) + b.writeByte('#') + b.writeType(declaredType) return true } return false diff --git a/pkg/checker/relater.go b/pkg/checker/relater.go index e4748ea83..38ae88c6d 100644 --- a/pkg/checker/relater.go +++ b/pkg/checker/relater.go @@ -97,16 +97,16 @@ func asRecursionId[T *ast.Node | *ast.Symbol | *Type](value T) RecursionId { } type Relation struct { - results map[string]RelationComparisonResult + results map[CacheHashKey]RelationComparisonResult } -func (r *Relation) get(key string) RelationComparisonResult { +func (r *Relation) get(key CacheHashKey) RelationComparisonResult { return r.results[key] } -func (r *Relation) set(key string, result RelationComparisonResult) { +func (r *Relation) set(key CacheHashKey, result RelationComparisonResult) { if r.results == nil { - r.results = make(map[string]RelationComparisonResult) + r.results = make(map[CacheHashKey]RelationComparisonResult) } r.results[key] = result } @@ -191,7 +191,8 @@ func (c *Checker) isTypeRelatedTo(source *Type, target *Type, relation *Relation } } if source.flags&TypeFlagsObject != 0 && target.flags&TypeFlagsObject != 0 { - related := relation.get(getRelationKey(source, target, IntersectionStateNone, relation == c.identityRelation, false)) + id, _ := getRelationKey(source, target, IntersectionStateNone, relation == c.identityRelation, false) + related := relation.get(id) if related != RelationComparisonResultNone { return related&RelationComparisonResultSucceeded != 0 } @@ -370,7 +371,7 @@ func (c *Checker) checkTypeRelatedToEx( result := r.isRelatedToEx(source, target, RecursionFlagsBoth, errorNode != nil /*reportErrors*/, headMessage, IntersectionStateNone) if r.overflow { // Record this relation as having failed such that we don't attempt the overflowing operation again. - id := getRelationKey(source, target, IntersectionStateNone, relation == c.identityRelation, false /*ignoreConstraints*/) + id, _ := getRelationKey(source, target, IntersectionStateNone, relation == c.identityRelation, false /*ignoreConstraints*/) relation.set(id, RelationComparisonResultFailed|core.IfElse(r.relationCount <= 0, RelationComparisonResultComplexityOverflow, RelationComparisonResultStackDepthOverflow)) message := core.IfElse(r.relationCount <= 0, diagnostics.Excessive_complexity_comparing_types_0_and_1, diagnostics.Excessive_stack_depth_comparing_types_0_and_1) if errorNode == nil { @@ -2504,8 +2505,8 @@ type Relater struct { errorNode *ast.Node errorChain *ErrorChain relatedInfo []*ast.Diagnostic - maybeKeys []string - maybeKeysSet collections.Set[string] + maybeKeys []CacheHashKey + maybeKeysSet collections.Set[CacheHashKey] sourceStack []*Type targetStack []*Type maybeCount int @@ -3014,7 +3015,7 @@ func (r *Relater) recursiveTypeRelatedTo(source *Type, target *Type, reportError if r.overflow { return TernaryFalse } - id := getRelationKey(source, target, intersectionState, r.relation == r.c.identityRelation, false /*ignoreConstraints*/) + id, constrained := getRelationKey(source, target, intersectionState, r.relation == r.c.identityRelation, false /*ignoreConstraints*/) if entry := r.relation.get(id); entry != RelationComparisonResultNone { if reportErrors && entry&RelationComparisonResultFailed != 0 && entry&RelationComparisonResultOverflow == 0 { // We are elaborating errors and the cached result is a failure not due to a comparison overflow, @@ -3041,11 +3042,11 @@ func (r *Relater) recursiveTypeRelatedTo(source *Type, target *Type, reportError if r.maybeKeysSet.Has(id) { return TernaryMaybe } - // A key that ends with "*" is an indication that we have type references that reference constrained + // A constrained key indicates that we have type references that reference constrained // type parameters. For such keys we also check against the key we would have gotten if all type parameters // were unconstrained. - if strings.HasSuffix(id, "*") { - broadestEquivalentId := getRelationKey(source, target, intersectionState, r.relation == r.c.identityRelation, true /*ignoreConstraints*/) + if constrained { + broadestEquivalentId, _ := getRelationKey(source, target, intersectionState, r.relation == r.c.identityRelation, true /*ignoreConstraints*/) if r.maybeKeysSet.Has(broadestEquivalentId) { return TernaryMaybe } diff --git a/pkg/checker/types.go b/pkg/checker/types.go index da5e2e9d8..628345351 100644 --- a/pkg/checker/types.go +++ b/pkg/checker/types.go @@ -183,8 +183,8 @@ type ExportTypeLinks struct { type TypeAliasLinks struct { declaredType *Type - typeParameters []*Type // Type parameters of type alias (undefined if non-generic) - instantiations map[string]*Type // Instantiations of generic type alias (undefined if non-generic) + typeParameters []*Type // Type parameters of type alias (undefined if non-generic) + instantiations map[CacheHashKey]*Type // Instantiations of generic type alias (undefined if non-generic) isConstructorDeclaredProperty bool } @@ -261,7 +261,7 @@ const ( ) type IndexSymbolLinks struct { - filteredIndexSymbolCache map[string]*ast.Symbol // Symbol with applicable declarations + filteredIndexSymbolCache map[CacheHashKey]*ast.Symbol // Symbol with applicable declarations } type MarkedAssignmentSymbolLinks struct { @@ -337,7 +337,8 @@ type NodeLinks struct { } type SymbolNodeLinks struct { - resolvedSymbol *ast.Symbol // Resolved symbol associated with node + resolvedSymbol *ast.Symbol // Resolved symbol associated with node + resolvedSymbolNoDiagnostics *ast.Symbol // Resolved symbol associated with node, generated without producing diagnostics for an API call } type TypeNodeLinks struct { @@ -849,9 +850,9 @@ func (t *StructuredType) Properties() []*ast.Symbol { type ObjectType struct { StructuredType - target *Type // Target of instantiated type - mapper *TypeMapper // Type mapper for instantiated type - instantiations map[string]*Type // Map of type instantiations + target *Type // Target of instantiated type + mapper *TypeMapper // Type mapper for instantiated type + instantiations map[CacheHashKey]*Type // Map of type instantiations } func (t *ObjectType) AsObjectType() *ObjectType { return t } @@ -1081,7 +1082,7 @@ type ConditionalRoot struct { isDistributive bool inferTypeParameters []*Type outerTypeParameters []*Type - instantiations map[string]*Type + instantiations map[CacheHashKey]*Type alias *TypeAlias } diff --git a/pkg/ls/hover.go b/pkg/ls/hover.go index 4710304b8..8fd4ebf9e 100644 --- a/pkg/ls/hover.go +++ b/pkg/ls/hover.go @@ -68,21 +68,21 @@ func (l *LanguageService) getQuickInfoAndDocumentationForSymbol(c *checker.Check if quickInfo == "" { return "", "" } - return quickInfo, l.getDocumentationFromDeclaration(c, declaration, contentFormat) + return quickInfo, l.getDocumentationFromDeclaration(c, declaration, contentFormat, false /*commentOnly*/) } -func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, declaration *ast.Node, contentFormat lsproto.MarkupKind) string { +func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, declaration *ast.Node, contentFormat lsproto.MarkupKind, commentOnly bool) string { if declaration == nil { return "" } isMarkdown := contentFormat == lsproto.MarkupKindMarkdown var b strings.Builder - if jsdoc := getJSDocOrTag(c, declaration); jsdoc != nil && !containsTypedefTag(jsdoc) { + if jsdoc := getJSDocOrTag(c, declaration); jsdoc != nil && !(declaration.Flags&ast.NodeFlagsReparsed == 0 && containsTypedefTag(jsdoc)) { l.writeComments(&b, c, jsdoc.Comments(), isMarkdown) - if jsdoc.Kind == ast.KindJSDoc { + if jsdoc.Kind == ast.KindJSDoc && !commentOnly { if tags := jsdoc.AsJSDoc().Tags; tags != nil { for _, tag := range tags.Nodes { - if tag.Kind == ast.KindJSDocTypeTag { + if tag.Kind == ast.KindJSDocTypeTag || tag.Kind == ast.KindJSDocTypedefTag || tag.Kind == ast.KindJSDocCallbackTag { continue } b.WriteString("\n\n") @@ -142,7 +142,7 @@ func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, de } } else if len(comments) != 0 { b.WriteString(" ") - if !commentHasPrefix(comments, "-") { + if comments[0].Kind != ast.KindJSDocText || !strings.HasPrefix(comments[0].Text(), "-") { b.WriteString("— ") } l.writeComments(&b, c, comments, isMarkdown) @@ -307,7 +307,7 @@ func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol b.WriteString(" = ") b.WriteString(c.TypeToStringEx(c.GetDeclaredTypeOfSymbol(symbol), container, typeFormatFlags|checker.TypeFormatFlagsInTypeAlias)) } - declaration = core.Find(symbol.Declarations, ast.IsTypeAliasDeclaration) + declaration = core.Find(symbol.Declarations, ast.IsTypeOrJSTypeAliasDeclaration) default: b.WriteString(c.TypeToStringEx(c.GetTypeOfSymbol(symbol), container, typeFormatFlags)) } @@ -442,10 +442,6 @@ func containsTypedefTag(jsdoc *ast.Node) bool { return false } -func commentHasPrefix(comments []*ast.Node, prefix string) bool { - return comments[0].Kind == ast.KindJSDocText && strings.HasPrefix(comments[0].Text(), prefix) -} - func getJSDoc(node *ast.Node) *ast.Node { return core.LastOrNil(node.JSDoc(nil)) } diff --git a/pkg/ls/signaturehelp.go b/pkg/ls/signaturehelp.go index 694094b63..797ec8ea2 100644 --- a/pkg/ls/signaturehelp.go +++ b/pkg/ls/signaturehelp.go @@ -418,9 +418,9 @@ func (l *LanguageService) computeActiveParameter(sig signatureInformation, argum func (l *LanguageService) getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool, callTargetSymbol string, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, c *checker.Checker, docFormat lsproto.MarkupKind) []signatureInformation { var infos []*signatureHelpItemInfo if isTypeParameterList { - infos = itemInfoForTypeParameters(candidate, c, enclosingDeclaration, sourceFile) + infos = l.itemInfoForTypeParameters(candidate, c, enclosingDeclaration, sourceFile, docFormat) } else { - infos = itemInfoForParameters(candidate, c, enclosingDeclaration, sourceFile) + infos = l.itemInfoForParameters(candidate, c, enclosingDeclaration, sourceFile, docFormat) } suffixDisplayParts := returnTypeToDisplayParts(candidate, c) @@ -428,7 +428,7 @@ func (l *LanguageService) getSignatureHelpItem(candidate *checker.Signature, isT // Generate documentation from the signature's declaration var documentation *string if declaration := candidate.Declaration(); declaration != nil { - doc := l.getDocumentationFromDeclaration(c, declaration, docFormat) + doc := l.getDocumentationFromDeclaration(c, declaration, docFormat, true /*commentOnly*/) if doc != "" { documentation = &doc } @@ -462,7 +462,7 @@ func returnTypeToDisplayParts(candidateSignature *checker.Signature, c *checker. return returnType.String() } -func itemInfoForTypeParameters(candidateSignature *checker.Signature, c *checker.Checker, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile) []*signatureHelpItemInfo { +func (l *LanguageService) itemInfoForTypeParameters(candidateSignature *checker.Signature, c *checker.Checker, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, docFormat lsproto.MarkupKind) []*signatureHelpItemInfo { printer := printer.NewPrinter(printer.PrinterOptions{NewLine: core.NewLineKindLF}, printer.PrintHandlers{}, nil) var typeParameters []*checker.Type @@ -478,7 +478,7 @@ func itemInfoForTypeParameters(candidateSignature *checker.Signature, c *checker thisParameter := []signatureHelpParameter{} if candidateSignature.ThisParameter() != nil { - thisParameter = []signatureHelpParameter{createSignatureHelpParameterForParameter(candidateSignature.ThisParameter(), enclosingDeclaration, printer, sourceFile, c)} + thisParameter = []signatureHelpParameter{l.createSignatureHelpParameterForParameter(candidateSignature.ThisParameter(), enclosingDeclaration, printer, sourceFile, c, docFormat)} } // Creating type parameter display label @@ -504,7 +504,7 @@ func itemInfoForTypeParameters(candidateSignature *checker.Signature, c *checker displayParameters.WriteString(displayParts.String()) parameters := thisParameter for j, param := range parameterList { - parameter := createSignatureHelpParameterForParameter(param, enclosingDeclaration, printer, sourceFile, c) + parameter := l.createSignatureHelpParameterForParameter(param, enclosingDeclaration, printer, sourceFile, c, docFormat) parameters = append(parameters, parameter) if j > 0 { displayParameters.WriteString(", ") @@ -522,7 +522,7 @@ func itemInfoForTypeParameters(candidateSignature *checker.Signature, c *checker return result } -func itemInfoForParameters(candidateSignature *checker.Signature, c *checker.Checker, enclosingDeclaratipn *ast.Node, sourceFile *ast.SourceFile) []*signatureHelpItemInfo { +func (l *LanguageService) itemInfoForParameters(candidateSignature *checker.Signature, c *checker.Checker, enclosingDeclaratipn *ast.Node, sourceFile *ast.SourceFile, docFormat lsproto.MarkupKind) []*signatureHelpItemInfo { printer := printer.NewPrinter(printer.PrinterOptions{NewLine: core.NewLineKindLF}, printer.PrintHandlers{}, nil) signatureHelpTypeParameters := make([]signatureHelpParameter, len(candidateSignature.TypeParameters())) @@ -564,7 +564,7 @@ func itemInfoForParameters(candidateSignature *checker.Signature, c *checker.Che var displayParameters strings.Builder displayParameters.WriteString(displayParts.String()) for j, param := range parameterList { - parameter := createSignatureHelpParameterForParameter(param, enclosingDeclaratipn, printer, sourceFile, c) + parameter := l.createSignatureHelpParameterForParameter(param, enclosingDeclaratipn, printer, sourceFile, c, docFormat) parameters[j] = parameter if j > 0 { displayParameters.WriteString(", ") @@ -585,14 +585,26 @@ func itemInfoForParameters(candidateSignature *checker.Signature, c *checker.Che const signatureHelpNodeBuilderFlags = nodebuilder.FlagsOmitParameterModifiers | nodebuilder.FlagsIgnoreErrors | nodebuilder.FlagsUseAliasDefinedOutsideCurrentScope -func createSignatureHelpParameterForParameter(parameter *ast.Symbol, enclosingDeclaratipn *ast.Node, p *printer.Printer, sourceFile *ast.SourceFile, c *checker.Checker) signatureHelpParameter { +func (l *LanguageService) createSignatureHelpParameterForParameter(parameter *ast.Symbol, enclosingDeclaratipn *ast.Node, p *printer.Printer, sourceFile *ast.SourceFile, c *checker.Checker, docFormat lsproto.MarkupKind) signatureHelpParameter { display := p.Emit(checker.NewNodeBuilder(c, printer.NewEmitContext()).SymbolToParameterDeclaration(parameter, enclosingDeclaratipn, signatureHelpNodeBuilderFlags, nodebuilder.InternalFlagsNone, nil), sourceFile) isOptional := parameter.CheckFlags&ast.CheckFlagsOptionalParameter != 0 isRest := parameter.CheckFlags&ast.CheckFlagsRestParameter != 0 + var documentation *lsproto.StringOrMarkupContent + if parameter.ValueDeclaration != nil { + doc := l.getDocumentationFromDeclaration(c, parameter.ValueDeclaration, docFormat, true /*commentOnly*/) + if doc != "" { + documentation = &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: docFormat, + Value: doc, + }, + } + } + } return signatureHelpParameter{ parameterInfo: &lsproto.ParameterInformation{ Label: lsproto.StringOrTuple{String: &display}, - Documentation: nil, + Documentation: documentation, }, isRest: isRest, isOptional: isOptional, diff --git a/pkg/ls/symbols.go b/pkg/ls/symbols.go index 311a96658..59e21004e 100644 --- a/pkg/ls/symbols.go +++ b/pkg/ls/symbols.go @@ -125,12 +125,14 @@ func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, nod if ctx.Err() != nil { return true } - if jsdocs := node.JSDoc(file); len(jsdocs) > 0 { - for _, jsdoc := range jsdocs { - if tagList := jsdoc.AsJSDoc().Tags; tagList != nil { - for _, tag := range tagList.Nodes { - if ast.IsJSDocTypedefTag(tag) || ast.IsJSDocCallbackTag(tag) { - addSymbolForNode(tag, nil /*children*/) + if node.Flags&ast.NodeFlagsReparsed == 0 { + if jsdocs := node.JSDoc(file); len(jsdocs) > 0 { + for _, jsdoc := range jsdocs { + if tagList := jsdoc.AsJSDoc().Tags; tagList != nil { + for _, tag := range tagList.Nodes { + if ast.IsJSDocTypedefTag(tag) || ast.IsJSDocCallbackTag(tag) { + addSymbolForNode(tag, nil /*children*/) + } } } } diff --git a/pkg/parser/jsdoc.go b/pkg/parser/jsdoc.go index 9df04ca23..90fb7255e 100644 --- a/pkg/parser/jsdoc.go +++ b/pkg/parser/jsdoc.go @@ -298,7 +298,7 @@ loop: func removeLeadingNewlines(comments []string) []string { i := 0 - for i < len(comments) && (comments[i] == "\n" || comments[i] == "\r") { + for i < len(comments) && strings.TrimLeft(comments[i], "\r\n") == "" { i++ } return comments[i:] diff --git a/pkg/parser/reparser.go b/pkg/parser/reparser.go index 4456ad87d..dac509285 100644 --- a/pkg/parser/reparser.go +++ b/pkg/parser/reparser.go @@ -84,6 +84,8 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod } typeAlias.AsTypeAliasDeclaration().Type = t p.finishReparsedNode(typeAlias, tag) + p.jsdocCache[typeAlias] = []*ast.Node{jsDoc} + typeAlias.Flags |= ast.NodeFlagsHasJSDoc p.reparseList = append(p.reparseList, typeAlias) case ast.KindJSDocCallbackTag: callbackTag := tag.AsJSDocCallbackTag() @@ -94,6 +96,8 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod typeAlias := p.factory.NewJSTypeAliasDeclaration(nil, p.factory.DeepCloneReparse(callbackTag.FullName), nil, functionType) typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag) p.finishReparsedNode(typeAlias, tag) + p.jsdocCache[typeAlias] = []*ast.Node{jsDoc} + typeAlias.Flags |= ast.NodeFlagsHasJSDoc p.reparseList = append(p.reparseList, typeAlias) case ast.KindJSDocImportTag: importTag := tag.AsJSDocImportTag() @@ -171,6 +175,7 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD } p.finishReparsedNode(parameter, param) parameters = append(parameters, parameter) + p.reparseJSDocComment(parameter, param) } signature.FunctionLikeData().Parameters = p.newNodeList(jsSignature.AsJSDocSignature().Parameters.Loc, parameters) @@ -205,6 +210,7 @@ func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode) *ast.Node { } p.finishReparsedNode(property, prop) properties = append(properties, property) + p.reparseJSDocComment(property, prop) } t = p.factory.NewTypeLiteralNode(p.newNodeList(jstypeliteral.Loc, properties)) if isArrayType { @@ -212,10 +218,20 @@ func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode) *ast.Node { t = p.factory.NewArrayTypeNode(t) } p.finishReparsedNode(t, jstypeliteral.AsNode()) + return t } return p.factory.DeepCloneReparse(t) } +func (p *Parser) reparseJSDocComment(node *ast.Node, tag *ast.Node) { + if comment := tag.CommentList(); comment != nil { + propJSDoc := p.factory.NewJSDoc(comment, nil) + p.finishReparsedNode(propJSDoc, tag) + p.jsdocCache[node] = []*ast.Node{propJSDoc} + node.Flags |= ast.NodeFlagsHasJSDoc + } +} + func (p *Parser) gatherTypeParameters(j *ast.Node, tagWithTypeParameters *ast.Node) *ast.NodeList { var typeParameters []*ast.Node pos := -1 diff --git a/pkg/project/snapshot.go b/pkg/project/snapshot.go index 2ca064b42..2511ad425 100644 --- a/pkg/project/snapshot.go +++ b/pkg/project/snapshot.go @@ -105,7 +105,10 @@ func (s *Snapshot) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo { } func (s *Snapshot) UserPreferences() *lsutil.UserPreferences { - return s.config.tsUserPreferences + if s.config.tsUserPreferences != nil { + return s.config.tsUserPreferences + } + return lsutil.NewDefaultUserPreferences() } func (s *Snapshot) FormatOptions() *format.FormatCodeSettings { diff --git a/pkg/tsoptions/wildcarddirectories.go b/pkg/tsoptions/wildcarddirectories.go index d995344f2..5906bf9ae 100644 --- a/pkg/tsoptions/wildcarddirectories.go +++ b/pkg/tsoptions/wildcarddirectories.go @@ -1,7 +1,6 @@ package tsoptions import ( - "regexp" "strings" "github.com/dlclark/regexp2" @@ -28,13 +27,13 @@ func getWildcardDirectories(include []string, exclude []string, comparePathsOpti } rawExcludeRegex := vfs.GetRegularExpressionForWildcard(exclude, comparePathsOptions.CurrentDirectory, "exclude") - var excludeRegex *regexp.Regexp + var excludeRegex *regexp2.Regexp if rawExcludeRegex != "" { - options := "" + flags := regexp2.ECMAScript if !comparePathsOptions.UseCaseSensitiveFileNames { - options = "(?i)" + flags |= regexp2.IgnoreCase } - excludeRegex = regexp.MustCompile(options + rawExcludeRegex) + excludeRegex = regexp2.MustCompile(rawExcludeRegex, regexp2.RegexOptions(flags)) } wildcardDirectories := make(map[string]bool) @@ -44,8 +43,10 @@ func getWildcardDirectories(include []string, exclude []string, comparePathsOpti for _, file := range include { spec := tspath.NormalizeSlashes(tspath.CombinePaths(comparePathsOptions.CurrentDirectory, file)) - if excludeRegex != nil && excludeRegex.MatchString(spec) { - continue + if excludeRegex != nil { + if matched, _ := excludeRegex.MatchString(spec); matched { + continue + } } match := getWildcardDirectoryFromSpec(spec, comparePathsOptions.UseCaseSensitiveFileNames) diff --git a/pkg/tsoptions/wildcarddirectories_test.go b/pkg/tsoptions/wildcarddirectories_test.go new file mode 100644 index 000000000..5e81225bc --- /dev/null +++ b/pkg/tsoptions/wildcarddirectories_test.go @@ -0,0 +1,65 @@ +package tsoptions + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/tspath" +) + +func TestGetWildcardDirectories_NonASCIICharacters(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + include []string + exclude []string + currentDirectory string + useCaseSensitiveFileNames bool + }{ + { + name: "Norwegian character æ in path", + include: []string{"src/**/*.test.ts", "src/**/*.stories.ts", "src/**/*.mdx"}, + exclude: []string{"node_modules"}, + currentDirectory: "C:/Users/TobiasLægreid/dev/app/frontend/packages/react", + useCaseSensitiveFileNames: false, + }, + { + name: "Japanese characters in path", + include: []string{"src/**/*.ts"}, + exclude: []string{"テスト"}, + currentDirectory: "/Users/ユーザー/プロジェクト", + useCaseSensitiveFileNames: true, + }, + { + name: "Chinese characters in path", + include: []string{"源代码/**/*.js"}, + exclude: []string{"节点模块"}, + currentDirectory: "/home/用户/项目", + useCaseSensitiveFileNames: true, + }, + { + name: "Various Unicode characters", + include: []string{"src/**/*.ts"}, + exclude: []string{"node_modules"}, + currentDirectory: "/Users/Müller/café/naïve/résumé", + useCaseSensitiveFileNames: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + comparePathsOptions := tspath.ComparePathsOptions{ + CurrentDirectory: tt.currentDirectory, + UseCaseSensitiveFileNames: tt.useCaseSensitiveFileNames, + } + + result := getWildcardDirectories(tt.include, tt.exclude, comparePathsOptions) + + if result == nil { + t.Fatalf("expected non-nil result") + } + }) + } +} diff --git a/pkg/vfs/utilities.go b/pkg/vfs/utilities.go index d9f728248..ca65bd83c 100644 --- a/pkg/vfs/utilities.go +++ b/pkg/vfs/utilities.go @@ -81,11 +81,11 @@ func IsImplicitGlob(lastPathComponent string) bool { return !strings.ContainsAny(lastPathComponent, ".*?") } -// Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. -// It may be inefficient (we could just match (/[-[\]{}()*+?.,\\^$|#\s]/g), but this is future -// proof. +// Reserved characters - only escape actual regex metacharacters. +// Go's regexp doesn't support \x escape sequences for arbitrary characters, +// so we only escape characters that have special meaning in regex. var ( - reservedCharacterPattern *regexp.Regexp = regexp.MustCompile(`[^\w\s/]`) + reservedCharacterPattern *regexp.Regexp = regexp.MustCompile(`[\\.\+*?()\[\]{}^$|#]`) wildcardCharCodes = []rune{'*', '?'} ) diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline index 99a04506f..5306cd56d 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoForJSDocWithHttpLinks.baseline @@ -17,6 +17,7 @@ // | ```tsx // | (property) https: number // | ``` +// | ://wass // | // | ---------------------------------------------------------------------- // */ @@ -105,7 +106,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\n(property) https: number\n```\n" + "value": "```tsx\n(property) https: number\n```\n://wass\n" }, "range": { "start": { diff --git a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline index 05bd1f676..d100750d6 100644 --- a/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline +++ b/testdata/baselines/reference/fourslash/quickInfo/quickInfoJsDocTagsTypedef.baseline @@ -8,7 +8,7 @@ // | ```tsx // | type Bar = { baz: string; qux: string; } // | ``` -// | +// | Bar comment // | ---------------------------------------------------------------------- // * @property {string} baz - baz comment // * @property {string} qux - qux comment @@ -22,7 +22,7 @@ // | ```tsx // | type Bar = { baz: string; qux: string; } // | ``` -// | +// | Bar comment // | ---------------------------------------------------------------------- // * @returns {Bar} // */ @@ -43,7 +43,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\n" + "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\nBar comment" }, "range": { "start": { @@ -70,7 +70,7 @@ "item": { "contents": { "kind": "markdown", - "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\n" + "value": "```tsx\ntype Bar = { baz: string; qux: string; }\n```\nBar comment" }, "range": { "start": { diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline index 09879cb55..e5705afcf 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline @@ -8,10 +8,6 @@ // ^ // | ---------------------------------------------------------------------- // | foo(): module -// | -// | -// | *@returns* — :@nodefuel/web~Webserver~wsServer#hello} Websocket server object -// | // | ---------------------------------------------------------------------- // // /** @@ -46,10 +42,6 @@ "signatures": [ { "label": "foo(): module", - "documentation": { - "kind": "markdown", - "value": "\n\n*@returns* — :@nodefuel/web~Webserver~wsServer#hello} Websocket server object\n" - }, "parameters": [] } ], diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline index f79cc4afe..a97845080 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline @@ -15,22 +15,9 @@ // ^ // | ---------------------------------------------------------------------- // | pathFilter(**basePath: String**, pattern: String, type: String, options: Object): any[] +// | - `basePath: String`: The base path where the search will be performed. + // | Filters a path based on a regexp or glob pattern. -// | -// | *@param* `basePath` — The base path where the search will be performed. -// | -// | -// | *@param* `pattern` — A string defining a regexp of a glob pattern. -// | -// | -// | *@param* `type` — The search pattern type, can be a regexp or a glob. -// | -// | -// | *@param* `options` — A object containing options to the search. -// | -// | -// | *@return* — A list containing the filtered paths. -// | // | ---------------------------------------------------------------------- [ { @@ -49,20 +36,36 @@ "label": "pathFilter(basePath: String, pattern: String, type: String, options: Object): any[]", "documentation": { "kind": "markdown", - "value": "Filters a path based on a regexp or glob pattern.\n\n*@param* `basePath` — The base path where the search will be performed.\n\n\n*@param* `pattern` — A string defining a regexp of a glob pattern.\n\n\n*@param* `type` — The search pattern type, can be a regexp or a glob.\n\n\n*@param* `options` — A object containing options to the search.\n\n\n*@return* — A list containing the filtered paths.\n" + "value": "Filters a path based on a regexp or glob pattern." }, "parameters": [ { - "label": "basePath: String" + "label": "basePath: String", + "documentation": { + "kind": "markdown", + "value": "The base path where the search will be performed.\n" + } }, { - "label": "pattern: String" + "label": "pattern: String", + "documentation": { + "kind": "markdown", + "value": "A string defining a regexp of a glob pattern.\n" + } }, { - "label": "type: String" + "label": "type: String", + "documentation": { + "kind": "markdown", + "value": "The search pattern type, can be a regexp or a glob.\n" + } }, { - "label": "options: Object" + "label": "options: Object", + "documentation": { + "kind": "markdown", + "value": "A object containing options to the search.\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline index 742ccccb8..18bef2575 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline @@ -11,70 +11,26 @@ // ^ // | ---------------------------------------------------------------------- // | f1(**p1: string**, p2: string, p3?: string, p4?: string): void -// | -// | -// | *@param* `p1` - A string param -// | -// | -// | *@param* `p2` - An optional param -// | -// | -// | *@param* `p3` - Another optional param -// | -// | -// | *@param* `p4` - An optional param with a default value -// | +// | - `p1: string`: - A string param + // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, **p2: string**, p3?: string, p4?: string): void -// | -// | -// | *@param* `p1` - A string param -// | -// | -// | *@param* `p2` - An optional param -// | -// | -// | *@param* `p3` - Another optional param -// | -// | -// | *@param* `p4` - An optional param with a default value -// | +// | - `p2: string`: - An optional param + // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, p2: string, **p3?: string**, p4?: string): void -// | -// | -// | *@param* `p1` - A string param -// | -// | -// | *@param* `p2` - An optional param -// | -// | -// | *@param* `p3` - Another optional param -// | -// | -// | *@param* `p4` - An optional param with a default value -// | +// | - `p3?: string`: - Another optional param + // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | f1(p1: string, p2: string, p3?: string, **p4?: string**): void -// | -// | -// | *@param* `p1` - A string param -// | -// | -// | *@param* `p2` - An optional param -// | -// | -// | *@param* `p3` - Another optional param -// | -// | -// | *@param* `p4` - An optional param with a default value -// | +// | - `p4?: string`: - An optional param with a default value + // | ---------------------------------------------------------------------- [ { @@ -91,22 +47,34 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" - }, "parameters": [ { - "label": "p1: string" + "label": "p1: string", + "documentation": { + "kind": "markdown", + "value": "- A string param\n" + } }, { - "label": "p2: string" + "label": "p2: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param\n" + } }, { - "label": "p3?: string" + "label": "p3?: string", + "documentation": { + "kind": "markdown", + "value": "- Another optional param\n" + } }, { - "label": "p4?: string" + "label": "p4?: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param with a default value\n" + } } ], "activeParameter": 0 @@ -129,22 +97,34 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" - }, "parameters": [ { - "label": "p1: string" + "label": "p1: string", + "documentation": { + "kind": "markdown", + "value": "- A string param\n" + } }, { - "label": "p2: string" + "label": "p2: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param\n" + } }, { - "label": "p3?: string" + "label": "p3?: string", + "documentation": { + "kind": "markdown", + "value": "- Another optional param\n" + } }, { - "label": "p4?: string" + "label": "p4?: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param with a default value\n" + } } ], "activeParameter": 1 @@ -167,22 +147,34 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" - }, "parameters": [ { - "label": "p1: string" + "label": "p1: string", + "documentation": { + "kind": "markdown", + "value": "- A string param\n" + } }, { - "label": "p2: string" + "label": "p2: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param\n" + } }, { - "label": "p3?: string" + "label": "p3?: string", + "documentation": { + "kind": "markdown", + "value": "- Another optional param\n" + } }, { - "label": "p4?: string" + "label": "p4?: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param with a default value\n" + } } ], "activeParameter": 2 @@ -205,22 +197,34 @@ "signatures": [ { "label": "f1(p1: string, p2: string, p3?: string, p4?: string): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `p1` - A string param\n\n\n*@param* `p2` - An optional param\n\n\n*@param* `p3` - Another optional param\n\n\n*@param* `p4` - An optional param with a default value\n" - }, "parameters": [ { - "label": "p1: string" + "label": "p1: string", + "documentation": { + "kind": "markdown", + "value": "- A string param\n" + } }, { - "label": "p2: string" + "label": "p2: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param\n" + } }, { - "label": "p3?: string" + "label": "p3?: string", + "documentation": { + "kind": "markdown", + "value": "- Another optional param\n" + } }, { - "label": "p4?: string" + "label": "p4?: string", + "documentation": { + "kind": "markdown", + "value": "- An optional param with a default value\n" + } } ], "activeParameter": 3 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline index 4551f8a9c..3134f625a 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline @@ -14,15 +14,6 @@ // | ---------------------------------------------------------------------- // | find(**l: unknown[]**, x: unknown): unknown // | Find an item -// | -// | *@template* `T` -// | -// | *@param* `l` -// | -// | *@param* `x` -// | -// | *@returns* — The names of the found item(s). -// | // | ---------------------------------------------------------------------- [ { @@ -41,7 +32,7 @@ "label": "find(l: unknown[], x: unknown): unknown", "documentation": { "kind": "markdown", - "value": "Find an item\n\n*@template* `T`\n\n*@param* `l`\n\n*@param* `x`\n\n*@returns* — The names of the found item(s).\n" + "value": "Find an item" }, "parameters": [ { diff --git a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline index 73e4be6af..25aa51135 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline @@ -40,61 +40,36 @@ // ^ // | ---------------------------------------------------------------------- // | f1(**var1: any**, var2: any): void -// | -// | -// | *@param* `var1` — **Highlighted text** -// | -// | -// | *@param* `var2` — Another **Highlighted text** -// | +// | - `var1: any`: **Highlighted text** + // | ---------------------------------------------------------------------- // f2(); // ^ // | ---------------------------------------------------------------------- // | f2(**var1: any**, var2: any): void -// | -// | -// | *@param* `var1` — *Regular text with an asterisk -// | -// | -// | *@param* `var2` — Another *Regular text with an asterisk -// | +// | - `var1: any`: *Regular text with an asterisk + // | ---------------------------------------------------------------------- // f3(); // ^ // | ---------------------------------------------------------------------- // | f3(**var1: any**, var2: any): void -// | -// | -// | *@param* `var1` — *Regular text with an asterisk -// | -// | -// | *@param* `var2` — Another *Regular text with an asterisk -// | +// | - `var1: any`: *Regular text with an asterisk + // | ---------------------------------------------------------------------- // f4(); // ^ // | ---------------------------------------------------------------------- // | f4(**var1: any**, var2: any): void -// | -// | -// | *@param* `var1` — **Highlighted text** -// | -// | -// | *@param* `var2` — Another **Highlighted text** -// | +// | - `var1: any`: **Highlighted text** + // | ---------------------------------------------------------------------- // f5(); // ^ // | ---------------------------------------------------------------------- // | f5(**var1: any**, var2: any): void -// | -// | -// | *@param* `var1` — **Highlighted text** -// | -// | -// | *@param* `var2` — Another **Highlighted text** -// | +// | - `var1: any`: **Highlighted text** + // | ---------------------------------------------------------------------- [ { @@ -111,16 +86,20 @@ "signatures": [ { "label": "f1(var1: any, var2: any): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" - }, "parameters": [ { - "label": "var1: any" + "label": "var1: any", + "documentation": { + "kind": "markdown", + "value": "**Highlighted text**\n" + } }, { - "label": "var2: any" + "label": "var2: any", + "documentation": { + "kind": "markdown", + "value": "Another **Highlighted text**\n" + } } ], "activeParameter": 0 @@ -143,16 +122,20 @@ "signatures": [ { "label": "f2(var1: any, var2: any): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `var1` — *Regular text with an asterisk\n\n\n*@param* `var2` — Another *Regular text with an asterisk\n" - }, "parameters": [ { - "label": "var1: any" + "label": "var1: any", + "documentation": { + "kind": "markdown", + "value": "*Regular text with an asterisk\n" + } }, { - "label": "var2: any" + "label": "var2: any", + "documentation": { + "kind": "markdown", + "value": "Another *Regular text with an asterisk\n" + } } ], "activeParameter": 0 @@ -175,16 +158,20 @@ "signatures": [ { "label": "f3(var1: any, var2: any): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `var1` — *Regular text with an asterisk\n\n\n*@param* `var2` — Another *Regular text with an asterisk\n" - }, "parameters": [ { - "label": "var1: any" + "label": "var1: any", + "documentation": { + "kind": "markdown", + "value": "*Regular text with an asterisk\n" + } }, { - "label": "var2: any" + "label": "var2: any", + "documentation": { + "kind": "markdown", + "value": "Another *Regular text with an asterisk\n" + } } ], "activeParameter": 0 @@ -207,16 +194,20 @@ "signatures": [ { "label": "f4(var1: any, var2: any): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" - }, "parameters": [ { - "label": "var1: any" + "label": "var1: any", + "documentation": { + "kind": "markdown", + "value": "**Highlighted text**\n" + } }, { - "label": "var2: any" + "label": "var2: any", + "documentation": { + "kind": "markdown", + "value": "Another **Highlighted text**\n" + } } ], "activeParameter": 0 @@ -239,16 +230,20 @@ "signatures": [ { "label": "f5(var1: any, var2: any): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `var1` — **Highlighted text**\n\n\n*@param* `var2` — Another **Highlighted text**\n" - }, "parameters": [ { - "label": "var1: any" + "label": "var1: any", + "documentation": { + "kind": "markdown", + "value": "**Highlighted text**\n" + } }, { - "label": "var2: any" + "label": "var2: any", + "documentation": { + "kind": "markdown", + "value": "Another **Highlighted text**\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline index 5ffa2a7a6..4737d216a 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline @@ -72,10 +72,9 @@ // ^ // | ---------------------------------------------------------------------- // | a(**a: string**): a +// | - `a: string`: this is my a + // | constructor for a -// | -// | *@param* `a` — this is my a -// | // | ---------------------------------------------------------------------- // module m { // export module m2 { @@ -217,11 +216,15 @@ "label": "a(a: string): a", "documentation": { "kind": "markdown", - "value": "constructor for a\n\n*@param* `a` — this is my a\n" + "value": "constructor for a" }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is my a\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline index e460d9a51..1198ac8bc 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline @@ -14,6 +14,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | - `b: number`: number to add // | sum with property // | ---------------------------------------------------------------------- // } @@ -23,6 +24,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | - `b: number`: number to add // | sum with property // | ---------------------------------------------------------------------- // } @@ -38,6 +40,7 @@ // ^ // | ---------------------------------------------------------------------- // | pp2(**b: number**): number +// | - `b: number`: number to add // | sum with property // | ---------------------------------------------------------------------- // } @@ -47,6 +50,7 @@ // ^ // | ---------------------------------------------------------------------- // | pp2(**b: number**): number +// | - `b: number`: number to add // | sum with property // | ---------------------------------------------------------------------- // } @@ -65,6 +69,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | - `b: number`: number to add // | static sum with property // | ---------------------------------------------------------------------- // } @@ -74,6 +79,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | - `b: number`: number to add // | static sum with property // | ---------------------------------------------------------------------- // } @@ -144,6 +150,7 @@ // ^ // | ---------------------------------------------------------------------- // | p2(**b: number**): number +// | - `b: number`: number to add // | sum with property // | ---------------------------------------------------------------------- // var i1_prop = i1.p3; @@ -163,6 +170,7 @@ // ^ // | ---------------------------------------------------------------------- // | s2(**b: number**): number +// | - `b: number`: number to add // | static sum with property // | ---------------------------------------------------------------------- // var i1_s_prop = c1.s3; @@ -229,7 +237,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -258,7 +270,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -287,7 +303,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -316,7 +336,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -345,7 +369,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -374,7 +402,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -577,7 +609,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 @@ -631,7 +667,11 @@ }, "parameters": [ { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "number to add" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline index f00c5fc84..4d24cd3db 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline @@ -169,24 +169,16 @@ // ^ // | ---------------------------------------------------------------------- // | sum(**a: number**, b: number): number +// | - `a: number`: first number + // | Adds two integers and returns the result -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` — second number -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | sum(a: number, **b: number**): number +// | - `b: number`: second number + // | Adds two integers and returns the result -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` — second number -// | // | ---------------------------------------------------------------------- // /** This is multiplication function // * @param @@ -201,112 +193,30 @@ // ^ // | ---------------------------------------------------------------------- // | multiply(**a: number**, b: number, c?: number, d?: any, e?: any): void +// | - `a: number`: first number + // | This is multiplication function -// | -// | *@param* `` -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` -// | -// | *@param* `c` -// | -// | *@param* `d` -// | -// | *@anotherTag* -// | -// | *@param* `e` — LastParam -// | -// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, **b: number**, c?: number, d?: any, e?: any): void // | This is multiplication function -// | -// | *@param* `` -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` -// | -// | *@param* `c` -// | -// | *@param* `d` -// | -// | *@anotherTag* -// | -// | *@param* `e` — LastParam -// | -// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, **c?: number**, d?: any, e?: any): void // | This is multiplication function -// | -// | *@param* `` -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` -// | -// | *@param* `c` -// | -// | *@param* `d` -// | -// | *@anotherTag* -// | -// | *@param* `e` — LastParam -// | -// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, c?: number, **d?: any**, e?: any): void // | This is multiplication function -// | -// | *@param* `` -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` -// | -// | *@param* `c` -// | -// | *@param* `d` -// | -// | *@anotherTag* -// | -// | *@param* `e` — LastParam -// | -// | *@anotherTag* // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | multiply(a: number, b: number, c?: number, d?: any, **e?: any**): void +// | - `e?: any`: LastParam // | This is multiplication function -// | -// | *@param* `` -// | -// | *@param* `a` — first number -// | -// | -// | *@param* `b` -// | -// | *@param* `c` -// | -// | *@param* `d` -// | -// | *@anotherTag* -// | -// | *@param* `e` — LastParam -// | -// | *@anotherTag* // | ---------------------------------------------------------------------- // /** fn f1 with number // * @param { string} b about b @@ -322,9 +232,6 @@ // | ---------------------------------------------------------------------- // | f1(**a: number**): any // | fn f1 with number -// | -// | *@param* `b` — about b -// | // | ---------------------------------------------------------------------- // f1("hello"); // ^ @@ -347,133 +254,39 @@ // | ---------------------------------------------------------------------- // | subtract(**a: number**, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, **b: number**, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void +// | - `b: number`: this is about b + // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, **c?: () => string**, d?: () => string, e?: () => string, f?: () => string): void +// | - `c?: () => string`: this is optional param c + // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, **d?: () => string**, e?: () => string, f?: () => string): void +// | - `d?: () => string`: this is optional param d + // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, d?: () => string, **e?: () => string**, f?: () => string): void +// | - `e?: () => string`: this is optional param e + // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, **f?: () => string**): void // | This is subtract function -// | -// | *@param* `` -// | -// | *@param* `b` — this is about b -// | -// | -// | *@param* `c` — this is optional param c -// | -// | -// | *@param* `d` — this is optional param d -// | -// | -// | *@param* `e` — this is optional param e -// | -// | -// | *@param* `` — { () => string; } } f this is optional param f -// | // | ---------------------------------------------------------------------- // /** this is square function // @paramTag { number } a this is input number of paramTag @@ -487,16 +300,9 @@ // ^ // | ---------------------------------------------------------------------- // | square(**a: number**): number +// | - `a: number`: this is input number + // | this is square function -// | -// | *@paramTag* — { number } a this is input number of paramTag -// | -// | -// | *@param* `a` — this is input number -// | -// | -// | *@returnType* — { number } it is return type -// | // | ---------------------------------------------------------------------- // /** this is divide function // @param { number} a this is a @@ -509,30 +315,16 @@ // ^ // | ---------------------------------------------------------------------- // | divide(**a: number**, b: number): void +// | - `a: number`: this is a + // | this is divide function -// | -// | *@param* `a` — this is a -// | -// | -// | *@paramTag* — { number } g this is optional param g -// | -// | -// | *@param* `b` — this is b -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | divide(a: number, **b: number**): void +// | - `b: number`: this is b + // | this is divide function -// | -// | *@param* `a` — this is a -// | -// | -// | *@paramTag* — { number } g this is optional param g -// | -// | -// | *@param* `b` — this is b -// | // | ---------------------------------------------------------------------- // /** // Function returns string concat of foo and bar @@ -546,24 +338,16 @@ // ^ // | ---------------------------------------------------------------------- // | fooBar(**foo: string**, bar: string): string +// | - `foo: string`: is string + // | Function returns string concat of foo and bar -// | -// | *@param* `foo` — is string -// | -// | -// | *@param* `bar` — is second string -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | fooBar(foo: string, **bar: string**): string +// | - `bar: string`: is second string + // | Function returns string concat of foo and bar -// | -// | *@param* `foo` — is string -// | -// | -// | *@param* `bar` — is second string -// | // | ---------------------------------------------------------------------- // /** This is a comment */ // var x; @@ -586,46 +370,26 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(**a: number**, b: number, c: number, d: number): number +// | - `a: number`: this is inline comment for a // | this is jsdoc style function with param tag as well as inline parameter help -// | -// | *@param* `a` — it is first parameter -// | -// | -// | *@param* `c` — it is third parameter -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, **b: number**, c: number, d: number): number +// | - `b: number`: this is inline comment for b // | this is jsdoc style function with param tag as well as inline parameter help -// | -// | *@param* `a` — it is first parameter -// | -// | -// | *@param* `c` — it is third parameter -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, b: number, **c: number**, d: number): number +// | - `c: number`: it is third parameter + // | this is jsdoc style function with param tag as well as inline parameter help -// | -// | *@param* `a` — it is first parameter -// | -// | -// | *@param* `c` — it is third parameter -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocParamTest(a: number, b: number, c: number, **d: number**): number // | this is jsdoc style function with param tag as well as inline parameter help -// | -// | *@param* `a` — it is first parameter -// | -// | -// | *@param* `c` — it is third parameter -// | // | ---------------------------------------------------------------------- // /** This is function comment // * And properly aligned comment @@ -668,62 +432,31 @@ // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(**a: string**, b: any, c: any): void +// | - `a: string`: this is info about a +spanning on two lines and aligned perfectly + // | This is function comment // | And aligned with 4 space char margin -// | -// | *@param* `a` — this is info about a -// | spanning on two lines and aligned perfectly -// | -// | -// | *@param* `b` — this is info about b -// | spanning on two lines and aligned perfectly -// | spanning one more line alined perfectly -// | spanning another line with more margin -// | -// | -// | *@param* `c` — this is info about b -// | not aligned text about parameter will eat only one space -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(a: string, **b: any**, c: any): void +// | - `b: any`: this is info about b +spanning on two lines and aligned perfectly +spanning one more line alined perfectly + spanning another line with more margin + // | This is function comment // | And aligned with 4 space char margin -// | -// | *@param* `a` — this is info about a -// | spanning on two lines and aligned perfectly -// | -// | -// | *@param* `b` — this is info about b -// | spanning on two lines and aligned perfectly -// | spanning one more line alined perfectly -// | spanning another line with more margin -// | -// | -// | *@param* `c` — this is info about b -// | not aligned text about parameter will eat only one space -// | // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | jsDocCommentAlignmentTest3(a: string, b: any, **c: any**): void +// | - `c: any`: this is info about b +not aligned text about parameter will eat only one space + // | This is function comment // | And aligned with 4 space char margin -// | -// | *@param* `a` — this is info about a -// | spanning on two lines and aligned perfectly -// | -// | -// | *@param* `b` — this is info about b -// | spanning on two lines and aligned perfectly -// | spanning one more line alined perfectly -// | spanning another line with more margin -// | -// | -// | *@param* `c` — this is info about b -// | not aligned text about parameter will eat only one space -// | // | ---------------------------------------------------------------------- // // ^ @@ -1065,14 +798,22 @@ "label": "sum(a: number, b: number): number", "documentation": { "kind": "markdown", - "value": "Adds two integers and returns the result\n\n*@param* `a` — first number\n\n\n*@param* `b` — second number\n" + "value": "Adds two integers and returns the result" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "second number\n" + } } ], "activeParameter": 0 @@ -1097,14 +838,22 @@ "label": "sum(a: number, b: number): number", "documentation": { "kind": "markdown", - "value": "Adds two integers and returns the result\n\n*@param* `a` — first number\n\n\n*@param* `b` — second number\n" + "value": "Adds two integers and returns the result" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "second number\n" + } } ], "activeParameter": 1 @@ -1129,11 +878,15 @@ "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "documentation": { "kind": "markdown", - "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + "value": "This is multiplication function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { "label": "b: number" @@ -1145,7 +898,11 @@ "label": "d?: any" }, { - "label": "e?: any" + "label": "e?: any", + "documentation": { + "kind": "markdown", + "value": "LastParam " + } } ], "activeParameter": 0 @@ -1170,11 +927,15 @@ "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "documentation": { "kind": "markdown", - "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + "value": "This is multiplication function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { "label": "b: number" @@ -1186,7 +947,11 @@ "label": "d?: any" }, { - "label": "e?: any" + "label": "e?: any", + "documentation": { + "kind": "markdown", + "value": "LastParam " + } } ], "activeParameter": 1 @@ -1211,11 +976,15 @@ "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "documentation": { "kind": "markdown", - "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + "value": "This is multiplication function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { "label": "b: number" @@ -1227,7 +996,11 @@ "label": "d?: any" }, { - "label": "e?: any" + "label": "e?: any", + "documentation": { + "kind": "markdown", + "value": "LastParam " + } } ], "activeParameter": 2 @@ -1252,11 +1025,15 @@ "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "documentation": { "kind": "markdown", - "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + "value": "This is multiplication function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { "label": "b: number" @@ -1268,7 +1045,11 @@ "label": "d?: any" }, { - "label": "e?: any" + "label": "e?: any", + "documentation": { + "kind": "markdown", + "value": "LastParam " + } } ], "activeParameter": 3 @@ -1293,11 +1074,15 @@ "label": "multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "documentation": { "kind": "markdown", - "value": "This is multiplication function\n\n*@param* ``\n\n*@param* `a` — first number\n\n\n*@param* `b`\n\n*@param* `c`\n\n*@param* `d`\n\n*@anotherTag*\n\n*@param* `e` — LastParam \n\n*@anotherTag*" + "value": "This is multiplication function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "first number\n" + } }, { "label": "b: number" @@ -1309,7 +1094,11 @@ "label": "d?: any" }, { - "label": "e?: any" + "label": "e?: any", + "documentation": { + "kind": "markdown", + "value": "LastParam " + } } ], "activeParameter": 4 @@ -1334,7 +1123,7 @@ "label": "f1(a: number): any", "documentation": { "kind": "markdown", - "value": "fn f1 with number\n\n*@param* `b` — about b\n" + "value": "fn f1 with number" }, "parameters": [ { @@ -1372,7 +1161,7 @@ "label": "f1(a: number): any", "documentation": { "kind": "markdown", - "value": "fn f1 with number\n\n*@param* `b` — about b\n" + "value": "fn f1 with number" }, "parameters": [ { @@ -1410,23 +1199,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1454,23 +1259,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1498,23 +1319,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1542,23 +1379,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1586,23 +1439,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1630,23 +1499,39 @@ "label": "subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "documentation": { "kind": "markdown", - "value": "This is subtract function\n\n*@param* ``\n\n*@param* `b` — this is about b\n\n\n*@param* `c` — this is optional param c\n\n\n*@param* `d` — this is optional param d\n\n\n*@param* `e` — this is optional param e\n\n\n*@param* `` — { () => string; } } f this is optional param f\n" + "value": "This is subtract function" }, "parameters": [ { "label": "a: number" }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is about b\n" + } }, { - "label": "c?: () => string" + "label": "c?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param c\n" + } }, { - "label": "d?: () => string" + "label": "d?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param d\n" + } }, { - "label": "e?: () => string" + "label": "e?: () => string", + "documentation": { + "kind": "markdown", + "value": "this is optional param e\n" + } }, { "label": "f?: () => string" @@ -1674,11 +1559,15 @@ "label": "square(a: number): number", "documentation": { "kind": "markdown", - "value": "this is square function\n\n*@paramTag* — { number } a this is input number of paramTag\n\n\n*@param* `a` — this is input number\n\n\n*@returnType* — { number } it is return type\n" + "value": "this is square function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is input number\n" + } } ], "activeParameter": 0 @@ -1703,14 +1592,22 @@ "label": "divide(a: number, b: number): void", "documentation": { "kind": "markdown", - "value": "this is divide function\n\n*@param* `a` — this is a\n\n\n*@paramTag* — { number } g this is optional param g\n\n\n*@param* `b` — this is b\n" + "value": "this is divide function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is a\n" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is b\n" + } } ], "activeParameter": 0 @@ -1735,14 +1632,22 @@ "label": "divide(a: number, b: number): void", "documentation": { "kind": "markdown", - "value": "this is divide function\n\n*@param* `a` — this is a\n\n\n*@paramTag* — { number } g this is optional param g\n\n\n*@param* `b` — this is b\n" + "value": "this is divide function" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is a\n" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is b\n" + } } ], "activeParameter": 1 @@ -1767,14 +1672,22 @@ "label": "fooBar(foo: string, bar: string): string", "documentation": { "kind": "markdown", - "value": "Function returns string concat of foo and bar\n\n*@param* `foo` — is string\n\n\n*@param* `bar` — is second string\n" + "value": "Function returns string concat of foo and bar" }, "parameters": [ { - "label": "foo: string" + "label": "foo: string", + "documentation": { + "kind": "markdown", + "value": "is string\n" + } }, { - "label": "bar: string" + "label": "bar: string", + "documentation": { + "kind": "markdown", + "value": "is second string\n" + } } ], "activeParameter": 0 @@ -1799,14 +1712,22 @@ "label": "fooBar(foo: string, bar: string): string", "documentation": { "kind": "markdown", - "value": "Function returns string concat of foo and bar\n\n*@param* `foo` — is string\n\n\n*@param* `bar` — is second string\n" + "value": "Function returns string concat of foo and bar" }, "parameters": [ { - "label": "foo: string" + "label": "foo: string", + "documentation": { + "kind": "markdown", + "value": "is string\n" + } }, { - "label": "bar: string" + "label": "bar: string", + "documentation": { + "kind": "markdown", + "value": "is second string\n" + } } ], "activeParameter": 1 @@ -1843,17 +1764,29 @@ "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", "documentation": { "kind": "markdown", - "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + "value": "this is jsdoc style function with param tag as well as inline parameter help" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for b" + } }, { - "label": "c: number" + "label": "c: number", + "documentation": { + "kind": "markdown", + "value": "it is third parameter\n" + } }, { "label": "d: number" @@ -1881,17 +1814,29 @@ "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", "documentation": { "kind": "markdown", - "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + "value": "this is jsdoc style function with param tag as well as inline parameter help" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for b" + } }, { - "label": "c: number" + "label": "c: number", + "documentation": { + "kind": "markdown", + "value": "it is third parameter\n" + } }, { "label": "d: number" @@ -1919,17 +1864,29 @@ "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", "documentation": { "kind": "markdown", - "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + "value": "this is jsdoc style function with param tag as well as inline parameter help" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for b" + } }, { - "label": "c: number" + "label": "c: number", + "documentation": { + "kind": "markdown", + "value": "it is third parameter\n" + } }, { "label": "d: number" @@ -1957,17 +1914,29 @@ "label": "jsDocParamTest(a: number, b: number, c: number, d: number): number", "documentation": { "kind": "markdown", - "value": "this is jsdoc style function with param tag as well as inline parameter help\n\n*@param* `a` — it is first parameter\n\n\n*@param* `c` — it is third parameter\n" + "value": "this is jsdoc style function with param tag as well as inline parameter help" }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is inline comment for b" + } }, { - "label": "c: number" + "label": "c: number", + "documentation": { + "kind": "markdown", + "value": "it is third parameter\n" + } }, { "label": "d: number" @@ -2043,17 +2012,29 @@ "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", "documentation": { "kind": "markdown", - "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + "value": "This is function comment\n And aligned with 4 space char margin" }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is info about a\nspanning on two lines and aligned perfectly\n" + } }, { - "label": "b: any" + "label": "b: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n" + } }, { - "label": "c: any" + "label": "c: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nnot aligned text about parameter will eat only one space\n" + } } ], "activeParameter": 0 @@ -2078,17 +2059,29 @@ "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", "documentation": { "kind": "markdown", - "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + "value": "This is function comment\n And aligned with 4 space char margin" }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is info about a\nspanning on two lines and aligned perfectly\n" + } }, { - "label": "b: any" + "label": "b: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n" + } }, { - "label": "c: any" + "label": "c: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nnot aligned text about parameter will eat only one space\n" + } } ], "activeParameter": 1 @@ -2113,17 +2106,29 @@ "label": "jsDocCommentAlignmentTest3(a: string, b: any, c: any): void", "documentation": { "kind": "markdown", - "value": "This is function comment\n And aligned with 4 space char margin\n\n*@param* `a` — this is info about a\nspanning on two lines and aligned perfectly\n\n\n*@param* `b` — this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n\n\n*@param* `c` — this is info about b\nnot aligned text about parameter will eat only one space\n" + "value": "This is function comment\n And aligned with 4 space char margin" }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is info about a\nspanning on two lines and aligned perfectly\n" + } }, { - "label": "b: any" + "label": "b: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nspanning on two lines and aligned perfectly\nspanning one more line alined perfectly\n spanning another line with more margin\n" + } }, { - "label": "c: any" + "label": "c: any", + "documentation": { + "kind": "markdown", + "value": "this is info about b\nnot aligned text about parameter will eat only one space\n" + } } ], "activeParameter": 2 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline index 66ecad0c6..b2bb5b74a 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline @@ -19,11 +19,13 @@ // ^ // | ---------------------------------------------------------------------- // | fooWithParameters(**a: string**, b: number): void +// | - `a: string`: this is comment about a // | This is comment for function signature // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | fooWithParameters(a: string, **b: number**): void +// | - `b: number`: this is comment for b // | This is comment for function signature // | ---------------------------------------------------------------------- // /** @@ -35,10 +37,9 @@ // ^ // | ---------------------------------------------------------------------- // | fn(**a: string**): any +// | - `a: string`: a string + // | Does something -// | -// | *@param* `a` — a string -// | // | ---------------------------------------------------------------------- [ { @@ -85,10 +86,18 @@ }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is comment about a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is comment for b" + } } ], "activeParameter": 0 @@ -117,10 +126,18 @@ }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "this is comment about a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "this is comment for b" + } } ], "activeParameter": 1 @@ -145,11 +162,15 @@ "label": "fn(a: string): any", "documentation": { "kind": "markdown", - "value": "Does something\n\n*@param* `a` — a string\n" + "value": "Does something" }, "parameters": [ { - "label": "a: string" + "label": "a: string", + "documentation": { + "kind": "markdown", + "value": "a string\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline index 9d140cdd0..8ed07113b 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline @@ -7,11 +7,13 @@ // ^ // | ---------------------------------------------------------------------- // | lambdaFoo(**a: number**, b: number): number +// | - `a: number`: param a // | this is lambda comment // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | lambdaFoo(a: number, **b: number**): number +// | - `b: number`: param b // | this is lambda comment // | ---------------------------------------------------------------------- // function anotherFunc(a: number) { @@ -39,13 +41,8 @@ // ^ // | ---------------------------------------------------------------------- // | assigned(**s: string**): number +// | - `s: string`: On parameter // | Summary on expression -// | -// | *@param* `s` — param on expression -// | -// | -// | *@returns* — return on expression -// | // | ---------------------------------------------------------------------- [ { @@ -68,10 +65,18 @@ }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "param a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "param b" + } } ], "activeParameter": 0 @@ -100,10 +105,18 @@ }, "parameters": [ { - "label": "a: number" + "label": "a: number", + "documentation": { + "kind": "markdown", + "value": "param a" + } }, { - "label": "b: number" + "label": "b: number", + "documentation": { + "kind": "markdown", + "value": "param b" + } } ], "activeParameter": 1 @@ -128,11 +141,15 @@ "label": "assigned(s: string): number", "documentation": { "kind": "markdown", - "value": "Summary on expression\n\n*@param* `s` — param on expression\n\n\n*@returns* — return on expression\n" + "value": "Summary on expression" }, "parameters": [ { - "label": "s: string" + "label": "s: string", + "documentation": { + "kind": "markdown", + "value": "On parameter" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline index 09d5ad8e9..013376084 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline @@ -12,10 +12,9 @@ // ^ // | ---------------------------------------------------------------------- // | Circle(**radius: number**): Circle +// | - `radius: number`: The radius of the circle. + // | Initialize a circle. -// | -// | *@param* `radius` — The radius of the circle. -// | // | ---------------------------------------------------------------------- [ { @@ -34,11 +33,15 @@ "label": "Circle(radius: number): Circle", "documentation": { "kind": "markdown", - "value": "Initialize a circle.\n\n*@param* `radius` — The radius of the circle.\n" + "value": "Initialize a circle." }, "parameters": [ { - "label": "radius: number" + "label": "radius: number", + "documentation": { + "kind": "markdown", + "value": "The radius of the circle.\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline index a3c8672f1..6af7f1602 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline @@ -14,9 +14,6 @@ // ^ // | ---------------------------------------------------------------------- // | foo(**a: Foo**): void -// | -// | -// | *@param* `a` // | ---------------------------------------------------------------------- [ { @@ -33,10 +30,6 @@ "signatures": [ { "label": "foo(a: Foo): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@param* `a`" - }, "parameters": [ { "label": "a: Foo" diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline index 4b8bdc8fe..335bb0ee7 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline @@ -25,14 +25,20 @@ // ^ // | ---------------------------------------------------------------------- // | t(**eventName: string**, eventName2: string | number, eventName3: any): number +// | - `eventName: string`: - So many words + // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | t(eventName: string, **eventName2: string | number**, eventName3: any): number +// | - `eventName2: string | number`: - Silence is golden + // | ---------------------------------------------------------------------- // ^ // | ---------------------------------------------------------------------- // | t(eventName: string, eventName2: string | number, **eventName3: any**): number +// | - `eventName3: any`: - Osterreich mos def + // | ---------------------------------------------------------------------- [ { @@ -51,13 +57,25 @@ "label": "t(eventName: string, eventName2: string | number, eventName3: any): number", "parameters": [ { - "label": "eventName: string" + "label": "eventName: string", + "documentation": { + "kind": "markdown", + "value": "- So many words\n" + } }, { - "label": "eventName2: string | number" + "label": "eventName2: string | number", + "documentation": { + "kind": "markdown", + "value": "- Silence is golden\n" + } }, { - "label": "eventName3: any" + "label": "eventName3: any", + "documentation": { + "kind": "markdown", + "value": "- Osterreich mos def\n" + } } ], "activeParameter": 0 @@ -82,13 +100,25 @@ "label": "t(eventName: string, eventName2: string | number, eventName3: any): number", "parameters": [ { - "label": "eventName: string" + "label": "eventName: string", + "documentation": { + "kind": "markdown", + "value": "- So many words\n" + } }, { - "label": "eventName2: string | number" + "label": "eventName2: string | number", + "documentation": { + "kind": "markdown", + "value": "- Silence is golden\n" + } }, { - "label": "eventName3: any" + "label": "eventName3: any", + "documentation": { + "kind": "markdown", + "value": "- Osterreich mos def\n" + } } ], "activeParameter": 1 @@ -113,13 +143,25 @@ "label": "t(eventName: string, eventName2: string | number, eventName3: any): number", "parameters": [ { - "label": "eventName: string" + "label": "eventName: string", + "documentation": { + "kind": "markdown", + "value": "- So many words\n" + } }, { - "label": "eventName2: string | number" + "label": "eventName2: string | number", + "documentation": { + "kind": "markdown", + "value": "- Silence is golden\n" + } }, { - "label": "eventName3: any" + "label": "eventName3: any", + "documentation": { + "kind": "markdown", + "value": "- Osterreich mos def\n" + } } ], "activeParameter": 2 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline index c8f35b8fd..11b013bb5 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline @@ -54,35 +54,22 @@ // | ---------------------------------------------------------------------- // | Foo(**value: number**): Foo // | This is the constructor. -// | -// | *@myjsdoctag* — this is a comment -// | // | ---------------------------------------------------------------------- // Foo.method1(); // ^ // | ---------------------------------------------------------------------- // | method1(): void // | method1 documentation -// | -// | *@mytag* — comment1 comment2 -// | // | ---------------------------------------------------------------------- // foo.method2(); // ^ // | ---------------------------------------------------------------------- // | method2(): void -// | -// | -// | *@mytag* // | ---------------------------------------------------------------------- // foo.method3(); // ^ // | ---------------------------------------------------------------------- // | method3(): number -// | -// | -// | *@returns* — a value -// | // | ---------------------------------------------------------------------- // foo.method4(); // foo.property1; @@ -106,7 +93,7 @@ "label": "Foo(value: number): Foo", "documentation": { "kind": "markdown", - "value": "This is the constructor.\n\n*@myjsdoctag* — this is a comment\n" + "value": "This is the constructor." }, "parameters": [ { @@ -135,7 +122,7 @@ "label": "method1(): void", "documentation": { "kind": "markdown", - "value": "method1 documentation\n\n*@mytag* — comment1 comment2\n" + "value": "method1 documentation" }, "parameters": [] } @@ -157,10 +144,6 @@ "signatures": [ { "label": "method2(): void", - "documentation": { - "kind": "markdown", - "value": "\n\n*@mytag*" - }, "parameters": [] } ], @@ -181,10 +164,6 @@ "signatures": [ { "label": "method3(): number", - "documentation": { - "kind": "markdown", - "value": "\n\n*@returns* — a value\n" - }, "parameters": [] } ], diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline index ba9dac6db..c46124de5 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline @@ -4,13 +4,9 @@ // ^ // | ---------------------------------------------------------------------- // | ReadonlyArray.filter(**predicate: (value: T, index: number, array: readonly T[]) => value is S**, thisArg?: any): S[] +// | - `predicate: (value: T, index: number, array: readonly T[]) => value is S`: A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. + // | Returns the elements of an array that meet the condition specified in a callback function. -// | -// | *@param* `predicate` — A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. -// | -// | -// | *@param* `thisArg` — An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. -// | // | ---------------------------------------------------------------------- [ { @@ -29,14 +25,22 @@ "label": "ReadonlyArray.filter(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]", "documentation": { "kind": "markdown", - "value": "Returns the elements of an array that meet the condition specified in a callback function.\n\n*@param* `predicate` — A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.\n\n\n*@param* `thisArg` — An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n" + "value": "Returns the elements of an array that meet the condition specified in a callback function." }, "parameters": [ { - "label": "predicate: (value: T, index: number, array: readonly T[]) => value is S" + "label": "predicate: (value: T, index: number, array: readonly T[]) => value is S", + "documentation": { + "kind": "markdown", + "value": "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.\n" + } }, { - "label": "thisArg?: any" + "label": "thisArg?: any", + "documentation": { + "kind": "markdown", + "value": "An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n" + } } ], "activeParameter": 0 @@ -45,14 +49,22 @@ "label": "ReadonlyArray.filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]", "documentation": { "kind": "markdown", - "value": "Returns the elements of an array that meet the condition specified in a callback function.\n\n*@param* `predicate` — A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.\n\n\n*@param* `thisArg` — An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n" + "value": "Returns the elements of an array that meet the condition specified in a callback function." }, "parameters": [ { - "label": "predicate: (value: T, index: number, array: readonly T[]) => unknown" + "label": "predicate: (value: T, index: number, array: readonly T[]) => unknown", + "documentation": { + "kind": "markdown", + "value": "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.\n" + } }, { - "label": "thisArg?: any" + "label": "thisArg?: any", + "documentation": { + "kind": "markdown", + "value": "An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline index 78c6b7c1f..a1c6ff80d 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline @@ -8,13 +8,9 @@ // ^ // | ---------------------------------------------------------------------- // | Function.call(thisArg: any, **...argArray: any[]**): any +// | - `...argArray: any[]`: A list of arguments to be passed to the method. + // | Calls a method of an object, substituting another object for the current object. -// | -// | *@param* `thisArg` — The object to be used as the current object. -// | -// | -// | *@param* `argArray` — A list of arguments to be passed to the method. -// | // | ---------------------------------------------------------------------- // }); // }; @@ -36,14 +32,22 @@ "label": "Function.call(thisArg: any, ...argArray: any[]): any", "documentation": { "kind": "markdown", - "value": "Calls a method of an object, substituting another object for the current object.\n\n*@param* `thisArg` — The object to be used as the current object.\n\n\n*@param* `argArray` — A list of arguments to be passed to the method.\n" + "value": "Calls a method of an object, substituting another object for the current object." }, "parameters": [ { - "label": "thisArg: any" + "label": "thisArg: any", + "documentation": { + "kind": "markdown", + "value": "The object to be used as the current object.\n" + } }, { - "label": "...argArray: any[]" + "label": "...argArray: any[]", + "documentation": { + "kind": "markdown", + "value": "A list of arguments to be passed to the method.\n" + } } ], "activeParameter": 1 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline index 07690179e..93cbe6016 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline @@ -4,14 +4,10 @@ // ^ // | ---------------------------------------------------------------------- // | assign(target: object, **...sources: any[]**): any +// | - `...sources: any[]`: One or more source objects from which to copy properties + // | Copy the values of all of the enumerable own properties from one or more source objects to a // | target object. Returns the target object. -// | -// | *@param* `target` — The target object to copy to. -// | -// | -// | *@param* `sources` — One or more source objects from which to copy properties -// | // | ---------------------------------------------------------------------- [ { @@ -30,14 +26,22 @@ "label": "assign(target: T, source: U): T & U", "documentation": { "kind": "markdown", - "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source` — The source object from which to copy properties.\n" + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object." }, "parameters": [ { - "label": "target: T" + "label": "target: T", + "documentation": { + "kind": "markdown", + "value": "The target object to copy to.\n" + } }, { - "label": "source: U" + "label": "source: U", + "documentation": { + "kind": "markdown", + "value": "The source object from which to copy properties.\n" + } } ], "activeParameter": 1 @@ -46,17 +50,29 @@ "label": "assign(target: T, source1: U, source2: V): T & U & V", "documentation": { "kind": "markdown", - "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source1` — The first source object from which to copy properties.\n\n\n*@param* `source2` — The second source object from which to copy properties.\n" + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object." }, "parameters": [ { - "label": "target: T" + "label": "target: T", + "documentation": { + "kind": "markdown", + "value": "The target object to copy to.\n" + } }, { - "label": "source1: U" + "label": "source1: U", + "documentation": { + "kind": "markdown", + "value": "The first source object from which to copy properties.\n" + } }, { - "label": "source2: V" + "label": "source2: V", + "documentation": { + "kind": "markdown", + "value": "The second source object from which to copy properties.\n" + } } ], "activeParameter": 1 @@ -65,20 +81,36 @@ "label": "assign(target: T, source1: U, source2: V, source3: W): T & U & V & W", "documentation": { "kind": "markdown", - "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `source1` — The first source object from which to copy properties.\n\n\n*@param* `source2` — The second source object from which to copy properties.\n\n\n*@param* `source3` — The third source object from which to copy properties.\n" + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object." }, "parameters": [ { - "label": "target: T" + "label": "target: T", + "documentation": { + "kind": "markdown", + "value": "The target object to copy to.\n" + } }, { - "label": "source1: U" + "label": "source1: U", + "documentation": { + "kind": "markdown", + "value": "The first source object from which to copy properties.\n" + } }, { - "label": "source2: V" + "label": "source2: V", + "documentation": { + "kind": "markdown", + "value": "The second source object from which to copy properties.\n" + } }, { - "label": "source3: W" + "label": "source3: W", + "documentation": { + "kind": "markdown", + "value": "The third source object from which to copy properties.\n" + } } ], "activeParameter": 1 @@ -87,14 +119,22 @@ "label": "assign(target: object, ...sources: any[]): any", "documentation": { "kind": "markdown", - "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.\n\n*@param* `target` — The target object to copy to.\n\n\n*@param* `sources` — One or more source objects from which to copy properties\n" + "value": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object." }, "parameters": [ { - "label": "target: object" + "label": "target: object", + "documentation": { + "kind": "markdown", + "value": "The target object to copy to.\n" + } }, { - "label": "...sources: any[]" + "label": "...sources: any[]", + "documentation": { + "kind": "markdown", + "value": "One or more source objects from which to copy properties\n" + } } ], "activeParameter": 1 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline index 8fded6dda..9103180f7 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline @@ -13,80 +13,24 @@ // | ---------------------------------------------------------------------- // | f<**T**, U, V, W>(a: number, b: string, c: boolean): void // | some documentation -// | -// | *@template* `T` — some documentation 2 -// | -// | -// | *@template* `W` -// | -// | *@template* `U`, `V` — others -// | -// | -// | *@param* `a` — ok -// | -// | -// | *@param* `b` — not ok -// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void // | some documentation -// | -// | *@template* `T` — some documentation 2 -// | -// | -// | *@template* `W` -// | -// | *@template* `U`, `V` — others -// | -// | -// | *@param* `a` — ok -// | -// | -// | *@param* `b` — not ok -// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void // | some documentation -// | -// | *@template* `T` — some documentation 2 -// | -// | -// | *@template* `W` -// | -// | *@template* `U`, `V` — others -// | -// | -// | *@param* `a` — ok -// | -// | -// | *@param* `b` — not ok -// | // | ---------------------------------------------------------------------- // f(a: number, b: string, c: boolean): void // | some documentation -// | -// | *@template* `T` — some documentation 2 -// | -// | -// | *@template* `W` -// | -// | *@template* `U`, `V` — others -// | -// | -// | *@param* `a` — ok -// | -// | -// | *@param* `b` — not ok -// | // | ---------------------------------------------------------------------- [ { @@ -105,7 +49,7 @@ "label": "f(a: number, b: string, c: boolean): void", "documentation": { "kind": "markdown", - "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + "value": "some documentation" }, "parameters": [ { @@ -143,7 +87,7 @@ "label": "f(a: number, b: string, c: boolean): void", "documentation": { "kind": "markdown", - "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + "value": "some documentation" }, "parameters": [ { @@ -181,7 +125,7 @@ "label": "f(a: number, b: string, c: boolean): void", "documentation": { "kind": "markdown", - "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + "value": "some documentation" }, "parameters": [ { @@ -219,7 +163,7 @@ "label": "f(a: number, b: string, c: boolean): void", "documentation": { "kind": "markdown", - "value": "some documentation\n\n*@template* `T` — some documentation 2\n\n\n*@template* `W`\n\n*@template* `U`, `V` — others\n\n\n*@param* `a` — ok\n\n\n*@param* `b` — not ok\n" + "value": "some documentation" }, "parameters": [ { diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline index fb0b57ecb..29b43eceb 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline @@ -4,10 +4,9 @@ // ^ // | ---------------------------------------------------------------------- // | eval(**x: string**): any +// | - `x: string`: A String value that contains valid JavaScript code. + // | Evaluates JavaScript code and executes it. -// | -// | *@param* `x` — A String value that contains valid JavaScript code. -// | // | ---------------------------------------------------------------------- [ { @@ -26,11 +25,15 @@ "label": "eval(x: string): any", "documentation": { "kind": "markdown", - "value": "Evaluates JavaScript code and executes it.\n\n*@param* `x` — A String value that contains valid JavaScript code.\n" + "value": "Evaluates JavaScript code and executes it." }, "parameters": [ { - "label": "x: string" + "label": "x: string", + "documentation": { + "kind": "markdown", + "value": "A String value that contains valid JavaScript code.\n" + } } ], "activeParameter": 0 diff --git a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline index 543be1ccc..19c6743be 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline @@ -12,10 +12,9 @@ // ^ // | ---------------------------------------------------------------------- // | str(n: number, **radix: number**): string +// | - `radix: number`: The radix + // | Stringifies a number with radix -// | -// | *@param* `radix` — The radix -// | // | ---------------------------------------------------------------------- // // declare function f(a: T): T; @@ -50,14 +49,18 @@ "label": "str(n: number, radix: number): string", "documentation": { "kind": "markdown", - "value": "Stringifies a number with radix\n\n*@param* `radix` — The radix\n" + "value": "Stringifies a number with radix" }, "parameters": [ { "label": "n: number" }, { - "label": "radix: number" + "label": "radix: number", + "documentation": { + "kind": "markdown", + "value": "The radix\n" + } } ], "activeParameter": 1