From 8c2423e6a47a4601a7c196fd8a6605a9f5b1ca66 Mon Sep 17 00:00:00 2001 From: buke <1013738+buke@users.noreply.github.com> Date: Tue, 2 Dec 2025 05:49:29 +0000 Subject: [PATCH] chore(sync): mirror internal packages into pkg/ (auto) --- pkg/ast/ast.go | 4 +- pkg/ast/utilities.go | 89 +- pkg/diagnostics/diagnostics_generated.go | 16 + pkg/diagnostics/extraDiagnosticMessages.json | 16 + pkg/fourslash/_scripts/convertFourslash.mts | 520 +++++++ pkg/fourslash/_scripts/failingTests.txt | 12 +- pkg/fourslash/_scripts/manualTests.txt | 2 + pkg/fourslash/baselineutil.go | 19 + pkg/fourslash/fourslash.go | 691 ++++++++- .../codeLensFunctionExpressions01_test.go | 53 + .../codeLensFunctionsAndConstants01_test.go | 50 + .../tests/codeLensInterface01_test.go | 59 + .../tests/codeLensOverloads01_test.go | 39 + .../codeLensShowOnAllClassMethods_test.go | 43 + .../tests/codeLensShowOnAllFunctions_test.go | 38 + .../codeLensShowOnInterfaceMethods_test.go | 52 + .../tests/gen/augmentedTypesModule2_test.go | 40 + .../tests/gen/augmentedTypesModule3_test.go | 39 + .../tests/gen/augmentedTypesModule6_test.go | 81 + .../tests/gen/callHierarchyAccessor_test.go | 29 + ...sionByConstNamedFunctionExpression_test.go | 29 + ...ierarchyClassPropertyArrowFunction_test.go | 25 + .../callHierarchyClassStaticBlock2_test.go | 38 + .../gen/callHierarchyClassStaticBlock_test.go | 38 + .../tests/gen/callHierarchyClass_test.go | 27 + ...llHierarchyConstNamedArrowFunction_test.go | 27 + ...HierarchyConstNamedClassExpression_test.go | 29 + ...rarchyConstNamedFunctionExpression_test.go | 27 + .../callHierarchyContainerNameServer_test.go | 53 + .../gen/callHierarchyContainerName_test.go | 52 + .../tests/gen/callHierarchyCrossFile_test.go | 29 + .../tests/gen/callHierarchyDecorator_test.go | 28 + .../callHierarchyExportDefaultClass_test.go | 32 + ...callHierarchyExportDefaultFunction_test.go | 30 + .../callHierarchyExportEqualsFunction_test.go | 30 + .../tests/gen/callHierarchyFile_test.go | 20 + .../callHierarchyFunctionAmbiguity1_test.go | 26 + .../callHierarchyFunctionAmbiguity2_test.go | 26 + .../callHierarchyFunctionAmbiguity3_test.go | 26 + .../callHierarchyFunctionAmbiguity4_test.go | 26 + .../callHierarchyFunctionAmbiguity5_test.go | 26 + .../tests/gen/callHierarchyFunction_test.go | 32 + .../gen/callHierarchyInterfaceMethod_test.go | 24 + .../tests/gen/callHierarchyJsxElement_test.go | 29 + .../gen/callHierarchyTaggedTemplate_test.go | 27 + .../tests/gen/callSignatureHelp_test.go | 22 + ...onsOfDissimilarTyeshaveGoodDisplay_test.go | 67 + .../gen/classExtendsInterfaceSigHelp1_test.go | 27 + .../commentsExternalModulesFourslash_test.go | 299 ++++ .../gen/commentsImportDeclaration_test.go | 138 ++ .../gen/commentsInheritanceFourslash_test.go | 1305 +++++++++++++++++ .../gen/commentsInterfaceFourslash_test.go | 417 ++++++ .../gen/commentsOverloadsFourslash_test.go | 723 +++++++++ .../tests/gen/commentsVariables_test.go | 231 +++ ...foExportedTypeDoesNotUseImportType_test.go | 29 + .../tests/gen/functionOverloadCount_test.go | 27 + .../tests/gen/functionProperty_test.go | 76 + .../gen/genericFunctionReturnType2_test.go | 30 + .../gen/genericFunctionReturnType_test.go | 27 + .../gen/genericFunctionSignatureHelp1_test.go | 19 + .../gen/genericFunctionSignatureHelp2_test.go | 19 + ...ricFunctionSignatureHelp3MultiFile_test.go | 52 + .../gen/genericFunctionSignatureHelp3_test.go | 45 + ...nericParameterHelpConstructorCalls_test.go | 37 + ...genericParameterHelpTypeReferences_test.go | 44 + .../tests/gen/genericParameterHelp_test.go | 37 + .../gen/getJavaScriptCompletions16_test.go | 75 + .../tests/gen/jsSignature-41059_test.go | 21 + .../gen/noSignatureHelpOnNewKeyword_test.go | 21 + .../gen/overloadOnConstCallSignature_test.go | 26 + .../tests/gen/qualifyModuleTypeNames_test.go | 20 + .../tests/gen/quickInfoCanBeTruncated_test.go | 539 +++++++ .../quickInfoInFunctionTypeReference2_test.go | 25 + ...oOnConstructorWithGenericParameter_test.go | 36 + .../quickInfoOnPrivateConstructorCall_test.go | 20 + ...uickInfoOnProtectedConstructorCall_test.go | 20 + .../tests/gen/restArgSignatureHelp_test.go | 19 + .../tests/gen/signatureHelp01_test.go | 24 + .../signatureHelpAnonymousFunction_test.go | 23 + .../tests/gen/signatureHelpAtEOF2_test.go | 19 + .../tests/gen/signatureHelpAtEOF_test.go | 21 + .../gen/signatureHelpBeforeSemicolon1_test.go | 21 + .../signatureHelpCallExpressionTuples_test.go | 38 + .../gen/signatureHelpCallExpression_test.go | 21 + .../signatureHelpConstructExpression_test.go | 21 + ...ignatureHelpConstructorInheritance_test.go | 29 + .../signatureHelpConstructorOverload_test.go | 22 + .../tests/gen/signatureHelpEmptyList_test.go | 25 + .../signatureHelpExpandedRestTuples_test.go | 28 + ...ureHelpExpandedRestUnlabeledTuples_test.go | 28 + ...ureHelpExpandedTuplesArgumentIndex_test.go | 40 + ...signatureHelpExplicitTypeArguments_test.go | 51 + .../signatureHelpFilteredTriggers03_test.go | 30 + ...orNonlocalTypeDoesNotUseImportType_test.go | 24 + .../signatureHelpForOptionalMethods_test.go | 27 + ...elpForSignatureWithUnreachableType_test.go | 28 + .../gen/signatureHelpForSuperCalls1_test.go | 35 + .../gen/signatureHelpFunctionOverload_test.go | 24 + .../signatureHelpFunctionParameter_test.go | 22 + .../signatureHelpImplicitConstructor_test.go | 20 + ...tureHelpImportStarFromExportEquals_test.go | 25 + .../signatureHelpInAdjacentBlockBody_test.go | 23 + .../tests/gen/signatureHelpInCallback_test.go | 22 + ...ignatureHelpInCompleteGenericsCall_test.go | 20 + ...FunctionDeclarationInMultipleFiles_test.go | 23 + .../gen/signatureHelpInFunctionCall_test.go | 20 + .../gen/signatureHelpInParenthetical_test.go | 21 + .../gen/signatureHelpInRecursiveType_test.go | 28 + .../gen/signatureHelpIncompleteCalls_test.go | 35 + ...gnatureHelpInferenceJsDocImportTag_test.go | 2 +- .../tests/gen/signatureHelpInference_test.go | 19 + .../signatureHelpJSMissingIdentifier_test.go | 20 + .../tests/gen/signatureHelpJSX_test.go | 23 + .../gen/signatureHelpLeadingRestTuple_test.go | 27 + .../gen/signatureHelpNegativeTests2_test.go | 18 + .../gen/signatureHelpNegativeTests_test.go | 19 + .../gen/signatureHelpNoArguments_test.go | 21 + ...ationExpressionNoArgs_NotAvailable_test.go | 18 + .../gen/signatureHelpObjectLiteral_test.go | 21 + .../gen/signatureHelpOnDeclaration_test.go | 18 + .../signatureHelpOnNestedOverloads_test.go | 24 + .../signatureHelpOnOverloadOnConst_test.go | 30 + ...tureHelpOnOverloadsDifferentArity2_test.go | 25 + ...tureHelpOnOverloadsDifferentArity3_test.go | 27 + ...atureHelpOnOverloadsDifferentArity_test.go | 25 + .../gen/signatureHelpOnOverloads_test.go | 22 + ...lpOnSuperWhenMembersAreNotResolved_test.go | 25 + .../gen/signatureHelpOnTypePredicates_test.go | 27 + .../gen/signatureHelpOptionalCall2_test.go | 19 + .../gen/signatureHelpOptionalCall_test.go | 19 + ...signatureHelpSimpleConstructorCall_test.go | 24 + .../signatureHelpSimpleFunctionCall_test.go | 24 + .../gen/signatureHelpSimpleSuperCall_test.go | 26 + ...natureHelpSuperConstructorOverload_test.go | 35 + ...atureHelpTaggedTemplatesNegatives1_test.go | 20 + ...atureHelpTaggedTemplatesNegatives2_test.go | 20 + ...atureHelpTaggedTemplatesNegatives3_test.go | 20 + ...atureHelpTaggedTemplatesNegatives4_test.go | 20 + ...atureHelpTaggedTemplatesNegatives5_test.go | 20 + .../tests/gen/signatureHelpThis_test.go | 55 + .../signatureHelpTrailingRestTuple_test.go | 27 + .../gen/signatureHelpTypeArguments_test.go | 43 + ...atureHelpTypeParametersNotVariadic_test.go | 19 + ...atureHelpWithInterfaceAsIdentifier_test.go | 20 + ...natureHelpWithInvalidArgumentList1_test.go | 19 + .../gen/signatureHelpWithTriggers02_test.go | 29 + .../gen/signatureHelp_contextual_test.go | 61 + .../tests/gen/staticGenericOverloads1_test.go | 32 + .../tests/gen/superInsideInnerClass_test.go | 27 + .../tests/gen/tsxSignatureHelp1_test.go | 38 + .../tests/gen/tsxSignatureHelp2_test.go | 43 + .../jsDocFunctionSignatures12_test.go | 14 +- .../manual/jsDocFunctionSignatures2_test.go | 23 + .../tests/signatureHelpCrash_test.go | 2 +- .../tests/signatureHelpTokenCrash_test.go | 4 +- pkg/ls/callhierarchy.go | 1043 +++++++++++++ pkg/ls/codelens.go | 230 +++ pkg/ls/completions.go | 3 +- pkg/ls/findallreferences.go | 108 +- pkg/ls/lsutil/userpreferences.go | 54 + pkg/ls/signaturehelp.go | 185 ++- pkg/ls/symbols.go | 44 +- pkg/lsp/lsproto/_generate/generate.mts | 78 +- pkg/lsp/lsproto/baseproto.go | 48 - pkg/lsp/lsproto/jsonrpc.go | 8 +- pkg/lsp/lsproto/lsp_generated.go | 258 ++-- pkg/lsp/server.go | 84 +- pkg/printer/printer.go | 8 +- pkg/testutil/baseline/baseline.go | 5 + .../importAttributesWithValueComments.js | 23 + .../importAttributesWithValueComments.symbols | 21 + .../importAttributesWithValueComments.types | 27 + ...deLensFunctionExpressions01.baseline.jsonc | 72 + ...LensFunctionsAndConstants01.baseline.jsonc | 42 + .../codeLensInterface01.baseline.jsonc | 242 +++ .../codeLensOverloads01.baseline.jsonc | 16 + ...ShowOnAllClassMethods=false.baseline.jsonc | 32 + ...sShowOnAllClassMethods=true.baseline.jsonc | 101 ++ ...cesShowOnAllFunctions=false.baseline.jsonc | 22 + ...ncesShowOnAllFunctions=true.baseline.jsonc | 34 + ...howOnInterfaceMethods=false.baseline.jsonc | 78 + ...ShowOnInterfaceMethods=true.baseline.jsonc | 173 +++ ...dAllReferencesOfConstructor.baseline.jsonc | 6 +- .../jsDocDontBreakWithNamespaces.baseline | 9 +- .../jsDocFunctionSignatures5.baseline | 6 +- .../jsDocFunctionSignatures6.baseline | 24 +- .../signatureHelp/jsdocReturnsTag.baseline | 6 +- .../quickInfoJsDocTags13.baseline | 18 +- .../quickInfoJsDocTextFormatting1.baseline | 30 +- .../signatureHelpAfterParameter.baseline | 72 +- .../signatureHelpCommentsClass.baseline | 21 +- ...signatureHelpCommentsClassMembers.baseline | 99 +- ...gnatureHelpCommentsCommentParsing.baseline | 216 ++- ...reHelpCommentsFunctionDeclaration.baseline | 21 +- ...ureHelpCommentsFunctionExpression.baseline | 18 +- ...elpConstructorCallParamProperties.baseline | 6 +- ...elpExpandedRestTuplesLocalLabels1.baseline | 246 ++-- ...natureHelpInferenceJsDocImportTag.baseline | 51 + .../signatureHelpIteratorNext.baseline | 48 +- .../signatureHelpJSDocCallbackTag.baseline | 18 +- .../signatureHelpJSDocTags.baseline | 15 +- ...natureHelpJSMissingPropertyAccess.baseline | 47 +- .../signatureHelpRestArgs1.baseline | 30 +- .../signatureHelpRestArgs2.baseline | 31 +- .../signatureHelpRestArgs3.baseline | 15 +- .../signatureHelpSkippedArgs1.baseline | 30 +- .../signatureHelpTypeArguments2.baseline | 24 +- .../signatureHelpWithUnknown.baseline | 6 +- .../signatureHelp_unionType.baseline | 18 +- .../trailingCommaSignatureHelp.baseline | 15 +- .../state/declarationMapsFindAllRefs.baseline | 2 +- ...FindAllRefsDefinitionInMappedFile.baseline | 2 +- ...psFindAllRefsStartingAtDefinition.baseline | 2 +- ...MapsFindAllRefsTargetDoesNotExist.baseline | 2 +- ...apsOpeningOriginalLocationProject.baseline | 2 +- ...eSourceOfProjectReferenceRedirect.baseline | 2 +- ...efsAncestorSiblingProjectsLoading.baseline | 4 +- ...tsLoadingDisableSolutionSearching.baseline | 4 +- ...irectsAreDisabledDeclMapIsMissing.baseline | 2 +- ...irectsAreDisabledDeclMapIsPresent.baseline | 2 +- ...directsAreEnabledDeclMapIsMissing.baseline | 2 +- ...directsAreEnabledDeclMapIsPresent.baseline | 2 +- ...irectsAreDisabledDeclMapIsMissing.baseline | 2 +- ...irectsAreDisabledDeclMapIsPresent.baseline | 2 +- ...directsAreEnabledDeclMapIsMissing.baseline | 2 +- ...directsAreEnabledDeclMapIsPresent.baseline | 2 +- ...irectsAreDisabledDeclMapIsMissing.baseline | 2 +- ...irectsAreDisabledDeclMapIsPresent.baseline | 2 +- ...directsAreEnabledDeclMapIsMissing.baseline | 2 +- ...directsAreEnabledDeclMapIsPresent.baseline | 2 +- ...irectsAreDisabledDeclMapIsMissing.baseline | 2 +- ...irectsAreDisabledDeclMapIsPresent.baseline | 2 +- ...directsAreEnabledDeclMapIsMissing.baseline | 2 +- ...directsAreEnabledDeclMapIsPresent.baseline | 2 +- ...terItsUpdateDoesNotIncludeTheFile.baseline | 2 +- ...onfiguredProjectThatWillBeRemoved.baseline | 2 +- .../findAllRefsOverlappingProjects.baseline | 4 +- ...erencingFileFromReferencedProject.baseline | 4 +- ...indAllRefsRootOfReferencedProject.baseline | 2 +- ...fReferencedProjectDeclarationMaps.baseline | 2 +- ...ReferencingDefaultProjectDirectly.baseline | 4 +- ...ferencingDefaultProjectIndirectly.baseline | 4 +- ...roughDisableReferencedProjectLoad.baseline | 4 +- ...ectLoadInOneButWithoutItInAnother.baseline | 4 +- ...ReferencingDefaultProjectDirectly.baseline | 4 +- ...owFunctionAsObjectLiteralProperty.baseline | 2 +- ...ctionAsObjectLiteralPropertyTypes.baseline | 2 +- ...fLocalnessArrowFunctionAssignment.baseline | 2 +- ...fLocalnessMethodOfClassExpression.baseline | 2 +- ...gOfLocalnessObjectLiteralProperty.baseline | 2 +- ...ojectsOpenAndOneProjectReferences.baseline | 2 +- .../callHierarchyAccessor.callHierarchy.txt | 67 + ...tNamedFunctionExpression.callHierarchy.txt | 108 ++ .../callHierarchyClass.callHierarchy.txt | 66 + ...assPropertyArrowFunction.callHierarchy.txt | 44 + ...ierarchyClassStaticBlock.callHierarchy.txt | 140 ++ ...erarchyClassStaticBlock2.callHierarchy.txt | 140 ++ ...yConstNamedArrowFunction.callHierarchy.txt | 66 + ...onstNamedClassExpression.callHierarchy.txt | 70 + ...tNamedFunctionExpression.callHierarchy.txt | 66 + ...llHierarchyContainerName.callHierarchy.txt | 166 +++ ...archyContainerNameServer.callHierarchy.txt | 166 +++ .../callHierarchyCrossFile.callHierarchy.txt | 64 + .../callHierarchyDecorator.callHierarchy.txt | 66 + ...rarchyExportDefaultClass.callHierarchy.txt | 70 + ...chyExportDefaultFunction.callHierarchy.txt | 66 + ...rchyExportEqualsFunction.callHierarchy.txt | 48 + .../callHierarchyFile.callHierarchy.txt | 42 + .../callHierarchyFunction.callHierarchy.txt | 96 ++ ...archyFunctionAmbiguity.1.callHierarchy.txt | 79 + ...archyFunctionAmbiguity.2.callHierarchy.txt | 79 + ...archyFunctionAmbiguity.3.callHierarchy.txt | 79 + ...archyFunctionAmbiguity.4.callHierarchy.txt | 79 + ...archyFunctionAmbiguity.5.callHierarchy.txt | 60 + ...HierarchyInterfaceMethod.callHierarchy.txt | 48 + .../callHierarchyJsxElement.callHierarchy.txt | 66 + ...lHierarchyTaggedTemplate.callHierarchy.txt | 66 + .../importAttributesWithValueComments.ts | 13 + 278 files changed, 14654 insertions(+), 844 deletions(-) create mode 100644 pkg/fourslash/tests/codeLensFunctionExpressions01_test.go create mode 100644 pkg/fourslash/tests/codeLensFunctionsAndConstants01_test.go create mode 100644 pkg/fourslash/tests/codeLensInterface01_test.go create mode 100644 pkg/fourslash/tests/codeLensOverloads01_test.go create mode 100644 pkg/fourslash/tests/codeLensShowOnAllClassMethods_test.go create mode 100644 pkg/fourslash/tests/codeLensShowOnAllFunctions_test.go create mode 100644 pkg/fourslash/tests/codeLensShowOnInterfaceMethods_test.go create mode 100644 pkg/fourslash/tests/gen/augmentedTypesModule2_test.go create mode 100644 pkg/fourslash/tests/gen/augmentedTypesModule3_test.go create mode 100644 pkg/fourslash/tests/gen/augmentedTypesModule6_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyAccessor_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyCallExpressionByConstNamedFunctionExpression_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyClassPropertyArrowFunction_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyClassStaticBlock2_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyClassStaticBlock_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyClass_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyConstNamedArrowFunction_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyConstNamedClassExpression_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyConstNamedFunctionExpression_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyContainerNameServer_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyContainerName_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyCrossFile_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyDecorator_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyExportDefaultClass_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyExportDefaultFunction_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyExportEqualsFunction_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFile_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity1_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity2_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity3_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity4_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity5_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyFunction_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyInterfaceMethod_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyJsxElement_test.go create mode 100644 pkg/fourslash/tests/gen/callHierarchyTaggedTemplate_test.go create mode 100644 pkg/fourslash/tests/gen/callSignatureHelp_test.go create mode 100644 pkg/fourslash/tests/gen/calledUnionsOfDissimilarTyeshaveGoodDisplay_test.go create mode 100644 pkg/fourslash/tests/gen/classExtendsInterfaceSigHelp1_test.go create mode 100644 pkg/fourslash/tests/gen/commentsExternalModulesFourslash_test.go create mode 100644 pkg/fourslash/tests/gen/commentsImportDeclaration_test.go create mode 100644 pkg/fourslash/tests/gen/commentsInheritanceFourslash_test.go create mode 100644 pkg/fourslash/tests/gen/commentsInterfaceFourslash_test.go create mode 100644 pkg/fourslash/tests/gen/commentsOverloadsFourslash_test.go create mode 100644 pkg/fourslash/tests/gen/commentsVariables_test.go create mode 100644 pkg/fourslash/tests/gen/crossFileQuickInfoExportedTypeDoesNotUseImportType_test.go create mode 100644 pkg/fourslash/tests/gen/functionOverloadCount_test.go create mode 100644 pkg/fourslash/tests/gen/functionProperty_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionReturnType2_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionReturnType_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionSignatureHelp1_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionSignatureHelp2_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionSignatureHelp3MultiFile_test.go create mode 100644 pkg/fourslash/tests/gen/genericFunctionSignatureHelp3_test.go create mode 100644 pkg/fourslash/tests/gen/genericParameterHelpConstructorCalls_test.go create mode 100644 pkg/fourslash/tests/gen/genericParameterHelpTypeReferences_test.go create mode 100644 pkg/fourslash/tests/gen/genericParameterHelp_test.go create mode 100644 pkg/fourslash/tests/gen/getJavaScriptCompletions16_test.go create mode 100644 pkg/fourslash/tests/gen/jsSignature-41059_test.go create mode 100644 pkg/fourslash/tests/gen/noSignatureHelpOnNewKeyword_test.go create mode 100644 pkg/fourslash/tests/gen/overloadOnConstCallSignature_test.go create mode 100644 pkg/fourslash/tests/gen/qualifyModuleTypeNames_test.go create mode 100644 pkg/fourslash/tests/gen/quickInfoCanBeTruncated_test.go create mode 100644 pkg/fourslash/tests/gen/quickInfoInFunctionTypeReference2_test.go create mode 100644 pkg/fourslash/tests/gen/quickInfoOnConstructorWithGenericParameter_test.go create mode 100644 pkg/fourslash/tests/gen/quickInfoOnPrivateConstructorCall_test.go create mode 100644 pkg/fourslash/tests/gen/quickInfoOnProtectedConstructorCall_test.go create mode 100644 pkg/fourslash/tests/gen/restArgSignatureHelp_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelp01_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpAnonymousFunction_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpAtEOF2_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpAtEOF_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpBeforeSemicolon1_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpCallExpressionTuples_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpCallExpression_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpConstructExpression_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpConstructorInheritance_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpConstructorOverload_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpEmptyList_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpExpandedRestTuples_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpExpandedRestUnlabeledTuples_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpExpandedTuplesArgumentIndex_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpExplicitTypeArguments_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpFilteredTriggers03_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpForNonlocalTypeDoesNotUseImportType_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpForOptionalMethods_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpForSignatureWithUnreachableType_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpForSuperCalls1_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpFunctionOverload_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpFunctionParameter_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpImplicitConstructor_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpImportStarFromExportEquals_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInAdjacentBlockBody_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInCallback_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInCompleteGenericsCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInFunctionCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInParenthetical_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInRecursiveType_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpIncompleteCalls_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpInference_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpJSMissingIdentifier_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpJSX_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpLeadingRestTuple_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpNegativeTests2_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpNegativeTests_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpNoArguments_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpObjectCreationExpressionNoArgs_NotAvailable_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpObjectLiteral_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnDeclaration_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnNestedOverloads_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnOverloadOnConst_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnOverloadsDifferentArity2_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnOverloadsDifferentArity3_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnOverloadsDifferentArity_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnOverloads_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnSuperWhenMembersAreNotResolved_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOnTypePredicates_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOptionalCall2_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpOptionalCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpSimpleConstructorCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpSimpleFunctionCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpSimpleSuperCall_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpSuperConstructorOverload_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives1_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives2_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives3_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives4_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives5_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpThis_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTrailingRestTuple_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTypeArguments_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpTypeParametersNotVariadic_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpWithInterfaceAsIdentifier_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpWithInvalidArgumentList1_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelpWithTriggers02_test.go create mode 100644 pkg/fourslash/tests/gen/signatureHelp_contextual_test.go create mode 100644 pkg/fourslash/tests/gen/staticGenericOverloads1_test.go create mode 100644 pkg/fourslash/tests/gen/superInsideInnerClass_test.go create mode 100644 pkg/fourslash/tests/gen/tsxSignatureHelp1_test.go create mode 100644 pkg/fourslash/tests/gen/tsxSignatureHelp2_test.go rename pkg/fourslash/tests/{gen => manual}/jsDocFunctionSignatures12_test.go (63%) create mode 100644 pkg/fourslash/tests/manual/jsDocFunctionSignatures2_test.go create mode 100644 pkg/ls/callhierarchy.go create mode 100644 pkg/ls/codelens.go create mode 100644 testdata/baselines/reference/compiler/importAttributesWithValueComments.js create mode 100644 testdata/baselines/reference/compiler/importAttributesWithValueComments.symbols create mode 100644 testdata/baselines/reference/compiler/importAttributesWithValueComments.types create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionExpressions01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionsAndConstants01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensOverloads01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=false.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=true.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=false.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=true.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=false.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=true.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyAccessor.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCallExpressionByConstNamedFunctionExpression.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClass.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassPropertyArrowFunction.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock2.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedArrowFunction.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedClassExpression.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedFunctionExpression.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerName.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerNameServer.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCrossFile.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyDecorator.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultClass.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultFunction.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportEqualsFunction.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFile.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunction.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.1.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.2.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.3.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.4.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.5.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyInterfaceMethod.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyJsxElement.callHierarchy.txt create mode 100644 testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyTaggedTemplate.callHierarchy.txt create mode 100644 testdata/tests/cases/compiler/importAttributesWithValueComments.ts diff --git a/pkg/ast/ast.go b/pkg/ast/ast.go index 601af3db1..7b5ddf4e6 100644 --- a/pkg/ast/ast.go +++ b/pkg/ast/ast.go @@ -2214,11 +2214,11 @@ func IsWriteAccess(node *Node) bool { } func IsWriteAccessForReference(node *Node) bool { - decl := getDeclarationFromName(node) + decl := GetDeclarationFromName(node) return (decl != nil && declarationIsWriteAccess(decl)) || node.Kind == KindDefaultKeyword || IsWriteAccess(node) } -func getDeclarationFromName(name *Node) *Declaration { +func GetDeclarationFromName(name *Node) *Declaration { if name == nil || name.Parent == nil { return nil } diff --git a/pkg/ast/utilities.go b/pkg/ast/utilities.go index 92941d7d0..78cf0c9f6 100644 --- a/pkg/ast/utilities.go +++ b/pkg/ast/utilities.go @@ -1386,7 +1386,7 @@ func GetNameOfDeclaration(declaration *Node) *Node { return nonAssignedName } if IsFunctionExpression(declaration) || IsArrowFunction(declaration) || IsClassExpression(declaration) { - return getAssignedName(declaration) + return GetAssignedName(declaration) } return nil } @@ -1415,7 +1415,7 @@ func GetNonAssignedNameOfDeclaration(declaration *Node) *Node { return declaration.Name() } -func getAssignedName(node *Node) *Node { +func GetAssignedName(node *Node) *Node { parent := node.Parent if parent != nil { switch parent.Kind { @@ -3441,6 +3441,91 @@ func IsRightSideOfPropertyAccess(node *Node) bool { return node.Parent.Kind == KindPropertyAccessExpression && node.Parent.Name() == node } +func IsArgumentExpressionOfElementAccess(node *Node) bool { + return node.Parent != nil && node.Parent.Kind == KindElementAccessExpression && node.Parent.AsElementAccessExpression().ArgumentExpression == node +} + +func ClimbPastPropertyAccess(node *Node) *Node { + if IsRightSideOfPropertyAccess(node) { + return node.Parent + } + return node +} + +func climbPastPropertyOrElementAccess(node *Node) *Node { + if IsRightSideOfPropertyAccess(node) || IsArgumentExpressionOfElementAccess(node) { + return node.Parent + } + return node +} + +func selectExpressionOfCallOrNewExpressionOrDecorator(node *Node) *Node { + if IsCallExpression(node) || IsNewExpression(node) || IsDecorator(node) { + return node.Expression() + } + return nil +} + +func selectTagOfTaggedTemplateExpression(node *Node) *Node { + if IsTaggedTemplateExpression(node) { + return node.AsTaggedTemplateExpression().Tag + } + return nil +} + +func selectTagNameOfJsxOpeningLikeElement(node *Node) *Node { + if IsJsxOpeningElement(node) || IsJsxSelfClosingElement(node) { + return node.TagName() + } + return nil +} + +func IsCallExpressionTarget(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsCallExpression, selectExpressionOfCallOrNewExpressionOrDecorator, includeElementAccess, skipPastOuterExpressions) +} + +func IsNewExpressionTarget(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsNewExpression, selectExpressionOfCallOrNewExpressionOrDecorator, includeElementAccess, skipPastOuterExpressions) +} + +func IsCallOrNewExpressionTarget(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsCallOrNewExpression, selectExpressionOfCallOrNewExpressionOrDecorator, includeElementAccess, skipPastOuterExpressions) +} + +func IsTaggedTemplateTag(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsTaggedTemplateExpression, selectTagOfTaggedTemplateExpression, includeElementAccess, skipPastOuterExpressions) +} + +func IsDecoratorTarget(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsDecorator, selectExpressionOfCallOrNewExpressionOrDecorator, includeElementAccess, skipPastOuterExpressions) +} + +func IsJsxOpeningLikeElementTagName(node *Node, includeElementAccess bool, skipPastOuterExpressions bool) bool { + return isCalleeWorker(node, IsJsxOpeningLikeElement, selectTagNameOfJsxOpeningLikeElement, includeElementAccess, skipPastOuterExpressions) +} + +func isCalleeWorker( + node *Node, + pred func(*Node) bool, + calleeSelector func(*Node) *Node, + includeElementAccess bool, + skipPastOuterExpressions bool, +) bool { + var target *Node + if includeElementAccess { + target = climbPastPropertyOrElementAccess(node) + } else { + target = ClimbPastPropertyAccess(node) + } + if skipPastOuterExpressions { + // Only skip outer expressions if the target is actually an expression node + if IsExpression(target) { + target = SkipOuterExpressions(target, OEKAll) + } + } + return target != nil && target.Parent != nil && pred(target.Parent) && calleeSelector(target.Parent) == target +} + func IsRightSideOfQualifiedNameOrPropertyAccess(node *Node) bool { parent := node.Parent switch parent.Kind { diff --git a/pkg/diagnostics/diagnostics_generated.go b/pkg/diagnostics/diagnostics_generated.go index d59fa2ec2..7710a0f87 100644 --- a/pkg/diagnostics/diagnostics_generated.go +++ b/pkg/diagnostics/diagnostics_generated.go @@ -4262,6 +4262,14 @@ var Set_the_number_of_checkers_per_project = &Message{code: 100003, category: Ca var X_4_unless_singleThreaded_is_passed = &Message{code: 100004, category: CategoryMessage, key: "4_unless_singleThreaded_is_passed_100004", text: "4, unless --singleThreaded is passed."} +var X_0_references = &Message{code: 100005, category: CategoryMessage, key: "_0_references_100005", text: "{0} references"} + +var X_1_reference = &Message{code: 100006, category: CategoryMessage, key: "1_reference_100006", text: "1 reference"} + +var X_0_implementations = &Message{code: 100007, category: CategoryMessage, key: "_0_implementations_100007", text: "{0} implementations"} + +var X_1_implementation = &Message{code: 100008, category: CategoryMessage, key: "1_implementation_100008", text: "1 implementation"} + func keyToMessage(key Key) *Message { switch key { case "Unterminated_string_literal_1002": @@ -8524,6 +8532,14 @@ func keyToMessage(key Key) *Message { return Set_the_number_of_checkers_per_project case "4_unless_singleThreaded_is_passed_100004": return X_4_unless_singleThreaded_is_passed + case "_0_references_100005": + return X_0_references + case "1_reference_100006": + return X_1_reference + case "_0_implementations_100007": + return X_0_implementations + case "1_implementation_100008": + return X_1_implementation default: return nil } diff --git a/pkg/diagnostics/extraDiagnosticMessages.json b/pkg/diagnostics/extraDiagnosticMessages.json index 47d3e93a1..e0f096b16 100644 --- a/pkg/diagnostics/extraDiagnosticMessages.json +++ b/pkg/diagnostics/extraDiagnosticMessages.json @@ -19,6 +19,22 @@ "category": "Message", "code": 100004 }, + "{0} references": { + "category": "Message", + "code": 100005 + }, + "1 reference": { + "category": "Message", + "code": 100006 + }, + "{0} implementations": { + "category": "Message", + "code": 100007 + }, + "1 implementation": { + "category": "Message", + "code": 100008 + }, "Non-relative paths are not allowed. Did you forget a leading './'?": { "category": "Error", "code": 5090 diff --git a/pkg/fourslash/_scripts/convertFourslash.mts b/pkg/fourslash/_scripts/convertFourslash.mts index d4dc96c95..61b789df1 100644 --- a/pkg/fourslash/_scripts/convertFourslash.mts +++ b/pkg/fourslash/_scripts/convertFourslash.mts @@ -194,8 +194,18 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { return parseBaselineQuickInfo(callExpression.arguments); case "baselineSignatureHelp": return [parseBaselineSignatureHelp(callExpression.arguments)]; + case "signatureHelp": + return parseSignatureHelp(callExpression.arguments); + case "noSignatureHelp": + return parseNoSignatureHelp(callExpression.arguments); + case "signatureHelpPresentForTriggerReason": + return parseSignatureHelpPresentForTriggerReason(callExpression.arguments); + case "noSignatureHelpForTriggerReason": + return parseNoSignatureHelpForTriggerReason(callExpression.arguments); case "baselineSmartSelection": return [parseBaselineSmartSelection(callExpression.arguments)]; + case "baselineCallHierarchy": + return [parseBaselineCallHierarchy(callExpression.arguments)]; case "baselineGoToDefinition": case "baselineGetDefinitionAtPosition": case "baselineGoToType": @@ -1679,6 +1689,334 @@ function parseBaselineSignatureHelp(args: ts.NodeArray): Cmd { }; } +function parseSignatureHelpOptions(obj: ts.ObjectLiteralExpression): VerifySignatureHelpOptions | undefined { + const options: VerifySignatureHelpOptions = {}; + + for (const prop of obj.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Unexpected property in signatureHelp options: ${prop.getText()}`); + continue; + } + const name = prop.name.text; + const value = prop.initializer; + + switch (name) { + case "marker": { + if (ts.isStringLiteral(value)) { + options.marker = value.text; + } + else if (ts.isArrayLiteralExpression(value)) { + const markers: string[] = []; + for (const elem of value.elements) { + if (ts.isStringLiteral(elem)) { + markers.push(elem.text); + } + else { + console.error(`Expected string literal in marker array, got ${elem.getText()}`); + return undefined; + } + } + options.marker = markers; + } + else { + console.error(`Expected string or array for marker, got ${value.getText()}`); + return undefined; + } + break; + } + case "text": { + const str = getStringLiteralLike(value); + if (!str) { + console.error(`Expected string for text, got ${value.getText()}`); + return undefined; + } + options.text = str.text; + break; + } + case "docComment": { + const str = getStringLiteralLike(value); + if (!str) { + console.error(`Expected string for docComment, got ${value.getText()}`); + return undefined; + } + options.docComment = str.text; + break; + } + case "parameterCount": { + const num = getNumericLiteral(value); + if (!num) { + console.error(`Expected number for parameterCount, got ${value.getText()}`); + return undefined; + } + options.parameterCount = parseInt(num.text, 10); + break; + } + case "parameterName": { + const str = getStringLiteralLike(value); + if (!str) { + console.error(`Expected string for parameterName, got ${value.getText()}`); + return undefined; + } + options.parameterName = str.text; + break; + } + case "parameterSpan": { + const str = getStringLiteralLike(value); + if (!str) { + console.error(`Expected string for parameterSpan, got ${value.getText()}`); + return undefined; + } + options.parameterSpan = str.text; + break; + } + case "parameterDocComment": { + const str = getStringLiteralLike(value); + if (!str) { + console.error(`Expected string for parameterDocComment, got ${value.getText()}`); + return undefined; + } + options.parameterDocComment = str.text; + break; + } + case "overloadsCount": { + const num = getNumericLiteral(value); + if (!num) { + console.error(`Expected number for overloadsCount, got ${value.getText()}`); + return undefined; + } + options.overloadsCount = parseInt(num.text, 10); + break; + } + case "overrideSelectedItemIndex": { + const num = getNumericLiteral(value); + if (!num) { + console.error(`Expected number for overrideSelectedItemIndex, got ${value.getText()}`); + return undefined; + } + options.overrideSelectedItemIndex = parseInt(num.text, 10); + break; + } + case "triggerReason": { + // triggerReason is an object like { kind: "invoked" } or { kind: "characterTyped", triggerCharacter: "(" } + // For now, just pass it through as a string representation + options.triggerReason = value.getText(); + break; + } + case "argumentCount": + // ignore + break; + case "isVariadic": { + if (value.kind === ts.SyntaxKind.TrueKeyword) { + options.isVariadic = true; + } + else if (value.kind === ts.SyntaxKind.FalseKeyword) { + options.isVariadic = false; + } + else { + console.error(`Expected boolean for isVariadic, got ${value.getText()}`); + return undefined; + } + break; + } + case "tags": + // ignore + break; + default: + console.error(`Unknown signatureHelp option: ${name}`); + return undefined; + } + } + return options; +} + +function parseSignatureHelp(args: ts.NodeArray): Cmd[] | undefined { + const allOptions: VerifySignatureHelpOptions[] = []; + + for (const arg of args) { + if (ts.isObjectLiteralExpression(arg)) { + const opts = parseSignatureHelpOptions(arg); + if (!opts) { + return undefined; + } + allOptions.push(opts); + } + else if (ts.isIdentifier(arg)) { + // Could be a variable reference like `help2` - skip for now + console.error(`signatureHelp with variable reference not supported: ${arg.getText()}`); + return undefined; + } + else { + console.error(`Unexpected argument type in signatureHelp: ${arg.getText()}`); + return undefined; + } + } + + if (allOptions.length === 0) { + console.error("signatureHelp requires at least one options object"); + return undefined; + } + + return [{ + kind: "verifySignatureHelp", + options: allOptions, + }]; +} + +function parseNoSignatureHelp(args: ts.NodeArray): Cmd[] | undefined { + const markers: string[] = []; + + for (const arg of args) { + if (ts.isStringLiteral(arg)) { + markers.push(arg.text); + } + else if (ts.isSpreadElement(arg)) { + // Handle ...test.markerNames() + const expr = arg.expression; + if ( + ts.isCallExpression(expr) && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + expr.expression.expression.text === "test" && + ts.isIdentifier(expr.expression.name) && + expr.expression.name.text === "markerNames" + ) { + // This means "all markers" - we'll handle this specially in the generator + return [{ + kind: "verifyNoSignatureHelp", + markers: ["...test.markerNames()"], + }]; + } + console.error(`Unsupported spread in noSignatureHelp: ${arg.getText()}`); + return undefined; + } + else { + console.error(`Unexpected argument in noSignatureHelp: ${arg.getText()}`); + return undefined; + } + } + + return [{ + kind: "verifyNoSignatureHelp", + markers, + }]; +} + +interface SignatureHelpTriggerReason { + kind: "invoked" | "characterTyped" | "retrigger"; + triggerCharacter?: string; +} + +function parseTriggerReason(arg: ts.Expression): SignatureHelpTriggerReason | undefined | "undefined" { + // Handle undefined literal + if (ts.isIdentifier(arg) && arg.text === "undefined") { + return "undefined"; + } + + if (!ts.isObjectLiteralExpression(arg)) { + console.error(`Expected object literal for trigger reason, got ${arg.getText()}`); + return undefined; + } + + let kind: "invoked" | "characterTyped" | "retrigger" | undefined; + let triggerCharacter: string | undefined; + + for (const prop of arg.properties) { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) { + console.error(`Unexpected property in trigger reason: ${prop.getText()}`); + return undefined; + } + const name = prop.name.text; + if (name === "kind") { + if (!ts.isStringLiteral(prop.initializer)) { + console.error(`Expected string literal for kind, got ${prop.initializer.getText()}`); + return undefined; + } + const k = prop.initializer.text; + if (k === "invoked" || k === "characterTyped" || k === "retrigger") { + kind = k; + } + else { + console.error(`Unknown trigger reason kind: ${k}`); + return undefined; + } + } + else if (name === "triggerCharacter") { + if (!ts.isStringLiteral(prop.initializer)) { + console.error(`Expected string literal for triggerCharacter, got ${prop.initializer.getText()}`); + return undefined; + } + triggerCharacter = prop.initializer.text; + } + } + + if (!kind) { + console.error(`Missing kind in trigger reason`); + return undefined; + } + + return { kind, triggerCharacter }; +} + +function parseSignatureHelpPresentForTriggerReason(args: ts.NodeArray): Cmd[] | undefined { + if (args.length === 0) { + console.error("signatureHelpPresentForTriggerReason requires at least one argument"); + return undefined; + } + + const triggerReason = parseTriggerReason(args[0]); + if (triggerReason === undefined) { + return undefined; + } + + const markers: string[] = []; + for (let i = 1; i < args.length; i++) { + const arg = args[i]; + if (ts.isStringLiteral(arg)) { + markers.push(arg.text); + } + else { + console.error(`Unexpected argument in signatureHelpPresentForTriggerReason: ${arg.getText()}`); + return undefined; + } + } + + return [{ + kind: "verifySignatureHelpPresent", + triggerReason: triggerReason === "undefined" ? undefined : triggerReason, + markers, + }]; +} + +function parseNoSignatureHelpForTriggerReason(args: ts.NodeArray): Cmd[] | undefined { + if (args.length === 0) { + console.error("noSignatureHelpForTriggerReason requires at least one argument"); + return undefined; + } + + const triggerReason = parseTriggerReason(args[0]); + if (triggerReason === undefined) { + return undefined; + } + + const markers: string[] = []; + for (let i = 1; i < args.length; i++) { + const arg = args[i]; + if (ts.isStringLiteral(arg)) { + markers.push(arg.text); + } + else { + console.error(`Unexpected argument in noSignatureHelpForTriggerReason: ${arg.getText()}`); + return undefined; + } + } + + return [{ + kind: "verifyNoSignatureHelpForTriggerReason", + triggerReason: triggerReason === "undefined" ? undefined : triggerReason, + markers, + }]; +} + function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { if (args.length !== 0) { // All calls are currently empty! @@ -1689,6 +2027,15 @@ function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { }; } +function parseBaselineCallHierarchy(args: ts.NodeArray): Cmd { + if (args.length !== 0) { + throw new Error("Expected no arguments in verify.baselineCallHierarchy"); + } + return { + kind: "verifyBaselineCallHierarchy", + }; +} + function parseKind(expr: ts.Expression): string | undefined { if (!ts.isStringLiteral(expr)) { console.error(`Expected string literal for kind, got ${expr.getText()}`); @@ -2063,6 +2410,10 @@ interface VerifyBaselineSmartSelection { kind: "verifyBaselineSmartSelection"; } +interface VerifyBaselineCallHierarchy { + kind: "verifyBaselineCallHierarchy"; +} + interface VerifyBaselineRenameCmd { kind: "verifyBaselineRename" | "verifyBaselineRenameAtRangesWithText"; args: string[]; @@ -2126,6 +2477,42 @@ interface VerifyNavToCmd { args: string[]; } +interface VerifySignatureHelpOptions { + marker?: string | string[]; + text?: string; + docComment?: string; + parameterCount?: number; + parameterName?: string; + parameterSpan?: string; + parameterDocComment?: string; + overloadsCount?: number; + overrideSelectedItemIndex?: number; + triggerReason?: string; + isVariadic?: boolean; +} + +interface VerifySignatureHelpCmd { + kind: "verifySignatureHelp"; + options: VerifySignatureHelpOptions[]; +} + +interface VerifyNoSignatureHelpCmd { + kind: "verifyNoSignatureHelp"; + markers: string[]; +} + +interface VerifySignatureHelpPresentCmd { + kind: "verifySignatureHelpPresent"; + triggerReason?: SignatureHelpTriggerReason; + markers: string[]; +} + +interface VerifyNoSignatureHelpForTriggerReasonCmd { + kind: "verifyNoSignatureHelpForTriggerReason"; + triggerReason?: SignatureHelpTriggerReason; + markers: string[]; +} + type Cmd = | VerifyCompletionsCmd | VerifyApplyCodeActionFromCompletionCmd @@ -2135,6 +2522,11 @@ type Cmd = | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd | VerifyBaselineSmartSelection + | VerifySignatureHelpCmd + | VerifyNoSignatureHelpCmd + | VerifySignatureHelpPresentCmd + | VerifyNoSignatureHelpForTriggerReasonCmd + | VerifyBaselineCallHierarchy | GoToCmd | EditCmd | VerifyQuickInfoCmd @@ -2258,6 +2650,124 @@ function generateImportFixAtPosition({ expectedTexts, preferences }: VerifyImpor return `f.VerifyImportFixAtPosition(t, []string{\n${expectedTexts.join(",\n")},\n}, ${preferences})`; } +function generateSignatureHelpExpected(opts: VerifySignatureHelpOptions): string { + const fields: string[] = []; + + if (opts.text !== undefined) { + fields.push(`Text: ${getGoStringLiteral(opts.text)}`); + } + if (opts.docComment !== undefined) { + fields.push(`DocComment: ${getGoStringLiteral(opts.docComment)}`); + } + if (opts.parameterCount !== undefined) { + fields.push(`ParameterCount: ${opts.parameterCount}`); + } + if (opts.parameterName !== undefined) { + fields.push(`ParameterName: ${getGoStringLiteral(opts.parameterName)}`); + } + if (opts.parameterSpan !== undefined) { + fields.push(`ParameterSpan: ${getGoStringLiteral(opts.parameterSpan)}`); + } + if (opts.parameterDocComment !== undefined) { + fields.push(`ParameterDocComment: ${getGoStringLiteral(opts.parameterDocComment)}`); + } + if (opts.overloadsCount !== undefined) { + fields.push(`OverloadsCount: ${opts.overloadsCount}`); + } + if (opts.overrideSelectedItemIndex !== undefined) { + fields.push(`OverrideSelectedItemIndex: ${opts.overrideSelectedItemIndex}`); + } + if (opts.isVariadic !== undefined) { + fields.push(`IsVariadic: ${opts.isVariadic}`); + fields.push(`IsVariadicSet: true`); + } + + return `fourslash.VerifySignatureHelpOptions{${fields.join(", ")}}`; +} + +function generateSignatureHelp({ options }: VerifySignatureHelpCmd): string { + const lines: string[] = []; + + for (const opts of options) { + const expected = generateSignatureHelpExpected(opts); + + // Add comments for unsupported options + const unsupportedComments: string[] = []; + + if (opts.marker !== undefined) { + const markers = Array.isArray(opts.marker) ? opts.marker : [opts.marker]; + for (const marker of markers) { + lines.push(`f.GoToMarker(t, ${getGoStringLiteral(marker)})`); + for (const comment of unsupportedComments) { + lines.push(comment); + } + lines.push(`f.VerifySignatureHelp(t, ${expected})`); + } + } + else { + // No marker specified, use current position + for (const comment of unsupportedComments) { + lines.push(comment); + } + lines.push(`f.VerifySignatureHelp(t, ${expected})`); + } + } + + return lines.join("\n"); +} + +function generateNoSignatureHelp({ markers }: VerifyNoSignatureHelpCmd): string { + if (markers.length === 1 && markers[0] === "...test.markerNames()") { + // All markers + return `f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...)`; + } + if (markers.length === 0) { + // Current position + return `f.VerifyNoSignatureHelp(t)`; + } + // Specific markers + const markerArgs = markers.map(m => getGoStringLiteral(m)).join(", "); + return `f.VerifyNoSignatureHelpForMarkers(t, ${markerArgs})`; +} + +function generateTriggerContext(triggerReason: SignatureHelpTriggerReason | undefined): string { + if (!triggerReason) { + return "nil"; + } + switch (triggerReason.kind) { + case "invoked": + return `&lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindInvoked}`; + case "characterTyped": + return `&lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter, TriggerCharacter: PtrTo(${getGoStringLiteral(triggerReason.triggerCharacter ?? "")}), IsRetrigger: false}`; + case "retrigger": + return `&lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter, TriggerCharacter: PtrTo(${getGoStringLiteral(triggerReason.triggerCharacter ?? "")}), IsRetrigger: true}`; + default: + throw new Error(`Unknown trigger reason kind: ${triggerReason}`); + } +} + +function generateSignatureHelpPresent({ triggerReason, markers }: VerifySignatureHelpPresentCmd): string { + const context = generateTriggerContext(triggerReason); + if (markers.length === 0) { + // Current position + return `f.VerifySignatureHelpPresent(t, ${context})`; + } + // Specific markers + const markerArgs = markers.map(m => getGoStringLiteral(m)).join(", "); + return `f.VerifySignatureHelpPresentForMarkers(t, ${context}, ${markerArgs})`; +} + +function generateNoSignatureHelpForTriggerReason({ triggerReason, markers }: VerifyNoSignatureHelpForTriggerReasonCmd): string { + const context = generateTriggerContext(triggerReason); + if (markers.length === 0) { + // Current position + return `f.VerifyNoSignatureHelpWithContext(t, ${context})`; + } + // Specific markers + const markerArgs = markers.map(m => getGoStringLiteral(m)).join(", "); + return `f.VerifyNoSignatureHelpForMarkersWithContext(t, ${context}, ${markerArgs})`; +} + function generateNavigateTo({ args }: VerifyNavToCmd): string { return `f.VerifyWorkspaceSymbol(t, []*fourslash.VerifyWorkspaceSymbolCase{\n${args.join(", ")}})`; } @@ -2283,6 +2793,8 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyBaselineSignatureHelp(t)`; case "verifyBaselineSmartSelection": return `f.VerifyBaselineSelectionRanges(t)`; + case "verifyBaselineCallHierarchy": + return `f.VerifyBaselineCallHierarchy(t)`; case "goTo": return generateGoToCommand(cmd); case "edit": @@ -2310,6 +2822,14 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyBaselineNonSuggestionDiagnostics(t)`; case "verifyNavigateTo": return generateNavigateTo(cmd); + case "verifySignatureHelp": + return generateSignatureHelp(cmd); + case "verifyNoSignatureHelp": + return generateNoSignatureHelp(cmd); + case "verifySignatureHelpPresent": + return generateSignatureHelpPresent(cmd); + case "verifyNoSignatureHelpForTriggerReason": + return generateNoSignatureHelpForTriggerReason(cmd); default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); diff --git a/pkg/fourslash/_scripts/failingTests.txt b/pkg/fourslash/_scripts/failingTests.txt index bb01a0e57..d9ed2dcb5 100644 --- a/pkg/fourslash/_scripts/failingTests.txt +++ b/pkg/fourslash/_scripts/failingTests.txt @@ -43,10 +43,17 @@ TestAutoImportTypeOnlyPreferred2 TestAutoImportVerbatimTypeOnly1 TestBestCommonTypeObjectLiterals TestBestCommonTypeObjectLiterals1 +TestCalledUnionsOfDissimilarTyeshaveGoodDisplay TestCodeCompletionEscaping TestCommentsEnumsFourslash +TestCommentsExternalModulesFourslash +TestCommentsImportDeclaration +TestCommentsInheritanceFourslash +TestCommentsInterfaceFourslash TestCommentsLinePreservation +TestCommentsOverloadsFourslash TestCommentsUnion +TestCommentsVariables TestCompletionAfterQuestionDot TestCompletionAutoInsertQuestionDot TestCompletionCloneQuestionToken @@ -227,6 +234,7 @@ TestCompletionWithConditionalOperatorMissingColon TestConstEnumQuickInfoAndCompletionList TestConstQuickInfoAndCompletionList TestContextuallyTypedFunctionExpressionGeneric1 +TestCrossFileQuickInfoExportedTypeDoesNotUseImportType TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass @@ -331,7 +339,6 @@ TestJsdocCallbackTag TestJsDocExtends TestJsDocFunctionSignatures10 TestJsDocFunctionSignatures11 -TestJsDocFunctionSignatures12 TestJsDocFunctionSignatures13 TestJsDocFunctionSignatures7 TestJsDocFunctionSignatures8 @@ -428,11 +435,13 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto +TestQualifyModuleTypeNames TestQuickInfo_notInsideComment TestQuickinfo01 TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 +TestQuickInfoCanBeTruncated TestQuickInfoClassKeyword TestQuickInfoContextuallyTypedSignatureOptionalParameterFromIntersection1 TestQuickInfoContextualTyping @@ -541,7 +550,6 @@ TestRenameFromNodeModulesDep4 TestRenamePrivateFields TestReverseMappedTypeQuickInfo TestSelfReferencedExternalModule -TestSignatureHelpInferenceJsDocImportTag TestStringCompletionsImportOrExportSpecifier TestStringCompletionsVsEscaping TestSymbolCompletionLowerPriority diff --git a/pkg/fourslash/_scripts/manualTests.txt b/pkg/fourslash/_scripts/manualTests.txt index 1dfd6557e..970916f31 100644 --- a/pkg/fourslash/_scripts/manualTests.txt +++ b/pkg/fourslash/_scripts/manualTests.txt @@ -13,3 +13,5 @@ quickInfoForOverloadOnConst1 renameDefaultKeyword renameForDefaultExport01 tsxCompletion12 +jsDocFunctionSignatures2 +jsDocFunctionSignatures12 diff --git a/pkg/fourslash/baselineutil.go b/pkg/fourslash/baselineutil.go index 181d9e477..d8363fd14 100644 --- a/pkg/fourslash/baselineutil.go +++ b/pkg/fourslash/baselineutil.go @@ -22,6 +22,7 @@ import ( const ( autoImportsCmd baselineCommand = "Auto Imports" + callHierarchyCmd baselineCommand = "Call Hierarchy" documentHighlightsCmd baselineCommand = "documentHighlights" findAllReferencesCmd baselineCommand = "findAllReferences" goToDefinitionCmd baselineCommand = "goToDefinition" @@ -33,6 +34,7 @@ const ( renameCmd baselineCommand = "findRenameLocations" signatureHelpCmd baselineCommand = "SignatureHelp" smartSelectionCmd baselineCommand = "Smart Selection" + codeLensesCmd baselineCommand = "Code Lenses" ) type baselineCommand string @@ -71,6 +73,8 @@ func getBaselineExtension(command baselineCommand) string { switch command { case quickInfoCmd, signatureHelpCmd, smartSelectionCmd, inlayHintsCmd, nonSuggestionDiagnosticsCmd: return "baseline" + case callHierarchyCmd: + return "callHierarchy.txt" case autoImportsCmd: return "baseline.md" default: @@ -91,6 +95,21 @@ func (f *FourslashTest) getBaselineOptions(command baselineCommand, testPath str Subfolder: subfolder, IsSubmodule: true, } + case callHierarchyCmd: + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + DiffFixupOld: func(s string) string { + // TypeScript baselines have "/tests/cases/fourslash/" prefix in file paths + // Handle /server/ subdirectory - need to remove both prefixes + s = strings.ReplaceAll(s, "/tests/cases/fourslash/server/", "/") + s = strings.ReplaceAll(s, "/tests/cases/fourslash/", "/") + // SymbolKind enum differences between Strada and tsgo + s = strings.ReplaceAll(s, "kind: getter", "kind: property") + s = strings.ReplaceAll(s, "kind: script", "kind: file") + return s + }, + } case renameCmd: return baseline.Options{ Subfolder: subfolder, diff --git a/pkg/fourslash/fourslash.go b/pkg/fourslash/fourslash.go index 677a3eeeb..c891f9ee8 100644 --- a/pkg/fourslash/fourslash.go +++ b/pkg/fourslash/fourslash.go @@ -7,6 +7,7 @@ import ( "maps" "runtime" "slices" + "strconv" "strings" "testing" "unicode/utf8" @@ -114,8 +115,8 @@ func (w *lspWriter) Write(msg *lsproto.Message) error { return nil } -func (r *lspWriter) Close() { - close(r.c) +func (w *lspWriter) Close() { + close(w.c) } var ( @@ -268,7 +269,23 @@ func getBaseFileNameFromTest(t *testing.T) string { name := t.Name() name = core.LastOrNil(strings.Split(name, "/")) name = strings.TrimPrefix(name, "Test") - return stringutil.LowerFirstChar(name) + name = stringutil.LowerFirstChar(name) + + // Special case: TypeScript has "callHierarchyFunctionAmbiguity.N" with periods + switch name { + case "callHierarchyFunctionAmbiguity1": + name = "callHierarchyFunctionAmbiguity.1" + case "callHierarchyFunctionAmbiguity2": + name = "callHierarchyFunctionAmbiguity.2" + case "callHierarchyFunctionAmbiguity3": + name = "callHierarchyFunctionAmbiguity.3" + case "callHierarchyFunctionAmbiguity4": + name = "callHierarchyFunctionAmbiguity.4" + case "callHierarchyFunctionAmbiguity5": + name = "callHierarchyFunctionAmbiguity.5" + } + + return name } func (f *FourslashTest) nextID() int32 { @@ -277,13 +294,16 @@ func (f *FourslashTest) nextID() int32 { return id } +const showCodeLensLocationsCommandName = "typescript.showCodeLensLocations" + func (f *FourslashTest) initialize(t *testing.T, capabilities *lsproto.ClientCapabilities) { params := &lsproto.InitializeParams{ Locale: ptrTo("en-US"), InitializationOptions: &lsproto.InitializationOptions{ // Hack: disable push diagnostics entirely, since the fourslash runner does not // yet gracefully handle non-request messages. - DisablePushDiagnostics: ptrTo(true), + DisablePushDiagnostics: ptrTo(true), + CodeLensShowLocationsCommandName: ptrTo(showCodeLensLocationsCommandName), }, } params.Capabilities = getCapabilitiesWithDefaults(capabilities) @@ -1302,7 +1322,9 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( Uri: lsconv.FileNameToDocumentURI(f.activeFilename), }, Position: f.currentCaretPosition, - Context: &lsproto.ReferenceContext{}, + Context: &lsproto.ReferenceContext{ + IncludeDeclaration: true, + }, } result := sendRequest(t, f, lsproto.TextDocumentReferencesInfo, params) f.addResultToBaseline(t, findAllReferencesCmd, f.getBaselineForLocationsWithFileContents(*result.Locations, baselineFourslashLocationsOptions{ @@ -1313,6 +1335,61 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( } } +func (f *FourslashTest) VerifyBaselineCodeLens(t *testing.T, preferences *lsutil.UserPreferences) { + if preferences != nil { + reset := f.ConfigureWithReset(t, preferences) + defer reset() + } + + foundAtLeastOneCodeLens := false + for _, openFile := range slices.Sorted(maps.Keys(f.openFiles)) { + params := &lsproto.CodeLensParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(openFile), + }, + } + + unresolvedCodeLensList := sendRequest(t, f, lsproto.TextDocumentCodeLensInfo, params) + if unresolvedCodeLensList.CodeLenses == nil || len(*unresolvedCodeLensList.CodeLenses) == 0 { + continue + } + foundAtLeastOneCodeLens = true + + for _, unresolvedCodeLens := range *unresolvedCodeLensList.CodeLenses { + assert.Assert(t, unresolvedCodeLens != nil) + resolvedCodeLens := sendRequest(t, f, lsproto.CodeLensResolveInfo, unresolvedCodeLens) + assert.Assert(t, resolvedCodeLens != nil) + assert.Assert(t, resolvedCodeLens.Command != nil, "Expected resolved code lens to have a command.") + if len(resolvedCodeLens.Command.Command) > 0 { + assert.Equal(t, resolvedCodeLens.Command.Command, showCodeLensLocationsCommandName) + } + + var locations []lsproto.Location + // commandArgs: (DocumentUri, Position, Location[]) + if commandArgs := resolvedCodeLens.Command.Arguments; commandArgs != nil { + locs, err := roundtripThroughJson[[]lsproto.Location]((*commandArgs)[2]) + if err != nil { + t.Fatalf("failed to re-encode code lens locations: %v", err) + } + locations = locs + } + + f.addResultToBaseline(t, codeLensesCmd, f.getBaselineForLocationsWithFileContents(locations, baselineFourslashLocationsOptions{ + marker: &RangeMarker{ + fileName: openFile, + LSRange: resolvedCodeLens.Range, + Range: f.converters.FromLSPRange(f.getScriptInfo(openFile), resolvedCodeLens.Range), + }, + markerName: "/*CODELENS: " + resolvedCodeLens.Command.Title + "*/", + })) + } + } + + if !foundAtLeastOneCodeLens { + t.Fatalf("Expected at least one code lens in any open file, but got none.") + } +} + func (f *FourslashTest) MarkTestAsStradaServer() { f.isStradaServer = true } @@ -1516,7 +1593,7 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { params := &lsproto.SignatureHelpParams{ TextDocument: lsproto.TextDocumentIdentifier{ - Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + Uri: lsconv.FileNameToDocumentURI(marker.FileName()), }, Position: marker.LSPosition, } @@ -1547,9 +1624,18 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { signatureLine := sig.Label activeParamLine := "" + // Determine active parameter: per-signature takes precedence over top-level per LSP spec + // "If provided (or `null`), this is used in place of `SignatureHelp.activeParameter`." + var activeParamPtr *lsproto.UintegerOrNull + if sig.ActiveParameter != nil { + activeParamPtr = sig.ActiveParameter + } else { + activeParamPtr = item.ActiveParameter + } + // Show active parameter if specified, and the signature text. - if item.ActiveParameter != nil && sig.Parameters != nil { - activeParamIndex := int(*item.ActiveParameter.Uinteger) + if activeParamPtr != nil && activeParamPtr.Uinteger != nil && sig.Parameters != nil { + activeParamIndex := int(*activeParamPtr.Uinteger) if activeParamIndex >= 0 && activeParamIndex < len(*sig.Parameters) { activeParam := (*sig.Parameters)[activeParamIndex] @@ -1742,6 +1828,310 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { f.addResultToBaseline(t, smartSelectionCmd, strings.TrimSuffix(result.String(), "\n")) } +func (f *FourslashTest) VerifyBaselineCallHierarchy(t *testing.T) { + fileName := f.activeFilename + position := f.currentCaretPosition + + params := &lsproto.CallHierarchyPrepareParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(fileName), + }, + Position: position, + } + + prepareResult := sendRequest(t, f, lsproto.TextDocumentPrepareCallHierarchyInfo, params) + if prepareResult.CallHierarchyItems == nil || len(*prepareResult.CallHierarchyItems) == 0 { + f.addResultToBaseline(t, callHierarchyCmd, "No call hierarchy items available") + return + } + + var result strings.Builder + + for _, callHierarchyItem := range *prepareResult.CallHierarchyItems { + seen := make(map[callHierarchyItemKey]bool) + itemFileName := callHierarchyItem.Uri.FileName() + script := f.getScriptInfo(itemFileName) + formatCallHierarchyItem(t, f, script, &result, *callHierarchyItem, callHierarchyItemDirectionRoot, seen, "") + } + + f.addResultToBaseline(t, callHierarchyCmd, strings.TrimSuffix(result.String(), "\n")) +} + +type callHierarchyItemDirection int + +const ( + callHierarchyItemDirectionRoot callHierarchyItemDirection = iota + callHierarchyItemDirectionIncoming + callHierarchyItemDirectionOutgoing +) + +type callHierarchyItemKey struct { + uri lsproto.DocumentUri + range_ lsproto.Range + direction callHierarchyItemDirection +} + +func symbolKindToLowercase(kind lsproto.SymbolKind) string { + return strings.ToLower(kind.String()) +} + +func formatCallHierarchyItem( + t *testing.T, + f *FourslashTest, + file *scriptInfo, + result *strings.Builder, + callHierarchyItem lsproto.CallHierarchyItem, + direction callHierarchyItemDirection, + seen map[callHierarchyItemKey]bool, + prefix string, +) { + key := callHierarchyItemKey{ + uri: callHierarchyItem.Uri, + range_: callHierarchyItem.Range, + direction: direction, + } + alreadySeen := seen[key] + seen[key] = true + + type incomingCallResult struct { + skip bool + seen bool + values []*lsproto.CallHierarchyIncomingCall + } + type outgoingCallResult struct { + skip bool + seen bool + values []*lsproto.CallHierarchyOutgoingCall + } + + var incomingCalls incomingCallResult + var outgoingCalls outgoingCallResult + + if direction == callHierarchyItemDirectionOutgoing { + incomingCalls.skip = true + } else if alreadySeen { + incomingCalls.seen = true + } else { + incomingParams := &lsproto.CallHierarchyIncomingCallsParams{ + Item: &callHierarchyItem, + } + incomingResult := sendRequest(t, f, lsproto.CallHierarchyIncomingCallsInfo, incomingParams) + if incomingResult.CallHierarchyIncomingCalls != nil { + incomingCalls.values = *incomingResult.CallHierarchyIncomingCalls + } + } + + if direction == callHierarchyItemDirectionIncoming { + outgoingCalls.skip = true + } else if alreadySeen { + outgoingCalls.seen = true + } else { + outgoingParams := &lsproto.CallHierarchyOutgoingCallsParams{ + Item: &callHierarchyItem, + } + outgoingResult := sendRequest(t, f, lsproto.CallHierarchyOutgoingCallsInfo, outgoingParams) + if outgoingResult.CallHierarchyOutgoingCalls != nil { + outgoingCalls.values = *outgoingResult.CallHierarchyOutgoingCalls + } + } + + trailingPrefix := prefix + result.WriteString(fmt.Sprintf("%s╭ name: %s\n", prefix, callHierarchyItem.Name)) + result.WriteString(fmt.Sprintf("%s├ kind: %s\n", prefix, symbolKindToLowercase(callHierarchyItem.Kind))) + if callHierarchyItem.Detail != nil && *callHierarchyItem.Detail != "" { + result.WriteString(fmt.Sprintf("%s├ containerName: %s\n", prefix, *callHierarchyItem.Detail)) + } + result.WriteString(fmt.Sprintf("%s├ file: %s\n", prefix, callHierarchyItem.Uri.FileName())) + result.WriteString(prefix + "├ span:\n") + formatCallHierarchyItemSpan(f, file, result, callHierarchyItem.Range, prefix+"│ ", prefix+"│ ") + result.WriteString(prefix + "├ selectionSpan:\n") + formatCallHierarchyItemSpan(f, file, result, callHierarchyItem.SelectionRange, prefix+"│ ", prefix+"│ ") + + // Handle incoming calls + if incomingCalls.seen { + if outgoingCalls.skip { + result.WriteString(trailingPrefix + "╰ incoming: ...\n") + } else { + result.WriteString(prefix + "├ incoming: ...\n") + } + } else if !incomingCalls.skip { + if len(incomingCalls.values) == 0 { + if outgoingCalls.skip { + result.WriteString(trailingPrefix + "╰ incoming: none\n") + } else { + result.WriteString(prefix + "├ incoming: none\n") + } + } else { + result.WriteString(prefix + "├ incoming:\n") + for i, incomingCall := range incomingCalls.values { + fromFileName := incomingCall.From.Uri.FileName() + fromFile := f.getScriptInfo(fromFileName) + result.WriteString(prefix + "│ ╭ from:\n") + formatCallHierarchyItem(t, f, fromFile, result, *incomingCall.From, callHierarchyItemDirectionIncoming, seen, prefix+"│ │ ") + result.WriteString(prefix + "│ ├ fromSpans:\n") + + fromSpansTrailingPrefix := trailingPrefix + "╰ ╰ " + if i < len(incomingCalls.values)-1 { + fromSpansTrailingPrefix = prefix + "│ ╰ " + } else if !outgoingCalls.skip && (!outgoingCalls.seen || len(outgoingCalls.values) > 0) { + fromSpansTrailingPrefix = prefix + "│ ╰ " + } + formatCallHierarchyItemSpans(f, fromFile, result, incomingCall.FromRanges, prefix+"│ │ ", fromSpansTrailingPrefix) + } + } + } + + // Handle outgoing calls + if outgoingCalls.seen { + result.WriteString(trailingPrefix + "╰ outgoing: ...\n") + } else if !outgoingCalls.skip { + if len(outgoingCalls.values) == 0 { + result.WriteString(trailingPrefix + "╰ outgoing: none\n") + } else { + result.WriteString(prefix + "├ outgoing:\n") + for i, outgoingCall := range outgoingCalls.values { + toFileName := outgoingCall.To.Uri.FileName() + toFile := f.getScriptInfo(toFileName) + result.WriteString(prefix + "│ ╭ to:\n") + formatCallHierarchyItem(t, f, toFile, result, *outgoingCall.To, callHierarchyItemDirectionOutgoing, seen, prefix+"│ │ ") + result.WriteString(prefix + "│ ├ fromSpans:\n") + + fromSpansTrailingPrefix := trailingPrefix + "╰ ╰ " + if i < len(outgoingCalls.values)-1 { + fromSpansTrailingPrefix = prefix + "│ ╰ " + } + formatCallHierarchyItemSpans(f, file, result, outgoingCall.FromRanges, prefix+"│ │ ", fromSpansTrailingPrefix) + } + } + } +} + +func formatCallHierarchyItemSpan( + f *FourslashTest, + file *scriptInfo, + result *strings.Builder, + span lsproto.Range, + prefix string, + closingPrefix string, +) { + startLc := span.Start + endLc := span.End + startPos := f.converters.LineAndCharacterToPosition(file, span.Start) + endPos := f.converters.LineAndCharacterToPosition(file, span.End) + + // Compute line starts for the file + lineStarts := computeLineStarts(file.content) + + // Find the line boundaries - expand to full lines + contextStart := int(startPos) + contextEnd := int(endPos) + + // Expand to start of first line + for contextStart > 0 && file.content[contextStart-1] != '\n' && file.content[contextStart-1] != '\r' { + contextStart-- + } + + // Expand to end of last line + for contextEnd < len(file.content) && file.content[contextEnd] != '\n' && file.content[contextEnd] != '\r' { + contextEnd++ + } + + // Get actual line and character positions for the context + contextStartLine := int(startLc.Line) + contextEndLine := int(endLc.Line) + + // Calculate line number padding + lineNumWidth := len(strconv.Itoa(contextEndLine+1)) + 2 + + result.WriteString(fmt.Sprintf("%s╭ %s:%d:%d-%d:%d\n", prefix, file.fileName, startLc.Line+1, startLc.Character+1, endLc.Line+1, endLc.Character+1)) + + for lineNum := contextStartLine; lineNum <= contextEndLine; lineNum++ { + lineStart := lineStarts[lineNum] + lineEnd := len(file.content) + if lineNum+1 < len(lineStarts) { + lineEnd = lineStarts[lineNum+1] + } + + // Get the line content, trimming trailing newlines + lineContent := file.content[lineStart:lineEnd] + lineContent = strings.TrimRight(lineContent, "\r\n") + + // Format with line number + lineNumStr := fmt.Sprintf("%d:", lineNum+1) + paddedLineNum := strings.Repeat(" ", lineNumWidth-len(lineNumStr)-1) + lineNumStr + if lineContent == "" { + result.WriteString(fmt.Sprintf("%s│ %s\n", prefix, paddedLineNum)) + } else { + result.WriteString(fmt.Sprintf("%s│ %s %s\n", prefix, paddedLineNum, lineContent)) + } + + // Add selection carets if this line contains part of the span + if lineNum >= int(startLc.Line) && lineNum <= int(endLc.Line) { + selStart := 0 + selEnd := len(lineContent) + + if lineNum == int(startLc.Line) { + selStart = int(startLc.Character) + } + if lineNum == int(endLc.Line) { + selEnd = int(endLc.Character) + } + + // Don't show carets for empty selections + isEmpty := startLc.Line == endLc.Line && startLc.Character == endLc.Character + if isEmpty { + // For empty selections, show a single "<" character + padding := strings.Repeat(" ", lineNumWidth+selStart) + result.WriteString(fmt.Sprintf("%s│ %s<\n", prefix, padding)) + } else { + // Calculate selection length (at least 1) + selLength := selEnd - selStart + selLength = max(selLength, 1) // Trim to actual content on the line + if lineNum < int(endLc.Line) { + // For lines before the last, trim to line content length + if selEnd > len(lineContent) { + selEnd = len(lineContent) + selLength = selEnd - selStart + } + } + + padding := strings.Repeat(" ", lineNumWidth+selStart) + carets := strings.Repeat("^", selLength) + result.WriteString(fmt.Sprintf("%s│ %s%s\n", prefix, padding, carets)) + } + } + } + + result.WriteString(closingPrefix + "╰\n") +} + +func computeLineStarts(content string) []int { + lineStarts := []int{0} + for i, ch := range content { + if ch == '\n' { + lineStarts = append(lineStarts, i+1) + } + } + return lineStarts +} + +func formatCallHierarchyItemSpans( + f *FourslashTest, + file *scriptInfo, + result *strings.Builder, + spans []lsproto.Range, + prefix string, + trailingPrefix string, +) { + for i, span := range spans { + closingPrefix := prefix + if i == len(spans)-1 { + closingPrefix = trailingPrefix + } + formatCallHierarchyItemSpan(f, file, result, span, prefix, closingPrefix) + } +} + func (f *FourslashTest) VerifyBaselineDocumentHighlights( t *testing.T, preferences *lsutil.UserPreferences, @@ -1825,6 +2215,25 @@ func ptrTo[T any](v T) *T { return &v } +// This function is intended for spots where a complex +// value needs to be reinterpreted following some prior JSON deserialization. +// The default deserializer for `any` properties will give us a map at runtime, +// but we want to validate against, and use, the types as returned from the the language service. +// +// Use this function sparingly. You can treat it as a "map-to-struct" converter, +// but updating the original types is probably better in most cases. +func roundtripThroughJson[T any](value any) (T, error) { + var result T + bytes, err := json.Marshal(value) + if err != nil { + return result, fmt.Errorf("failed to marshal value to JSON: %w", err) + } + if err := json.Unmarshal(bytes, &result); err != nil { + return result, fmt.Errorf("failed to unmarshal value from JSON: %w", err) + } + return result, nil +} + // Insert text at the current caret position. func (f *FourslashTest) Insert(t *testing.T, text string) { f.typeText(t, text) @@ -2083,13 +2492,277 @@ func (f *FourslashTest) VerifyQuickInfoIs(t *testing.T, expectedText string, exp f.verifyHoverContent(t, hover.Contents, expectedText, expectedDocumentation, f.getCurrentPositionPrefix()) } +// VerifySignatureHelpOptions contains options for verifying signature help. +// All fields are optional - only specified fields will be verified. +type VerifySignatureHelpOptions struct { + // Text is the full signature text (e.g., "fn(x: string, y: number): void") + Text string + // DocComment is the documentation comment for the signature + DocComment string + // ParameterCount is the expected number of parameters + ParameterCount int + // ParameterName is the expected name of the active parameter + ParameterName string + // ParameterSpan is the expected label of the active parameter (e.g., "x: string") + ParameterSpan string + // ParameterDocComment is the documentation for the active parameter + ParameterDocComment string + // OverloadsCount is the expected number of overloads (signatures) + OverloadsCount int + // OverrideSelectedItemIndex overrides which signature to check (default: ActiveSignature) + OverrideSelectedItemIndex int + // IsVariadic indicates if the signature has a rest parameter + IsVariadic bool + // IsVariadicSet is true when IsVariadic was explicitly set (to distinguish from default false) + IsVariadicSet bool +} + +// VerifySignatureHelp verifies signature help at the current position matches the expected options. +func (f *FourslashTest) VerifySignatureHelp(t *testing.T, expected VerifySignatureHelpOptions) { + t.Helper() + prefix := f.getCurrentPositionPrefix() + params := &lsproto.SignatureHelpParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) + help := result.SignatureHelp + if help == nil { + t.Fatalf("%sCould not get signature help", prefix) + } + + // Determine which signature to check + selectedIndex := 0 + if expected.OverrideSelectedItemIndex > 0 { + selectedIndex = expected.OverrideSelectedItemIndex + } else if help.ActiveSignature != nil { + selectedIndex = int(*help.ActiveSignature) + } + + if selectedIndex >= len(help.Signatures) { + t.Fatalf("%sSelected signature index %d out of range (have %d signatures)", prefix, selectedIndex, len(help.Signatures)) + } + + selectedSig := help.Signatures[selectedIndex] + + // Verify overloads count + if expected.OverloadsCount > 0 { + if len(help.Signatures) != expected.OverloadsCount { + t.Errorf("%sExpected %d overloads, got %d", prefix, expected.OverloadsCount, len(help.Signatures)) + } + } + + // Verify signature text + if expected.Text != "" { + if selectedSig.Label != expected.Text { + t.Errorf("%sExpected signature text %q, got %q", prefix, expected.Text, selectedSig.Label) + } + } + + // Verify doc comment + if expected.DocComment != "" { + actualDoc := "" + if selectedSig.Documentation != nil { + if selectedSig.Documentation.MarkupContent != nil { + actualDoc = selectedSig.Documentation.MarkupContent.Value + } else if selectedSig.Documentation.String != nil { + actualDoc = *selectedSig.Documentation.String + } + } + if actualDoc != expected.DocComment { + t.Errorf("%sExpected doc comment %q, got %q", prefix, expected.DocComment, actualDoc) + } + } + + // Verify parameter count + if expected.ParameterCount > 0 { + paramCount := 0 + if selectedSig.Parameters != nil { + paramCount = len(*selectedSig.Parameters) + } + if paramCount != expected.ParameterCount { + t.Errorf("%sExpected %d parameters, got %d", prefix, expected.ParameterCount, paramCount) + } + } + + // Get active parameter + var activeParamIndex int + if selectedSig.ActiveParameter != nil && selectedSig.ActiveParameter.Uinteger != nil { + activeParamIndex = int(*selectedSig.ActiveParameter.Uinteger) + } else if help.ActiveParameter != nil && help.ActiveParameter.Uinteger != nil { + activeParamIndex = int(*help.ActiveParameter.Uinteger) + } + + var activeParam *lsproto.ParameterInformation + if selectedSig.Parameters != nil && activeParamIndex < len(*selectedSig.Parameters) { + activeParam = (*selectedSig.Parameters)[activeParamIndex] + } + + // Verify parameter name + if expected.ParameterName != "" { + if activeParam == nil { + t.Errorf("%sExpected parameter name %q, but no active parameter", prefix, expected.ParameterName) + } else { + // Parameter name is extracted from the label + actualName := "" + if activeParam.Label.String != nil { + // Extract name from label like "x: string" -> "x" or "T extends Foo" -> "T" or "...x: any[]" -> "x" + label := *activeParam.Label.String + // Strip leading "..." for rest parameters + label = strings.TrimPrefix(label, "...") + if name, _, found := strings.Cut(label, ":"); found { + actualName = strings.TrimSpace(name) + } else if name, _, found := strings.Cut(label, " extends "); found { + actualName = strings.TrimSpace(name) + } else { + actualName = label + } + } + if actualName != expected.ParameterName { + t.Errorf("%sExpected parameter name %q, got %q", prefix, expected.ParameterName, actualName) + } + } + } + + // Verify parameter span (label) + if expected.ParameterSpan != "" { + if activeParam == nil { + t.Errorf("%sExpected parameter span %q, but no active parameter", prefix, expected.ParameterSpan) + } else { + actualSpan := "" + if activeParam.Label.String != nil { + actualSpan = *activeParam.Label.String + } + if actualSpan != expected.ParameterSpan { + t.Errorf("%sExpected parameter span %q, got %q", prefix, expected.ParameterSpan, actualSpan) + } + } + } + + // Verify parameter doc comment + if expected.ParameterDocComment != "" { + if activeParam == nil { + t.Errorf("%sExpected parameter doc comment %q, but no active parameter", prefix, expected.ParameterDocComment) + } else { + actualDoc := "" + if activeParam.Documentation != nil { + if activeParam.Documentation.MarkupContent != nil { + actualDoc = activeParam.Documentation.MarkupContent.Value + } else if activeParam.Documentation.String != nil { + actualDoc = *activeParam.Documentation.String + } + } + if actualDoc != expected.ParameterDocComment { + t.Errorf("%sExpected parameter doc comment %q, got %q", prefix, expected.ParameterDocComment, actualDoc) + } + } + } + + // Verify isVariadic (check if any parameter starts with "...") + if expected.IsVariadicSet { + actualIsVariadic := false + if selectedSig.Parameters != nil { + for _, param := range *selectedSig.Parameters { + if param.Label.String != nil && strings.HasPrefix(*param.Label.String, "...") { + actualIsVariadic = true + break + } + } + } + if actualIsVariadic != expected.IsVariadic { + t.Errorf("%sExpected isVariadic=%v, got %v", prefix, expected.IsVariadic, actualIsVariadic) + } + } +} + +// VerifyNoSignatureHelp verifies that no signature help is available at the current position. +func (f *FourslashTest) VerifyNoSignatureHelp(t *testing.T) { + t.Helper() + prefix := f.getCurrentPositionPrefix() + params := &lsproto.SignatureHelpParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) + if result.SignatureHelp != nil && len(result.SignatureHelp.Signatures) > 0 { + t.Errorf("%sExpected no signature help, but got %d signatures", prefix, len(result.SignatureHelp.Signatures)) + } +} + +// VerifyNoSignatureHelpWithContext verifies that no signature help is available at the current position with a given context. +func (f *FourslashTest) VerifyNoSignatureHelpWithContext(t *testing.T, context *lsproto.SignatureHelpContext) { + t.Helper() + prefix := f.getCurrentPositionPrefix() + params := &lsproto.SignatureHelpParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + Context: context, + } + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) + if result.SignatureHelp != nil && len(result.SignatureHelp.Signatures) > 0 { + t.Errorf("%sExpected no signature help, but got %d signatures", prefix, len(result.SignatureHelp.Signatures)) + } +} + +// VerifyNoSignatureHelpForMarkersWithContext verifies that no signature help is available at the given markers with a given context. +func (f *FourslashTest) VerifyNoSignatureHelpForMarkersWithContext(t *testing.T, context *lsproto.SignatureHelpContext, markers ...string) { + t.Helper() + for _, marker := range markers { + f.GoToMarker(t, marker) + f.VerifyNoSignatureHelpWithContext(t, context) + } +} + +// VerifySignatureHelpPresent verifies that signature help is available at the current position with a given context. +func (f *FourslashTest) VerifySignatureHelpPresent(t *testing.T, context *lsproto.SignatureHelpContext) { + t.Helper() + prefix := f.getCurrentPositionPrefix() + params := &lsproto.SignatureHelpParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + Context: context, + } + result := sendRequest(t, f, lsproto.TextDocumentSignatureHelpInfo, params) + if result.SignatureHelp == nil || len(result.SignatureHelp.Signatures) == 0 { + t.Errorf("%sExpected signature help to be present, but got none", prefix) + } +} + +// VerifySignatureHelpPresentForMarkers verifies that signature help is available at the given markers with a given context. +func (f *FourslashTest) VerifySignatureHelpPresentForMarkers(t *testing.T, context *lsproto.SignatureHelpContext, markers ...string) { + t.Helper() + for _, marker := range markers { + f.GoToMarker(t, marker) + f.VerifySignatureHelpPresent(t, context) + } +} + +// VerifyNoSignatureHelpForMarkers verifies that no signature help is available at the given markers. +func (f *FourslashTest) VerifyNoSignatureHelpForMarkers(t *testing.T, markers ...string) { + t.Helper() + for _, marker := range markers { + f.GoToMarker(t, marker) + f.VerifyNoSignatureHelp(t) + } +} + type SignatureHelpCase struct { Context *lsproto.SignatureHelpContext MarkerInput MarkerInput Expected *lsproto.SignatureHelp } -func (f *FourslashTest) VerifySignatureHelp(t *testing.T, signatureHelpCases ...*SignatureHelpCase) { +// VerifySignatureHelpWithCases verifies signature help using detailed SignatureHelpCase structs. +// This is useful for more complex tests that need to verify the full signature help response. +func (f *FourslashTest) VerifySignatureHelpWithCases(t *testing.T, signatureHelpCases ...*SignatureHelpCase) { for _, option := range signatureHelpCases { switch marker := option.MarkerInput.(type) { case string: diff --git a/pkg/fourslash/tests/codeLensFunctionExpressions01_test.go b/pkg/fourslash/tests/codeLensFunctionExpressions01_test.go new file mode 100644 index 000000000..0fc1a9efd --- /dev/null +++ b/pkg/fourslash/tests/codeLensFunctionExpressions01_test.go @@ -0,0 +1,53 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensFunctionExpressions01(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +// @filename: anonymousFunctionExpressions.ts +export let anonFn1 = function () {}; +export const anonFn2 = function () {}; + +let anonFn3 = function () {}; +const anonFn4 = function () {}; + +// @filename: arrowFunctions.ts +export let arrowFn1 = () => {}; +export const arrowFn2 = () => {}; + +let arrowFn3 = () => {}; +const arrowFn4 = () => {}; + +// @filename: namedFunctions.ts +export let namedFn1 = function namedFn1() { + namedFn1(); +} +namedFn1(); + +export const namedFn2 = function namedFn2() { + namedFn2(); +} +namedFn2(); + +let namedFn3 = function namedFn3() {}; +const namedFn4 = function namedFn4() {}; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ReferencesCodeLensEnabled: true, + ReferencesCodeLensShowOnAllFunctions: true, + + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnInterfaceMethods: true, + ImplementationsCodeLensShowOnAllClassMethods: true, + }) +} diff --git a/pkg/fourslash/tests/codeLensFunctionsAndConstants01_test.go b/pkg/fourslash/tests/codeLensFunctionsAndConstants01_test.go new file mode 100644 index 000000000..24cfb3dc2 --- /dev/null +++ b/pkg/fourslash/tests/codeLensFunctionsAndConstants01_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensFunctionsAndConstants01(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +// @module: preserve + +// @filename: ./exports.ts + +let callCount = 0; +export function foo(n: number): void { + callCount++; + if (n > 0) { + foo(n - 1); + } + else { + console.log("function was called " + callCount + " times"); + } +} + +foo(5); + +export const bar = 123; + +// @filename: ./importer.ts +import { foo, bar } from "./exports"; + +foo(5); +console.log(bar); +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ReferencesCodeLensEnabled: true, + ReferencesCodeLensShowOnAllFunctions: true, + + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnInterfaceMethods: true, + ImplementationsCodeLensShowOnAllClassMethods: true, + }) +} diff --git a/pkg/fourslash/tests/codeLensInterface01_test.go b/pkg/fourslash/tests/codeLensInterface01_test.go new file mode 100644 index 000000000..a62991751 --- /dev/null +++ b/pkg/fourslash/tests/codeLensInterface01_test.go @@ -0,0 +1,59 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensInterface01(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +// @module: preserve + +// @filename: ./pointable.ts +export interface Pointable { + getX(): number; + getY(): number; +} + +// @filename: ./classPointable.ts +import { Pointable } from "./pointable"; + +class Point implements Pointable { + getX(): number { + return 0; + } + getY(): number { + return 0; + } +} + +// @filename: ./objectPointable.ts +import { Pointable } from "./pointable"; + +let x = 0; +let y = 0; +const p: Pointable = { + getX(): number { + return x; + }, + getY(): number { + return y; + }, +}; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ReferencesCodeLensEnabled: true, + ReferencesCodeLensShowOnAllFunctions: true, + + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnInterfaceMethods: true, + ImplementationsCodeLensShowOnAllClassMethods: true, + }) +} diff --git a/pkg/fourslash/tests/codeLensOverloads01_test.go b/pkg/fourslash/tests/codeLensOverloads01_test.go new file mode 100644 index 000000000..a90a1c844 --- /dev/null +++ b/pkg/fourslash/tests/codeLensOverloads01_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensOverloads01(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +export function foo(x: number): number; +export function foo(x: string): string; +export function foo(x: string | number): string | number { + return x; +} + +foo(1); + +foo("hello"); + +// This one isn't expected to match any overload, +// but is really just here to test how it affects how code lens. +foo(Math.random() ? 1 : "hello"); +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ReferencesCodeLensEnabled: true, + ReferencesCodeLensShowOnAllFunctions: true, + + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnInterfaceMethods: true, + ImplementationsCodeLensShowOnAllClassMethods: true, + }) +} diff --git a/pkg/fourslash/tests/codeLensShowOnAllClassMethods_test.go b/pkg/fourslash/tests/codeLensShowOnAllClassMethods_test.go new file mode 100644 index 000000000..1835b92b6 --- /dev/null +++ b/pkg/fourslash/tests/codeLensShowOnAllClassMethods_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "fmt" + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensReferencesShowOnAllClassMethods(t *testing.T) { + t.Parallel() + containingTestName := t.Name() + for _, value := range []bool{true, false} { + t.Run(fmt.Sprintf("%s=%v", containingTestName, value), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +export abstract class ABC { + abstract methodA(): void; + methodB(): void {} + #methodC(): void {} + protected methodD(): void {} + private methodE(): void {} + protected abstract methodG(): void; + public methodH(): void {} + + static methodStaticA(): void {} + protected static methodStaticB(): void {} + private static methodStaticC(): void {} + static #methodStaticD(): void {} +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnAllClassMethods: value, + }) + }) + } +} diff --git a/pkg/fourslash/tests/codeLensShowOnAllFunctions_test.go b/pkg/fourslash/tests/codeLensShowOnAllFunctions_test.go new file mode 100644 index 000000000..8d0551c76 --- /dev/null +++ b/pkg/fourslash/tests/codeLensShowOnAllFunctions_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "fmt" + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensReferencesShowOnAllFunctions(t *testing.T) { + t.Parallel() + containingTestName := t.Name() + for _, value := range []bool{true, false} { + t.Run(fmt.Sprintf("%s=%v", containingTestName, value), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +export function f1(): void {} + +function f2(): void {} + +export const f3 = () => {}; + +const f4 = () => {}; + +const f5 = function() {}; +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ReferencesCodeLensEnabled: true, + ReferencesCodeLensShowOnAllFunctions: value, + }) + }) + } +} diff --git a/pkg/fourslash/tests/codeLensShowOnInterfaceMethods_test.go b/pkg/fourslash/tests/codeLensShowOnInterfaceMethods_test.go new file mode 100644 index 000000000..8f95a7d9e --- /dev/null +++ b/pkg/fourslash/tests/codeLensShowOnInterfaceMethods_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "fmt" + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCodeLensReferencesShowOnInterfaceMethods(t *testing.T) { + t.Parallel() + containingTestName := t.Name() + for _, value := range []bool{true, false} { + t.Run(fmt.Sprintf("%s=%v", containingTestName, value), func(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = ` +export interface I { + methodA(): void; +} +export interface I { + methodB(): void; +} + +interface J extends I { + methodB(): void; + methodC(): void; +} + +class C implements J { + methodA(): void {} + methodB(): void {} + methodC(): void {} +} + +class AbstractC implements J { + abstract methodA(): void; + methodB(): void {} + abstract methodC(): void; +} +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{ + ImplementationsCodeLensEnabled: true, + ImplementationsCodeLensShowOnInterfaceMethods: value, + }) + }) + } +} diff --git a/pkg/fourslash/tests/gen/augmentedTypesModule2_test.go b/pkg/fourslash/tests/gen/augmentedTypesModule2_test.go new file mode 100644 index 000000000..830f7e9d7 --- /dev/null +++ b/pkg/fourslash/tests/gen/augmentedTypesModule2_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAugmentedTypesModule2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function /*11*/m2f(x: number) { }; +namespace m2f { export interface I { foo(): void } } +var x: m2f./*1*/ +var /*2*/r = m2f/*3*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "11", "function m2f(x: number): void\nnamespace m2f", "") + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "I", + }, + }, + }) + f.Insert(t, "I.") + f.VerifyCompletions(t, nil, nil) + f.Backspace(t, 1) + f.VerifyQuickInfoAt(t, "2", "var r: (x: number) => void", "") + f.GoToMarker(t, "3") + f.Insert(t, "(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m2f(x: number): void"}) +} diff --git a/pkg/fourslash/tests/gen/augmentedTypesModule3_test.go b/pkg/fourslash/tests/gen/augmentedTypesModule3_test.go new file mode 100644 index 000000000..4e4b96db8 --- /dev/null +++ b/pkg/fourslash/tests/gen/augmentedTypesModule3_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAugmentedTypesModule3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function m2g() { }; +module m2g { export class C { foo(x: number) { } } } +var x: m2g./*1*/; +var /*2*/r = m2g/*3*/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + "C", + }, + }, + }) + f.Insert(t, "C.") + f.VerifyCompletions(t, nil, nil) + f.Backspace(t, 1) + f.VerifyQuickInfoAt(t, "2", "var r: typeof m2g", "") + f.GoToMarker(t, "3") + f.Insert(t, "(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m2g(): void"}) +} diff --git a/pkg/fourslash/tests/gen/augmentedTypesModule6_test.go b/pkg/fourslash/tests/gen/augmentedTypesModule6_test.go new file mode 100644 index 000000000..d4e13aebd --- /dev/null +++ b/pkg/fourslash/tests/gen/augmentedTypesModule6_test.go @@ -0,0 +1,81 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestAugmentedTypesModule6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare class m3f { foo(x: number): void } +module m3f { export interface I { foo(): void } } +var x: m3f./*1*/ +var /*4*/r = new /*2*/m3f(/*3*/); +r./*5*/ +var r2: m3f.I = r; +r2./*6*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "I", + }, + Excludes: []string{ + "foo", + }, + }, + }) + f.Insert(t, "I;") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "m3f", + }, + }, + }) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m3f(): m3f"}) + f.VerifyQuickInfoAt(t, "4", "var r: m3f", "") + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "foo", + }, + }, + }) + f.Insert(t, "foo(1)") + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + "foo", + }, + }, + }) + f.Insert(t, "foo(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(): void"}) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyAccessor_test.go b/pkg/fourslash/tests/gen/callHierarchyAccessor_test.go new file mode 100644 index 000000000..d1c697207 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyAccessor_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyAccessor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + new C().bar; +} + +class C { + get /**/bar() { + return baz(); + } +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyCallExpressionByConstNamedFunctionExpression_test.go b/pkg/fourslash/tests/gen/callHierarchyCallExpressionByConstNamedFunctionExpression_test.go new file mode 100644 index 000000000..9c94ff13d --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyCallExpressionByConstNamedFunctionExpression_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyCallExpressionByConstNamedFunctionExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar(); +} + +const bar = function () { + baz(); +} + +function baz() { +} + +/**/bar()` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyClassPropertyArrowFunction_test.go b/pkg/fourslash/tests/gen/callHierarchyClassPropertyArrowFunction_test.go new file mode 100644 index 000000000..c10a86816 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyClassPropertyArrowFunction_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyClassPropertyArrowFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + caller = () => { + this.callee(); + } + + /**/callee = () => { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock2_test.go b/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock2_test.go new file mode 100644 index 000000000..97f04e13c --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock2_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyClassStaticBlock2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + /**/static { + function foo() { + bar(); + } + + function bar() { + baz(); + quxx(); + baz(); + } + + foo(); + } +} + +function baz() { +} + +function quxx() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock_test.go b/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock_test.go new file mode 100644 index 000000000..3cfc85a70 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyClassStaticBlock_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyClassStaticBlock(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + static { + function foo() { + bar(); + } + + function /**/bar() { + baz(); + quxx(); + baz(); + } + + foo(); + } +} + +function baz() { +} + +function quxx() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyClass_test.go b/pkg/fourslash/tests/gen/callHierarchyClass_test.go new file mode 100644 index 000000000..946fc9029 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyClass_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar(); +} + +function /**/bar() { + new Baz(); +} + +class Baz { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyConstNamedArrowFunction_test.go b/pkg/fourslash/tests/gen/callHierarchyConstNamedArrowFunction_test.go new file mode 100644 index 000000000..b630fd497 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyConstNamedArrowFunction_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyConstNamedArrowFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar(); +} + +const /**/bar = () => { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyConstNamedClassExpression_test.go b/pkg/fourslash/tests/gen/callHierarchyConstNamedClassExpression_test.go new file mode 100644 index 000000000..115c2cdc5 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyConstNamedClassExpression_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyConstNamedClassExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + new Bar(); +} + +const /**/Bar = class { + constructor() { + baz(); + } +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyConstNamedFunctionExpression_test.go b/pkg/fourslash/tests/gen/callHierarchyConstNamedFunctionExpression_test.go new file mode 100644 index 000000000..1484fb644 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyConstNamedFunctionExpression_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyConstNamedFunctionExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar(); +} + +const /**/bar = function () { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyContainerNameServer_test.go b/pkg/fourslash/tests/gen/callHierarchyContainerNameServer_test.go new file mode 100644 index 000000000..1be0a36e3 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyContainerNameServer_test.go @@ -0,0 +1,53 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyContainerNameServer(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function /**/f() {} + +class A { + static sameName() { + f(); + } +} + +class B { + sameName() { + A.sameName(); + } +} + +const Obj = { + get sameName() { + return new B().sameName; + } +}; + +namespace Foo { + function sameName() { + return Obj.sameName; + } + + export class C { + constructor() { + sameName(); + } + } +} + +module Foo.Bar { + const sameName = () => new Foo.C(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyContainerName_test.go b/pkg/fourslash/tests/gen/callHierarchyContainerName_test.go new file mode 100644 index 000000000..5c6c47feb --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyContainerName_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyContainerName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function /**/f() {} + +class A { + static sameName() { + f(); + } +} + +class B { + sameName() { + A.sameName(); + } +} + +const Obj = { + get sameName() { + return new B().sameName; + } +}; + +namespace Foo { + function sameName() { + return Obj.sameName; + } + + export class C { + constructor() { + sameName(); + } + } +} + +module Foo.Bar { + const sameName = () => new Foo.C(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyCrossFile_test.go b/pkg/fourslash/tests/gen/callHierarchyCrossFile_test.go new file mode 100644 index 000000000..1acaef241 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyCrossFile_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyCrossFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: /a.ts +export function /**/createModelReference() {} +// @filename: /b.ts +import { createModelReference } from "./a"; +function openElementsAtEditor() { + createModelReference(); +} +// @filename: /c.ts +import { createModelReference } from "./a"; +function registerDefaultLanguageCommand() { + createModelReference(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyDecorator_test.go b/pkg/fourslash/tests/gen/callHierarchyDecorator_test.go new file mode 100644 index 000000000..aca6afd6c --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyDecorator_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyDecorator(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @experimentalDecorators: true +@bar +class Foo { +} + +function /**/bar() { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyExportDefaultClass_test.go b/pkg/fourslash/tests/gen/callHierarchyExportDefaultClass_test.go new file mode 100644 index 000000000..9b65fcd46 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyExportDefaultClass_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyExportDefaultClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: main.ts +import Bar from "./other"; + +function foo() { + new Bar(); +} +// @filename: other.ts +export /**/default class { + constructor() { + baz(); + } +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyExportDefaultFunction_test.go b/pkg/fourslash/tests/gen/callHierarchyExportDefaultFunction_test.go new file mode 100644 index 000000000..ff92663e5 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyExportDefaultFunction_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyExportDefaultFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: main.ts +import bar from "./other"; + +function foo() { + bar(); +} +// @filename: other.ts +export /**/default function () { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyExportEqualsFunction_test.go b/pkg/fourslash/tests/gen/callHierarchyExportEqualsFunction_test.go new file mode 100644 index 000000000..c8f55be85 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyExportEqualsFunction_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyExportEqualsFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: main.ts +import bar = require("./other"); + +function foo() { + bar(); +} +// @filename: other.ts +export = /**/function () { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFile_test.go b/pkg/fourslash/tests/gen/callHierarchyFile_test.go new file mode 100644 index 000000000..aaca73b06 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFile_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `foo(); +function /**/foo() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity1_test.go b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity1_test.go new file mode 100644 index 000000000..13d5f036a --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity1_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunctionAmbiguity1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: a.d.ts +declare function foo(x?: number): void; +// @filename: b.d.ts +declare function foo(x?: string): void; +declare function foo(x?: boolean): void; +// @filename: main.ts +function bar() { + /**/foo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity2_test.go b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity2_test.go new file mode 100644 index 000000000..29f49a2cd --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity2_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunctionAmbiguity2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: a.d.ts +declare function /**/foo(x?: number): void; +// @filename: b.d.ts +declare function foo(x?: string): void; +declare function foo(x?: boolean): void; +// @filename: main.ts +function bar() { + foo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity3_test.go b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity3_test.go new file mode 100644 index 000000000..709fb4703 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity3_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunctionAmbiguity3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: a.d.ts +declare function foo(x?: number): void; +// @filename: b.d.ts +declare function /**/foo(x?: string): void; +declare function foo(x?: boolean): void; +// @filename: main.ts +function bar() { + foo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity4_test.go b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity4_test.go new file mode 100644 index 000000000..0a45e6ac2 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity4_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunctionAmbiguity4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: a.d.ts +declare function foo(x?: number): void; +// @filename: b.d.ts +declare function foo(x?: string): void; +declare function /**/foo(x?: boolean): void; +// @filename: main.ts +function bar() { + foo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity5_test.go b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity5_test.go new file mode 100644 index 000000000..d79796c80 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunctionAmbiguity5_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunctionAmbiguity5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @filename: a.d.ts +declare function foo(x?: number): void; +// @filename: b.d.ts +declare function foo(x?: string): void; +declare function foo(x?: boolean): void; +// @filename: main.ts +function /**/bar() { + foo(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyFunction_test.go b/pkg/fourslash/tests/gen/callHierarchyFunction_test.go new file mode 100644 index 000000000..f98c62d3b --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyFunction_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar(); +} + +function /**/bar() { + baz(); + quxx(); + baz(); +} + +function baz() { +} + +function quxx() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyInterfaceMethod_test.go b/pkg/fourslash/tests/gen/callHierarchyInterfaceMethod_test.go new file mode 100644 index 000000000..aec31d62a --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyInterfaceMethod_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyInterfaceMethod(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + /**/foo(): void; +} + +const obj: I = { foo() {} }; + +obj.foo();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyJsxElement_test.go b/pkg/fourslash/tests/gen/callHierarchyJsxElement_test.go new file mode 100644 index 000000000..127eed151 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyJsxElement_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyJsxElement(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +// @filename: main.tsx +function foo() { + return ; +} + +function /**/Bar() { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callHierarchyTaggedTemplate_test.go b/pkg/fourslash/tests/gen/callHierarchyTaggedTemplate_test.go new file mode 100644 index 000000000..49ac1afb8 --- /dev/null +++ b/pkg/fourslash/tests/gen/callHierarchyTaggedTemplate_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallHierarchyTaggedTemplate(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + bar` + "`" + `a${1}b` + "`" + `; +} + +function /**/bar(array: TemplateStringsArray, ...args: any[]) { + baz(); +} + +function baz() { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifyBaselineCallHierarchy(t) +} diff --git a/pkg/fourslash/tests/gen/callSignatureHelp_test.go b/pkg/fourslash/tests/gen/callSignatureHelp_test.go new file mode 100644 index 000000000..1de8f988a --- /dev/null +++ b/pkg/fourslash/tests/gen/callSignatureHelp_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCallSignatureHelp(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface C { + (): number; +} +var c: C; +c(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "c(): number"}) +} diff --git a/pkg/fourslash/tests/gen/calledUnionsOfDissimilarTyeshaveGoodDisplay_test.go b/pkg/fourslash/tests/gen/calledUnionsOfDissimilarTyeshaveGoodDisplay_test.go new file mode 100644 index 000000000..19419b5af --- /dev/null +++ b/pkg/fourslash/tests/gen/calledUnionsOfDissimilarTyeshaveGoodDisplay_test.go @@ -0,0 +1,67 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCalledUnionsOfDissimilarTyeshaveGoodDisplay(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare const callableThing1: + | ((o1: {x: number}) => void) + | ((o1: {y: number}) => void) + ; + +callableThing1(/*1*/); + +declare const callableThing2: + | ((o1: {x: number}) => void) + | ((o2: {y: number}) => void) + ; + +callableThing2(/*2*/); + +declare const callableThing3: + | ((o1: {x: number}) => void) + | ((o2: {y: number}) => void) + | ((o3: {z: number}) => void) + | ((o4: {u: number}) => void) + | ((o5: {v: number}) => void) + ; + +callableThing3(/*3*/); + +declare const callableThing4: + | ((o1: {x: number}) => void) + | ((o2: {y: number}) => void) + | ((o3: {z: number}) => void) + | ((o4: {u: number}) => void) + | ((o5: {v: number}) => void) + | ((o6: {w: number}) => void) + ; + +callableThing4(/*4*/); + +declare const callableThing5: + | ((a1: U) => void) + | (() => void) + ; + +callableThing5(/*5*/1) +` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callableThing1(o1: { x: number; } & { y: number; }): void"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callableThing2(arg0: { x: number; } & { y: number; }): void"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callableThing3(arg0: { x: number; } & { y: number; } & { z: number; } & { u: number; } & { v: number; }): void"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callableThing4(arg0: { x: number; } & { y: number; } & { z: number; } & { u: number; } & { v: number; } & { w: number; }): void"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callableThing5(a1: number): void"}) +} diff --git a/pkg/fourslash/tests/gen/classExtendsInterfaceSigHelp1_test.go b/pkg/fourslash/tests/gen/classExtendsInterfaceSigHelp1_test.go new file mode 100644 index 000000000..ee88cb513 --- /dev/null +++ b/pkg/fourslash/tests/gen/classExtendsInterfaceSigHelp1_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestClassExtendsInterfaceSigHelp1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + public foo(x: string); + public foo(x: number); + public foo(x: any) { return x; } +} +interface I extends C { + other(x: any): any; +} +var i: I; +i.foo(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterSpan: "x: string", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/commentsExternalModulesFourslash_test.go b/pkg/fourslash/tests/gen/commentsExternalModulesFourslash_test.go new file mode 100644 index 000000000..1adedf8af --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsExternalModulesFourslash_test.go @@ -0,0 +1,299 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsExternalModulesFourslash(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: commentsExternalModules_file0.ts +/** Namespace comment*/ +export namespace m/*1*/1 { + /** b's comment*/ + export var b: number; + /** foo's comment*/ + function foo() { + return /*2*/b; + } + /** m2 comments*/ + export namespace m2 { + /** class comment;*/ + export class c { + }; + /** i*/ + export var i = new c(); + } + /** exported function*/ + export function fooExport() { + return f/*3q*/oo(/*3*/); + } +} +/*4*/m1./*5*/fooEx/*6q*/port(/*6*/); +var my/*7*/var = new m1.m2./*8*/c(); +// @Filename: commentsExternalModules_file1.ts +/**This is on import declaration*/ +import ex/*9*/tMod = require("./commentsExternalModules_file0"); +/*10*/extMod./*11*/m1./*12*/fooExp/*13q*/ort(/*13*/); +var new/*14*/Var = new extMod.m1.m2./*15*/c();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToFile(t, "commentsExternalModules_file0.ts") + f.VerifyQuickInfoAt(t, "1", "namespace m1", "Namespace comment") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Detail: PtrTo("var b: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "b's comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("function foo(): number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "foo's comment", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foo's comment"}) + f.VerifyQuickInfoAt(t, "3q", "function foo(): number", "foo's comment") + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "m1", + Detail: PtrTo("namespace m1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "Namespace comment", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "5", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Detail: PtrTo("var m1.b: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "b's comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "fooExport", + Detail: PtrTo("function m1.fooExport(): number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "exported function", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "m2", + Detail: PtrTo("namespace m1.m2"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "m2 comments", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "exported function"}) + f.VerifyQuickInfoAt(t, "6q", "function m1.fooExport(): number", "exported function") + f.VerifyQuickInfoAt(t, "7", "var myvar: m1.m2.c", "") + f.VerifyCompletions(t, "8", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c", + Detail: PtrTo("constructor m1.m2.c(): m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "class comment;", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i", + Detail: PtrTo("var m1.m2.i: m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i", + }, + }, + }, + }, + }, + }) + f.GoToFile(t, "commentsExternalModules_file1.ts") + f.VerifyQuickInfoAt(t, "9", "import extMod = require(\"./commentsExternalModules_file0\")", "This is on import declaration") + f.VerifyCompletions(t, "10", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "extMod", + Detail: PtrTo("import extMod = require(\"./commentsExternalModules_file0\")"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "This is on import declaration", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "11", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "m1", + Detail: PtrTo("namespace extMod.m1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "Namespace comment", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "12", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Detail: PtrTo("var extMod.m1.b: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "b's comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "fooExport", + Detail: PtrTo("function extMod.m1.fooExport(): number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "exported function", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "m2", + Detail: PtrTo("namespace extMod.m1.m2"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "m2 comments", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "13") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "exported function"}) + f.VerifyQuickInfoAt(t, "13q", "function extMod.m1.fooExport(): number", "exported function") + f.VerifyQuickInfoAt(t, "14", "var newVar: extMod.m1.m2.c", "") + f.VerifyCompletions(t, "15", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c", + Detail: PtrTo("constructor extMod.m1.m2.c(): extMod.m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "class comment;", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i", + Detail: PtrTo("var extMod.m1.m2.i: extMod.m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i", + }, + }, + }, + }, + }, + }) +} diff --git a/pkg/fourslash/tests/gen/commentsImportDeclaration_test.go b/pkg/fourslash/tests/gen/commentsImportDeclaration_test.go new file mode 100644 index 000000000..52126290f --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsImportDeclaration_test.go @@ -0,0 +1,138 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsImportDeclaration(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: commentsImportDeclaration_file0.ts +/** NamespaceComment*/ +export namespace m/*2*/1 { + /** b's comment*/ + export var b: number; + /** m2 comments*/ + export namespace m2 { + /** class comment;*/ + export class c { + }; + /** i*/ + export var i: c;; + } + /** exported function*/ + export function fooExport(): number; +} +// @Filename: commentsImportDeclaration_file1.ts +/// +/** Import declaration*/ +import /*3*/extMod = require("./commentsImportDeclaration_file0/*4*/"); +extMod./*6*/m1./*7*/fooEx/*8q*/port(/*8*/); +var new/*9*/Var = new extMod.m1.m2./*10*/c();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "2", "namespace m1", "NamespaceComment") + f.VerifyQuickInfoAt(t, "3", "import extMod = require(\"./commentsImportDeclaration_file0\")", "Import declaration") + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "m1", + Detail: PtrTo("namespace extMod.m1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "NamespaceComment", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "7", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "b", + Detail: PtrTo("var extMod.m1.b: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "b's comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "fooExport", + Detail: PtrTo("function extMod.m1.fooExport(): number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "exported function", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "m2", + Detail: PtrTo("namespace extMod.m1.m2"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "m2 comments", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "exported function"}) + f.VerifyQuickInfoAt(t, "8q", "function extMod.m1.fooExport(): number", "exported function") + f.VerifyQuickInfoAt(t, "9", "var newVar: extMod.m1.m2.c", "") + f.VerifyCompletions(t, "10", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c", + Detail: PtrTo("constructor extMod.m1.m2.c(): extMod.m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "class comment;", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i", + Detail: PtrTo("var extMod.m1.m2.i: extMod.m1.m2.c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i", + }, + }, + }, + }, + }, + }) +} diff --git a/pkg/fourslash/tests/gen/commentsInheritanceFourslash_test.go b/pkg/fourslash/tests/gen/commentsInheritanceFourslash_test.go new file mode 100644 index 000000000..dba3af273 --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsInheritanceFourslash_test.go @@ -0,0 +1,1305 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsInheritanceFourslash(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** i1 is interface with properties*/ +interface i1 { + /** i1_p1*/ + i1_p1: number; + /** i1_f1*/ + i1_f1(): void; + /** i1_l1*/ + i1_l1: () => void; + i1_nc_p1: number; + i1_nc_f1(): void; + i1_nc_l1: () => void; + p1: number; + f1(): void; + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +class c1 implements i1 { + public i1_p1: number; + public i1_f1() { + } + public i1_l1: () => void; + public i1_nc_p1: number; + public i1_nc_f1() { + } + public i1_nc_l1: () => void; + /** c1_p1*/ + public p1: number; + /** c1_f1*/ + public f1() { + } + /** c1_l1*/ + public l1: () => void; + /** c1_nc_p1*/ + public nc_p1: number; + /** c1_nc_f1*/ + public nc_f1() { + } + /** c1_nc_l1*/ + public nc_l1: () => void; +} +var i1/*1iq*/_i: /*16i*/i1; +i1_i./*1*/i/*2q*/1_f1(/*2*/); +i1_i.i1_n/*3q*/c_f1(/*3*/); +i1_i.f/*4q*/1(/*4*/); +i1_i.nc/*5q*/_f1(/*5*/); +i1_i.i1/*l2q*/_l1(/*l2*/); +i1_i.i1_/*l3q*/nc_l1(/*l3*/); +i1_i.l/*l4q*/1(/*l4*/); +i1_i.nc/*l5q*/_l1(/*l5*/); +var c1/*6iq*/_i = new c1(); +c1_i./*6*/i1/*7q*/_f1(/*7*/); +c1_i.i1_nc/*8q*/_f1(/*8*/); +c1_i.f/*9q*/1(/*9*/); +c1_i.nc/*10q*/_f1(/*10*/); +c1_i.i1/*l7q*/_l1(/*l7*/); +c1_i.i1_n/*l8q*/c_l1(/*l8*/); +c1_i.l/*l9q*/1(/*l9*/); +c1_i.nc/*l10q*/_l1(/*l10*/); +// assign to interface +i1_i = c1_i; +i1_i./*11*/i1/*12q*/_f1(/*12*/); +i1_i.i1_nc/*13q*/_f1(/*13*/); +i1_i.f/*14q*/1(/*14*/); +i1_i.nc/*15q*/_f1(/*15*/); +i1_i.i1/*l12q*/_l1(/*l12*/); +i1_i.i1/*l13q*/_nc_l1(/*l13*/); +i1_i.l/*l14q*/1(/*l14*/); +i1_i.nc/*l15q*/_l1(/*l15*/); +/*16*/ +class c2 { + /** c2 c2_p1*/ + public c2_p1: number; + /** c2 c2_f1*/ + public c2_f1() { + } + /** c2 c2_prop*/ + public get c2_prop() { + return 10; + } + public c2_nc_p1: number; + public c2_nc_f1() { + } + public get c2_nc_prop() { + return 10; + } + /** c2 p1*/ + public p1: number; + /** c2 f1*/ + public f1() { + } + /** c2 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + public nc_f1() { + } + public get nc_prop() { + return 10; + } + /** c2 constructor*/ + constr/*55*/uctor(a: number) { + this.c2_p1 = a; + } +} +class c3 extends c2 { + cons/*56*/tructor() { + su/*18sq*/per(10); + this.p1 = s/*18spropq*/uper./*18spropProp*/c2_p1; + } + /** c3 p1*/ + public p1: number; + /** c3 f1*/ + public f1() { + } + /** c3 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + public nc_f1() { + } + public get nc_prop() { + return 10; + } +} +var c/*17iq*/2_i = new c/*17q*/2(/*17*/10); +var c/*18iq*/3_i = new c/*18q*/3(/*18*/); +c2_i./*19*/c2/*20q*/_f1(/*20*/); +c2_i.c2_nc/*21q*/_f1(/*21*/); +c2_i.f/*22q*/1(/*22*/); +c2_i.nc/*23q*/_f1(/*23*/); +c3_i./*24*/c2/*25q*/_f1(/*25*/); +c3_i.c2_nc/*26q*/_f1(/*26*/); +c3_i.f/*27q*/1(/*27*/); +c3_i.nc/*28q*/_f1(/*28*/); +// assign +c2_i = c3_i; +c2_i./*29*/c2/*30q*/_f1(/*30*/); +c2_i.c2_nc_/*31q*/f1(/*31*/); +c2_i.f/*32q*/1(/*32*/); +c2_i.nc/*33q*/_f1(/*33*/); +class c4 extends c2 { +} +var c4/*34iq*/_i = new c/*34q*/4(/*34*/10); +/*35*/ +interface i2 { + /** i2_p1*/ + i2_p1: number; + /** i2_f1*/ + i2_f1(): void; + /** i2_l1*/ + i2_l1: () => void; + i2_nc_p1: number; + i2_nc_f1(): void; + i2_nc_l1: () => void; + /** i2 p1*/ + p1: number; + /** i2 f1*/ + f1(): void; + /** i2 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +interface i3 extends i2 { + /** i3 p1*/ + p1: number; + /** i3 f1*/ + f1(): void; + /** i3 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +var i2/*36iq*/_i: /*51i*/i2; +var i3/*37iq*/_i: i3; +i2_i./*36*/i2/*37q*/_f1(/*37*/); +i2_i.i2_n/*38q*/c_f1(/*38*/); +i2_i.f/*39q*/1(/*39*/); +i2_i.nc/*40q*/_f1(/*40*/); +i2_i.i2_/*l37q*/l1(/*l37*/); +i2_i.i2_nc/*l38q*/_l1(/*l38*/); +i2_i.l/*l39q*/1(/*l39*/); +i2_i.nc_/*l40q*/l1(/*l40*/); +i3_i./*41*/i2_/*42q*/f1(/*42*/); +i3_i.i2_nc/*43q*/_f1(/*43*/); +i3_i.f/*44q*/1(/*44*/); +i3_i.nc_/*45q*/f1(/*45*/); +i3_i.i2_/*l42q*/l1(/*l42*/); +i3_i.i2_nc/*l43q*/_l1(/*l43*/); +i3_i.l/*l44q*/1(/*l44*/); +i3_i.nc_/*l45q*/l1(/*l45*/); +// assign to interface +i2_i = i3_i; +i2_i./*46*/i2/*47q*/_f1(/*47*/); +i2_i.i2_nc_/*48q*/f1(/*48*/); +i2_i.f/*49q*/1(/*49*/); +i2_i.nc/*50q*/_f1(/*50*/); +i2_i.i2_/*l47q*/l1(/*l47*/); +i2_i.i2_nc/*l48q*/_l1(/*l48*/); +i2_i.l/*l49q*/1(/*l49*/); +i2_i.nc_/*l50q*/l1(/*l50*/); +/*51*/ +/**c5 class*/ +class c5 { + public b: number; +} +class c6 extends c5 { + public d; + const/*57*/ructor() { + /*52*/super(); + this.d = /*53*/super./*54*/b; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyCompletions(t, []string{"1", "11"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_p1", + Detail: PtrTo("(property) i1.i1_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_f1", + Detail: PtrTo("(method) i1.i1_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_l1", + Detail: PtrTo("(property) i1.i1_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_nc_p1", + Detail: PtrTo("(property) i1.i1_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_f1", + Detail: PtrTo("(method) i1.i1_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_l1", + Detail: PtrTo("(property) i1.i1_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) i1.p1: number"), + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) i1.f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) i1.l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) i1.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) i1.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) i1.nc_l1: () => void"), + }, + }, + }, + }) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i1_f1"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "1iq", "var i1_i: i1", "") + f.VerifyQuickInfoAt(t, "2q", "(method) i1.i1_f1(): void", "i1_f1") + f.VerifyQuickInfoAt(t, "3q", "(method) i1.i1_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "4q", "(method) i1.f1(): void", "") + f.VerifyQuickInfoAt(t, "5q", "(method) i1.nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "l2q", "(property) i1.i1_l1: () => void", "i1_l1") + f.VerifyQuickInfoAt(t, "l3q", "(property) i1.i1_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l4q", "(property) i1.l1: () => void", "") + f.VerifyQuickInfoAt(t, "l5q", "(property) i1.nc_l1: () => void", "") + f.VerifyCompletions(t, "6", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_p1", + Detail: PtrTo("(property) c1.i1_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_f1", + Detail: PtrTo("(method) c1.i1_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_l1", + Detail: PtrTo("(property) c1.i1_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_nc_p1", + Detail: PtrTo("(property) c1.i1_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_f1", + Detail: PtrTo("(method) c1.i1_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_l1", + Detail: PtrTo("(property) c1.i1_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) c1.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) c1.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) c1.l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) c1.nc_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_nc_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) c1.nc_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_nc_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) c1.nc_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c1_nc_l1", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i1_f1"}) + f.GoToMarker(t, "9") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c1_f1"}) + f.GoToMarker(t, "10") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c1_nc_f1"}) + f.GoToMarker(t, "l9") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c1_l1"}) + f.GoToMarker(t, "l10") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c1_nc_l1"}) + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "6iq", "var c1_i: c1", "") + f.VerifyQuickInfoAt(t, "7q", "(method) c1.i1_f1(): void", "i1_f1") + f.VerifyQuickInfoAt(t, "8q", "(method) c1.i1_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "9q", "(method) c1.f1(): void", "c1_f1") + f.VerifyQuickInfoAt(t, "10q", "(method) c1.nc_f1(): void", "c1_nc_f1") + f.VerifyQuickInfoAt(t, "l7q", "(property) c1.i1_l1: () => void", "i1_l1") + f.VerifyQuickInfoAt(t, "l8q", "(property) c1.i1_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l9q", "(property) c1.l1: () => void", "c1_l1") + f.VerifyQuickInfoAt(t, "l10q", "(property) c1.nc_l1: () => void", "c1_nc_l1") + f.VerifyCompletions(t, "11", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_p1", + Detail: PtrTo("(property) i1.i1_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_f1", + Detail: PtrTo("(method) i1.i1_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_l1", + Detail: PtrTo("(property) i1.i1_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i1_nc_p1", + Detail: PtrTo("(property) i1.i1_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_f1", + Detail: PtrTo("(method) i1.i1_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i1_nc_l1", + Detail: PtrTo("(property) i1.i1_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) i1.p1: number"), + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) i1.f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) i1.l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) i1.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) i1.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) i1.nc_l1: () => void"), + }, + }, + }, + }) + f.GoToMarker(t, "12") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i1_f1"}) + f.GoToMarker(t, "13") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "14") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "15") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l12") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l13") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l14") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l15") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "12q", "(method) i1.i1_f1(): void", "i1_f1") + f.VerifyQuickInfoAt(t, "13q", "(method) i1.i1_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "14q", "(method) i1.f1(): void", "") + f.VerifyQuickInfoAt(t, "15q", "(method) i1.nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "l12q", "(property) i1.i1_l1: () => void", "i1_l1") + f.VerifyQuickInfoAt(t, "l13q", "(property) i1.i1_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l14q", "(property) i1.l1: () => void", "") + f.VerifyQuickInfoAt(t, "l15q", "(property) i1.nc_l1: () => void", "") + f.VerifyCompletions(t, "16", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_i", + Detail: PtrTo("var i1_i: i1"), + }, + &lsproto.CompletionItem{ + Label: "c1", + Detail: PtrTo("class c1"), + }, + &lsproto.CompletionItem{ + Label: "c1_i", + Detail: PtrTo("var c1_i: c1"), + }, + }, + Excludes: []string{ + "i1", + }, + }, + }) + f.VerifyCompletions(t, "16i", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1", + Detail: PtrTo("interface i1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i1 is interface with properties", + }, + }, + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "17iq", "var c2_i: c2", "") + f.VerifyQuickInfoAt(t, "18iq", "var c3_i: c3", "") + f.GoToMarker(t, "17") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 constructor"}) + f.GoToMarker(t, "18") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "18sq", "constructor c2(a: number): c2", "c2 constructor") + f.VerifyQuickInfoAt(t, "18spropq", "class c2", "") + f.VerifyQuickInfoAt(t, "18spropProp", "(property) c2.c2_p1: number", "c2 c2_p1") + f.VerifyQuickInfoAt(t, "17q", "constructor c2(a: number): c2", "c2 constructor") + f.VerifyQuickInfoAt(t, "18q", "constructor c3(): c3", "") + f.VerifyCompletions(t, []string{"19", "29"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c2_p1", + Detail: PtrTo("(property) c2.c2_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_f1", + Detail: PtrTo("(method) c2.c2_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_prop", + Detail: PtrTo("(property) c2.c2_prop: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_prop", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_nc_p1", + Detail: PtrTo("(property) c2.c2_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "c2_nc_f1", + Detail: PtrTo("(method) c2.c2_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "c2_nc_prop", + Detail: PtrTo("(property) c2.c2_nc_prop: number"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) c2.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) c2.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "prop", + Detail: PtrTo("(property) c2.prop: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 prop", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) c2.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) c2.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_prop", + Detail: PtrTo("(property) c2.nc_prop: number"), + }, + }, + }, + }) + f.GoToMarker(t, "20") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 c2_f1"}) + f.GoToMarker(t, "22") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 f1"}) + f.GoToMarker(t, "21") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "23") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "20q", "(method) c2.c2_f1(): void", "c2 c2_f1") + f.VerifyQuickInfoAt(t, "21q", "(method) c2.c2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "22q", "(method) c2.f1(): void", "c2 f1") + f.VerifyQuickInfoAt(t, "23q", "(method) c2.nc_f1(): void", "") + f.VerifyCompletions(t, "24", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c2_p1", + Detail: PtrTo("(property) c2.c2_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_f1", + Detail: PtrTo("(method) c2.c2_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_prop", + Detail: PtrTo("(property) c2.c2_prop: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c2 c2_prop", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "c2_nc_p1", + Detail: PtrTo("(property) c2.c2_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "c2_nc_f1", + Detail: PtrTo("(method) c2.c2_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "c2_nc_prop", + Detail: PtrTo("(property) c2.c2_nc_prop: number"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) c3.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c3 p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) c3.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c3 f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "prop", + Detail: PtrTo("(property) c3.prop: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "c3 prop", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) c3.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) c3.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_prop", + Detail: PtrTo("(property) c3.nc_prop: number"), + }, + }, + }, + }) + f.GoToMarker(t, "25") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 c2_f1"}) + f.GoToMarker(t, "27") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c3 f1"}) + f.GoToMarker(t, "26") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "28") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "25q", "(method) c2.c2_f1(): void", "c2 c2_f1") + f.VerifyQuickInfoAt(t, "26q", "(method) c2.c2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "27q", "(method) c3.f1(): void", "c3 f1") + f.VerifyQuickInfoAt(t, "28q", "(method) c3.nc_f1(): void", "") + f.GoToMarker(t, "30") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 c2_f1"}) + f.GoToMarker(t, "32") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 f1"}) + f.GoToMarker(t, "31") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "33") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "30q", "(method) c2.c2_f1(): void", "c2 c2_f1") + f.VerifyQuickInfoAt(t, "31q", "(method) c2.c2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "32q", "(method) c2.f1(): void", "c2 f1") + f.VerifyQuickInfoAt(t, "33q", "(method) c2.nc_f1(): void", "") + f.GoToMarker(t, "34") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 constructor"}) + f.VerifyQuickInfoAt(t, "34iq", "var c4_i: c4", "") + f.VerifyQuickInfoAt(t, "34q", "constructor c4(a: number): c4", "c2 constructor") + f.VerifyCompletions(t, "35", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c2", + Detail: PtrTo("class c2"), + }, + &lsproto.CompletionItem{ + Label: "c2_i", + Detail: PtrTo("var c2_i: c2"), + }, + &lsproto.CompletionItem{ + Label: "c3", + Detail: PtrTo("class c3"), + }, + &lsproto.CompletionItem{ + Label: "c3_i", + Detail: PtrTo("var c3_i: c3"), + }, + &lsproto.CompletionItem{ + Label: "c4", + Detail: PtrTo("class c4"), + }, + &lsproto.CompletionItem{ + Label: "c4_i", + Detail: PtrTo("var c4_i: c4"), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"36", "46"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i2_p1", + Detail: PtrTo("(property) i2.i2_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_f1", + Detail: PtrTo("(method) i2.i2_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_l1", + Detail: PtrTo("(property) i2.i2_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_nc_p1", + Detail: PtrTo("(property) i2.i2_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_f1", + Detail: PtrTo("(method) i2.i2_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_l1", + Detail: PtrTo("(property) i2.i2_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) i2.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) i2.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) i2.l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) i2.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) i2.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) i2.nc_l1: () => void"), + }, + }, + }, + }) + f.GoToMarker(t, "37") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i2_f1"}) + f.GoToMarker(t, "39") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i2 f1"}) + f.GoToMarker(t, "38") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "40") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l37") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l37") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l39") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l40") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "36iq", "var i2_i: i2", "") + f.VerifyQuickInfoAt(t, "37iq", "var i3_i: i3", "") + f.VerifyQuickInfoAt(t, "37q", "(method) i2.i2_f1(): void", "i2_f1") + f.VerifyQuickInfoAt(t, "38q", "(method) i2.i2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "39q", "(method) i2.f1(): void", "i2 f1") + f.VerifyQuickInfoAt(t, "40q", "(method) i2.nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "l37q", "(property) i2.i2_l1: () => void", "i2_l1") + f.VerifyQuickInfoAt(t, "l38q", "(property) i2.i2_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l39q", "(property) i2.l1: () => void", "i2 l1") + f.VerifyQuickInfoAt(t, "l40q", "(property) i2.nc_l1: () => void", "") + f.VerifyCompletions(t, "41", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i2_p1", + Detail: PtrTo("(property) i2.i2_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_f1", + Detail: PtrTo("(method) i2.i2_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_l1", + Detail: PtrTo("(property) i2.i2_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_nc_p1", + Detail: PtrTo("(property) i2.i2_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_f1", + Detail: PtrTo("(method) i2.i2_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_l1", + Detail: PtrTo("(property) i2.i2_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) i3.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i3 p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) i3.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i3 f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) i3.l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i3 l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) i3.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) i3.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) i3.nc_l1: () => void"), + }, + }, + }, + }) + f.GoToMarker(t, "42") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i2_f1"}) + f.GoToMarker(t, "44") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i3 f1"}) + f.GoToMarker(t, "43") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "45") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l42") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l43") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l44") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l45") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "42q", "(method) i2.i2_f1(): void", "i2_f1") + f.VerifyQuickInfoAt(t, "43q", "(method) i2.i2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "44q", "(method) i3.f1(): void", "i3 f1") + f.VerifyQuickInfoAt(t, "45q", "(method) i3.nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "l42q", "(property) i2.i2_l1: () => void", "i2_l1") + f.VerifyQuickInfoAt(t, "l43q", "(property) i2.i2_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l44q", "(property) i3.l1: () => void", "i3 l1") + f.VerifyQuickInfoAt(t, "l45q", "(property) i3.nc_l1: () => void", "") + f.VerifyCompletions(t, "46", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i2_p1", + Detail: PtrTo("(property) i2.i2_p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_f1", + Detail: PtrTo("(method) i2.i2_f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_l1", + Detail: PtrTo("(property) i2.i2_l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2_l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_nc_p1", + Detail: PtrTo("(property) i2.i2_nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_f1", + Detail: PtrTo("(method) i2.i2_nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "i2_nc_l1", + Detail: PtrTo("(property) i2.i2_nc_l1: () => void"), + }, + &lsproto.CompletionItem{ + Label: "p1", + Detail: PtrTo("(property) i2.p1: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 p1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("(method) i2.f1(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 f1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "l1", + Detail: PtrTo("(property) i2.l1: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i2 l1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_p1", + Detail: PtrTo("(property) i2.nc_p1: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_f1", + Detail: PtrTo("(method) i2.nc_f1(): void"), + }, + &lsproto.CompletionItem{ + Label: "nc_l1", + Detail: PtrTo("(property) i2.nc_l1: () => void"), + }, + }, + }, + }) + f.GoToMarker(t, "47") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i2_f1"}) + f.GoToMarker(t, "49") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "i2 f1"}) + f.GoToMarker(t, "48") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l47") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l48") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l49") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.GoToMarker(t, "l50") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "47q", "(method) i2.i2_f1(): void", "i2_f1") + f.VerifyQuickInfoAt(t, "48q", "(method) i2.i2_nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "49q", "(method) i2.f1(): void", "i2 f1") + f.VerifyQuickInfoAt(t, "50q", "(method) i2.nc_f1(): void", "") + f.VerifyQuickInfoAt(t, "l47q", "(property) i2.i2_l1: () => void", "i2_l1") + f.VerifyQuickInfoAt(t, "l48q", "(property) i2.i2_nc_l1: () => void", "") + f.VerifyQuickInfoAt(t, "l49q", "(property) i2.l1: () => void", "i2 l1") + f.VerifyQuickInfoAt(t, "l40q", "(property) i2.nc_l1: () => void", "") + f.VerifyCompletions(t, "51", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i2_i", + Detail: PtrTo("var i2_i: i2"), + }, + &lsproto.CompletionItem{ + Label: "i3_i", + Detail: PtrTo("var i3_i: i3"), + }, + }, + Excludes: []string{ + "i2", + "i3", + }, + }, + }) + f.VerifyCompletions(t, "51i", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i2", + Detail: PtrTo("interface i2"), + }, + &lsproto.CompletionItem{ + Label: "i3", + Detail: PtrTo("interface i3"), + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "52", "constructor c5(): c5", "c5 class") + f.VerifyQuickInfoAt(t, "53", "class c5", "c5 class") + f.VerifyQuickInfoAt(t, "54", "(property) c5.b: number", "") + f.VerifyQuickInfoAt(t, "55", "constructor c2(a: number): c2", "c2 constructor") + f.VerifyQuickInfoAt(t, "56", "constructor c3(): c3", "") + f.VerifyQuickInfoAt(t, "57", "constructor c6(): c6", "") +} diff --git a/pkg/fourslash/tests/gen/commentsInterfaceFourslash_test.go b/pkg/fourslash/tests/gen/commentsInterfaceFourslash_test.go new file mode 100644 index 000000000..976d9c4dc --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsInterfaceFourslash_test.go @@ -0,0 +1,417 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsInterfaceFourslash(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** this is interface 1*/ +interface i/*1*/1 { +} +var i1/*2*/_i: i1; +interface nc_/*3*/i1 { +} +var nc_/*4*/i1_i: nc_i1; +/** this is interface 2 with members*/ +interface i/*5*/2 { + /** this is x*/ + x: number; + /** this is foo*/ + foo: (/**param help*/b: number) => string; + /** this is indexer*/ + [/**string param*/i: string]: number; + /**new method*/ + new (/** param*/i: i1); + nc_x: number; + nc_foo: (b: number) => string; + [i: number]: number; + /** this is call signature*/ + (/**paramhelp a*/a: number,/**paramhelp b*/ b: number) : number; + /** this is fnfoo*/ + fnfoo(/**param help*/b: number): string; + nc_fnfoo(b: number): string; +} +var i2/*6*/_i: /*34i*/i2; +var i2_i/*7*/_x = i2_i./*8*/x; +var i2_i/*9*/_foo = i2_i.f/*10*/oo; +var i2_i_f/*11*/oo_r = i2_i.f/*12q*/oo(/*12*/30); +var i2_i_i2_/*13*/si = i2/*13q*/_i["hello"]; +var i2_i_i2/*14*/_ii = i2/*14q*/_i[30]; +var i2_/*15*/i_n = new i2/*16q*/_i(/*16*/i1_i); +var i2_i/*17*/_nc_x = i2_i.n/*18*/c_x; +var i2_i_/*19*/nc_foo = i2_i.n/*20*/c_foo; +var i2_i_nc_f/*21*/oo_r = i2_i.nc/*22q*/_foo(/*22*/30); +var i2/*23*/_i_r = i2/*24q*/_i(/*24*/10, /*25*/20); +var i2_i/*26*/_fnfoo = i2_i.fn/*27*/foo; +var i2_i_/*28*/fnfoo_r = i2_i.fn/*29q*/foo(/*29*/10); +var i2_i/*30*/_nc_fnfoo = i2_i.nc_fn/*31*/foo; +var i2_i_nc_/*32*/fnfoo_r = i2_i.nc/*33q*/_fnfoo(/*33*/10); +/*34*/ +interface i3 { + /** Comment i3 x*/ + x: number; + /** Function i3 f*/ + f(/**number parameter*/a: number): string; + /** i3 l*/ + l: (/**comment i3 l b*/b: number) => string; + nc_x: number; + nc_f(a: number): string; + nc_l: (b: number) => string; +} +var i3_i: i3; +i3_i = { + /*35*/f: /**own f*/ (/**i3_i a*/a: number) => "Hello" + /*36*/a, + l: this./*37*/f, + /** own x*/ + x: this.f(/*38*/10), + nc_x: this.l(/*39*/this.x), + nc_f: this.f, + nc_l: this.l +}; +/*40*/i/*40q*/3_i./*41*/f(/*42*/10); +i3_i./*43q*/l(/*43*/10); +i3_i.nc_/*44q*/f(/*44*/10); +i3_i.nc/*45q*/_l(/*45*/10);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "interface i1", "this is interface 1") + f.VerifyQuickInfoAt(t, "2", "var i1_i: i1", "") + f.VerifyQuickInfoAt(t, "3", "interface nc_i1", "") + f.VerifyQuickInfoAt(t, "4", "var nc_i1_i: nc_i1", "") + f.VerifyQuickInfoAt(t, "5", "interface i2", "this is interface 2 with members") + f.VerifyQuickInfoAt(t, "6", "var i2_i: i2", "") + f.VerifyQuickInfoAt(t, "7", "var i2_i_x: number", "") + f.VerifyQuickInfoAt(t, "8", "(property) i2.x: number", "this is x") + f.VerifyCompletions(t, "8", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: CompletionFunctionMembersWithPrototypePlus( + []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Detail: PtrTo("(property) i2.x: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is x", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("(property) i2.foo: (b: number) => string"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is foo", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_x", + Detail: PtrTo("(property) i2.nc_x: number"), + }, + &lsproto.CompletionItem{ + Label: "nc_foo", + Detail: PtrTo("(property) i2.nc_foo: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "fnfoo", + Detail: PtrTo("(method) i2.fnfoo(b: number): string"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is fnfoo", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_fnfoo", + Detail: PtrTo("(method) i2.nc_fnfoo(b: number): string"), + }, + }), + }, + }) + f.VerifyQuickInfoAt(t, "9", "var i2_i_foo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "10", "(property) i2.foo: (b: number) => string", "this is foo") + f.VerifyQuickInfoAt(t, "11", "var i2_i_foo_r: string", "") + f.GoToMarker(t, "12") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "", ParameterDocComment: "param help"}) + f.VerifyQuickInfoAt(t, "12q", "(property) i2.foo: (b: number) => string", "this is foo") + f.VerifyQuickInfoAt(t, "13", "var i2_i_i2_si: number", "") + f.VerifyQuickInfoAt(t, "13q", "var i2_i: i2", "") + f.VerifyQuickInfoAt(t, "14", "var i2_i_i2_ii: number", "") + f.VerifyQuickInfoAt(t, "14q", "var i2_i: i2", "") + f.VerifyQuickInfoAt(t, "15", "var i2_i_n: any", "") + f.GoToMarker(t, "16") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "new method", ParameterDocComment: "param"}) + f.VerifyQuickInfoAt(t, "16q", "var i2_i: i2\nnew (i: i1) => any", "new method") + f.VerifyQuickInfoAt(t, "17", "var i2_i_nc_x: number", "") + f.VerifyQuickInfoAt(t, "18", "(property) i2.nc_x: number", "") + f.VerifyQuickInfoAt(t, "19", "var i2_i_nc_foo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "20", "(property) i2.nc_foo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "21", "var i2_i_nc_foo_r: string", "") + f.GoToMarker(t, "22") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "22q", "(property) i2.nc_foo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "23", "var i2_i_r: number", "") + f.GoToMarker(t, "24") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is call signature", ParameterDocComment: "paramhelp a"}) + f.VerifyQuickInfoAt(t, "24q", "var i2_i: i2\n(a: number, b: number) => number", "this is call signature") + f.GoToMarker(t, "25") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is call signature", ParameterDocComment: "paramhelp b"}) + f.VerifyQuickInfoAt(t, "26", "var i2_i_fnfoo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "27", "(method) i2.fnfoo(b: number): string", "this is fnfoo") + f.VerifyQuickInfoAt(t, "28", "var i2_i_fnfoo_r: string", "") + f.GoToMarker(t, "29") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is fnfoo", ParameterDocComment: "param help"}) + f.VerifyQuickInfoAt(t, "29q", "(method) i2.fnfoo(b: number): string", "this is fnfoo") + f.VerifyQuickInfoAt(t, "30", "var i2_i_nc_fnfoo: (b: number) => string", "") + f.VerifyQuickInfoAt(t, "31", "(method) i2.nc_fnfoo(b: number): string", "") + f.VerifyQuickInfoAt(t, "32", "var i2_i_nc_fnfoo_r: string", "") + f.GoToMarker(t, "33") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "33q", "(method) i2.nc_fnfoo(b: number): string", "") + f.VerifyCompletions(t, "34", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_i", + Detail: PtrTo("var i1_i: i1"), + }, + &lsproto.CompletionItem{ + Label: "nc_i1_i", + Detail: PtrTo("var nc_i1_i: nc_i1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_i", + Detail: PtrTo("var i2_i: i2"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_x", + Detail: PtrTo("var i2_i_x: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_foo", + Detail: PtrTo("var i2_i_foo: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_foo_r", + Detail: PtrTo("var i2_i_foo_r: string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_i2_si", + Detail: PtrTo("var i2_i_i2_si: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_i2_ii", + Detail: PtrTo("var i2_i_i2_ii: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_n", + Detail: PtrTo("var i2_i_n: any"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_nc_x", + Detail: PtrTo("var i2_i_nc_x: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_nc_foo", + Detail: PtrTo("var i2_i_nc_foo: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_nc_foo_r", + Detail: PtrTo("var i2_i_nc_foo_r: string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_r", + Detail: PtrTo("var i2_i_r: number"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_fnfoo", + Detail: PtrTo("var i2_i_fnfoo: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_fnfoo_r", + Detail: PtrTo("var i2_i_fnfoo_r: string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_nc_fnfoo", + Detail: PtrTo("var i2_i_nc_fnfoo: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "i2_i_nc_fnfoo_r", + Detail: PtrTo("var i2_i_nc_fnfoo_r: string"), + }, + }, + Excludes: []string{ + "i1", + "nc_i1", + "i2", + }, + }, + }) + f.VerifyCompletions(t, "34i", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1", + Detail: PtrTo("interface i1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is interface 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_i1", + Detail: PtrTo("interface nc_i1"), + }, + &lsproto.CompletionItem{ + Label: "i2", + Detail: PtrTo("interface i2"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is interface 2 with members", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "36", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "a", + Detail: PtrTo("(parameter) a: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i3_i a", + }, + }, + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "40q", "var i3_i: i3", "") + f.VerifyCompletions(t, "40", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i3_i", + Detail: PtrTo("var i3_i: i3"), + }, + }, + Excludes: []string{ + "i3", + }, + }, + }) + f.GoToMarker(t, "41") + f.VerifyQuickInfoIs(t, "(method) i3.f(a: number): string", "Function i3 f") + f.VerifyCompletions(t, "41", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "f", + Detail: PtrTo("(method) i3.f(a: number): string"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "Function i3 f", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "l", + Detail: PtrTo("(property) i3.l: (b: number) => string"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "i3 l", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "nc_f", + Detail: PtrTo("(method) i3.nc_f(a: number): string"), + }, + &lsproto.CompletionItem{ + Label: "nc_l", + Detail: PtrTo("(property) i3.nc_l: (b: number) => string"), + }, + &lsproto.CompletionItem{ + Label: "nc_x", + Detail: PtrTo("(property) i3.nc_x: number"), + }, + &lsproto.CompletionItem{ + Label: "x", + Detail: PtrTo("(property) i3.x: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "Comment i3 x", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "42") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "Function i3 f", ParameterDocComment: "number parameter"}) + f.GoToMarker(t, "43") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "", ParameterDocComment: "comment i3 l b"}) + f.VerifyQuickInfoAt(t, "43q", "(property) i3.l: (b: number) => string", "i3 l") + f.GoToMarker(t, "44") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "44q", "(method) i3.nc_f(a: number): string", "") + f.GoToMarker(t, "45") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: ""}) + f.VerifyQuickInfoAt(t, "45q", "(property) i3.nc_l: (b: number) => string", "") +} diff --git a/pkg/fourslash/tests/gen/commentsOverloadsFourslash_test.go b/pkg/fourslash/tests/gen/commentsOverloadsFourslash_test.go new file mode 100644 index 000000000..7484d6081 --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsOverloadsFourslash_test.go @@ -0,0 +1,723 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsOverloadsFourslash(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** this is signature 1*/ +function /*1*/f1(/**param a*/a: number): number; +function /*2*/f1(b: string): number; +function /*3*/f1(aOrb: any) { + return 10; +} +f/*4q*/1(/*4*/"hello"); +f/*o4q*/1(/*o4*/10); +function /*5*/f2(/**param a*/a: number): number; +/** this is signature 2*/ +function /*6*/f2(b: string): number; +/** this is f2 var comment*/ +function /*7*/f2(aOrb: any) { + return 10; +} +f/*8q*/2(/*8*/"hello"); +f/*o8q*/2(/*o8*/10); +function /*9*/f3(a: number): number; +function /*10*/f3(b: string): number; +function /*11*/f3(aOrb: any) { + return 10; +} +f/*12q*/3(/*12*/"hello"); +f/*o12q*/3(/*o12*/10); +/** this is signature 4 - with number parameter*/ +function /*13*/f4(/**param a*/a: number): number; +/** this is signature 4 - with string parameter*/ +function /*14*/f4(b: string): number; +function /*15*/f4(aOrb: any) { + return 10; +} +f/*16q*/4(/*16*/"hello"); +f/*o16q*/4(/*o16*/10); +/*17*/ +interface i1 { + /**this signature 1*/ + (/**param a*/ a: number): number; + /**this is signature 2*/ + (b: string): number; + /** foo 1*/ + foo(a: number): number; + /** foo 2*/ + foo(b: string): number; + foo2(a: number): number; + /** foo2 2*/ + foo2(b: string): number; + foo3(a: number): number; + foo3(b: string): number; + /** foo4 1*/ + foo4(a: number): number; + foo4(b: string): number; + /** new 1*/ + new (a: string); + new (b: number); +} +var i1_i: i1; +interface i2 { + new (a: string); + /** new 2*/ + new (b: number); + (a: number): number; + /**this is signature 2*/ + (b: string): number; +} +var i2_i: i2; +interface i3 { + /** new 1*/ + new (a: string); + /** new 2*/ + new (b: number); + /**this is signature 1*/ + (a: number): number; + (b: string): number; +} +var i3_i: i3; +interface i4 { + new (a: string); + new (b: number); + (a: number): number; + (b: string): number; +} +var i4_i: i4; +new /*18*/i1/*19q*/_i(/*19*/10); +new i/*20q*/1_i(/*20*/"Hello"); +i/*21q*/1_i(/*21*/10); +i/*22q*/1_i(/*22*/"hello"); +i1_i./*23*/f/*24q*/oo(/*24*/10); +i1_i.f/*25q*/oo(/*25*/"hello"); +i1_i.fo/*26q*/o2(/*26*/10); +i1_i.fo/*27q*/o2(/*27*/"hello"); +i1_i.fo/*28q*/o3(/*28*/10); +i1_i.fo/*29q*/o3(/*29*/"hello"); +i1_i.fo/*30q*/o4(/*30*/10); +i1_i.fo/*31q*/o4(/*31*/"hello"); +new i2/*32q*/_i(/*32*/10); +new i2/*33q*/_i(/*33*/"Hello"); +i/*34q*/2_i(/*34*/10); +i2/*35q*/_i(/*35*/"hello"); +new i/*36q*/3_i(/*36*/10); +new i3/*37q*/_i(/*37*/"Hello"); +i3/*38q*/_i(/*38*/10); +i3/*39q*/_i(/*39*/"hello"); +new i4/*40q*/_i(/*40*/10); +new i/*41q*/4_i(/*41*/"Hello"); +i4/*42q*/_i(/*42*/10); +i4/*43q*/_i(/*43*/"hello"); +class c { + public /*93*/prop1(a: number): number; + public /*94*/prop1(b: string): number; + public /*95*/prop1(aorb: any) { + return 10; + } + /** prop2 1*/ + public /*96*/prop2(a: number): number; + public /*97*/prop2(b: string): number; + public /*98*/prop2(aorb: any) { + return 10; + } + public /*99*/prop3(a: number): number; + /** prop3 2*/ + public /*100*/prop3(b: string): number; + public /*101*/prop3(aorb: any) { + return 10; + } + /** prop4 1*/ + public /*102*/prop4(a: number): number; + /** prop4 2*/ + public /*103*/prop4(b: string): number; + public /*104*/prop4(aorb: any) { + return 10; + } + /** prop5 1*/ + public /*105*/prop5(a: number): number; + /** prop5 2*/ + public /*106*/prop5(b: string): number; + /** Prop5 implementaion*/ + public /*107*/prop5(aorb: any) { + return 10; + } +} +class c1 { + /*78*/constructor(a: number); + /*79*/constructor(b: string); + /*80*/constructor(aorb: any) { + } +} +class c2 { + /** c2 1*/ + /*81*/constructor(a: number); + /*82*/constructor(b: string); + /*83*/constructor(aorb: any) { + } +} +class c3 { + /*84*/constructor(a: number); + /** c3 2*/ + /*85*/constructor(b: string); + /*86*/constructor(aorb: any) { + } +} +class c4 { + /** c4 1*/ + /*87*/constructor(a: number); + /** c4 2*/ + /*88*/constructor(b: string); + /*89*/constructor(aorb: any) { + } +} +class c5 { + /** c5 1*/ + /*90*/constructor(a: number); + /** c5 2*/ + /*91*/constructor(b: string); + /** c5 implementation*/ + /*92*/constructor(aorb: any) { + } +} +var c_i = new c(); +c_i./*44*/pro/*45q*/p1(/*45*/10); +c_i.pr/*46q*/op1(/*46*/"hello"); +c_i.pr/*47q*/op2(/*47*/10); +c_i.pr/*48q*/op2(/*48*/"hello"); +c_i.pro/*49q*/p3(/*49*/10); +c_i.pr/*50q*/op3(/*50*/"hello"); +c_i.pr/*51q*/op4(/*51*/10); +c_i.pr/*52q*/op4(/*52*/"hello"); +c_i.pr/*53q*/op5(/*53*/10); +c_i.pr/*54q*/op5(/*54*/"hello"); +var c1/*66*/_i_1 = new c/*55q*/1(/*55*/10); +var c1_i_2 = new c/*56q*/1(/*56*/"hello"); +var c2_i_1 = new c/*57q*/2(/*57*/10); +var c/*67*/2_i_2 = new c/*58q*/2(/*58*/"hello"); +var c3_i_1 = new c/*59q*/3(/*59*/10); +var c/*68*/3_i_2 = new c/*60q*/3(/*60*/"hello"); +var c4/*69*/_i_1 = new c/*61q*/4(/*61*/10); +var c4_i_2 = new c/*62q*/4(/*62*/"hello"); +var c/*70*/5_i_1 = new c/*63q*/5(/*63*/10); +var c5_i_2 = new c/*64q*/5(/*64*/"hello"); +/** This is multiOverload F1 1*/ +function multiOverload(a: number): string; +/** This is multiOverload F1 2*/ +function multiOverload(b: string): string; +/** This is multiOverload F1 3*/ +function multiOverload(c: boolean): string; +/** This is multiOverload Implementation */ +function multiOverload(d): string { + return "Hello"; +} +multiOverl/*71*/oad(10); +multiOverl/*72*/oad("hello"); +multiOverl/*73*/oad(true); +/** This is ambient F1 1*/ +declare function ambientF1(a: number): string; +/** This is ambient F1 2*/ +declare function ambientF1(b: string): string; +/** This is ambient F1 3*/ +declare function ambientF1(c: boolean): boolean; +/*65*/ +ambient/*74*/F1(10); +ambient/*75*/F1("hello"); +ambient/*76*/F1(true); +function foo(a/*77*/a: i3) { +} +foo(null);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "function f1(a: number): number (+1 overload)", "this is signature 1") + f.VerifyQuickInfoAt(t, "2", "function f1(b: string): number (+1 overload)", "this is signature 1") + f.VerifyQuickInfoAt(t, "3", "function f1(a: number): number (+1 overload)", "this is signature 1") + f.VerifyQuickInfoAt(t, "4q", "function f1(b: string): number (+1 overload)", "this is signature 1") + f.VerifyQuickInfoAt(t, "o4q", "function f1(a: number): number (+1 overload)", "this is signature 1") + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.GoToMarker(t, "o4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 1", ParameterDocComment: "param a", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "5", "function f2(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "6", "function f2(b: string): number (+1 overload)", "this is signature 2") + f.VerifyQuickInfoAt(t, "7", "function f2(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "8q", "function f2(b: string): number (+1 overload)", "this is signature 2") + f.VerifyQuickInfoAt(t, "o8q", "function f2(a: number): number (+1 overload)", "") + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 2", OverloadsCount: 2}) + f.GoToMarker(t, "o8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterDocComment: "param a", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "9", "function f3(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "10", "function f3(b: string): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "11", "function f3(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "12q", "function f3(b: string): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "o12q", "function f3(a: number): number (+1 overload)", "") + f.GoToMarker(t, "12") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.GoToMarker(t, "o12") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "13", "function f4(a: number): number (+1 overload)", "this is signature 4 - with number parameter") + f.VerifyQuickInfoAt(t, "14", "function f4(b: string): number (+1 overload)", "this is signature 4 - with string parameter") + f.VerifyQuickInfoAt(t, "15", "function f4(a: number): number (+1 overload)", "this is signature 4 - with number parameter") + f.VerifyQuickInfoAt(t, "16q", "function f4(b: string): number (+1 overload)", "this is signature 4 - with string parameter") + f.VerifyQuickInfoAt(t, "o16q", "function f4(a: number): number (+1 overload)", "this is signature 4 - with number parameter") + f.GoToMarker(t, "16") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 4 - with string parameter", OverloadsCount: 2}) + f.GoToMarker(t, "o16") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 4 - with number parameter", ParameterDocComment: "param a", OverloadsCount: 2}) + f.VerifyCompletions(t, "17", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "f1", + Detail: PtrTo("function f1(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is signature 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "f2", + Detail: PtrTo("function f2(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "f3", + Detail: PtrTo("function f3(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "f4", + Detail: PtrTo("function f4(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "this is signature 4 - with number parameter", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "18", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_i", + Detail: PtrTo("var i1_i: i1\nnew (b: number) => any (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "new 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i2_i", + Detail: PtrTo("var i2_i: i2\nnew (a: string) => any (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "i3_i", + Detail: PtrTo("var i3_i: i3\nnew (a: string) => any (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "new 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "i4_i", + Detail: PtrTo("var i4_i: i4\nnew (a: string) => any (+1 overload)"), + }, + }, + Excludes: []string{ + "i1", + "i2", + "i3", + "i4", + }, + }, + }) + f.GoToMarker(t, "19") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "19q", "var i1_i: i1\nnew (b: number) => any (+1 overload)", "new 1") + f.GoToMarker(t, "20") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "new 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "20q", "var i1_i: i1\nnew (a: string) => any (+1 overload)", "new 1") + f.GoToMarker(t, "21") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this signature 1", ParameterDocComment: "param a", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "21q", "var i1_i: i1\n(a: number) => number (+1 overload)", "this signature 1") + f.GoToMarker(t, "22") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 2", OverloadsCount: 2}) + f.GoToMarker(t, "22q") + f.VerifyQuickInfoAt(t, "22q", "var i1_i: i1\n(b: string) => number (+1 overload)", "this is signature 2") + f.VerifyCompletions(t, "23", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("(method) i1.foo(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "foo 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "foo2", + Detail: PtrTo("(method) i1.foo2(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "foo3", + Detail: PtrTo("(method) i1.foo3(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "foo4", + Detail: PtrTo("(method) i1.foo4(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "foo4 1", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "24") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foo 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "24q", "(method) i1.foo(a: number): number (+1 overload)", "foo 1") + f.GoToMarker(t, "25") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foo 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "25q", "(method) i1.foo(b: string): number (+1 overload)", "foo 2") + f.GoToMarker(t, "26") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "26q", "(method) i1.foo2(a: number): number (+1 overload)", "") + f.GoToMarker(t, "27") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foo2 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "27q", "(method) i1.foo2(b: string): number (+1 overload)", "foo2 2") + f.GoToMarker(t, "28") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "28q", "(method) i1.foo3(a: number): number (+1 overload)", "") + f.GoToMarker(t, "29") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "29q", "(method) i1.foo3(b: string): number (+1 overload)", "") + f.GoToMarker(t, "30") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foo4 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "30q", "(method) i1.foo4(a: number): number (+1 overload)", "foo4 1") + f.GoToMarker(t, "31") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "31q", "(method) i1.foo4(b: string): number (+1 overload)", "foo4 1") + f.GoToMarker(t, "32") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "new 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "32q", "var i2_i: i2\nnew (b: number) => any (+1 overload)", "new 2") + f.GoToMarker(t, "33") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "33q", "var i2_i: i2\nnew (a: string) => any (+1 overload)", "") + f.GoToMarker(t, "34") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "34q", "var i2_i: i2\n(a: number) => number (+1 overload)", "") + f.GoToMarker(t, "35") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "35q", "var i2_i: i2\n(b: string) => number (+1 overload)", "this is signature 2") + f.GoToMarker(t, "36") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "new 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "36q", "var i3_i: i3\nnew (b: number) => any (+1 overload)", "new 2") + f.GoToMarker(t, "37") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "new 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "37q", "var i3_i: i3\nnew (a: string) => any (+1 overload)", "new 1") + f.GoToMarker(t, "38") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "this is signature 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "38q", "var i3_i: i3\n(a: number) => number (+1 overload)", "this is signature 1") + f.GoToMarker(t, "39") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "39q", "var i3_i: i3\n(b: string) => number (+1 overload)", "this is signature 1") + f.GoToMarker(t, "40") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "40q", "var i4_i: i4\nnew (b: number) => any (+1 overload)", "") + f.GoToMarker(t, "41") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "41q", "var i4_i: i4\nnew (a: string) => any (+1 overload)", "") + f.GoToMarker(t, "42") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "42q", "var i4_i: i4\n(a: number) => number (+1 overload)", "") + f.GoToMarker(t, "43") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "43q", "var i4_i: i4\n(b: string) => number (+1 overload)", "") + f.VerifyCompletions(t, "44", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "prop1", + Detail: PtrTo("(method) c.prop1(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "prop2", + Detail: PtrTo("(method) c.prop2(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "prop2 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "prop3", + Detail: PtrTo("(method) c.prop3(a: number): number (+1 overload)"), + }, + &lsproto.CompletionItem{ + Label: "prop4", + Detail: PtrTo("(method) c.prop4(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "prop4 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "prop5", + Detail: PtrTo("(method) c.prop5(a: number): number (+1 overload)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "prop5 1", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "45") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "45q", "(method) c.prop1(a: number): number (+1 overload)", "") + f.GoToMarker(t, "46") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "46q", "(method) c.prop1(b: string): number (+1 overload)", "") + f.GoToMarker(t, "47") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop2 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "47q", "(method) c.prop2(a: number): number (+1 overload)", "prop2 1") + f.GoToMarker(t, "48") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "48q", "(method) c.prop2(b: string): number (+1 overload)", "prop2 1") + f.GoToMarker(t, "49") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "49q", "(method) c.prop3(a: number): number (+1 overload)", "") + f.GoToMarker(t, "50") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop3 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "50q", "(method) c.prop3(b: string): number (+1 overload)", "prop3 2") + f.GoToMarker(t, "51") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop4 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "51q", "(method) c.prop4(a: number): number (+1 overload)", "prop4 1") + f.GoToMarker(t, "52") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop4 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "52q", "(method) c.prop4(b: string): number (+1 overload)", "prop4 2") + f.GoToMarker(t, "53") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop5 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "53q", "(method) c.prop5(a: number): number (+1 overload)", "prop5 1") + f.GoToMarker(t, "54") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "prop5 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "54q", "(method) c.prop5(b: string): number (+1 overload)", "prop5 2") + f.GoToMarker(t, "55") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "55q", "constructor c1(a: number): c1 (+1 overload)", "") + f.GoToMarker(t, "56") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "56q", "constructor c1(b: string): c1 (+1 overload)", "") + f.GoToMarker(t, "57") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c2 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "57q", "constructor c2(a: number): c2 (+1 overload)", "c2 1") + f.GoToMarker(t, "58") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "58q", "constructor c2(b: string): c2 (+1 overload)", "c2 1") + f.GoToMarker(t, "59") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "59q", "constructor c3(a: number): c3 (+1 overload)", "") + f.GoToMarker(t, "60") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c3 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "60q", "constructor c3(b: string): c3 (+1 overload)", "c3 2") + f.GoToMarker(t, "61") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c4 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "61q", "constructor c4(a: number): c4 (+1 overload)", "c4 1") + f.GoToMarker(t, "62") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c4 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "62q", "constructor c4(b: string): c4 (+1 overload)", "c4 2") + f.GoToMarker(t, "63") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c5 1", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "63q", "constructor c5(a: number): c5 (+1 overload)", "c5 1") + f.GoToMarker(t, "64") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "c5 2", OverloadsCount: 2}) + f.VerifyQuickInfoAt(t, "64q", "constructor c5(b: string): c5 (+1 overload)", "c5 2") + f.VerifyCompletions(t, "65", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "c", + Detail: PtrTo("class c"), + }, + &lsproto.CompletionItem{ + Label: "c1", + Detail: PtrTo("class c1"), + }, + &lsproto.CompletionItem{ + Label: "c2", + Detail: PtrTo("class c2"), + }, + &lsproto.CompletionItem{ + Label: "c3", + Detail: PtrTo("class c3"), + }, + &lsproto.CompletionItem{ + Label: "c4", + Detail: PtrTo("class c4"), + }, + &lsproto.CompletionItem{ + Label: "c5", + Detail: PtrTo("class c5"), + }, + &lsproto.CompletionItem{ + Label: "c_i", + Detail: PtrTo("var c_i: c"), + }, + &lsproto.CompletionItem{ + Label: "c1_i_1", + Detail: PtrTo("var c1_i_1: c1"), + }, + &lsproto.CompletionItem{ + Label: "c2_i_1", + Detail: PtrTo("var c2_i_1: c2"), + }, + &lsproto.CompletionItem{ + Label: "c3_i_1", + Detail: PtrTo("var c3_i_1: c3"), + }, + &lsproto.CompletionItem{ + Label: "c4_i_1", + Detail: PtrTo("var c4_i_1: c4"), + }, + &lsproto.CompletionItem{ + Label: "c5_i_1", + Detail: PtrTo("var c5_i_1: c5"), + }, + &lsproto.CompletionItem{ + Label: "c1_i_2", + Detail: PtrTo("var c1_i_2: c1"), + }, + &lsproto.CompletionItem{ + Label: "c2_i_2", + Detail: PtrTo("var c2_i_2: c2"), + }, + &lsproto.CompletionItem{ + Label: "c3_i_2", + Detail: PtrTo("var c3_i_2: c3"), + }, + &lsproto.CompletionItem{ + Label: "c4_i_2", + Detail: PtrTo("var c4_i_2: c4"), + }, + &lsproto.CompletionItem{ + Label: "c5_i_2", + Detail: PtrTo("var c5_i_2: c5"), + }, + &lsproto.CompletionItem{ + Label: "multiOverload", + Detail: PtrTo("function multiOverload(a: number): string (+2 overloads)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "This is multiOverload F1 1", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "ambientF1", + Detail: PtrTo("function ambientF1(a: number): string (+2 overloads)"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "This is ambient F1 1", + }, + }, + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "66", "var c1_i_1: c1", "") + f.VerifyQuickInfoAt(t, "67", "var c2_i_2: c2", "") + f.VerifyQuickInfoAt(t, "68", "var c3_i_2: c3", "") + f.VerifyQuickInfoAt(t, "69", "var c4_i_1: c4", "") + f.VerifyQuickInfoAt(t, "70", "var c5_i_1: c5", "") + f.VerifyQuickInfoAt(t, "71", "function multiOverload(a: number): string (+2 overloads)", "This is multiOverload F1 1") + f.VerifyQuickInfoAt(t, "72", "function multiOverload(b: string): string (+2 overloads)", "This is multiOverload F1 2") + f.VerifyQuickInfoAt(t, "73", "function multiOverload(c: boolean): string (+2 overloads)", "This is multiOverload F1 3") + f.VerifyQuickInfoAt(t, "74", "function ambientF1(a: number): string (+2 overloads)", "This is ambient F1 1") + f.VerifyQuickInfoAt(t, "75", "function ambientF1(b: string): string (+2 overloads)", "This is ambient F1 2") + f.VerifyQuickInfoAt(t, "76", "function ambientF1(c: boolean): boolean (+2 overloads)", "This is ambient F1 3") + f.VerifyQuickInfoAt(t, "77", "(parameter) aa: i3", "") + f.VerifyQuickInfoAt(t, "78", "constructor c1(a: number): c1 (+1 overload)", "") + f.VerifyQuickInfoAt(t, "79", "constructor c1(b: string): c1 (+1 overload)", "") + f.VerifyQuickInfoAt(t, "80", "constructor c1(a: number): c1 (+1 overload)", "") + f.VerifyQuickInfoAt(t, "81", "constructor c2(a: number): c2 (+1 overload)", "c2 1") + f.VerifyQuickInfoAt(t, "82", "constructor c2(b: string): c2 (+1 overload)", "c2 1") + f.VerifyQuickInfoAt(t, "83", "constructor c2(a: number): c2 (+1 overload)", "c2 1") + f.VerifyQuickInfoAt(t, "84", "constructor c3(a: number): c3 (+1 overload)", "") + f.VerifyQuickInfoAt(t, "85", "constructor c3(b: string): c3 (+1 overload)", "c3 2") + f.VerifyQuickInfoAt(t, "86", "constructor c3(a: number): c3 (+1 overload)", "") + f.VerifyQuickInfoAt(t, "87", "constructor c4(a: number): c4 (+1 overload)", "c4 1") + f.VerifyQuickInfoAt(t, "88", "constructor c4(b: string): c4 (+1 overload)", "c4 2") + f.VerifyQuickInfoAt(t, "89", "constructor c4(a: number): c4 (+1 overload)", "c4 1") + f.VerifyQuickInfoAt(t, "90", "constructor c5(a: number): c5 (+1 overload)", "c5 1") + f.VerifyQuickInfoAt(t, "91", "constructor c5(b: string): c5 (+1 overload)", "c5 2") + f.VerifyQuickInfoAt(t, "92", "constructor c5(a: number): c5 (+1 overload)", "c5 1") + f.VerifyQuickInfoAt(t, "93", "(method) c.prop1(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "94", "(method) c.prop1(b: string): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "95", "(method) c.prop1(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "96", "(method) c.prop2(a: number): number (+1 overload)", "prop2 1") + f.VerifyQuickInfoAt(t, "97", "(method) c.prop2(b: string): number (+1 overload)", "prop2 1") + f.VerifyQuickInfoAt(t, "98", "(method) c.prop2(a: number): number (+1 overload)", "prop2 1") + f.VerifyQuickInfoAt(t, "99", "(method) c.prop3(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "100", "(method) c.prop3(b: string): number (+1 overload)", "prop3 2") + f.VerifyQuickInfoAt(t, "101", "(method) c.prop3(a: number): number (+1 overload)", "") + f.VerifyQuickInfoAt(t, "102", "(method) c.prop4(a: number): number (+1 overload)", "prop4 1") + f.VerifyQuickInfoAt(t, "103", "(method) c.prop4(b: string): number (+1 overload)", "prop4 2") + f.VerifyQuickInfoAt(t, "104", "(method) c.prop4(a: number): number (+1 overload)", "prop4 1") + f.VerifyQuickInfoAt(t, "105", "(method) c.prop5(a: number): number (+1 overload)", "prop5 1") + f.VerifyQuickInfoAt(t, "106", "(method) c.prop5(b: string): number (+1 overload)", "prop5 2") + f.VerifyQuickInfoAt(t, "107", "(method) c.prop5(a: number): number (+1 overload)", "prop5 1") +} diff --git a/pkg/fourslash/tests/gen/commentsVariables_test.go b/pkg/fourslash/tests/gen/commentsVariables_test.go new file mode 100644 index 000000000..7ca395e25 --- /dev/null +++ b/pkg/fourslash/tests/gen/commentsVariables_test.go @@ -0,0 +1,231 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCommentsVariables(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** This is my variable*/ +var myV/*1*/ariable = 10; +/*2*/ +/** d variable*/ +var d = 10; +myVariable = d; +/*3*/ +/** foos comment*/ +function foo() { +} +/** fooVar comment*/ +var foo/*12*/Var: () => void; +/*4*/ +f/*5q*/oo(/*5*/); +fo/*6q*/oVar(/*6*/); +fo/*13*/oVar = f/*14*/oo; +/*7*/ +f/*8q*/oo(/*8*/); +foo/*9q*/Var(/*9*/); +var fooVarVar = /*9aq*/fooVar; +/**class comment*/ +class c { + /** constructor comment*/ + constructor() { + } +} +/**instance comment*/ +var i = new c(); +/*10*/ +/** interface comments*/ +interface i1 { +} +/**interface instance comments*/ +var i1_i: i1; +/*11*/ +function foo2(a: number): void; +function foo2(b: string): void; +function foo2(aOrb) { +} +var x = fo/*15*/o2;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "var myVariable: number", "This is my variable") + f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myVariable", + Detail: PtrTo("var myVariable: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "This is my variable", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "myVariable", + Detail: PtrTo("var myVariable: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "This is my variable", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "d", + Detail: PtrTo("var d: number"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "d variable", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "4", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("function foo(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "foos comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "fooVar", + Detail: PtrTo("var fooVar: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "fooVar comment", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foos comment"}) + f.VerifyQuickInfoAt(t, "5q", "function foo(): void", "foos comment") + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "fooVar comment"}) + f.VerifyQuickInfoAt(t, "6q", "var fooVar: () => void", "fooVar comment") + f.VerifyCompletions(t, "7", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "foo", + Detail: PtrTo("function foo(): void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "foos comment", + }, + }, + }, + &lsproto.CompletionItem{ + Label: "fooVar", + Detail: PtrTo("var fooVar: () => void"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "fooVar comment", + }, + }, + }, + }, + }, + }) + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "foos comment"}) + f.VerifyQuickInfoAt(t, "8q", "function foo(): void", "foos comment") + f.GoToMarker(t, "9") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "fooVar comment"}) + f.VerifyQuickInfoAt(t, "9q", "var fooVar: () => void", "fooVar comment") + f.VerifyQuickInfoAt(t, "9aq", "var fooVar: () => void", "fooVar comment") + f.VerifyCompletions(t, "10", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i", + Detail: PtrTo("var i: c"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "instance comment", + }, + }, + }, + }, + }, + }) + f.VerifyCompletions(t, "11", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "i1_i", + Detail: PtrTo("var i1_i: i1"), + Documentation: &lsproto.StringOrMarkupContent{ + MarkupContent: &lsproto.MarkupContent{ + Kind: lsproto.MarkupKindMarkdown, + Value: "interface instance comments", + }, + }, + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "12", "var fooVar: () => void", "fooVar comment") + f.VerifyQuickInfoAt(t, "13", "var fooVar: () => void", "fooVar comment") + f.VerifyQuickInfoAt(t, "14", "function foo(): void", "foos comment") + f.VerifyQuickInfoAt(t, "15", "function foo2(a: number): void (+1 overload)", "") +} diff --git a/pkg/fourslash/tests/gen/crossFileQuickInfoExportedTypeDoesNotUseImportType_test.go b/pkg/fourslash/tests/gen/crossFileQuickInfoExportedTypeDoesNotUseImportType_test.go new file mode 100644 index 000000000..f8d2fbc53 --- /dev/null +++ b/pkg/fourslash/tests/gen/crossFileQuickInfoExportedTypeDoesNotUseImportType_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestCrossFileQuickInfoExportedTypeDoesNotUseImportType(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: b.ts +export interface B {} +export function foob(): { + x: B, + y: B +} { + return null as any; +} +// @Filename: a.ts +import { foob } from "./b"; +const thing/*1*/ = foob(/*2*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "const thing: {\n x: B;\n y: B;\n}", "") + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foob(): { x: B; y: B; }"}) +} diff --git a/pkg/fourslash/tests/gen/functionOverloadCount_test.go b/pkg/fourslash/tests/gen/functionOverloadCount_test.go new file mode 100644 index 000000000..0e09add34 --- /dev/null +++ b/pkg/fourslash/tests/gen/functionOverloadCount_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFunctionOverloadCount(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C1 { + public attr(): string; + public attr(i: number): string; + public attr(i: number, x: boolean): string; + public attr(i?: any, x?: any) { + return "hi"; + } +} +var i = new C1; +i.attr(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 3}) +} diff --git a/pkg/fourslash/tests/gen/functionProperty_test.go b/pkg/fourslash/tests/gen/functionProperty_test.go new file mode 100644 index 000000000..68896691f --- /dev/null +++ b/pkg/fourslash/tests/gen/functionProperty_test.go @@ -0,0 +1,76 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestFunctionProperty(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var a = { + x(a: number) { } +}; + +var b = { + x: function (a: number) { } +}; + +var c = { + x: (a: number) => { } +}; +a.x(/*signatureA*/1); +b.x(/*signatureB*/1); +c.x(/*signatureC*/1); +a./*completionA*/; +b./*completionB*/; +c./*completionC*/; +a./*quickInfoA*/x; +b./*quickInfoB*/x; +c./*quickInfoC*/x;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "signatureA") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "x(a: number): void"}) + f.GoToMarker(t, "signatureB") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "x(a: number): void"}) + f.GoToMarker(t, "signatureC") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "x(a: number): void"}) + f.VerifyCompletions(t, "completionA", &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Detail: PtrTo("(method) x(a: number): void"), + }, + }, + }, + }) + f.VerifyCompletions(t, []string{"completionB", "completionC"}, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Exact: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Detail: PtrTo("(property) x: (a: number) => void"), + }, + }, + }, + }) + f.VerifyQuickInfoAt(t, "quickInfoA", "(method) x(a: number): void", "") + f.VerifyQuickInfoAt(t, "quickInfoB", "(property) x: (a: number) => void", "") + f.VerifyQuickInfoAt(t, "quickInfoC", "(property) x: (a: number) => void", "") +} diff --git a/pkg/fourslash/tests/gen/genericFunctionReturnType2_test.go b/pkg/fourslash/tests/gen/genericFunctionReturnType2_test.go new file mode 100644 index 000000000..f0be52bb6 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionReturnType2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionReturnType2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + constructor(x: T) { } + foo(x: T) { + return (a: T) => x; + } +} +var x = new C(1); +var /*2*/r = x.foo(/*1*/3); +var /*4*/r2 = r(/*3*/4);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(x: number): (a: number) => number"}) + f.VerifyQuickInfoAt(t, "2", "var r: (a: number) => number", "") + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "r(a: number): number"}) + f.VerifyQuickInfoAt(t, "4", "var r2: number", "") +} diff --git a/pkg/fourslash/tests/gen/genericFunctionReturnType_test.go b/pkg/fourslash/tests/gen/genericFunctionReturnType_test.go new file mode 100644 index 000000000..9e606f779 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionReturnType_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionReturnType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(x: T, y: U): (a: U) => T { + var z = y; + return (z) => x; +} +var /*2*/r = foo(/*1*/1, ""); +var /*4*/r2 = r(/*3*/"");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(x: number, y: string): (a: string) => number"}) + f.VerifyQuickInfoAt(t, "2", "var r: (a: string) => number", "") + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "r(a: string): number"}) + f.VerifyQuickInfoAt(t, "4", "var r2: number", "") +} diff --git a/pkg/fourslash/tests/gen/genericFunctionSignatureHelp1_test.go b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp1_test.go new file mode 100644 index 000000000..7014eff70 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionSignatureHelp1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: T): T { return null; } +f(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(a: unknown): unknown"}) +} diff --git a/pkg/fourslash/tests/gen/genericFunctionSignatureHelp2_test.go b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp2_test.go new file mode 100644 index 000000000..90ae1b762 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionSignatureHelp2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var f = (a: T) => a; +f(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(a: unknown): unknown"}) +} diff --git a/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3MultiFile_test.go b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3MultiFile_test.go new file mode 100644 index 000000000..40d93735b --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3MultiFile_test.go @@ -0,0 +1,52 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionSignatureHelp3MultiFile(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: genericFunctionSignatureHelp_0.ts +function foo1(x: number, callback: (y1: T) => number) { } +// @Filename: genericFunctionSignatureHelp_1.ts +function foo2(x: number, callback: (y2: T) => number) { } +// @Filename: genericFunctionSignatureHelp_2.ts +function foo3(x: number, callback: (y3: T) => number) { } +// @Filename: genericFunctionSignatureHelp_3.ts +function foo4(x: number, callback: (y4: T) => number) { } +// @Filename: genericFunctionSignatureHelp_4.ts +function foo5(x: number, callback: (y5: T) => number) { } +// @Filename: genericFunctionSignatureHelp_5.ts +function foo6(x: number, callback: (y6: T) => number) { } +// @Filename: genericFunctionSignatureHelp_6.ts +function foo7(x: number, callback: (y7: T) => number) { } +// @Filename: genericFunctionSignatureHelp_7.ts +foo1(/*1*/ // signature help shows y as T +foo2(1,/*2*/ // signature help shows y as {} +foo3(1, (/*3*/ // signature help shows y as T +foo4(1,/*4*/ // signature help shows y as string +foo5(1, (/*5*/ // signature help shows y as T +foo6(1, (/*7*/ // signature help shows y as T` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo1(x: number, callback: (y1: unknown) => number): void"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo2(x: number, callback: (y2: unknown) => number): void"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(y3: unknown): number"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo4(x: number, callback: (y4: string) => number): void"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(y5: string): number"}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo6(x: number, callback: (y6: unknown) => number): void"}) + f.Insert(t, "string>(null,null);") + f.GoToMarker(t, "7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo7(x: number, callback: (y7: unknown) => number): void"}) +} diff --git a/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3_test.go b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3_test.go new file mode 100644 index 000000000..e8ee72606 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericFunctionSignatureHelp3_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericFunctionSignatureHelp3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo1(x: number, callback: (y1: T) => number) { } +function foo2(x: number, callback: (y2: T) => number) { } +function foo3(x: number, callback: (y3: T) => number) { } +function foo4(x: number, callback: (y4: T) => number) { } +function foo5(x: number, callback: (y5: T) => number) { } +function foo6(x: number, callback: (y6: T) => number) { } +function foo7(x: number, callback: (y7: T) => number) { } + IDE shows the results on the right of each line, fourslash says different +foo1(/*1*/ // signature help shows y as T +foo2(1,/*2*/ // signature help shows y as {} +foo3(1, (/*3*/ // signature help shows y as T +foo4(1,/*4*/ // signature help shows y as string +foo5(1, (/*5*/ // signature help shows y as T +foo6(1, (/*7*/ // signature help shows y as T` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo1(x: number, callback: (y1: unknown) => number): void"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo2(x: number, callback: (y2: unknown) => number): void"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(y3: unknown): number"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo4(x: number, callback: (y4: string) => number): void"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(y5: string): number"}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo6(x: number, callback: (y6: unknown) => number): void"}) + f.Insert(t, "string>(null,null);") + f.GoToMarker(t, "7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo7(x: number, callback: (y7: unknown) => number): void"}) +} diff --git a/pkg/fourslash/tests/gen/genericParameterHelpConstructorCalls_test.go b/pkg/fourslash/tests/gen/genericParameterHelpConstructorCalls_test.go new file mode 100644 index 000000000..6c8208d08 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericParameterHelpConstructorCalls_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericParameterHelpConstructorCalls(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { } + +class testClass { + constructor(a:T, b:U, c:M){ } +} + +// Constructor calls +new testClass(null, null, null) +new testClass<,,/*constructor4*/>(null, null, null) +new testClass(null, null, null)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "constructor1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "testClass(a: T, b: U, c: M): testClass", ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "constructor2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "U", ParameterSpan: "U"}) + f.GoToMarker(t, "constructor3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "constructor4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "M", ParameterSpan: "M extends IFoo"}) + f.GoToMarker(t, "constructor5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "U", ParameterSpan: "U"}) +} diff --git a/pkg/fourslash/tests/gen/genericParameterHelpTypeReferences_test.go b/pkg/fourslash/tests/gen/genericParameterHelpTypeReferences_test.go new file mode 100644 index 000000000..fc4de0201 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericParameterHelpTypeReferences_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericParameterHelpTypeReferences(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { } + +class testClass { + constructor(a:T, b:U, c:M){ } +} + +// Generic types +testClass extends testClass; + +interface I {} +let i: I; + +type Ty = T; +let t: Ty;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "type1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "testClass", ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "type2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "testClass", ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "type3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "testClass", ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "type4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "M", ParameterSpan: "M extends IFoo"}) + f.GoToMarker(t, "interface") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "I", ParameterName: "T", ParameterSpan: "T"}) + f.GoToMarker(t, "typeAlias") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Ty", ParameterName: "T", ParameterSpan: "T"}) +} diff --git a/pkg/fourslash/tests/gen/genericParameterHelp_test.go b/pkg/fourslash/tests/gen/genericParameterHelp_test.go new file mode 100644 index 000000000..bb40eaa86 --- /dev/null +++ b/pkg/fourslash/tests/gen/genericParameterHelp_test.go @@ -0,0 +1,37 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGenericParameterHelp(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface IFoo { } + +function testFunction(a: T, b: U, c: M): M { + return null; +} + +// Function calls +testFunction(/*3*/ +testFunction(null, null, null); +testFunction<, ,/*5*/>(null, null, null);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "testFunction(a: T, b: U, c: M): M", ParameterCount: 3, ParameterName: "T", ParameterSpan: "T extends IFoo"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "U", ParameterSpan: "U"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "a", ParameterSpan: "a: any"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "M", ParameterSpan: "M extends IFoo"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "M", ParameterSpan: "M extends IFoo"}) +} diff --git a/pkg/fourslash/tests/gen/getJavaScriptCompletions16_test.go b/pkg/fourslash/tests/gen/getJavaScriptCompletions16_test.go new file mode 100644 index 000000000..aae42386f --- /dev/null +++ b/pkg/fourslash/tests/gen/getJavaScriptCompletions16_test.go @@ -0,0 +1,75 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestGetJavaScriptCompletions16(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowNonTsExtensions: true +// @Filename: file.js +"use strict"; + +class Something { + + /** + * @param {number} a + */ + constructor(a, b) { + a/*body*/ + } + + /** + * @param {number} a + */ + method(a) { + a/*method*/ + } +} +let x = new Something(/*sig*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "body") + f.Insert(t, ".") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "toFixed", + Kind: PtrTo(lsproto.CompletionItemKindMethod), + }, + }, + }, + }) + f.Backspace(t, 1) + f.GoToMarker(t, "sig") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Something(a: number, b: any): Something"}) + f.GoToMarker(t, "method") + f.Insert(t, ".") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "toFixed", + Kind: PtrTo(lsproto.CompletionItemKindMethod), + }, + }, + }, + }) +} diff --git a/pkg/fourslash/tests/gen/jsSignature-41059_test.go b/pkg/fourslash/tests/gen/jsSignature-41059_test.go new file mode 100644 index 000000000..96ccf57c6 --- /dev/null +++ b/pkg/fourslash/tests/gen/jsSignature-41059_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsSignature_41059(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @lib: esnext +// @allowNonTsExtensions: true +// @Filename: Foo.js +a.next(/**/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Generator.next(): IteratorResult", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/noSignatureHelpOnNewKeyword_test.go b/pkg/fourslash/tests/gen/noSignatureHelpOnNewKeyword_test.go new file mode 100644 index 000000000..2540e073d --- /dev/null +++ b/pkg/fourslash/tests/gen/noSignatureHelpOnNewKeyword_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestNoSignatureHelpOnNewKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { } +new/*1*/ Foo +new /*2*/Foo(/*3*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "1", "2") + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Foo(): Foo"}) +} diff --git a/pkg/fourslash/tests/gen/overloadOnConstCallSignature_test.go b/pkg/fourslash/tests/gen/overloadOnConstCallSignature_test.go new file mode 100644 index 000000000..cfa19723e --- /dev/null +++ b/pkg/fourslash/tests/gen/overloadOnConstCallSignature_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestOverloadOnConstCallSignature(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var foo: { + (name: string): string; + (name: 'order'): string; + (name: 'content'): string; + (name: 'done'): string; +} +var /*2*/x = foo(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(name: \"order\"): string", OverloadsCount: 4}) + f.Insert(t, "\"hi\"") + f.VerifyQuickInfoAt(t, "2", "var x: string", "") +} diff --git a/pkg/fourslash/tests/gen/qualifyModuleTypeNames_test.go b/pkg/fourslash/tests/gen/qualifyModuleTypeNames_test.go new file mode 100644 index 000000000..05f23de89 --- /dev/null +++ b/pkg/fourslash/tests/gen/qualifyModuleTypeNames_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQualifyModuleTypeNames(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { export class c { } }; +function x(arg: m.c) { return arg; } +x(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "x(arg: m.c): m.c"}) +} diff --git a/pkg/fourslash/tests/gen/quickInfoCanBeTruncated_test.go b/pkg/fourslash/tests/gen/quickInfoCanBeTruncated_test.go new file mode 100644 index 000000000..35b71669a --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoCanBeTruncated_test.go @@ -0,0 +1,539 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoCanBeTruncated(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noLib: true +interface Foo { + _0: 0; + _1: 1; + _2: 2; + _3: 3; + _4: 4; + _5: 5; + _6: 6; + _7: 7; + _8: 8; + _9: 9; + _10: 10; + _11: 11; + _12: 12; + _13: 13; + _14: 14; + _15: 15; + _16: 16; + _17: 17; + _18: 18; + _19: 19; + _20: 20; + _21: 21; + _22: 22; + _23: 23; + _24: 24; + _25: 25; + _26: 26; + _27: 27; + _28: 28; + _29: 29; + _30: 30; + _31: 31; + _32: 32; + _33: 33; + _34: 34; + _35: 35; + _36: 36; + _37: 37; + _38: 38; + _39: 39; + _40: 40; + _41: 41; + _42: 42; + _43: 43; + _44: 44; + _45: 45; + _46: 46; + _47: 47; + _48: 48; + _49: 49; + _50: 50; + _51: 51; + _52: 52; + _53: 53; + _54: 54; + _55: 55; + _56: 56; + _57: 57; + _58: 58; + _59: 59; + _60: 60; + _61: 61; + _62: 62; + _63: 63; + _64: 64; + _65: 65; + _66: 66; + _67: 67; + _68: 68; + _69: 69; + _70: 70; + _71: 71; + _72: 72; + _73: 73; + _74: 74; + _75: 75; + _76: 76; + _77: 77; + _78: 78; + _79: 79; + _80: 80; + _81: 81; + _82: 82; + _83: 83; + _84: 84; + _85: 85; + _86: 86; + _87: 87; + _88: 88; + _89: 89; + _90: 90; + _91: 91; + _92: 92; + _93: 93; + _94: 94; + _95: 95; + _96: 96; + _97: 97; + _98: 98; + _99: 99; + _100: 100; + _101: 101; + _102: 102; + _103: 103; + _104: 104; + _105: 105; + _106: 106; + _107: 107; + _108: 108; + _109: 109; + _110: 110; + _111: 111; + _112: 112; + _113: 113; + _114: 114; + _115: 115; + _116: 116; + _117: 117; + _118: 118; + _119: 119; + _120: 120; + _121: 121; + _122: 122; + _123: 123; + _124: 124; + _125: 125; + _126: 126; + _127: 127; + _128: 128; + _129: 129; + _130: 130; + _131: 131; + _132: 132; + _133: 133; + _134: 134; + _135: 135; + _136: 136; + _137: 137; + _138: 138; + _139: 139; + _140: 140; + _141: 141; + _142: 142; + _143: 143; + _144: 144; + _145: 145; + _146: 146; + _147: 147; + _148: 148; + _149: 149; + _150: 150; + _151: 151; + _152: 152; + _153: 153; + _154: 154; + _155: 155; + _156: 156; + _157: 157; + _158: 158; + _159: 159; + _160: 160; + _161: 161; + _162: 162; + _163: 163; + _164: 164; + _165: 165; + _166: 166; + _167: 167; + _168: 168; + _169: 169; + _170: 170; + _171: 171; + _172: 172; + _173: 173; + _174: 174; + _175: 175; + _176: 176; + _177: 177; + _178: 178; + _179: 179; + _180: 180; + _181: 181; + _182: 182; + _183: 183; + _184: 184; + _185: 185; + _186: 186; + _187: 187; + _188: 188; + _189: 189; + _190: 190; + _191: 191; + _192: 192; + _193: 193; + _194: 194; + _195: 195; + _196: 196; + _197: 197; + _198: 198; + _199: 199; + _200: 200; + _201: 201; + _202: 202; + _203: 203; + _204: 204; + _205: 205; + _206: 206; + _207: 207; + _208: 208; + _209: 209; + _210: 210; + _211: 211; + _212: 212; + _213: 213; + _214: 214; + _215: 215; + _216: 216; + _217: 217; + _218: 218; + _219: 219; + _220: 220; + _221: 221; + _222: 222; + _223: 223; + _224: 224; + _225: 225; + _226: 226; + _227: 227; + _228: 228; + _229: 229; + _230: 230; + _231: 231; + _232: 232; + _233: 233; + _234: 234; + _235: 235; + _236: 236; + _237: 237; + _238: 238; + _239: 239; + _240: 240; + _241: 241; + _242: 242; + _243: 243; + _244: 244; + _245: 245; + _246: 246; + _247: 247; + _248: 248; + _249: 249; + _250: 250; + _251: 251; + _252: 252; + _253: 253; + _254: 254; + _255: 255; + _256: 256; + _257: 257; + _258: 258; + _259: 259; + _260: 260; + _261: 261; + _262: 262; + _263: 263; + _264: 264; + _265: 265; + _266: 266; + _267: 267; + _268: 268; + _269: 269; + _270: 270; + _271: 271; + _272: 272; + _273: 273; + _274: 274; + _275: 275; + _276: 276; + _277: 277; + _278: 278; + _279: 279; + _280: 280; + _281: 281; + _282: 282; + _283: 283; + _284: 284; + _285: 285; + _286: 286; + _287: 287; + _288: 288; + _289: 289; + _290: 290; + _291: 291; + _292: 292; + _293: 293; + _294: 294; + _295: 295; + _296: 296; + _297: 297; + _298: 298; + _299: 299; + _300: 300; + _301: 301; + _302: 302; + _303: 303; + _304: 304; + _305: 305; + _306: 306; + _307: 307; + _308: 308; + _309: 309; + _310: 310; + _311: 311; + _312: 312; + _313: 313; + _314: 314; + _315: 315; + _316: 316; + _317: 317; + _318: 318; + _319: 319; + _320: 320; + _321: 321; + _322: 322; + _323: 323; + _324: 324; + _325: 325; + _326: 326; + _327: 327; + _328: 328; + _329: 329; + _330: 330; + _331: 331; + _332: 332; + _333: 333; + _334: 334; + _335: 335; + _336: 336; + _337: 337; + _338: 338; + _339: 339; + _340: 340; + _341: 341; + _342: 342; + _343: 343; + _344: 344; + _345: 345; + _346: 346; + _347: 347; + _348: 348; + _349: 349; + _350: 350; + _351: 351; + _352: 352; + _353: 353; + _354: 354; + _355: 355; + _356: 356; + _357: 357; + _358: 358; + _359: 359; + _360: 360; + _361: 361; + _362: 362; + _363: 363; + _364: 364; + _365: 365; + _366: 366; + _367: 367; + _368: 368; + _369: 369; + _370: 370; + _371: 371; + _372: 372; + _373: 373; + _374: 374; + _375: 375; + _376: 376; + _377: 377; + _378: 378; + _379: 379; + _380: 380; + _381: 381; + _382: 382; + _383: 383; + _384: 384; + _385: 385; + _386: 386; + _387: 387; + _388: 388; + _389: 389; + _390: 390; + _391: 391; + _392: 392; + _393: 393; + _394: 394; + _395: 395; + _396: 396; + _397: 397; + _398: 398; + _399: 399; + _400: 400; + _401: 401; + _402: 402; + _403: 403; + _404: 404; + _405: 405; + _406: 406; + _407: 407; + _408: 408; + _409: 409; + _410: 410; + _411: 411; + _412: 412; + _413: 413; + _414: 414; + _415: 415; + _416: 416; + _417: 417; + _418: 418; + _419: 419; + _420: 420; + _421: 421; + _422: 422; + _423: 423; + _424: 424; + _425: 425; + _426: 426; + _427: 427; + _428: 428; + _429: 429; + _430: 430; + _431: 431; + _432: 432; + _433: 433; + _434: 434; + _435: 435; + _436: 436; + _437: 437; + _438: 438; + _439: 439; + _440: 440; + _441: 441; + _442: 442; + _443: 443; + _444: 444; + _445: 445; + _446: 446; + _447: 447; + _448: 448; + _449: 449; + _450: 450; + _451: 451; + _452: 452; + _453: 453; + _454: 454; + _455: 455; + _456: 456; + _457: 457; + _458: 458; + _459: 459; + _460: 460; + _461: 461; + _462: 462; + _463: 463; + _464: 464; + _465: 465; + _466: 466; + _467: 467; + _468: 468; + _469: 469; + _470: 470; + _471: 471; + _472: 472; + _473: 473; + _474: 474; + _475: 475; + _476: 476; + _477: 477; + _478: 478; + _479: 479; + _480: 480; + _481: 481; + _482: 482; + _483: 483; + _484: 484; + _485: 485; + _486: 486; + _487: 487; + _488: 488; + _489: 489; + _490: 490; + _491: 491; + _492: 492; + _493: 493; + _494: 494; + _495: 495; + _496: 496; + _497: 497; + _498: 498; + _499: 499; +} +type A/*1*/ = keyof Foo; +type Exclude = T extends U ? never : T; +type Less/*2*/ = Exclude; +function f(s: T, x: Exclude, y: string) {} +f("_499", /*3*/); +type Decomposed/*4*/ = {[K in A]: Foo[K]} +type LongTuple/*5*/ = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17.18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]; +type DeeplyMapped/*6*/ = {[K in keyof Foo]: {[K2 in keyof Foo]: [K, K2, Foo[K], Foo[K2]]}}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifyQuickInfoIs(t, "type A = keyof Foo", "") + f.GoToMarker(t, "2") + f.VerifyQuickInfoIs(t, "type Less = \"_1\" | \"_10\" | \"_100\" | \"_101\" | \"_102\" | \"_103\" | \"_104\" | \"_105\" | \"_106\" | \"_107\" | \"_108\" | \"_109\" | \"_11\" | \"_110\" | \"_111\" | \"_112\" | \"_113\" | \"_114\" | \"_115\" | \"_116\" | \"_117\" | \"_118\" | \"_119\" | \"_12\" | \"_120\" | \"_121\" | \"_122\" | \"_123\" | \"_124\" | \"_125\" | \"_126\" | \"_127\" | \"_128\" | \"_129\" | \"_13\" | \"_130\" | \"_131\" | \"_132\" | \"_133\" | \"_134\" | \"_135\" | \"_136\" | \"_137\" | \"_138\" | \"_139\" | \"_14\" | \"_140\" | \"_141\" | \"_142\" | \"_143\" | \"_144\" | \"_145\" | \"_146\" | \"_147\" | \"_148\" | \"_149\" | \"_15\" | \"_150\" | \"_151\" | \"_152\" | \"_153\" | \"_154\" | \"_155\" | \"_156\" | ... 434 more ... | \"_99\"", "") + f.GoToMarker(t, "3") + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(s: \"_499\", x: \"_0\" | \"_1\" | \"_10\" | \"_100\" | \"_101\" | \"_102\" | \"_103\" | \"_104\" | \"_105\" | \"_106\" | \"_107\" | \"_108\" | \"_109\" | \"_11\" | \"_110\" | \"_111\" | \"_112\" | \"_113\" | \"_114\" | \"_115\" | \"_116\" | ... 477 more ... | \"_99\", y: string): void"}) + f.GoToMarker(t, "4") + f.VerifyQuickInfoIs(t, "type Decomposed = {\n _0: 0;\n _1: 1;\n _10: 10;\n _100: 100;\n _101: 101;\n _102: 102;\n _103: 103;\n _104: 104;\n _105: 105;\n _106: 106;\n _107: 107;\n _108: 108;\n _109: 109;\n _11: 11;\n _110: 110;\n _111: 111;\n _112: 112;\n _113: 113;\n _114: 114;\n _115: 115;\n _116: 116;\n _117: 117;\n _118: 118;\n _119: 119;\n _12: 12;\n _120: 120;\n _121: 121;\n _122: 122;\n _123: 123;\n _124: 124;\n _125: 125;\n _126: 126;\n _127: 127;\n _128: 128;\n _129: 129;\n _13: 13;\n _130: 130;\n _131: 131;\n _132: 132;\n _133: 133;\n _134: 134;\n _135: 135;\n _136: 136;\n _137: 137;\n _138: 138;\n _139: 139;\n _14: 14;\n _140: 140;\n _141: 141;\n _142: 142;\n _143: 143;\n _144: 144;\n _145: 145;\n _146: 146;\n _147: 147;\n _148: 148;\n _149: 149;\n _15: 15;\n _150: 150;\n _151: 151;\n _152: 152;\n _153: 153;\n _154: 154;\n _155: 155;\n _156: 156;\n _157: 157;\n ... 433 more ...;\n _99: 99;\n}", "") + f.GoToMarker(t, "5") + f.VerifyQuickInfoIs(t, "type LongTuple = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17.18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]", "") + f.GoToMarker(t, "6") + f.VerifyQuickInfoIs(t, "type DeeplyMapped = {\n _0: {\n _0: [\"_0\", \"_0\", 0, 0];\n _1: [\"_0\", \"_1\", 0, 1];\n _2: [\"_0\", \"_2\", 0, 2];\n _3: [\"_0\", \"_3\", 0, 3];\n _4: [\"_0\", \"_4\", 0, 4];\n _5: [\"_0\", \"_5\", 0, 5];\n _6: [\"_0\", \"_6\", 0, 6];\n _7: [\"_0\", \"_7\", 0, 7];\n _8: [\"_0\", \"_8\", 0, 8];\n _9: [\"_0\", \"_9\", 0, 9];\n _10: [\"_0\", \"_10\", 0, 10];\n _11: [\"_0\", \"_11\", 0, 11];\n _12: [\"_0\", \"_12\", 0, 12];\n _13: [\"_0\", \"_13\", 0, 13];\n _14: [\"_0\", \"_14\", 0, 14];\n _15: [\"_0\", \"_15\", 0, 15];\n _16: [\"_0\", \"_16\", 0, 16];\n _17: [\"_0\", \"_17\", 0, 17];\n _18: [\"_0\", \"_18\", 0, 18];\n _19: [\"_0\", \"_19\", 0, 19];\n _20: [\"_0\", \"_20\", 0, 20];\n _21: [\"_0\", \"_21\", 0, 21];\n ... 477 more ...;\n _499: [...];\n };\n ... 498 more ...;\n _499: {\n ...;\n };\n}", "") +} diff --git a/pkg/fourslash/tests/gen/quickInfoInFunctionTypeReference2_test.go b/pkg/fourslash/tests/gen/quickInfoInFunctionTypeReference2_test.go new file mode 100644 index 000000000..2cff69726 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoInFunctionTypeReference2_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoInFunctionTypeReference2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + map(fn: (/*1*/k: string, /*2*/value: T, context: any) => void, context: any) { + } +} +var c: C; +c.map(/*3*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "1", "(parameter) k: string", "") + f.VerifyQuickInfoAt(t, "2", "(parameter) value: T", "") + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "map(fn: (k: string, value: number, context: any) => void, context: any): void"}) +} diff --git a/pkg/fourslash/tests/gen/quickInfoOnConstructorWithGenericParameter_test.go b/pkg/fourslash/tests/gen/quickInfoOnConstructorWithGenericParameter_test.go new file mode 100644 index 000000000..30429505d --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoOnConstructorWithGenericParameter_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoOnConstructorWithGenericParameter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + x: number; +} +class Foo { + y: T; +} +class A { + foo() { } +} +class B extends A { + constructor(a: Foo, b: number) { + super(); + } +} +var x = new /*2*/B(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(a: Foo, b: number): B"}) + f.Insert(t, "null,") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(a: Foo, b: number): B"}) + f.Insert(t, "10);") + f.VerifyQuickInfoAt(t, "2", "constructor B(a: Foo, b: number): B", "") +} diff --git a/pkg/fourslash/tests/gen/quickInfoOnPrivateConstructorCall_test.go b/pkg/fourslash/tests/gen/quickInfoOnPrivateConstructorCall_test.go new file mode 100644 index 000000000..2f034082e --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoOnPrivateConstructorCall_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoOnPrivateConstructorCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + private constructor() {} +} +var x = new A(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "1") +} diff --git a/pkg/fourslash/tests/gen/quickInfoOnProtectedConstructorCall_test.go b/pkg/fourslash/tests/gen/quickInfoOnProtectedConstructorCall_test.go new file mode 100644 index 000000000..0140cc224 --- /dev/null +++ b/pkg/fourslash/tests/gen/quickInfoOnProtectedConstructorCall_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestQuickInfoOnProtectedConstructorCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + protected constructor() {} +} +var x = new A(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "1") +} diff --git a/pkg/fourslash/tests/gen/restArgSignatureHelp_test.go b/pkg/fourslash/tests/gen/restArgSignatureHelp_test.go new file mode 100644 index 000000000..c417bbda1 --- /dev/null +++ b/pkg/fourslash/tests/gen/restArgSignatureHelp_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestRestArgSignatureHelp(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(...x: any[]) { } +f(/**/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "x", IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelp01_test.go b/pkg/fourslash/tests/gen/signatureHelp01_test.go new file mode 100644 index 000000000..dd028c7de --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelp01_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelp01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(data: number) { +} + +function bar { + foo(/*1*/) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.MarkTestAsStradaServer() + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{DocComment: "", ParameterCount: 1}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpAnonymousFunction_test.go b/pkg/fourslash/tests/gen/signatureHelpAnonymousFunction_test.go new file mode 100644 index 000000000..b14cf520d --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpAnonymousFunction_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpAnonymousFunction(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var anonymousFunctionTest = function(n: number, s: string): (a: number, b: string) => string { + return null; +} +anonymousFunctionTest(5, "")(/*anonymousFunction1*/1, /*anonymousFunction2*/"");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "anonymousFunction1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "(a: number, b: string): string", ParameterCount: 2, ParameterName: "a", ParameterSpan: "a: number"}) + f.GoToMarker(t, "anonymousFunction2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "b", ParameterSpan: "b: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpAtEOF2_test.go b/pkg/fourslash/tests/gen/signatureHelpAtEOF2_test.go new file mode 100644 index 000000000..d656879e1 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpAtEOF2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpAtEOF2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `console.log() +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkersWithContext(t, &lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindInvoked}, "") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpAtEOF_test.go b/pkg/fourslash/tests/gen/signatureHelpAtEOF_test.go new file mode 100644 index 000000000..0c35fef98 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpAtEOF_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpAtEOF(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function Foo(arg1: string, arg2: string) { +} + +Foo(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Foo(arg1: string, arg2: string): void", ParameterCount: 2, ParameterName: "arg1", ParameterSpan: "arg1: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpBeforeSemicolon1_test.go b/pkg/fourslash/tests/gen/signatureHelpBeforeSemicolon1_test.go new file mode 100644 index 000000000..c62238141 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpBeforeSemicolon1_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpBeforeSemicolon1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function Foo(arg1: string, arg2: string) { +} + +Foo(/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Foo(arg1: string, arg2: string): void", ParameterCount: 2, ParameterName: "arg1", ParameterSpan: "arg1: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpCallExpressionTuples_test.go b/pkg/fourslash/tests/gen/signatureHelpCallExpressionTuples_test.go new file mode 100644 index 000000000..384aab5e9 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpCallExpressionTuples_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpCallExpressionTuples(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function fnTest(str: string, num: number) { } +declare function wrap(fn: (...a: A) => R) : (...a: A) => R; +var fnWrapped = wrap(fnTest); +fnWrapped/*3*/(/*1*/'', /*2*/5); +function fnTestVariadic (str: string, ...num: number[]) { } +var fnVariadicWrapped = wrap(fnTestVariadic); +fnVariadicWrapped/*4*/(/*5*/'', /*6*/5); +function fnNoParams () { } +var fnNoParamsWrapped = wrap(fnNoParams); +fnNoParamsWrapped/*7*/(/*8*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "3", "var fnWrapped: (str: string, num: number) => void", "") + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnWrapped(str: string, num: number): void", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "num", ParameterSpan: "num: number"}) + f.VerifyQuickInfoAt(t, "4", "var fnVariadicWrapped: (str: string, ...num: number[]) => void", "") + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnVariadicWrapped(str: string, ...num: number[]): void", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string", IsVariadic: true, IsVariadicSet: true}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "num", ParameterSpan: "...num: number[]", IsVariadic: true, IsVariadicSet: true}) + f.VerifyQuickInfoAt(t, "7", "var fnNoParamsWrapped: () => void", "") + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnNoParamsWrapped(): void", ParameterCount: 0}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpCallExpression_test.go b/pkg/fourslash/tests/gen/signatureHelpCallExpression_test.go new file mode 100644 index 000000000..c1f88c885 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpCallExpression_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpCallExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function fnTest(str: string, num: number) { } +fnTest(/*1*/'', /*2*/5);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnTest(str: string, num: number): void", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "num", ParameterSpan: "num: number"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpConstructExpression_test.go b/pkg/fourslash/tests/gen/signatureHelpConstructExpression_test.go new file mode 100644 index 000000000..f474789cb --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpConstructExpression_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpConstructExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class sampleCls { constructor(str: string, num: number) { } } +var x = new sampleCls(/*1*/"", /*2*/5);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "sampleCls(str: string, num: number): sampleCls", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "num", ParameterSpan: "num: number"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpConstructorInheritance_test.go b/pkg/fourslash/tests/gen/signatureHelpConstructorInheritance_test.go new file mode 100644 index 000000000..3ba16c9d7 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpConstructorInheritance_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpConstructorInheritance(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class base { + constructor(s: string); + constructor(n: number); + constructor(a: any) { } +} +class B1 extends base { } +class B2 extends B1 { } +class B3 extends B2 { + constructor() { + super(/*indirectSuperCall*/3); + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "indirectSuperCall") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B2(n: number): B2", ParameterCount: 1, ParameterName: "n", ParameterSpan: "n: number", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpConstructorOverload_test.go b/pkg/fourslash/tests/gen/signatureHelpConstructorOverload_test.go new file mode 100644 index 000000000..276d12b0c --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpConstructorOverload_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpConstructorOverload(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class clsOverload { constructor(); constructor(test: string); constructor(test?: string) { } } +var x = new clsOverload(/*1*/); +var y = new clsOverload(/*2*/'');` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "clsOverload(): clsOverload", ParameterCount: 0, OverloadsCount: 2}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "clsOverload(test: string): clsOverload", ParameterCount: 1, ParameterName: "test", ParameterSpan: "test: string", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpEmptyList_test.go b/pkg/fourslash/tests/gen/signatureHelpEmptyList_test.go new file mode 100644 index 000000000..4cb2cf592 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpEmptyList_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpEmptyList(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function Foo(arg1: string, arg2: string) { +} + +Foo(/*1*/); +function Bar(arg1: string, arg2: string) { } +Bar();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Foo(arg1: string, arg2: string): void", ParameterCount: 2, ParameterName: "arg1", ParameterSpan: "arg1: string"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Bar(arg1: string, arg2: string): void"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpExpandedRestTuples_test.go b/pkg/fourslash/tests/gen/signatureHelpExpandedRestTuples_test.go new file mode 100644 index 000000000..49f57157d --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpExpandedRestTuples_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpExpandedRestTuples(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export function complex(item: string, another: string, ...rest: [] | [settings: object, errorHandler: (err: Error) => void] | [errorHandler: (err: Error) => void, ...mixins: object[]]) { + +} + +complex(/*1*/); +complex("ok", "ok", /*2*/); +complex("ok", "ok", e => void e, {}, /*3*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string): void", ParameterCount: 2, ParameterName: "item", ParameterSpan: "item: string", OverloadsCount: 3, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string, settings: object, errorHandler: (err: Error) => void): void", ParameterCount: 4, ParameterName: "settings", ParameterSpan: "settings: object", OverloadsCount: 3, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string, errorHandler: (err: Error) => void, ...mixins: object[]): void", OverloadsCount: 3, IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpExpandedRestUnlabeledTuples_test.go b/pkg/fourslash/tests/gen/signatureHelpExpandedRestUnlabeledTuples_test.go new file mode 100644 index 000000000..0070a7072 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpExpandedRestUnlabeledTuples_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpExpandedRestUnlabeledTuples(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export function complex(item: string, another: string, ...rest: [] | [object, (err: Error) => void] | [(err: Error) => void, ...object[]]) { + +} + +complex(/*1*/); +complex("ok", "ok", /*2*/); +complex("ok", "ok", e => void e, {}, /*3*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string): void", ParameterCount: 2, ParameterName: "item", ParameterSpan: "item: string", OverloadsCount: 3, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string, rest_0: object, rest_1: (err: Error) => void): void", ParameterCount: 4, ParameterName: "rest_0", ParameterSpan: "rest_0: object", OverloadsCount: 3, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "complex(item: string, another: string, rest_0: (err: Error) => void, ...rest: object[]): void", OverloadsCount: 3, IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpExpandedTuplesArgumentIndex_test.go b/pkg/fourslash/tests/gen/signatureHelpExpandedTuplesArgumentIndex_test.go new file mode 100644 index 000000000..db2003dfc --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpExpandedTuplesArgumentIndex_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpExpandedTuplesArgumentIndex(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(...args: [string, string] | [number, string, string] +) { + +} + +foo(123/*1*/,) +foo(""/*2*/, ""/*3*/) +foo(123/*4*/, ""/*5*/, ) +foo(123/*6*/, ""/*7*/, ""/*8*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_0", ParameterSpan: "args_0: number", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: string, args_1: string): void", ParameterCount: 2, ParameterName: "args_0", ParameterSpan: "args_0: string", OverloadsCount: 2, OverrideSelectedItemIndex: 0, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: string, args_1: string): void", ParameterCount: 2, ParameterName: "args_1", ParameterSpan: "args_1: string", OverloadsCount: 2, OverrideSelectedItemIndex: 0, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_0", ParameterSpan: "args_0: number", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_1", ParameterSpan: "args_1: string", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_0", ParameterSpan: "args_0: number", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_1", ParameterSpan: "args_1: string", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(args_0: number, args_1: string, args_2: string): void", ParameterCount: 3, ParameterName: "args_2", ParameterSpan: "args_2: string", OverloadsCount: 2, OverrideSelectedItemIndex: 1, IsVariadic: false, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpExplicitTypeArguments_test.go b/pkg/fourslash/tests/gen/signatureHelpExplicitTypeArguments_test.go new file mode 100644 index 000000000..172bb18a5 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpExplicitTypeArguments_test.go @@ -0,0 +1,51 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpExplicitTypeArguments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function f(x: T, y: U): T; +f(/*1*/); +f(/*2*/); +f(/*3*/); +f(/*4*/); +interface A { a: number } +interface B extends A { b: string } +declare function g(x: T, y: U, z: V): T; +declare function h(x: T, y: U, z: V): T; +declare function j(x: T, y: U, z: V): T; +g(/*5*/); +h(/*6*/); +j(/*7*/); +g(/*8*/); +h(/*9*/); +j(/*10*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(x: number, y: string): number"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(x: boolean, y: string): boolean"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(x: number, y: string): number"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(x: number, y: string): number"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "g(x: unknown, y: unknown, z: B): unknown"}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "h(x: unknown, y: unknown, z: A): unknown"}) + f.GoToMarker(t, "7") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "j(x: unknown, y: unknown, z: B): unknown"}) + f.GoToMarker(t, "8") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "g(x: number, y: unknown, z: B): number"}) + f.GoToMarker(t, "9") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "h(x: number, y: unknown, z: A): number"}) + f.GoToMarker(t, "10") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "j(x: number, y: unknown, z: B): number"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpFilteredTriggers03_test.go b/pkg/fourslash/tests/gen/signatureHelpFilteredTriggers03_test.go new file mode 100644 index 000000000..2f86d7066 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpFilteredTriggers03_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpFilteredTriggers03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare class ViewJayEss { + constructor(obj: object); +} +new ViewJayEss({ + methods: { + sayHello/**/ + } +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.Insert(t, "(") + f.VerifyNoSignatureHelpWithContext(t, &lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter, TriggerCharacter: PtrTo("("), IsRetrigger: false}) + f.Insert(t, ") {},") + f.VerifyNoSignatureHelpWithContext(t, &lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter, TriggerCharacter: PtrTo(","), IsRetrigger: false}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpForNonlocalTypeDoesNotUseImportType_test.go b/pkg/fourslash/tests/gen/signatureHelpForNonlocalTypeDoesNotUseImportType_test.go new file mode 100644 index 000000000..9e1f20e48 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpForNonlocalTypeDoesNotUseImportType_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpForNonlocalTypeDoesNotUseImportType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: exporter.ts +export interface Thing {} +export const Foo: () => Thing = null as any; +// @Filename: usage.ts +import {Foo} from "./exporter" +function f(p = Foo()): void {} +f(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(p?: Thing): void"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpForOptionalMethods_test.go b/pkg/fourslash/tests/gen/signatureHelpForOptionalMethods_test.go new file mode 100644 index 000000000..ca8eca0d6 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpForOptionalMethods_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpForOptionalMethods(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @strict: true +interface Obj { + optionalMethod?: (current: any) => any; +}; + +const o: Obj = { + optionalMethod(/*1*/) { + return {}; + } +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "optionalMethod(current: any): any", ParameterName: "current", ParameterSpan: "current: any"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpForSignatureWithUnreachableType_test.go b/pkg/fourslash/tests/gen/signatureHelpForSignatureWithUnreachableType_test.go new file mode 100644 index 000000000..079146e65 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpForSignatureWithUnreachableType_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpForSignatureWithUnreachableType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /node_modules/foo/node_modules/bar/index.d.ts +export interface SomeType { + x?: number; +} +// @Filename: /node_modules/foo/index.d.ts +import { SomeType } from "bar"; +export function func(param: T): void; +export function func(param: T, other: T): void; +// @Filename: /usage.ts +import { func } from "foo"; +func({/*1*/});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "func(param: {}): void", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpForSuperCalls1_test.go b/pkg/fourslash/tests/gen/signatureHelpForSuperCalls1_test.go new file mode 100644 index 000000000..7736d56c9 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpForSuperCalls1_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpForSuperCalls1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { } +class B extends A { } +class C extends B { + constructor() { + super(/*1*/ // sig help here? + } +} +class A2 { } +class B2 extends A2 { + constructor(x:number) {} + } +class C2 extends B2 { + constructor() { + super(/*2*/ // sig help here? + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(): B"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B2(x: number): B2"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpFunctionOverload_test.go b/pkg/fourslash/tests/gen/signatureHelpFunctionOverload_test.go new file mode 100644 index 000000000..fedd16adc --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpFunctionOverload_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpFunctionOverload(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function functionOverload(); +function functionOverload(test: string); +function functionOverload(test?: string) { } +functionOverload(/*functionOverload1*/); +functionOverload(""/*functionOverload2*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "functionOverload1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "functionOverload(): any", ParameterCount: 0, OverloadsCount: 2}) + f.GoToMarker(t, "functionOverload2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "functionOverload(test: string): any", ParameterName: "test", ParameterSpan: "test: string", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpFunctionParameter_test.go b/pkg/fourslash/tests/gen/signatureHelpFunctionParameter_test.go new file mode 100644 index 000000000..3133d49d4 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpFunctionParameter_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpFunctionParameter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function parameterFunction(callback: (a: number, b: string) => void) { + callback(/*parameterFunction1*/5, /*parameterFunction2*/""); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "parameterFunction1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(a: number, b: string): void", ParameterCount: 2, ParameterName: "a", ParameterSpan: "a: number"}) + f.GoToMarker(t, "parameterFunction2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "callback(a: number, b: string): void", ParameterName: "b", ParameterSpan: "b: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpImplicitConstructor_test.go b/pkg/fourslash/tests/gen/signatureHelpImplicitConstructor_test.go new file mode 100644 index 000000000..a011ffee1 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpImplicitConstructor_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpImplicitConstructor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class ImplicitConstructor { +} +var implicitConstructor = new ImplicitConstructor(/**/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "ImplicitConstructor(): ImplicitConstructor", ParameterCount: 0}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpImportStarFromExportEquals_test.go b/pkg/fourslash/tests/gen/signatureHelpImportStarFromExportEquals_test.go new file mode 100644 index 000000000..4137bf2f7 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpImportStarFromExportEquals_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpImportStarFromExportEquals(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /node_modules/@types/abs/index.d.ts +declare function abs(str: string): string; +export = abs; +// @Filename: /a.js +import * as abs from "abs"; +abs/**/;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.Insert(t, "(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "abs(str: string): string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInAdjacentBlockBody_test.go b/pkg/fourslash/tests/gen/signatureHelpInAdjacentBlockBody_test.go new file mode 100644 index 000000000..d78b17695 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInAdjacentBlockBody_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInAdjacentBlockBody(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function foo(...args); + +foo(() => {/*1*/}/*2*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelpPresent(t, &lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindInvoked}) + f.GoToMarker(t, "2") + f.VerifySignatureHelpPresent(t, &lsproto.SignatureHelpContext{TriggerKind: lsproto.SignatureHelpTriggerKindInvoked}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInCallback_test.go b/pkg/fourslash/tests/gen/signatureHelpInCallback_test.go new file mode 100644 index 000000000..d37ee23ce --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInCallback_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInCallback(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function forEach(f: () => void); +forEach(/*1*/() => { + /*2*/ +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "forEach(f: () => void): any"}) + f.VerifyNoSignatureHelpForMarkers(t, "2") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInCompleteGenericsCall_test.go b/pkg/fourslash/tests/gen/signatureHelpInCompleteGenericsCall_test.go new file mode 100644 index 000000000..9c61a32d7 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInCompleteGenericsCall_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInCompleteGenericsCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(x: number, callback: (x: T) => number) { +} +foo(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(x: number, callback: (x: unknown) => number): void"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_test.go b/pkg/fourslash/tests/gen/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_test.go new file mode 100644 index 000000000..53ce5020e --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file0.ts +declare function fn(x: string, y: number); +// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file1.ts +declare function fn(x: string); +// @Filename: signatureHelpInFunctionCallOnFunctionDeclarationInMultipleFiles_file2.ts +fn(/*1*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInFunctionCall_test.go b/pkg/fourslash/tests/gen/signatureHelpInFunctionCall_test.go new file mode 100644 index 000000000..3678840a5 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInFunctionCall_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInFunctionCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var items = []; +items.forEach(item => { + for (/**/ +});` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInParenthetical_test.go b/pkg/fourslash/tests/gen/signatureHelpInParenthetical_test.go new file mode 100644 index 000000000..0c30f629a --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInParenthetical_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInParenthetical(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class base { constructor (public n: number, public y: string) { } } +(new base(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "n"}) + f.Insert(t, "0, ") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "y"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInRecursiveType_test.go b/pkg/fourslash/tests/gen/signatureHelpInRecursiveType_test.go new file mode 100644 index 000000000..7bf6e7aa6 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInRecursiveType_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInRecursiveType(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type Tail = + ((...args: T) => any) extends ((head: any, ...tail: infer R) => any) ? R : never; + +type Reverse = _Reverse; + +type _Reverse = { + 1: Result, + 0: _Reverse, 0>, +}[Source extends [] ? 1 : 0]; + +type Foo = Reverse<[0,/**/]>;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Reverse"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpIncompleteCalls_test.go b/pkg/fourslash/tests/gen/signatureHelpIncompleteCalls_test.go new file mode 100644 index 000000000..e9667ee62 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpIncompleteCalls_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpIncompleteCalls(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module IncompleteCalls { + class Foo { + public f1() { } + public f2(n: number): number { return 0; } + public f3(n: number, s: string) : string { return ""; } + } + var x = new Foo(); + x.f1(); + x.f2(5); + x.f3(5, ""); + x.f1(/*incompleteCalls1*/ + x.f2(5,/*incompleteCalls2*/ + x.f3(5,/*incompleteCalls3*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "incompleteCalls1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f1(): void", ParameterCount: 0}) + f.GoToMarker(t, "incompleteCalls2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f2(n: number): number", ParameterCount: 1}) + f.GoToMarker(t, "incompleteCalls3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f3(n: number, s: string): string", ParameterCount: 2, ParameterName: "s", ParameterSpan: "s: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpInferenceJsDocImportTag_test.go b/pkg/fourslash/tests/gen/signatureHelpInferenceJsDocImportTag_test.go index ffa25d228..00b9e7f3f 100644 --- a/pkg/fourslash/tests/gen/signatureHelpInferenceJsDocImportTag_test.go +++ b/pkg/fourslash/tests/gen/signatureHelpInferenceJsDocImportTag_test.go @@ -9,7 +9,7 @@ import ( func TestSignatureHelpInferenceJsDocImportTag(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJS: true // @checkJs: true diff --git a/pkg/fourslash/tests/gen/signatureHelpInference_test.go b/pkg/fourslash/tests/gen/signatureHelpInference_test.go new file mode 100644 index 000000000..cd4adccfc --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpInference_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpInference(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function f(a: T, b: T, c: T): void; +f("x", /**/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(a: \"x\", b: \"x\", c: \"x\"): void", ParameterCount: 3, ParameterName: "b", ParameterSpan: "b: \"x\""}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpJSMissingIdentifier_test.go b/pkg/fourslash/tests/gen/signatureHelpJSMissingIdentifier_test.go new file mode 100644 index 000000000..36b3e8a0c --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpJSMissingIdentifier_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpJSMissingIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: test.js +log(/**/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpJSX_test.go b/pkg/fourslash/tests/gen/signatureHelpJSX_test.go new file mode 100644 index 000000000..bd7548ea4 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpJSX_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + . "github.com/buke/typescript-go-internal/pkg/fourslash/tests/util" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpJSX(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: test.tsx +//@jsx: react +declare var React: any; +const z =
{[].map(x => "" }; +objectLiteral.f(/*objectLiteral1*/4, /*objectLiteral2*/"");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "objectLiteral1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(a: number, b: string): string", ParameterCount: 2, ParameterName: "a", ParameterSpan: "a: number"}) + f.GoToMarker(t, "objectLiteral2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(a: number, b: string): string", ParameterName: "b", ParameterSpan: "b: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpOnDeclaration_test.go b/pkg/fourslash/tests/gen/signatureHelpOnDeclaration_test.go new file mode 100644 index 000000000..9c31d2233 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpOnDeclaration_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpOnDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: any): a is T {} +function f3(a: any, ...b): a is number {} +f1(/*1*/) +f2(/*2*/) +f3(/*3*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f1(a: any): a is number"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f2(a: any): a is unknown"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f3(a: any, ...b: any[]): a is number", IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpOptionalCall2_test.go b/pkg/fourslash/tests/gen/signatureHelpOptionalCall2_test.go new file mode 100644 index 000000000..828788b44 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpOptionalCall2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpOptionalCall2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare const fnTest: undefined | ((str: string, num: number) => void); +fnTest?.(/*1*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnTest(str: string, num: number): void", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpOptionalCall_test.go b/pkg/fourslash/tests/gen/signatureHelpOptionalCall_test.go new file mode 100644 index 000000000..5ab845b47 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpOptionalCall_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpOptionalCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function fnTest(str: string, num: number) { } +fnTest?.(/*1*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "fnTest(str: string, num: number): void", ParameterCount: 2, ParameterName: "str", ParameterSpan: "str: string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpSimpleConstructorCall_test.go b/pkg/fourslash/tests/gen/signatureHelpSimpleConstructorCall_test.go new file mode 100644 index 000000000..e55292207 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpSimpleConstructorCall_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpSimpleConstructorCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class ConstructorCall { + constructor(str: string, num: number) { + } +} +var x = new ConstructorCall(/*constructorCall1*/1,/*constructorCall2*/2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "constructorCall1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "ConstructorCall(str: string, num: number): ConstructorCall", ParameterName: "str", ParameterSpan: "str: string"}) + f.GoToMarker(t, "constructorCall2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "ConstructorCall(str: string, num: number): ConstructorCall", ParameterName: "num", ParameterSpan: "num: number"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpSimpleFunctionCall_test.go b/pkg/fourslash/tests/gen/signatureHelpSimpleFunctionCall_test.go new file mode 100644 index 000000000..43fb472b3 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpSimpleFunctionCall_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpSimpleFunctionCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Simple function test +function functionCall(str: string, num: number) { +} +functionCall(/*functionCall1*/); +functionCall("", /*functionCall2*/1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "functionCall1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "functionCall(str: string, num: number): void", ParameterName: "str", ParameterSpan: "str: string"}) + f.GoToMarker(t, "functionCall2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "functionCall(str: string, num: number): void", ParameterName: "num", ParameterSpan: "num: number"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpSimpleSuperCall_test.go b/pkg/fourslash/tests/gen/signatureHelpSimpleSuperCall_test.go new file mode 100644 index 000000000..b17bea0ac --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpSimpleSuperCall_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpSimpleSuperCall(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class SuperCallBase { + constructor(b: boolean) { + } +} +class SuperCall extends SuperCallBase { + constructor() { + super(/*superCall*/); + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "superCall") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "SuperCallBase(b: boolean): SuperCallBase", ParameterName: "b", ParameterSpan: "b: boolean"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpSuperConstructorOverload_test.go b/pkg/fourslash/tests/gen/signatureHelpSuperConstructorOverload_test.go new file mode 100644 index 000000000..915c0e1e8 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpSuperConstructorOverload_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpSuperConstructorOverload(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class SuperOverloadBase { + constructor(); + constructor(test: string); + constructor(test?: string) { + } +} +class SuperOverLoad1 extends SuperOverloadBase { + constructor() { + super(/*superOverload1*/); + } +} +class SuperOverLoad2 extends SuperOverloadBase { + constructor() { + super(""/*superOverload2*/); + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "superOverload1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "SuperOverloadBase(): SuperOverloadBase", ParameterCount: 0, OverloadsCount: 2}) + f.GoToMarker(t, "superOverload2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "SuperOverloadBase(test: string): SuperOverloadBase", ParameterCount: 1, ParameterName: "test", ParameterSpan: "test: string", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives1_test.go b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives1_test.go new file mode 100644 index 000000000..b2255f27c --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTaggedTemplatesNegatives1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(templateStrings, x, y, z) { return 10; } +function g(templateStrings, x, y, z) { return ""; } + +/*1*/f/*2*/ /*3*/` + "`" + ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g ` + "`" + ` ` + "`" + ` } ` + "`" + `/*4*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives2_test.go b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives2_test.go new file mode 100644 index 000000000..6e1555b2a --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTaggedTemplatesNegatives2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(strs, ...rest) { +} + +/*1*/fo/*2*/o /*3*/` + "`" + `abcd${0 + 1}abcd{1 + 1}` + "`" + `/*4*/ /*5*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives3_test.go b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives3_test.go new file mode 100644 index 000000000..f2b085a73 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives3_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTaggedTemplatesNegatives3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(strs, ...rest) { +} + +/*1*/fo/*2*/o /*3*/` + "`" + `abcd${0 + 1}abcd{1 + 1}abcd` + "`" + `/*4*/ /*5*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives4_test.go b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives4_test.go new file mode 100644 index 000000000..f24ca7b3b --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives4_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTaggedTemplatesNegatives4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(strs, ...rest) { +} + +/*1*/fo/*2*/o /*3*/` + "`" + `` + "`" + `/*4*/ /*5*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives5_test.go b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives5_test.go new file mode 100644 index 000000000..4bb7e0ef1 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTaggedTemplatesNegatives5_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTaggedTemplatesNegatives5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(strs, ...rest) { +} + +/*1*/fo/*2*/o /*3*/` + "`" + `abcd` + "`" + `/*4*/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, f.MarkerNames()...) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpThis_test.go b/pkg/fourslash/tests/gen/signatureHelpThis_test.go new file mode 100644 index 000000000..2d32fea1b --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpThis_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpThis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + public implicitAny(n: number) { + } + public explicitThis(this: this, n: number) { + console.log(this); + } + public explicitClass(this: Foo, n: number) { + console.log(this); + } +} + +function implicitAny(x: number): void { + return this; +} +function explicitVoid(this: void, x: number): void { + return this; +} +function explicitLiteral(this: { n: number }, x: number): void { + console.log(this); +} +let foo = new Foo(); +foo.implicitAny(/*1*/); +foo.explicitThis(/*2*/); +foo.explicitClass(/*3*/); +implicitAny(/*4*/12); +explicitVoid(/*5*/13); +let o = { n: 14, m: explicitLiteral }; +o.m(/*6*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "n"}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "n"}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "n"}) + f.GoToMarker(t, "4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "x"}) + f.GoToMarker(t, "5") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "x"}) + f.GoToMarker(t, "6") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{ParameterName: "x"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTrailingRestTuple_test.go b/pkg/fourslash/tests/gen/signatureHelpTrailingRestTuple_test.go new file mode 100644 index 000000000..e4e14bac4 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTrailingRestTuple_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTrailingRestTuple(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export function leading(allCaps: boolean, ...names: string[]): void { +} + +leading(/*1*/); +leading(false, /*2*/); +leading(false, "ok", /*3*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "leading(allCaps: boolean, ...names: string[]): void", ParameterCount: 2, ParameterName: "allCaps", ParameterSpan: "allCaps: boolean", OverloadsCount: 1, IsVariadic: true, IsVariadicSet: true}) + f.GoToMarker(t, "2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "leading(allCaps: boolean, ...names: string[]): void", ParameterCount: 2, ParameterName: "names", ParameterSpan: "...names: string[]", OverloadsCount: 1, IsVariadic: true, IsVariadicSet: true}) + f.GoToMarker(t, "3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "leading(allCaps: boolean, ...names: string[]): void", ParameterCount: 2, ParameterName: "names", ParameterSpan: "...names: string[]", OverloadsCount: 1, IsVariadic: true, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTypeArguments_test.go b/pkg/fourslash/tests/gen/signatureHelpTypeArguments_test.go new file mode 100644 index 000000000..d3036db4d --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTypeArguments_test.go @@ -0,0 +1,43 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTypeArguments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function f(a: number, b: string, c: boolean): void; // ignored, not generic +declare function f(): void; +declare function f(): void; +declare function f(): void; +f(): void; + new(): void; + new(): void; +}; +new C(): void", ParameterName: "T", ParameterSpan: "T extends number", OverloadsCount: 3}) + f.GoToMarker(t, "f1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(): void", ParameterName: "U", ParameterSpan: "U", OverloadsCount: 2}) + f.GoToMarker(t, "f2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f(): void", ParameterName: "V", ParameterSpan: "V extends string"}) + f.GoToMarker(t, "C0") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "C(): void", ParameterName: "T", ParameterSpan: "T extends number", OverloadsCount: 3}) + f.GoToMarker(t, "C1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "C(): void", ParameterName: "U", ParameterSpan: "U", OverloadsCount: 2}) + f.GoToMarker(t, "C2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "C(): void", ParameterName: "V", ParameterSpan: "V extends string"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpTypeParametersNotVariadic_test.go b/pkg/fourslash/tests/gen/signatureHelpTypeParametersNotVariadic_test.go new file mode 100644 index 000000000..7b2bdc2d4 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpTypeParametersNotVariadic_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpTypeParametersNotVariadic(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function f(a: any, ...b: any[]): any; +f(1, 2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{IsVariadic: false, IsVariadicSet: true}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpWithInterfaceAsIdentifier_test.go b/pkg/fourslash/tests/gen/signatureHelpWithInterfaceAsIdentifier_test.go new file mode 100644 index 000000000..fe94e81f1 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpWithInterfaceAsIdentifier_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpWithInterfaceAsIdentifier(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface C { + (): void; +} +C(/*1*/);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "1") +} diff --git a/pkg/fourslash/tests/gen/signatureHelpWithInvalidArgumentList1_test.go b/pkg/fourslash/tests/gen/signatureHelpWithInvalidArgumentList1_test.go new file mode 100644 index 000000000..8c44a744d --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpWithInvalidArgumentList1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpWithInvalidArgumentList1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(a) { } +foo(hello my name /**/is` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(a: any): void"}) +} diff --git a/pkg/fourslash/tests/gen/signatureHelpWithTriggers02_test.go b/pkg/fourslash/tests/gen/signatureHelpWithTriggers02_test.go new file mode 100644 index 000000000..9dfa9b25b --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelpWithTriggers02_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelpWithTriggers02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare function foo(x: T, y: T): T; +declare function bar(x: U, y: U): U; + +foo(bar/*1*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "1") + f.Insert(t, "(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "bar(x: unknown, y: unknown): unknown"}) + f.Backspace(t, 1) + f.Insert(t, "<") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "bar(x: U, y: U): U"}) + f.Backspace(t, 1) + f.Insert(t, ",") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(x: (x: U, y: U) => U, y: (x: U, y: U) => U): (x: U, y: U) => U"}) + f.Backspace(t, 1) +} diff --git a/pkg/fourslash/tests/gen/signatureHelp_contextual_test.go b/pkg/fourslash/tests/gen/signatureHelp_contextual_test.go new file mode 100644 index 000000000..07fe086e2 --- /dev/null +++ b/pkg/fourslash/tests/gen/signatureHelp_contextual_test.go @@ -0,0 +1,61 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSignatureHelp_contextual(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + m(n: number, s: string): void; + m2: () => void; +} +declare function takesObj(i: I): void; +takesObj({ m: (/*takesObj0*/) }); +takesObj({ m(/*takesObj1*/) }); +takesObj({ m: function(/*takesObj2*/) }); +takesObj({ m2: (/*takesObj3*/) }); + +declare function takesCb(cb: (n: number, s: string, b: boolean) => void): void; +takesCb((/*contextualParameter1*/)); +takesCb((/*contextualParameter1b*/) => {}); +takesCb((n, /*contextualParameter2*/)); +takesCb((n, s, /*contextualParameter3*/)); +takesCb((n,/*contextualParameter3_2*/ s, b)); +takesCb((n, s, b, /*contextualParameter4*/)); + +type Cb = () => void; +const cb: Cb = (/*contextualTypeAlias*/) + +const cb2: () => void = (/*contextualFunctionType*/)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "takesObj0") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m(n: number, s: string): void", ParameterCount: 2, ParameterName: "n", ParameterSpan: "n: number"}) + f.GoToMarker(t, "takesObj1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m(n: number, s: string): void", ParameterCount: 2, ParameterName: "n", ParameterSpan: "n: number"}) + f.GoToMarker(t, "takesObj2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m(n: number, s: string): void", ParameterCount: 2, ParameterName: "n", ParameterSpan: "n: number"}) + f.GoToMarker(t, "takesObj3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "m2(): void", ParameterCount: 0}) + f.GoToMarker(t, "contextualParameter1") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3, ParameterName: "n", ParameterSpan: "n: number"}) + f.GoToMarker(t, "contextualParameter1b") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3, ParameterName: "n", ParameterSpan: "n: number"}) + f.GoToMarker(t, "contextualParameter2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3, ParameterName: "s", ParameterSpan: "s: string"}) + f.GoToMarker(t, "contextualParameter3") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3, ParameterName: "b", ParameterSpan: "b: boolean"}) + f.GoToMarker(t, "contextualParameter3_2") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3, ParameterName: "s", ParameterSpan: "s: string"}) + f.GoToMarker(t, "contextualParameter4") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb(n: number, s: string, b: boolean): void", ParameterCount: 3}) + f.GoToMarker(t, "contextualTypeAlias") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "Cb(): void", ParameterCount: 0}) + f.GoToMarker(t, "contextualFunctionType") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "cb2(): void", ParameterCount: 0}) +} diff --git a/pkg/fourslash/tests/gen/staticGenericOverloads1_test.go b/pkg/fourslash/tests/gen/staticGenericOverloads1_test.go new file mode 100644 index 000000000..14a74bf45 --- /dev/null +++ b/pkg/fourslash/tests/gen/staticGenericOverloads1_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestStaticGenericOverloads1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + static B(v: A): A; + static B(v: S): A; + static B(v: any): A { + return null; + } +} +var a = new A(); +A.B(/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{OverloadsCount: 2}) + f.Insert(t, "a") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(v: A): A", OverloadsCount: 2}) + f.Insert(t, "); A.B(") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(v: A): A", OverloadsCount: 2}) + f.Insert(t, "a") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "B(v: A): A", OverloadsCount: 2}) +} diff --git a/pkg/fourslash/tests/gen/superInsideInnerClass_test.go b/pkg/fourslash/tests/gen/superInsideInnerClass_test.go new file mode 100644 index 000000000..ebabdf8ca --- /dev/null +++ b/pkg/fourslash/tests/gen/superInsideInnerClass_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestSuperInsideInnerClass(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Base { + constructor(n: number) { + } +} +class Derived extends Base { + constructor() { + class Nested { + [super(/*1*/)] = 11111 + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyNoSignatureHelpForMarkers(t, "1") +} diff --git a/pkg/fourslash/tests/gen/tsxSignatureHelp1_test.go b/pkg/fourslash/tests/gen/tsxSignatureHelp1_test.go new file mode 100644 index 000000000..7642a6ff3 --- /dev/null +++ b/pkg/fourslash/tests/gen/tsxSignatureHelp1_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestTsxSignatureHelp1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//@Filename: file.tsx +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts +import React = require('react'); +export interface ClickableProps { + children?: string; + className?: string; +} +export interface ButtonProps extends ClickableProps { + onClick(event?: React.MouseEvent): void; +} +function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element { + return(); +} +export function MainButton(props: ButtonProps): JSX.Element { + return this._buildMainButton(props); +} +let e1 = ): void; +} +export interface LinkProps extends ClickableProps { + goTo(where: "home" | "contact"): void; +} +function _buildMainButton({ onClick, children, className }: ButtonProps): JSX.Element { + return(); +} +export function MainButton(buttonProps: ButtonProps): JSX.Element; +export function MainButton(linkProps: LinkProps): JSX.Element; +export function MainButton(props: ButtonProps | LinkProps): JSX.Element { + return this._buildMainButton(props); +} +let e1 = any * }} o */ function f1(o) { @@ -32,5 +28,5 @@ function f1(o) { }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) f.GoToMarker(t, "") - f.VerifyQuickInfoIs(t, "(parameter) o: {\n stringProp: string;\n numProp: number;\n boolProp: boolean;\n anyProp: any;\n anotherAnyProp: any;\n functionProp: (arg0: string, arg1: any) => any;\n}", "") + f.VerifyQuickInfoIs(t, "(parameter) o: { stringProp: string; numProp: number; boolProp: boolean; anyProp: any; anotherAnyProp: any; functionProp: (arg0: string, arg1: any) => any; }", "") } diff --git a/pkg/fourslash/tests/manual/jsDocFunctionSignatures2_test.go b/pkg/fourslash/tests/manual/jsDocFunctionSignatures2_test.go new file mode 100644 index 000000000..5e22f15be --- /dev/null +++ b/pkg/fourslash/tests/manual/jsDocFunctionSignatures2_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/buke/typescript-go-internal/pkg/fourslash" + "github.com/buke/typescript-go-internal/pkg/testutil" +) + +func TestJsDocFunctionSignatures2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowNonTsExtensions: true +// @Filename: Foo.js +/** @type {(arg0: string, arg1?: boolean) => number} */ +var f6; + +f6('', /**/false)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "") + f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "f6(arg0: string, arg1?: boolean): number"}) +} diff --git a/pkg/fourslash/tests/signatureHelpCrash_test.go b/pkg/fourslash/tests/signatureHelpCrash_test.go index 3d97a0c87..1714c3648 100644 --- a/pkg/fourslash/tests/signatureHelpCrash_test.go +++ b/pkg/fourslash/tests/signatureHelpCrash_test.go @@ -20,7 +20,7 @@ function foo(x: string, y: T, z: U) { foo/*1*/("hello", 123,456) ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifySignatureHelp(t, &fourslash.SignatureHelpCase{ + f.VerifySignatureHelpWithCases(t, &fourslash.SignatureHelpCase{ MarkerInput: "1", Expected: nil, Context: &lsproto.SignatureHelpContext{ diff --git a/pkg/fourslash/tests/signatureHelpTokenCrash_test.go b/pkg/fourslash/tests/signatureHelpTokenCrash_test.go index 5165a0035..b282c8b0e 100644 --- a/pkg/fourslash/tests/signatureHelpTokenCrash_test.go +++ b/pkg/fourslash/tests/signatureHelpTokenCrash_test.go @@ -23,7 +23,7 @@ foo((/*1*/ foo/** More comments*/((/*2*/ ` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifySignatureHelp(t, &fourslash.SignatureHelpCase{ + f.VerifySignatureHelpWithCases(t, &fourslash.SignatureHelpCase{ MarkerInput: "1", Expected: nil, Context: &lsproto.SignatureHelpContext{ @@ -32,7 +32,7 @@ foo/** More comments*/((/*2*/ TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter, }, }) - f.VerifySignatureHelp(t, &fourslash.SignatureHelpCase{ + f.VerifySignatureHelpWithCases(t, &fourslash.SignatureHelpCase{ MarkerInput: "2", Expected: nil, Context: &lsproto.SignatureHelpContext{ diff --git a/pkg/ls/callhierarchy.go b/pkg/ls/callhierarchy.go new file mode 100644 index 000000000..df8fbcf46 --- /dev/null +++ b/pkg/ls/callhierarchy.go @@ -0,0 +1,1043 @@ +package ls + +import ( + "context" + "slices" + "strings" + + "github.com/buke/typescript-go-internal/pkg/ast" + "github.com/buke/typescript-go-internal/pkg/astnav" + "github.com/buke/typescript-go-internal/pkg/checker" + "github.com/buke/typescript-go-internal/pkg/compiler" + "github.com/buke/typescript-go-internal/pkg/core" + "github.com/buke/typescript-go-internal/pkg/debug" + "github.com/buke/typescript-go-internal/pkg/ls/lsconv" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/printer" + "github.com/buke/typescript-go-internal/pkg/scanner" +) + +type CallHierarchyDeclaration = *ast.Node + +// Indictates whether a node is named function or class expression. +func isNamedExpression(node *ast.Node) bool { + if node == nil { + return false + } + if !ast.IsFunctionExpression(node) && !ast.IsClassExpression(node) { + return false + } + name := node.Name() + return name != nil && ast.IsIdentifier(name) +} + +func isVariableLike(node *ast.Node) bool { + if node == nil { + return false + } + return ast.IsPropertyDeclaration(node) || ast.IsVariableDeclaration(node) +} + +// Indicates whether a node is a function, arrow, or class expression assigned to a constant variable or class property. +func isAssignedExpression(node *ast.Node) bool { + if node == nil { + return false + } + if !(ast.IsFunctionExpression(node) || ast.IsArrowFunction(node) || ast.IsClassExpression(node)) { + return false + } + if node.Name() != nil { + return false + } + parent := node.Parent + if !isVariableLike(parent) { + return false + } + + if parent.Initializer() != node { + return false + } + + name := parent.Name() + if !ast.IsIdentifier(name) { + return false + } + + return (ast.GetCombinedNodeFlags(parent)&ast.NodeFlagsConst) != 0 || ast.IsPropertyDeclaration(parent) +} + +// Indicates whether a node could possibly be a call hierarchy declaration. +// +// See `resolveCallHierarchyDeclaration` for the specific rules. +func isPossibleCallHierarchyDeclaration(node *ast.Node) bool { + if node == nil { + return false + } + return ast.IsSourceFile(node) || + ast.IsModuleDeclaration(node) || + ast.IsFunctionDeclaration(node) || + ast.IsFunctionExpression(node) || + ast.IsClassDeclaration(node) || + ast.IsClassExpression(node) || + ast.IsClassStaticBlockDeclaration(node) || + ast.IsMethodDeclaration(node) || + ast.IsMethodSignatureDeclaration(node) || + ast.IsGetAccessorDeclaration(node) || + ast.IsSetAccessorDeclaration(node) +} + +// Indicates whether a node is a valid a call hierarchy declaration. +// +// See `resolveCallHierarchyDeclaration` for the specific rules. +func isValidCallHierarchyDeclaration(node *ast.Node) bool { + if node == nil { + return false + } + + if ast.IsSourceFile(node) { + return true + } + + if ast.IsModuleDeclaration(node) { + return ast.IsIdentifier(node.Name()) + } + + return ast.IsFunctionDeclaration(node) || + ast.IsClassDeclaration(node) || + ast.IsClassStaticBlockDeclaration(node) || + ast.IsMethodDeclaration(node) || + ast.IsMethodSignatureDeclaration(node) || + ast.IsGetAccessorDeclaration(node) || + ast.IsSetAccessorDeclaration(node) || + isNamedExpression(node) || + isAssignedExpression(node) +} + +// Gets the node that can be used as a reference to a call hierarchy declaration. +func getCallHierarchyDeclarationReferenceNode(node *ast.Node) *ast.Node { + if node == nil { + return nil + } + + if ast.IsSourceFile(node) { + return node + } + + if name := node.Name(); name != nil { + return name + } + + if isAssignedExpression(node) { + return node.Parent.Name() + } + + if modifiers := node.Modifiers(); modifiers != nil { + for _, mod := range modifiers.Nodes { + if mod.Kind == ast.KindDefaultKeyword { + return mod + } + } + } + + debug.Assert(false, "Expected call hierarchy declaration to have a reference node") + return nil +} + +// Gets the symbol for a call hierarchy declaration. +func getSymbolOfCallHierarchyDeclaration(c *checker.Checker, node *ast.Node) *ast.Symbol { + if ast.IsClassStaticBlockDeclaration(node) { + return nil + } + location := getCallHierarchyDeclarationReferenceNode(node) + if location == nil { + return nil + } + return c.GetSymbolAtLocation(location) +} + +// Gets the text and range for the name of a call hierarchy declaration. +func getCallHierarchyItemName(program *compiler.Program, node *ast.Node) (text string, pos int, end int) { + if ast.IsSourceFile(node) { + sourceFile := node.AsSourceFile() + return sourceFile.FileName(), 0, 0 + } + + if (ast.IsFunctionDeclaration(node) || ast.IsClassDeclaration(node)) && node.Name() == nil { + if modifiers := node.Modifiers(); modifiers != nil { + for _, mod := range modifiers.Nodes { + if mod.Kind == ast.KindDefaultKeyword { + sourceFile := ast.GetSourceFileOfNode(node) + start := scanner.SkipTrivia(sourceFile.Text(), mod.Pos()) + return "default", start, mod.End() + } + } + } + } + + if ast.IsClassStaticBlockDeclaration(node) { + sourceFile := ast.GetSourceFileOfNode(node) + pos := scanner.SkipTrivia(sourceFile.Text(), moveRangePastModifiers(node).Pos()) + end := pos + 6 // "static".length + c, done := program.GetTypeCheckerForFile(context.Background(), sourceFile) + defer done() + symbol := c.GetSymbolAtLocation(node.Parent) + prefix := "" + if symbol != nil { + prefix = c.SymbolToString(symbol) + " " + } + return prefix + "static {}", pos, end + } + + var declName *ast.Node + if isAssignedExpression(node) { + declName = node.Parent.Name() + } else { + declName = ast.GetNameOfDeclaration(node) + } + + debug.AssertIsDefined(declName, "Expected call hierarchy item to have a name") + + if ast.IsIdentifier(declName) { + text = declName.Text() + } else if ast.IsStringOrNumericLiteralLike(declName) { + text = declName.Text() + } else if ast.IsComputedPropertyName(declName) { + expr := declName.Expression() + if ast.IsStringOrNumericLiteralLike(expr) { + text = expr.Text() + } + } + + if text == "" { + c, done := program.GetTypeCheckerForFile(context.Background(), ast.GetSourceFileOfNode(node)) + defer done() + symbol := c.GetSymbolAtLocation(declName) + if symbol != nil { + text = c.SymbolToString(symbol) + } + } + + // get the text from printing the node on a single line without comments... + if text == "" { + sourceFile := ast.GetSourceFileOfNode(node) + writer, putWriter := printer.GetSingleLineStringWriter() + defer putWriter() + p := printer.NewPrinter(printer.PrinterOptions{RemoveComments: true}, printer.PrintHandlers{}, nil) + p.Write(node, sourceFile, writer, nil) + text = writer.String() + } + + sourceFile := ast.GetSourceFileOfNode(node) + namePos := scanner.SkipTrivia(sourceFile.Text(), declName.Pos()) + + return text, namePos, declName.End() +} + +func getCallHierarchyItemContainerName(node *ast.Node) string { + if isAssignedExpression(node) { + parent := node.Parent + if ast.IsPropertyDeclaration(parent) && ast.IsClassLike(parent.Parent) { + if ast.IsClassExpression(parent.Parent) { + if assignedName := ast.GetAssignedName(parent.Parent); assignedName != nil { + return assignedName.Text() + } + } else { + if name := parent.Parent.Name(); name != nil { + return name.Text() + } + } + } + if ast.IsModuleBlock(parent.Parent.Parent.Parent) { + modParent := parent.Parent.Parent.Parent.Parent + if ast.IsModuleDeclaration(modParent) { + if name := modParent.Name(); name != nil && ast.IsIdentifier(name) { + return name.Text() + } + } + } + return "" + } + + switch node.Kind { + case ast.KindGetAccessor, ast.KindSetAccessor, ast.KindMethodDeclaration: + if node.Parent.Kind == ast.KindObjectLiteralExpression { + if assignedName := ast.GetAssignedName(node.Parent); assignedName != nil { + return assignedName.Text() + } + } + if name := ast.GetNameOfDeclaration(node.Parent); name != nil { + return name.Text() + } + case ast.KindFunctionDeclaration, ast.KindClassDeclaration, ast.KindModuleDeclaration: + if ast.IsModuleBlock(node.Parent) { + if ast.IsModuleDeclaration(node.Parent.Parent) { + if name := node.Parent.Parent.Name(); name != nil && ast.IsIdentifier(name) { + return name.Text() + } + } + } + } + + return "" +} + +func moveRangePastModifiers(node *ast.Node) core.TextRange { + if modifiers := node.Modifiers(); modifiers != nil && len(modifiers.Nodes) > 0 { + lastMod := modifiers.Nodes[len(modifiers.Nodes)-1] + return core.NewTextRange(lastMod.End(), node.End()) + } + return core.NewTextRange(node.Pos(), node.End()) +} + +// Finds the implementation of a function-like declaration, if one exists. +func findImplementation(c *checker.Checker, node *ast.Node) *ast.Node { + if node == nil { + return nil + } + + if !ast.IsFunctionLikeDeclaration(node) { + return node + } + + if node.Body() != nil { + return node + } + + if ast.IsConstructorDeclaration(node) { + return ast.GetFirstConstructorWithBody(node.Parent) + } + + if ast.IsFunctionDeclaration(node) || ast.IsMethodDeclaration(node) { + symbol := getSymbolOfCallHierarchyDeclaration(c, node) + if symbol != nil && symbol.ValueDeclaration != nil { + if ast.IsFunctionLikeDeclaration(symbol.ValueDeclaration) && symbol.ValueDeclaration.Body() != nil { + return symbol.ValueDeclaration + } + } + return nil + } + + return node +} + +func findAllInitialDeclarations(c *checker.Checker, node *ast.Node) []*ast.Node { + if ast.IsClassStaticBlockDeclaration(node) { + return nil + } + + symbol := getSymbolOfCallHierarchyDeclaration(c, node) + if symbol == nil || symbol.Declarations == nil { + return nil + } + + type declKey struct { + file string + pos int + } + + indices := make([]int, len(symbol.Declarations)) + for i := range indices { + indices[i] = i + } + keys := make([]declKey, len(symbol.Declarations)) + for i, decl := range symbol.Declarations { + keys[i] = declKey{ + file: ast.GetSourceFileOfNode(decl).FileName(), + pos: decl.Pos(), + } + } + + slices.SortFunc(indices, func(a, b int) int { + if keys[a].file != keys[b].file { + return strings.Compare(keys[a].file, keys[b].file) + } + return keys[a].pos - keys[b].pos + }) + + var declarations []*ast.Node + var lastDecl *ast.Node + + for _, i := range indices { + decl := symbol.Declarations[i] + if isValidCallHierarchyDeclaration(decl) { + if lastDecl == nil || lastDecl.Parent != decl.Parent || lastDecl.End() != decl.Pos() { + declarations = append(declarations, decl) + } + lastDecl = decl + } + } + + return declarations +} + +// Find the implementation or the first declaration for a call hierarchy declaration. +func findImplementationOrAllInitialDeclarations(c *checker.Checker, node *ast.Node) any { + if ast.IsClassStaticBlockDeclaration(node) { + return node + } + + if ast.IsFunctionLikeDeclaration(node) { + if impl := findImplementation(c, node); impl != nil { + return impl + } + if decls := findAllInitialDeclarations(c, node); decls != nil { + return decls + } + return node + } + + if decls := findAllInitialDeclarations(c, node); decls != nil { + return decls + } + return node +} + +// Resolves the call hierarchy declaration for a node. +func resolveCallHierarchyDeclaration(program *compiler.Program, location *ast.Node) (result any) { + // A call hierarchy item must refer to either a SourceFile, Module Declaration, Class Static Block, or something intrinsically callable that has a name: + // - Class Declarations + // - Class Expressions (with a name) + // - Function Declarations + // - Function Expressions (with a name or assigned to a const variable) + // - Arrow Functions (assigned to a const variable) + // - Constructors + // - Class `static {}` initializer blocks + // - Methods + // - Accessors + // + // If a call is contained in a non-named callable Node (function expression, arrow function, etc.), then + // its containing `CallHierarchyItem` is a containing function or SourceFile that matches the above list. + + c, done := program.GetTypeChecker(context.Background()) + defer done() + + followingSymbol := false + + for location != nil { + if isValidCallHierarchyDeclaration(location) { + return findImplementationOrAllInitialDeclarations(c, location) + } + + if isPossibleCallHierarchyDeclaration(location) { + ancestor := ast.FindAncestor(location, isValidCallHierarchyDeclaration) + if ancestor != nil { + return findImplementationOrAllInitialDeclarations(c, ancestor) + } + } + + if ast.IsDeclarationName(location) { + if isValidCallHierarchyDeclaration(location.Parent) { + return findImplementationOrAllInitialDeclarations(c, location.Parent) + } + if isPossibleCallHierarchyDeclaration(location.Parent) { + ancestor := ast.FindAncestor(location.Parent, isValidCallHierarchyDeclaration) + if ancestor != nil { + return findImplementationOrAllInitialDeclarations(c, ancestor) + } + } + if isVariableLike(location.Parent) { + initializer := location.Parent.Initializer() + if initializer != nil && isAssignedExpression(initializer) { + return initializer + } + } + return nil + } + + if ast.IsConstructorDeclaration(location) { + if isValidCallHierarchyDeclaration(location.Parent) { + return location.Parent + } + return nil + } + + if location.Kind == ast.KindStaticKeyword && ast.IsClassStaticBlockDeclaration(location.Parent) { + location = location.Parent + continue + } + + // #39453 + if ast.IsVariableDeclaration(location) { + if initializer := location.Initializer(); initializer != nil && isAssignedExpression(initializer) { + return initializer + } + } + + if !followingSymbol { + symbol := c.GetSymbolAtLocation(location) + if symbol != nil { + if (symbol.Flags & ast.SymbolFlagsAlias) != 0 { + symbol = c.GetAliasedSymbol(symbol) + } + if symbol.ValueDeclaration != nil { + followingSymbol = true + location = symbol.ValueDeclaration + continue + } + } + } + + return nil + } + + return nil +} + +// Creates a `CallHierarchyItem` for a call hierarchy declaration. +func (l *LanguageService) createCallHierarchyItem(program *compiler.Program, node *ast.Node) *lsproto.CallHierarchyItem { + sourceFile := ast.GetSourceFileOfNode(node) + nameText, namePos, nameEnd := getCallHierarchyItemName(program, node) + containerName := getCallHierarchyItemContainerName(node) + + kind := getSymbolKindFromNode(node) + + fullStart := scanner.SkipTriviaEx(sourceFile.Text(), node.Pos(), &scanner.SkipTriviaOptions{StopAtComments: true}) + script := l.getScript(sourceFile.FileName()) + span := l.converters.ToLSPRange(script, core.NewTextRange(fullStart, node.End())) + selectionSpan := l.converters.ToLSPRange(script, core.NewTextRange(namePos, nameEnd)) + + item := &lsproto.CallHierarchyItem{ + Name: nameText, + Kind: kind, + Uri: lsconv.FileNameToDocumentURI(sourceFile.FileName()), + Range: span, + SelectionRange: selectionSpan, + } + + if containerName != "" { + item.Detail = &containerName + } + + return item +} + +type callSite struct { + declaration *ast.Node + textRange core.TextRange + sourceFile *ast.Node +} + +func convertEntryToCallSite(entry *ReferenceEntry) *callSite { + if entry.kind != entryKindNode { + return nil + } + + node := entry.node + if !ast.IsCallOrNewExpressionTarget(node, true /*includeElementAccess*/, true /*skipPastOuterExpressions*/) && + !ast.IsTaggedTemplateTag(node, true, true) && + !ast.IsDecoratorTarget(node, true, true) && + !ast.IsJsxOpeningLikeElementTagName(node, true, true) && + !ast.IsRightSideOfPropertyAccess(node) && + !ast.IsArgumentExpressionOfElementAccess(node) { + return nil + } + + sourceFile := ast.GetSourceFileOfNode(node) + ancestor := ast.FindAncestor(node, isValidCallHierarchyDeclaration) + if ancestor == nil { + ancestor = sourceFile.AsNode() + } + + start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) + return &callSite{ + declaration: ancestor, + textRange: core.NewTextRange(start, node.End()), + sourceFile: sourceFile.AsNode(), + } +} + +func getCallSiteGroupKey(site *callSite) ast.NodeId { + return ast.GetNodeId(site.declaration) +} + +func (l *LanguageService) convertCallSiteGroupToIncomingCall(program *compiler.Program, entries []*callSite) *lsproto.CallHierarchyIncomingCall { + fromRanges := make([]lsproto.Range, len(entries)) + for i, entry := range entries { + script := l.getScript(entry.sourceFile.AsSourceFile().FileName()) + fromRanges[i] = l.converters.ToLSPRange(script, entry.textRange) + } + + slices.SortFunc(fromRanges, func(a, b lsproto.Range) int { + return lsproto.CompareRanges(&a, &b) + }) + + return &lsproto.CallHierarchyIncomingCall{ + From: l.createCallHierarchyItem(program, entries[0].declaration), + FromRanges: fromRanges, + } +} + +// Gets the call sites that call into the provided call hierarchy declaration. +func (l *LanguageService) getIncomingCalls(ctx context.Context, program *compiler.Program, declaration *ast.Node) []*lsproto.CallHierarchyIncomingCall { + // Source files and modules have no incoming calls. + if ast.IsSourceFile(declaration) || ast.IsModuleDeclaration(declaration) || ast.IsClassStaticBlockDeclaration(declaration) { + return nil + } + + location := getCallHierarchyDeclarationReferenceNode(declaration) + if location == nil { + return nil + } + + sourceFiles := program.GetSourceFiles() + options := refOptions{use: referenceUseReferences} + symbolsAndEntries := l.getReferencedSymbolsForNode(ctx, 0, location, program, sourceFiles, options, nil) + + var refEntries []*ReferenceEntry + for _, symbolAndEntry := range symbolsAndEntries { + refEntries = append(refEntries, symbolAndEntry.references...) + } + + var callSites []*callSite + for _, entry := range refEntries { + if site := convertEntryToCallSite(entry); site != nil { + callSites = append(callSites, site) + } + } + + if len(callSites) == 0 { + return nil + } + + grouped := make(map[ast.NodeId][]*callSite) + for _, site := range callSites { + key := getCallSiteGroupKey(site) + grouped[key] = append(grouped[key], site) + } + + var result []*lsproto.CallHierarchyIncomingCall + for _, sites := range grouped { + result = append(result, l.convertCallSiteGroupToIncomingCall(program, sites)) + } + + slices.SortFunc(result, func(a, b *lsproto.CallHierarchyIncomingCall) int { + if uriComp := strings.Compare(string(a.From.Uri), string(b.From.Uri)); uriComp != 0 { + return uriComp + } + if len(a.FromRanges) == 0 || len(b.FromRanges) == 0 { + return 0 + } + return lsproto.CompareRanges(&a.FromRanges[0], &b.FromRanges[0]) + }) + + return result +} + +type callSiteCollector struct { + program *compiler.Program + callSites []*callSite +} + +func (c *callSiteCollector) recordCallSite(node *ast.Node) { + var target *ast.Node + + switch { + case ast.IsTaggedTemplateExpression(node): + target = node.AsTaggedTemplateExpression().Tag + case ast.IsJsxOpeningElement(node): + target = node.TagName() + case ast.IsJsxSelfClosingElement(node): + target = node.TagName() + case ast.IsPropertyAccessExpression(node) || ast.IsElementAccessExpression(node): + target = node + case ast.IsClassStaticBlockDeclaration(node): + target = node + case ast.IsCallExpression(node): + target = node.Expression() + case ast.IsNewExpression(node): + target = node.Expression() + case ast.IsDecorator(node): + target = node.Expression() + } + + if target == nil { + return + } + + declaration := resolveCallHierarchyDeclaration(c.program, target) + if declaration == nil { + return + } + + sourceFile := ast.GetSourceFileOfNode(target) + start := scanner.SkipTrivia(sourceFile.Text(), target.Pos()) + textRange := core.NewTextRange(start, target.End()) + + switch decl := declaration.(type) { + case *ast.Node: + c.callSites = append(c.callSites, &callSite{ + declaration: decl, + textRange: textRange, + sourceFile: sourceFile.AsNode(), + }) + case []*ast.Node: + for _, d := range decl { + c.callSites = append(c.callSites, &callSite{ + declaration: d, + textRange: textRange, + sourceFile: sourceFile.AsNode(), + }) + } + } +} + +func (c *callSiteCollector) collect(node *ast.Node) { + if node == nil { + return + } + + // do not descend into ambient nodes. + if (node.Flags & ast.NodeFlagsAmbient) != 0 { + return + } + + // do not descend into other call site declarations, other than class member names + if isValidCallHierarchyDeclaration(node) { + if ast.IsClassLike(node) { + for _, member := range node.Members() { + if member.Name() != nil && ast.IsComputedPropertyName(member.Name()) { + c.collect(member.Name().Expression()) + } + } + } + return + } + + switch node.Kind { + case ast.KindIdentifier, + ast.KindImportEqualsDeclaration, + ast.KindImportDeclaration, + ast.KindExportDeclaration, + ast.KindInterfaceDeclaration, + ast.KindTypeAliasDeclaration: + // do not descend into nodes that cannot contain callable nodes + return + case ast.KindClassStaticBlockDeclaration: + c.recordCallSite(node) + return + case ast.KindTypeAssertionExpression, ast.KindAsExpression: + // do not descend into the type side of an assertion + c.collect(node.Expression()) + return + case ast.KindVariableDeclaration, ast.KindParameter: + // do not descend into the type of a variable or parameter declaration + c.collect(node.Name()) + c.collect(node.Initializer()) + return + case ast.KindCallExpression: + // do not descend into the type arguments of a call expression + c.recordCallSite(node) + c.collect(node.Expression()) + for _, arg := range node.Arguments() { + c.collect(arg) + } + return + case ast.KindNewExpression: + // do not descend into the type arguments of a new expression + c.recordCallSite(node) + c.collect(node.Expression()) + for _, arg := range node.Arguments() { + c.collect(arg) + } + return + case ast.KindTaggedTemplateExpression: + // do not descend into the type arguments of a tagged template expression + c.recordCallSite(node) + taggedTemplate := node.AsTaggedTemplateExpression() + c.collect(taggedTemplate.Tag) + c.collect(taggedTemplate.Template) + return + case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: + // do not descend into the type arguments of a JsxOpeningLikeElement + c.recordCallSite(node) + c.collect(node.TagName()) + c.collect(node.Attributes()) + return + case ast.KindDecorator: + c.recordCallSite(node) + c.collect(node.Expression()) + return + case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: + c.recordCallSite(node) + node.ForEachChild(func(child *ast.Node) bool { + c.collect(child) + return false + }) + return + case ast.KindSatisfiesExpression: + // do not descend into the type side of an assertion + c.collect(node.Expression()) + return + } + + if ast.IsPartOfTypeNode(node) { + // do not descend into types + return + } + + node.ForEachChild(func(child *ast.Node) bool { + c.collect(child) + return false + }) +} + +func collectCallSites(program *compiler.Program, c *checker.Checker, node *ast.Node) []*callSite { + collector := &callSiteCollector{ + program: program, + callSites: make([]*callSite, 0), + } + + switch node.Kind { + case ast.KindSourceFile: + for _, stmt := range node.Statements() { + collector.collect(stmt) + } + + case ast.KindModuleDeclaration: + if body := node.Body(); !ast.HasSyntacticModifier(node, ast.ModifierFlagsAmbient) && body != nil && ast.IsModuleBlock(body) { + for _, stmt := range body.Statements() { + collector.collect(stmt) + } + } + + case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, + ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor: + impl := findImplementation(c, node) + if impl != nil { + for _, param := range impl.Parameters() { + collector.collect(param) + } + collector.collect(impl.Body()) + } + + case ast.KindClassDeclaration, ast.KindClassExpression: + if modifiers := node.Modifiers(); modifiers != nil { + for _, mod := range modifiers.Nodes { + collector.collect(mod) + } + } + + heritage := ast.GetClassExtendsHeritageElement(node) + if heritage != nil { + collector.collect(heritage.Expression()) + } + + for _, member := range node.Members() { + if ast.CanHaveModifiers(member) && member.Modifiers() != nil { + for _, mod := range member.Modifiers().Nodes { + collector.collect(mod) + } + } + + if ast.IsPropertyDeclaration(member) { + collector.collect(member.Initializer()) + } else if ast.IsConstructorDeclaration(member) { + if body := member.Body(); body != nil { + for _, param := range member.Parameters() { + collector.collect(param) + } + collector.collect(body) + } + } else if ast.IsClassStaticBlockDeclaration(member) { + collector.collect(member) + } + } + + case ast.KindClassStaticBlockDeclaration: + staticBlock := node.AsClassStaticBlockDeclaration() + collector.collect(staticBlock.Body) + + default: + debug.AssertNever(node) + } + + return collector.callSites +} + +func (l *LanguageService) convertCallSiteGroupToOutgoingCall(program *compiler.Program, entries []*callSite) *lsproto.CallHierarchyOutgoingCall { + fromRanges := make([]lsproto.Range, len(entries)) + for i, entry := range entries { + script := l.getScript(entry.sourceFile.AsSourceFile().FileName()) + fromRanges[i] = l.converters.ToLSPRange(script, entry.textRange) + } + + slices.SortFunc(fromRanges, func(a, b lsproto.Range) int { + return lsproto.CompareRanges(&a, &b) + }) + + return &lsproto.CallHierarchyOutgoingCall{ + To: l.createCallHierarchyItem(program, entries[0].declaration), + FromRanges: fromRanges, + } +} + +// Gets the call sites that call out of the provided call hierarchy declaration. +func (l *LanguageService) getOutgoingCalls(program *compiler.Program, declaration *ast.Node) []*lsproto.CallHierarchyOutgoingCall { + if (declaration.Flags&ast.NodeFlagsAmbient) != 0 || ast.IsMethodSignatureDeclaration(declaration) { + return nil + } + + c, done := program.GetTypeChecker(context.Background()) + defer done() + + callSites := collectCallSites(program, c, declaration) + + if len(callSites) == 0 { + return nil + } + + grouped := make(map[ast.NodeId][]*callSite) + for _, site := range callSites { + key := getCallSiteGroupKey(site) + grouped[key] = append(grouped[key], site) + } + + var result []*lsproto.CallHierarchyOutgoingCall + for _, sites := range grouped { + result = append(result, l.convertCallSiteGroupToOutgoingCall(program, sites)) + } + + slices.SortFunc(result, func(a, b *lsproto.CallHierarchyOutgoingCall) int { + if uriComp := strings.Compare(string(a.To.Uri), string(b.To.Uri)); uriComp != 0 { + return uriComp + } + if len(a.FromRanges) == 0 || len(b.FromRanges) == 0 { + return 0 + } + return lsproto.CompareRanges(&a.FromRanges[0], &b.FromRanges[0]) + }) + + return result +} + +func (l *LanguageService) ProvidePrepareCallHierarchy( + ctx context.Context, + documentURI lsproto.DocumentUri, + position lsproto.Position, +) (lsproto.CallHierarchyPrepareResponse, error) { + program, file := l.getProgramAndFile(documentURI) + node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) + + if node.Kind == ast.KindSourceFile { + return lsproto.CallHierarchyItemsOrNull{}, nil + } + + declaration := resolveCallHierarchyDeclaration(program, node) + if declaration == nil { + return lsproto.CallHierarchyItemsOrNull{}, nil + } + + var items []*lsproto.CallHierarchyItem + switch decl := declaration.(type) { + case *ast.Node: + items = []*lsproto.CallHierarchyItem{l.createCallHierarchyItem(program, decl)} + case []*ast.Node: + items = make([]*lsproto.CallHierarchyItem, len(decl)) + for i, d := range decl { + items[i] = l.createCallHierarchyItem(program, d) + } + } + + if items == nil { + return lsproto.CallHierarchyItemsOrNull{}, nil + } + return lsproto.CallHierarchyItemsOrNull{CallHierarchyItems: &items}, nil +} + +func (l *LanguageService) ProvideCallHierarchyIncomingCalls( + ctx context.Context, + item *lsproto.CallHierarchyItem, +) (lsproto.CallHierarchyIncomingCallsResponse, error) { + program := l.GetProgram() + fileName := item.Uri.FileName() + file := program.GetSourceFile(fileName) + if file == nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, nil + } + + pos := int(l.converters.LineAndCharacterToPosition(file, item.SelectionRange.Start)) + var node *ast.Node + if pos == 0 { + node = file.AsNode() + } else { + node = astnav.GetTouchingPropertyName(file, pos) + } + + if node == nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, nil + } + + declaration := resolveCallHierarchyDeclaration(program, node) + if declaration == nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, nil + } + + var decl *ast.Node + switch d := declaration.(type) { + case *ast.Node: + decl = d + case []*ast.Node: + if len(d) > 0 { + decl = d[0] + } + } + + if decl == nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, nil + } + + calls := l.getIncomingCalls(ctx, program, decl) + if calls == nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, nil + } + return lsproto.CallHierarchyIncomingCallsOrNull{CallHierarchyIncomingCalls: &calls}, nil +} + +func (l *LanguageService) ProvideCallHierarchyOutgoingCalls( + ctx context.Context, + item *lsproto.CallHierarchyItem, +) (lsproto.CallHierarchyOutgoingCallsResponse, error) { + program := l.GetProgram() + fileName := item.Uri.FileName() + file := program.GetSourceFile(fileName) + if file == nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, nil + } + + pos := int(l.converters.LineAndCharacterToPosition(file, item.SelectionRange.Start)) + var node *ast.Node + if pos == 0 { + node = file.AsNode() + } else { + node = astnav.GetTouchingPropertyName(file, pos) + } + + if node == nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, nil + } + + declaration := resolveCallHierarchyDeclaration(program, node) + if declaration == nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, nil + } + + var decl *ast.Node + switch d := declaration.(type) { + case *ast.Node: + decl = d + case []*ast.Node: + if len(d) > 0 { + decl = d[0] + } + } + + if decl == nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, nil + } + + calls := l.getOutgoingCalls(program, decl) + if calls == nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, nil + } + return lsproto.CallHierarchyOutgoingCallsOrNull{CallHierarchyOutgoingCalls: &calls}, nil +} diff --git a/pkg/ls/codelens.go b/pkg/ls/codelens.go new file mode 100644 index 000000000..f6237dff9 --- /dev/null +++ b/pkg/ls/codelens.go @@ -0,0 +1,230 @@ +package ls + +import ( + "context" + + "github.com/buke/typescript-go-internal/pkg/ast" + "github.com/buke/typescript-go-internal/pkg/core" + "github.com/buke/typescript-go-internal/pkg/diagnostics" + "github.com/buke/typescript-go-internal/pkg/locale" + "github.com/buke/typescript-go-internal/pkg/ls/lsutil" + "github.com/buke/typescript-go-internal/pkg/lsp/lsproto" + "github.com/buke/typescript-go-internal/pkg/scanner" +) + +func (l *LanguageService) ProvideCodeLenses(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.CodeLensResponse, error) { + _, file := l.getProgramAndFile(documentURI) + + userPrefs := l.UserPreferences() + if !userPrefs.ReferencesCodeLensEnabled && !userPrefs.ImplementationsCodeLensEnabled { + return lsproto.CodeLensResponse{}, nil + } + + // Keeps track of the last symbol to avoid duplicating code lenses across overloads. + var lastSymbol *ast.Symbol + var result []*lsproto.CodeLens + var visit func(node *ast.Node) bool + visit = func(node *ast.Node) bool { + if ctx.Err() != nil { + return true + } + + if currentSymbol := node.Symbol(); lastSymbol != currentSymbol { + lastSymbol = currentSymbol + + if userPrefs.ReferencesCodeLensEnabled && isValidReferenceLensNode(node, userPrefs) { + result = append(result, l.newCodeLensForNode(documentURI, file, node, lsproto.CodeLensKindReferences)) + } + + if userPrefs.ImplementationsCodeLensEnabled && isValidImplementationsCodeLensNode(node, userPrefs) { + result = append(result, l.newCodeLensForNode(documentURI, file, node, lsproto.CodeLensKindImplementations)) + } + } + + savedLastSymbol := lastSymbol + node.ForEachChild(visit) + lastSymbol = savedLastSymbol + return false + } + + visit(file.AsNode()) + + return lsproto.CodeLensResponse{ + CodeLenses: &result, + }, nil +} + +func (l *LanguageService) ResolveCodeLens(ctx context.Context, codeLens *lsproto.CodeLens, showLocationsCommandName *string) (*lsproto.CodeLens, error) { + uri := codeLens.Data.Uri + _, sourceFile := l.tryGetProgramAndFile(uri.FileName()) + if sourceFile == nil || + l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(sourceFile.End())).Line < codeLens.Range.Start.Line { + // This can happen if a codeLens/resolve request comes in after a program change. + // While it's true that handlers should latch onto a specific snapshot + // while processing requests, we just set `Data.Uri` based on + // some older snapshot's contents. The content could have been modified, + // or the file itself could have been removed from the session entirely. + // Note this won't bail out on every change, but will prevent crashing + // based on non-existent files and line maps from shortened files. + return codeLens, lsproto.ErrorCodeContentModified + } + + textDoc := lsproto.TextDocumentIdentifier{ + Uri: uri, + } + locale := locale.FromContext(ctx) + var locs []lsproto.Location + var lensTitle string + switch codeLens.Data.Kind { + case lsproto.CodeLensKindReferences: + origNode, symbolsAndEntries, ok := l.ProvideSymbolsAndEntries(ctx, uri, codeLens.Range.Start, false /*isRename*/) + if ok { + references, err := l.ProvideReferencesFromSymbolAndEntries( + ctx, + &lsproto.ReferenceParams{ + TextDocument: textDoc, + Position: codeLens.Range.Start, + Context: &lsproto.ReferenceContext{ + // Don't include the declaration in the references count. + IncludeDeclaration: false, + }, + }, + origNode, + symbolsAndEntries, + ) + if err != nil { + return nil, err + } + + if references.Locations != nil { + locs = *references.Locations + } + } + + if len(locs) == 1 { + lensTitle = diagnostics.X_1_reference.Localize(locale) + } else { + lensTitle = diagnostics.X_0_references.Localize(locale, len(locs)) + } + case lsproto.CodeLensKindImplementations: + // "Force" link support to be false so that we only get `Locations` back, + // and don't include the "current" node in the results. + findImplsOptions := provideImplementationsOpts{ + requireLocationsResult: true, + dropOriginNodes: true, + } + implementations, err := l.provideImplementationsEx( + ctx, + &lsproto.ImplementationParams{ + TextDocument: textDoc, + Position: codeLens.Range.Start, + }, + findImplsOptions, + ) + if err != nil { + return nil, err + } + + if implementations.Locations != nil { + locs = *implementations.Locations + } + + if len(locs) == 1 { + lensTitle = diagnostics.X_1_implementation.Localize(locale) + } else { + lensTitle = diagnostics.X_0_implementations.Localize(locale, len(locs)) + } + } + + cmd := &lsproto.Command{ + Title: lensTitle, + } + if len(locs) > 0 && showLocationsCommandName != nil { + cmd.Command = *showLocationsCommandName + cmd.Arguments = &[]any{ + uri, + codeLens.Range.Start, + locs, + } + } + + codeLens.Command = cmd + return codeLens, nil +} + +func (l *LanguageService) newCodeLensForNode(fileUri lsproto.DocumentUri, file *ast.SourceFile, node *ast.Node, kind lsproto.CodeLensKind) *lsproto.CodeLens { + nodeForRange := node + nodeName := node.Name() + if nodeName != nil { + nodeForRange = nodeName + } + pos := scanner.SkipTrivia(file.Text(), nodeForRange.Pos()) + + return &lsproto.CodeLens{ + Range: lsproto.Range{ + Start: l.converters.PositionToLineAndCharacter(file, core.TextPos(pos)), + End: l.converters.PositionToLineAndCharacter(file, core.TextPos(node.End())), + }, + Data: &lsproto.CodeLensData{ + Kind: kind, + Uri: fileUri, + }, + } +} + +func isValidImplementationsCodeLensNode(node *ast.Node, userPrefs *lsutil.UserPreferences) bool { + switch node.Kind { + // Always show on interfaces + case ast.KindInterfaceDeclaration: + // TODO: ast.KindTypeAliasDeclaration? + return true + + // If configured, show on interface methods + case ast.KindMethodSignature: + return userPrefs.ImplementationsCodeLensShowOnInterfaceMethods && node.Parent.Kind == ast.KindInterfaceDeclaration + + // If configured, show on all class methods - but not private ones. + case ast.KindMethodDeclaration: + if userPrefs.ImplementationsCodeLensShowOnAllClassMethods && node.Parent.Kind == ast.KindClassDeclaration { + return !ast.HasModifier(node, ast.ModifierFlagsPrivate) && node.Name().Kind != ast.KindPrivateIdentifier + } + fallthrough + + // Always show on abstract classes/properties/methods + case ast.KindClassDeclaration, ast.KindConstructor, + ast.KindGetAccessor, ast.KindSetAccessor, ast.KindPropertyDeclaration: + return ast.HasModifier(node, ast.ModifierFlagsAbstract) + } + + return false +} + +func isValidReferenceLensNode(node *ast.Node, userPrefs *lsutil.UserPreferences) bool { + switch node.Kind { + case ast.KindFunctionDeclaration: + if userPrefs.ReferencesCodeLensShowOnAllFunctions { + return true + } + fallthrough + + case ast.KindVariableDeclaration: + return ast.GetCombinedModifierFlags(node)&ast.ModifierFlagsExport != 0 + + case ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindTypeAliasDeclaration, ast.KindEnumDeclaration, ast.KindEnumMember: + return true + + case ast.KindMethodDeclaration, ast.KindMethodSignature, ast.KindConstructor, + ast.KindGetAccessor, ast.KindSetAccessor, + ast.KindPropertyDeclaration, ast.KindPropertySignature: + // Don't show if child and parent have same start + // For https://github.com/microsoft/vscode/issues/90396 + // !!! + + switch node.Parent.Kind { + case ast.KindClassDeclaration, ast.KindInterfaceDeclaration, ast.KindTypeLiteral: + return true + } + } + + return false +} diff --git a/pkg/ls/completions.go b/pkg/ls/completions.go index cd667436a..d00fe3823 100644 --- a/pkg/ls/completions.go +++ b/pkg/ls/completions.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "maps" "slices" "strings" "sync" @@ -1989,7 +1988,7 @@ func (l *LanguageService) getCompletionEntriesFromSymbols( } uniqueSet := collections.NewSetWithSizeHint[string](len(uniques)) - for name := range maps.Keys(uniques) { + for name := range uniques { uniqueSet.Add(name) } return *uniqueSet, sortedEntries diff --git a/pkg/ls/findallreferences.go b/pkg/ls/findallreferences.go index 182bf94bd..5055cbda4 100644 --- a/pkg/ls/findallreferences.go +++ b/pkg/ls/findallreferences.go @@ -599,11 +599,24 @@ func (l *LanguageService) ProvideSymbolsAndEntries(ctx context.Context, uri lspr func (l *LanguageService) ProvideReferencesFromSymbolAndEntries(ctx context.Context, params *lsproto.ReferenceParams, originalNode *ast.Node, symbolsAndEntries []*SymbolAndEntries) (lsproto.ReferencesResponse, error) { // `findReferencedSymbols` except only computes the information needed to return reference locations - locations := core.FlatMap(symbolsAndEntries, l.convertSymbolAndEntriesToLocations) + locations := core.FlatMap(symbolsAndEntries, func(s *SymbolAndEntries) []lsproto.Location { + return l.convertSymbolAndEntriesToLocations(s, params.Context.IncludeDeclaration) + }) return lsproto.LocationsOrNull{Locations: &locations}, nil } func (l *LanguageService) ProvideImplementations(ctx context.Context, params *lsproto.ImplementationParams) (lsproto.ImplementationResponse, error) { + return l.provideImplementationsEx(ctx, params, provideImplementationsOpts{}) +} + +type provideImplementationsOpts struct { + // Force the result to be Location objects. + requireLocationsResult bool + // Omit node(s) containing the original position. + dropOriginNodes bool +} + +func (l *LanguageService) provideImplementationsEx(ctx context.Context, params *lsproto.ImplementationParams, opts provideImplementationsOpts) (lsproto.ImplementationResponse, error) { program, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) position := int(l.converters.LineAndCharacterToPosition(sourceFile, params.Position)) node := astnav.GetTouchingPropertyName(sourceFile, position) @@ -620,12 +633,14 @@ func (l *LanguageService) ProvideImplementations(ctx context.Context, params *ls queue = queue[1:] if !seenNodes.Has(entry.node) { seenNodes.Add(entry.node) - entries = append(entries, entry) + if !(opts.dropOriginNodes && entry.node.Loc.ContainsInclusive(position)) { + entries = append(entries, entry) + } queue = append(queue, l.getImplementationReferenceEntries(ctx, program, entry.node, entry.node.Pos())...) } } - if lsproto.GetClientCapabilities(ctx).TextDocument.Implementation.LinkSupport { + if !opts.requireLocationsResult && lsproto.GetClientCapabilities(ctx).TextDocument.Implementation.LinkSupport { links := l.convertEntriesToLocationLinks(entries) return lsproto.LocationOrLocationsOrDefinitionLinksOrNull{DefinitionLinks: &links}, nil } @@ -713,8 +728,41 @@ func (l *LanguageService) getTextForRename(originalNode *ast.Node, entry *Refere } // == functions for conversions == -func (l *LanguageService) convertSymbolAndEntriesToLocations(s *SymbolAndEntries) []lsproto.Location { - return l.convertEntriesToLocations(s.references) +func (l *LanguageService) convertSymbolAndEntriesToLocations(s *SymbolAndEntries, includeDeclarations bool) []lsproto.Location { + references := s.references + + // !!! includeDeclarations + if !includeDeclarations && s.definition != nil { + references = core.Filter(references, func(entry *ReferenceEntry) bool { + return !isDeclarationOfSymbol(entry.node, s.definition.symbol) + }) + } + + return l.convertEntriesToLocations(references) +} + +func isDeclarationOfSymbol(node *ast.Node, target *ast.Symbol) bool { + if target == nil { + return false + } + + var source *ast.Node + if decl := ast.GetDeclarationFromName(node); decl != nil { + source = decl + } else if node.Kind == ast.KindDefaultKeyword { + source = node.Parent + } else if ast.IsLiteralComputedPropertyDeclarationName(node) { + source = node.Parent.Parent + } else if node.Kind == ast.KindConstructorKeyword && ast.IsConstructorDeclaration(node.Parent) { + source = node.Parent.Parent + } + + // !!! + // const commonjsSource = source && isBinaryExpression(source) ? source.left as unknown as Declaration : undefined; + + return source != nil && core.Some(target.Declarations, func(decl *ast.Node) bool { + return decl == source + }) } func (l *LanguageService) convertEntriesToLocations(entries []*ReferenceEntry) []lsproto.Location { @@ -1421,7 +1469,7 @@ func getReferencedSymbolsForSymbol(originalSymbol *ast.Symbol, node *ast.Node, s // When renaming at an export specifier, rename the export and not the thing being exported. // state.getReferencesAtExportSpecifier(exportSpecifier.Name(), symbol, exportSpecifier.AsExportSpecifier(), state.createSearch(node, originalSymbol, comingFromUnknown /*comingFrom*/, "", nil), true /*addReferencesHere*/, true /*alwaysGetReferences*/) } else if node != nil && node.Kind == ast.KindDefaultKeyword && symbol.Name == ast.InternalSymbolNameDefault && symbol.Parent != nil { - state.addReference(node, symbol, entryKindNone) + state.addReference(node, symbol, entryKindNode) state.searchForImportsOfExport(node, symbol, &ExportInfo{exportingModuleSymbol: symbol.Parent, exportKind: ExportKindDefault}) } else { search := state.createSearch(node, symbol, ImpExpKindUnknown /*comingFrom*/, "", state.populateSearchSymbolSet(symbol, node, options.use == referenceUseRename, options.useAliasesForRename, options.implementations)) @@ -1573,33 +1621,12 @@ func getReferenceEntriesForShorthandPropertyAssignment(node *ast.Node, checker * } } -func climbPastPropertyAccess(node *ast.Node) *ast.Node { - if ast.IsRightSideOfPropertyAccess(node) { - return node.Parent - } - return node -} - -func isNewExpressionTarget(node *ast.Node) bool { - if node.Parent == nil { - return false - } - return node.Parent.Kind == ast.KindNewExpression && node.Parent.Expression() == node -} - -func isCallExpressionTarget(node *ast.Node) bool { - if node.Parent == nil { - return false - } - return node.Parent.Kind == ast.KindCallExpression && node.Parent.Expression() == node -} - func isMethodOrAccessor(node *ast.Node) bool { return node.Kind == ast.KindMethodDeclaration || node.Kind == ast.KindGetAccessor || node.Kind == ast.KindSetAccessor } func tryGetClassByExtendingIdentifier(node *ast.Node) *ast.ClassLikeDeclaration { - return ast.TryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).Parent) + return ast.TryGetClassExtendingExpressionWithTypeArguments(ast.ClimbPastPropertyAccess(node).Parent) } func getClassConstructorSymbol(classSymbol *ast.Symbol) *ast.Symbol { @@ -1632,7 +1659,7 @@ func findOwnConstructorReferences(classSymbol *ast.Symbol, sourceFile *ast.Sourc body := decl.Body() if body != nil { forEachDescendantOfKind(body, ast.KindThisKeyword, func(thisKeyword *ast.Node) { - if isNewExpressionTarget(thisKeyword) { + if ast.IsNewExpressionTarget(thisKeyword, false, false) { addNode(thisKeyword) } }) @@ -1653,7 +1680,7 @@ func findSuperConstructorAccesses(classDeclaration *ast.ClassLikeDeclaration, ad body := decl.Body() if body != nil { forEachDescendantOfKind(body, ast.KindSuperKeyword, func(node *ast.Node) { - if isCallExpressionTarget(node) { + if ast.IsCallExpressionTarget(node, false, false) { addNode(node) } }) @@ -1736,7 +1763,8 @@ func (state *refState) getReferencesInContainerOrFiles(symbol *ast.Symbol, searc // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). if scope := getSymbolScope(symbol); scope != nil { - state.getReferencesInContainer(scope, ast.GetSourceFileOfNode(scope), search /*addReferencesHere*/, !(scope.Kind == ast.KindSourceFile && !slices.Contains(state.sourceFiles, scope.AsSourceFile()))) + addReferencesHere := scope.Kind != ast.KindSourceFile || slices.Contains(state.sourceFiles, scope.AsSourceFile()) + state.getReferencesInContainer(scope, ast.GetSourceFileOfNode(scope), search, addReferencesHere) } else { // Global search for _, sourceFile := range state.sourceFiles { @@ -1853,8 +1881,8 @@ func (state *refState) getReferencesAtLocation(sourceFile *ast.SourceFile, posit } func (state *refState) addConstructorReferences(referenceLocation *ast.Node, symbol *ast.Symbol, search *refSearch, addReferencesHere bool) { - if isNewExpressionTarget(referenceLocation) && addReferencesHere { - state.addReference(referenceLocation, symbol, entryKindNone) + if ast.IsNewExpressionTarget(referenceLocation, false, false) && addReferencesHere { + state.addReference(referenceLocation, symbol, entryKindNode) } pusher := func() func(*ast.Node, entryKind) { @@ -1865,13 +1893,13 @@ func (state *refState) addConstructorReferences(referenceLocation *ast.Node, sym // This is the class declaration containing the constructor. sourceFile := ast.GetSourceFileOfNode(referenceLocation) findOwnConstructorReferences(search.symbol, sourceFile, func(n *ast.Node) { - pusher()(n, entryKindNone) + pusher()(n, entryKindNode) }) } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. if classExtending := tryGetClassByExtendingIdentifier(referenceLocation); classExtending != nil { findSuperConstructorAccesses(classExtending, func(n *ast.Node) { - pusher()(n, entryKindNone) + pusher()(n, entryKindNode) }) state.findInheritedConstructorReferences(classExtending) } @@ -1880,7 +1908,7 @@ func (state *refState) addConstructorReferences(referenceLocation *ast.Node, sym func (state *refState) addClassStaticThisReferences(referenceLocation *ast.Node, symbol *ast.Symbol, search *refSearch, addReferencesHere bool) { if addReferencesHere { - state.addReference(referenceLocation, symbol, entryKindNone) + state.addReference(referenceLocation, symbol, entryKindNode) } classLike := referenceLocation.Parent @@ -1902,7 +1930,7 @@ func (state *refState) addClassStaticThisReferences(referenceLocation *ast.Node, var cb func(*ast.Node) cb = func(node *ast.Node) { if node.Kind == ast.KindThisKeyword { - addRef(node, entryKindNone) + addRef(node, entryKindNode) } else if !ast.IsFunctionLike(node) && !ast.IsClassLike(node) { node.ForEachChild(func(child *ast.Node) bool { cb(child) @@ -2017,7 +2045,7 @@ func (state *refState) getReferenceForShorthandProperty(referenceSymbol *ast.Sym // the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the // position of property accessing, the referenceEntry of such position will be handled in the first case. if name != nil && search.includes(shorthandValueSymbol) { - state.addReference(name, shorthandValueSymbol, entryKindNone) + state.addReference(name, shorthandValueSymbol, entryKindNode) } } @@ -2163,7 +2191,7 @@ func (state *refState) forEachRelatedSymbol( } if res := fromRoot(symbol); res != nil { - return res, entryKindNone + return res, entryKindNode } if symbol.ValueDeclaration != nil && ast.IsParameterPropertyDeclaration(symbol.ValueDeclaration, symbol.ValueDeclaration.Parent) { @@ -2176,7 +2204,7 @@ func (state *refState) forEachRelatedSymbol( if !(paramProp1.Flags&ast.SymbolFlagsFunctionScopedVariable != 0 && paramProp2.Flags&ast.SymbolFlagsProperty != 0) { panic("Expected a parameter and a property") } - return fromRoot(core.IfElse(symbol.Flags&ast.SymbolFlagsFunctionScopedVariable != 0, paramProp2, paramProp1)), entryKindNone + return fromRoot(core.IfElse(symbol.Flags&ast.SymbolFlagsFunctionScopedVariable != 0, paramProp2, paramProp1)), entryKindNode } if exportSpecifier := ast.GetDeclarationOfKind(symbol, ast.KindExportSpecifier); exportSpecifier != nil && (!isForRenamePopulateSearchSymbolSet || exportSpecifier.PropertyName() == nil) { diff --git a/pkg/ls/lsutil/userpreferences.go b/pkg/ls/lsutil/userpreferences.go index 42379361c..87f340d41 100644 --- a/pkg/ls/lsutil/userpreferences.go +++ b/pkg/ls/lsutil/userpreferences.go @@ -145,6 +145,14 @@ type UserPreferences struct { IncludeInlayFunctionLikeReturnTypeHints bool IncludeInlayEnumMemberValueHints bool + // ------- CodeLens ------- + + ReferencesCodeLensEnabled bool + ImplementationsCodeLensEnabled bool + ReferencesCodeLensShowOnAllFunctions bool + ImplementationsCodeLensShowOnInterfaceMethods bool + ImplementationsCodeLensShowOnAllClassMethods bool + // ------- Symbols ------- ExcludeLibrarySymbolsInNavTo bool @@ -381,6 +389,10 @@ func (p *UserPreferences) parseWorker(config map[string]any) { continue case "inlayHints": p.parseInlayHints(values) + case "referencesCodeLens": + p.parseReferencesCodeLens(values) + case "implementationsCodeLens": + p.parseImplementationsCodeLens(values) case "suggest": p.parseSuggest(values) case "preferences": @@ -444,6 +456,38 @@ func (p *UserPreferences) parseInlayHints(prefs any) { } } +func (p *UserPreferences) parseReferencesCodeLens(prefs any) { + referencesCodeLens, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range referencesCodeLens { + switch name { + case "enabled": + p.set("referencesCodeLensEnabled", value) + case "showOnAllFunctions": + p.set("referencesCodeLensShowOnAllFunctions", value) + } + } +} + +func (p *UserPreferences) parseImplementationsCodeLens(prefs any) { + implementationsCodeLens, ok := prefs.(map[string]any) + if !ok { + return + } + for name, value := range implementationsCodeLens { + switch name { + case "enabled": + p.set("implementationsCodeLensEnabled", value) + case "showOnInterfaceMethods": + p.set("implementationsCodeLensShowOnInterfaceMethods", value) + case "showOnAllClassMethods": + p.set("implementationsCodeLensShowOnAllClassMethods", value) + } + } +} + func (p *UserPreferences) parseSuggest(prefs any) { completionsPreferences, ok := prefs.(map[string]any) if !ok { @@ -655,5 +699,15 @@ func (p *UserPreferences) set(name string, value any) { p.DisplayPartsForJSDoc = parseBoolWithDefault(value, true) case "reportstylechecksaswarnings": p.ReportStyleChecksAsWarnings = parseBoolWithDefault(value, true) + case "referencescodelensenabled": + p.ReferencesCodeLensEnabled = parseBoolWithDefault(value, false) + case "implementationscodelensenabled": + p.ImplementationsCodeLensEnabled = parseBoolWithDefault(value, false) + case "referencescodelensshowonallfunctions": + p.ReferencesCodeLensShowOnAllFunctions = parseBoolWithDefault(value, false) + case "implementationscodelensshowoninterfacemethods": + p.ImplementationsCodeLensShowOnInterfaceMethods = parseBoolWithDefault(value, false) + case "implementationscodelensshowonallclassmethods": + p.ImplementationsCodeLensShowOnAllClassMethods = parseBoolWithDefault(value, false) } } diff --git a/pkg/ls/signaturehelp.go b/pkg/ls/signaturehelp.go index 07a7ab33b..89f8908fa 100644 --- a/pkg/ls/signaturehelp.go +++ b/pkg/ls/signaturehelp.go @@ -111,7 +111,7 @@ func (l *LanguageService) GetSignatureHelpItems( onlyUseSyntacticOwners := triggerReasonKind == signatureHelpTriggerReasonKindCharacterTyped // Bail out quickly in the middle of a string or comment, don't provide signature help unless the user explicitly requested it. - if onlyUseSyntacticOwners && IsInString(sourceFile, position, startingToken) { // isInComment(sourceFile, position) needs formatting implemented + if onlyUseSyntacticOwners && (IsInString(sourceFile, position, startingToken) || isInComment(sourceFile, position, startingToken) != nil) { return nil } @@ -121,17 +121,23 @@ func (l *LanguageService) GetSignatureHelpItems( return nil } - // cancellationToken.throwIfCancellationRequested(); + if ctx.Err() != nil { + return nil + } // Extra syntactic and semantic filtering of signature help candidateInfo := getCandidateOrTypeInfo(argumentInfo, typeChecker, sourceFile, startingToken, onlyUseSyntacticOwners) - // cancellationToken.throwIfCancellationRequested(); + + if ctx.Err() != nil { + return nil + } if candidateInfo == nil { - // !!! - // // We didn't have any sig help items produced by the TS compiler. If this is a JS - // // file, then see if we can figure out anything better. - // return isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; + // For JS files, try a fallback that searches all source files for declarations + // with matching names that have call signatures. This is a heuristic for untyped JS code. + if ast.IsSourceFileJS(sourceFile) { + return l.createJSSignatureHelpItems(ctx, argumentInfo, program, typeChecker) + } return nil } @@ -139,34 +145,49 @@ func (l *LanguageService) GetSignatureHelpItems( if candidateInfo.candidateInfo != nil { return l.createSignatureHelpItems(ctx, candidateInfo.candidateInfo.candidates, candidateInfo.candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker, onlyUseSyntacticOwners) } - return createTypeHelpItems(candidateInfo.typeInfo, argumentInfo, sourceFile, typeChecker) + return createTypeHelpItems(ctx, candidateInfo.typeInfo, argumentInfo, sourceFile, typeChecker) } -func createTypeHelpItems(symbol *ast.Symbol, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker) *lsproto.SignatureHelp { +func createTypeHelpItems(ctx context.Context, symbol *ast.Symbol, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker) *lsproto.SignatureHelp { typeParameters := c.GetLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) if typeParameters == nil { return nil } item := getTypeHelpItem(symbol, typeParameters, getEnclosingDeclarationFromInvocation(argumentInfo.invocation), sourceFile, c) + // Check client capabilities for activeParameter handling + caps := lsproto.GetClientCapabilities(ctx) + sigInfoCaps := caps.TextDocument.SignatureHelp.SignatureInformation + supportsPerSignatureActiveParam := sigInfoCaps.ActiveParameterSupport + // Converting signatureHelpParameter to *lsproto.ParameterInformation parameters := make([]*lsproto.ParameterInformation, len(item.Parameters)) for i, param := range item.Parameters { parameters[i] = param.parameterInfo } - signatureInformation := []*lsproto.SignatureInformation{ - { - Label: item.Label, - Documentation: nil, - Parameters: ¶meters, - }, + + sigInfo := &lsproto.SignatureInformation{ + Label: item.Label, + Documentation: nil, + Parameters: ¶meters, } - return &lsproto.SignatureHelp{ - Signatures: signatureInformation, + // If client supports per-signature activeParameter, set it on SignatureInformation + if supportsPerSignatureActiveParam && len(item.Parameters) > 0 { + sigInfo.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(argumentInfo.argumentIndex))} + } + + help := &lsproto.SignatureHelp{ + Signatures: []*lsproto.SignatureInformation{sigInfo}, ActiveSignature: ptrTo(uint32(0)), - ActiveParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(argumentInfo.argumentIndex))}, } + + // If client doesn't support per-signature activeParameter, set it on the top-level SignatureHelp + if !supportsPerSignatureActiveParam && len(item.Parameters) > 0 { + help.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(argumentInfo.argumentIndex))} + } + + return help } func getTypeHelpItem(symbol *ast.Symbol, typeParameter []*checker.Type, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, c *checker.Checker) signatureInformation { @@ -199,6 +220,60 @@ func getTypeHelpItem(symbol *ast.Symbol, typeParameter []*checker.Type, enclosin } } +// createJSSignatureHelpItems is a fallback for JavaScript files when normal signature help +// doesn't produce results. It searches all source files for declarations with matching names +// that have call signatures. +func (l *LanguageService) createJSSignatureHelpItems(ctx context.Context, argumentInfo *argumentListInfo, program *compiler.Program, c *checker.Checker) *lsproto.SignatureHelp { + if argumentInfo.invocation.contextualInvocation != nil { + return nil + } + // See if we can find some symbol with the call expression name that has call signatures. + expression := getExpressionFromInvocation(argumentInfo) + if !ast.IsPropertyAccessExpression(expression) { + return nil + } + name := expression.AsPropertyAccessExpression().Name().Text() + if name == "" { + return nil + } + + for _, sf := range program.GetSourceFiles() { + result := l.findSignatureHelpFromNamedDeclarations(ctx, sf, name, argumentInfo, c) + if result != nil { + return result + } + } + return nil +} + +func (l *LanguageService) findSignatureHelpFromNamedDeclarations(ctx context.Context, sourceFile *ast.SourceFile, name string, argumentInfo *argumentListInfo, c *checker.Checker) *lsproto.SignatureHelp { + var result *lsproto.SignatureHelp + var visit func(node *ast.Node) bool + visit = func(node *ast.Node) bool { + if result != nil { + return true + } + if ast.GetDeclarationName(node) == name { + if symbol := node.Symbol(); symbol != nil { + if t := c.GetTypeOfSymbolAtLocation(symbol, node); t != nil { + if callSignatures := c.GetCallSignatures(t); len(callSignatures) > 0 { + result = l.createSignatureHelpItems(ctx, callSignatures, callSignatures[0], argumentInfo, sourceFile, c, true /*useFullPrefix*/) + if result != nil { + return true + } + } + } + } + } + node.ForEachChild(func(child *ast.Node) bool { + return visit(child) + }) + return result != nil + } + visit(sourceFile.AsNode()) + return result +} + func (l *LanguageService) createSignatureHelpItems(ctx context.Context, candidates []*checker.Signature, resolvedSignature *checker.Signature, argumentInfo *argumentListInfo, sourceFile *ast.SourceFile, c *checker.Checker, useFullPrefix bool) *lsproto.SignatureHelp { caps := lsproto.GetClientCapabilities(ctx) docFormat := lsproto.PreferredMarkupKind(caps.TextDocument.SignatureHelp.SignatureInformation.DocumentationFormat) @@ -219,7 +294,11 @@ func (l *LanguageService) createSignatureHelpItems(ctx context.Context, candidat var callTargetDisplayParts strings.Builder if callTargetSymbol != nil { - callTargetDisplayParts.WriteString(c.SymbolToString(callTargetSymbol)) + if useFullPrefix { + callTargetDisplayParts.WriteString(c.SymbolToStringEx(callTargetSymbol, sourceFile.AsNode(), ast.SymbolFlagsNone, checker.SymbolFormatFlagsUseAliasDefinedOutsideCurrentScope)) + } else { + callTargetDisplayParts.WriteString(c.SymbolToString(callTargetSymbol)) + } } items := make([][]signatureInformation, len(candidates)) for i, candidateSignature := range candidates { @@ -255,6 +334,11 @@ func (l *LanguageService) createSignatureHelpItems(ctx context.Context, candidat return nil } + // Check client capabilities for activeParameter handling + sigInfoCaps := caps.TextDocument.SignatureHelp.SignatureInformation + supportsPerSignatureActiveParam := sigInfoCaps.ActiveParameterSupport + supportsNullActiveParam := sigInfoCaps.NoActiveParameterSupport + // Converting []signatureInformation to []*lsproto.SignatureInformation signatureInformation := make([]*lsproto.SignatureInformation, len(flattenedSignatures)) for i, item := range flattenedSignatures { @@ -271,33 +355,64 @@ func (l *LanguageService) createSignatureHelpItems(ctx context.Context, candidat }, } } - signatureInformation[i] = &lsproto.SignatureInformation{ + sigInfo := &lsproto.SignatureInformation{ Label: item.Label, Documentation: documentation, Parameters: ¶meters, } + + // If client supports per-signature activeParameter, set it on each SignatureInformation + if supportsPerSignatureActiveParam { + sigInfo.ActiveParameter = l.computeActiveParameter(item, argumentInfo.argumentIndex, supportsNullActiveParam) + } + + signatureInformation[i] = sigInfo } help := &lsproto.SignatureHelp{ Signatures: signatureInformation, ActiveSignature: ptrTo(uint32(selectedItemIndex)), - ActiveParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(argumentInfo.argumentIndex))}, } - activeSignature := flattenedSignatures[selectedItemIndex] - if activeSignature.IsVariadic { - firstRest := core.FindIndex(activeSignature.Parameters, func(p signatureHelpParameter) bool { + // If client doesn't support per-signature activeParameter, set it on the top-level SignatureHelp + if !supportsPerSignatureActiveParam { + activeSignature := flattenedSignatures[selectedItemIndex] + help.ActiveParameter = l.computeActiveParameter(activeSignature, argumentInfo.argumentIndex, supportsNullActiveParam) + } + + return help +} + +// computeActiveParameter calculates the active parameter index for a signature, +// handling variadic signatures and null support appropriately. +func (l *LanguageService) computeActiveParameter(sig signatureInformation, argumentIndex int, supportsNull bool) *lsproto.UintegerOrNull { + paramCount := len(sig.Parameters) + if paramCount == 0 { + // No parameters, return nil (omit the field) + return nil + } + + activeParam := uint32(argumentIndex) + + if sig.IsVariadic { + firstRest := core.FindIndex(sig.Parameters, func(p signatureHelpParameter) bool { return p.isRest }) - if -1 < firstRest && firstRest < len(activeSignature.Parameters)-1 { - // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL - help.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(len(activeSignature.Parameters)))} + if -1 < firstRest && firstRest < paramCount-1 { + // Middle rest parameter - we can't accurately highlight, so indicate "no active parameter" + if supportsNull { + return &lsproto.UintegerOrNull{} // null means "no parameter is active" + } + // Client doesn't support null, use out-of-range index (defaults to 0 per LSP spec) + return &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(paramCount))} } - if help.ActiveParameter != nil && help.ActiveParameter.Uinteger != nil && *help.ActiveParameter.Uinteger > uint32(len(activeSignature.Parameters)-1) { - help.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(len(activeSignature.Parameters) - 1))} + // Clamp to last parameter for trailing rest parameters + if activeParam > uint32(paramCount-1) { + activeParam = uint32(paramCount - 1) } } - return help + + return &lsproto.UintegerOrNull{Uinteger: ptrTo(activeParam)} } func (l *LanguageService) getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool, callTargetSymbol string, enclosingDeclaration *ast.Node, sourceFile *ast.SourceFile, c *checker.Checker, docFormat lsproto.MarkupKind) []signatureInformation { @@ -556,6 +671,9 @@ func getCandidateOrTypeInfo(info *argumentListInfo, c *checker.Checker, sourceFi return nil } resolvedSignature, candidates := checker.GetResolvedSignatureForSignatureHelp(info.invocation.callInvocation.node, info.argumentCount, c) + if len(candidates) == 0 { + return nil + } return &CandidateOrTypeInfo{ candidateInfo: &candidateInfo{ candidates: candidates, @@ -598,7 +716,7 @@ func getCandidateOrTypeInfo(info *argumentListInfo, c *checker.Checker, sourceFi return nil } -func isSyntacticOwner(startingToken *ast.Node, node *ast.CallLikeExpression, sourceFile *ast.SourceFile) bool { // !!! not tested +func isSyntacticOwner(startingToken *ast.Node, node *ast.CallLikeExpression, sourceFile *ast.SourceFile) bool { if !ast.IsCallOrNewExpression(node) { return false } @@ -622,13 +740,12 @@ func containsPrecedingToken(startingToken *ast.Node, sourceFile *ast.SourceFile, // multiple nested levels. currentParent := startingToken.Parent for currentParent != nil { - precedingToken := astnav.FindPrecedingToken(sourceFile, pos) + precedingToken := astnav.FindPrecedingTokenEx(sourceFile, pos, currentParent, true /*excludeJSDoc*/) if precedingToken != nil { return RangeContainsRange(container.Loc, precedingToken.Loc) } currentParent = currentParent.Parent } - // return Debug.fail("Could not find preceding token"); return false } @@ -966,7 +1083,7 @@ func getArgumentOrParameterListAndIndex(node *ast.Node, sourceFile *ast.SourceFi } } -func getChildListThatStartsWithOpenerToken(parent *ast.Node, openerToken *ast.Node) *ast.NodeList { //!!! +func getChildListThatStartsWithOpenerToken(parent *ast.Node, openerToken *ast.Node) *ast.NodeList { if ast.IsCallExpression(parent) { parentCallExpression := parent.AsCallExpression() if openerToken.Kind == ast.KindLessThanToken { diff --git a/pkg/ls/symbols.go b/pkg/ls/symbols.go index fca82a186..807c25792 100644 --- a/pkg/ls/symbols.go +++ b/pkg/ls/symbols.go @@ -350,35 +350,53 @@ func compareDeclarationInfos(d1, d2 DeclarationInfo) int { return d1.declaration.Pos() - d2.declaration.Pos() } +// getSymbolKindFromNode converts an AST node to an LSP SymbolKind. +// Combines getNodeKind with VS Code's fromProtocolScriptElementKind. func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { switch node.Kind { + case ast.KindSourceFile: + if ast.IsExternalModule(node.AsSourceFile()) { + return lsproto.SymbolKindModule + } + return lsproto.SymbolKindFile case ast.KindModuleDeclaration: - return lsproto.SymbolKindNamespace - case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindTypeAliasDeclaration: + return lsproto.SymbolKindModule + case ast.KindClassDeclaration, ast.KindClassExpression: + return lsproto.SymbolKindClass + case ast.KindInterfaceDeclaration: + return lsproto.SymbolKindInterface + case ast.KindTypeAliasDeclaration: return lsproto.SymbolKindClass + case ast.KindEnumDeclaration: + return lsproto.SymbolKindEnum + case ast.KindVariableDeclaration: + return lsproto.SymbolKindVariable + case ast.KindArrowFunction, ast.KindFunctionDeclaration, ast.KindFunctionExpression: + return lsproto.SymbolKindFunction + case ast.KindGetAccessor, ast.KindSetAccessor: + return lsproto.SymbolKindProperty case ast.KindMethodDeclaration, ast.KindMethodSignature: return lsproto.SymbolKindMethod - case ast.KindPropertyDeclaration, ast.KindPropertySignature, ast.KindGetAccessor, ast.KindSetAccessor: + case ast.KindPropertyDeclaration, ast.KindPropertySignature: return lsproto.SymbolKindProperty - case ast.KindConstructor, ast.KindConstructSignature: + case ast.KindIndexSignature, ast.KindCallSignature: + return lsproto.SymbolKindMethod + case ast.KindConstructSignature: + return lsproto.SymbolKindConstructor + case ast.KindConstructor, ast.KindClassStaticBlockDeclaration: return lsproto.SymbolKindConstructor - case ast.KindEnumDeclaration: - return lsproto.SymbolKindEnum - case ast.KindInterfaceDeclaration: - return lsproto.SymbolKindInterface - case ast.KindFunctionDeclaration, ast.KindFunctionExpression: - return lsproto.SymbolKindFunction - case ast.KindEnumMember: - return lsproto.SymbolKindEnumMember case ast.KindTypeParameter: return lsproto.SymbolKindTypeParameter + case ast.KindEnumMember: + return lsproto.SymbolKindEnumMember case ast.KindParameter: if ast.HasSyntacticModifier(node, ast.ModifierFlagsParameterPropertyModifier) { return lsproto.SymbolKindProperty } return lsproto.SymbolKindVariable case ast.KindBinaryExpression: - switch ast.GetAssignmentDeclarationKind(node.AsBinaryExpression()) { + kind := ast.GetAssignmentDeclarationKind(node.AsBinaryExpression()) + switch kind { case ast.JSDeclarationKindThisProperty, ast.JSDeclarationKindProperty: return lsproto.SymbolKindProperty } diff --git a/pkg/lsp/lsproto/_generate/generate.mts b/pkg/lsp/lsproto/_generate/generate.mts index 43a78e3a2..546af5759 100644 --- a/pkg/lsp/lsproto/_generate/generate.mts +++ b/pkg/lsp/lsproto/_generate/generate.mts @@ -6,6 +6,7 @@ import path from "node:path"; import url from "node:url"; import which from "which"; import type { + Enumeration, MetaModel, Notification, OrType, @@ -40,6 +41,12 @@ const customStructures: Structure[] = [ optional: true, documentation: "DisablePushDiagnostics disables automatic pushing of diagnostics to the client.", }, + { + name: "codeLensShowLocationsCommandName", + type: { kind: "base", name: "string" }, + optional: true, + documentation: "The client-side command name that resolved references/implementations `CodeLens` should trigger. Arguments passed will be `(DocumentUri, Position, Location[])`.", + }, ], documentation: "InitializationOptions contains user-provided initialization options.", }, @@ -151,6 +158,41 @@ const customStructures: Structure[] = [ ], documentation: "CompletionItemData is preserved on a CompletionItem between CompletionRequest and CompletionResolveRequest.", }, + { + name: "CodeLensData", + properties: [ + { + name: "kind", + type: { kind: "reference", name: "CodeLensKind" }, + documentation: `The kind of the code lens ("references" or "implementations").`, + }, + { + name: "uri", + type: { kind: "base", name: "DocumentUri" }, + documentation: `The document in which the code lens and its range are located.`, + }, + ], + }, +]; + +const customEnumerations: Enumeration[] = [ + { + name: "CodeLensKind", + type: { + kind: "base", + name: "string", + }, + values: [ + { + name: "References", + value: "references", + }, + { + name: "Implementations", + value: "implementations", + }, + ], + }, ]; // Track which custom Data structures were declared explicitly @@ -251,7 +293,8 @@ function patchAndPreprocessModel() { }); } - // Add custom structures and synthetic structures to the model + // Add custom enumerations, custom structures, and synthetic structures to the model + model.enumerations.push(...customEnumerations); model.structures.push(...customStructures, ...syntheticStructures); // Build structure map for preprocessing @@ -306,6 +349,29 @@ function patchAndPreprocessModel() { // Remove _InitializeParams structure after flattening (it was only needed for inheritance) model.structures = model.structures.filter(s => s.name !== "_InitializeParams"); + + // Merge LSPErrorCodes into ErrorCodes and remove LSPErrorCodes + const errorCodesEnum = model.enumerations.find(e => e.name === "ErrorCodes"); + const lspErrorCodesEnum = model.enumerations.find(e => e.name === "LSPErrorCodes"); + if (errorCodesEnum && lspErrorCodesEnum) { + // Merge LSPErrorCodes values into ErrorCodes + errorCodesEnum.values.push(...lspErrorCodesEnum.values); + // Remove LSPErrorCodes from the model + model.enumerations = model.enumerations.filter(e => e.name !== "LSPErrorCodes"); + } + + // Singularize plural enum names (e.g., "ErrorCodes" -> "ErrorCode") + for (const enumeration of model.enumerations) { + if (enumeration.name.endsWith("Codes")) { + enumeration.name = enumeration.name.slice(0, -1); // "Codes" -> "Code" + } + else if (enumeration.name.endsWith("Modifiers")) { + enumeration.name = enumeration.name.slice(0, -1); // "Modifiers" -> "Modifier" + } + else if (enumeration.name.endsWith("Types")) { + enumeration.name = enumeration.name.slice(0, -1); // "Types" -> "Type" + } + } } patchAndPreprocessModel(); @@ -1051,7 +1117,7 @@ function generateCode() { value: String(value.value), numericValue: Number(value.value), name: value.name, - identifier: `${enumeration.name}${value.name}`, + identifier: `${enumeration.name}${titleCase(value.name)}`, documentation: value.documentation, deprecated: value.deprecated, })); @@ -1264,6 +1330,14 @@ function generateCode() { } } } + + // Generate Error() method for ErrorCode to implement the error interface + if (enumeration.name === "ErrorCode") { + writeLine(`func (e ${enumeration.name}) Error() string {`); + writeLine(`\treturn e.String()`); + writeLine(`}`); + writeLine(""); + } } const requestsAndNotifications: (Request | Notification)[] = [...model.requests, ...model.notifications]; diff --git a/pkg/lsp/lsproto/baseproto.go b/pkg/lsp/lsproto/baseproto.go index a954c9328..fa06755ca 100644 --- a/pkg/lsp/lsproto/baseproto.go +++ b/pkg/lsp/lsproto/baseproto.go @@ -90,51 +90,3 @@ func (w *BaseWriter) Write(data []byte) error { } return w.w.Flush() } - -type ErrorCode struct { //nolint:errname - Name string - Code int32 -} - -func (e *ErrorCode) Error() string { - return e.Name -} - -var ( - // Defined by JSON-RPC - ErrParseError = &ErrorCode{"ParseError", -32700} - ErrInvalidRequest = &ErrorCode{"InvalidRequest", -32600} - ErrMethodNotFound = &ErrorCode{"MethodNotFound", -32601} - ErrInvalidParams = &ErrorCode{"InvalidParams", -32602} - ErrInternalError = &ErrorCode{"InternalError", -32603} - - // Error code indicating that a server received a notification or - // request before the server has received the `initialize` request. - ErrServerNotInitialized = &ErrorCode{"ServerNotInitialized", -32002} - ErrUnknownErrorCode = &ErrorCode{"UnknownErrorCode", -32001} - - // A request failed but it was syntactically correct, e.g the - // method name was known and the parameters were valid. The error - // message should contain human readable information about why - // the request failed. - ErrRequestFailed = &ErrorCode{"RequestFailed", -32803} - - // The server cancelled the request. This error code should - // only be used for requests that explicitly support being - // server cancellable. - ErrServerCancelled = &ErrorCode{"ServerCancelled", -32802} - - // The server detected that the content of a document got - // modified outside normal conditions. A server should - // NOT send this error code if it detects a content change - // in it unprocessed messages. The result even computed - // on an older state might still be useful for the client. - // - // If a client decides that a result is not of any use anymore - // the client should cancel the request. - ErrContentModified = &ErrorCode{"ContentModified", -32801} - - // The client has canceled a request and a server has detected - // the cancel. - ErrRequestCancelled = &ErrorCode{"RequestCancelled", -32800} -) diff --git a/pkg/lsp/lsproto/jsonrpc.go b/pkg/lsp/lsproto/jsonrpc.go index 19d75ac8a..e07e23206 100644 --- a/pkg/lsp/lsproto/jsonrpc.go +++ b/pkg/lsp/lsproto/jsonrpc.go @@ -111,7 +111,7 @@ func (m *Message) UnmarshalJSON(data []byte) error { Error *ResponseError `json:"error,omitzero"` } if err := json.Unmarshal(data, &raw); err != nil { - return fmt.Errorf("%w: %w", ErrInvalidRequest, err) + return fmt.Errorf("%w: %w", ErrorCodeInvalidRequest, err) } if raw.ID != nil && raw.Method == "" { m.Kind = MessageKindResponse @@ -128,7 +128,7 @@ func (m *Message) UnmarshalJSON(data []byte) error { if len(raw.Params) > 0 { params, err = unmarshalParams(raw.Method, raw.Params) if err != nil { - return fmt.Errorf("%w: %w", ErrInvalidRequest, err) + return fmt.Errorf("%w: %w", ErrorCodeInvalidRequest, err) } } @@ -173,7 +173,7 @@ func (r *RequestMessage) UnmarshalJSON(data []byte) error { Params jsontext.Value `json:"params"` } if err := json.Unmarshal(data, &raw); err != nil { - return fmt.Errorf("%w: %w", ErrInvalidRequest, err) + return fmt.Errorf("%w: %w", ErrorCodeInvalidRequest, err) } r.ID = raw.ID @@ -182,7 +182,7 @@ func (r *RequestMessage) UnmarshalJSON(data []byte) error { var err error r.Params, err = unmarshalParams(raw.Method, raw.Params) if err != nil { - return fmt.Errorf("%w: %w", ErrInvalidRequest, err) + return fmt.Errorf("%w: %w", ErrorCodeInvalidRequest, err) } return nil diff --git a/pkg/lsp/lsproto/lsp_generated.go b/pkg/lsp/lsproto/lsp_generated.go index 8c5585ee6..584527432 100644 --- a/pkg/lsp/lsproto/lsp_generated.go +++ b/pkg/lsp/lsproto/lsp_generated.go @@ -21595,6 +21595,9 @@ type ClientSemanticTokensRequestFullDelta struct { type InitializationOptions struct { // DisablePushDiagnostics disables automatic pushing of diagnostics to the client. DisablePushDiagnostics *bool `json:"disablePushDiagnostics,omitzero"` + + // The client-side command name that resolved references/implementations `CodeLens` should trigger. Arguments passed will be `(DocumentUri, Position, Location[])`. + CodeLensShowLocationsCommandName *string `json:"codeLensShowLocationsCommandName,omitzero"` } // ExportInfoMapKey uniquely identifies an export for auto-import purposes. @@ -21651,6 +21654,70 @@ type CompletionItemData struct { AutoImport *AutoImportData `json:"autoImport,omitzero"` } +type CodeLensData struct { + // The kind of the code lens ("references" or "implementations"). + Kind CodeLensKind `json:"kind"` + + // The document in which the code lens and its range are located. + Uri DocumentUri `json:"uri"` +} + +var _ json.UnmarshalerFrom = (*CodeLensData)(nil) + +func (s *CodeLensData) UnmarshalJSONFrom(dec *jsontext.Decoder) error { + const ( + missingKind uint = 1 << iota + missingUri + _missingLast + ) + missing := _missingLast - 1 + + if k := dec.PeekKind(); k != '{' { + return fmt.Errorf("expected object start, but encountered %v", k) + } + if _, err := dec.ReadToken(); err != nil { + return err + } + + for dec.PeekKind() != '}' { + name, err := dec.ReadValue() + if err != nil { + return err + } + switch string(name) { + case `"kind"`: + missing &^= missingKind + if err := json.UnmarshalDecode(dec, &s.Kind); err != nil { + return err + } + case `"uri"`: + missing &^= missingUri + if err := json.UnmarshalDecode(dec, &s.Uri); err != nil { + return err + } + default: + // Ignore unknown properties. + } + } + + if _, err := dec.ReadToken(); err != nil { + return err + } + + if missing != 0 { + var missingProps []string + if missing&missingKind != 0 { + missingProps = append(missingProps, "kind") + } + if missing&missingUri != 0 { + missingProps = append(missingProps, "uri") + } + return fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", ")) + } + + return nil +} + // CallHierarchyItemData is a placeholder for custom data preserved on a CallHierarchyItem. type CallHierarchyItemData struct{} @@ -21666,9 +21733,6 @@ type CodeActionData struct{} // WorkspaceSymbolData is a placeholder for custom data preserved on a WorkspaceSymbol. type WorkspaceSymbolData struct{} -// CodeLensData is a placeholder for custom data preserved on a CodeLens. -type CodeLensData struct{} - // DocumentLinkData is a placeholder for custom data preserved on a DocumentLink. type DocumentLinkData struct{} @@ -21745,37 +21809,37 @@ func (s *ColorPresentationRegistrationOptions) UnmarshalJSONFrom(dec *jsontext.D // corresponding client capabilities. // // Since: 3.16.0 -type SemanticTokenTypes string +type SemanticTokenType string const ( - SemanticTokenTypesnamespace SemanticTokenTypes = "namespace" + SemanticTokenTypeNamespace SemanticTokenType = "namespace" // Represents a generic type. Acts as a fallback for types which can't be mapped to // a specific type like class or enum. - SemanticTokenTypestype SemanticTokenTypes = "type" - SemanticTokenTypesclass SemanticTokenTypes = "class" - SemanticTokenTypesenum SemanticTokenTypes = "enum" - SemanticTokenTypesinterface SemanticTokenTypes = "interface" - SemanticTokenTypesstruct SemanticTokenTypes = "struct" - SemanticTokenTypestypeParameter SemanticTokenTypes = "typeParameter" - SemanticTokenTypesparameter SemanticTokenTypes = "parameter" - SemanticTokenTypesvariable SemanticTokenTypes = "variable" - SemanticTokenTypesproperty SemanticTokenTypes = "property" - SemanticTokenTypesenumMember SemanticTokenTypes = "enumMember" - SemanticTokenTypesevent SemanticTokenTypes = "event" - SemanticTokenTypesfunction SemanticTokenTypes = "function" - SemanticTokenTypesmethod SemanticTokenTypes = "method" - SemanticTokenTypesmacro SemanticTokenTypes = "macro" - SemanticTokenTypeskeyword SemanticTokenTypes = "keyword" - SemanticTokenTypesmodifier SemanticTokenTypes = "modifier" - SemanticTokenTypescomment SemanticTokenTypes = "comment" - SemanticTokenTypesstring SemanticTokenTypes = "string" - SemanticTokenTypesnumber SemanticTokenTypes = "number" - SemanticTokenTypesregexp SemanticTokenTypes = "regexp" - SemanticTokenTypesoperator SemanticTokenTypes = "operator" + SemanticTokenTypeType SemanticTokenType = "type" + SemanticTokenTypeClass SemanticTokenType = "class" + SemanticTokenTypeEnum SemanticTokenType = "enum" + SemanticTokenTypeInterface SemanticTokenType = "interface" + SemanticTokenTypeStruct SemanticTokenType = "struct" + SemanticTokenTypeTypeParameter SemanticTokenType = "typeParameter" + SemanticTokenTypeParameter SemanticTokenType = "parameter" + SemanticTokenTypeVariable SemanticTokenType = "variable" + SemanticTokenTypeProperty SemanticTokenType = "property" + SemanticTokenTypeEnumMember SemanticTokenType = "enumMember" + SemanticTokenTypeEvent SemanticTokenType = "event" + SemanticTokenTypeFunction SemanticTokenType = "function" + SemanticTokenTypeMethod SemanticTokenType = "method" + SemanticTokenTypeMacro SemanticTokenType = "macro" + SemanticTokenTypeKeyword SemanticTokenType = "keyword" + SemanticTokenTypeModifier SemanticTokenType = "modifier" + SemanticTokenTypeComment SemanticTokenType = "comment" + SemanticTokenTypeString SemanticTokenType = "string" + SemanticTokenTypeNumber SemanticTokenType = "number" + SemanticTokenTypeRegexp SemanticTokenType = "regexp" + SemanticTokenTypeOperator SemanticTokenType = "operator" // Since: 3.17.0 - SemanticTokenTypesdecorator SemanticTokenTypes = "decorator" + SemanticTokenTypeDecorator SemanticTokenType = "decorator" // Since: 3.18.0 - SemanticTokenTypeslabel SemanticTokenTypes = "label" + SemanticTokenTypeLabel SemanticTokenType = "label" ) // A set of predefined token modifiers. This set is not fixed @@ -21783,19 +21847,19 @@ const ( // corresponding client capabilities. // // Since: 3.16.0 -type SemanticTokenModifiers string +type SemanticTokenModifier string const ( - SemanticTokenModifiersdeclaration SemanticTokenModifiers = "declaration" - SemanticTokenModifiersdefinition SemanticTokenModifiers = "definition" - SemanticTokenModifiersreadonly SemanticTokenModifiers = "readonly" - SemanticTokenModifiersstatic SemanticTokenModifiers = "static" - SemanticTokenModifiersdeprecated SemanticTokenModifiers = "deprecated" - SemanticTokenModifiersabstract SemanticTokenModifiers = "abstract" - SemanticTokenModifiersasync SemanticTokenModifiers = "async" - SemanticTokenModifiersmodification SemanticTokenModifiers = "modification" - SemanticTokenModifiersdocumentation SemanticTokenModifiers = "documentation" - SemanticTokenModifiersdefaultLibrary SemanticTokenModifiers = "defaultLibrary" + SemanticTokenModifierDeclaration SemanticTokenModifier = "declaration" + SemanticTokenModifierDefinition SemanticTokenModifier = "definition" + SemanticTokenModifierReadonly SemanticTokenModifier = "readonly" + SemanticTokenModifierStatic SemanticTokenModifier = "static" + SemanticTokenModifierDeprecated SemanticTokenModifier = "deprecated" + SemanticTokenModifierAbstract SemanticTokenModifier = "abstract" + SemanticTokenModifierAsync SemanticTokenModifier = "async" + SemanticTokenModifierModification SemanticTokenModifier = "modification" + SemanticTokenModifierDocumentation SemanticTokenModifier = "documentation" + SemanticTokenModifierDefaultLibrary SemanticTokenModifier = "defaultLibrary" ) // The document diagnostic report kinds. @@ -21813,59 +21877,31 @@ const ( ) // Predefined error codes. -type ErrorCodes int32 +type ErrorCode int32 const ( - ErrorCodesParseError ErrorCodes = -32700 - ErrorCodesInvalidRequest ErrorCodes = -32600 - ErrorCodesMethodNotFound ErrorCodes = -32601 - ErrorCodesInvalidParams ErrorCodes = -32602 - ErrorCodesInternalError ErrorCodes = -32603 + ErrorCodeParseError ErrorCode = -32700 + ErrorCodeInvalidRequest ErrorCode = -32600 + ErrorCodeMethodNotFound ErrorCode = -32601 + ErrorCodeInvalidParams ErrorCode = -32602 + ErrorCodeInternalError ErrorCode = -32603 // Error code indicating that a server received a notification or // request before the server has received the `initialize` request. - ErrorCodesServerNotInitialized ErrorCodes = -32002 - ErrorCodesUnknownErrorCode ErrorCodes = -32001 -) - -const _ErrorCodes_name = "ParseErrorInternalErrorInvalidParamsMethodNotFoundInvalidRequestServerNotInitializedUnknownErrorCode" - -var ( - _ErrorCodes_index_0 = [...]uint16{0, 10} - _ErrorCodes_index_1 = [...]uint16{0, 13, 26, 40, 54} - _ErrorCodes_index_2 = [...]uint16{0, 20, 36} -) - -func (e ErrorCodes) String() string { - switch { - case e == -32700: - return _ErrorCodes_name[0:10] - case -32603 <= e && e <= -32600: - i := int(e) - -32603 - return _ErrorCodes_name[10+_ErrorCodes_index_1[i] : 10+_ErrorCodes_index_1[i+1]] - case -32002 <= e && e <= -32001: - i := int(e) - -32002 - return _ErrorCodes_name[64+_ErrorCodes_index_2[i] : 64+_ErrorCodes_index_2[i+1]] - default: - return fmt.Sprintf("ErrorCodes(%d)", e) - } -} - -type LSPErrorCodes int32 - -const ( + ErrorCodeServerNotInitialized ErrorCode = -32002 + ErrorCodeUnknownErrorCode ErrorCode = -32001 // A request failed but it was syntactically correct, e.g the // method name was known and the parameters were valid. The error // message should contain human readable information about why // the request failed. // // Since: 3.17.0 - LSPErrorCodesRequestFailed LSPErrorCodes = -32803 + ErrorCodeRequestFailed ErrorCode = -32803 // The server cancelled the request. This error code should // only be used for requests that explicitly support being // server cancellable. // // Since: 3.17.0 - LSPErrorCodesServerCancelled LSPErrorCodes = -32802 + ErrorCodeServerCancelled ErrorCode = -32802 // The server detected that the content of a document got // modified outside normal conditions. A server should // NOT send this error code if it detects a content change @@ -21874,22 +21910,41 @@ const ( // // If a client decides that a result is not of any use anymore // the client should cancel the request. - LSPErrorCodesContentModified LSPErrorCodes = -32801 + ErrorCodeContentModified ErrorCode = -32801 // The client has canceled a request and a server has detected // the cancel. - LSPErrorCodesRequestCancelled LSPErrorCodes = -32800 + ErrorCodeRequestCancelled ErrorCode = -32800 ) -const _LSPErrorCodes_name = "RequestFailedServerCancelledContentModifiedRequestCancelled" +const _ErrorCode_name = "RequestFailedServerCancelledContentModifiedRequestCancelledParseErrorInternalErrorInvalidParamsMethodNotFoundInvalidRequestServerNotInitializedUnknownErrorCode" -var _LSPErrorCodes_index = [...]uint16{0, 13, 28, 43, 59} +var ( + _ErrorCode_index_0 = [...]uint16{0, 13, 28, 43, 59} + _ErrorCode_index_1 = [...]uint16{0, 10} + _ErrorCode_index_2 = [...]uint16{0, 13, 26, 40, 54} + _ErrorCode_index_3 = [...]uint16{0, 20, 36} +) -func (e LSPErrorCodes) String() string { - i := int(e) - -32803 - if i < 0 || i >= len(_LSPErrorCodes_index)-1 { - return fmt.Sprintf("LSPErrorCodes(%d)", e) +func (e ErrorCode) String() string { + switch { + case -32803 <= e && e <= -32800: + i := int(e) - -32803 + return _ErrorCode_name[0+_ErrorCode_index_0[i] : 0+_ErrorCode_index_0[i+1]] + case e == -32700: + return _ErrorCode_name[59:69] + case -32603 <= e && e <= -32600: + i := int(e) - -32603 + return _ErrorCode_name[69+_ErrorCode_index_2[i] : 69+_ErrorCode_index_2[i+1]] + case -32002 <= e && e <= -32001: + i := int(e) - -32002 + return _ErrorCode_name[123+_ErrorCode_index_3[i] : 123+_ErrorCode_index_3[i+1]] + default: + return fmt.Sprintf("ErrorCode(%d)", e) } - return _LSPErrorCodes_name[_LSPErrorCodes_index[i]:_LSPErrorCodes_index[i+1]] +} + +func (e ErrorCode) Error() string { + return e.String() } // A set of predefined range kinds. @@ -21977,15 +22032,15 @@ type UniquenessLevel string const ( // The moniker is only unique inside a document - UniquenessLeveldocument UniquenessLevel = "document" + UniquenessLevelDocument UniquenessLevel = "document" // The moniker is unique inside a project for which a dump got created - UniquenessLevelproject UniquenessLevel = "project" + UniquenessLevelProject UniquenessLevel = "project" // The moniker is unique inside the group to which a project belongs - UniquenessLevelgroup UniquenessLevel = "group" + UniquenessLevelGroup UniquenessLevel = "group" // The moniker is unique inside the moniker scheme. - UniquenessLevelscheme UniquenessLevel = "scheme" + UniquenessLevelScheme UniquenessLevel = "scheme" // The moniker is globally unique - UniquenessLevelglobal UniquenessLevel = "global" + UniquenessLevelGlobal UniquenessLevel = "global" ) // The moniker kind. @@ -21995,12 +22050,12 @@ type MonikerKind string const ( // The moniker represent a symbol that is imported into a project - MonikerKindimport MonikerKind = "import" + MonikerKindImport MonikerKind = "import" // The moniker represents a symbol that is exported from a project - MonikerKindexport MonikerKind = "export" + MonikerKindExport MonikerKind = "export" // The moniker represents a symbol that is local to a project (e.g. a local // variable of a function, a class not visible outside the project, ...) - MonikerKindlocal MonikerKind = "local" + MonikerKindLocal MonikerKind = "local" ) // Inlay hint kinds. @@ -22220,7 +22275,7 @@ const ( // inserted using the indentation defined in the string value. // The client will not apply any kind of adjustments to the // string. - InsertTextModeasIs InsertTextMode = 1 + InsertTextModeAsIs InsertTextMode = 1 // The editor adjusts leading whitespace of new lines so that // they match the indentation up to the cursor of the line for // which the item is accepted. @@ -22228,7 +22283,7 @@ const ( // Consider a line like this: <2tabs><3tabs>foo. Accepting a // multi line completion item is indented using 2 tabs and all // following lines inserted will be indented using 2 tabs as well. - InsertTextModeadjustIndentation InsertTextMode = 2 + InsertTextModeAdjustIndentation InsertTextMode = 2 ) const _InsertTextMode_name = "asIsadjustIndentation" @@ -22742,9 +22797,9 @@ type FileOperationPatternKind string const ( // The pattern matches a file only. - FileOperationPatternKindfile FileOperationPatternKind = "file" + FileOperationPatternKindFile FileOperationPatternKind = "file" // The pattern matches a folder only. - FileOperationPatternKindfolder FileOperationPatternKind = "folder" + FileOperationPatternKindFolder FileOperationPatternKind = "folder" ) // A notebook cell kind. @@ -22826,6 +22881,13 @@ const ( TokenFormatRelative TokenFormat = "relative" ) +type CodeLensKind string + +const ( + CodeLensKindReferences CodeLensKind = "references" + CodeLensKindImplementations CodeLensKind = "implementations" +) + func unmarshalParams(method Method, data []byte) (any, error) { switch method { case MethodTextDocumentImplementation: diff --git a/pkg/lsp/server.go b/pkg/lsp/server.go index c21f204ff..ff71fadc5 100644 --- a/pkg/lsp/server.go +++ b/pkg/lsp/server.go @@ -110,7 +110,7 @@ func (r *lspReader) Read() (*lsproto.Message, error) { req := &lsproto.Message{} if err := json.Unmarshal(data, req); err != nil { - return nil, fmt.Errorf("%w: %w", lsproto.ErrInvalidRequest, err) + return nil, fmt.Errorf("%w: %w", lsproto.ErrorCodeInvalidRequest, err) } return req, nil @@ -302,7 +302,7 @@ func (s *Server) readLoop(ctx context.Context) error { } msg, err := s.read() if err != nil { - if errors.Is(err, lsproto.ErrInvalidRequest) { + if errors.Is(err, lsproto.ErrorCodeInvalidRequest) { s.sendError(nil, err) continue } @@ -318,7 +318,7 @@ func (s *Server) readLoop(ctx context.Context) error { } s.sendResult(req.ID, resp) } else { - s.sendError(req.ID, lsproto.ErrServerNotInitialized) + s.sendError(req.ID, lsproto.ErrorCodeServerNotInitialized) } continue } @@ -380,7 +380,7 @@ func (s *Server) dispatchLoop(ctx context.Context) error { handle := func() { if err := s.handleRequestOrNotification(requestCtx, req); err != nil { if errors.Is(err, context.Canceled) { - s.sendError(req.ID, lsproto.ErrRequestCancelled) + s.sendError(req.ID, lsproto.ErrorCodeRequestCancelled) } else if errors.Is(err, io.EOF) { lspExit() } else { @@ -453,15 +453,15 @@ func (s *Server) sendResult(id *lsproto.ID, result any) { } func (s *Server) sendError(id *lsproto.ID, err error) { - code := lsproto.ErrInternalError.Code - if errCode := (*lsproto.ErrorCode)(nil); errors.As(err, &errCode) { - code = errCode.Code + code := lsproto.ErrorCodeInternalError + if errCode := lsproto.ErrorCode(0); errors.As(err, &errCode) { + code = errCode } // TODO(jakebailey): error data s.sendResponse(&lsproto.ResponseMessage{ ID: id, Error: &lsproto.ResponseError{ - Code: code, + Code: int32(code), Message: err.Error(), }, }) @@ -479,7 +479,7 @@ func (s *Server) handleRequestOrNotification(ctx context.Context, req *lsproto.R } s.Log("unknown method", req.Method) if req.ID != nil { - s.sendError(req.ID, lsproto.ErrInvalidRequest) + s.sendError(req.ID, lsproto.ErrorCodeInvalidRequest) } return nil } @@ -516,13 +516,19 @@ var handlers = sync.OnceValue(func() handlerMap { registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentHighlightInfo, (*Server).handleDocumentHighlight) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentSelectionRangeInfo, (*Server).handleSelectionRange) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentInlayHintInfo, (*Server).handleInlayHint) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentCodeLensInfo, (*Server).handleCodeLens) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentCodeActionInfo, (*Server).handleCodeAction) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentPrepareCallHierarchyInfo, (*Server).handlePrepareCallHierarchy) registerMultiProjectReferenceRequestHandler(handlers, lsproto.TextDocumentReferencesInfo, (*Server).handleReferences, combineReferences) registerMultiProjectReferenceRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename, combineRenameResponse) + registerRequestHandler(handlers, lsproto.CallHierarchyIncomingCallsInfo, (*Server).handleCallHierarchyIncomingCalls) + registerRequestHandler(handlers, lsproto.CallHierarchyOutgoingCallsInfo, (*Server).handleCallHierarchyOutgoingCalls) + registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) + registerRequestHandler(handlers, lsproto.CodeLensResolveInfo, (*Server).handleCodeLensResolve) return handlers }) @@ -530,7 +536,7 @@ var handlers = sync.OnceValue(func() handlerMap { func registerNotificationHandler[Req any](handlers handlerMap, info lsproto.NotificationInfo[Req], fn func(*Server, context.Context, Req) error) { handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error { if s.session == nil && req.Method != lsproto.MethodInitialized { - return lsproto.ErrServerNotInitialized + return lsproto.ErrorCodeServerNotInitialized } var params Req @@ -552,7 +558,7 @@ func registerRequestHandler[Req, Resp any]( ) { handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error { if s.session == nil && req.Method != lsproto.MethodInitialize { - return lsproto.ErrServerNotInitialized + return lsproto.ErrorCodeServerNotInitialized } var params Req @@ -838,7 +844,7 @@ func (s *Server) recover(req *lsproto.RequestMessage) { stack := debug.Stack() s.Log("panic handling request", req.Method, r, string(stack)) if req.ID != nil { - s.sendError(req.ID, fmt.Errorf("%w: panic handling request %s: %v", lsproto.ErrInternalError, req.Method, r)) + s.sendError(req.ID, fmt.Errorf("%w: panic handling request %s: %v", lsproto.ErrorCodeInternalError, req.Method, r)) } else { s.Log("unhandled panic in notification", req.Method, r) } @@ -847,7 +853,7 @@ func (s *Server) recover(req *lsproto.RequestMessage) { func (s *Server) handleInitialize(ctx context.Context, params *lsproto.InitializeParams, _ *lsproto.RequestMessage) (lsproto.InitializeResponse, error) { if s.initializeParams != nil { - return nil, lsproto.ErrInvalidRequest + return nil, lsproto.ErrorCodeInvalidRequest } s.initializeParams = params @@ -945,6 +951,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ InlayHintProvider: &lsproto.BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions{ Boolean: ptrTo(true), }, + CodeLensProvider: &lsproto.CodeLensOptions{ + ResolveProvider: ptrTo(true), + }, CodeActionProvider: &lsproto.BooleanOrCodeActionOptions{ CodeActionOptions: &lsproto.CodeActionOptions{ CodeActionKinds: &[]lsproto.CodeActionKind{ @@ -952,6 +961,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ }, }, }, + CallHierarchyProvider: &lsproto.BooleanOrCallHierarchyOptionsOrCallHierarchyRegistrationOptions{ + Boolean: ptrTo(true), + }, }, } @@ -1285,6 +1297,52 @@ func (s *Server) handleInlayHint( return languageService.ProvideInlayHint(ctx, params) } +func (s *Server) handleCodeLens(ctx context.Context, ls *ls.LanguageService, params *lsproto.CodeLensParams) (lsproto.CodeLensResponse, error) { + return ls.ProvideCodeLenses(ctx, params.TextDocument.Uri) +} + +func (s *Server) handleCodeLensResolve(ctx context.Context, codeLens *lsproto.CodeLens, reqMsg *lsproto.RequestMessage) (*lsproto.CodeLens, error) { + ls, err := s.session.GetLanguageService(ctx, codeLens.Data.Uri) + if err != nil { + return nil, err + } + defer s.recover(reqMsg) + + return ls.ResolveCodeLens(ctx, codeLens, s.initializeParams.InitializationOptions.CodeLensShowLocationsCommandName) +} + +func (s *Server) handlePrepareCallHierarchy( + ctx context.Context, + languageService *ls.LanguageService, + params *lsproto.CallHierarchyPrepareParams, +) (lsproto.CallHierarchyPrepareResponse, error) { + return languageService.ProvidePrepareCallHierarchy(ctx, params.TextDocument.Uri, params.Position) +} + +func (s *Server) handleCallHierarchyIncomingCalls( + ctx context.Context, + params *lsproto.CallHierarchyIncomingCallsParams, + _ *lsproto.RequestMessage, +) (lsproto.CallHierarchyIncomingCallsResponse, error) { + languageService, err := s.session.GetLanguageService(ctx, params.Item.Uri) + if err != nil { + return lsproto.CallHierarchyIncomingCallsOrNull{}, err + } + return languageService.ProvideCallHierarchyIncomingCalls(ctx, params.Item) +} + +func (s *Server) handleCallHierarchyOutgoingCalls( + ctx context.Context, + params *lsproto.CallHierarchyOutgoingCallsParams, + _ *lsproto.RequestMessage, +) (lsproto.CallHierarchyOutgoingCallsResponse, error) { + languageService, err := s.session.GetLanguageService(ctx, params.Item.Uri) + if err != nil { + return lsproto.CallHierarchyOutgoingCallsOrNull{}, err + } + return languageService.ProvideCallHierarchyOutgoingCalls(ctx, params.Item) +} + func (s *Server) Log(msg ...any) { fmt.Fprintln(s.stderr, msg...) } diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index 75c119817..35b8fcd30 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -3802,8 +3802,12 @@ func (p *Printer) emitImportAttribute(node *ast.ImportAttribute) { p.emitImportAttributeName(node.Name()) p.writePunctuation(":") p.writeSpace() - /// !!! emit trailing comments of value - p.emitExpression(node.Value, ast.OperatorPrecedenceDisallowComma) + value := node.Value + if p.emitContext.EmitFlags(node.Value)&EFNoLeadingComments == 0 { + commentRange := getCommentRange(value) + p.emitTrailingComments(commentRange.Pos(), commentSeparatorAfter) + } + p.emitExpression(value, ast.OperatorPrecedenceDisallowComma) p.exitNode(node.AsNode(), state) } diff --git a/pkg/testutil/baseline/baseline.go b/pkg/testutil/baseline/baseline.go index eb43c07c4..973939c7c 100644 --- a/pkg/testutil/baseline/baseline.go +++ b/pkg/testutil/baseline/baseline.go @@ -126,6 +126,11 @@ func getBaselineDiff(t *testing.T, actual string, expected string, fileName stri } s := DiffText("old."+fileName, "new."+fileName, expected, actual) + // If the diff is empty (just headers, no hunks), return NoContent + if !strings.Contains(s, "@@") { + return NoContent + } + // Remove line numbers from unified diff headers; this avoids adding/deleting // lines in our baselines from causing knock-on header changes later in the diff. diff --git a/testdata/baselines/reference/compiler/importAttributesWithValueComments.js b/testdata/baselines/reference/compiler/importAttributesWithValueComments.js new file mode 100644 index 000000000..8cb031078 --- /dev/null +++ b/testdata/baselines/reference/compiler/importAttributesWithValueComments.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/importAttributesWithValueComments.ts] //// + +//// [a.ts] +export default { + a: "a", + b: "b", + 1: "1", +} + +//// [b.ts] +import a from "./a" with { a: /* a */ "a", "b": /* b */ "b" }; +a; + + +//// [a.js] +export default { + a: "a", + b: "b", + 1: "1", +}; +//// [b.js] +import a from "./a" with { a: /* a */ "a", "b": /* b */ "b" }; +a; diff --git a/testdata/baselines/reference/compiler/importAttributesWithValueComments.symbols b/testdata/baselines/reference/compiler/importAttributesWithValueComments.symbols new file mode 100644 index 000000000..a70fa74cf --- /dev/null +++ b/testdata/baselines/reference/compiler/importAttributesWithValueComments.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/importAttributesWithValueComments.ts] //// + +=== /a.ts === +export default { + a: "a", +>a : Symbol(a, Decl(a.ts, 0, 16)) + + b: "b", +>b : Symbol(b, Decl(a.ts, 1, 11)) + + 1: "1", +>1 : Symbol(1, Decl(a.ts, 2, 11)) +} + +=== /b.ts === +import a from "./a" with { a: /* a */ "a", "b": /* b */ "b" }; +>a : Symbol(a, Decl(b.ts, 0, 6)) + +a; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/testdata/baselines/reference/compiler/importAttributesWithValueComments.types b/testdata/baselines/reference/compiler/importAttributesWithValueComments.types new file mode 100644 index 000000000..a9ea0943a --- /dev/null +++ b/testdata/baselines/reference/compiler/importAttributesWithValueComments.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/importAttributesWithValueComments.ts] //// + +=== /a.ts === +export default { +>{ a: "a", b: "b", 1: "1",} : { a: string; b: string; 1: string; } + + a: "a", +>a : string +>"a" : "a" + + b: "b", +>b : string +>"b" : "b" + + 1: "1", +>1 : string +>"1" : "1" +} + +=== /b.ts === +import a from "./a" with { a: /* a */ "a", "b": /* b */ "b" }; +>a : { a: string; b: string; 1: string; } +>a : any + +a; +>a : { a: string; b: string; 1: string; } + diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionExpressions01.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionExpressions01.baseline.jsonc new file mode 100644 index 000000000..5b8911c10 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionExpressions01.baseline.jsonc @@ -0,0 +1,72 @@ +// === Code Lenses === +// === /anonymousFunctionExpressions.ts === +// export let /*CODELENS: 0 references*/anonFn1 = function () {}; +// export const anonFn2 = function () {}; +// +// let anonFn3 = function () {}; +// const anonFn4 = function () {}; +// + + + +// === Code Lenses === +// === /anonymousFunctionExpressions.ts === +// export let anonFn1 = function () {}; +// export const /*CODELENS: 0 references*/anonFn2 = function () {}; +// +// let anonFn3 = function () {}; +// const anonFn4 = function () {}; +// + + + +// === Code Lenses === +// === /arrowFunctions.ts === +// export let /*CODELENS: 0 references*/arrowFn1 = () => {}; +// export const arrowFn2 = () => {}; +// +// let arrowFn3 = () => {}; +// const arrowFn4 = () => {}; +// + + + +// === Code Lenses === +// === /arrowFunctions.ts === +// export let arrowFn1 = () => {}; +// export const /*CODELENS: 0 references*/arrowFn2 = () => {}; +// +// let arrowFn3 = () => {}; +// const arrowFn4 = () => {}; +// + + + +// === Code Lenses === +// === /namedFunctions.ts === +// export let /*CODELENS: 1 reference*/namedFn1 = function namedFn1() { +// namedFn1(); +// } +// [|namedFn1|](); +// +// export const namedFn2 = function namedFn2() { +// namedFn2(); +// --- (line: 8) skipped --- + + + +// === Code Lenses === +// === /namedFunctions.ts === +// export let namedFn1 = function namedFn1() { +// namedFn1(); +// } +// namedFn1(); +// +// export const /*CODELENS: 1 reference*/namedFn2 = function namedFn2() { +// namedFn2(); +// } +// [|namedFn2|](); +// +// let namedFn3 = function namedFn3() {}; +// const namedFn4 = function namedFn4() {}; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionsAndConstants01.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionsAndConstants01.baseline.jsonc new file mode 100644 index 000000000..5c306865e --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensFunctionsAndConstants01.baseline.jsonc @@ -0,0 +1,42 @@ +// === Code Lenses === +// === /exports.ts === +// let callCount = 0; +// export function /*CODELENS: 3 references*/foo(n: number): void { +// callCount++; +// if (n > 0) { +// [|foo|](n - 1); +// } +// else { +// console.log("function was called " + callCount + " times"); +// } +// } +// +// [|foo|](5); +// +// export const bar = 123; +// + +// === /importer.ts === +// import { foo, bar } from "./exports"; +// +// [|foo|](5); +// console.log(bar); +// + + + +// === Code Lenses === +// === /importer.ts === +// import { foo, bar } from "./exports"; +// +// foo(5); +// console.log([|bar|]); +// + +// === /exports.ts === +// --- (line: 10) skipped --- +// +// foo(5); +// +// export const /*CODELENS: 1 reference*/bar = 123; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc new file mode 100644 index 000000000..dc284d737 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensInterface01.baseline.jsonc @@ -0,0 +1,242 @@ +// === Code Lenses === +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class /*CODELENS: 0 references*/Point implements Pointable { +// getX(): number { +// return 0; +// } +// --- (line: 7) skipped --- + + + +// === Code Lenses === +// === /objectPointable.ts === +// import { Pointable } from "./pointable"; +// +// let x = 0; +// let y = 0; +// const p: Pointable = { +// [|getX|](): number { +// return x; +// }, +// getY(): number { +// --- (line: 10) skipped --- + +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class Point implements Pointable { +// /*CODELENS: 1 reference*/getX(): number { +// return 0; +// } +// getY(): number { +// --- (line: 8) skipped --- + + + +// === Code Lenses === +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class Point implements Pointable { +// /*CODELENS: 0 implementations*/getX(): number { +// return 0; +// } +// getY(): number { +// --- (line: 8) skipped --- + + + +// === Code Lenses === +// === /objectPointable.ts === +// --- (line: 5) skipped --- +// getX(): number { +// return x; +// }, +// [|getY|](): number { +// return y; +// }, +// }; +// + +// === /classPointable.ts === +// --- (line: 3) skipped --- +// getX(): number { +// return 0; +// } +// /*CODELENS: 1 reference*/getY(): number { +// return 0; +// } +// } +// + + + +// === Code Lenses === +// === /classPointable.ts === +// --- (line: 3) skipped --- +// getX(): number { +// return 0; +// } +// /*CODELENS: 0 implementations*/getY(): number { +// return 0; +// } +// } +// + + + +// === Code Lenses === +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class Point implements [|Pointable|] { +// getX(): number { +// return 0; +// } +// --- (line: 7) skipped --- + +// === /objectPointable.ts === +// import { Pointable } from "./pointable"; +// +// let x = 0; +// let y = 0; +// const p: [|Pointable|] = { +// getX(): number { +// return x; +// }, +// --- (line: 9) skipped --- + +// === /pointable.ts === +// export interface /*CODELENS: 2 references*/Pointable { +// getX(): number; +// getY(): number; +// } +// + + + +// === Code Lenses === +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class [|Point|] implements Pointable { +// getX(): number { +// return 0; +// } +// --- (line: 7) skipped --- + +// === /pointable.ts === +// export interface /*CODELENS: 1 implementation*/Pointable { +// getX(): number; +// getY(): number; +// } +// + + + +// === Code Lenses === +// === /objectPointable.ts === +// import { Pointable } from "./pointable"; +// +// let x = 0; +// let y = 0; +// const p: Pointable = { +// [|getX|](): number { +// return x; +// }, +// getY(): number { +// --- (line: 10) skipped --- + +// === /pointable.ts === +// export interface Pointable { +// /*CODELENS: 1 reference*/getX(): number; +// getY(): number; +// } +// + + + +// === Code Lenses === +// === /classPointable.ts === +// import { Pointable } from "./pointable"; +// +// class Point implements Pointable { +// [|getX|](): number { +// return 0; +// } +// getY(): number { +// --- (line: 8) skipped --- + +// === /objectPointable.ts === +// import { Pointable } from "./pointable"; +// +// let x = 0; +// let y = 0; +// const p: Pointable = { +// [|getX|](): number { +// return x; +// }, +// getY(): number { +// --- (line: 10) skipped --- + +// === /pointable.ts === +// export interface Pointable { +// /*CODELENS: 2 implementations*/getX(): number; +// getY(): number; +// } +// + + + +// === Code Lenses === +// === /objectPointable.ts === +// --- (line: 5) skipped --- +// getX(): number { +// return x; +// }, +// [|getY|](): number { +// return y; +// }, +// }; +// + +// === /pointable.ts === +// export interface Pointable { +// getX(): number; +// /*CODELENS: 1 reference*/getY(): number; +// } +// + + + +// === Code Lenses === +// === /classPointable.ts === +// --- (line: 3) skipped --- +// getX(): number { +// return 0; +// } +// [|getY|](): number { +// return 0; +// } +// } +// + +// === /objectPointable.ts === +// --- (line: 5) skipped --- +// getX(): number { +// return x; +// }, +// [|getY|](): number { +// return y; +// }, +// }; +// + +// === /pointable.ts === +// export interface Pointable { +// getX(): number; +// /*CODELENS: 2 implementations*/getY(): number; +// } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensOverloads01.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensOverloads01.baseline.jsonc new file mode 100644 index 000000000..f8163d73a --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensOverloads01.baseline.jsonc @@ -0,0 +1,16 @@ +// === Code Lenses === +// === /codeLensOverloads01.ts === +// export function /*CODELENS: 3 references*/foo(x: number): number; +// export function foo(x: string): string; +// export function foo(x: string | number): string | number { +// return x; +// } +// +// [|foo|](1); +// +// [|foo|]("hello"); +// +// // This one isn't expected to match any overload, +// // but is really just here to test how it affects how code lens. +// [|foo|](Math.random() ? 1 : "hello"); +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=false.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=false.baseline.jsonc new file mode 100644 index 000000000..09d45e997 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=false.baseline.jsonc @@ -0,0 +1,32 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=false.ts === +// export abstract class /*CODELENS: 0 implementations*/ABC { +// abstract methodA(): void; +// methodB(): void {} +// #methodC(): void {} +// --- (line: 5) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=false.ts === +// export abstract class ABC { +// abstract /*CODELENS: 0 implementations*/methodA(): void; +// methodB(): void {} +// #methodC(): void {} +// protected methodD(): void {} +// --- (line: 6) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=false.ts === +// --- (line: 3) skipped --- +// #methodC(): void {} +// protected methodD(): void {} +// private methodE(): void {} +// protected abstract /*CODELENS: 0 implementations*/methodG(): void; +// public methodH(): void {} +// +// static methodStaticA(): void {} +// --- (line: 11) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=true.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=true.baseline.jsonc new file mode 100644 index 000000000..7da1d95f5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllClassMethods=true.baseline.jsonc @@ -0,0 +1,101 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// export abstract class /*CODELENS: 0 implementations*/ABC { +// abstract methodA(): void; +// methodB(): void {} +// #methodC(): void {} +// --- (line: 5) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// export abstract class ABC { +// abstract /*CODELENS: 0 implementations*/methodA(): void; +// methodB(): void {} +// #methodC(): void {} +// protected methodD(): void {} +// --- (line: 6) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// export abstract class ABC { +// abstract methodA(): void; +// /*CODELENS: 0 implementations*/methodB(): void {} +// #methodC(): void {} +// protected methodD(): void {} +// private methodE(): void {} +// --- (line: 7) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// export abstract class ABC { +// abstract methodA(): void; +// methodB(): void {} +// #methodC(): void {} +// protected /*CODELENS: 0 implementations*/methodD(): void {} +// private methodE(): void {} +// protected abstract methodG(): void; +// public methodH(): void {} +// --- (line: 9) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// --- (line: 3) skipped --- +// #methodC(): void {} +// protected methodD(): void {} +// private methodE(): void {} +// protected abstract /*CODELENS: 0 implementations*/methodG(): void; +// public methodH(): void {} +// +// static methodStaticA(): void {} +// --- (line: 11) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// --- (line: 4) skipped --- +// protected methodD(): void {} +// private methodE(): void {} +// protected abstract methodG(): void; +// public /*CODELENS: 0 implementations*/methodH(): void {} +// +// static methodStaticA(): void {} +// protected static methodStaticB(): void {} +// --- (line: 12) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// --- (line: 6) skipped --- +// protected abstract methodG(): void; +// public methodH(): void {} +// +// static /*CODELENS: 0 implementations*/methodStaticA(): void {} +// protected static methodStaticB(): void {} +// private static methodStaticC(): void {} +// static #methodStaticD(): void {} +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllClassMethods=true.ts === +// --- (line: 7) skipped --- +// public methodH(): void {} +// +// static methodStaticA(): void {} +// protected static /*CODELENS: 0 implementations*/methodStaticB(): void {} +// private static methodStaticC(): void {} +// static #methodStaticD(): void {} +// } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=false.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=false.baseline.jsonc new file mode 100644 index 000000000..7bb4a5657 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=false.baseline.jsonc @@ -0,0 +1,22 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnAllFunctions=false.ts === +// export function /*CODELENS: 0 references*/f1(): void {} +// +// function f2(): void {} +// +// --- (line: 5) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllFunctions=false.ts === +// export function f1(): void {} +// +// function f2(): void {} +// +// export const /*CODELENS: 0 references*/f3 = () => {}; +// +// const f4 = () => {}; +// +// const f5 = function() {}; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=true.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=true.baseline.jsonc new file mode 100644 index 000000000..b890c7f5c --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnAllFunctions=true.baseline.jsonc @@ -0,0 +1,34 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnAllFunctions=true.ts === +// export function /*CODELENS: 0 references*/f1(): void {} +// +// function f2(): void {} +// +// --- (line: 5) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllFunctions=true.ts === +// export function f1(): void {} +// +// function /*CODELENS: 0 references*/f2(): void {} +// +// export const f3 = () => {}; +// +// --- (line: 7) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnAllFunctions=true.ts === +// export function f1(): void {} +// +// function f2(): void {} +// +// export const /*CODELENS: 0 references*/f3 = () => {}; +// +// const f4 = () => {}; +// +// const f5 = function() {}; +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=false.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=false.baseline.jsonc new file mode 100644 index 000000000..5f9918a03 --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=false.baseline.jsonc @@ -0,0 +1,78 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=false.ts === +// export interface /*CODELENS: 3 implementations*/I { +// methodA(): void; +// } +// export interface I { +// methodB(): void; +// } +// +// interface [|J|] extends I { +// methodB(): void; +// methodC(): void; +// } +// +// class [|C|] implements J { +// methodA(): void {} +// methodB(): void {} +// methodC(): void {} +// } +// +// class [|AbstractC|] implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=false.ts === +// --- (line: 4) skipped --- +// methodB(): void; +// } +// +// interface /*CODELENS: 2 implementations*/J extends I { +// methodB(): void; +// methodC(): void; +// } +// +// class [|C|] implements J { +// methodA(): void {} +// methodB(): void {} +// methodC(): void {} +// } +// +// class [|AbstractC|] implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=false.ts === +// --- (line: 16) skipped --- +// } +// +// class AbstractC implements J { +// abstract /*CODELENS: 0 implementations*/methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=false.ts === +// --- (line: 18) skipped --- +// class AbstractC implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract /*CODELENS: 0 implementations*/methodC(): void; +// } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=true.baseline.jsonc b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=true.baseline.jsonc new file mode 100644 index 000000000..cf498182d --- /dev/null +++ b/testdata/baselines/reference/fourslash/codeLenses/codeLensReferencesShowOnInterfaceMethods=true.baseline.jsonc @@ -0,0 +1,173 @@ +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// export interface /*CODELENS: 3 implementations*/I { +// methodA(): void; +// } +// export interface I { +// methodB(): void; +// } +// +// interface [|J|] extends I { +// methodB(): void; +// methodC(): void; +// } +// +// class [|C|] implements J { +// methodA(): void {} +// methodB(): void {} +// methodC(): void {} +// } +// +// class [|AbstractC|] implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// export interface I { +// /*CODELENS: 1 implementation*/methodA(): void; +// } +// export interface I { +// methodB(): void; +// --- (line: 6) skipped --- + +// --- (line: 10) skipped --- +// } +// +// class C implements J { +// [|methodA|](): void {} +// methodB(): void {} +// methodC(): void {} +// } +// --- (line: 18) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// export interface I { +// methodA(): void; +// } +// export interface I { +// /*CODELENS: 2 implementations*/methodB(): void; +// } +// +// interface J extends I { +// methodB(): void; +// methodC(): void; +// } +// +// class C implements J { +// methodA(): void {} +// [|methodB|](): void {} +// methodC(): void {} +// } +// +// class AbstractC implements J { +// abstract methodA(): void; +// [|methodB|](): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// --- (line: 4) skipped --- +// methodB(): void; +// } +// +// interface /*CODELENS: 2 implementations*/J extends I { +// methodB(): void; +// methodC(): void; +// } +// +// class [|C|] implements J { +// methodA(): void {} +// methodB(): void {} +// methodC(): void {} +// } +// +// class [|AbstractC|] implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// --- (line: 5) skipped --- +// } +// +// interface J extends I { +// /*CODELENS: 2 implementations*/methodB(): void; +// methodC(): void; +// } +// +// class C implements J { +// methodA(): void {} +// [|methodB|](): void {} +// methodC(): void {} +// } +// +// class AbstractC implements J { +// abstract methodA(): void; +// [|methodB|](): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// --- (line: 6) skipped --- +// +// interface J extends I { +// methodB(): void; +// /*CODELENS: 1 implementation*/methodC(): void; +// } +// +// class C implements J { +// methodA(): void {} +// methodB(): void {} +// [|methodC|](): void {} +// } +// +// class AbstractC implements J { +// --- (line: 20) skipped --- + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// --- (line: 16) skipped --- +// } +// +// class AbstractC implements J { +// abstract /*CODELENS: 0 implementations*/methodA(): void; +// methodB(): void {} +// abstract methodC(): void; +// } +// + + + +// === Code Lenses === +// === /codeLensReferencesShowOnInterfaceMethods=true.ts === +// --- (line: 18) skipped --- +// class AbstractC implements J { +// abstract methodA(): void; +// methodB(): void {} +// abstract /*CODELENS: 0 implementations*/methodC(): void; +// } +// \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc index 90ec6e075..4e2671027 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesOfConstructor.baseline.jsonc @@ -29,7 +29,7 @@ // === /d.ts === // import * as a from "./a"; -// new a.C(); +// new a.[|C|](); // class d extends a.C { constructor() { [|super|](); } @@ -65,7 +65,7 @@ // === /d.ts === // import * as a from "./a"; -// new a.C(); +// new a.[|C|](); // class d extends a.C { constructor() { [|super|](); } @@ -101,5 +101,5 @@ // === /d.ts === // import * as a from "./a"; -// new a.C(); +// new a.[|C|](); // class d extends a.C { constructor() { [|super|](); } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline index 8ccdf9907..09879cb55 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocDontBreakWithNamespaces.baseline @@ -53,8 +53,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -74,8 +73,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -95,8 +93,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline index 57f7193a1..f79cc4afe 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures5.baseline @@ -64,11 +64,11 @@ { "label": "options: Object" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline index 490770f2a..742ccccb8 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsDocFunctionSignatures6.baseline @@ -108,11 +108,11 @@ { "label": "p4?: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -146,11 +146,11 @@ { "label": "p4?: string" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -184,11 +184,11 @@ { "label": "p4?: string" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -222,11 +222,11 @@ { "label": "p4?: string" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline index 09b671b36..4551f8a9c 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/jsdocReturnsTag.baseline @@ -50,11 +50,11 @@ { "label": "x: unknown" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTags13.baseline b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTags13.baseline index 18ca3b557..e67cb9cd3 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTags13.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTags13.baseline @@ -49,7 +49,8 @@ { "label": "a: number" } - ] + ], + "activeParameter": 0 }, { "label": "f(a: string): void", @@ -57,11 +58,11 @@ { "label": "a: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -82,7 +83,8 @@ { "label": "a: number" } - ] + ], + "activeParameter": 0 }, { "label": "f(a: string): void", @@ -90,11 +92,11 @@ { "label": "a: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline index aa8485069..73e4be6af 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/quickInfoJsDocTextFormatting1.baseline @@ -122,11 +122,11 @@ { "label": "var2: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -154,11 +154,11 @@ { "label": "var2: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -186,11 +186,11 @@ { "label": "var2: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -218,11 +218,11 @@ { "label": "var2: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -250,11 +250,11 @@ { "label": "var2: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpAfterParameter.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpAfterParameter.baseline index 8049e26f5..1af28b146 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpAfterParameter.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpAfterParameter.baseline @@ -77,11 +77,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -108,11 +108,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -139,11 +139,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -170,11 +170,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -201,11 +201,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -232,11 +232,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -263,11 +263,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -294,11 +294,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -325,11 +325,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -356,11 +356,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -387,11 +387,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -418,11 +418,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline index eee615b3a..5ffa2a7a6 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClass.baseline @@ -106,8 +106,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -131,8 +130,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -156,8 +154,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -177,8 +174,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -202,8 +198,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -228,11 +223,11 @@ { "label": "a: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline index d6c43e6b2..e460d9a51 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsClassMembers.baseline @@ -231,11 +231,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -260,11 +260,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -289,11 +289,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -318,11 +318,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -347,11 +347,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -376,11 +376,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -401,11 +401,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -426,11 +426,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -451,11 +451,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -476,11 +476,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -501,11 +501,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -526,11 +526,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -554,8 +554,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -580,11 +579,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -605,11 +604,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -634,11 +633,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -659,11 +658,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline index f9f951a72..f00c5fc84 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsCommentParsing.baseline @@ -750,8 +750,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -771,8 +770,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -796,8 +794,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -821,8 +818,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -846,8 +842,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -871,8 +866,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -896,8 +890,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -921,8 +914,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -946,8 +938,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -971,8 +962,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -996,8 +986,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1017,8 +1006,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1038,8 +1026,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1059,8 +1046,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1088,11 +1074,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1120,11 +1106,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1161,11 +1147,11 @@ { "label": "e?: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1202,11 +1188,11 @@ { "label": "e?: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1243,11 +1229,11 @@ { "label": "e?: any" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1284,11 +1270,11 @@ { "label": "e?: any" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } }, { @@ -1325,11 +1311,11 @@ { "label": "e?: any" } - ] + ], + "activeParameter": 4 } ], - "activeSignature": 0, - "activeParameter": 4 + "activeSignature": 0 } }, { @@ -1354,7 +1340,8 @@ { "label": "a: number" } - ] + ], + "activeParameter": 0 }, { "label": "f1(b: string): any", @@ -1362,11 +1349,11 @@ { "label": "b: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1391,7 +1378,8 @@ { "label": "a: number" } - ] + ], + "activeParameter": 0 }, { "label": "f1(b: string): any", @@ -1399,11 +1387,11 @@ { "label": "b: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } }, { @@ -1443,11 +1431,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1487,11 +1475,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1531,11 +1519,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1575,11 +1563,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } }, { @@ -1619,11 +1607,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 4 } ], - "activeSignature": 0, - "activeParameter": 4 + "activeSignature": 0 } }, { @@ -1663,11 +1651,11 @@ { "label": "f?: () => string" } - ] + ], + "activeParameter": 5 } ], - "activeSignature": 0, - "activeParameter": 5 + "activeSignature": 0 } }, { @@ -1692,11 +1680,11 @@ { "label": "a: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1724,11 +1712,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1756,11 +1744,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1788,11 +1776,11 @@ { "label": "bar: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1820,11 +1808,11 @@ { "label": "bar: string" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1870,11 +1858,11 @@ { "label": "d: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1908,11 +1896,11 @@ { "label": "d: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1946,11 +1934,11 @@ { "label": "d: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1984,11 +1972,11 @@ { "label": "d: number" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } }, { @@ -2012,8 +2000,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -2037,8 +2024,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -2069,11 +2055,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -2104,11 +2090,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -2139,11 +2125,11 @@ { "label": "c: any" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline index 9379624b7..66ecad0c6 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionDeclaration.baseline @@ -62,8 +62,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -91,11 +90,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -123,11 +122,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -152,11 +151,11 @@ { "label": "a: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline index 909f65f09..9d140cdd0 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsFunctionExpression.baseline @@ -73,11 +73,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -105,11 +105,11 @@ { "label": "b: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -134,11 +134,11 @@ { "label": "s: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline index 1250243a3..09d5ad8e9 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpConstructorCallParamProperties.baseline @@ -40,11 +40,11 @@ { "label": "radius: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpExpandedRestTuplesLocalLabels1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpExpandedRestTuplesLocalLabels1.baseline index 5ed475ad9..c0c73da4e 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpExpandedRestTuplesLocalLabels1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpExpandedRestTuplesLocalLabels1.baseline @@ -197,7 +197,8 @@ { "label": "info: AppleInfo" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple1(fruit: \"banana\", info: BananaInfo): void", @@ -208,11 +209,11 @@ { "label": "info: BananaInfo" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -236,7 +237,8 @@ { "label": "info: AppleInfo" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple2(arg_0: \"banana\", info: BananaInfo): void", @@ -247,11 +249,11 @@ { "label": "info: BananaInfo" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -275,7 +277,8 @@ { "label": "info: AppleInfo" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple2(arg_0: \"banana\", info: BananaInfo): void", @@ -286,11 +289,11 @@ { "label": "info: BananaInfo" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -314,7 +317,8 @@ { "label": "rest_0: AppleInfo" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple3(fruit: \"banana\", rest_0: BananaInfo): void", @@ -325,11 +329,11 @@ { "label": "rest_0: BananaInfo" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -353,7 +357,8 @@ { "label": "rest_0: AppleInfo" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple3(fruit: \"banana\", rest_0: BananaInfo): void", @@ -364,11 +369,11 @@ { "label": "rest_0: BananaInfo" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -392,7 +397,8 @@ { "label": "info: AppleInfo" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple4(fruit: \"banana\", info: BananaInfo): void", @@ -403,11 +409,11 @@ { "label": "info: BananaInfo" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -431,7 +437,8 @@ { "label": "info: AppleInfo" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple4(fruit: \"banana\", info: BananaInfo): void", @@ -442,11 +449,11 @@ { "label": "info: BananaInfo" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -470,7 +477,8 @@ { "label": "...firstInfo_n: AppleInfo[]" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple5(fruit: \"banana\", ...firstInfo_n: BananaInfo[]): void", @@ -481,11 +489,11 @@ { "label": "...firstInfo_n: BananaInfo[]" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -509,7 +517,8 @@ { "label": "...firstInfo_n: AppleInfo[]" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple5(fruit: \"banana\", ...firstInfo_n: BananaInfo[]): void", @@ -520,11 +529,11 @@ { "label": "...firstInfo_n: BananaInfo[]" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -548,7 +557,8 @@ { "label": "...fruitInfo: AppleInfo[]" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple6(fruit: \"banana\", ...fruitInfo: BananaInfo[]): void", @@ -559,11 +569,11 @@ { "label": "...fruitInfo: BananaInfo[]" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -587,7 +597,8 @@ { "label": "...fruitInfo: AppleInfo[]" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple6(fruit: \"banana\", ...fruitInfo: BananaInfo[]): void", @@ -598,11 +609,11 @@ { "label": "...fruitInfo: BananaInfo[]" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -629,7 +640,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple7(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -643,11 +655,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -674,7 +686,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple7(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -688,11 +701,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -719,7 +732,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 }, { "label": "logFruitTuple7(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -733,11 +747,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -764,7 +778,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple8(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -778,11 +793,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -809,7 +824,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple8(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -823,11 +839,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -854,7 +870,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 }, { "label": "logFruitTuple8(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -868,11 +885,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -899,7 +916,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple9(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -913,11 +931,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -944,7 +962,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple9(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -958,11 +977,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -989,7 +1008,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 }, { "label": "logFruitTuple9(fruit: \"banana\", ...fruitInfoOrNumber_n: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -1003,11 +1023,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1034,7 +1054,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple10(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -1048,11 +1069,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1079,7 +1100,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple10(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -1093,11 +1115,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1124,7 +1146,8 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 }, { "label": "logFruitTuple10(fruit: \"banana\", ...arg_1: BananaInfo[], secondFruitInfoOrNumber: number): void", @@ -1138,11 +1161,11 @@ { "label": "secondFruitInfoOrNumber: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1169,7 +1192,8 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 0 }, { "label": "logFruitTuple11(arg_0: \"banana\", ...arg_1: BananaInfo[], arg_2: number): void", @@ -1183,11 +1207,11 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1214,7 +1238,8 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 1 }, { "label": "logFruitTuple11(arg_0: \"banana\", ...arg_1: BananaInfo[], arg_2: number): void", @@ -1228,11 +1253,11 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -1259,7 +1284,8 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 2 }, { "label": "logFruitTuple11(arg_0: \"banana\", ...arg_1: BananaInfo[], arg_2: number): void", @@ -1273,11 +1299,11 @@ { "label": "arg_2: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -1301,11 +1327,11 @@ { "label": "named: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -1329,11 +1355,11 @@ { "label": "named: string" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline new file mode 100644 index 000000000..a3c8672f1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpInferenceJsDocImportTag.baseline @@ -0,0 +1,51 @@ +// === SignatureHelp === +=== /b.js === +// /** +// * @import { +// * Foo +// * } from './a' +// */ +// +// /** +// * @param {Foo} a +// */ +// function foo(a) {} +// foo() +// ^ +// | ---------------------------------------------------------------------- +// | foo(**a: Foo**): void +// | +// | +// | *@param* `a` +// | ---------------------------------------------------------------------- +[ + { + "marker": { + "Position": 98, + "LSPosition": { + "line": 10, + "character": 4 + }, + "Name": "", + "Data": {} + }, + "item": { + "signatures": [ + { + "label": "foo(a: Foo): void", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* `a`" + }, + "parameters": [ + { + "label": "a: Foo" + } + ], + "activeParameter": 0 + } + ], + "activeSignature": 0 + } + } +] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpIteratorNext.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpIteratorNext.baseline index e20d663b3..519fc4bfa 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpIteratorNext.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpIteratorNext.baseline @@ -74,11 +74,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -103,11 +103,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } }, { @@ -132,11 +132,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -161,11 +161,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } }, { @@ -190,11 +190,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -219,11 +219,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } }, { @@ -248,11 +248,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -277,11 +277,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 1, - "activeParameter": 0 + "activeSignature": 1 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline index d9d476bfc..4b8bdc8fe 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocCallbackTag.baseline @@ -59,11 +59,11 @@ { "label": "eventName3: any" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -90,11 +90,11 @@ { "label": "eventName3: any" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -121,11 +121,11 @@ { "label": "eventName3: any" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline index 58c8b36f3..c8f35b8fd 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSDocTags.baseline @@ -112,11 +112,11 @@ { "label": "value: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -140,8 +140,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -165,8 +164,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -190,8 +188,7 @@ "parameters": [] } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline index 3ef7b0bf7..ba9dac6db 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpJSMissingPropertyAccess.baseline @@ -3,7 +3,14 @@ // foo.filter() // ^ // | ---------------------------------------------------------------------- -// | No signaturehelp at /**/. +// | ReadonlyArray.filter(**predicate: (value: T, index: number, array: readonly T[]) => value is S**, thisArg?: any): S[] +// | 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. +// | // | ---------------------------------------------------------------------- [ { @@ -16,6 +23,42 @@ "Name": "", "Data": {} }, - "item": null + "item": { + "signatures": [ + { + "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" + }, + "parameters": [ + { + "label": "predicate: (value: T, index: number, array: readonly T[]) => value is S" + }, + { + "label": "thisArg?: any" + } + ], + "activeParameter": 0 + }, + { + "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" + }, + "parameters": [ + { + "label": "predicate: (value: T, index: number, array: readonly T[]) => unknown" + }, + { + "label": "thisArg?: any" + } + ], + "activeParameter": 0 + } + ], + "activeSignature": 0 + } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs1.baseline index 4dd6dc8b4..0051b268f 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs1.baseline @@ -54,11 +54,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -85,11 +85,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -116,11 +116,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -147,11 +147,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -178,11 +178,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline index 42f95f62b..78c6b7c1f 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs2.baseline @@ -7,7 +7,14 @@ // fn.call(thisArg, ...arguments, ); // ^ // | ---------------------------------------------------------------------- -// | No signaturehelp at /*1*/. +// | Function.call(thisArg: any, **...argArray: any[]**): any +// | 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. +// | // | ---------------------------------------------------------------------- // }); // }; @@ -23,6 +30,26 @@ "Name": "1", "Data": {} }, - "item": null + "item": { + "signatures": [ + { + "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" + }, + "parameters": [ + { + "label": "thisArg: any" + }, + { + "label": "...argArray: any[]" + } + ], + "activeParameter": 1 + } + ], + "activeSignature": 0 + } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline index 0bfd6e0bd..07690179e 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpRestArgs3.baseline @@ -39,7 +39,8 @@ { "label": "source: U" } - ] + ], + "activeParameter": 1 }, { "label": "assign(target: T, source1: U, source2: V): T & U & V", @@ -57,7 +58,8 @@ { "label": "source2: V" } - ] + ], + "activeParameter": 1 }, { "label": "assign(target: T, source1: U, source2: V, source3: W): T & U & V & W", @@ -78,7 +80,8 @@ { "label": "source3: W" } - ] + ], + "activeParameter": 1 }, { "label": "assign(target: object, ...sources: any[]): any", @@ -93,11 +96,11 @@ { "label": "...sources: any[]" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 3, - "activeParameter": 1 + "activeSignature": 3 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpSkippedArgs1.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpSkippedArgs1.baseline index 72b1c3664..e100bb616 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpSkippedArgs1.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpSkippedArgs1.baseline @@ -47,11 +47,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -78,11 +78,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -109,11 +109,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -140,11 +140,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } }, { @@ -171,11 +171,11 @@ { "label": "c: number" } - ] + ], + "activeParameter": 4 } ], - "activeSignature": 0, - "activeParameter": 4 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline index 04519d87b..8fded6dda 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpTypeArguments2.baseline @@ -120,11 +120,11 @@ { "label": "W" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -158,11 +158,11 @@ { "label": "W" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } }, { @@ -196,11 +196,11 @@ { "label": "W" } - ] + ], + "activeParameter": 2 } ], - "activeSignature": 0, - "activeParameter": 2 + "activeSignature": 0 } }, { @@ -234,11 +234,11 @@ { "label": "W" } - ] + ], + "activeParameter": 3 } ], - "activeSignature": 0, - "activeParameter": 3 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline index 3bc1d52da..fb0b57ecb 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpWithUnknown.baseline @@ -32,11 +32,11 @@ { "label": "x: string" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelp_unionType.baseline b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelp_unionType.baseline index dfd2d4052..de46967af 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/signatureHelp_unionType.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/signatureHelp_unionType.baseline @@ -47,11 +47,11 @@ { "label": "fn?: ((x: string) => string) | ((y: number) => number)" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -72,11 +72,11 @@ { "label": "x: string | number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } }, { @@ -97,11 +97,11 @@ { "label": "x: string | number" } - ] + ], + "activeParameter": 0 } ], - "activeSignature": 0, - "activeParameter": 0 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline index a605b3403..543be1ccc 100644 --- a/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline +++ b/testdata/baselines/reference/fourslash/signatureHelp/trailingCommaSignatureHelp.baseline @@ -43,7 +43,8 @@ { "label": "n: number" } - ] + ], + "activeParameter": 1 }, { "label": "str(n: number, radix: number): string", @@ -58,11 +59,11 @@ { "label": "radix: number" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 1, - "activeParameter": 1 + "activeSignature": 1 } }, { @@ -83,11 +84,11 @@ { "label": "a: 2" } - ] + ], + "activeParameter": 1 } ], - "activeSignature": 0, - "activeParameter": 1 + "activeSignature": 0 } } ] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline index 3403e09e0..1b14590dc 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefs.baseline @@ -91,7 +91,7 @@ Config File Names:: "character": 29 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline index 86588d554..46a15f07a 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsDefinitionInMappedFile.baseline @@ -75,7 +75,7 @@ Config File Names:: "character": 0 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline index e11f907ae..146f249b7 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsStartingAtDefinition.baseline @@ -129,7 +129,7 @@ Config File Names:: "character": 16 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline index c07f94032..07171af38 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsFindAllRefsTargetDoesNotExist.baseline @@ -91,7 +91,7 @@ Config File Names:: "character": 38 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline index 19bddaea8..dab19dd2d 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProject.baseline @@ -73,7 +73,7 @@ Config File Names:: "character": 4 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline index fa57e3f9a..7bea29dfe 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsOpeningOriginalLocationProjectDisableSourceOfProjectReferenceRedirect.baseline @@ -73,7 +73,7 @@ Config File Names:: "character": 4 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline index ec8c01300..495562c58 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoading.baseline @@ -91,7 +91,7 @@ Config File Names:: "character": 25 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -118,7 +118,7 @@ Config File Names:: "character": 2 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline index e544f1b7e..fe379c37d 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsAncestorSiblingProjectsLoadingDisableSolutionSearching.baseline @@ -87,7 +87,7 @@ Config File Names:: "character": 25 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -114,7 +114,7 @@ Config File Names:: "character": 2 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline index d65075638..f8e6887b3 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -110,7 +110,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline index 26e0d6071..deff2e52f 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -119,7 +119,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline index 26e216f15..0792eae63 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -110,7 +110,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline index 34ead087e..92d0083b8 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -119,7 +119,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline index 744a08f01..b7c565586 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -110,7 +110,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline index a84a5fd03..486127f0d 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -119,7 +119,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline index b9b50f45d..91f7b2f7d 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -110,7 +110,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline index 8f986664f..1e0455ffa 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -119,7 +119,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline index 23659d8d8..fbf99a594 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -68,7 +68,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline index 46b5b8d57..c88b86be0 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -77,7 +77,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline index bf66bd9fe..04c077884 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -68,7 +68,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline index b7fcab837..387d2817a 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsDisabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -77,7 +77,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline index e75c517c0..10f5deff3 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsMissing.baseline @@ -68,7 +68,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline index d98007bb4..b20b88cac 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreDisabledDeclMapIsPresent.baseline @@ -77,7 +77,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline index fd2ef7802..634f5d5ab 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsMissing.baseline @@ -68,7 +68,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline index 455c0744b..be1499ba2 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDeclarationInOtherProjectProjIsNotLoadedRefdProjLoadingIsEnabledProjRefRedirectsAreEnabledDeclMapIsPresent.baseline @@ -77,7 +77,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline index 109e42807..1cf21205b 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsDoesNotTryToSearchProjectAfterItsUpdateDoesNotIncludeTheFile.baseline @@ -412,7 +412,7 @@ Config File Names:: "character": 1 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline index 176a89c9d..e051740ac 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsOpenFileInConfiguredProjectThatWillBeRemoved.baseline @@ -108,7 +108,7 @@ Config File Names:: "character": 16 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline index 4707f0a90..658e49124 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsOverlappingProjects.baseline @@ -114,7 +114,7 @@ Config File Names:: "character": 26 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -205,7 +205,7 @@ Config:: "character": 26 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline index aaf116174..22558923b 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsProjectWithOwnFilesReferencingFileFromReferencedProject.baseline @@ -387,7 +387,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -465,7 +465,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline index d98432e86..e09956e1d 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProject.baseline @@ -137,7 +137,7 @@ Config File Names:: "character": 16 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline index 1c5b3a716..8d8dd028a 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsRootOfReferencedProjectDeclarationMaps.baseline @@ -342,7 +342,7 @@ Config File Names:: "character": 16 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline index 9c58b1571..ba44b2847 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectDirectly.baseline @@ -331,7 +331,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -405,7 +405,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline index 5eaa2c755..43a1190dc 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectly.baseline @@ -504,7 +504,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -580,7 +580,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline index 5a6e45d79..3b8eae0e6 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoad.baseline @@ -490,7 +490,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -565,7 +565,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline index 2f2df123c..19287e15a 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionReferencingDefaultProjectIndirectlyThroughDisableReferencedProjectLoadInOneButWithoutItInAnother.baseline @@ -505,7 +505,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -581,7 +581,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline index 42f55d967..4900d5c94 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSolutionWithDisableReferencedProjectLoadReferencingDefaultProjectDirectly.baseline @@ -318,7 +318,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } @@ -391,7 +391,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline index 91a1f25a3..323d02cd9 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralProperty.baseline @@ -94,7 +94,7 @@ Config File Names:: "character": 11 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline index 950d47029..8060e5b00 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAsObjectLiteralPropertyTypes.baseline @@ -93,7 +93,7 @@ Config File Names:: "character": 11 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline index 79d114c2d..5b7188647 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessArrowFunctionAssignment.baseline @@ -93,7 +93,7 @@ Config File Names:: "character": 7 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline index ea029f119..93e19e498 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessMethodOfClassExpression.baseline @@ -95,7 +95,7 @@ Config File Names:: "character": 9 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline index 00d57bb41..2b1d25aaa 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsSpecialHandlingOfLocalnessObjectLiteralProperty.baseline @@ -93,7 +93,7 @@ Config File Names:: "character": 11 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline b/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline index d1dde7193..78d043b55 100644 --- a/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline +++ b/testdata/baselines/reference/fourslash/state/findAllRefsTwoProjectsOpenAndOneProjectReferences.baseline @@ -280,7 +280,7 @@ Config File Names:: "character": 13 }, "context": { - "includeDeclaration": false + "includeDeclaration": true } } } diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyAccessor.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyAccessor.callHierarchy.txt new file mode 100644 index 000000000..68b3d05e3 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyAccessor.callHierarchy.txt @@ -0,0 +1,67 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: property +├ containerName: C +├ file: /callHierarchyAccessor.ts +├ span: +│ ╭ /callHierarchyAccessor.ts:6:5-8:6 +│ │ 6: get bar() { +│ │ ^^^^^^^^^^^ +│ │ 7: return baz(); +│ │ ^^^^^^^^^^^^^^^^^^^^^ +│ │ 8: } +│ │ ^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyAccessor.ts:6:9-6:12 +│ │ 6: get bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyAccessor.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyAccessor.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: new C().bar; +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyAccessor.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyAccessor.ts:2:13-2:16 +│ │ │ 2: new C().bar; +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyAccessor.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyAccessor.ts:11:1-12:2 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 12: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyAccessor.ts:11:10-11:13 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyAccessor.ts:7:16-7:19 +│ │ │ 7: return baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCallExpressionByConstNamedFunctionExpression.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCallExpressionByConstNamedFunctionExpression.callHierarchy.txt new file mode 100644 index 000000000..bfa14daf2 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCallExpressionByConstNamedFunctionExpression.callHierarchy.txt @@ -0,0 +1,108 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyCallExpressionByConstNamedFunctionExpression.ts +├ span: +│ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:5:13-7:2 +│ │ 5: const bar = function () { +│ │ ^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:5:7-5:10 +│ │ 5: const bar = function () { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyCallExpressionByConstNamedFunctionExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:2:5-2:8 +│ │ │ 2: bar(); +│ │ │ ^^^ +│ ╰ ╰ +│ ╭ from: +│ │ ╭ name: /callHierarchyCallExpressionByConstNamedFunctionExpression.ts +│ │ ├ kind: file +│ │ ├ file: /callHierarchyCallExpressionByConstNamedFunctionExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:1:1-12:6 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ │ 4: +│ │ │ │ ^ +│ │ │ │ 5: const bar = function () { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 6: baz(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 7: } +│ │ │ │ ^ +│ │ │ │ 8: +│ │ │ │ ^ +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ │ 11: +│ │ │ │ ^ +│ │ │ │ 12: bar() +│ │ │ │ ^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:1:1-1:1 +│ │ │ │ 1: function foo() { +│ │ │ │ < +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:12:1-12:4 +│ │ │ 12: bar() +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyCallExpressionByConstNamedFunctionExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyCallExpressionByConstNamedFunctionExpression.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClass.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClass.callHierarchy.txt new file mode 100644 index 000000000..801b8d404 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClass.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyClass.ts +├ span: +│ ╭ /callHierarchyClass.ts:5:1-7:2 +│ │ 5: function bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 6: new Baz(); +│ │ ^^^^^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyClass.ts:5:10-5:13 +│ │ 5: function bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyClass.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClass.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClass.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyClass.ts:2:5-2:8 +│ │ │ 2: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: Baz +│ │ ├ kind: class +│ │ ├ file: /callHierarchyClass.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClass.ts:9:1-10:2 +│ │ │ │ 9: class Baz { +│ │ │ │ ^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClass.ts:9:7-9:10 +│ │ │ │ 9: class Baz { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyClass.ts:6:9-6:12 +│ │ │ 6: new Baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassPropertyArrowFunction.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassPropertyArrowFunction.callHierarchy.txt new file mode 100644 index 000000000..6a78d564e --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassPropertyArrowFunction.callHierarchy.txt @@ -0,0 +1,44 @@ +// === Call Hierarchy === +╭ name: callee +├ kind: function +├ containerName: C +├ file: /callHierarchyClassPropertyArrowFunction.ts +├ span: +│ ╭ /callHierarchyClassPropertyArrowFunction.ts:6:14-7:6 +│ │ 6: callee = () => { +│ │ ^^^^^^^ +│ │ 7: } +│ │ ^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyClassPropertyArrowFunction.ts:6:5-6:11 +│ │ 6: callee = () => { +│ │ ^^^^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: caller +│ │ ├ kind: function +│ │ ├ containerName: C +│ │ ├ file: /callHierarchyClassPropertyArrowFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClassPropertyArrowFunction.ts:2:14-4:6 +│ │ │ │ 2: caller = () => { +│ │ │ │ ^^^^^^^ +│ │ │ │ 3: this.callee(); +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 4: } +│ │ │ │ ^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClassPropertyArrowFunction.ts:2:5-2:11 +│ │ │ │ 2: caller = () => { +│ │ │ │ ^^^^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyClassPropertyArrowFunction.ts:3:14-3:20 +│ │ │ 3: this.callee(); +│ │ │ ^^^^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock.callHierarchy.txt new file mode 100644 index 000000000..cef1e4637 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock.callHierarchy.txt @@ -0,0 +1,140 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyClassStaticBlock.ts +├ span: +│ ╭ /callHierarchyClassStaticBlock.ts:7:9-11:10 +│ │ 7: function bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 8: baz(); +│ │ ^^^^^^^^^^^^^^^^^^ +│ │ 9: quxx(); +│ │ ^^^^^^^^^^^^^^^^^^^ +│ │ 10: baz(); +│ │ ^^^^^^^^^^^^^^^^^^ +│ │ 11: } +│ │ ^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyClassStaticBlock.ts:7:18-7:21 +│ │ 7: function bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyClassStaticBlock.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:3:9-5:10 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 4: bar(); +│ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ 5: } +│ │ │ │ ^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:3:18-3:21 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ├ incoming: +│ │ │ ╭ from: +│ │ │ │ ╭ name: static {} +│ │ │ │ ├ kind: constructor +│ │ │ │ ├ file: /callHierarchyClassStaticBlock.ts +│ │ │ │ ├ span: +│ │ │ │ │ ╭ /callHierarchyClassStaticBlock.ts:2:5-14:6 +│ │ │ │ │ │ 2: static { +│ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ 3: function foo() { +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 4: bar(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 5: } +│ │ │ │ │ │ ^^^^^^^^^ +│ │ │ │ │ │ 6: +│ │ │ │ │ │ ^ +│ │ │ │ │ │ 7: function bar() { +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 8: baz(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 9: quxx(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 10: baz(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 11: } +│ │ │ │ │ │ ^^^^^^^^^ +│ │ │ │ │ │ 12: +│ │ │ │ │ │ ^ +│ │ │ │ │ │ 13: foo(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^ +│ │ │ │ │ │ 14: } +│ │ │ │ │ │ ^^^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ selectionSpan: +│ │ │ │ │ ╭ /callHierarchyClassStaticBlock.ts:2:5-2:11 +│ │ │ │ │ │ 2: static { +│ │ │ │ │ │ ^^^^^^ +│ │ │ │ │ ╰ +│ │ │ │ ╰ incoming: none +│ │ │ ├ fromSpans: +│ │ │ │ ╭ /callHierarchyClassStaticBlock.ts:13:9-13:12 +│ │ │ │ │ 13: foo(); +│ │ │ │ │ ^^^ +│ │ ╰ ╰ ╰ +│ ├ fromSpans: +│ │ ╭ /callHierarchyClassStaticBlock.ts:4:13-4:16 +│ │ │ 4: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyClassStaticBlock.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:17:1-18:2 +│ │ │ │ 17: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 18: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:17:10-17:13 +│ │ │ │ 17: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyClassStaticBlock.ts:8:13-8:16 +│ │ │ 8: baz(); +│ │ │ ^^^ +│ │ ╰ +│ │ ╭ /callHierarchyClassStaticBlock.ts:10:13-10:16 +│ │ │ 10: baz(); +│ │ │ ^^^ +│ ╰ ╰ +│ ╭ to: +│ │ ╭ name: quxx +│ │ ├ kind: function +│ │ ├ file: /callHierarchyClassStaticBlock.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:20:1-21:2 +│ │ │ │ 20: function quxx() { +│ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ 21: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClassStaticBlock.ts:20:10-20:14 +│ │ │ │ 20: function quxx() { +│ │ │ │ ^^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyClassStaticBlock.ts:9:13-9:17 +│ │ │ 9: quxx(); +│ │ │ ^^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock2.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock2.callHierarchy.txt new file mode 100644 index 000000000..dd4bfa270 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyClassStaticBlock2.callHierarchy.txt @@ -0,0 +1,140 @@ +// === Call Hierarchy === +╭ name: static {} +├ kind: constructor +├ file: /callHierarchyClassStaticBlock2.ts +├ span: +│ ╭ /callHierarchyClassStaticBlock2.ts:2:5-14:6 +│ │ 2: static { +│ │ ^^^^^^^^ +│ │ 3: function foo() { +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ 4: bar(); +│ │ ^^^^^^^^^^^^^^^^^^ +│ │ 5: } +│ │ ^^^^^^^^^ +│ │ 6: +│ │ ^ +│ │ 7: function bar() { +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ 8: baz(); +│ │ ^^^^^^^^^^^^^^^^^^ +│ │ 9: quxx(); +│ │ ^^^^^^^^^^^^^^^^^^^ +│ │ 10: baz(); +│ │ ^^^^^^^^^^^^^^^^^^ +│ │ 11: } +│ │ ^^^^^^^^^ +│ │ 12: +│ │ ^ +│ │ 13: foo(); +│ │ ^^^^^^^^^^^^^^ +│ │ 14: } +│ │ ^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyClassStaticBlock2.ts:2:5-2:11 +│ │ 2: static { +│ │ ^^^^^^ +│ ╰ +├ incoming: none +├ outgoing: +│ ╭ to: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyClassStaticBlock2.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyClassStaticBlock2.ts:3:9-5:10 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 4: bar(); +│ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ 5: } +│ │ │ │ ^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyClassStaticBlock2.ts:3:18-3:21 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ├ outgoing: +│ │ │ ╭ to: +│ │ │ │ ╭ name: bar +│ │ │ │ ├ kind: function +│ │ │ │ ├ file: /callHierarchyClassStaticBlock2.ts +│ │ │ │ ├ span: +│ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:7:9-11:10 +│ │ │ │ │ │ 7: function bar() { +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 8: baz(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 9: quxx(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 10: baz(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 11: } +│ │ │ │ │ │ ^^^^^^^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ selectionSpan: +│ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:7:18-7:21 +│ │ │ │ │ │ 7: function bar() { +│ │ │ │ │ │ ^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ outgoing: +│ │ │ │ │ ╭ to: +│ │ │ │ │ │ ╭ name: baz +│ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ ├ file: /callHierarchyClassStaticBlock2.ts +│ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:17:1-18:2 +│ │ │ │ │ │ │ │ 17: function baz() { +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 18: } +│ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:17:10-17:13 +│ │ │ │ │ │ │ │ 17: function baz() { +│ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ╰ outgoing: none +│ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:8:13-8:16 +│ │ │ │ │ │ │ 8: baz(); +│ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ ╰ +│ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:10:13-10:16 +│ │ │ │ │ │ │ 10: baz(); +│ │ │ │ │ │ │ ^^^ +│ │ │ │ │ ╰ ╰ +│ │ │ │ │ ╭ to: +│ │ │ │ │ │ ╭ name: quxx +│ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ ├ file: /callHierarchyClassStaticBlock2.ts +│ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:20:1-21:2 +│ │ │ │ │ │ │ │ 20: function quxx() { +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 21: } +│ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:20:10-20:14 +│ │ │ │ │ │ │ │ 20: function quxx() { +│ │ │ │ │ │ │ │ ^^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ╰ outgoing: none +│ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:9:13-9:17 +│ │ │ │ │ │ │ 9: quxx(); +│ │ │ │ │ │ │ ^^^^ +│ │ │ │ ╰ ╰ ╰ +│ │ │ ├ fromSpans: +│ │ │ │ ╭ /callHierarchyClassStaticBlock2.ts:4:13-4:16 +│ │ │ │ │ 4: bar(); +│ │ │ │ │ ^^^ +│ │ ╰ ╰ ╰ +│ ├ fromSpans: +│ │ ╭ /callHierarchyClassStaticBlock2.ts:13:9-13:12 +│ │ │ 13: foo(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedArrowFunction.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedArrowFunction.callHierarchy.txt new file mode 100644 index 000000000..9d7eef6e0 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedArrowFunction.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyConstNamedArrowFunction.ts +├ span: +│ ╭ /callHierarchyConstNamedArrowFunction.ts:5:13-7:2 +│ │ 5: const bar = () => { +│ │ ^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyConstNamedArrowFunction.ts:5:7-5:10 +│ │ 5: const bar = () => { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedArrowFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedArrowFunction.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedArrowFunction.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedArrowFunction.ts:2:5-2:8 +│ │ │ 2: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedArrowFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedArrowFunction.ts:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedArrowFunction.ts:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedArrowFunction.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedClassExpression.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedClassExpression.callHierarchy.txt new file mode 100644 index 000000000..61abee5be --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedClassExpression.callHierarchy.txt @@ -0,0 +1,70 @@ +// === Call Hierarchy === +╭ name: Bar +├ kind: class +├ file: /callHierarchyConstNamedClassExpression.ts +├ span: +│ ╭ /callHierarchyConstNamedClassExpression.ts:5:13-9:2 +│ │ 5: const Bar = class { +│ │ ^^^^^^^ +│ │ 6: constructor() { +│ │ ^^^^^^^^^^^^^^^^^^^ +│ │ 7: baz(); +│ │ ^^^^^^^^^^^^^^ +│ │ 8: } +│ │ ^^^^^ +│ │ 9: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyConstNamedClassExpression.ts:5:7-5:10 +│ │ 5: const Bar = class { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedClassExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedClassExpression.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: new Bar(); +│ │ │ │ ^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedClassExpression.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedClassExpression.ts:2:9-2:12 +│ │ │ 2: new Bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedClassExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedClassExpression.ts:11:1-12:2 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 12: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedClassExpression.ts:11:10-11:13 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedClassExpression.ts:7:9-7:12 +│ │ │ 7: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedFunctionExpression.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedFunctionExpression.callHierarchy.txt new file mode 100644 index 000000000..d1bb8a767 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyConstNamedFunctionExpression.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyConstNamedFunctionExpression.ts +├ span: +│ ╭ /callHierarchyConstNamedFunctionExpression.ts:5:13-7:2 +│ │ 5: const bar = function () { +│ │ ^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyConstNamedFunctionExpression.ts:5:7-5:10 +│ │ 5: const bar = function () { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedFunctionExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:2:5-2:8 +│ │ │ 2: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyConstNamedFunctionExpression.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyConstNamedFunctionExpression.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerName.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerName.callHierarchy.txt new file mode 100644 index 000000000..237f7ae11 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerName.callHierarchy.txt @@ -0,0 +1,166 @@ +// === Call Hierarchy === +╭ name: f +├ kind: function +├ file: /callHierarchyContainerName.ts +├ span: +│ ╭ /callHierarchyContainerName.ts:1:1-1:16 +│ │ 1: function f() {} +│ │ ^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyContainerName.ts:1:10-1:11 +│ │ 1: function f() {} +│ │ ^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: sameName +│ │ ├ kind: method +│ │ ├ containerName: A +│ │ ├ file: /callHierarchyContainerName.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyContainerName.ts:4:3-6:4 +│ │ │ │ 4: static sameName() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 5: f(); +│ │ │ │ ^^^^^^^^ +│ │ │ │ 6: } +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyContainerName.ts:4:10-4:18 +│ │ │ │ 4: static sameName() { +│ │ │ │ ^^^^^^^^ +│ │ │ ╰ +│ │ ├ incoming: +│ │ │ ╭ from: +│ │ │ │ ╭ name: sameName +│ │ │ │ ├ kind: method +│ │ │ │ ├ containerName: B +│ │ │ │ ├ file: /callHierarchyContainerName.ts +│ │ │ │ ├ span: +│ │ │ │ │ ╭ /callHierarchyContainerName.ts:10:3-12:4 +│ │ │ │ │ │ 10: sameName() { +│ │ │ │ │ │ ^^^^^^^^^^^^ +│ │ │ │ │ │ 11: A.sameName(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 12: } +│ │ │ │ │ │ ^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ selectionSpan: +│ │ │ │ │ ╭ /callHierarchyContainerName.ts:10:3-10:11 +│ │ │ │ │ │ 10: sameName() { +│ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ incoming: +│ │ │ │ │ ╭ from: +│ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ ├ kind: property +│ │ │ │ │ │ ├ containerName: Obj +│ │ │ │ │ │ ├ file: /callHierarchyContainerName.ts +│ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:16:3-18:4 +│ │ │ │ │ │ │ │ 16: get sameName() { +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 17: return new B().sameName; +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 18: } +│ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:16:7-16:15 +│ │ │ │ │ │ │ │ 16: get sameName() { +│ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ │ │ ├ containerName: Foo +│ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerName.ts +│ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:22:3-24:4 +│ │ │ │ │ │ │ │ │ │ 22: function sameName() { +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ 23: return Obj.sameName; +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ 24: } +│ │ │ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:22:12-22:20 +│ │ │ │ │ │ │ │ │ │ 22: function sameName() { +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ │ │ ╭ name: C +│ │ │ │ │ │ │ │ │ │ ├ kind: class +│ │ │ │ │ │ │ │ │ │ ├ containerName: Foo +│ │ │ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerName.ts +│ │ │ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:26:3-30:4 +│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C { +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 27: constructor() { +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 28: sameName(); +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 29: } +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 30: } +│ │ │ │ │ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:26:16-26:17 +│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C { +│ │ │ │ │ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ │ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ │ │ │ │ │ │ ├ containerName: Bar +│ │ │ │ │ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerName.ts +│ │ │ │ │ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:34:20-34:37 +│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:34:9-34:17 +│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ │ │ ╰ incoming: none +│ │ │ │ │ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:34:34-34:35 +│ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:28:7-28:15 +│ │ │ │ │ │ │ │ │ │ │ 28: sameName(); +│ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:23:16-23:24 +│ │ │ │ │ │ │ │ │ 23: return Obj.sameName; +│ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ ╭ /callHierarchyContainerName.ts:17:20-17:28 +│ │ │ │ │ │ │ 17: return new B().sameName; +│ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ ╰ ╰ ╰ +│ │ │ ├ fromSpans: +│ │ │ │ ╭ /callHierarchyContainerName.ts:11:7-11:15 +│ │ │ │ │ 11: A.sameName(); +│ │ │ │ │ ^^^^^^^^ +│ │ ╰ ╰ ╰ +│ ├ fromSpans: +│ │ ╭ /callHierarchyContainerName.ts:5:5-5:6 +│ │ │ 5: f(); +│ │ │ ^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerNameServer.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerNameServer.callHierarchy.txt new file mode 100644 index 000000000..22c38f323 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyContainerNameServer.callHierarchy.txt @@ -0,0 +1,166 @@ +// === Call Hierarchy === +╭ name: f +├ kind: function +├ file: /callHierarchyContainerNameServer.ts +├ span: +│ ╭ /callHierarchyContainerNameServer.ts:1:1-1:16 +│ │ 1: function f() {} +│ │ ^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyContainerNameServer.ts:1:10-1:11 +│ │ 1: function f() {} +│ │ ^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: sameName +│ │ ├ kind: method +│ │ ├ containerName: A +│ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyContainerNameServer.ts:4:3-6:4 +│ │ │ │ 4: static sameName() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 5: f(); +│ │ │ │ ^^^^^^^^ +│ │ │ │ 6: } +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyContainerNameServer.ts:4:10-4:18 +│ │ │ │ 4: static sameName() { +│ │ │ │ ^^^^^^^^ +│ │ │ ╰ +│ │ ├ incoming: +│ │ │ ╭ from: +│ │ │ │ ╭ name: sameName +│ │ │ │ ├ kind: method +│ │ │ │ ├ containerName: B +│ │ │ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ │ │ ├ span: +│ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:10:3-12:4 +│ │ │ │ │ │ 10: sameName() { +│ │ │ │ │ │ ^^^^^^^^^^^^ +│ │ │ │ │ │ 11: A.sameName(); +│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ 12: } +│ │ │ │ │ │ ^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ selectionSpan: +│ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:10:3-10:11 +│ │ │ │ │ │ 10: sameName() { +│ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ ╰ +│ │ │ │ ├ incoming: +│ │ │ │ │ ╭ from: +│ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ ├ kind: property +│ │ │ │ │ │ ├ containerName: Obj +│ │ │ │ │ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:16:3-18:4 +│ │ │ │ │ │ │ │ 16: get sameName() { +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 17: return new B().sameName; +│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ 18: } +│ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:16:7-16:15 +│ │ │ │ │ │ │ │ 16: get sameName() { +│ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ │ │ ├ containerName: Foo +│ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:22:3-24:4 +│ │ │ │ │ │ │ │ │ │ 22: function sameName() { +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ 23: return Obj.sameName; +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ 24: } +│ │ │ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:22:12-22:20 +│ │ │ │ │ │ │ │ │ │ 22: function sameName() { +│ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ │ │ ╭ name: C +│ │ │ │ │ │ │ │ │ │ ├ kind: class +│ │ │ │ │ │ │ │ │ │ ├ containerName: Foo +│ │ │ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ │ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:26:3-30:4 +│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C { +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 27: constructor() { +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 28: sameName(); +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 29: } +│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ 30: } +│ │ │ │ │ │ │ │ │ │ │ │ ^^^ +│ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:26:16-26:17 +│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C { +│ │ │ │ │ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ ├ incoming: +│ │ │ │ │ │ │ │ │ │ │ ╭ from: +│ │ │ │ │ │ │ │ │ │ │ │ ╭ name: sameName +│ │ │ │ │ │ │ │ │ │ │ │ ├ kind: function +│ │ │ │ │ │ │ │ │ │ │ │ ├ containerName: Bar +│ │ │ │ │ │ │ │ │ │ │ │ ├ file: /callHierarchyContainerNameServer.ts +│ │ │ │ │ │ │ │ │ │ │ │ ├ span: +│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:34:20-34:37 +│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ │ │ ├ selectionSpan: +│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:34:9-34:17 +│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ │ │ │ │ │ ╰ +│ │ │ │ │ │ │ │ │ │ │ │ ╰ incoming: none +│ │ │ │ │ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:34:34-34:35 +│ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C(); +│ │ │ │ │ │ │ │ │ │ │ │ │ ^ +│ │ │ │ │ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:28:7-28:15 +│ │ │ │ │ │ │ │ │ │ │ 28: sameName(); +│ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:23:16-23:24 +│ │ │ │ │ │ │ │ │ 23: return Obj.sameName; +│ │ │ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ │ │ ╰ ╰ ╰ +│ │ │ │ │ ├ fromSpans: +│ │ │ │ │ │ ╭ /callHierarchyContainerNameServer.ts:17:20-17:28 +│ │ │ │ │ │ │ 17: return new B().sameName; +│ │ │ │ │ │ │ ^^^^^^^^ +│ │ │ │ ╰ ╰ ╰ +│ │ │ ├ fromSpans: +│ │ │ │ ╭ /callHierarchyContainerNameServer.ts:11:7-11:15 +│ │ │ │ │ 11: A.sameName(); +│ │ │ │ │ ^^^^^^^^ +│ │ ╰ ╰ ╰ +│ ├ fromSpans: +│ │ ╭ /callHierarchyContainerNameServer.ts:5:5-5:6 +│ │ │ 5: f(); +│ │ │ ^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCrossFile.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCrossFile.callHierarchy.txt new file mode 100644 index 000000000..e11d62c05 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyCrossFile.callHierarchy.txt @@ -0,0 +1,64 @@ +// === Call Hierarchy === +╭ name: createModelReference +├ kind: function +├ file: /a.ts +├ span: +│ ╭ /a.ts:1:1-1:42 +│ │ 1: export function createModelReference() {} +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /a.ts:1:17-1:37 +│ │ 1: export function createModelReference() {} +│ │ ^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: openElementsAtEditor +│ │ ├ kind: function +│ │ ├ file: /b.ts +│ │ ├ span: +│ │ │ ╭ /b.ts:2:1-4:2 +│ │ │ │ 2: function openElementsAtEditor() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 3: createModelReference(); +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 4: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /b.ts:2:10-2:30 +│ │ │ │ 2: function openElementsAtEditor() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /b.ts:3:3-3:23 +│ │ │ 3: createModelReference(); +│ │ │ ^^^^^^^^^^^^^^^^^^^^ +│ ╰ ╰ +│ ╭ from: +│ │ ╭ name: registerDefaultLanguageCommand +│ │ ├ kind: function +│ │ ├ file: /c.ts +│ │ ├ span: +│ │ │ ╭ /c.ts:2:1-4:2 +│ │ │ │ 2: function registerDefaultLanguageCommand() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 3: createModelReference(); +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 4: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /c.ts:2:10-2:40 +│ │ │ │ 2: function registerDefaultLanguageCommand() { +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /c.ts:3:3-3:23 +│ │ │ 3: createModelReference(); +│ │ │ ^^^^^^^^^^^^^^^^^^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyDecorator.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyDecorator.callHierarchy.txt new file mode 100644 index 000000000..879d802f6 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyDecorator.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyDecorator.ts +├ span: +│ ╭ /callHierarchyDecorator.ts:5:1-7:2 +│ │ 5: function bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyDecorator.ts:5:10-5:13 +│ │ 5: function bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: Foo +│ │ ├ kind: class +│ │ ├ file: /callHierarchyDecorator.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyDecorator.ts:1:1-3:2 +│ │ │ │ 1: @bar +│ │ │ │ ^^^^ +│ │ │ │ 2: class Foo { +│ │ │ │ ^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyDecorator.ts:2:7-2:10 +│ │ │ │ 2: class Foo { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyDecorator.ts:1:2-1:5 +│ │ │ 1: @bar +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyDecorator.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyDecorator.ts:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyDecorator.ts:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyDecorator.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultClass.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultClass.callHierarchy.txt new file mode 100644 index 000000000..430a44c47 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultClass.callHierarchy.txt @@ -0,0 +1,70 @@ +// === Call Hierarchy === +╭ name: default +├ kind: class +├ file: /other.ts +├ span: +│ ╭ /other.ts:1:1-5:2 +│ │ 1: export default class { +│ │ ^^^^^^^^^^^^^^^^^^^^^^ +│ │ 2: constructor() { +│ │ ^^^^^^^^^^^^^^^^^^^ +│ │ 3: baz(); +│ │ ^^^^^^^^^^^^^^ +│ │ 4: } +│ │ ^^^^^ +│ │ 5: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /other.ts:1:8-1:15 +│ │ 1: export default class { +│ │ ^^^^^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:3:1-5:2 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 4: new Bar(); +│ │ │ │ ^^^^^^^^^^^^^^ +│ │ │ │ 5: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:3:10-3:13 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:4:9-4:12 +│ │ │ 4: new Bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /other.ts +│ │ ├ span: +│ │ │ ╭ /other.ts:7:1-8:2 +│ │ │ │ 7: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 8: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /other.ts:7:10-7:13 +│ │ │ │ 7: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /other.ts:3:9-3:12 +│ │ │ 3: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultFunction.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultFunction.callHierarchy.txt new file mode 100644 index 000000000..eba573d57 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportDefaultFunction.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: default +├ kind: function +├ file: /other.ts +├ span: +│ ╭ /other.ts:1:1-3:2 +│ │ 1: export default function () { +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ 2: baz(); +│ │ ^^^^^^^^^^ +│ │ 3: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /other.ts:1:8-1:15 +│ │ 1: export default function () { +│ │ ^^^^^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:3:1-5:2 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 4: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 5: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:3:10-3:13 +│ │ │ │ 3: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:4:5-4:8 +│ │ │ 4: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /other.ts +│ │ ├ span: +│ │ │ ╭ /other.ts:5:1-6:2 +│ │ │ │ 5: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 6: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /other.ts:5:10-5:13 +│ │ │ │ 5: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /other.ts:2:5-2:8 +│ │ │ 2: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportEqualsFunction.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportEqualsFunction.callHierarchy.txt new file mode 100644 index 000000000..3e85787a8 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyExportEqualsFunction.callHierarchy.txt @@ -0,0 +1,48 @@ +// === Call Hierarchy === +╭ name: /other.ts +├ kind: module +├ file: /other.ts +├ span: +│ ╭ /other.ts:1:1-6:2 +│ │ 1: export = function () { +│ │ ^^^^^^^^^^^^^^^^^^^^^^ +│ │ 2: baz(); +│ │ ^^^^^^^^^^ +│ │ 3: } +│ │ ^ +│ │ 4: +│ │ ^ +│ │ 5: function baz() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 6: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /other.ts:1:1-1:1 +│ │ 1: export = function () { +│ │ < +│ ╰ +├ incoming: none +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /other.ts +│ │ ├ span: +│ │ │ ╭ /other.ts:5:1-6:2 +│ │ │ │ 5: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 6: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /other.ts:5:10-5:13 +│ │ │ │ 5: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /other.ts:2:5-2:8 +│ │ │ 2: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFile.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFile.callHierarchy.txt new file mode 100644 index 000000000..be23e82ae --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFile.callHierarchy.txt @@ -0,0 +1,42 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: function +├ file: /callHierarchyFile.ts +├ span: +│ ╭ /callHierarchyFile.ts:2:1-3:2 +│ │ 2: function foo() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 3: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyFile.ts:2:10-2:13 +│ │ 2: function foo() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: /callHierarchyFile.ts +│ │ ├ kind: file +│ │ ├ file: /callHierarchyFile.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyFile.ts:1:1-3:2 +│ │ │ │ 1: foo(); +│ │ │ │ ^^^^^^ +│ │ │ │ 2: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyFile.ts:1:1-1:1 +│ │ │ │ 1: foo(); +│ │ │ │ < +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyFile.ts:1:1-1:4 +│ │ │ 1: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunction.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunction.callHierarchy.txt new file mode 100644 index 000000000..c43da437e --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunction.callHierarchy.txt @@ -0,0 +1,96 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyFunction.ts +├ span: +│ ╭ /callHierarchyFunction.ts:5:1-9:2 +│ │ 5: function bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: quxx(); +│ │ ^^^^^^^^^^^ +│ │ 8: baz(); +│ │ ^^^^^^^^^^ +│ │ 9: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyFunction.ts:5:10-5:13 +│ │ 5: function bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyFunction.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyFunction.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyFunction.ts:2:5-2:8 +│ │ │ 2: bar(); +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyFunction.ts:11:1-12:2 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 12: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyFunction.ts:11:10-11:13 +│ │ │ │ 11: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyFunction.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +│ │ ╰ +│ │ ╭ /callHierarchyFunction.ts:8:5-8:8 +│ │ │ 8: baz(); +│ │ │ ^^^ +│ ╰ ╰ +│ ╭ to: +│ │ ╭ name: quxx +│ │ ├ kind: function +│ │ ├ file: /callHierarchyFunction.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyFunction.ts:14:1-15:2 +│ │ │ │ 14: function quxx() { +│ │ │ │ ^^^^^^^^^^^^^^^^^ +│ │ │ │ 15: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyFunction.ts:14:10-14:14 +│ │ │ │ 14: function quxx() { +│ │ │ │ ^^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyFunction.ts:7:5-7:9 +│ │ │ 7: quxx(); +│ │ │ ^^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.1.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.1.callHierarchy.txt new file mode 100644 index 000000000..3b77dc6cf --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.1.callHierarchy.txt @@ -0,0 +1,79 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: function +├ file: /a.d.ts +├ span: +│ ╭ /a.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /a.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none +╭ name: foo +├ kind: function +├ file: /b.d.ts +├ span: +│ ╭ /b.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /b.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.2.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.2.callHierarchy.txt new file mode 100644 index 000000000..3b77dc6cf --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.2.callHierarchy.txt @@ -0,0 +1,79 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: function +├ file: /a.d.ts +├ span: +│ ╭ /a.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /a.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none +╭ name: foo +├ kind: function +├ file: /b.d.ts +├ span: +│ ╭ /b.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /b.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.3.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.3.callHierarchy.txt new file mode 100644 index 000000000..3b77dc6cf --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.3.callHierarchy.txt @@ -0,0 +1,79 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: function +├ file: /a.d.ts +├ span: +│ ╭ /a.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /a.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none +╭ name: foo +├ kind: function +├ file: /b.d.ts +├ span: +│ ╭ /b.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /b.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.4.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.4.callHierarchy.txt new file mode 100644 index 000000000..3b77dc6cf --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.4.callHierarchy.txt @@ -0,0 +1,79 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: function +├ file: /a.d.ts +├ span: +│ ╭ /a.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /a.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: number): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none +╭ name: foo +├ kind: function +├ file: /b.d.ts +├ span: +│ ╭ /b.d.ts:1:1-1:40 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /b.d.ts:1:18-1:21 +│ │ 1: declare function foo(x?: string): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: bar +│ │ ├ kind: function +│ │ ├ file: /main.ts +│ │ ├ span: +│ │ │ ╭ /main.ts:1:1-3:2 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.ts:1:10-1:13 +│ │ │ │ 1: function bar() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.5.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.5.callHierarchy.txt new file mode 100644 index 000000000..b4b46fc4f --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyFunctionAmbiguity.5.callHierarchy.txt @@ -0,0 +1,60 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /main.ts +├ span: +│ ╭ /main.ts:1:1-3:2 +│ │ 1: function bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 2: foo(); +│ │ ^^^^^^^^^^ +│ │ 3: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /main.ts:1:10-1:13 +│ │ 1: function bar() { +│ │ ^^^ +│ ╰ +├ incoming: none +├ outgoing: +│ ╭ to: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /a.d.ts +│ │ ├ span: +│ │ │ ╭ /a.d.ts:1:1-1:40 +│ │ │ │ 1: declare function foo(x?: number): void; +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /a.d.ts:1:18-1:21 +│ │ │ │ 1: declare function foo(x?: number): void; +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +│ ╰ ╰ +│ ╭ to: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /b.d.ts +│ │ ├ span: +│ │ │ ╭ /b.d.ts:1:1-1:40 +│ │ │ │ 1: declare function foo(x?: string): void; +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /b.d.ts:1:18-1:21 +│ │ │ │ 1: declare function foo(x?: string): void; +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /main.ts:2:5-2:8 +│ │ │ 2: foo(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyInterfaceMethod.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyInterfaceMethod.callHierarchy.txt new file mode 100644 index 000000000..4cdbb8c53 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyInterfaceMethod.callHierarchy.txt @@ -0,0 +1,48 @@ +// === Call Hierarchy === +╭ name: foo +├ kind: method +├ file: /callHierarchyInterfaceMethod.ts +├ span: +│ ╭ /callHierarchyInterfaceMethod.ts:2:5-2:17 +│ │ 2: foo(): void; +│ │ ^^^^^^^^^^^^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyInterfaceMethod.ts:2:5-2:8 +│ │ 2: foo(): void; +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: /callHierarchyInterfaceMethod.ts +│ │ ├ kind: file +│ │ ├ file: /callHierarchyInterfaceMethod.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyInterfaceMethod.ts:1:1-7:11 +│ │ │ │ 1: interface I { +│ │ │ │ ^^^^^^^^^^^^^ +│ │ │ │ 2: foo(): void; +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ │ 4: +│ │ │ │ ^ +│ │ │ │ 5: const obj: I = { foo() {} }; +│ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ │ │ 6: +│ │ │ │ ^ +│ │ │ │ 7: obj.foo(); +│ │ │ │ ^^^^^^^^^^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyInterfaceMethod.ts:1:1-1:1 +│ │ │ │ 1: interface I { +│ │ │ │ < +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyInterfaceMethod.ts:7:5-7:8 +│ │ │ 7: obj.foo(); +│ │ │ ^^^ +│ ╰ ╰ +╰ outgoing: none \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyJsxElement.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyJsxElement.callHierarchy.txt new file mode 100644 index 000000000..4609c0ecd --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyJsxElement.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: Bar +├ kind: function +├ file: /main.tsx +├ span: +│ ╭ /main.tsx:5:1-7:2 +│ │ 5: function Bar() { +│ │ ^^^^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /main.tsx:5:10-5:13 +│ │ 5: function Bar() { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /main.tsx +│ │ ├ span: +│ │ │ ╭ /main.tsx:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: return ; +│ │ │ │ ^^^^^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.tsx:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /main.tsx:2:13-2:16 +│ │ │ 2: return ; +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /main.tsx +│ │ ├ span: +│ │ │ ╭ /main.tsx:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /main.tsx:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /main.tsx:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyTaggedTemplate.callHierarchy.txt b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyTaggedTemplate.callHierarchy.txt new file mode 100644 index 000000000..e7b0093b0 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/callHierarchy/callHierarchyTaggedTemplate.callHierarchy.txt @@ -0,0 +1,66 @@ +// === Call Hierarchy === +╭ name: bar +├ kind: function +├ file: /callHierarchyTaggedTemplate.ts +├ span: +│ ╭ /callHierarchyTaggedTemplate.ts:5:1-7:2 +│ │ 5: function bar(array: TemplateStringsArray, ...args: any[]) { +│ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +│ │ 6: baz(); +│ │ ^^^^^^^^^^ +│ │ 7: } +│ │ ^ +│ ╰ +├ selectionSpan: +│ ╭ /callHierarchyTaggedTemplate.ts:5:10-5:13 +│ │ 5: function bar(array: TemplateStringsArray, ...args: any[]) { +│ │ ^^^ +│ ╰ +├ incoming: +│ ╭ from: +│ │ ╭ name: foo +│ │ ├ kind: function +│ │ ├ file: /callHierarchyTaggedTemplate.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyTaggedTemplate.ts:1:1-3:2 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 2: bar`a${1}b`; +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 3: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyTaggedTemplate.ts:1:10-1:13 +│ │ │ │ 1: function foo() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ incoming: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyTaggedTemplate.ts:2:5-2:8 +│ │ │ 2: bar`a${1}b`; +│ │ │ ^^^ +│ ╰ ╰ +├ outgoing: +│ ╭ to: +│ │ ╭ name: baz +│ │ ├ kind: function +│ │ ├ file: /callHierarchyTaggedTemplate.ts +│ │ ├ span: +│ │ │ ╭ /callHierarchyTaggedTemplate.ts:9:1-10:2 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^^^^^^^^^^^^^^ +│ │ │ │ 10: } +│ │ │ │ ^ +│ │ │ ╰ +│ │ ├ selectionSpan: +│ │ │ ╭ /callHierarchyTaggedTemplate.ts:9:10-9:13 +│ │ │ │ 9: function baz() { +│ │ │ │ ^^^ +│ │ │ ╰ +│ │ ╰ outgoing: none +│ ├ fromSpans: +│ │ ╭ /callHierarchyTaggedTemplate.ts:6:5-6:8 +│ │ │ 6: baz(); +│ │ │ ^^^ +╰ ╰ ╰ \ No newline at end of file diff --git a/testdata/tests/cases/compiler/importAttributesWithValueComments.ts b/testdata/tests/cases/compiler/importAttributesWithValueComments.ts new file mode 100644 index 000000000..77a7a6ebf --- /dev/null +++ b/testdata/tests/cases/compiler/importAttributesWithValueComments.ts @@ -0,0 +1,13 @@ +// @target: esnext +// @module: esnext + +// @filename: /a.ts +export default { + a: "a", + b: "b", + 1: "1", +} + +// @filename: /b.ts +import a from "./a" with { a: /* a */ "a", "b": /* b */ "b" }; +a;