Skip to content

Misc LSP server / fourslash testing improvements #1591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/tsgo/lsp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"flag"
"fmt"
"os"
Expand All @@ -14,7 +15,7 @@ import (
"github.com/microsoft/typescript-go/internal/vfs/osvfs"
)

func runLSP(args []string) int {
func runLSP(ctx context.Context, args []string) int {
flag := flag.NewFlagSet("lsp", flag.ContinueOnError)
stdio := flag.Bool("stdio", false, "use stdio for communication")
pprofDir := flag.String("pprofDir", "", "Generate pprof CPU/memory profiles to the given directory.")
Expand Down Expand Up @@ -51,7 +52,7 @@ func runLSP(args []string) int {
TypingsLocation: typingsLocation,
})

if err := s.Run(); err != nil {
if err := s.Run(ctx); err != nil {
return 1
}
return 0
Expand Down
8 changes: 7 additions & 1 deletion cmd/tsgo/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package main

import (
"context"
"os"
"os/signal"
"syscall"

"github.com/microsoft/typescript-go/internal/execute"
)
Expand All @@ -11,11 +14,14 @@ func main() {
}

func runMain() int {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()

args := os.Args[1:]
if len(args) > 0 {
switch args[0] {
case "--lsp":
return runLSP(args[1:])
return runLSP(ctx, args[1:])
case "--api":
return runAPI(args[1:])
}
Expand Down
292 changes: 0 additions & 292 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,8 @@
TestAliasMergingWithNamespace
TestAmbientShorthandGotoDefinition
TestArgumentsAreAvailableAfterEditsAtEndOfFunction
TestAugmentedTypesClass1
TestAugmentedTypesClass3Fourslash
TestBestCommonTypeObjectLiterals
TestBestCommonTypeObjectLiterals1
TestCodeCompletionEscaping
TestCommentsEnumsFourslash
TestCommentsLinePreservation
TestCommentsUnion
TestCompletionAfterQuestionDot
TestCompletionAutoInsertQuestionDot
TestCompletionCloneQuestionToken
TestCompletionEntryForArgumentConstrainedToString
TestCompletionEntryForArrayElementConstrainedToString
TestCompletionEntryForArrayElementConstrainedToString2
TestCompletionEntryForClassMembers_StaticWhenBaseTypeIsNotResolved
TestCompletionEntryForUnionProperty
TestCompletionEntryForUnionProperty2
TestCompletionExportFrom
TestCompletionForComputedStringProperties
TestCompletionForMetaProperty
TestCompletionForStringLiteral
TestCompletionForStringLiteral4
TestCompletionForStringLiteralExport
TestCompletionForStringLiteralImport1
TestCompletionForStringLiteralImport2
TestCompletionForStringLiteralNonrelativeImport12
TestCompletionForStringLiteralNonrelativeImport14
TestCompletionForStringLiteralNonrelativeImport16
TestCompletionForStringLiteralNonrelativeImport17
TestCompletionForStringLiteralNonrelativeImport18
TestCompletionForStringLiteralNonrelativeImport2
TestCompletionForStringLiteralNonrelativeImport3
TestCompletionForStringLiteralNonrelativeImport4
TestCompletionForStringLiteralNonrelativeImport7
TestCompletionForStringLiteralNonrelativeImport8
TestCompletionForStringLiteralNonrelativeImport9
TestCompletionForStringLiteralNonrelativeImportTypings1
TestCompletionForStringLiteralNonrelativeImportTypings2
TestCompletionForStringLiteralNonrelativeImportTypings3
TestCompletionForStringLiteralRelativeImport4
TestCompletionForStringLiteralRelativeImport6
TestCompletionForStringLiteralRelativeImportAllowJSTrue
TestCompletionForStringLiteralWithDynamicImport
TestCompletionForStringLiteral_details
TestCompletionForStringLiteral_quotePreference
Expand All @@ -64,225 +24,10 @@ TestCompletionImportModuleSpecifierEndingTsxPreserve
TestCompletionImportModuleSpecifierEndingTsxReact
TestCompletionImportModuleSpecifierEndingUnsupportedExtension
TestCompletionInFunctionLikeBody_includesPrimitiveTypes
TestCompletionInJsDoc
TestCompletionInNamedImportLocation
TestCompletionInUncheckedJSFile
TestCompletionListBuilderLocations_VariableDeclarations
TestCompletionListForDerivedType1
TestCompletionListForTransitivelyExportedMembers04
TestCompletionListFunctionExpression
TestCompletionListInArrowFunctionInUnclosedCallSite01
TestCompletionListInClassExpressionWithTypeParameter
TestCompletionListInClassStaticBlocks
TestCompletionListInImportClause01
TestCompletionListInImportClause05
TestCompletionListInImportClause06
TestCompletionListInNamedClassExpression
TestCompletionListInNamedClassExpressionWithShadowing
TestCompletionListInNamedFunctionExpression
TestCompletionListInNamedFunctionExpression1
TestCompletionListInNamedFunctionExpressionWithShadowing
TestCompletionListInScope
TestCompletionListInTemplateLiteralParts1
TestCompletionListInUnclosedCommaExpression01
TestCompletionListInUnclosedCommaExpression02
TestCompletionListInUnclosedFunction08
TestCompletionListInUnclosedFunction09
TestCompletionListInUnclosedTaggedTemplate01
TestCompletionListInUnclosedTaggedTemplate02
TestCompletionListInUnclosedTemplate01
TestCompletionListInUnclosedTemplate02
TestCompletionListInvalidMemberNames
TestCompletionListInvalidMemberNames2
TestCompletionListInvalidMemberNames_escapeQuote
TestCompletionListInvalidMemberNames_startWithSpace
TestCompletionListInvalidMemberNames_withExistingIdentifier
TestCompletionListObjectMembersInTypeLocationWithTypeof
TestCompletionListOfGenericSymbol
TestCompletionListOnAliases
TestCompletionListStringParenthesizedExpression
TestCompletionListStringParenthesizedType
TestCompletionListWithoutVariableinitializer
TestCompletionListsStringLiteralTypeAsIndexedAccessTypeObject
TestCompletionNoAutoInsertQuestionDotForThis
TestCompletionNoAutoInsertQuestionDotForTypeParameter
TestCompletionNoAutoInsertQuestionDotWithUserPreferencesOff
TestCompletionOfAwaitPromise1
TestCompletionOfAwaitPromise2
TestCompletionOfAwaitPromise3
TestCompletionOfAwaitPromise5
TestCompletionOfAwaitPromise6
TestCompletionOfAwaitPromise7
TestCompletionOfInterfaceAndVar
TestCompletionPreferredSuggestions1
TestCompletionWithConditionalOperatorMissingColon
TestCompletionsAfterJSDoc
TestCompletionsBeforeRestArg1
TestCompletionsElementAccessNumeric
TestCompletionsExportImport
TestCompletionsGenericTypeWithMultipleBases1
TestCompletionsImportOrExportSpecifier
TestCompletionsInExport
TestCompletionsInExport_moduleBlock
TestCompletionsInRequire
TestCompletionsJSDocImportTagAttributesEmptyModuleSpecifier1
TestCompletionsJSDocImportTagAttributesErrorModuleSpecifier1
TestCompletionsJSDocImportTagEmptyModuleSpecifier1
TestCompletionsJSDocNoCrash1
TestCompletionsJsdocTypeTagCast
TestCompletionsJsxAttribute2
TestCompletionsJsxAttributeInitializer2
TestCompletionsLiteralFromInferenceWithinInferredType3
TestCompletionsLiterals
TestCompletionsMergedDeclarations1
TestCompletionsNewTarget
TestCompletionsOptionalMethod
TestCompletionsOverridingMethod1
TestCompletionsOverridingMethod10
TestCompletionsOverridingMethod11
TestCompletionsOverridingMethod14
TestCompletionsOverridingMethod17
TestCompletionsOverridingMethod3
TestCompletionsOverridingMethod4
TestCompletionsOverridingMethod9
TestCompletionsOverridingMethodCrash1
TestCompletionsOverridingProperties1
TestCompletionsPathsJsonModule
TestCompletionsPathsRelativeJsonModule
TestCompletionsPaths_importType
TestCompletionsPaths_kinds
TestCompletionsPaths_pathMapping
TestCompletionsPaths_pathMapping_nonTrailingWildcard1
TestCompletionsPaths_pathMapping_parentDirectory
TestCompletionsRecommended_union
TestCompletionsRedeclareModuleAsGlobal
TestCompletionsStringsWithTriggerCharacter
TestCompletionsSymbolMembers
TestCompletionsTriggerCharacter
TestCompletionsTuple
TestCompletionsUniqueSymbol1
TestConstEnumQuickInfoAndCompletionList
TestConstQuickInfoAndCompletionList
TestContextuallyTypedFunctionExpressionGeneric1
TestDoubleUnderscoreCompletions
TestEditJsdocType
TestExportDefaultClass
TestExportDefaultFunction
TestFindAllReferencesDynamicImport1
TestFindAllReferencesTripleSlash
TestFindAllReferencesUmdModuleAsGlobalConst
TestFindAllRefsCommonJsRequire
TestFindAllRefsCommonJsRequire2
TestFindAllRefsCommonJsRequire3
TestFindAllRefsExportEquals
TestFindAllRefsForDefaultExport03
TestFindAllRefsModuleDotExports
TestFindAllRefsReExport_broken
TestFindAllRefs_importType_typeofImport
TestFindReferencesAfterEdit
TestFindReferencesBindingPatternInJsdocNoCrash1
TestFindReferencesBindingPatternInJsdocNoCrash2
TestGenericCombinatorWithConstraints1
TestGenericCombinators3
TestGenericFunctionWithGenericParams1
TestGenericInterfacesWithConstraints1
TestGenericTypeWithMultipleBases1MultiFile
TestGetJavaScriptCompletions10
TestGetJavaScriptCompletions12
TestGetJavaScriptCompletions13
TestGetJavaScriptCompletions15
TestGetJavaScriptCompletions18
TestGetJavaScriptCompletions20
TestGetJavaScriptCompletions8
TestGetJavaScriptCompletions9
TestGetJavaScriptGlobalCompletions1
TestGetJavaScriptQuickInfo1
TestGetJavaScriptQuickInfo2
TestGetJavaScriptQuickInfo3
TestGetJavaScriptQuickInfo4
TestGetJavaScriptQuickInfo5
TestGetJavaScriptQuickInfo6
TestGetJavaScriptQuickInfo7
TestGetJavaScriptQuickInfo8
TestGetJavaScriptSyntacticDiagnostics24
TestGetQuickInfoForIntersectionTypes
TestHoverOverComment
TestImportCompletionsPackageJsonExportsSpecifierEndsInTs
TestImportCompletionsPackageJsonExportsTrailingSlash1
TestImportCompletionsPackageJsonImportsConditions1
TestImportCompletionsPackageJsonImportsLength1
TestImportCompletionsPackageJsonImportsLength2
TestImportCompletionsPackageJsonImportsPattern
TestImportCompletionsPackageJsonImportsPattern2
TestImportCompletionsPackageJsonImportsPattern_capsInPath1
TestImportCompletionsPackageJsonImportsPattern_capsInPath2
TestImportCompletionsPackageJsonImportsPattern_js_ts
TestImportCompletionsPackageJsonImportsPattern_ts
TestImportCompletionsPackageJsonImportsPattern_ts_ts
TestImportCompletionsPackageJsonImports_ts
TestImportCompletions_importsMap1
TestImportCompletions_importsMap2
TestImportCompletions_importsMap3
TestImportCompletions_importsMap4
TestImportCompletions_importsMap5
TestImportStatementCompletions4
TestImportStatementCompletions_noPatternAmbient
TestImportStatementCompletions_pnpmTransitive
TestIndexerReturnTypes1
TestIndirectClassInstantiation
TestInstanceTypesForGenericType1
TestJavascriptModules20
TestJavascriptModules21
TestJavascriptModulesTypeImport
TestJsDocAugments
TestJsDocExtends
TestJsDocFunctionSignatures10
TestJsDocFunctionSignatures11
TestJsDocFunctionSignatures12
TestJsDocFunctionSignatures13
TestJsDocFunctionSignatures7
TestJsDocFunctionSignatures8
TestJsDocGenerics2
TestJsDocInheritDoc
TestJsDocPropertyDescription1
TestJsDocPropertyDescription10
TestJsDocPropertyDescription11
TestJsDocPropertyDescription12
TestJsDocPropertyDescription2
TestJsDocPropertyDescription3
TestJsDocPropertyDescription4
TestJsDocPropertyDescription5
TestJsDocPropertyDescription6
TestJsDocPropertyDescription7
TestJsDocPropertyDescription8
TestJsDocPropertyDescription9
TestJsDocTagsWithHyphen
TestJsQuickInfoGenerallyAcceptableSize
TestJsRequireQuickInfo
TestJsdocCallbackTag
TestJsdocLink2
TestJsdocLink3
TestJsdocLink6
TestJsdocLink_findAllReferences1
TestJsdocTemplatePrototypeCompletions
TestJsdocThrowsTagCompletion
TestJsdocTypedefTag
TestJsdocTypedefTag2
TestJsdocTypedefTagNamespace
TestJsxFindAllReferencesOnRuntimeImportWithPaths1
TestLetQuickInfoAndCompletionList
TestLocalFunction
TestLocalGetReferences
TestMemberListInReopenedEnum
TestMemberListInWithBlock
TestMemberListOfExportedClass
TestMemberListOnContextualThis
TestModuleReexportedIntoGlobalQuickInfo
TestNgProxy1
TestNoQuickInfoForLabel
TestNoQuickInfoInWhitespace
TestNodeModulesImportCompletions1
TestNumericPropertyNames
TestOverloadQuickInfo
TestParameterWithDestructuring
TestParameterWithNestedDestructuring
Expand Down Expand Up @@ -328,12 +73,7 @@ TestPathCompletionsPackageJsonImportsWildcard7
TestPathCompletionsPackageJsonImportsWildcard8
TestPathCompletionsPackageJsonImportsWildcard9
TestPathCompletionsTypesVersionsLocal
TestPathCompletionsTypesVersionsWildcard1
TestPathCompletionsTypesVersionsWildcard2
TestPathCompletionsTypesVersionsWildcard3
TestPathCompletionsTypesVersionsWildcard4
TestPathCompletionsTypesVersionsWildcard5
TestPathCompletionsTypesVersionsWildcard6
TestProtoVarVisibleWithOuterScopeUnderscoreProto
TestQuickInfoAlias
TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1
Expand Down Expand Up @@ -375,16 +115,6 @@ TestQuickInfoJSDocFunctionThis
TestQuickInfoJSExport
TestQuickInfoJsDocGetterSetterNoCrash1
TestQuickInfoJsDocNonDiscriminatedUnionSharedProp
TestQuickInfoJsPropertyAssignedAfterMethodDeclaration
TestQuickInfoJsdocTypedefMissingType
TestQuickInfoMappedSpreadTypes
TestQuickInfoMappedType
TestQuickInfoMappedTypeMethods
TestQuickInfoMappedTypeRecursiveInference
TestQuickInfoModuleVariables
TestQuickInfoNarrowedTypeOfAliasSymbol
TestQuickInfoNestedGenericCalls
TestQuickInfoOnArgumentsInsideFunction
TestQuickInfoOnCatchVariable
TestQuickInfoOnClosingJsx
TestQuickInfoOnElementAccessInWriteLocation1
Expand Down Expand Up @@ -441,7 +171,6 @@ TestQuickinfoForNamespaceMergeWithClassConstrainedToSelf
TestQuickinfoForUnionProperty
TestQuickinfoWrongComment
TestRecursiveInternalModuleImport
TestReferencesForExportedValues
TestReferencesForStatementKeywords
TestReferencesInComment
TestReferencesInEmptyFile
Expand All @@ -452,27 +181,6 @@ TestSelfReferencedExternalModule
TestSignatureHelpInferenceJsDocImportTag
TestStringCompletionsImportOrExportSpecifier
TestStringCompletionsVsEscaping
TestSyntheticImportFromBabelGeneratedFile1
TestSyntheticImportFromBabelGeneratedFile2
TestThisBindingInLambda
TestThisPredicateFunctionQuickInfo01
TestThisPredicateFunctionQuickInfo02
TestTripleSlashRefPathCompletionAbsolutePaths
TestTripleSlashRefPathCompletionContext
TestTripleSlashRefPathCompletionExtensionsAllowJSFalse
TestTripleSlashRefPathCompletionExtensionsAllowJSTrue
TestTripleSlashRefPathCompletionHiddenFile
TestTripleSlashRefPathCompletionRootdirs
TestTslibFindAllReferencesOnRuntimeImportWithPaths1
TestTsxCompletion12
TestTsxCompletion13
TestTsxCompletion14
TestTsxCompletion15
TestTsxCompletion8
TestTsxCompletionNonTagLessThan
TestTsxQuickInfo1
TestTsxQuickInfo4
TestTsxQuickInfo5
TestTsxQuickInfo6
TestTsxQuickInfo7
TestTypeOperatorNodeBuilding
Loading
Loading