diff --git a/internal/ast/ast.go b/internal/ast/ast.go index e991bd08ad..6aa647cdf1 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -2188,6 +2188,244 @@ type ( JsxAttributeList = NodeList // NodeList[*JsxAttributeLike] ) +func IsWriteOnlyAccess(node *Node) bool { + return accessKind(node) == AccessKindWrite +} + +func IsWriteAccess(node *Node) bool { + return accessKind(node) != AccessKindRead +} + +func IsWriteAccessForReference(node *Node) bool { + decl := getDeclarationFromName(node) + return (decl != nil && declarationIsWriteAccess(decl)) || node.Kind == KindDefaultKeyword || IsWriteAccess(node) +} + +func getDeclarationFromName(name *Node) *Declaration { + if name == nil || name.Parent == nil { + return nil + } + parent := name.Parent + switch name.Kind { + case KindStringLiteral, KindNoSubstitutionTemplateLiteral, KindNumericLiteral: + if IsComputedPropertyName(parent) { + return parent.Parent + } + fallthrough + case KindIdentifier: + if IsDeclaration(parent) { + if parent.Name() == name { + return parent + } + return nil + } + if IsQualifiedName(parent) { + tag := parent.Parent + if IsJSDocParameterTag(tag) && tag.Name() == parent { + return tag + } + return nil + } + binExp := parent.Parent + if IsBinaryExpression(binExp) && GetAssignmentDeclarationKind(binExp.AsBinaryExpression()) != JSDeclarationKindNone { + // (binExp.left as BindableStaticNameExpression).symbol || binExp.symbol + leftHasSymbol := false + if binExp.AsBinaryExpression().Left != nil && binExp.AsBinaryExpression().Left.Symbol() != nil { + leftHasSymbol = true + } + if leftHasSymbol || binExp.Symbol() != nil { + if GetNameOfDeclaration(binExp.AsNode()) == name { + return binExp.AsNode() + } + } + } + case KindPrivateIdentifier: + if IsDeclaration(parent) && parent.Name() == name { + return parent + } + } + return nil +} + +func declarationIsWriteAccess(decl *Node) bool { + if decl == nil { + return false + } + // Consider anything in an ambient declaration to be a write access since it may be coming from JS. + if decl.Flags&NodeFlagsAmbient != 0 { + return true + } + + switch decl.Kind { + case KindBinaryExpression, + KindBindingElement, + KindClassDeclaration, + KindClassExpression, + KindDefaultKeyword, + KindEnumDeclaration, + KindEnumMember, + KindExportSpecifier, + KindImportClause, // default import + KindImportEqualsDeclaration, + KindImportSpecifier, + KindInterfaceDeclaration, + KindJSDocCallbackTag, + KindJSDocTypedefTag, + KindJsxAttribute, + KindModuleDeclaration, + KindNamespaceExportDeclaration, + KindNamespaceImport, + KindNamespaceExport, + KindParameter, + KindShorthandPropertyAssignment, + KindTypeAliasDeclaration, + KindTypeParameter: + return true + + case KindPropertyAssignment: + // In `({ x: y } = 0);`, `x` is not a write access. + return !IsArrayLiteralOrObjectLiteralDestructuringPattern(decl.Parent) + + case KindFunctionDeclaration, KindFunctionExpression, KindConstructor, KindMethodDeclaration, KindGetAccessor, KindSetAccessor: + // functions considered write if they provide a value (have a body) + switch decl.Kind { + case KindFunctionDeclaration: + return decl.AsFunctionDeclaration().Body != nil + case KindFunctionExpression: + return decl.AsFunctionExpression().Body != nil + case KindConstructor: + // constructor node stores body on the parent? treat same as others + return decl.AsConstructorDeclaration().Body != nil + case KindMethodDeclaration: + return decl.AsMethodDeclaration().Body != nil + case KindGetAccessor: + return decl.AsGetAccessorDeclaration().Body != nil + case KindSetAccessor: + return decl.AsSetAccessorDeclaration().Body != nil + } + return false + + case KindVariableDeclaration, KindPropertyDeclaration: + // variable/property write if initializer present or is in catch clause + var hasInit bool + switch decl.Kind { + case KindVariableDeclaration: + hasInit = decl.AsVariableDeclaration().Initializer != nil + case KindPropertyDeclaration: + hasInit = decl.AsPropertyDeclaration().Initializer != nil + } + return hasInit || IsCatchClause(decl.Parent) + + case KindMethodSignature, KindPropertySignature, KindJSDocPropertyTag, KindJSDocParameterTag: + return false + + default: + // preserve TS behavior: crash on unexpected kinds + panic("Unhandled case in declarationIsWriteAccess") + } +} + +func IsArrayLiteralOrObjectLiteralDestructuringPattern(node *Node) bool { + if !(IsArrayLiteralExpression(node) || IsObjectLiteralExpression(node)) { + return false + } + parent := node.Parent + // [a,b,c] from: + // [a, b, c] = someExpression; + if IsBinaryExpression(parent) && parent.AsBinaryExpression().Left == node && parent.AsBinaryExpression().OperatorToken.Kind == KindEqualsToken { + return true + } + // [a, b, c] from: + // for([a, b, c] of expression) + if IsForOfStatement(parent) && parent.Initializer() == node { + return true + } + // {x, a: {a, b, c} } = someExpression + if IsPropertyAssignment(parent) { + return IsArrayLiteralOrObjectLiteralDestructuringPattern(parent.Parent) + } + // [a, b, c] of + // [x, [a, b, c] ] = someExpression + return IsArrayLiteralOrObjectLiteralDestructuringPattern(parent) +} + +func accessKind(node *Node) AccessKind { + parent := node.Parent + switch parent.Kind { + case KindParenthesizedExpression: + return accessKind(parent) + case KindPrefixUnaryExpression: + operator := parent.AsPrefixUnaryExpression().Operator + if operator == KindPlusPlusToken || operator == KindMinusMinusToken { + return AccessKindReadWrite + } + return AccessKindRead + case KindPostfixUnaryExpression: + operator := parent.AsPostfixUnaryExpression().Operator + if operator == KindPlusPlusToken || operator == KindMinusMinusToken { + return AccessKindReadWrite + } + return AccessKindRead + case KindBinaryExpression: + if parent.AsBinaryExpression().Left == node { + operator := parent.AsBinaryExpression().OperatorToken + if IsAssignmentOperator(operator.Kind) { + if operator.Kind == KindEqualsToken { + return AccessKindWrite + } + return AccessKindReadWrite + } + } + return AccessKindRead + case KindPropertyAccessExpression: + if parent.AsPropertyAccessExpression().Name() != node { + return AccessKindRead + } + return accessKind(parent) + case KindPropertyAssignment: + parentAccess := accessKind(parent.Parent) + // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. + if node == parent.AsPropertyAssignment().Name() { + return reverseAccessKind(parentAccess) + } + return parentAccess + case KindShorthandPropertyAssignment: + // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. + if node == parent.AsShorthandPropertyAssignment().ObjectAssignmentInitializer { + return AccessKindRead + } + return accessKind(parent.Parent) + case KindArrayLiteralExpression: + return accessKind(parent) + case KindForInStatement, KindForOfStatement: + if node == parent.AsForInOrOfStatement().Initializer { + return AccessKindWrite + } + return AccessKindRead + } + return AccessKindRead +} + +func reverseAccessKind(a AccessKind) AccessKind { + switch a { + case AccessKindRead: + return AccessKindWrite + case AccessKindWrite: + return AccessKindRead + case AccessKindReadWrite: + return AccessKindReadWrite + } + panic("Unhandled case in reverseAccessKind") +} + +type AccessKind int32 + +const ( + AccessKindRead AccessKind = iota // Only reads from a variable + AccessKindWrite // Only writes to a variable without ever reading it. E.g.: `x=1;`. + AccessKindReadWrite // Reads from and writes to a variable. E.g.: `f(x++);`, `x/=1`. +) + // DeclarationBase type DeclarationBase struct { @@ -3191,6 +3429,10 @@ func (node *ThrowStatement) computeSubtreeFacts() SubtreeFacts { return propagateSubtreeFacts(node.Expression) } +func IsThrowStatement(node *Node) bool { + return node.Kind == KindThrowStatement +} + // TryStatement type TryStatement struct { @@ -6153,6 +6395,10 @@ func (node *YieldExpression) computeSubtreeFacts() SubtreeFacts { return propagateSubtreeFacts(node.Expression) | SubtreeContainsForAwaitOrAsyncGenerator } +func IsYieldExpression(node *Node) bool { + return node.Kind == KindYieldExpression +} + // ArrowFunction type ArrowFunction struct { diff --git a/internal/checker/checker.go b/internal/checker/checker.go index b6d46d2e70..6fd276817c 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -10873,7 +10873,7 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l c.checkPropertyNotUsedBeforeDeclaration(prop, node, right) c.markPropertyAsReferenced(prop, node, c.isSelfTypeAccess(left, parentSymbol)) c.symbolNodeLinks.Get(node).resolvedSymbol = prop - c.checkPropertyAccessibility(node, left.Kind == ast.KindSuperKeyword, isWriteAccess(node), apparentType, prop) + c.checkPropertyAccessibility(node, left.Kind == ast.KindSuperKeyword, ast.IsWriteAccess(node), apparentType, prop) if c.isAssignmentToReadonlyEntity(node, prop, assignmentKind) { c.error(right, diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, right.Text()) return c.errorType @@ -10881,7 +10881,7 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l switch { case c.isThisPropertyAccessInConstructor(node, prop): propType = c.autoType - case writeOnly || isWriteOnlyAccess(node): + case writeOnly || ast.IsWriteOnlyAccess(node): propType = c.getWriteTypeOfSymbol(prop) default: propType = c.getTypeOfSymbol(prop) @@ -13284,7 +13284,7 @@ func (c *Checker) getResolvedSymbol(node *ast.Node) *ast.Symbol { var symbol *ast.Symbol if !ast.NodeIsMissing(node) { symbol = c.resolveName(node, node.AsIdentifier().Text, ast.SymbolFlagsValue|ast.SymbolFlagsExportValue, - c.getCannotFindNameDiagnosticForName(node), !isWriteOnlyAccess(node), false /*excludeGlobals*/) + c.getCannotFindNameDiagnosticForName(node), !ast.IsWriteOnlyAccess(node), false /*excludeGlobals*/) } links.resolvedSymbol = core.OrElse(symbol, c.unknownSymbol) } @@ -15719,9 +15719,9 @@ func (c *Checker) GetTypeOfSymbolAtLocation(symbol *ast.Symbol, location *ast.No if ast.IsRightSideOfQualifiedNameOrPropertyAccess(location) { location = location.Parent } - if ast.IsExpressionNode(location) && (!ast.IsAssignmentTarget(location) || isWriteAccess(location)) { + if ast.IsExpressionNode(location) && (!ast.IsAssignmentTarget(location) || ast.IsWriteAccess(location)) { var t *Type - if isWriteAccess(location) && location.Kind == ast.KindPropertyAccessExpression { + if ast.IsWriteAccess(location) && location.Kind == ast.KindPropertyAccessExpression { t = c.checkPropertyAccessExpression(location, CheckModeNormal, true /*writeOnly*/) } else { t = c.getTypeOfExpression(location) @@ -15739,7 +15739,7 @@ func (c *Checker) GetTypeOfSymbolAtLocation(symbol *ast.Symbol, location *ast.No // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - if isRightSideOfAccessExpression(location) && isWriteAccess(location.Parent) { + if isRightSideOfAccessExpression(location) && ast.IsWriteAccess(location.Parent) { return c.getWriteTypeOfSymbol(symbol) } } @@ -26711,7 +26711,7 @@ func (c *Checker) markPropertyAsReferenced(prop *ast.Symbol, nodeForCheckWriteOn if !hasPrivateModifier && !hasPrivateIdentifier { return } - if nodeForCheckWriteOnly != nil && isWriteOnlyAccess(nodeForCheckWriteOnly) && prop.Flags&ast.SymbolFlagsSetAccessor == 0 { + if nodeForCheckWriteOnly != nil && ast.IsWriteOnlyAccess(nodeForCheckWriteOnly) && prop.Flags&ast.SymbolFlagsSetAccessor == 0 { return } if isSelfTypeAccess { diff --git a/internal/checker/services.go b/internal/checker/services.go index caed1fbccc..f4b8aa19df 100644 --- a/internal/checker/services.go +++ b/internal/checker/services.go @@ -762,7 +762,7 @@ func (c *Checker) GetPropertySymbolsFromContextualType(node *ast.Node, contextua // // [a] = [ property1, property2 ] func (c *Checker) GetPropertySymbolOfDestructuringAssignment(location *ast.Node) *ast.Symbol { - if isArrayLiteralOrObjectLiteralDestructuringPattern(location.Parent.Parent) { + if ast.IsArrayLiteralOrObjectLiteralDestructuringPattern(location.Parent.Parent) { // Get the type of the object or array literal and then look for property of given name in the type if typeOfObjectLiteral := c.getTypeOfAssignmentPattern(location.Parent.Parent); typeOfObjectLiteral != nil { return c.getPropertyOfType(typeOfObjectLiteral, location.Text()) @@ -809,27 +809,3 @@ func (c *Checker) getTypeOfAssignmentPattern(expr *ast.Node) *Type { elementType := core.OrElse(c.checkIteratedTypeOrElementType(IterationUseDestructuring, typeOfArrayLiteral, c.undefinedType, expr.Parent), c.errorType) return c.checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, slices.Index(node.AsArrayLiteralExpression().Elements.Nodes, expr), elementType, CheckModeNormal) } - -func isArrayLiteralOrObjectLiteralDestructuringPattern(node *ast.Node) bool { - if !(ast.IsArrayLiteralExpression(node) || ast.IsObjectLiteralExpression(node)) { - return false - } - parent := node.Parent - // [a,b,c] from: - // [a, b, c] = someExpression; - if ast.IsBinaryExpression(parent) && parent.AsBinaryExpression().Left == node && parent.AsBinaryExpression().OperatorToken.Kind == ast.KindEqualsToken { - return true - } - // [a, b, c] from: - // for([a, b, c] of expression) - if ast.IsForOfStatement(parent) && parent.Initializer() == node { - return true - } - // {x, a: {a, b, c} } = someExpression - if ast.IsPropertyAssignment(parent) { - return isArrayLiteralOrObjectLiteralDestructuringPattern(parent.Parent) - } - // [a, b, c] of - // [x, [a, b, c] ] = someExpression - return isArrayLiteralOrObjectLiteralDestructuringPattern(parent) -} diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 10f1c6c0c7..e131201893 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -1074,91 +1074,6 @@ func isThisInitializedDeclaration(node *ast.Node) bool { return node != nil && ast.IsVariableDeclaration(node) && node.AsVariableDeclaration().Initializer != nil && node.AsVariableDeclaration().Initializer.Kind == ast.KindThisKeyword } -func isWriteOnlyAccess(node *ast.Node) bool { - return accessKind(node) == AccessKindWrite -} - -func isWriteAccess(node *ast.Node) bool { - return accessKind(node) != AccessKindRead -} - -type AccessKind int32 - -const ( - AccessKindRead AccessKind = iota // Only reads from a variable - AccessKindWrite // Only writes to a variable without ever reading it. E.g.: `x=1;`. - AccessKindReadWrite // Reads from and writes to a variable. E.g.: `f(x++);`, `x/=1`. -) - -func accessKind(node *ast.Node) AccessKind { - parent := node.Parent - switch parent.Kind { - case ast.KindParenthesizedExpression: - return accessKind(parent) - case ast.KindPrefixUnaryExpression: - operator := parent.AsPrefixUnaryExpression().Operator - if operator == ast.KindPlusPlusToken || operator == ast.KindMinusMinusToken { - return AccessKindReadWrite - } - return AccessKindRead - case ast.KindPostfixUnaryExpression: - operator := parent.AsPostfixUnaryExpression().Operator - if operator == ast.KindPlusPlusToken || operator == ast.KindMinusMinusToken { - return AccessKindReadWrite - } - return AccessKindRead - case ast.KindBinaryExpression: - if parent.AsBinaryExpression().Left == node { - operator := parent.AsBinaryExpression().OperatorToken - if ast.IsAssignmentOperator(operator.Kind) { - if operator.Kind == ast.KindEqualsToken { - return AccessKindWrite - } - return AccessKindReadWrite - } - } - return AccessKindRead - case ast.KindPropertyAccessExpression: - if parent.AsPropertyAccessExpression().Name() != node { - return AccessKindRead - } - return accessKind(parent) - case ast.KindPropertyAssignment: - parentAccess := accessKind(parent.Parent) - // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. - if node == parent.AsPropertyAssignment().Name() { - return reverseAccessKind(parentAccess) - } - return parentAccess - case ast.KindShorthandPropertyAssignment: - // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - if node == parent.AsShorthandPropertyAssignment().ObjectAssignmentInitializer { - return AccessKindRead - } - return accessKind(parent.Parent) - case ast.KindArrayLiteralExpression: - return accessKind(parent) - case ast.KindForInStatement, ast.KindForOfStatement: - if node == parent.AsForInOrOfStatement().Initializer { - return AccessKindWrite - } - return AccessKindRead - } - return AccessKindRead -} - -func reverseAccessKind(a AccessKind) AccessKind { - switch a { - case AccessKindRead: - return AccessKindWrite - case AccessKindWrite: - return AccessKindRead - case AccessKindReadWrite: - return AccessKindReadWrite - } - panic("Unhandled case in reverseAccessKind") -} - func isInfinityOrNaNString(name string) bool { return name == "Infinity" || name == "-Infinity" || name == "NaN" } diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 0e45d21ce7..919d72b777 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -178,6 +178,8 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { case "baselineFindAllReferences": // `verify.baselineFindAllReferences(...)` return parseBaselineFindAllReferencesArgs(callExpression.arguments); + case "baselineDocumentHighlights": + return parseBaselineDocumentHighlightsArgs(callExpression.arguments); case "baselineQuickInfo": return [parseBaselineQuickInfo(callExpression.arguments)]; case "baselineSignatureHelp": @@ -778,6 +780,43 @@ function parseBaselineFindAllReferencesArgs(args: readonly ts.Expression[]): [Ve }]; } +function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [VerifyBaselineDocumentHighlightsCmd] | undefined { + const newArgs: string[] = []; + let preferences: string | undefined; + for (const arg of args) { + let strArg; + if (strArg = getArrayLiteralExpression(arg)) { + for (const elem of strArg.elements) { + const newArg = parseBaselineMarkerOrRangeArg(elem); + if (!newArg) { + return undefined; + } + newArgs.push(newArg); + } + } + else if (ts.isObjectLiteralExpression(arg)) { + // !!! todo when multiple files supported in lsp + } + else if (strArg = parseBaselineMarkerOrRangeArg(arg)) { + newArgs.push(strArg); + } + else { + console.error(`Unrecognized argument in verify.baselineDocumentHighlights: ${arg.getText()}`); + return undefined; + } + } + + if (newArgs.length === 0) { + newArgs.push("ToAny(f.Ranges())..."); + } + + return [{ + kind: "verifyBaselineDocumentHighlights", + args: newArgs, + preferences: preferences ? preferences : "nil /*preferences*/", + }]; +} + function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [VerifyBaselineGoToDefinitionCmd] | undefined { const newArgs = []; for (const arg of args) { @@ -843,7 +882,7 @@ function parseBaselineRenameArgs(funcName: string, args: readonly ts.Expression[ let typedArg; if ((typedArg = getArrayLiteralExpression(arg))) { for (const elem of typedArg.elements) { - const newArg = parseBaselineRenameArg(elem); + const newArg = parseBaselineMarkerOrRangeArg(elem); if (!newArg) { return undefined; } @@ -858,7 +897,7 @@ function parseBaselineRenameArgs(funcName: string, args: readonly ts.Expression[ } continue; } - else if (typedArg = parseBaselineRenameArg(arg)) { + else if (typedArg = parseBaselineMarkerOrRangeArg(arg)) { newArgs.push(typedArg); } else { @@ -896,7 +935,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefin return `&ls.UserPreferences{${preferences.join(",")}}`; } -function parseBaselineRenameArg(arg: ts.Expression): string | undefined { +function parseBaselineMarkerOrRangeArg(arg: ts.Expression): string | undefined { if (ts.isStringLiteral(arg)) { return getGoStringLiteral(arg.text); } @@ -1262,6 +1301,12 @@ interface VerifyBaselineRenameCmd { preferences: string; } +interface VerifyBaselineDocumentHighlightsCmd { + kind: "verifyBaselineDocumentHighlights"; + args: string[]; + preferences: string; +} + interface GoToCmd { kind: "goTo"; // !!! `selectRange` and `rangeStart` require parsing variables and `test.ranges()[n]` @@ -1289,6 +1334,7 @@ interface VerifyRenameInfoCmd { type Cmd = | VerifyCompletionsCmd | VerifyBaselineFindAllReferencesCmd + | VerifyBaselineDocumentHighlightsCmd | VerifyBaselineGoToDefinitionCmd | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd @@ -1332,6 +1378,10 @@ function generateBaselineFindAllReferences({ markers, ranges }: VerifyBaselineFi return `f.VerifyBaselineFindAllReferences(t, ${markers.join(", ")})`; } +function generateBaselineDocumentHighlights({ args, preferences }: VerifyBaselineDocumentHighlightsCmd): string { + return `f.VerifyBaselineDocumentHighlights(t, ${preferences}, ${args.join(", ")})`; +} + function generateBaselineGoToDefinition({ markers, ranges }: VerifyBaselineGoToDefinitionCmd): string { if (ranges || markers.length === 0) { return `f.VerifyBaselineGoToDefinition(t)`; @@ -1372,6 +1422,8 @@ function generateCmd(cmd: Cmd): string { return generateVerifyCompletions(cmd); case "verifyBaselineFindAllReferences": return generateBaselineFindAllReferences(cmd); + case "verifyBaselineDocumentHighlights": + return generateBaselineDocumentHighlights(cmd); case "verifyBaselineGoToDefinition": return generateBaselineGoToDefinition(cmd); case "verifyBaselineQuickInfo": diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 909240a459..278f859e52 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -162,8 +162,15 @@ TestCompletionsUniqueSymbol1 TestConstEnumQuickInfoAndCompletionList TestConstQuickInfoAndCompletionList TestContextuallyTypedFunctionExpressionGeneric1 +TestDocumentHighlightInExport1 +TestDocumentHighlightInTypeExport +TestDocumentHighlightJSDocTypedef +TestDocumentHighlightTemplateStrings +TestDocumentHighlightsInvalidGlobalThis +TestDocumentHighlights_40082 TestDoubleUnderscoreCompletions TestEditJsdocType +TestEmptyExportFindReferences TestExportDefaultClass TestExportDefaultFunction TestFindAllReferencesDynamicImport1 @@ -173,6 +180,7 @@ TestFindAllRefsCommonJsRequire2 TestFindAllRefsCommonJsRequire3 TestFindAllRefsExportEquals TestFindAllRefsForDefaultExport03 +TestFindAllRefsForModule TestFindAllRefsModuleDotExports TestFindAllRefs_importType_typeofImport TestFindReferencesAfterEdit @@ -201,6 +209,13 @@ TestGetJavaScriptQuickInfo6 TestGetJavaScriptQuickInfo7 TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 +TestGetOccurrencesClassExpressionConstructor +TestGetOccurrencesConstructor +TestGetOccurrencesConstructor2 +TestGetOccurrencesIfElseBroken +TestGetOccurrencesOfAnonymousFunction +TestGetOccurrencesStringLiteralTypes +TestGetOccurrencesStringLiterals TestGetQuickInfoForIntersectionTypes TestHoverOverComment TestImportCompletionsPackageJsonExportsSpecifierEndsInTs @@ -264,6 +279,7 @@ TestJsdocThrowsTagCompletion TestJsdocTypedefTag TestJsdocTypedefTag2 TestJsdocTypedefTagNamespace +TestJsdocTypedefTagServices TestJsxFindAllReferencesOnRuntimeImportWithPaths1 TestLetQuickInfoAndCompletionList TestLocalFunction @@ -329,6 +345,7 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto +TestQualifiedName_import_declaration_with_variable_entity_names TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 8927813263..2fff230f31 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1031,6 +1031,83 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { } } +func (f *FourslashTest) VerifyBaselineDocumentHighlights( + t *testing.T, + preferences *ls.UserPreferences, + markerOrRangeOrNames ...MarkerOrRangeOrName, +) { + var markerOrRanges []MarkerOrRange + for _, markerOrRangeOrName := range markerOrRangeOrNames { + switch markerOrNameOrRange := markerOrRangeOrName.(type) { + case string: + marker, ok := f.testData.MarkerPositions[markerOrNameOrRange] + if !ok { + t.Fatalf("Marker '%s' not found", markerOrNameOrRange) + } + markerOrRanges = append(markerOrRanges, marker) + case *Marker: + markerOrRanges = append(markerOrRanges, markerOrNameOrRange) + case *RangeMarker: + markerOrRanges = append(markerOrRanges, markerOrNameOrRange) + default: + t.Fatalf("Invalid marker or range type: %T. Expected string, *Marker, or *RangeMarker.", markerOrNameOrRange) + } + } + + f.verifyBaselineDocumentHighlights(t, preferences, markerOrRanges) +} + +func (f *FourslashTest) verifyBaselineDocumentHighlights( + t *testing.T, + preferences *ls.UserPreferences, + markerOrRanges []MarkerOrRange, +) { + for _, markerOrRange := range markerOrRanges { + f.goToMarker(t, markerOrRange) + + params := &lsproto.DocumentHighlightParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: ls.FileNameToDocumentURI(f.activeFilename), + }, + Position: f.currentCaretPosition, + } + resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentDocumentHighlightInfo, params) + if resMsg == nil { + if f.lastKnownMarkerName == nil { + t.Fatalf("Nil response received for document highlights request at pos %v", f.currentCaretPosition) + } else { + t.Fatalf("Nil response received for document highlights request at marker '%s'", *f.lastKnownMarkerName) + } + } + if !resultOk { + if f.lastKnownMarkerName == nil { + t.Fatalf("Unexpected document highlights response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) + } else { + t.Fatalf("Unexpected document highlights response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) + } + } + + highlights := result.DocumentHighlights + if highlights == nil { + highlights = &[]*lsproto.DocumentHighlight{} + } + + var spans []lsproto.Location + for _, h := range *highlights { + spans = append(spans, lsproto.Location{ + Uri: ls.FileNameToDocumentURI(f.activeFilename), + Range: h.Range, + }) + } + + // Add result to baseline + f.addResultToBaseline(t, "documentHighlights", f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ + marker: markerOrRange, + markerName: "/*HIGHLIGHTS*/", + })) + } +} + // Collects all named markers if provided, or defaults to anonymous ranges func (f *FourslashTest) lookupMarkersOrGetRanges(t *testing.T, markers []string) []MarkerOrRange { var referenceLocations []MarkerOrRange diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties1_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties1_test.go new file mode 100644 index 0000000000..5b5fc277e9 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties1_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +interface interface1 extends interface1 { + [|doStuff|](): void; + [|propName|]: string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties2_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties2_test.go new file mode 100644 index 0000000000..e052120c4b --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class class1 extends class1 { + [|doStuff|]() { } + [|propName|]: string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties3_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties3_test.go new file mode 100644 index 0000000000..b0480b7f0e --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties3_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +interface interface1 extends interface1 { + [|doStuff|](): void; + [|propName|]: string; +} + +var v: interface1; +v.[|propName|]; +v.[|doStuff|]();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties4_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties4_test.go new file mode 100644 index 0000000000..8f3a1764e3 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties4_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class class1 extends class1 { + [|doStuff|]() { } + [|propName|]: string; +} + +var c: class1; +c.[|doStuff|](); +c.[|propName|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties5_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties5_test.go new file mode 100644 index 0000000000..7ce6a2d0d1 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties5_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +interface C extends D { + [|prop0|]: string; + [|prop1|]: number; +} + +interface D extends C { + [|prop0|]: string; + [|prop1|]: number; +} + +var d: D; +d.[|prop1|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties6_test.go b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties6_test.go new file mode 100644 index 0000000000..692ec509a2 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtInheritedProperties6_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtInheritedProperties6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class C extends D { + [|prop0|]: string; + [|prop1|]: string; +} + +class D extends C { + [|prop0|]: string; + [|prop1|]: string; +} + +var d: D; +d.[|prop1|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration1_test.go b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration1_test.go new file mode 100644 index 0000000000..e2a2c3d204 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration1_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtParameterPropertyDeclaration1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class Foo { + constructor(private [|privateParam|]: number, + public [|publicParam|]: string, + protected [|protectedParam|]: boolean) { + + let localPrivate = [|privateParam|]; + this.[|privateParam|] += 10; + + let localPublic = [|publicParam|]; + this.[|publicParam|] += " Hello!"; + + let localProtected = [|protectedParam|]; + this.[|protectedParam|] = false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration2_test.go b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration2_test.go new file mode 100644 index 0000000000..9c11d48ba8 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtParameterPropertyDeclaration2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class Foo { + // This is not valid syntax: parameter property can't be binding pattern + constructor(private {[|privateParam|]}: number, + public {[|publicParam|]}: string, + protected {[|protectedParam|]}: boolean) { + + let localPrivate = [|privateParam|]; + this.privateParam += 10; + + let localPublic = [|publicParam|]; + this.publicParam += " Hello!"; + + let localProtected = [|protectedParam|]; + this.protectedParam = false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration3_test.go b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration3_test.go new file mode 100644 index 0000000000..e87d2bb37d --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration3_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightAtParameterPropertyDeclaration3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class Foo { + // This is not valid syntax: parameter property can't be binding pattern + constructor(private [[|privateParam|]]: number, + public [[|publicParam|]]: string, + protected [[|protectedParam|]]: boolean) { + + let localPrivate = [|privateParam|]; + this.privateParam += 10; + + let localPublic = [|publicParam|]; + this.publicParam += " Hello!"; + + let localProtected = [|protectedParam|]; + this.protectedParam = false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightDefaultInKeyword_test.go b/internal/fourslash/tests/gen/documentHighlightDefaultInKeyword_test.go new file mode 100644 index 0000000000..d3261f3b7d --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightDefaultInKeyword_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightDefaultInKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|case|] +[|default|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightDefaultInSwitch_test.go b/internal/fourslash/tests/gen/documentHighlightDefaultInSwitch_test.go new file mode 100644 index 0000000000..b450aad659 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightDefaultInSwitch_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightDefaultInSwitch(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const foo = 'foo'; +[|switch|] (foo) { + [|case|] 'foo': + [|break|]; + [|default|]: + [|break|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[4]) +} diff --git a/internal/fourslash/tests/gen/documentHighlightInExport1_test.go b/internal/fourslash/tests/gen/documentHighlightInExport1_test.go new file mode 100644 index 0000000000..3a6d1301f7 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightInExport1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightInExport1(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class [|C|] {} +[|export|] { [|C|] [|as|] [|D|] };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightInKeyword_test.go b/internal/fourslash/tests/gen/documentHighlightInKeyword_test.go new file mode 100644 index 0000000000..7b818bc281 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightInKeyword_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightInKeyword(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export type Foo = { + [K [|in|] keyof T]: any; +} + +"a" [|in|] {}; + +for (let a [|in|] {}) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightInTypeExport_test.go b/internal/fourslash/tests/gen/documentHighlightInTypeExport_test.go new file mode 100644 index 0000000000..adde0ccb24 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightInTypeExport_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightInTypeExport(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /1.ts +type [|A|] = 1; +export { [|A|] as [|B|] }; +// @Filename: /2.ts +type [|A|] = 1; +let [|A|]: [|A|] = 1; +export { [|A|] as [|B|] }; +// @Filename: /3.ts +type [|A|] = 1; +let [|A|]: [|A|] = 1; +export type { [|A|] as [|B|] };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightJSDocTypedef_test.go b/internal/fourslash/tests/gen/documentHighlightJSDocTypedef_test.go new file mode 100644 index 0000000000..4201f123b8 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightJSDocTypedef_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightJSDocTypedef(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @checkJs: true +// @Filename: index.js +/** + * @typedef {{ + * [|foo|]: string; + * [|bar|]: number; + * }} Foo + */ + +/** @type {Foo} */ +const x = { + [|foo|]: "", + [|bar|]: 42, +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightMultilineTemplateStrings_test.go b/internal/fourslash/tests/gen/documentHighlightMultilineTemplateStrings_test.go new file mode 100644 index 0000000000..2829d20a42 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightMultilineTemplateStrings_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightMultilineTemplateStrings(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const foo = ` + "`" + ` + a + [|b|] + c +` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} diff --git a/internal/fourslash/tests/gen/documentHighlightTemplateStrings_test.go b/internal/fourslash/tests/gen/documentHighlightTemplateStrings_test.go new file mode 100644 index 0000000000..6f7ce4adfc --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightTemplateStrings_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightTemplateStrings(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type Foo = "[|a|]" | "b"; + +class C { + p: Foo = ` + "`" + `[|a|]` + "`" + `; + m() { + switch (this.p) { + case ` + "`" + `[|a|]` + "`" + `: + return 1; + case "b": + return 2; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[2]) +} diff --git a/internal/fourslash/tests/gen/documentHighlightVarianceModifiers_test.go b/internal/fourslash/tests/gen/documentHighlightVarianceModifiers_test.go new file mode 100644 index 0000000000..86649021ba --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightVarianceModifiers_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightVarianceModifiers(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type TFoo = { value: Value }; +type TBar<[|in|] [|out|] Value> = TFoo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlights01_test.go b/internal/fourslash/tests/gen/documentHighlights01_test.go new file mode 100644 index 0000000000..27c28183c0 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlights01_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlights01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +function [|f|](x: typeof [|f|]) { + [|f|]([|f|]); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightsInvalidGlobalThis_test.go b/internal/fourslash/tests/gen/documentHighlightsInvalidGlobalThis_test.go new file mode 100644 index 0000000000..3d6c6f2a12 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightsInvalidGlobalThis_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightsInvalidGlobalThis(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare global { + export { globalThis as [|global|] } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightsInvalidModifierLocations_test.go b/internal/fourslash/tests/gen/documentHighlightsInvalidModifierLocations_test.go new file mode 100644 index 0000000000..49041808de --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightsInvalidModifierLocations_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightsInvalidModifierLocations(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + m([|readonly|] p) {} +} +function f([|readonly|] p) {} + +class D { + m([|public|] p) {} +} +function g([|public|] p) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go b/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go new file mode 100644 index 0000000000..8eee5defce --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlightsTypeParameterInHeritageClause01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I<[|T|]> extends I<[|T|]>, [|T|] { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/documentHighlights_33722_test.go b/internal/fourslash/tests/gen/documentHighlights_33722_test.go new file mode 100644 index 0000000000..88674ff6dc --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlights_33722_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlights_33722(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /y.ts +class Foo { + private foo() {} +} + +const f = () => new Foo(); +export default f; +// @Filename: /x.ts +import y from "./y"; + +y().[|foo|]();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} diff --git a/internal/fourslash/tests/gen/documentHighlights_40082_test.go b/internal/fourslash/tests/gen/documentHighlights_40082_test.go new file mode 100644 index 0000000000..37f7dffb52 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlights_40082_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlights_40082(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +export = (state, messages) => { + export [|default|] { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[0]) +} diff --git a/internal/fourslash/tests/gen/documentHighlights_filesToSearch_test.go b/internal/fourslash/tests/gen/documentHighlights_filesToSearch_test.go new file mode 100644 index 0000000000..edf123b827 --- /dev/null +++ b/internal/fourslash/tests/gen/documentHighlights_filesToSearch_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlights_filesToSearch(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: /a.ts +export const [|x|] = 0; +// @Filename: /b.ts +import { [|x|] } from "./a";` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/emptyExportFindReferences_test.go b/internal/fourslash/tests/gen/emptyExportFindReferences_test.go new file mode 100644 index 0000000000..6fe7ccd1f3 --- /dev/null +++ b/internal/fourslash/tests/gen/emptyExportFindReferences_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestEmptyExportFindReferences(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowNonTsExtensions: true +// @Filename: Foo.js +/**/module.exports = { + +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/findAllRefsForModule_test.go b/internal/fourslash/tests/gen/findAllRefsForModule_test.go new file mode 100644 index 0000000000..f0f4d2f456 --- /dev/null +++ b/internal/fourslash/tests/gen/findAllRefsForModule_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestFindAllRefsForModule(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.ts +export const x = 0; +// @Filename: /b.ts +[|import { x } from "/*0*/[|{| "contextRangeIndex": 0 |}./a|]";|] +// @Filename: /c/sub.js +[|const a = require("/*1*/[|{| "contextRangeIndex": 2 |}../a|]");|] +// @Filename: /d.ts + /// ` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "0", "1", "2") + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[3], f.Ranges()[4]) +} diff --git a/internal/fourslash/tests/gen/findReferencesJSXTagName3_test.go b/internal/fourslash/tests/gen/findReferencesJSXTagName3_test.go new file mode 100644 index 0000000000..b43ae83798 --- /dev/null +++ b/internal/fourslash/tests/gen/findReferencesJSXTagName3_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestFindReferencesJSXTagName3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @jsx: preserve +// @Filename: /a.tsx +namespace JSX { + export interface Element { } + export interface IntrinsicElements { + [|[|/*1*/div|]: any;|] + } +} + +[|const [|/*6*/Comp|] = () => + [|<[|/*2*/div|]> + Some content + [|<[|/*3*/div|]>More content|] + |];|] + +const x = [|<[|/*7*/Comp|]> + Content +|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "1", "2", "3", "4", "5", "6", "7", "8") + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[1], f.Ranges()[5], f.Ranges()[7], f.Ranges()[8], f.Ranges()[9]) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, f.Ranges()[3], f.Ranges()[11], f.Ranges()[12]) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAbstract01_test.go b/internal/fourslash/tests/gen/getOccurrencesAbstract01_test.go new file mode 100644 index 0000000000..8eab9e56d7 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAbstract01_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAbstract01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|abstract|] class Animal { + [|abstract|] prop1; // Does not compile + [|abstract|] abstract(); + [|abstract|] walk(): void; + [|abstract|] makeSound(): void; +} +// Abstract class below should not get highlighted +abstract class Foo { + abstract foo(): void; + abstract bar(): void; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAbstract02_test.go b/internal/fourslash/tests/gen/getOccurrencesAbstract02_test.go new file mode 100644 index 0000000000..25f0d3b588 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAbstract02_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAbstract02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Not valid TS (abstract methods can only appear in abstract classes) +class Animal { + [|abstract|] walk(): void; + [|abstract|] makeSound(): void; +} +// abstract cannot appear here, won't get highlighted +let c = /*1*/abstract class Foo { + /*2*/abstract foo(): void; + abstract bar(): void; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1", "2") + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAbstract03_test.go b/internal/fourslash/tests/gen/getOccurrencesAbstract03_test.go new file mode 100644 index 0000000000..ef6f46338e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAbstract03_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAbstract03(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f() { + [|abstract|] class A { + [|abstract|] m(): void; + } + abstract class B {} +} +switch (0) { + case 0: + [|abstract|] class A { [|abstract|] m(): void; } + default: + [|abstract|] class B { [|abstract|] m(): void; } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAfterEdit_test.go b/internal/fourslash/tests/gen/getOccurrencesAfterEdit_test.go new file mode 100644 index 0000000000..899c79a668 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAfterEdit_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAfterEdit(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*0*/ +interface A { + foo: string; +} +function foo(x: A) { + x.f/*1*/oo +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1") + f.GoToMarker(t, "0") + f.Insert(t, "\n") + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAsyncAwait2_test.go b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait2_test.go new file mode 100644 index 0000000000..52d962bcbe --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait2_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAsyncAwait2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|a/**/sync|] function f() { + [|await|] 100; + [|await|] [|await|] 200; + return [|await|] async function () { + await 300; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go new file mode 100644 index 0000000000..018d7214d7 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAsyncAwait3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `a/**/wait 100; +async function f() { + await 300; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesAsyncAwait_test.go b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait_test.go new file mode 100644 index 0000000000..f32e3da21a --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesAsyncAwait(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|async|] function f() { + [|await|] 100; + [|a/**/wait|] [|await|] 200; +class Foo { + async memberFunction() { + await 1; + } +} + return [|await|] async function () { + await 300; + } +} +async function g() { + await 300; + async function f() { + await 400; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionConstructor_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionConstructor_test.go new file mode 100644 index 0000000000..2fb2f56bfd --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionConstructor_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionConstructor(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let A = class Foo { + [|constructor|](); + [|constructor|](x: number); + [|constructor|](y: string); + [|constructor|](a?: any) { + } +} + +let B = class D { + constructor(x: number) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionPrivate_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionPrivate_test.go new file mode 100644 index 0000000000..f851c80c83 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionPrivate_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionPrivate(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let A = class Foo { + [|private|] foo; + [|private|] private; + constructor([|private|] y: string, public x: string) { + } + [|private|] method() { } + public method2() { } + [|private|] static static() { } +} + +let B = class D { + constructor(private x: number) { + } + private test() {} + public test2() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionPublic_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionPublic_test.go new file mode 100644 index 0000000000..f73954f7a8 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionPublic_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionPublic(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let A = class Foo { + [|public|] foo; + [|public|] public; + constructor([|public|] y: string, private x: string) { + } + [|public|] method() { } + private method2() {} + [|public|] static static() { } +} + +let B = class D { + constructor(private x: number) { + } + private test() {} + public test2() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionStaticThis_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionStaticThis_test.go new file mode 100644 index 0000000000..5b92b9142d --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionStaticThis_test.go @@ -0,0 +1,62 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionStaticThis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = class C { + public x; + public y; + public z; + public staticX; + constructor() { + this; + this.x; + this.y; + this.z; + } + foo() { + this; + () => this; + () => { + if (this) { + this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + return this.x; + } + + static bar() { + [|this|]; + [|this|].staticX; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionStatic_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionStatic_test.go new file mode 100644 index 0000000000..6ed8879aee --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionStatic_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionStatic(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let A = class Foo { + public [|static|] foo; + [|static|] a; + constructor(public y: string, private x: string) { + } + public method() { } + private method2() {} + public [|static|] static() { } + private [|static|] static2() { } +} + +let B = class D { + static a; + constructor(private x: number) { + } + private static test() {} + public static test2() {} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesClassExpressionThis_test.go b/internal/fourslash/tests/gen/getOccurrencesClassExpressionThis_test.go new file mode 100644 index 0000000000..201a92434a --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesClassExpressionThis_test.go @@ -0,0 +1,60 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesClassExpressionThis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = class C { + public x; + public y; + public z; + constructor() { + [|this|]; + [|this|].x; + [|this|].y; + [|this|].z; + } + foo() { + [|this|]; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + return [|this|].x; + } + + static bar() { + this; + () => this; + () => { + if (this) { + this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesConst01_test.go b/internal/fourslash/tests/gen/getOccurrencesConst01_test.go new file mode 100644 index 0000000000..21754b9c17 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesConst01_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesConst01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|const|] enum E1 { + v1, + v2 +} + +/*2*/const c = 0;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "2") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesConst04_test.go b/internal/fourslash/tests/gen/getOccurrencesConst04_test.go new file mode 100644 index 0000000000..02c8506933 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesConst04_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesConst04(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export const class C { + private static c/*1*/onst f/*2*/oo; + constructor(public con/*3*/st foo) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1", "2", "3") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesConstructor2_test.go b/internal/fourslash/tests/gen/getOccurrencesConstructor2_test.go new file mode 100644 index 0000000000..757990b784 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesConstructor2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesConstructor2(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + constructor(); + constructor(x: number); + constructor(y: string, x: number); + constructor(a?: any, ...r: any[]) { + if (a === undefined && r.length === 0) { + return; + } + + return; + } +} + +class D { + [|con/**/structor|](public x: number, public y: number) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesConstructor_test.go b/internal/fourslash/tests/gen/getOccurrencesConstructor_test.go new file mode 100644 index 0000000000..1f65312b9e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesConstructor_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesConstructor(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [|const/**/ructor|](); + [|constructor|](x: number); + [|constructor|](y: string, x: number); + [|constructor|](a?: any, ...r: any[]) { + if (a === undefined && r.length === 0) { + return; + } + + return; + } +} + +class D { + constructor(public x: number, public y: number) { + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesDeclare1_test.go b/internal/fourslash/tests/gen/getOccurrencesDeclare1_test.go new file mode 100644 index 0000000000..ee74dbc06e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesDeclare1_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesDeclare1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export [|declare|] module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + } + } + } + + [|declare|] var ambientThing: number; + export var exportedThing = 10; + [|declare|] function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesDeclare2_test.go b/internal/fourslash/tests/gen/getOccurrencesDeclare2_test.go new file mode 100644 index 0000000000..0e2280b8c3 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesDeclare2_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesDeclare2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + [|declare|] var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesDeclare3_test.go b/internal/fourslash/tests/gen/getOccurrencesDeclare3_test.go new file mode 100644 index 0000000000..058607a896 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesDeclare3_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesDeclare3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` +[|declare|] var x; +export [|declare|] var y, z; + +module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +} + +[|declare|] export var v1, v2; +[|declare|] module dm { } +export class EC { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesExport1_test.go b/internal/fourslash/tests/gen/getOccurrencesExport1_test.go new file mode 100644 index 0000000000..62e69b091b --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesExport1_test.go @@ -0,0 +1,69 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesExport1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + [|export|] class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + [|export|] interface I1 { + } + + [|export|] declare module ma.m1.m2.m3 { + interface I2 { + } + } + + [|export|] module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + } + } + } + + declare var ambientThing: number; + [|export|] var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesExport2_test.go b/internal/fourslash/tests/gen/getOccurrencesExport2_test.go new file mode 100644 index 0000000000..3ff78a6c49 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesExport2_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesExport2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + [|export|] class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesExport3_test.go b/internal/fourslash/tests/gen/getOccurrencesExport3_test.go new file mode 100644 index 0000000000..dc43590e8c --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesExport3_test.go @@ -0,0 +1,77 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesExport3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = ` +declare var x; +[|export|] declare var y, z; + +module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +} + +declare [|export|] var v1, v2; +declare module dm { } +[|export|] class EC { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesIfElse2_test.go b/internal/fourslash/tests/gen/getOccurrencesIfElse2_test.go new file mode 100644 index 0000000000..adbee13569 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesIfElse2_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesIfElse2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (true) { + [|if|] (false) { + } + [|else|]{ + } + if (true) { + } + else { + if (false) + if (true) + var x = undefined; + } +} +else if (null) { +} +else /* whar garbl */ if (undefined) { +} +else +if (false) { +} +else { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesIfElse3_test.go b/internal/fourslash/tests/gen/getOccurrencesIfElse3_test.go new file mode 100644 index 0000000000..12e834b700 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesIfElse3_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesIfElse3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `if (true) { + if (false) { + } + else { + } + [|if|] (true) { + } + [|else|] { + if (false) + if (true) + var x = undefined; + } +} +else if (null) { +} +else /* whar garbl */ if (undefined) { +} +else +if (false) { +} +else { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesIfElseBroken_test.go b/internal/fourslash/tests/gen/getOccurrencesIfElseBroken_test.go new file mode 100644 index 0000000000..111891b96d --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesIfElseBroken_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesIfElseBroken(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|if|] (true) { + var x = 1; +} +[|else if|] () +[|else if|] +[|else|] /* whar garbl */ [|if|] (i/**/f (true) { } else { }) +else` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesIfElse_test.go b/internal/fourslash/tests/gen/getOccurrencesIfElse_test.go new file mode 100644 index 0000000000..749e03f3c5 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesIfElse_test.go @@ -0,0 +1,38 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesIfElse(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|if|] (true) { + if (false) { + } + else { + } + if (true) { + } + else { + if (false) + if (true) + var x = undefined; + } +} +[|else i/**/f|] (null) { +} +[|else|] /* whar garbl */ [|if|] (undefined) { +} +[|else|] +[|if|] (false) { +} +[|else|] { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue2_test.go b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue2_test.go new file mode 100644 index 0000000000..2cbd65cea6 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue2_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesLoopBreakContinue2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var arr = [1, 2, 3, 4]; +label1: for (var n in arr) { + break; + continue; + break label1; + continue label1; + + label2: [|f/**/or|] (var i = 0; i < arr[n]; i++) { + break label1; + continue label1; + + [|break|]; + [|continue|]; + [|break|] label2; + [|continue|] label2; + + function foo() { + label3: while (true) { + break; + continue; + break label3; + continue label3; + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + + label4: do { + break; + continue; + break label4; + continue label4; + + break label3; + continue label3; + + switch (10) { + case 1: + case 2: + break; + break label4; + default: + continue; + } + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + () => { break; + } while (true) + } + } + } +} + +label5: while (true) break label5; + +label7: while (true) continue label5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue3_test.go b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue3_test.go new file mode 100644 index 0000000000..a9203e967e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue3_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesLoopBreakContinue3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var arr = [1, 2, 3, 4]; +label1: for (var n in arr) { + break; + continue; + break label1; + continue label1; + + label2: for (var i = 0; i < arr[n]; i++) { + break label1; + continue label1; + + break; + continue; + break label2; + continue label2; + + function foo() { + label3: [|w/**/hile|] (true) { + [|break|]; + [|continue|]; + [|break|] label3; + [|continue|] label3; + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + + label4: do { + break; + continue; + break label4; + continue label4; + + [|break|] label3; + [|continue|] label3; + + switch (10) { + case 1: + case 2: + break; + break label4; + default: + continue; + } + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + () => { break; } + } while (true) + } + } + } +} + +label5: while (true) break label5; + +label7: while (true) continue label5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue4_test.go b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue4_test.go new file mode 100644 index 0000000000..c5ad290aef --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue4_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesLoopBreakContinue4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var arr = [1, 2, 3, 4]; +label1: for (var n in arr) { + break; + continue; + break label1; + continue label1; + + label2: for (var i = 0; i < arr[n]; i++) { + break label1; + continue label1; + + break; + continue; + break label2; + continue label2; + + function foo() { + label3: while (true) { + break; + continue; + break label3; + continue label3; + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + + label4: [|do|] { + [|break|]; + [|continue|]; + [|break|] label4; + [|continue|] label4; + + break label3; + continue label3; + + switch (10) { + case 1: + case 2: + break; + [|break|] label4; + default: + [|continue|]; + } + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + () => { break; } + } [|wh/**/ile|] (true) + } + } + } +} + +label5: while (true) break label5; + +label7: while (true) continue label5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue5_test.go b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue5_test.go new file mode 100644 index 0000000000..510fe9f2e6 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue5_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesLoopBreakContinue5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var arr = [1, 2, 3, 4]; +label1: for (var n in arr) { + break; + continue; + break label1; + continue label1; + + label2: for (var i = 0; i < arr[n]; i++) { + break label1; + continue label1; + + break; + continue; + break label2; + continue label2; + + function foo() { + label3: while (true) { + break; + continue; + break label3; + continue label3; + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + + label4: do { + break; + continue; + break label4; + continue label4; + + break label3; + continue label3; + + switch (10) { + case 1: + case 2: + break; + break label4; + default: + continue; + } + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + () => { break; } + } while (true) + } + } + } +} + +label5: [|while|] (true) [|br/**/eak|] label5; + +label7: while (true) continue label5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue_test.go b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue_test.go new file mode 100644 index 0000000000..671561d9b3 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue_test.go @@ -0,0 +1,79 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesLoopBreakContinue(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var arr = [1, 2, 3, 4]; +label1: [|for|] (var n in arr) { + [|break|]; + [|continue|]; + [|br/**/eak|] label1; + [|continue|] label1; + + label2: for (var i = 0; i < arr[n]; i++) { + [|break|] label1; + [|continue|] label1; + + break; + continue; + break label2; + continue label2; + + function foo() { + label3: while (true) { + break; + continue; + break label3; + continue label3; + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + + label4: do { + break; + continue; + break label4; + continue label4; + + break label3; + continue label3; + + switch (10) { + case 1: + case 2: + break; + break label4; + default: + continue; + } + + // these cross function boundaries + break label1; + continue label1; + break label2; + continue label2; + () => { break; } + } while (true) + } + } + } +} + +label5: while (true) break label5; + +label7: while (true) continue label5;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesModifiersNegatives1_test.go b/internal/fourslash/tests/gen/getOccurrencesModifiersNegatives1_test.go new file mode 100644 index 0000000000..46b9a8d66e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesModifiersNegatives1_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesModifiersNegatives1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [|{| "count": 3 |}export|] foo; + [|{| "count": 3 |}declare|] bar; + [|{| "count": 3 |}export|] [|{| "count": 3 |}declare|] foobar; + [|{| "count": 3 |}declare|] [|{| "count": 3 |}export|] barfoo; + + constructor([|{| "count": 9 |}export|] conFoo, + [|{| "count": 9 |}declare|] conBar, + [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] conFooBar, + [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] conBarFoo, + [|{| "count": 4 |}static|] sue, + [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] sueFooBar, + [|{| "count": 4 |}static|] [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] sueBarFoo, + [|{| "count": 9 |}declare|] [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] barSueFoo) { + } +} + +module m { + [|{| "count": 0 |}static|] a; + [|{| "count": 0 |}public|] b; + [|{| "count": 0 |}private|] c; + [|{| "count": 0 |}protected|] d; + [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e; + [|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f; + [|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g; +} +[|{| "count": 0 |}static|] a; +[|{| "count": 0 |}public|] b; +[|{| "count": 0 |}private|] c; +[|{| "count": 0 |}protected|] d; +[|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e; +[|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f; +[|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesNonStringImportAssertion_test.go b/internal/fourslash/tests/gen/getOccurrencesNonStringImportAssertion_test.go new file mode 100644 index 0000000000..59b4d6fc29 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesNonStringImportAssertion_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesNonStringImportAssertion(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +import * as react from "react" assert { cache: /**/0 }; +react.Children;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesNonStringImportAttributes_test.go b/internal/fourslash/tests/gen/getOccurrencesNonStringImportAttributes_test.go new file mode 100644 index 0000000000..b830be2cf5 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesNonStringImportAttributes_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesNonStringImportAttributes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @module: node18 +import * as react from "react" with { cache: /**/0 }; +react.Children;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction2_test.go b/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction2_test.go new file mode 100644 index 0000000000..53cb251a85 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction2_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesOfAnonymousFunction2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `//global foo definition +function foo() {} + +(function f/*local*/oo(): number { + return foo(); // local foo reference +}) +//global foo references +fo/*global*/o(); +var f = foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "local", "global") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction_test.go b/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction_test.go new file mode 100644 index 0000000000..d5565d9b30 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesOfAnonymousFunction(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `(function [|foo|](): number { + var x = [|foo|]; + return 0; +})` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesOfDecorators_test.go b/internal/fourslash/tests/gen/getOccurrencesOfDecorators_test.go new file mode 100644 index 0000000000..1de1f9dff6 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesOfDecorators_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesOfDecorators(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: b.ts +@/*1*/decorator +class C { + @decorator + method() {} +} +function decorator(target) { + return target; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesOfUndefinedSymbol_test.go b/internal/fourslash/tests/gen/getOccurrencesOfUndefinedSymbol_test.go new file mode 100644 index 0000000000..c53dcf4073 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesOfUndefinedSymbol_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesOfUndefinedSymbol(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var obj1: { + (bar: any): any; + new (bar: any): any; + [bar: any]: any; + bar: any; + foob(bar: any): any; +}; + +class cls3 { + property zeFunc() { + super.ceFun/**/c(); +} +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesPrivate1_test.go b/internal/fourslash/tests/gen/getOccurrencesPrivate1_test.go new file mode 100644 index 0000000000..82dcabbfd8 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesPrivate1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesPrivate1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + [|private|] priv1; + [|private|] priv2; + protected prot1; + protected prot2; + + public public; + [|private|] private; + protected protected; + + public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + [|private|] static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesPrivate2_test.go b/internal/fourslash/tests/gen/getOccurrencesPrivate2_test.go new file mode 100644 index 0000000000..bdc44779e5 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesPrivate2_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesPrivate2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + [|private|] priv1; + protected prot1; + + protected constructor(public public, protected protected, [|private|] private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesPropertyInAliasedInterface_test.go b/internal/fourslash/tests/gen/getOccurrencesPropertyInAliasedInterface_test.go new file mode 100644 index 0000000000..7a6580c910 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesPropertyInAliasedInterface_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesPropertyInAliasedInterface(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export interface Foo { + [|abc|] + } +} + +import Bar = m.Foo; + +export interface I extends Bar { + [|abc|] +} + +class C implements Bar { + [|abc|] +} + +(new C()).[|abc|];` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesProtected1_test.go b/internal/fourslash/tests/gen/getOccurrencesProtected1_test.go new file mode 100644 index 0000000000..8d3446009d --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesProtected1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesProtected1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + [|protected|] prot1; + [|protected|] prot2; + + public public; + private private; + [|protected|] protected; + + public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + [|protected|] static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesProtected2_test.go b/internal/fourslash/tests/gen/getOccurrencesProtected2_test.go new file mode 100644 index 0000000000..920dda9ff2 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesProtected2_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesProtected2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + [|protected|] prot1; + + [|protected|] constructor(public public, [|protected|] protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesPublic1_test.go b/internal/fourslash/tests/gen/getOccurrencesPublic1_test.go new file mode 100644 index 0000000000..ef8c17709b --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesPublic1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesPublic1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + [|public|] pub1; + [|public|] pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + [|public|] public; + private private; + protected protected; + + [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + [|public|] get x() { return 10; } + [|public|] set x(value) { } + + [|public|] static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesPublic2_test.go b/internal/fourslash/tests/gen/getOccurrencesPublic2_test.go new file mode 100644 index 0000000000..ad0539050c --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesPublic2_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesPublic2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public static statPub; + private static statPriv; + protected static statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + [|public|] pub1; + private priv1; + protected prot1; + + protected constructor([|public|] public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReadonly1_test.go b/internal/fourslash/tests/gen/getOccurrencesReadonly1_test.go new file mode 100644 index 0000000000..09207e111c --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReadonly1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReadonly1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + [|readonly|] prop: string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReadonly2_test.go b/internal/fourslash/tests/gen/getOccurrencesReadonly2_test.go new file mode 100644 index 0000000000..394a37edb3 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReadonly2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReadonly2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type T = { + [|readonly|] prop: string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReadonly3_test.go b/internal/fourslash/tests/gen/getOccurrencesReadonly3_test.go new file mode 100644 index 0000000000..d28f052ad8 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReadonly3_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReadonly3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [|readonly|] prop: /**/readonly string[] = []; + constructor([|readonly|] prop2: string) { + class D { + readonly prop: string = ""; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "") +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReturn2_test.go b/internal/fourslash/tests/gen/getOccurrencesReturn2_test.go new file mode 100644 index 0000000000..2bbf9a577a --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReturn2_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReturn2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + if (a > 0) { + return (function () { + [|return|]; + [|ret/**/urn|]; + [|return|]; + + while (false) { + [|return|] true; + } + })() || true; + } + + var unusued = [1, 2, 3, 4].map(x => { return 4 }) + + return; + return true; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReturn3_test.go b/internal/fourslash/tests/gen/getOccurrencesReturn3_test.go new file mode 100644 index 0000000000..0db759c30e --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReturn3_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReturn3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + if (a > 0) { + return (function () { + return; + return; + return; + + if (false) { + return true; + } + })() || true; + } + + var unusued = [1, 2, 3, 4].map(x => { [|return|] 4 }) + + return; + return true; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesReturn_test.go b/internal/fourslash/tests/gen/getOccurrencesReturn_test.go new file mode 100644 index 0000000000..ec174948e7 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesReturn_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesReturn(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + if (a > 0) { + [|ret/**/urn|] (function () { + return; + return; + return; + + if (false) { + return true; + } + })() || true; + } + + var unusued = [1, 2, 3, 4].map(x => { return 4 }) + + [|return|]; + [|return|] true; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSetAndGet2_test.go b/internal/fourslash/tests/gen/getOccurrencesSetAndGet2_test.go new file mode 100644 index 0000000000..d295c766c0 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSetAndGet2_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSetAndGet2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + set bar(b: any) { + } + + public get bar(): any { + return undefined; + } + + public [|set|] set(s: any) { + } + + public [|get|] set(): any { + return undefined; + } + + public set get(g: any) { + } + + public get get(): any { + return undefined; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSetAndGet3_test.go b/internal/fourslash/tests/gen/getOccurrencesSetAndGet3_test.go new file mode 100644 index 0000000000..db8bcf2ed0 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSetAndGet3_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSetAndGet3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + set bar(b: any) { + } + + public get bar(): any { + return undefined; + } + + public set set(s: any) { + } + + public get set(): any { + return undefined; + } + + public [|set|] get(g: any) { + } + + public [|get|] get(): any { + return undefined; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSetAndGet_test.go b/internal/fourslash/tests/gen/getOccurrencesSetAndGet_test.go new file mode 100644 index 0000000000..8331f0cbf7 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSetAndGet_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSetAndGet(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + [|set|] bar(b: any) { + } + + public [|get|] bar(): any { + return undefined; + } + + public set set(s: any) { + } + + public get set(): any { + return undefined; + } + + public set get(g: any) { + } + + public get get(): any { + return undefined; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesStatic1_test.go b/internal/fourslash/tests/gen/getOccurrencesStatic1_test.go new file mode 100644 index 0000000000..cbc201d844 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesStatic1_test.go @@ -0,0 +1,70 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesStatic1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module m { + export class C1 { + public pub1; + public pub2; + private priv1; + private priv2; + protected prot1; + protected prot2; + + public public; + private private; + protected protected; + + public constructor(public a, private b, protected c, public d, private e, protected f) { + this.public = 10; + this.private = 10; + this.protected = 10; + } + + public get x() { return 10; } + public set x(value) { } + + public [|static|] statPub; + private [|static|] statPriv; + protected [|static|] statProt; + } + + export interface I1 { + } + + export declare module ma.m1.m2.m3 { + interface I2 { + } + } + + export module mb.m1.m2.m3 { + declare var foo; + + export class C2 { + public pub1; + private priv1; + protected prot1; + + protected constructor(public public, protected protected, private private) { + public = private = protected; + } + } + } + + declare var ambientThing: number; + export var exportedThing = 10; + declare function foo(): string; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesStringLiteralTypes_test.go b/internal/fourslash/tests/gen/getOccurrencesStringLiteralTypes_test.go new file mode 100644 index 0000000000..fbeb14bddf --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesStringLiteralTypes_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesStringLiteralTypes(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo(a: "[|option 1|]") { } +foo("[|option 1|]");` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesStringLiterals_test.go b/internal/fourslash/tests/gen/getOccurrencesStringLiterals_test.go new file mode 100644 index 0000000000..3b35ac59ac --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesStringLiterals_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesStringLiterals(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = "[|string|]"; +function f(a = "[|initial value|]") { }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSuper2_test.go b/internal/fourslash/tests/gen/getOccurrencesSuper2_test.go new file mode 100644 index 0000000000..dc9abe7f75 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSuper2_test.go @@ -0,0 +1,66 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSuper2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class SuperType { + superMethod() { + } + + static superStaticMethod() { + return 10; + } +} + +class SubType extends SuperType { + public prop1 = super.superMethod; + private prop2 = super.superMethod; + + constructor() { + super(); + } + + public method1() { + return super.superMethod(); + } + + private method2() { + return super.superMethod(); + } + + public method3() { + var x = () => super.superMethod(); + + // Bad but still gets highlighted + function f() { + super.superMethod(); + } + } + + // Bad but still gets highlighted. + public static statProp1 = [|super|].superStaticMethod; + + public static staticMethod1() { + return [|super|].superStaticMethod(); + } + + private static staticMethod2() { + return [|supe/**/r|].superStaticMethod(); + } + + // Are not actually 'super' keywords. + super = 10; + static super = 20; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSuper3_test.go b/internal/fourslash/tests/gen/getOccurrencesSuper3_test.go new file mode 100644 index 0000000000..e364755a57 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSuper3_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSuper3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let x = { + a() { + return [|s/**/uper|].b(); + }, + b() { + return [|super|].a(); + }, + c: function () { + return [|super|].a(); + } + d: () => [|super|].b(); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSuperNegatives_test.go b/internal/fourslash/tests/gen/getOccurrencesSuperNegatives_test.go new file mode 100644 index 0000000000..a63a247b32 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSuperNegatives_test.go @@ -0,0 +1,36 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSuperNegatives(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(x = [|super|]) { + [|super|]; +} + +module M { + [|super|]; + function f(x = [|super|]) { + [|super|]; + } + + class A { + } + + class B extends A { + constructor() { + super(); + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSuper_test.go b/internal/fourslash/tests/gen/getOccurrencesSuper_test.go new file mode 100644 index 0000000000..46e10aed15 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSuper_test.go @@ -0,0 +1,66 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSuper(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class SuperType { + superMethod() { + } + + static superStaticMethod() { + return 10; + } +} + +class SubType extends SuperType { + public prop1 = [|s/**/uper|].superMethod; + private prop2 = [|super|].superMethod; + + constructor() { + [|super|](); + } + + public method1() { + return [|super|].superMethod(); + } + + private method2() { + return [|super|].superMethod(); + } + + public method3() { + var x = () => [|super|].superMethod(); + + // Bad but still gets highlighted + function f() { + [|super|].superMethod(); + } + } + + // Bad but still gets highlighted. + public static statProp1 = super.superStaticMethod; + + public static staticMethod1() { + return super.superStaticMethod(); + } + + private static staticMethod2() { + return super.superStaticMethod(); + } + + // Are not actually 'super' keywords. + super = 10; + static super = 20; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault2_test.go b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault2_test.go new file mode 100644 index 0000000000..3dd8679d83 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault2_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSwitchCaseDefault2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `switch (10) { + case 1: + case 2: + case 4: + case 8: + foo: [|switch|] (20) { + [|case|] 1: + [|case|] 2: + [|break|]; + [|default|]: + [|break|] foo; + } + case 0xBEEF: + default: + break; + case 16: +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault3_test.go b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault3_test.go new file mode 100644 index 0000000000..5e9a8a468f --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault3_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSwitchCaseDefault3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `foo: [|switch|] (1) { + [|case|] 1: + [|case|] 2: + [|break|]; + [|case|] 3: + switch (2) { + case 1: + [|break|] foo; + continue; // invalid + default: + break; + } + [|default|]: + [|break|]; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault_test.go b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault_test.go new file mode 100644 index 0000000000..3806974007 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesSwitchCaseDefault(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|switch|] (10) { + [|case|] 1: + [|case|] 2: + [|case|] 4: + [|case|] 8: + foo: switch (20) { + case 1: + case 2: + break; + default: + break foo; + } + [|case|] 0xBEEF: + [|default|]: + [|break|]; + [|case|] 16: +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThis2_test.go b/internal/fourslash/tests/gen/getOccurrencesThis2_test.go new file mode 100644 index 0000000000..eeed422afe --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThis2_test.go @@ -0,0 +1,156 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThis2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `this; +this; + +function f() { + [|this|]; + [|this|]; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + else { + [|t/**/his|].this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } +} + +module m { + function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +class A { + public b = this.method1; + + public method1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private method2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + public static staticB = this.staticMethod1; + + public static staticMethod1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private static staticMethod2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +var x = { + f() { + this; + }, + g() { + this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThis3_test.go b/internal/fourslash/tests/gen/getOccurrencesThis3_test.go new file mode 100644 index 0000000000..5ce3cc6080 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThis3_test.go @@ -0,0 +1,156 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThis3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `this; +this; + +function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + [|t/**/his|]; + (function (_) { + this; + })([|this|]); + } +} + +module m { + function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +class A { + public b = this.method1; + + public method1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private method2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + public static staticB = this.staticMethod1; + + public static staticMethod1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private static staticMethod2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +var x = { + f() { + this; + }, + g() { + this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThis4_test.go b/internal/fourslash/tests/gen/getOccurrencesThis4_test.go new file mode 100644 index 0000000000..4664946228 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThis4_test.go @@ -0,0 +1,156 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThis4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `this; +this; + +function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } +} + +module m { + function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +class A { + public b = [|this|].method1; + + public method1() { + [|this|]; + [|this|]; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + else { + [|this|].this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private method2() { + [|this|]; + [|this|]; + () => [|t/**/his|]; + () => { + if ([|this|]) { + [|this|]; + } + else { + [|this|].this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + public static staticB = this.staticMethod1; + + public static staticMethod1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private static staticMethod2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +var x = { + f() { + this; + }, + g() { + this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThis5_test.go b/internal/fourslash/tests/gen/getOccurrencesThis5_test.go new file mode 100644 index 0000000000..a8fc65fda6 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThis5_test.go @@ -0,0 +1,156 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThis5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `this; +this; + +function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } +} + +module m { + function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +class A { + public b = this.method1; + + public method1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private method2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + public static staticB = [|this|].staticMethod1; + + public static staticMethod1() { + [|this|]; + [|this|]; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + else { + [|this|].this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private static staticMethod2() { + [|this|]; + [|this|]; + () => [|this|]; + () => { + if ([|this|]) { + [|this|]; + } + else { + [|t/**/his|].this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +var x = { + f() { + this; + }, + g() { + this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThis_test.go b/internal/fourslash/tests/gen/getOccurrencesThis_test.go new file mode 100644 index 0000000000..35066c8151 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThis_test.go @@ -0,0 +1,156 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThis(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|this|]; +[|th/**/is|]; + +function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } +} + +module m { + function f() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +class A { + public b = this.method1; + + public method1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private method2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + public static staticB = this.staticMethod1; + + public static staticMethod1() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } + + private static staticMethod2() { + this; + this; + () => this; + () => { + if (this) { + this; + } + else { + this.this; + } + } + function inside() { + this; + (function (_) { + this; + })(this); + } + } +} + +var x = { + f() { + this; + }, + g() { + this; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow2_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow2_test.go new file mode 100644 index 0000000000..0aa3981683 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow2_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + try { + throw "Hello"; + + try { + [|t/**/hrow|] 10; + } + catch (x) { + return 100; + } + finally { + throw 10; + } + } + catch (x) { + throw "Something"; + } + finally { + throw "Also something"; + } + if (a > 0) { + return (function () { + return; + return; + return; + + if (false) { + return true; + } + throw "Hello!"; + })() || true; + } + + throw 10; + + var unusued = [1, 2, 3, 4].map(x => { throw 4 }) + + return; + return true; + throw false; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow3_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow3_test.go new file mode 100644 index 0000000000..0b3c9db94b --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow3_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + try { + [|throw|] "Hello"; + + try { + throw 10; + } + catch (x) { + return 100; + } + finally { + [|thr/**/ow|] 10; + } + } + catch (x) { + throw "Something"; + } + finally { + throw "Also something"; + } + if (a > 0) { + return (function () { + return; + return; + return; + + if (false) { + return true; + } + throw "Hello!"; + })() || true; + } + + throw 10; + + var unusued = [1, 2, 3, 4].map(x => { throw 4 }) + + return; + return true; + throw false; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow4_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow4_test.go new file mode 100644 index 0000000000..5561fdfc34 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow4_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + try { + throw "Hello"; + + try { + throw 10; + } + catch (x) { + return 100; + } + finally { + throw 10; + } + } + catch (x) { + throw "Something"; + } + finally { + throw "Also something"; + } + if (a > 0) { + return (function () { + [|return|]; + [|return|]; + [|return|]; + + if (false) { + [|return|] true; + } + [|th/**/row|] "Hello!"; + })() || true; + } + + throw 10; + + var unusued = [1, 2, 3, 4].map(x => { throw 4 }) + + return; + return true; + throw false; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow5_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow5_test.go new file mode 100644 index 0000000000..adab577183 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow5_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + try { + throw "Hello"; + + try { + throw 10; + } + catch (x) { + return 100; + } + finally { + throw 10; + } + } + catch (x) { + throw "Something"; + } + finally { + throw "Also something"; + } + if (a > 0) { + return (function () { + return; + return; + return; + + if (false) { + return true; + } + throw "Hello!"; + })() || true; + } + + throw 10; + + var unusued = [1, 2, 3, 4].map(x => { [|thr/**/ow|] 4 }) + + return; + return true; + throw false; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow6_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow6_test.go new file mode 100644 index 0000000000..0981f2089c --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow6_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `[|throw|] 100; + +try { + throw 0; + var x = () => { throw 0; }; +} +catch (y) { + var x = () => { throw 0; }; + [|throw|] 200; +} +finally { + [|throw|] 300; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow7_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow7_test.go new file mode 100644 index 0000000000..47006b2a8d --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow7_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `try { + [|throw|] 10; + + try { + throw 10; + } + catch (x) { + [|throw|] 10; + } + finally { + [|throw|] 10; + } +} +finally { + [|throw|] 10; +} + +[|throw|] 10;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow8_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow8_test.go new file mode 100644 index 0000000000..d4cbd56faa --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow8_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `try { + throw 10; + + try { + [|throw|] 10; + } + catch (x) { + throw 10; + } + finally { + throw 10; + } +} +finally { + throw 10; +} + +throw 10;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesThrow_test.go b/internal/fourslash/tests/gen/getOccurrencesThrow_test.go new file mode 100644 index 0000000000..7d4a7b5dc4 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesThrow_test.go @@ -0,0 +1,58 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesThrow(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(a: number) { + try { + throw "Hello"; + + try { + throw 10; + } + catch (x) { + [|return|] 100; + } + finally { + throw 10; + } + } + catch (x) { + [|throw|] "Something"; + } + finally { + [|throw|] "Also something"; + } + if (a > 0) { + [|return|] (function () { + return; + return; + return; + + if (false) { + return true; + } + throw "Hello!"; + })() || true; + } + + [|th/**/row|] 10; + + var unusued = [1, 2, 3, 4].map(x => { throw 4 }) + + [|return|]; + [|return|] true; + [|throw|] false; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getOccurrencesYield_test.go b/internal/fourslash/tests/gen/getOccurrencesYield_test.go new file mode 100644 index 0000000000..3eeb7faa92 --- /dev/null +++ b/internal/fourslash/tests/gen/getOccurrencesYield_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetOccurrencesYield(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function* f() { + [|yield|] 100; + [|y/**/ield|] [|yield|] 200; + class Foo { + *memberFunction() { + return yield 1; + } + } + return function* g() { + yield 1; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/getPropertySymbolsFromBaseTypesDoesntCrash_test.go b/internal/fourslash/tests/gen/getPropertySymbolsFromBaseTypesDoesntCrash_test.go new file mode 100644 index 0000000000..cc6213dbe9 --- /dev/null +++ b/internal/fourslash/tests/gen/getPropertySymbolsFromBaseTypesDoesntCrash_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetPropertySymbolsFromBaseTypesDoesntCrash(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +class ClassA implements IInterface { + private [|value|]: number; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go new file mode 100644 index 0000000000..9cfe690620 --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocTypedefTagServices(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: a.js +/** + * Doc comment + * [|@typedef /*def*/[|{| "contextRangeIndex": 0 |}Product|] + * @property {string} title + |]*/ +/** + * @type {[|/*use*/Product|]} + */ +const product = null;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyQuickInfoAt(t, "use", "type Product = {\n title: string;\n}", "Doc comment") + f.VerifyBaselineFindAllReferences(t, "use", "def") + f.VerifyBaselineRename(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges()[1:])...) + f.VerifyBaselineGoToDefinition(t, "use") +} diff --git a/internal/fourslash/tests/gen/occurrences01_test.go b/internal/fourslash/tests/gen/occurrences01_test.go new file mode 100644 index 0000000000..a50d465552 --- /dev/null +++ b/internal/fourslash/tests/gen/occurrences01_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestOccurrences01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `foo: [|switch|] (10) { + [|case|] 1: + [|case|] 2: + [|case|] 3: + [|break|]; + [|break|] foo; + continue; + continue foo; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/occurrences02_test.go b/internal/fourslash/tests/gen/occurrences02_test.go new file mode 100644 index 0000000000..c58ac51a81 --- /dev/null +++ b/internal/fourslash/tests/gen/occurrences02_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestOccurrences02(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function [|f|](x: typeof [|f|]) { + [|f|]([|f|]); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) +} diff --git a/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go b/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go new file mode 100644 index 0000000000..bc4c7a1445 --- /dev/null +++ b/internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestQualifiedName_import_declaration_with_variable_entity_names(t *testing.T) { + t.Parallel() + t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `module Alpha { + export var [|{| "name" : "def" |}x|] = 100; +} + +module Beta { + import p = Alpha.[|{| "name" : "import" |}x|]; +} + +var x = Alpha.[|{| "name" : "mem" |}x|]` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.GoToMarker(t, "import") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &DefaultCommitCharacters, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{ + Includes: []fourslash.CompletionsExpectedItem{ + &lsproto.CompletionItem{ + Label: "x", + Detail: PtrTo("var Alpha.x: number"), + }, + }, + }, + }) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "import") + f.VerifyBaselineGoToDefinition(t, "import") +} diff --git a/internal/fourslash/tests/gen/renameDefaultImportDifferentName_test.go b/internal/fourslash/tests/gen/renameDefaultImportDifferentName_test.go new file mode 100644 index 0000000000..ea59817468 --- /dev/null +++ b/internal/fourslash/tests/gen/renameDefaultImportDifferentName_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestRenameDefaultImportDifferentName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: B.ts +[|export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { + test() { + } +}|] +// @Filename: A.ts +[|import /*2*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] from "./B";|] +let b = new [|B|](); +b.test();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineFindAllReferences(t, "1", "2") + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[1]) + f.VerifyBaselineRename(t, nil /*preferences*/, f.Ranges()[3], f.Ranges()[4]) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1") +} diff --git a/internal/fourslash/tests/gen/scopeOfUnionProperties_test.go b/internal/fourslash/tests/gen/scopeOfUnionProperties_test.go new file mode 100644 index 0000000000..511e6d7473 --- /dev/null +++ b/internal/fourslash/tests/gen/scopeOfUnionProperties_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestScopeOfUnionProperties(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(s: string | number) { + s.constr/*1*/uctor +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "1") +} diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go new file mode 100644 index 0000000000..8469c0935d --- /dev/null +++ b/internal/ls/documenthighlights.go @@ -0,0 +1,690 @@ +package ls + +import ( + "context" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/collections" + "github.com/microsoft/typescript-go/internal/compiler" + "github.com/microsoft/typescript-go/internal/lsutil" + "github.com/microsoft/typescript-go/internal/scanner" + "github.com/microsoft/typescript-go/internal/stringutil" + + "github.com/microsoft/typescript-go/internal/lsp/lsproto" +) + +func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documentUri lsproto.DocumentUri, documentPosition lsproto.Position) (lsproto.DocumentHighlightResponse, error) { + program, sourceFile := l.getProgramAndFile(documentUri) + position := int(l.converters.LineAndCharacterToPosition(sourceFile, documentPosition)) + node := astnav.GetTouchingPropertyName(sourceFile, position) + if node.Parent != nil && (node.Parent.Kind == ast.KindJsxClosingElement || (node.Parent.Kind == ast.KindJsxOpeningElement && node.Parent.TagName() == node)) { + var openingElement, closingElement *ast.Node + if ast.IsJsxElement(node.Parent.Parent) { + openingElement = node.Parent.Parent.AsJsxElement().OpeningElement + closingElement = node.Parent.Parent.AsJsxElement().ClosingElement + } + var documentHighlights []*lsproto.DocumentHighlight + kind := lsproto.DocumentHighlightKindRead + if openingElement != nil { + documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(openingElement, sourceFile), + Kind: &kind, + }) + } + if closingElement != nil { + documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(closingElement, sourceFile), + Kind: &kind, + }) + } + return lsproto.DocumentHighlightsOrNull{ + DocumentHighlights: &documentHighlights, + }, nil + } + documentHighlights := l.getSemanticDocumentHighlights(ctx, position, node, program, sourceFile) + if len(documentHighlights) == 0 { + documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile) + } + // if nil is passed here we never generate an error, just pass an empty higlight + return lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights}, nil +} + +func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + options := refOptions{use: referenceUseReferences} + referenceEntries := l.getReferencedSymbolsForNode(ctx, position, node, program, []*ast.SourceFile{sourceFile}, options, &collections.Set[string]{}) + if referenceEntries == nil { + return nil + } + var highlights []*lsproto.DocumentHighlight + for _, entry := range referenceEntries { + for _, ref := range entry.references { + if ref.node != nil { + fileName, highlight := l.toDocumentHighlight(ref) + if fileName == sourceFile.FileName() { + highlights = append(highlights, highlight) + } + } + } + } + return highlights +} + +func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *lsproto.DocumentHighlight) { + entry = l.resolveEntry(entry) + + kind := lsproto.DocumentHighlightKindRead + if entry.kind == entryKindRange { + return entry.fileName, &lsproto.DocumentHighlight{ + Range: *entry.textRange, + Kind: &kind, + } + } + + // Determine write access for node references. + if ast.IsWriteAccessForReference(entry.node) { + kind = lsproto.DocumentHighlightKindWrite + } + + dh := &lsproto.DocumentHighlight{ + Range: *entry.textRange, + Kind: &kind, + } + + return entry.fileName, dh +} + +func (l *LanguageService) getSyntacticDocumentHighlights(node *ast.Node, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + switch node.Kind { + case ast.KindIfKeyword, ast.KindElseKeyword: + if ast.IsIfStatement(node.Parent) { + return l.getIfElseOccurrences(node.Parent.AsIfStatement(), sourceFile) + } + return nil + case ast.KindReturnKeyword: + return l.useParent(node.Parent, ast.IsReturnStatement, getReturnOccurrences, sourceFile) + case ast.KindThrowKeyword: + return l.useParent(node.Parent, ast.IsThrowStatement, getThrowOccurrences, sourceFile) + case ast.KindTryKeyword, ast.KindCatchKeyword, ast.KindFinallyKeyword: + var tryStatement *ast.Node + if node.Kind == ast.KindCatchKeyword { + tryStatement = node.Parent.Parent + } else { + tryStatement = node.Parent + } + return l.useParent(tryStatement, ast.IsTryStatement, getTryCatchFinallyOccurrences, sourceFile) + case ast.KindSwitchKeyword: + return l.useParent(node.Parent, ast.IsSwitchStatement, getSwitchCaseDefaultOccurrences, sourceFile) + case ast.KindCaseKeyword, ast.KindDefaultKeyword: + if ast.IsDefaultClause(node.Parent) || ast.IsCaseClause(node.Parent) { + return l.useParent(node.Parent.Parent.Parent, ast.IsSwitchStatement, getSwitchCaseDefaultOccurrences, sourceFile) + } + return nil + case ast.KindBreakKeyword, ast.KindContinueKeyword: + return l.useParent(node.Parent, ast.IsBreakOrContinueStatement, getBreakOrContinueStatementOccurrences, sourceFile) + case ast.KindForKeyword, ast.KindWhileKeyword, ast.KindDoKeyword: + return l.useParent(node.Parent, func(n *ast.Node) bool { + return ast.IsIterationStatement(n, true) + }, getLoopBreakContinueOccurrences, sourceFile) + case ast.KindConstructorKeyword: + return l.getFromAllDeclarations(ast.IsConstructorDeclaration, []ast.Kind{ast.KindConstructorKeyword}, node, sourceFile) + case ast.KindGetKeyword, ast.KindSetKeyword: + return l.getFromAllDeclarations(ast.IsAccessor, []ast.Kind{ast.KindGetKeyword, ast.KindSetKeyword}, node, sourceFile) + case ast.KindAwaitKeyword: + return l.useParent(node.Parent, ast.IsAwaitExpression, getAsyncAndAwaitOccurrences, sourceFile) + case ast.KindAsyncKeyword: + return l.highlightSpans(getAsyncAndAwaitOccurrences(node, sourceFile), sourceFile) + case ast.KindYieldKeyword: + return l.highlightSpans(getYieldOccurrences(node, sourceFile), sourceFile) + case ast.KindInKeyword, ast.KindOutKeyword: + return nil + default: + if ast.IsModifierKind(node.Kind) && (ast.IsDeclaration(node.Parent) || ast.IsVariableStatement(node.Parent)) { + return l.highlightSpans(getModifierOccurrences(node.Kind, node.Parent, sourceFile), sourceFile) + } + return nil + } +} + +func (l *LanguageService) useParent(node *ast.Node, nodeTest func(*ast.Node) bool, getNodes func(*ast.Node, *ast.SourceFile) []*ast.Node, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + if nodeTest(node) { + return l.highlightSpans(getNodes(node, sourceFile), sourceFile) + } + return nil +} + +func (l *LanguageService) highlightSpans(nodes []*ast.Node, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + if len(nodes) == 0 { + return nil + } + var highlights []*lsproto.DocumentHighlight + kind := lsproto.DocumentHighlightKindRead + for _, node := range nodes { + if node != nil { + highlights = append(highlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(node, sourceFile), + Kind: &kind, + }) + } + } + return highlights +} + +func (l *LanguageService) getFromAllDeclarations(nodeTest func(*ast.Node) bool, keywords []ast.Kind, node *ast.Node, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + return l.useParent(node.Parent, nodeTest, func(decl *ast.Node, sf *ast.SourceFile) []*ast.Node { + var symbolDecls []*ast.Node + if ast.CanHaveSymbol(decl) { + if symbol := decl.Symbol(); symbol != nil { + for _, d := range symbol.Declarations { + if nodeTest(d) { + outer: + for _, c := range getChildrenFromNonJSDocNode(d, sourceFile) { + for _, k := range keywords { + if c.Kind == k { + symbolDecls = append(symbolDecls, c) + break outer + } + } + } + } + } + } + } + return symbolDecls + }, sourceFile) +} + +func (l *LanguageService) getIfElseOccurrences(ifStatement *ast.IfStatement, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + keywords := getIfElseKeywords(ifStatement, sourceFile) + kind := lsproto.DocumentHighlightKindRead + var highlights []*lsproto.DocumentHighlight + + // We'd like to highlight else/ifs together if they are only separated by whitespace + // (i.e. the keywords are separated by no comments, no newlines). + for i := 0; i < len(keywords); i++ { + if keywords[i].Kind == ast.KindElseKeyword && i < len(keywords)-1 { + elseKeyword := keywords[i] + ifKeyword := keywords[i+1] // this *should* always be an 'if' keyword. + shouldCombine := true + + // Avoid recalculating getStart() by iterating backwards. + ifTokenStart := scanner.GetTokenPosOfNode(ifKeyword, sourceFile, false) + if ifTokenStart < 0 { + ifTokenStart = ifKeyword.Pos() + } + for j := ifTokenStart - 1; j >= elseKeyword.End(); j-- { + if !stringutil.IsWhiteSpaceSingleLine(rune(sourceFile.Text()[j])) { + shouldCombine = false + break + } + } + if shouldCombine { + highlights = append(highlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromBounds(scanner.SkipTrivia(sourceFile.Text(), elseKeyword.Pos()), ifKeyword.End(), sourceFile), + Kind: &kind, + }) + i++ // skip the next keyword + continue + } + } + // Ordinary case: just highlight the keyword. + highlights = append(highlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(keywords[i], sourceFile), + Kind: &kind, + }) + } + return highlights +} + +func getIfElseKeywords(ifStatement *ast.IfStatement, sourceFile *ast.SourceFile) []*ast.Node { + // Traverse upwards through all parent if-statements linked by their else-branches. + // Is this cast error safe or should i be checking if elseStatement exists first? + for ast.IsIfStatement(ifStatement.Parent) && ifStatement.Parent.AsIfStatement().ElseStatement.AsIfStatement() == ifStatement { + ifStatement = ifStatement.Parent.AsIfStatement() + } + + var keywords []*ast.Node + + // Traverse back down through the else branches, aggregating if/else keywords of if-statements. + for { + children := getChildrenFromNonJSDocNode(ifStatement.AsNode(), sourceFile) + if len(children) > 0 && children[0].Kind == ast.KindIfKeyword { + keywords = append(keywords, children[0]) + } + // Generally the 'else' keyword is second-to-last, so traverse backwards. + for i := len(children) - 1; i >= 0; i-- { + if children[i].Kind == ast.KindElseKeyword { + keywords = append(keywords, children[i]) + break + } + } + elseStatement := ifStatement.ElseStatement + if elseStatement == nil || !ast.IsIfStatement(elseStatement) { + break + } + ifStatement = elseStatement.AsIfStatement() + } + return keywords +} + +func getReturnOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + funcNode := ast.FindAncestor(node.Parent, ast.IsFunctionLike) + if funcNode == nil { + return nil + } + + var keywords []*ast.Node + body := funcNode.Body() + if body != nil { + ast.ForEachReturnStatement(body, func(ret *ast.Node) bool { + keyword := findChildOfKind(ret, ast.KindReturnKeyword, sourceFile) + if keyword != nil { + keywords = append(keywords, keyword) + } + return false // continue traversal + }) + + // Get all throw statements not in a try block + throwStatements := aggregateOwnedThrowStatements(body, sourceFile) + for _, throw := range throwStatements { + keyword := findChildOfKind(throw, ast.KindThrowKeyword, sourceFile) + if keyword != nil { + keywords = append(keywords, keyword) + } + } + } + return keywords +} + +func aggregateOwnedThrowStatements(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + if ast.IsThrowStatement(node) { + return []*ast.Node{node} + } + if ast.IsTryStatement(node) { + // Exceptions thrown within a try block lacking a catch clause are "owned" in the current context. + statement := node.AsTryStatement() + tryBlock := statement.TryBlock + catchClause := statement.CatchClause + finallyBlock := statement.FinallyBlock + + var result []*ast.Node + if catchClause != nil { + result = aggregateOwnedThrowStatements(catchClause, sourceFile) + } else if tryBlock != nil { + result = aggregateOwnedThrowStatements(tryBlock, sourceFile) + } + if finallyBlock != nil { + result = append(result, aggregateOwnedThrowStatements(finallyBlock, sourceFile)...) + } + return result + } + // Do not cross function boundaries. + if ast.IsFunctionLike(node) { + return nil + } + return flatMapChildren(node, sourceFile, aggregateOwnedThrowStatements) +} + +func flatMapChildren[T any](node *ast.Node, sourceFile *ast.SourceFile, cb func(child *ast.Node, sourceFile *ast.SourceFile) []T) []T { + var result []T + + node.ForEachChild(func(child *ast.Node) bool { + value := cb(child, sourceFile) + if value != nil { + result = append(result, value...) + } + return false // continue traversal + }) + return result +} + +func getThrowOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + owner := getThrowStatementOwner(node) + if owner == nil { + return nil + } + + var keywords []*ast.Node + + // Aggregate all throw statements "owned" by this owner. + throwStatements := aggregateOwnedThrowStatements(owner, sourceFile) + for _, throw := range throwStatements { + keyword := findChildOfKind(throw, ast.KindThrowKeyword, sourceFile) + if keyword != nil { + keywords = append(keywords, keyword) + } + } + + // If the "owner" is a function, then we equate 'return' and 'throw' statements in their + // ability to "jump out" of the function, and include occurrences for both + if ast.IsFunctionBlock(owner) { + ast.ForEachReturnStatement(owner, func(ret *ast.Node) bool { + keyword := findChildOfKind(ret, ast.KindReturnKeyword, sourceFile) + if keyword != nil { + keywords = append(keywords, keyword) + } + return false // continue traversal + }) + } + + return keywords +} + +// For lack of a better name, this function takes a throw statement and returns the +// nearest ancestor that is a try-block (whose try statement has a catch clause), +// function-block, or source file. +func getThrowStatementOwner(throwStatement *ast.Node) *ast.Node { + child := throwStatement + for child.Parent != nil { + parent := child.Parent + + if ast.IsFunctionBlock(parent) || parent.Kind == ast.KindSourceFile { + return parent + } + + // A throw-statement is only owned by a try-statement if the try-statement has + // a catch clause, and if the throw-statement occurs within the try block. + if ast.IsTryStatement(parent) { + tryStatement := parent.AsTryStatement() + if tryStatement.TryBlock == child && tryStatement.CatchClause != nil { + return child + } + } + + child = parent + } + return nil +} + +func getTryCatchFinallyOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + tryStatement := node.AsTryStatement() + + var keywords []*ast.Node + token := lsutil.GetFirstToken(node, sourceFile) + if token.Kind == ast.KindTryKeyword { + keywords = append(keywords, token) + } + + if tryStatement.CatchClause != nil { + catchToken := lsutil.GetFirstToken(tryStatement.CatchClause.AsNode(), sourceFile) + if catchToken.Kind == ast.KindCatchKeyword { + keywords = append(keywords, catchToken) + } + } + + if tryStatement.FinallyBlock != nil { + finallyKeyword := findChildOfKind(node, ast.KindFinallyKeyword, sourceFile) + if finallyKeyword.Kind == ast.KindFinallyKeyword { + keywords = append(keywords, finallyKeyword) + } + } + + return keywords +} + +func getSwitchCaseDefaultOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + switchStatement := node.AsSwitchStatement() + + var keywords []*ast.Node + token := lsutil.GetFirstToken(node, sourceFile) + if token.Kind == ast.KindSwitchKeyword { + keywords = append(keywords, token) + } + + clauses := switchStatement.CaseBlock.AsCaseBlock().Clauses + for _, clause := range clauses.Nodes { + clauseToken := lsutil.GetFirstToken(clause.AsNode(), sourceFile) + if clauseToken.Kind == ast.KindCaseKeyword || clauseToken.Kind == ast.KindDefaultKeyword { + keywords = append(keywords, clauseToken) + } + + breakAndContinueStatements := aggregateAllBreakAndContinueStatements(clause, sourceFile) + for _, statement := range breakAndContinueStatements { + if statement.Kind == ast.KindBreakStatement && ownsBreakOrContinueStatement(switchStatement.AsNode(), statement) { + keywords = append(keywords, lsutil.GetFirstToken(statement, sourceFile)) + } + } + } + + return keywords +} + +func aggregateAllBreakAndContinueStatements(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + if ast.IsBreakOrContinueStatement(node) { + return []*ast.Node{node} + } + if ast.IsFunctionLike(node) { + return nil + } + return flatMapChildren(node, sourceFile, aggregateAllBreakAndContinueStatements) +} + +func ownsBreakOrContinueStatement(owner *ast.Node, statement *ast.Node) bool { + actualOwner := getBreakOrContinueOwner(statement) + if actualOwner == nil { + return false + } + return actualOwner == owner +} + +func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { + return ast.FindAncestorOrQuit(statement, func(node *ast.Node) ast.FindAncestorResult { + switch node.Kind { + case ast.KindSwitchStatement: + if statement.Kind == ast.KindContinueStatement { + return ast.FindAncestorFalse + } + fallthrough + case ast.KindForStatement, + ast.KindForInStatement, + ast.KindForOfStatement, + ast.KindWhileStatement, + ast.KindDoStatement: + // If the statement is labeled, check if the node is labeled by the statement's label. + if statement.Label() == nil || isLabeledBy(node, statement.Label().Text()) { + return ast.FindAncestorTrue + } + return ast.FindAncestorFalse + default: + // Don't cross function boundaries. + if ast.IsFunctionLike(node) { + return ast.FindAncestorQuit + } + return ast.FindAncestorFalse + } + }) +} + +// Whether or not a 'node' is preceded by a label of the given string. +// Note: 'node' cannot be a SourceFile. +func isLabeledBy(node *ast.Node, labelName string) bool { + return ast.FindAncestorOrQuit(node.Parent, func(owner *ast.Node) ast.FindAncestorResult { + if !ast.IsLabeledStatement(owner) { + return ast.FindAncestorQuit + } + if owner.Label().Text() == labelName { + return ast.FindAncestorTrue + } + return ast.FindAncestorFalse + }) != nil +} + +func getBreakOrContinueStatementOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + if owner := getBreakOrContinueOwner(node); owner != nil { + switch owner.Kind { + case ast.KindForStatement, ast.KindForInStatement, ast.KindForOfStatement, ast.KindDoStatement, ast.KindWhileStatement: + return getLoopBreakContinueOccurrences(owner, sourceFile) + case ast.KindSwitchStatement: + return getSwitchCaseDefaultOccurrences(owner, sourceFile) + } + } + return nil +} + +func getLoopBreakContinueOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + var keywords []*ast.Node + + token := lsutil.GetFirstToken(node, sourceFile) + if token.Kind == ast.KindForKeyword || token.Kind == ast.KindDoKeyword || token.Kind == ast.KindWhileKeyword { + keywords = append(keywords, token) + if node.Kind == ast.KindDoStatement { + loopTokens := getChildrenFromNonJSDocNode(node, sourceFile) + for i := len(loopTokens) - 1; i >= 0; i-- { + if loopTokens[i].Kind == ast.KindWhileKeyword { + keywords = append(keywords, loopTokens[i]) + break + } + } + } + } + + breakAndContinueStatements := aggregateAllBreakAndContinueStatements(node, sourceFile) + for _, statement := range breakAndContinueStatements { + token := lsutil.GetFirstToken(statement, sourceFile) + if ownsBreakOrContinueStatement(node, statement) && (token.Kind == ast.KindBreakKeyword || token.Kind == ast.KindContinueKeyword) { + keywords = append(keywords, token) + } + } + + return keywords +} + +func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + parent := ast.FindAncestor(node.Parent, ast.IsFunctionLike) + if parent == nil { + return nil + } + parentFunc := parent.AsFunctionDeclaration() + var keywords []*ast.Node + + modifiers := parentFunc.Modifiers() + if modifiers != nil { + for _, modifier := range modifiers.Nodes { + if modifier.Kind == ast.KindAsyncKeyword { + keywords = append(keywords, modifier) + } + } + } + + parentFunc.ForEachChild(func(child *ast.Node) bool { + traverseWithoutCrossingFunction(child, sourceFile, func(child *ast.Node) { + if ast.IsAwaitExpression(child) { + token := lsutil.GetFirstToken(child, sourceFile) + if token.Kind == ast.KindAwaitKeyword { + keywords = append(keywords, token) + } + } + }) + return false // continue traversal + }) + + return keywords +} + +func getYieldOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + parentFunc := ast.FindAncestor(node.Parent, ast.IsFunctionLike).AsFunctionDeclaration() + if parentFunc == nil { + return nil + } + + var keywords []*ast.Node + + parentFunc.ForEachChild(func(child *ast.Node) bool { + traverseWithoutCrossingFunction(child, sourceFile, func(child *ast.Node) { + if ast.IsYieldExpression(child) { + token := lsutil.GetFirstToken(child, sourceFile) + if token.Kind == ast.KindYieldKeyword { + keywords = append(keywords, token) + } + } + }) + return false // continue traversal + }) + + return keywords +} + +func traverseWithoutCrossingFunction(node *ast.Node, sourceFile *ast.SourceFile, cb func(*ast.Node)) { + cb(node) + if !ast.IsFunctionLike(node) && !ast.IsClassLike(node) && !ast.IsInterfaceDeclaration(node) && !ast.IsModuleDeclaration(node) && !ast.IsTypeAliasDeclaration(node) && !ast.IsTypeNode(node) { + node.ForEachChild(func(child *ast.Node) bool { + traverseWithoutCrossingFunction(child, sourceFile, cb) + return false // continue traversal + }) + } +} + +func getModifierOccurrences(kind ast.Kind, node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + var result []*ast.Node + + nodesToSearch := getNodesToSearchForModifier(node, ast.ModifierToFlag(kind)) + for _, n := range nodesToSearch { + modifier := findModifier(n, kind) + if modifier != nil { + result = append(result, modifier) + } + } + return result +} + +func getNodesToSearchForModifier(declaration *ast.Node, modifierFlag ast.ModifierFlags) []*ast.Node { + var result []*ast.Node + + container := declaration.Parent + if container == nil { + return nil + } + + // Types of node whose children might have modifiers. + switch container.Kind { + case ast.KindModuleBlock, ast.KindSourceFile, ast.KindBlock, ast.KindCaseClause, ast.KindDefaultClause: + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag&ast.ModifierFlagsAbstract) != 0 && ast.IsClassDeclaration(declaration) { + return append(append(result, declaration.Members()...), declaration) + } else { + return append(result, container.Statements()...) + } + case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: + // Parameters and, if inside a class, also class members + result = append(result, container.Parameters()...) + if ast.IsClassLike(container.Parent) { + result = append(result, container.Parent.Members()...) + } + return result + case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindTypeLiteral: + nodes := container.Members() + result = append(result, nodes...) + // If we're an accessibility modifier, we're in an instance member and should search + // the constructor's parameter list for instance members as well. + if (modifierFlag & (ast.ModifierFlagsAccessibilityModifier | ast.ModifierFlagsReadonly)) != 0 { + var constructor *ast.Node + + for _, member := range nodes { + if ast.IsConstructorDeclaration(member) { + constructor = member + break + } + } + if constructor != nil { + result = append(result, constructor.Parameters()...) + } + } else if (modifierFlag & ast.ModifierFlagsAbstract) != 0 { + result = append(result, container) + } + return result + default: + // Syntactically invalid positions or unsupported containers + return nil + } +} + +func findModifier(node *ast.Node, kind ast.Kind) *ast.Node { + if modifiers := node.Modifiers(); modifiers != nil { + for _, modifier := range modifiers.Nodes { + if modifier.Kind == kind { + return modifier + } + } + } + return nil +} diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 8f099d691f..256da67860 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -245,7 +245,7 @@ func getContextNode(node *ast.Node) *ast.Node { return nil case ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment: - if isArrayLiteralOrObjectLiteralDestructuringPattern(node.Parent) { + if ast.IsArrayLiteralOrObjectLiteralDestructuringPattern(node.Parent) { return getContextNode(ast.FindAncestor(node.Parent, func(node *ast.Node) bool { return node.Kind == ast.KindBinaryExpression || ast.IsForInOrOfStatement(node) })) @@ -945,6 +945,9 @@ func getPossibleSymbolReferencePositions(sourceFile *ast.SourceFile, symbolName positions = append(positions, position) } startIndex := position + symbolNameLength + 1 + if startIndex > len(text) { + break + } if foundIndex := strings.Index(text[startIndex:], symbolName); foundIndex != -1 { position = startIndex + foundIndex } else { diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 2cfdff6842..0610524c7b 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -671,32 +671,6 @@ func isImplementationExpression(node *ast.Node) bool { } } -func isArrayLiteralOrObjectLiteralDestructuringPattern(node *ast.Node) bool { - if node.Kind == ast.KindArrayLiteralExpression || node.Kind == ast.KindObjectLiteralExpression { - // [a,b,c] from: - // [a, b, c] = someExpression; - if node.Parent.Kind == ast.KindBinaryExpression && node.Parent.AsBinaryExpression().Left == node && node.Parent.AsBinaryExpression().OperatorToken.Kind == ast.KindEqualsToken { - return true - } - - // [a, b, c] from: - // for([a, b, c] of expression) - if node.Parent.Kind == ast.KindForOfStatement && node.Parent.AsForInOrOfStatement().Initializer == node { - return true - } - - // [a, b, c] of - // [x, [a, b, c] ] = someExpression - // or - // {x, a: {a, b, c} } = someExpression - if isArrayLiteralOrObjectLiteralDestructuringPattern(core.IfElse(node.Parent.Kind == ast.KindPropertyAssignment, node.Parent.Parent, node.Parent)) { - return true - } - } - - return false -} - func isReadonlyTypeOperator(node *ast.Node) bool { return node.Kind == ast.KindReadonlyKeyword && node.Parent.Kind == ast.KindTypeOperator && node.Parent.AsTypeOperatorNode().Operator == ast.KindReadonlyKeyword } diff --git a/internal/lsp/server.go b/internal/lsp/server.go index e057e28d61..62d3baa28c 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -460,6 +460,7 @@ var handlers = sync.OnceValue(func() handlerMap { registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentOnTypeFormattingInfo, (*Server).handleDocumentOnTypeFormat) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentSymbolInfo, (*Server).handleDocumentSymbol) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentHighlightInfo, (*Server).handleDocumentHighlight) registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) @@ -636,6 +637,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ RenameProvider: &lsproto.BooleanOrRenameOptions{ Boolean: ptrTo(true), }, + DocumentHighlightProvider: &lsproto.BooleanOrDocumentHighlightOptions{ + Boolean: ptrTo(true), + }, }, } @@ -836,6 +840,10 @@ func (s *Server) handleRename(ctx context.Context, ls *ls.LanguageService, param return ls.ProvideRename(ctx, params) } +func (s *Server) handleDocumentHighlight(ctx context.Context, ls *ls.LanguageService, params *lsproto.DocumentHighlightParams) (lsproto.DocumentHighlightResponse, error) { + return ls.ProvideDocumentHighlights(ctx, params.TextDocument.Uri, params.Position) +} + func (s *Server) Log(msg ...any) { fmt.Fprintln(s.stderr, msg...) } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties1.baseline.jsonc new file mode 100644 index 0000000000..1878204506 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties1.baseline.jsonc @@ -0,0 +1,15 @@ +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// /*HIGHLIGHTS*/[|doStuff|](): void; +// propName: string; +// } + + + +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// doStuff(): void; +// /*HIGHLIGHTS*/[|propName|]: string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties2.baseline.jsonc new file mode 100644 index 0000000000..85ba0dee42 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties2.baseline.jsonc @@ -0,0 +1,15 @@ +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// /*HIGHLIGHTS*/[|doStuff|]() { } +// propName: string; +// } + + + +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// doStuff() { } +// /*HIGHLIGHTS*/[|propName|]: string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties3.baseline.jsonc new file mode 100644 index 0000000000..c6cf1d5d22 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties3.baseline.jsonc @@ -0,0 +1,49 @@ +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// /*HIGHLIGHTS*/[|doStuff|](): void; +// propName: string; +// } +// +// var v: interface1; +// v.propName; +// v.[|doStuff|](); + + + +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// doStuff(): void; +// /*HIGHLIGHTS*/[|propName|]: string; +// } +// +// var v: interface1; +// v.[|propName|]; +// v.doStuff(); + + + +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// doStuff(): void; +// [|propName|]: string; +// } +// +// var v: interface1; +// v./*HIGHLIGHTS*/[|propName|]; +// v.doStuff(); + + + +// === documentHighlights === +// === /file1.ts === +// interface interface1 extends interface1 { +// [|doStuff|](): void; +// propName: string; +// } +// +// var v: interface1; +// v.propName; +// v./*HIGHLIGHTS*/[|doStuff|](); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties4.baseline.jsonc new file mode 100644 index 0000000000..d716513d69 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties4.baseline.jsonc @@ -0,0 +1,49 @@ +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// /*HIGHLIGHTS*/[|doStuff|]() { } +// propName: string; +// } +// +// var c: class1; +// c.[|doStuff|](); +// c.propName; + + + +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// doStuff() { } +// /*HIGHLIGHTS*/[|propName|]: string; +// } +// +// var c: class1; +// c.doStuff(); +// c.[|propName|]; + + + +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// [|doStuff|]() { } +// propName: string; +// } +// +// var c: class1; +// c./*HIGHLIGHTS*/[|doStuff|](); +// c.propName; + + + +// === documentHighlights === +// === /file1.ts === +// class class1 extends class1 { +// doStuff() { } +// [|propName|]: string; +// } +// +// var c: class1; +// c.doStuff(); +// c./*HIGHLIGHTS*/[|propName|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties5.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties5.baseline.jsonc new file mode 100644 index 0000000000..430b6bd370 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties5.baseline.jsonc @@ -0,0 +1,82 @@ +// === documentHighlights === +// === /file1.ts === +// interface C extends D { +// /*HIGHLIGHTS*/[|prop0|]: string; +// prop1: number; +// } +// +// interface D extends C { +// [|prop0|]: string; +// prop1: number; +// } +// +// var d: D; +// d.prop1; + + + +// === documentHighlights === +// === /file1.ts === +// interface C extends D { +// prop0: string; +// /*HIGHLIGHTS*/[|prop1|]: number; +// } +// +// interface D extends C { +// prop0: string; +// [|prop1|]: number; +// } +// +// var d: D; +// d.[|prop1|]; + + + +// === documentHighlights === +// === /file1.ts === +// interface C extends D { +// [|prop0|]: string; +// prop1: number; +// } +// +// interface D extends C { +// /*HIGHLIGHTS*/[|prop0|]: string; +// prop1: number; +// } +// +// var d: D; +// d.prop1; + + + +// === documentHighlights === +// === /file1.ts === +// interface C extends D { +// prop0: string; +// [|prop1|]: number; +// } +// +// interface D extends C { +// prop0: string; +// /*HIGHLIGHTS*/[|prop1|]: number; +// } +// +// var d: D; +// d.[|prop1|]; + + + +// === documentHighlights === +// === /file1.ts === +// interface C extends D { +// prop0: string; +// [|prop1|]: number; +// } +// +// interface D extends C { +// prop0: string; +// [|prop1|]: number; +// } +// +// var d: D; +// d./*HIGHLIGHTS*/[|prop1|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc new file mode 100644 index 0000000000..e819cd0446 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc @@ -0,0 +1,63 @@ +// === documentHighlights === +// === /file1.ts === +// class C extends D { +// /*HIGHLIGHTS*/[|prop0|]: string; +// prop1: string; +// } +// +// // --- (line: 6) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class C extends D { +// prop0: string; +// /*HIGHLIGHTS*/[|prop1|]: string; +// } +// +// class D extends C { +// // --- (line: 7) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// --- (line: 3) skipped --- +// } +// +// class D extends C { +// /*HIGHLIGHTS*/[|prop0|]: string; +// prop1: string; +// } +// +// var d: D; +// d.prop1; + + + +// === documentHighlights === +// === /file1.ts === +// --- (line: 4) skipped --- +// +// class D extends C { +// prop0: string; +// /*HIGHLIGHTS*/[|prop1|]: string; +// } +// +// var d: D; +// d.[|prop1|]; + + + +// === documentHighlights === +// === /file1.ts === +// --- (line: 4) skipped --- +// +// class D extends C { +// prop0: string; +// [|prop1|]: string; +// } +// +// var d: D; +// d./*HIGHLIGHTS*/[|prop1|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc new file mode 100644 index 0000000000..5176a15ed5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc @@ -0,0 +1,165 @@ +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private /*HIGHLIGHTS*/[|privateParam|]: number, +// public publicParam: string, +// protected protectedParam: boolean) { +// +// let localPrivate = [|privateParam|]; +// this.[|privateParam|] += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public /*HIGHLIGHTS*/[|publicParam|]: string, +// protected protectedParam: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = [|publicParam|]; +// this.[|publicParam|] += " Hello!"; +// +// let localProtected = protectedParam; +// this.protectedParam = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public publicParam: string, +// protected /*HIGHLIGHTS*/[|protectedParam|]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = [|protectedParam|]; +// this.[|protectedParam|] = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private [|privateParam|]: number, +// public publicParam: string, +// protected protectedParam: boolean) { +// +// let localPrivate = /*HIGHLIGHTS*/[|privateParam|]; +// this.[|privateParam|] += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private [|privateParam|]: number, +// public publicParam: string, +// protected protectedParam: boolean) { +// +// let localPrivate = [|privateParam|]; +// this./*HIGHLIGHTS*/[|privateParam|] += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public [|publicParam|]: string, +// protected protectedParam: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = /*HIGHLIGHTS*/[|publicParam|]; +// this.[|publicParam|] += " Hello!"; +// +// let localProtected = protectedParam; +// this.protectedParam = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public [|publicParam|]: string, +// protected protectedParam: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = [|publicParam|]; +// this./*HIGHLIGHTS*/[|publicParam|] += " Hello!"; +// +// let localProtected = protectedParam; +// this.protectedParam = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public publicParam: string, +// protected [|protectedParam|]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = /*HIGHLIGHTS*/[|protectedParam|]; +// this.[|protectedParam|] = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// constructor(private privateParam: number, +// public publicParam: string, +// protected [|protectedParam|]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = [|protectedParam|]; +// this./*HIGHLIGHTS*/[|protectedParam|] = false; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc new file mode 100644 index 0000000000..69914c5798 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc @@ -0,0 +1,109 @@ +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {/*HIGHLIGHTS*/[|privateParam|]}: number, +// public {publicParam}: string, +// protected {protectedParam}: boolean) { +// +// let localPrivate = [|privateParam|]; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {privateParam}: number, +// public {/*HIGHLIGHTS*/[|publicParam|]}: string, +// protected {protectedParam}: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = [|publicParam|]; +// this.publicParam += " Hello!"; +// +// let localProtected = protectedParam; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {privateParam}: number, +// public {publicParam}: string, +// protected {/*HIGHLIGHTS*/[|protectedParam|]}: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = [|protectedParam|]; +// this.protectedParam = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {[|privateParam|]}: number, +// public {publicParam}: string, +// protected {protectedParam}: boolean) { +// +// let localPrivate = /*HIGHLIGHTS*/[|privateParam|]; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {privateParam}: number, +// public {[|publicParam|]}: string, +// protected {protectedParam}: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = /*HIGHLIGHTS*/[|publicParam|]; +// this.publicParam += " Hello!"; +// +// let localProtected = protectedParam; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private {privateParam}: number, +// public {publicParam}: string, +// protected {[|protectedParam|]}: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = /*HIGHLIGHTS*/[|protectedParam|]; +// this.protectedParam = false; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc new file mode 100644 index 0000000000..c5e2753dbe --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc @@ -0,0 +1,109 @@ +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [/*HIGHLIGHTS*/[|privateParam|]]: number, +// public [publicParam]: string, +// protected [protectedParam]: boolean) { +// +// let localPrivate = [|privateParam|]; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [privateParam]: number, +// public [/*HIGHLIGHTS*/[|publicParam|]]: string, +// protected [protectedParam]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = [|publicParam|]; +// this.publicParam += " Hello!"; +// +// let localProtected = protectedParam; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [privateParam]: number, +// public [publicParam]: string, +// protected [/*HIGHLIGHTS*/[|protectedParam|]]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = [|protectedParam|]; +// this.protectedParam = false; +// } +// } + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [[|privateParam|]]: number, +// public [publicParam]: string, +// protected [protectedParam]: boolean) { +// +// let localPrivate = /*HIGHLIGHTS*/[|privateParam|]; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [privateParam]: number, +// public [[|publicParam|]]: string, +// protected [protectedParam]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = /*HIGHLIGHTS*/[|publicParam|]; +// this.publicParam += " Hello!"; +// +// let localProtected = protectedParam; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /file1.ts === +// class Foo { +// // This is not valid syntax: parameter property can't be binding pattern +// constructor(private [privateParam]: number, +// public [publicParam]: string, +// protected [[|protectedParam|]]: boolean) { +// +// let localPrivate = privateParam; +// this.privateParam += 10; +// +// let localPublic = publicParam; +// this.publicParam += " Hello!"; +// +// let localProtected = /*HIGHLIGHTS*/[|protectedParam|]; +// this.protectedParam = false; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInKeyword.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInKeyword.baseline.jsonc new file mode 100644 index 0000000000..4d164587b5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInKeyword.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /documentHighlightDefaultInKeyword.ts === +// /*HIGHLIGHTS*/case +// default + + + +// === documentHighlights === +// === /documentHighlightDefaultInKeyword.ts === +// case +// /*HIGHLIGHTS*/default \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInSwitch.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInSwitch.baseline.jsonc new file mode 100644 index 0000000000..0e160b3e4c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInSwitch.baseline.jsonc @@ -0,0 +1,21 @@ +// === documentHighlights === +// === /documentHighlightDefaultInSwitch.ts === +// const foo = 'foo'; +// [|switch|] (foo) { +// /*HIGHLIGHTS*/[|case|] 'foo': +// [|break|]; +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /documentHighlightDefaultInSwitch.ts === +// const foo = 'foo'; +// [|switch|] (foo) { +// [|case|] 'foo': +// [|break|]; +// [|default|]: +// /*HIGHLIGHTS*/[|break|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInKeyword.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInKeyword.baseline.jsonc new file mode 100644 index 0000000000..1b627f9ea7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInKeyword.baseline.jsonc @@ -0,0 +1,31 @@ +// === documentHighlights === +// === /documentHighlightInKeyword.ts === +// export type Foo = { +// [K /*HIGHLIGHTS*/in keyof T]: any; +// } +// +// "a" in {}; +// +// for (let a in {}) {} + + + +// === documentHighlights === +// === /documentHighlightInKeyword.ts === +// export type Foo = { +// [K in keyof T]: any; +// } +// +// "a" /*HIGHLIGHTS*/in {}; +// +// for (let a in {}) {} + + + +// === documentHighlights === +// === /documentHighlightInKeyword.ts === +// --- (line: 3) skipped --- +// +// "a" in {}; +// +// for (let a /*HIGHLIGHTS*/in {}) {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightMultilineTemplateStrings.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightMultilineTemplateStrings.baseline.jsonc new file mode 100644 index 0000000000..c8e706c822 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightMultilineTemplateStrings.baseline.jsonc @@ -0,0 +1,7 @@ +// === documentHighlights === +// === /documentHighlightMultilineTemplateStrings.ts === +// const foo = ` +// a +// /*HIGHLIGHTS*/b +// c +// ` \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightVarianceModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightVarianceModifiers.baseline.jsonc new file mode 100644 index 0000000000..3eef4f868a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightVarianceModifiers.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /documentHighlightVarianceModifiers.ts === +// type TFoo = { value: Value }; +// type TBar = TFoo; + + + +// === documentHighlights === +// === /documentHighlightVarianceModifiers.ts === +// type TFoo = { value: Value }; +// type TBar = TFoo; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights01.baseline.jsonc new file mode 100644 index 0000000000..5fbec7f68f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights01.baseline.jsonc @@ -0,0 +1,29 @@ +// === documentHighlights === +// === /a.ts === +// function /*HIGHLIGHTS*/[|f|](x: typeof [|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /a.ts === +// function [|f|](x: typeof /*HIGHLIGHTS*/[|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /a.ts === +// function [|f|](x: typeof [|f|]) { +// /*HIGHLIGHTS*/[|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /a.ts === +// function [|f|](x: typeof [|f|]) { +// [|f|](/*HIGHLIGHTS*/[|f|]); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc new file mode 100644 index 0000000000..694ac0952d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc @@ -0,0 +1,44 @@ +// === documentHighlights === +// === /documentHighlightsInvalidModifierLocations.ts === +// class C { +// m(/*HIGHLIGHTS*/[|readonly|] p) {} +// } +// function f(readonly p) {} +// +// // --- (line: 6) skipped --- + + + +// === documentHighlights === +// === /documentHighlightsInvalidModifierLocations.ts === +// class C { +// m(readonly p) {} +// } +// function f(/*HIGHLIGHTS*/[|readonly|] p) {} +// +// class D { +// m(public p) {} +// } +// function g(public p) {} + + + +// === documentHighlights === +// === /documentHighlightsInvalidModifierLocations.ts === +// --- (line: 3) skipped --- +// function f(readonly p) {} +// +// class D { +// m(/*HIGHLIGHTS*/[|public|] p) {} +// } +// function g(public p) {} + + + +// === documentHighlights === +// === /documentHighlightsInvalidModifierLocations.ts === +// --- (line: 5) skipped --- +// class D { +// m(public p) {} +// } +// function g(/*HIGHLIGHTS*/[|public|] p) {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsTypeParameterInHeritageClause01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsTypeParameterInHeritageClause01.baseline.jsonc new file mode 100644 index 0000000000..d930af83ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsTypeParameterInHeritageClause01.baseline.jsonc @@ -0,0 +1,18 @@ +// === documentHighlights === +// === /documentHighlightsTypeParameterInHeritageClause01.ts === +// interface I extends I<[|T|]>, [|T|] { +// } + + + +// === documentHighlights === +// === /documentHighlightsTypeParameterInHeritageClause01.ts === +// interface I<[|T|]> extends I, [|T|] { +// } + + + +// === documentHighlights === +// === /documentHighlightsTypeParameterInHeritageClause01.ts === +// interface I<[|T|]> extends I<[|T|]>, /*HIGHLIGHTS*/[|T|] { +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_33722.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_33722.baseline.jsonc new file mode 100644 index 0000000000..a789840493 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_33722.baseline.jsonc @@ -0,0 +1,5 @@ +// === documentHighlights === +// === /x.ts === +// import y from "./y"; +// +// y()./*HIGHLIGHTS*/foo(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_filesToSearch.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_filesToSearch.baseline.jsonc new file mode 100644 index 0000000000..e8e985a42a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_filesToSearch.baseline.jsonc @@ -0,0 +1,9 @@ +// === documentHighlights === +// === /a.ts === +// export const /*HIGHLIGHTS*/[|x|] = 0; + + + +// === documentHighlights === +// === /b.ts === +// import { /*HIGHLIGHTS*/[|x|] } from "./a"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc new file mode 100644 index 0000000000..e2ffbc30f3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc @@ -0,0 +1,124 @@ +// === documentHighlights === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// /*HIGHLIGHTS*/[|div|]: any; +// } +// } +// +// const Comp = () => +// <[|div|]> +// Some content +// <[|div|]>More content +// ; +// +// const x = +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 5) skipped --- +// } +// +// const Comp = () => +// [||] +// Some content +//
More content
+// [||]; +// +// const x = +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 7) skipped --- +// const Comp = () => +//
+// Some content +// [||]More content[|
|] +// ; +// +// const x = +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 7) skipped --- +// const Comp = () => +//
+// Some content +// [|
|]More content[||] +//
; +// +// const x = +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 5) skipped --- +// } +// +// const Comp = () => +// [|
|] +// Some content +//
More content
+// [||]; +// +// const x = +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 4) skipped --- +// } +// } +// +// const /*HIGHLIGHTS*/[|Comp|] = () => +//
+// Some content +//
More content
+//
; +// +// const x = <[|Comp|]> +// Content +// ; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 10) skipped --- +//
More content
+//
; +// +// const x = [||] +// Content +// [||]; + + + +// === documentHighlights === +// === /a.tsx === +// --- (line: 10) skipped --- +//
More content
+//
; +// +// const x = [||] +// Content +// [||]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc new file mode 100644 index 0000000000..3d811b7b7a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc @@ -0,0 +1,67 @@ +// === documentHighlights === +// === /getOccurrencesAbstract01.ts === +// /*HIGHLIGHTS*/[|abstract|] class Animal { +// [|abstract|] prop1; // Does not compile +// [|abstract|] abstract(); +// [|abstract|] walk(): void; +// [|abstract|] makeSound(): void; +// } +// // Abstract class below should not get highlighted +// abstract class Foo { +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract01.ts === +// [|abstract|] class Animal { +// /*HIGHLIGHTS*/[|abstract|] prop1; // Does not compile +// [|abstract|] abstract(); +// [|abstract|] walk(): void; +// [|abstract|] makeSound(): void; +// } +// // Abstract class below should not get highlighted +// abstract class Foo { +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract01.ts === +// [|abstract|] class Animal { +// [|abstract|] prop1; // Does not compile +// /*HIGHLIGHTS*/[|abstract|] abstract(); +// [|abstract|] walk(): void; +// [|abstract|] makeSound(): void; +// } +// // Abstract class below should not get highlighted +// abstract class Foo { +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract01.ts === +// [|abstract|] class Animal { +// [|abstract|] prop1; // Does not compile +// [|abstract|] abstract(); +// /*HIGHLIGHTS*/[|abstract|] walk(): void; +// [|abstract|] makeSound(): void; +// } +// // Abstract class below should not get highlighted +// abstract class Foo { +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract01.ts === +// [|abstract|] class Animal { +// [|abstract|] prop1; // Does not compile +// [|abstract|] abstract(); +// [|abstract|] walk(): void; +// /*HIGHLIGHTS*/[|abstract|] makeSound(): void; +// } +// // Abstract class below should not get highlighted +// abstract class Foo { +// // --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc new file mode 100644 index 0000000000..08faaf8825 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc @@ -0,0 +1,48 @@ +// === documentHighlights === +// === /getOccurrencesAbstract02.ts === +// --- (line: 3) skipped --- +// abstract makeSound(): void; +// } +// // abstract cannot appear here, won't get highlighted +// let c = /*HIGHLIGHTS*/abstract class Foo { +// abstract foo(): void; +// abstract bar(): void; +// } + + + +// === documentHighlights === +// === /getOccurrencesAbstract02.ts === +// --- (line: 4) skipped --- +// } +// // abstract cannot appear here, won't get highlighted +// let c = abstract class Foo { +// /*HIGHLIGHTS*/[|abstract|] foo(): void; +// [|abstract|] bar(): void; +// } + + + +// === documentHighlights === +// === /getOccurrencesAbstract02.ts === +// // Not valid TS (abstract methods can only appear in abstract classes) +// class Animal { +// /*HIGHLIGHTS*/[|abstract|] walk(): void; +// [|abstract|] makeSound(): void; +// } +// // abstract cannot appear here, won't get highlighted +// let c = abstract class Foo { +// // --- (line: 8) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract02.ts === +// // Not valid TS (abstract methods can only appear in abstract classes) +// class Animal { +// [|abstract|] walk(): void; +// /*HIGHLIGHTS*/[|abstract|] makeSound(): void; +// } +// // abstract cannot appear here, won't get highlighted +// let c = abstract class Foo { +// // --- (line: 8) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc new file mode 100644 index 0000000000..10c2925c08 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc @@ -0,0 +1,69 @@ +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// function f() { +// /*HIGHLIGHTS*/[|abstract|] class A { +// [|abstract|] m(): void; +// } +// abstract class B {} +// } +// // --- (line: 7) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// function f() { +// [|abstract|] class A { +// /*HIGHLIGHTS*/[|abstract|] m(): void; +// } +// abstract class B {} +// } +// // --- (line: 7) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// --- (line: 5) skipped --- +// } +// switch (0) { +// case 0: +// /*HIGHLIGHTS*/[|abstract|] class A { [|abstract|] m(): void; } +// default: +// abstract class B { abstract m(): void; } +// } + + + +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// --- (line: 5) skipped --- +// } +// switch (0) { +// case 0: +// [|abstract|] class A { /*HIGHLIGHTS*/[|abstract|] m(): void; } +// default: +// abstract class B { abstract m(): void; } +// } + + + +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// --- (line: 7) skipped --- +// case 0: +// abstract class A { abstract m(): void; } +// default: +// /*HIGHLIGHTS*/[|abstract|] class B { [|abstract|] m(): void; } +// } + + + +// === documentHighlights === +// === /getOccurrencesAbstract03.ts === +// --- (line: 7) skipped --- +// case 0: +// abstract class A { abstract m(): void; } +// default: +// [|abstract|] class B { /*HIGHLIGHTS*/[|abstract|] m(): void; } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAfterEdit.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAfterEdit.baseline.jsonc new file mode 100644 index 0000000000..c056b68775 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAfterEdit.baseline.jsonc @@ -0,0 +1,22 @@ +// === documentHighlights === +// === /getOccurrencesAfterEdit.ts === +// +// interface A { +// [|foo|]: string; +// } +// function foo(x: A) { +// x.[|f/*HIGHLIGHTS*/oo|] +// } + + + +// === documentHighlights === +// === /getOccurrencesAfterEdit.ts === +// +// +// interface A { +// [|foo|]: string; +// } +// function foo(x: A) { +// x.[|f/*HIGHLIGHTS*/oo|] +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc new file mode 100644 index 0000000000..4934e838b1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc @@ -0,0 +1,87 @@ +// === documentHighlights === +// === /getOccurrencesAsyncAwait.ts === +// /*HIGHLIGHTS*/[|async|] function f() { +// [|await|] 100; +// [|await|] [|await|] 200; +// class Foo { +// async memberFunction() { +// await 1; +// } +// } +// return [|await|] async function () { +// await 300; +// } +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait.ts === +// [|async|] function f() { +// /*HIGHLIGHTS*/[|await|] 100; +// [|await|] [|await|] 200; +// class Foo { +// async memberFunction() { +// await 1; +// } +// } +// return [|await|] async function () { +// await 300; +// } +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait.ts === +// [|async|] function f() { +// [|await|] 100; +// /*HIGHLIGHTS*/[|await|] [|await|] 200; +// class Foo { +// async memberFunction() { +// await 1; +// } +// } +// return [|await|] async function () { +// await 300; +// } +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait.ts === +// [|async|] function f() { +// [|await|] 100; +// [|await|] /*HIGHLIGHTS*/[|await|] 200; +// class Foo { +// async memberFunction() { +// await 1; +// } +// } +// return [|await|] async function () { +// await 300; +// } +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait.ts === +// [|async|] function f() { +// [|await|] 100; +// [|await|] [|await|] 200; +// class Foo { +// async memberFunction() { +// await 1; +// } +// } +// return /*HIGHLIGHTS*/[|await|] async function () { +// await 300; +// } +// } +// // --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait2.baseline.jsonc new file mode 100644 index 0000000000..308b71fb35 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait2.baseline.jsonc @@ -0,0 +1,57 @@ +// === documentHighlights === +// === /getOccurrencesAsyncAwait2.ts === +// /*HIGHLIGHTS*/[|async|] function f() { +// [|await|] 100; +// [|await|] [|await|] 200; +// return [|await|] async function () { +// await 300; +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait2.ts === +// [|async|] function f() { +// /*HIGHLIGHTS*/[|await|] 100; +// [|await|] [|await|] 200; +// return [|await|] async function () { +// await 300; +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait2.ts === +// [|async|] function f() { +// [|await|] 100; +// /*HIGHLIGHTS*/[|await|] [|await|] 200; +// return [|await|] async function () { +// await 300; +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait2.ts === +// [|async|] function f() { +// [|await|] 100; +// [|await|] /*HIGHLIGHTS*/[|await|] 200; +// return [|await|] async function () { +// await 300; +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesAsyncAwait2.ts === +// [|async|] function f() { +// [|await|] 100; +// [|await|] [|await|] 200; +// return /*HIGHLIGHTS*/[|await|] async function () { +// await 300; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait3.baseline.jsonc new file mode 100644 index 0000000000..f8ae89bc84 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait3.baseline.jsonc @@ -0,0 +1,6 @@ +// === documentHighlights === +// === /getOccurrencesAsyncAwait3.ts === +// a/*HIGHLIGHTS*/wait 100; +// async function f() { +// await 300; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc new file mode 100644 index 0000000000..923a851a0c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc @@ -0,0 +1,82 @@ +// === documentHighlights === +// === /getOccurrencesClassExpressionPrivate.ts === +// let A = class Foo { +// /*HIGHLIGHTS*/[|private|] foo; +// [|private|] private; +// constructor([|private|] y: string, public x: string) { +// } +// [|private|] method() { } +// public method2() { } +// [|private|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPrivate.ts === +// let A = class Foo { +// [|private|] foo; +// /*HIGHLIGHTS*/[|private|] private; +// constructor([|private|] y: string, public x: string) { +// } +// [|private|] method() { } +// public method2() { } +// [|private|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPrivate.ts === +// let A = class Foo { +// [|private|] foo; +// [|private|] private; +// constructor(/*HIGHLIGHTS*/[|private|] y: string, public x: string) { +// } +// [|private|] method() { } +// public method2() { } +// [|private|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPrivate.ts === +// let A = class Foo { +// [|private|] foo; +// [|private|] private; +// constructor([|private|] y: string, public x: string) { +// } +// /*HIGHLIGHTS*/[|private|] method() { } +// public method2() { } +// [|private|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPrivate.ts === +// let A = class Foo { +// [|private|] foo; +// [|private|] private; +// constructor([|private|] y: string, public x: string) { +// } +// [|private|] method() { } +// public method2() { } +// /*HIGHLIGHTS*/[|private|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc new file mode 100644 index 0000000000..44ea7bf572 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc @@ -0,0 +1,82 @@ +// === documentHighlights === +// === /getOccurrencesClassExpressionPublic.ts === +// let A = class Foo { +// /*HIGHLIGHTS*/[|public|] foo; +// [|public|] public; +// constructor([|public|] y: string, private x: string) { +// } +// [|public|] method() { } +// private method2() {} +// [|public|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPublic.ts === +// let A = class Foo { +// [|public|] foo; +// /*HIGHLIGHTS*/[|public|] public; +// constructor([|public|] y: string, private x: string) { +// } +// [|public|] method() { } +// private method2() {} +// [|public|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPublic.ts === +// let A = class Foo { +// [|public|] foo; +// [|public|] public; +// constructor(/*HIGHLIGHTS*/[|public|] y: string, private x: string) { +// } +// [|public|] method() { } +// private method2() {} +// [|public|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPublic.ts === +// let A = class Foo { +// [|public|] foo; +// [|public|] public; +// constructor([|public|] y: string, private x: string) { +// } +// /*HIGHLIGHTS*/[|public|] method() { } +// private method2() {} +// [|public|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionPublic.ts === +// let A = class Foo { +// [|public|] foo; +// [|public|] public; +// constructor([|public|] y: string, private x: string) { +// } +// [|public|] method() { } +// private method2() {} +// /*HIGHLIGHTS*/[|public|] static static() { } +// } +// +// let B = class D { +// // --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc new file mode 100644 index 0000000000..6e552e9a49 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc @@ -0,0 +1,69 @@ +// === documentHighlights === +// === /getOccurrencesClassExpressionStatic.ts === +// let A = class Foo { +// public /*HIGHLIGHTS*/[|static|] foo; +// [|static|] a; +// constructor(public y: string, private x: string) { +// } +// public method() { } +// private method2() {} +// public [|static|] static() { } +// private [|static|] static2() { } +// } +// +// let B = class D { +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStatic.ts === +// let A = class Foo { +// public [|static|] foo; +// /*HIGHLIGHTS*/[|static|] a; +// constructor(public y: string, private x: string) { +// } +// public method() { } +// private method2() {} +// public [|static|] static() { } +// private [|static|] static2() { } +// } +// +// let B = class D { +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStatic.ts === +// let A = class Foo { +// public [|static|] foo; +// [|static|] a; +// constructor(public y: string, private x: string) { +// } +// public method() { } +// private method2() {} +// public /*HIGHLIGHTS*/[|static|] static() { } +// private [|static|] static2() { } +// } +// +// let B = class D { +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStatic.ts === +// let A = class Foo { +// public [|static|] foo; +// [|static|] a; +// constructor(public y: string, private x: string) { +// } +// public method() { } +// private method2() {} +// public [|static|] static() { } +// private /*HIGHLIGHTS*/[|static|] static2() { } +// } +// +// let B = class D { +// // --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc new file mode 100644 index 0000000000..d5d4cce282 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc @@ -0,0 +1,92 @@ +// === documentHighlights === +// === /getOccurrencesClassExpressionStaticThis.ts === +// --- (line: 26) skipped --- +// } +// +// static bar() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|].staticX; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// // --- (line: 39) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStaticThis.ts === +// --- (line: 26) skipped --- +// } +// +// static bar() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|].staticX; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// // --- (line: 39) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStaticThis.ts === +// --- (line: 26) skipped --- +// } +// +// static bar() { +// [|this|]; +// [|this|].staticX; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// // --- (line: 39) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStaticThis.ts === +// --- (line: 26) skipped --- +// } +// +// static bar() { +// [|this|]; +// [|this|].staticX; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// } +// function inside() { +// // --- (line: 39) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionStaticThis.ts === +// --- (line: 26) skipped --- +// } +// +// static bar() { +// [|this|]; +// [|this|].staticX; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// } +// function inside() { +// // --- (line: 39) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc new file mode 100644 index 0000000000..0b18513ac4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc @@ -0,0 +1,303 @@ +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// /*HIGHLIGHTS*/[|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// /*HIGHLIGHTS*/[|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return [|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesClassExpressionThis.ts === +// var x = class C { +// public x; +// public y; +// public z; +// constructor() { +// [|this|]; +// [|this|].x; +// [|this|].y; +// [|this|].z; +// } +// foo() { +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// } +// function inside() { +// this; +// (function (_) { +// this; +// })(this); +// } +// return /*HIGHLIGHTS*/[|this|].x; +// } +// +// static bar() { +// // --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst01.baseline.jsonc new file mode 100644 index 0000000000..57f75d7218 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst01.baseline.jsonc @@ -0,0 +1,19 @@ +// === documentHighlights === +// === /getOccurrencesConst01.ts === +// /*HIGHLIGHTS*/[|const|] enum E1 { +// v1, +// v2 +// } +// +// const c = 0; + + + +// === documentHighlights === +// === /getOccurrencesConst01.ts === +// const enum E1 { +// v1, +// v2 +// } +// +// /*HIGHLIGHTS*/const c = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst04.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst04.baseline.jsonc new file mode 100644 index 0000000000..ef739ce89e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst04.baseline.jsonc @@ -0,0 +1,27 @@ +// === documentHighlights === +// === /getOccurrencesConst04.ts === +// export const class C { +// private static [|c/*HIGHLIGHTS*/onst|] foo; +// constructor(public const foo) { +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesConst04.ts === +// export const class C { +// private static const [|f/*HIGHLIGHTS*/oo|]; +// constructor(public const foo) { +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesConst04.ts === +// export const class C { +// private static [|const|] foo; +// constructor(public con/*HIGHLIGHTS*/st foo) { +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc new file mode 100644 index 0000000000..dcb84d6fb3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc @@ -0,0 +1,66 @@ +// === documentHighlights === +// === /getOccurrencesDeclare1.ts === +// --- (line: 27) skipped --- +// export interface I1 { +// } +// +// export /*HIGHLIGHTS*/[|declare|] module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// // --- (line: 35) skipped --- + +// --- (line: 45) skipped --- +// } +// } +// +// [|declare|] var ambientThing: number; +// export var exportedThing = 10; +// [|declare|] function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesDeclare1.ts === +// --- (line: 27) skipped --- +// export interface I1 { +// } +// +// export [|declare|] module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// // --- (line: 35) skipped --- + +// --- (line: 45) skipped --- +// } +// } +// +// /*HIGHLIGHTS*/[|declare|] var ambientThing: number; +// export var exportedThing = 10; +// [|declare|] function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesDeclare1.ts === +// --- (line: 27) skipped --- +// export interface I1 { +// } +// +// export [|declare|] module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// // --- (line: 35) skipped --- + +// --- (line: 45) skipped --- +// } +// } +// +// [|declare|] var ambientThing: number; +// export var exportedThing = 10; +// /*HIGHLIGHTS*/[|declare|] function foo(): string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc new file mode 100644 index 0000000000..e8aad750bf --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /getOccurrencesDeclare2.ts === +// --- (line: 33) skipped --- +// } +// +// export module mb.m1.m2.m3 { +// /*HIGHLIGHTS*/[|declare|] var foo; +// +// export class C2 { +// public pub1; +// // --- (line: 41) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc new file mode 100644 index 0000000000..fe4b8851c5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc @@ -0,0 +1,73 @@ +// === documentHighlights === +// === /getOccurrencesDeclare3.ts === +// /*HIGHLIGHTS*/[|declare|] var x; +// export [|declare|] var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// [|declare|] export var v1, v2; +// [|declare|] module dm { } +// export class EC { } + + + +// === documentHighlights === +// === /getOccurrencesDeclare3.ts === +// [|declare|] var x; +// export /*HIGHLIGHTS*/[|declare|] var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// [|declare|] export var v1, v2; +// [|declare|] module dm { } +// export class EC { } + + + +// === documentHighlights === +// === /getOccurrencesDeclare3.ts === +// [|declare|] var x; +// export [|declare|] var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// /*HIGHLIGHTS*/[|declare|] export var v1, v2; +// [|declare|] module dm { } +// export class EC { } + + + +// === documentHighlights === +// === /getOccurrencesDeclare3.ts === +// [|declare|] var x; +// export [|declare|] var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// [|declare|] export var v1, v2; +// /*HIGHLIGHTS*/[|declare|] module dm { } +// export class EC { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc new file mode 100644 index 0000000000..bc27b75743 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc @@ -0,0 +1,182 @@ +// === documentHighlights === +// === /getOccurrencesExport1.ts === +// module m { +// /*HIGHLIGHTS*/[|export|] class C1 { +// public pub1; +// public pub2; +// private priv1; +// // --- (line: 6) skipped --- + +// --- (line: 24) skipped --- +// protected static statProt; +// } +// +// [|export|] interface I1 { +// } +// +// [|export|] declare module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// +// [|export|] module mb.m1.m2.m3 { +// declare var foo; +// +// export class C2 { +// // --- (line: 40) skipped --- + +// --- (line: 46) skipped --- +// } +// +// declare var ambientThing: number; +// [|export|] var exportedThing = 10; +// declare function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesExport1.ts === +// module m { +// [|export|] class C1 { +// public pub1; +// public pub2; +// private priv1; +// // --- (line: 6) skipped --- + +// --- (line: 24) skipped --- +// protected static statProt; +// } +// +// /*HIGHLIGHTS*/[|export|] interface I1 { +// } +// +// [|export|] declare module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// +// [|export|] module mb.m1.m2.m3 { +// declare var foo; +// +// export class C2 { +// // --- (line: 40) skipped --- + +// --- (line: 46) skipped --- +// } +// +// declare var ambientThing: number; +// [|export|] var exportedThing = 10; +// declare function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesExport1.ts === +// module m { +// [|export|] class C1 { +// public pub1; +// public pub2; +// private priv1; +// // --- (line: 6) skipped --- + +// --- (line: 24) skipped --- +// protected static statProt; +// } +// +// [|export|] interface I1 { +// } +// +// /*HIGHLIGHTS*/[|export|] declare module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// +// [|export|] module mb.m1.m2.m3 { +// declare var foo; +// +// export class C2 { +// // --- (line: 40) skipped --- + +// --- (line: 46) skipped --- +// } +// +// declare var ambientThing: number; +// [|export|] var exportedThing = 10; +// declare function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesExport1.ts === +// module m { +// [|export|] class C1 { +// public pub1; +// public pub2; +// private priv1; +// // --- (line: 6) skipped --- + +// --- (line: 24) skipped --- +// protected static statProt; +// } +// +// [|export|] interface I1 { +// } +// +// [|export|] declare module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// +// /*HIGHLIGHTS*/[|export|] module mb.m1.m2.m3 { +// declare var foo; +// +// export class C2 { +// // --- (line: 40) skipped --- + +// --- (line: 46) skipped --- +// } +// +// declare var ambientThing: number; +// [|export|] var exportedThing = 10; +// declare function foo(): string; +// } + + + +// === documentHighlights === +// === /getOccurrencesExport1.ts === +// module m { +// [|export|] class C1 { +// public pub1; +// public pub2; +// private priv1; +// // --- (line: 6) skipped --- + +// --- (line: 24) skipped --- +// protected static statProt; +// } +// +// [|export|] interface I1 { +// } +// +// [|export|] declare module ma.m1.m2.m3 { +// interface I2 { +// } +// } +// +// [|export|] module mb.m1.m2.m3 { +// declare var foo; +// +// export class C2 { +// // --- (line: 40) skipped --- + +// --- (line: 46) skipped --- +// } +// +// declare var ambientThing: number; +// /*HIGHLIGHTS*/[|export|] var exportedThing = 10; +// declare function foo(): string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc new file mode 100644 index 0000000000..a870127ec7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /getOccurrencesExport2.ts === +// --- (line: 35) skipped --- +// export module mb.m1.m2.m3 { +// declare var foo; +// +// /*HIGHLIGHTS*/[|export|] class C2 { +// public pub1; +// private priv1; +// protected prot1; +// // --- (line: 43) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc new file mode 100644 index 0000000000..f403d6f737 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc @@ -0,0 +1,54 @@ +// === documentHighlights === +// === /getOccurrencesExport3.ts === +// declare var x; +// /*HIGHLIGHTS*/[|export|] declare var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// declare [|export|] var v1, v2; +// declare module dm { } +// [|export|] class EC { } + + + +// === documentHighlights === +// === /getOccurrencesExport3.ts === +// declare var x; +// [|export|] declare var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// declare /*HIGHLIGHTS*/[|export|] var v1, v2; +// declare module dm { } +// [|export|] class EC { } + + + +// === documentHighlights === +// === /getOccurrencesExport3.ts === +// declare var x; +// [|export|] declare var y, z; +// +// module m { +// export class C1 { +// // --- (line: 6) skipped --- + +// --- (line: 53) skipped --- +// declare function foo(): string; +// } +// +// declare [|export|] var v1, v2; +// declare module dm { } +// /*HIGHLIGHTS*/[|export|] class EC { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc new file mode 100644 index 0000000000..f8dcb8e4ee --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc @@ -0,0 +1,158 @@ +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// /*HIGHLIGHTS*/[|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// [|else|] /* whar garbl */ [|if|] (undefined) { +// } +// [|else|] +// [|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// /*HIGHLIGHTS*/[|else if|] (null) { +// } +// [|else|] /* whar garbl */ [|if|] (undefined) { +// } +// [|else|] +// [|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (undefined) { +// } +// [|else|] +// [|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (undefined) { +// } +// [|else|] +// [|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// [|else|] /* whar garbl */ [|if|] (undefined) { +// } +// /*HIGHLIGHTS*/[|else|] +// [|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// [|else|] /* whar garbl */ [|if|] (undefined) { +// } +// [|else|] +// /*HIGHLIGHTS*/[|if|] (false) { +// } +// [|else|] { } + + + +// === documentHighlights === +// === /getOccurrencesIfElse.ts === +// [|if|] (true) { +// if (false) { +// } +// else { +// // --- (line: 5) skipped --- + +// --- (line: 10) skipped --- +// var x = undefined; +// } +// } +// [|else if|] (null) { +// } +// [|else|] /* whar garbl */ [|if|] (undefined) { +// } +// [|else|] +// [|if|] (false) { +// } +// /*HIGHLIGHTS*/[|else|] { } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc new file mode 100644 index 0000000000..1bfc0a9616 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc @@ -0,0 +1,23 @@ +// === documentHighlights === +// === /getOccurrencesIfElse2.ts === +// if (true) { +// /*HIGHLIGHTS*/[|if|] (false) { +// } +// [|else|]{ +// } +// if (true) { +// } +// // --- (line: 8) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesIfElse2.ts === +// if (true) { +// [|if|] (false) { +// } +// /*HIGHLIGHTS*/[|else|]{ +// } +// if (true) { +// } +// // --- (line: 8) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc new file mode 100644 index 0000000000..b519b05023 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc @@ -0,0 +1,31 @@ +// === documentHighlights === +// === /getOccurrencesIfElse3.ts === +// if (true) { +// if (false) { +// } +// else { +// } +// /*HIGHLIGHTS*/[|if|] (true) { +// } +// [|else|] { +// if (false) +// if (true) +// var x = undefined; +// // --- (line: 12) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesIfElse3.ts === +// if (true) { +// if (false) { +// } +// else { +// } +// [|if|] (true) { +// } +// /*HIGHLIGHTS*/[|else|] { +// if (false) +// if (true) +// var x = undefined; +// // --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc new file mode 100644 index 0000000000..18d8c97660 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc @@ -0,0 +1,130 @@ +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: /*HIGHLIGHTS*/[|for|] (var n in arr) { +// [|break|]; +// [|continue|]; +// [|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// /*HIGHLIGHTS*/[|break|]; +// [|continue|]; +// [|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// [|break|]; +// /*HIGHLIGHTS*/[|continue|]; +// [|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// [|break|]; +// [|continue|]; +// /*HIGHLIGHTS*/[|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// [|break|]; +// [|continue|]; +// [|break|] label1; +// /*HIGHLIGHTS*/[|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// [|break|]; +// [|continue|]; +// [|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// /*HIGHLIGHTS*/[|break|] label1; +// [|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue.ts === +// var arr = [1, 2, 3, 4]; +// label1: [|for|] (var n in arr) { +// [|break|]; +// [|continue|]; +// [|break|] label1; +// [|continue|] label1; +// +// label2: for (var i = 0; i < arr[n]; i++) { +// [|break|] label1; +// /*HIGHLIGHTS*/[|continue|] label1; +// +// break; +// continue; +// // --- (line: 14) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc new file mode 100644 index 0000000000..2449c57254 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc @@ -0,0 +1,102 @@ +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue2.ts === +// --- (line: 4) skipped --- +// break label1; +// continue label1; +// +// label2: /*HIGHLIGHTS*/[|for|] (var i = 0; i < arr[n]; i++) { +// break label1; +// continue label1; +// +// [|break|]; +// [|continue|]; +// [|break|] label2; +// [|continue|] label2; +// +// function foo() { +// label3: while (true) { +// // --- (line: 19) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue2.ts === +// --- (line: 4) skipped --- +// break label1; +// continue label1; +// +// label2: [|for|] (var i = 0; i < arr[n]; i++) { +// break label1; +// continue label1; +// +// /*HIGHLIGHTS*/[|break|]; +// [|continue|]; +// [|break|] label2; +// [|continue|] label2; +// +// function foo() { +// label3: while (true) { +// // --- (line: 19) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue2.ts === +// --- (line: 4) skipped --- +// break label1; +// continue label1; +// +// label2: [|for|] (var i = 0; i < arr[n]; i++) { +// break label1; +// continue label1; +// +// [|break|]; +// /*HIGHLIGHTS*/[|continue|]; +// [|break|] label2; +// [|continue|] label2; +// +// function foo() { +// label3: while (true) { +// // --- (line: 19) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue2.ts === +// --- (line: 4) skipped --- +// break label1; +// continue label1; +// +// label2: [|for|] (var i = 0; i < arr[n]; i++) { +// break label1; +// continue label1; +// +// [|break|]; +// [|continue|]; +// /*HIGHLIGHTS*/[|break|] label2; +// [|continue|] label2; +// +// function foo() { +// label3: while (true) { +// // --- (line: 19) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue2.ts === +// --- (line: 4) skipped --- +// break label1; +// continue label1; +// +// label2: [|for|] (var i = 0; i < arr[n]; i++) { +// break label1; +// continue label1; +// +// [|break|]; +// [|continue|]; +// [|break|] label2; +// /*HIGHLIGHTS*/[|continue|] label2; +// +// function foo() { +// label3: while (true) { +// // --- (line: 19) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc new file mode 100644 index 0000000000..dda8ff0265 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc @@ -0,0 +1,200 @@ +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: /*HIGHLIGHTS*/[|while|] (true) { +// [|break|]; +// [|continue|]; +// [|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// /*HIGHLIGHTS*/[|break|]; +// [|continue|]; +// [|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// [|break|]; +// /*HIGHLIGHTS*/[|continue|]; +// [|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// [|break|]; +// [|continue|]; +// /*HIGHLIGHTS*/[|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// [|break|]; +// [|continue|]; +// [|break|] label3; +// /*HIGHLIGHTS*/[|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// [|break|]; +// [|continue|]; +// [|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// /*HIGHLIGHTS*/[|break|] label3; +// [|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue3.ts === +// --- (line: 14) skipped --- +// continue label2; +// +// function foo() { +// label3: [|while|] (true) { +// [|break|]; +// [|continue|]; +// [|break|] label3; +// [|continue|] label3; +// +// // these cross function boundaries +// break label1; +// // --- (line: 26) skipped --- + +// --- (line: 32) skipped --- +// break label4; +// continue label4; +// +// [|break|] label3; +// /*HIGHLIGHTS*/[|continue|] label3; +// +// switch (10) { +// case 1: +// // --- (line: 41) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc new file mode 100644 index 0000000000..36319f7756 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc @@ -0,0 +1,301 @@ +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: /*HIGHLIGHTS*/[|do|] { +// [|break|]; +// [|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// /*HIGHLIGHTS*/[|break|]; +// [|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// /*HIGHLIGHTS*/[|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// [|continue|]; +// /*HIGHLIGHTS*/[|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// [|continue|]; +// [|break|] label4; +// /*HIGHLIGHTS*/[|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// [|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// /*HIGHLIGHTS*/[|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// [|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// /*HIGHLIGHTS*/[|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } [|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue4.ts === +// --- (line: 26) skipped --- +// break label2; +// continue label2; +// +// label4: [|do|] { +// [|break|]; +// [|continue|]; +// [|break|] label4; +// [|continue|] label4; +// +// break label3; +// continue label3; +// +// switch (10) { +// case 1: +// case 2: +// break; +// [|break|] label4; +// default: +// [|continue|]; +// } +// +// // these cross function boundaries +// break label1; +// continue label1; +// break label2; +// continue label2; +// () => { break; } +// } /*HIGHLIGHTS*/[|while|] (true) +// } +// } +// } +// // --- (line: 58) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue5.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue5.baseline.jsonc new file mode 100644 index 0000000000..41073f8721 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue5.baseline.jsonc @@ -0,0 +1,21 @@ +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue5.ts === +// --- (line: 56) skipped --- +// } +// } +// +// label5: /*HIGHLIGHTS*/[|while|] (true) [|break|] label5; +// +// label7: while (true) continue label5; + + + +// === documentHighlights === +// === /getOccurrencesLoopBreakContinue5.ts === +// --- (line: 56) skipped --- +// } +// } +// +// label5: [|while|] (true) /*HIGHLIGHTS*/[|break|] label5; +// +// label7: while (true) continue label5; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc new file mode 100644 index 0000000000..6bdbd543a4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc @@ -0,0 +1,813 @@ +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// /*HIGHLIGHTS*/[|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// /*HIGHLIGHTS*/[|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// /*HIGHLIGHTS*/[|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export /*HIGHLIGHTS*/[|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// /*HIGHLIGHTS*/[|declare|] export barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare /*HIGHLIGHTS*/[|export|] barfoo; +// +// constructor(export conFoo, +// declare conBar, +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor(/*HIGHLIGHTS*/[|export|] conFoo, +// declare conBar, +// [|export|] declare conFooBar, +// declare [|export|] conBarFoo, +// static sue, +// static [|export|] declare sueFooBar, +// static declare [|export|] sueBarFoo, +// declare static [|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// /*HIGHLIGHTS*/[|declare|] conBar, +// export [|declare|] conFooBar, +// [|declare|] export conBarFoo, +// static sue, +// static export [|declare|] sueFooBar, +// static [|declare|] export sueBarFoo, +// [|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor([|export|] conFoo, +// declare conBar, +// /*HIGHLIGHTS*/[|export|] declare conFooBar, +// declare [|export|] conBarFoo, +// static sue, +// static [|export|] declare sueFooBar, +// static declare [|export|] sueBarFoo, +// declare static [|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// [|declare|] conBar, +// export /*HIGHLIGHTS*/[|declare|] conFooBar, +// [|declare|] export conBarFoo, +// static sue, +// static export [|declare|] sueFooBar, +// static [|declare|] export sueBarFoo, +// [|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// [|declare|] conBar, +// export [|declare|] conFooBar, +// /*HIGHLIGHTS*/[|declare|] export conBarFoo, +// static sue, +// static export [|declare|] sueFooBar, +// static [|declare|] export sueBarFoo, +// [|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor([|export|] conFoo, +// declare conBar, +// [|export|] declare conFooBar, +// declare /*HIGHLIGHTS*/[|export|] conBarFoo, +// static sue, +// static [|export|] declare sueFooBar, +// static declare [|export|] sueBarFoo, +// declare static [|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 7) skipped --- +// declare conBar, +// export declare conFooBar, +// declare export conBarFoo, +// /*HIGHLIGHTS*/[|static|] sue, +// [|static|] export declare sueFooBar, +// [|static|] declare export sueBarFoo, +// declare [|static|] export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 7) skipped --- +// declare conBar, +// export declare conFooBar, +// declare export conBarFoo, +// [|static|] sue, +// /*HIGHLIGHTS*/[|static|] export declare sueFooBar, +// [|static|] declare export sueBarFoo, +// declare [|static|] export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor([|export|] conFoo, +// declare conBar, +// [|export|] declare conFooBar, +// declare [|export|] conBarFoo, +// static sue, +// static /*HIGHLIGHTS*/[|export|] declare sueFooBar, +// static declare [|export|] sueBarFoo, +// declare static [|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// [|declare|] conBar, +// export [|declare|] conFooBar, +// [|declare|] export conBarFoo, +// static sue, +// static export /*HIGHLIGHTS*/[|declare|] sueFooBar, +// static [|declare|] export sueBarFoo, +// [|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 7) skipped --- +// declare conBar, +// export declare conFooBar, +// declare export conBarFoo, +// [|static|] sue, +// [|static|] export declare sueFooBar, +// /*HIGHLIGHTS*/[|static|] declare export sueBarFoo, +// declare [|static|] export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// [|declare|] conBar, +// export [|declare|] conFooBar, +// [|declare|] export conBarFoo, +// static sue, +// static export [|declare|] sueFooBar, +// static /*HIGHLIGHTS*/[|declare|] export sueBarFoo, +// [|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor([|export|] conFoo, +// declare conBar, +// [|export|] declare conFooBar, +// declare [|export|] conBarFoo, +// static sue, +// static [|export|] declare sueFooBar, +// static declare /*HIGHLIGHTS*/[|export|] sueBarFoo, +// declare static [|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// export foo; +// [|declare|] bar; +// export [|declare|] foobar; +// [|declare|] export barfoo; +// +// constructor(export conFoo, +// [|declare|] conBar, +// export [|declare|] conFooBar, +// [|declare|] export conBarFoo, +// static sue, +// static export [|declare|] sueFooBar, +// static [|declare|] export sueBarFoo, +// /*HIGHLIGHTS*/[|declare|] static export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 7) skipped --- +// declare conBar, +// export declare conFooBar, +// declare export conBarFoo, +// [|static|] sue, +// [|static|] export declare sueFooBar, +// [|static|] declare export sueBarFoo, +// declare /*HIGHLIGHTS*/[|static|] export barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// class C { +// [|export|] foo; +// declare bar; +// [|export|] declare foobar; +// declare [|export|] barfoo; +// +// constructor([|export|] conFoo, +// declare conBar, +// [|export|] declare conFooBar, +// declare [|export|] conBarFoo, +// static sue, +// static [|export|] declare sueFooBar, +// static declare [|export|] sueBarFoo, +// declare static /*HIGHLIGHTS*/[|export|] barSueFoo) { +// } +// } +// +// // --- (line: 18) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 15) skipped --- +// } +// +// module m { +// /*HIGHLIGHTS*/static a; +// public b; +// private c; +// protected d; +// // --- (line: 23) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 16) skipped --- +// +// module m { +// static a; +// /*HIGHLIGHTS*/public b; +// private c; +// protected d; +// static public private protected e; +// // --- (line: 24) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 17) skipped --- +// module m { +// static a; +// public b; +// /*HIGHLIGHTS*/private c; +// protected d; +// static public private protected e; +// public static protected private f; +// // --- (line: 25) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 18) skipped --- +// static a; +// public b; +// private c; +// /*HIGHLIGHTS*/protected d; +// static public private protected e; +// public static protected private f; +// protected static public g; +// // --- (line: 26) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 19) skipped --- +// public b; +// private c; +// protected d; +// /*HIGHLIGHTS*/static public private protected e; +// public static protected private f; +// protected static public g; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 19) skipped --- +// public b; +// private c; +// protected d; +// static /*HIGHLIGHTS*/public private protected e; +// public static protected private f; +// protected static public g; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 19) skipped --- +// public b; +// private c; +// protected d; +// static public /*HIGHLIGHTS*/private protected e; +// public static protected private f; +// protected static public g; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 19) skipped --- +// public b; +// private c; +// protected d; +// static public private /*HIGHLIGHTS*/protected e; +// public static protected private f; +// protected static public g; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 20) skipped --- +// private c; +// protected d; +// static public private protected e; +// /*HIGHLIGHTS*/public static protected private f; +// protected static public g; +// } +// static a; +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 20) skipped --- +// private c; +// protected d; +// static public private protected e; +// public /*HIGHLIGHTS*/static protected private f; +// protected static public g; +// } +// static a; +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 20) skipped --- +// private c; +// protected d; +// static public private protected e; +// public static /*HIGHLIGHTS*/protected private f; +// protected static public g; +// } +// static a; +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 20) skipped --- +// private c; +// protected d; +// static public private protected e; +// public static protected /*HIGHLIGHTS*/private f; +// protected static public g; +// } +// static a; +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 21) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// /*HIGHLIGHTS*/protected static public g; +// } +// static a; +// public b; +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 21) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// protected /*HIGHLIGHTS*/static public g; +// } +// static a; +// public b; +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 21) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// protected static /*HIGHLIGHTS*/public g; +// } +// static a; +// public b; +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 23) skipped --- +// public static protected private f; +// protected static public g; +// } +// /*HIGHLIGHTS*/static a; +// public b; +// private c; +// protected d; +// // --- (line: 31) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 24) skipped --- +// protected static public g; +// } +// static a; +// /*HIGHLIGHTS*/public b; +// private c; +// protected d; +// static public private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 25) skipped --- +// } +// static a; +// public b; +// /*HIGHLIGHTS*/private c; +// protected d; +// static public private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 26) skipped --- +// static a; +// public b; +// private c; +// /*HIGHLIGHTS*/protected d; +// static public private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 27) skipped --- +// public b; +// private c; +// protected d; +// /*HIGHLIGHTS*/static public private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 27) skipped --- +// public b; +// private c; +// protected d; +// static /*HIGHLIGHTS*/public private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 27) skipped --- +// public b; +// private c; +// protected d; +// static public /*HIGHLIGHTS*/private protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 27) skipped --- +// public b; +// private c; +// protected d; +// static public private /*HIGHLIGHTS*/protected e; +// public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 28) skipped --- +// private c; +// protected d; +// static public private protected e; +// /*HIGHLIGHTS*/public static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 28) skipped --- +// private c; +// protected d; +// static public private protected e; +// public /*HIGHLIGHTS*/static protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 28) skipped --- +// private c; +// protected d; +// static public private protected e; +// public static /*HIGHLIGHTS*/protected private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 28) skipped --- +// private c; +// protected d; +// static public private protected e; +// public static protected /*HIGHLIGHTS*/private f; +// protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 29) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// /*HIGHLIGHTS*/protected static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 29) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// protected /*HIGHLIGHTS*/static public g; + + + +// === documentHighlights === +// === /getOccurrencesModifiersNegatives1.ts === +// --- (line: 29) skipped --- +// protected d; +// static public private protected e; +// public static protected private f; +// protected static /*HIGHLIGHTS*/public g; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAssertion.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAssertion.baseline.jsonc new file mode 100644 index 0000000000..8f74025002 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAssertion.baseline.jsonc @@ -0,0 +1,4 @@ +// === documentHighlights === +// === /getOccurrencesNonStringImportAssertion.ts === +// import * as react from "react" assert { cache: /*HIGHLIGHTS*/0 }; +// react.Children; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAttributes.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAttributes.baseline.jsonc new file mode 100644 index 0000000000..495cc04088 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAttributes.baseline.jsonc @@ -0,0 +1,4 @@ +// === documentHighlights === +// === /getOccurrencesNonStringImportAttributes.ts === +// import * as react from "react" with { cache: /*HIGHLIGHTS*/0 }; +// react.Children; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfAnonymousFunction2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfAnonymousFunction2.baseline.jsonc new file mode 100644 index 0000000000..9a267b1549 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfAnonymousFunction2.baseline.jsonc @@ -0,0 +1,25 @@ +// === documentHighlights === +// === /getOccurrencesOfAnonymousFunction2.ts === +// //global foo definition +// function foo() {} +// +// (function [|f/*HIGHLIGHTS*/oo|](): number { +// return [|foo|](); // local foo reference +// }) +// //global foo references +// foo(); +// var f = foo; + + + +// === documentHighlights === +// === /getOccurrencesOfAnonymousFunction2.ts === +// //global foo definition +// function [|foo|]() {} +// +// (function foo(): number { +// return foo(); // local foo reference +// }) +// //global foo references +// [|fo/*HIGHLIGHTS*/o|](); +// var f = [|foo|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfDecorators.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfDecorators.baseline.jsonc new file mode 100644 index 0000000000..39f4a722e1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfDecorators.baseline.jsonc @@ -0,0 +1,10 @@ +// === documentHighlights === +// === /b.ts === +// @/*HIGHLIGHTS*/[|decorator|] +// class C { +// @[|decorator|] +// method() {} +// } +// function [|decorator|](target) { +// return target; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfUndefinedSymbol.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfUndefinedSymbol.baseline.jsonc new file mode 100644 index 0000000000..046ff4e22a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfUndefinedSymbol.baseline.jsonc @@ -0,0 +1,9 @@ +// === documentHighlights === +// === /getOccurrencesOfUndefinedSymbol.ts === +// --- (line: 7) skipped --- +// +// class cls3 { +// property zeFunc() { +// super.ceFun/*HIGHLIGHTS*/c(); +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc new file mode 100644 index 0000000000..3617a1c9ba --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc @@ -0,0 +1,195 @@ +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// /*HIGHLIGHTS*/[|private|] priv1; +// [|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// [|private|] private; +// protected protected; +// +// public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// [|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// [|private|] priv1; +// /*HIGHLIGHTS*/[|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// [|private|] private; +// protected protected; +// +// public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// [|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// [|private|] priv1; +// [|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// /*HIGHLIGHTS*/[|private|] private; +// protected protected; +// +// public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// [|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// [|private|] priv1; +// [|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// [|private|] private; +// protected protected; +// +// public constructor(public a, /*HIGHLIGHTS*/[|private|] b, protected c, public d, [|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// [|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// [|private|] priv1; +// [|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// [|private|] private; +// protected protected; +// +// public constructor(public a, [|private|] b, protected c, public d, /*HIGHLIGHTS*/[|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// [|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate1.ts === +// module m { +// export class C1 { +// public pub1; +// public pub2; +// [|private|] priv1; +// [|private|] priv2; +// protected prot1; +// protected prot2; +// +// public public; +// [|private|] private; +// protected protected; +// +// public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// public get x() { return 10; } +// public set x(value) { } +// +// public static statPub; +// /*HIGHLIGHTS*/[|private|] static statPriv; +// protected static statProt; +// } +// +// // --- (line: 28) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc new file mode 100644 index 0000000000..f60965a862 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc @@ -0,0 +1,31 @@ +// === documentHighlights === +// === /getOccurrencesPrivate2.ts === +// --- (line: 37) skipped --- +// +// export class C2 { +// public pub1; +// /*HIGHLIGHTS*/[|private|] priv1; +// protected prot1; +// +// protected constructor(public public, protected protected, [|private|] private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPrivate2.ts === +// --- (line: 37) skipped --- +// +// export class C2 { +// public pub1; +// [|private|] priv1; +// protected prot1; +// +// protected constructor(public public, protected protected, /*HIGHLIGHTS*/[|private|] private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPropertyInAliasedInterface.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPropertyInAliasedInterface.baseline.jsonc new file mode 100644 index 0000000000..d0cba623f7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPropertyInAliasedInterface.baseline.jsonc @@ -0,0 +1,85 @@ +// === documentHighlights === +// === /getOccurrencesPropertyInAliasedInterface.ts === +// module m { +// export interface Foo { +// /*HIGHLIGHTS*/[|abc|] +// } +// } +// +// import Bar = m.Foo; +// +// export interface I extends Bar { +// [|abc|] +// } +// +// class C implements Bar { +// [|abc|] +// } +// +// (new C()).[|abc|]; + + + +// === documentHighlights === +// === /getOccurrencesPropertyInAliasedInterface.ts === +// module m { +// export interface Foo { +// [|abc|] +// } +// } +// +// import Bar = m.Foo; +// +// export interface I extends Bar { +// /*HIGHLIGHTS*/[|abc|] +// } +// +// class C implements Bar { +// [|abc|] +// } +// +// (new C()).[|abc|]; + + + +// === documentHighlights === +// === /getOccurrencesPropertyInAliasedInterface.ts === +// module m { +// export interface Foo { +// [|abc|] +// } +// } +// +// import Bar = m.Foo; +// +// export interface I extends Bar { +// [|abc|] +// } +// +// class C implements Bar { +// /*HIGHLIGHTS*/[|abc|] +// } +// +// (new C()).[|abc|]; + + + +// === documentHighlights === +// === /getOccurrencesPropertyInAliasedInterface.ts === +// module m { +// export interface Foo { +// [|abc|] +// } +// } +// +// import Bar = m.Foo; +// +// export interface I extends Bar { +// [|abc|] +// } +// +// class C implements Bar { +// [|abc|] +// } +// +// (new C())./*HIGHLIGHTS*/[|abc|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc new file mode 100644 index 0000000000..8490faf1d0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc @@ -0,0 +1,183 @@ +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// /*HIGHLIGHTS*/[|protected|] prot1; +// [|protected|] prot2; +// +// public public; +// private private; +// [|protected|] protected; +// +// public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// [|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// [|protected|] prot1; +// /*HIGHLIGHTS*/[|protected|] prot2; +// +// public public; +// private private; +// [|protected|] protected; +// +// public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// [|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// [|protected|] prot1; +// [|protected|] prot2; +// +// public public; +// private private; +// /*HIGHLIGHTS*/[|protected|] protected; +// +// public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// [|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// [|protected|] prot1; +// [|protected|] prot2; +// +// public public; +// private private; +// [|protected|] protected; +// +// public constructor(public a, private b, /*HIGHLIGHTS*/[|protected|] c, public d, private e, [|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// [|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// [|protected|] prot1; +// [|protected|] prot2; +// +// public public; +// private private; +// [|protected|] protected; +// +// public constructor(public a, private b, [|protected|] c, public d, private e, /*HIGHLIGHTS*/[|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// [|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected1.ts === +// --- (line: 3) skipped --- +// public pub2; +// private priv1; +// private priv2; +// [|protected|] prot1; +// [|protected|] prot2; +// +// public public; +// private private; +// [|protected|] protected; +// +// public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// // --- (line: 18) skipped --- + +// --- (line: 21) skipped --- +// +// public static statPub; +// private static statPriv; +// /*HIGHLIGHTS*/[|protected|] static statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc new file mode 100644 index 0000000000..70dd56fa8a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc @@ -0,0 +1,45 @@ +// === documentHighlights === +// === /getOccurrencesProtected2.ts === +// --- (line: 38) skipped --- +// export class C2 { +// public pub1; +// private priv1; +// /*HIGHLIGHTS*/[|protected|] prot1; +// +// [|protected|] constructor(public public, [|protected|] protected, private private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected2.ts === +// --- (line: 38) skipped --- +// export class C2 { +// public pub1; +// private priv1; +// [|protected|] prot1; +// +// /*HIGHLIGHTS*/[|protected|] constructor(public public, [|protected|] protected, private private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesProtected2.ts === +// --- (line: 38) skipped --- +// export class C2 { +// public pub1; +// private priv1; +// [|protected|] prot1; +// +// [|protected|] constructor(public public, /*HIGHLIGHTS*/[|protected|] protected, private private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc new file mode 100644 index 0000000000..f0245158d1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc @@ -0,0 +1,285 @@ +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// /*HIGHLIGHTS*/[|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// /*HIGHLIGHTS*/[|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// /*HIGHLIGHTS*/[|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// /*HIGHLIGHTS*/[|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor(/*HIGHLIGHTS*/[|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, /*HIGHLIGHTS*/[|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// /*HIGHLIGHTS*/[|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// /*HIGHLIGHTS*/[|public|] set x(value) { } +// +// [|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic1.ts === +// module m { +// export class C1 { +// [|public|] pub1; +// [|public|] pub2; +// private priv1; +// private priv2; +// protected prot1; +// protected prot2; +// +// [|public|] public; +// private private; +// protected protected; +// +// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) { +// this.public = 10; +// this.private = 10; +// this.protected = 10; +// } +// +// [|public|] get x() { return 10; } +// [|public|] set x(value) { } +// +// /*HIGHLIGHTS*/[|public|] static statPub; +// private static statPriv; +// protected static statProt; +// } +// // --- (line: 27) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc new file mode 100644 index 0000000000..368425ff54 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc @@ -0,0 +1,33 @@ +// === documentHighlights === +// === /getOccurrencesPublic2.ts === +// --- (line: 36) skipped --- +// declare var foo; +// +// export class C2 { +// /*HIGHLIGHTS*/[|public|] pub1; +// private priv1; +// protected prot1; +// +// protected constructor([|public|] public, protected protected, private private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesPublic2.ts === +// --- (line: 36) skipped --- +// declare var foo; +// +// export class C2 { +// [|public|] pub1; +// private priv1; +// protected prot1; +// +// protected constructor(/*HIGHLIGHTS*/[|public|] public, protected protected, private private) { +// public = private = protected; +// } +// } +// // --- (line: 48) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly1.baseline.jsonc new file mode 100644 index 0000000000..55af9fc7a9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly1.baseline.jsonc @@ -0,0 +1,5 @@ +// === documentHighlights === +// === /getOccurrencesReadonly1.ts === +// interface I { +// /*HIGHLIGHTS*/[|readonly|] prop: string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly2.baseline.jsonc new file mode 100644 index 0000000000..e627f6211b --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly2.baseline.jsonc @@ -0,0 +1,5 @@ +// === documentHighlights === +// === /getOccurrencesReadonly2.ts === +// type T = { +// /*HIGHLIGHTS*/[|readonly|] prop: string; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc new file mode 100644 index 0000000000..aa353f0e86 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc @@ -0,0 +1,34 @@ +// === documentHighlights === +// === /getOccurrencesReadonly3.ts === +// class C { +// /*HIGHLIGHTS*/[|readonly|] prop: readonly string[] = []; +// constructor([|readonly|] prop2: string) { +// class D { +// readonly prop: string = ""; +// } +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesReadonly3.ts === +// class C { +// [|readonly|] prop: readonly string[] = []; +// constructor(/*HIGHLIGHTS*/[|readonly|] prop2: string) { +// class D { +// readonly prop: string = ""; +// } +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesReadonly3.ts === +// class C { +// readonly prop: /*HIGHLIGHTS*/[|readonly|] string[] = []; +// constructor(readonly prop2: string) { +// class D { +// readonly prop: string = ""; +// // --- (line: 6) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc new file mode 100644 index 0000000000..e1e04ea209 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc @@ -0,0 +1,57 @@ +// === documentHighlights === +// === /getOccurrencesReturn.ts === +// function f(a: number) { +// if (a > 0) { +// /*HIGHLIGHTS*/[|return|] (function () { +// return; +// return; +// return; +// // --- (line: 7) skipped --- + +// --- (line: 12) skipped --- +// +// var unusued = [1, 2, 3, 4].map(x => { return 4 }) +// +// [|return|]; +// [|return|] true; +// } + + + +// === documentHighlights === +// === /getOccurrencesReturn.ts === +// function f(a: number) { +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 7) skipped --- + +// --- (line: 12) skipped --- +// +// var unusued = [1, 2, 3, 4].map(x => { return 4 }) +// +// /*HIGHLIGHTS*/[|return|]; +// [|return|] true; +// } + + + +// === documentHighlights === +// === /getOccurrencesReturn.ts === +// function f(a: number) { +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 7) skipped --- + +// --- (line: 12) skipped --- +// +// var unusued = [1, 2, 3, 4].map(x => { return 4 }) +// +// [|return|]; +// /*HIGHLIGHTS*/[|return|] true; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc new file mode 100644 index 0000000000..6a7fa7bfdd --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc @@ -0,0 +1,69 @@ +// === documentHighlights === +// === /getOccurrencesReturn2.ts === +// function f(a: number) { +// if (a > 0) { +// return (function () { +// /*HIGHLIGHTS*/[|return|]; +// [|return|]; +// [|return|]; +// +// while (false) { +// [|return|] true; +// } +// })() || true; +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesReturn2.ts === +// function f(a: number) { +// if (a > 0) { +// return (function () { +// [|return|]; +// /*HIGHLIGHTS*/[|return|]; +// [|return|]; +// +// while (false) { +// [|return|] true; +// } +// })() || true; +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesReturn2.ts === +// function f(a: number) { +// if (a > 0) { +// return (function () { +// [|return|]; +// [|return|]; +// /*HIGHLIGHTS*/[|return|]; +// +// while (false) { +// [|return|] true; +// } +// })() || true; +// } +// // --- (line: 13) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesReturn2.ts === +// function f(a: number) { +// if (a > 0) { +// return (function () { +// [|return|]; +// [|return|]; +// [|return|]; +// +// while (false) { +// /*HIGHLIGHTS*/[|return|] true; +// } +// })() || true; +// } +// // --- (line: 13) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn3.baseline.jsonc new file mode 100644 index 0000000000..c7c2ed6336 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn3.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /getOccurrencesReturn3.ts === +// --- (line: 10) skipped --- +// })() || true; +// } +// +// var unusued = [1, 2, 3, 4].map(x => { /*HIGHLIGHTS*/[|return|] 4 }) +// +// return; +// return true; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc new file mode 100644 index 0000000000..f8e611291b --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc @@ -0,0 +1,25 @@ +// === documentHighlights === +// === /getOccurrencesSetAndGet.ts === +// class Foo { +// /*HIGHLIGHTS*/[|set|] bar(b: any) { +// } +// +// public [|get|] bar(): any { +// return undefined; +// } +// +// // --- (line: 9) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSetAndGet.ts === +// class Foo { +// [|set|] bar(b: any) { +// } +// +// public /*HIGHLIGHTS*/[|get|] bar(): any { +// return undefined; +// } +// +// // --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc new file mode 100644 index 0000000000..99684a437f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc @@ -0,0 +1,31 @@ +// === documentHighlights === +// === /getOccurrencesSetAndGet2.ts === +// --- (line: 5) skipped --- +// return undefined; +// } +// +// public /*HIGHLIGHTS*/[|set|] set(s: any) { +// } +// +// public [|get|] set(): any { +// return undefined; +// } +// +// // --- (line: 16) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSetAndGet2.ts === +// --- (line: 5) skipped --- +// return undefined; +// } +// +// public [|set|] set(s: any) { +// } +// +// public /*HIGHLIGHTS*/[|get|] set(): any { +// return undefined; +// } +// +// // --- (line: 16) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet3.baseline.jsonc new file mode 100644 index 0000000000..c6fd4fe2b8 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet3.baseline.jsonc @@ -0,0 +1,29 @@ +// === documentHighlights === +// === /getOccurrencesSetAndGet3.ts === +// --- (line: 12) skipped --- +// return undefined; +// } +// +// public /*HIGHLIGHTS*/[|set|] get(g: any) { +// } +// +// public [|get|] get(): any { +// return undefined; +// } +// } + + + +// === documentHighlights === +// === /getOccurrencesSetAndGet3.ts === +// --- (line: 12) skipped --- +// return undefined; +// } +// +// public [|set|] get(g: any) { +// } +// +// public /*HIGHLIGHTS*/[|get|] get(): any { +// return undefined; +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc new file mode 100644 index 0000000000..669bccd3c2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc @@ -0,0 +1,45 @@ +// === documentHighlights === +// === /getOccurrencesStatic1.ts === +// --- (line: 19) skipped --- +// public get x() { return 10; } +// public set x(value) { } +// +// public /*HIGHLIGHTS*/[|static|] statPub; +// private [|static|] statPriv; +// protected [|static|] statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesStatic1.ts === +// --- (line: 19) skipped --- +// public get x() { return 10; } +// public set x(value) { } +// +// public [|static|] statPub; +// private /*HIGHLIGHTS*/[|static|] statPriv; +// protected [|static|] statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesStatic1.ts === +// --- (line: 19) skipped --- +// public get x() { return 10; } +// public set x(value) { } +// +// public [|static|] statPub; +// private [|static|] statPriv; +// protected /*HIGHLIGHTS*/[|static|] statProt; +// } +// +// export interface I1 { +// // --- (line: 29) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc new file mode 100644 index 0000000000..a89f8f9810 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc @@ -0,0 +1,235 @@ +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = /*HIGHLIGHTS*/[|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = /*HIGHLIGHTS*/[|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// /*HIGHLIGHTS*/[|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return /*HIGHLIGHTS*/[|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return /*HIGHLIGHTS*/[|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => /*HIGHLIGHTS*/[|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// [|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper.ts === +// --- (line: 7) skipped --- +// } +// +// class SubType extends SuperType { +// public prop1 = [|super|].superMethod; +// private prop2 = [|super|].superMethod; +// +// constructor() { +// [|super|](); +// } +// +// public method1() { +// return [|super|].superMethod(); +// } +// +// private method2() { +// return [|super|].superMethod(); +// } +// +// public method3() { +// var x = () => [|super|].superMethod(); +// +// // Bad but still gets highlighted +// function f() { +// /*HIGHLIGHTS*/[|super|].superMethod(); +// } +// } +// +// // --- (line: 35) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc new file mode 100644 index 0000000000..199a3e90e5 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc @@ -0,0 +1,60 @@ +// === documentHighlights === +// === /getOccurrencesSuper2.ts === +// --- (line: 32) skipped --- +// } +// +// // Bad but still gets highlighted. +// public static statProp1 = /*HIGHLIGHTS*/[|super|].superStaticMethod; +// +// public static staticMethod1() { +// return [|super|].superStaticMethod(); +// } +// +// private static staticMethod2() { +// return [|super|].superStaticMethod(); +// } +// +// // Are not actually 'super' keywords. +// // --- (line: 47) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper2.ts === +// --- (line: 32) skipped --- +// } +// +// // Bad but still gets highlighted. +// public static statProp1 = [|super|].superStaticMethod; +// +// public static staticMethod1() { +// return /*HIGHLIGHTS*/[|super|].superStaticMethod(); +// } +// +// private static staticMethod2() { +// return [|super|].superStaticMethod(); +// } +// +// // Are not actually 'super' keywords. +// // --- (line: 47) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper2.ts === +// --- (line: 32) skipped --- +// } +// +// // Bad but still gets highlighted. +// public static statProp1 = [|super|].superStaticMethod; +// +// public static staticMethod1() { +// return [|super|].superStaticMethod(); +// } +// +// private static staticMethod2() { +// return /*HIGHLIGHTS*/[|super|].superStaticMethod(); +// } +// +// // Are not actually 'super' keywords. +// // --- (line: 47) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc new file mode 100644 index 0000000000..527a1d8087 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc @@ -0,0 +1,51 @@ +// === documentHighlights === +// === /getOccurrencesSuper3.ts === +// let x = { +// a() { +// return /*HIGHLIGHTS*/[|super|].b(); +// }, +// b() { +// return [|super|].a(); +// }, +// c: function () { +// return super.a(); +// // --- (line: 10) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper3.ts === +// let x = { +// a() { +// return [|super|].b(); +// }, +// b() { +// return /*HIGHLIGHTS*/[|super|].a(); +// }, +// c: function () { +// return super.a(); +// // --- (line: 10) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuper3.ts === +// --- (line: 5) skipped --- +// return super.a(); +// }, +// c: function () { +// return /*HIGHLIGHTS*/super.a(); +// } +// d: () => super.b(); +// } + + + +// === documentHighlights === +// === /getOccurrencesSuper3.ts === +// --- (line: 7) skipped --- +// c: function () { +// return super.a(); +// } +// d: () => /*HIGHLIGHTS*/super.b(); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc new file mode 100644 index 0000000000..c1812ce56f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc @@ -0,0 +1,61 @@ +// === documentHighlights === +// === /getOccurrencesSuperNegatives.ts === +// function f(x = /*HIGHLIGHTS*/super) { +// super; +// } +// +// // --- (line: 5) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuperNegatives.ts === +// function f(x = super) { +// /*HIGHLIGHTS*/super; +// } +// +// module M { +// // --- (line: 6) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuperNegatives.ts === +// function f(x = super) { +// super; +// } +// +// module M { +// /*HIGHLIGHTS*/super; +// function f(x = super) { +// super; +// } +// // --- (line: 10) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuperNegatives.ts === +// --- (line: 3) skipped --- +// +// module M { +// super; +// function f(x = /*HIGHLIGHTS*/super) { +// super; +// } +// +// // --- (line: 11) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSuperNegatives.ts === +// --- (line: 4) skipped --- +// module M { +// super; +// function f(x = super) { +// /*HIGHLIGHTS*/super; +// } +// +// class A { +// // --- (line: 12) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault.baseline.jsonc new file mode 100644 index 0000000000..d71e3b477f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault.baseline.jsonc @@ -0,0 +1,195 @@ +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// /*HIGHLIGHTS*/[|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// /*HIGHLIGHTS*/[|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// /*HIGHLIGHTS*/[|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// /*HIGHLIGHTS*/[|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// /*HIGHLIGHTS*/[|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// /*HIGHLIGHTS*/[|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// /*HIGHLIGHTS*/[|default|]: +// [|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// /*HIGHLIGHTS*/[|break|]; +// [|case|] 16: +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault.ts === +// [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 4: +// [|case|] 8: +// foo: switch (20) { +// case 1: +// case 2: +// break; +// default: +// break foo; +// } +// [|case|] 0xBEEF: +// [|default|]: +// [|break|]; +// /*HIGHLIGHTS*/[|case|] 16: +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc new file mode 100644 index 0000000000..2f45fd199e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc @@ -0,0 +1,117 @@ +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: /*HIGHLIGHTS*/[|switch|] (20) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|default|]: +// [|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: [|switch|] (20) { +// /*HIGHLIGHTS*/[|case|] 1: +// [|case|] 2: +// [|break|]; +// [|default|]: +// [|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: [|switch|] (20) { +// [|case|] 1: +// /*HIGHLIGHTS*/[|case|] 2: +// [|break|]; +// [|default|]: +// [|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: [|switch|] (20) { +// [|case|] 1: +// [|case|] 2: +// /*HIGHLIGHTS*/[|break|]; +// [|default|]: +// [|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: [|switch|] (20) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// /*HIGHLIGHTS*/[|default|]: +// [|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault2.ts === +// switch (10) { +// case 1: +// case 2: +// case 4: +// case 8: +// foo: [|switch|] (20) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|default|]: +// /*HIGHLIGHTS*/[|break|] foo; +// } +// case 0xBEEF: +// default: +// // --- (line: 15) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault3.baseline.jsonc new file mode 100644 index 0000000000..43f829ea61 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault3.baseline.jsonc @@ -0,0 +1,157 @@ +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: /*HIGHLIGHTS*/[|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// /*HIGHLIGHTS*/[|case|] 1: +// [|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// /*HIGHLIGHTS*/[|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// /*HIGHLIGHTS*/[|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// /*HIGHLIGHTS*/[|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// /*HIGHLIGHTS*/[|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// /*HIGHLIGHTS*/[|default|]: +// [|break|]; +// } + + + +// === documentHighlights === +// === /getOccurrencesSwitchCaseDefault3.ts === +// foo: [|switch|] (1) { +// [|case|] 1: +// [|case|] 2: +// [|break|]; +// [|case|] 3: +// switch (2) { +// case 1: +// [|break|] foo; +// continue; // invalid +// default: +// break; +// } +// [|default|]: +// /*HIGHLIGHTS*/[|break|]; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc new file mode 100644 index 0000000000..2418ead776 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc @@ -0,0 +1,19 @@ +// === documentHighlights === +// === /getOccurrencesThis.ts === +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// +// function f() { +// this; +// // --- (line: 6) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis.ts === +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// +// function f() { +// this; +// // --- (line: 6) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc new file mode 100644 index 0000000000..76d9c05eb4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc @@ -0,0 +1,129 @@ +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// [|this|]; +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis2.ts === +// this; +// this; +// +// function f() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// /*HIGHLIGHTS*/[|this|].this; +// } +// } +// function inside() { +// // --- (line: 17) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc new file mode 100644 index 0000000000..8beeaf0051 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc @@ -0,0 +1,31 @@ +// === documentHighlights === +// === /getOccurrencesThis3.ts === +// --- (line: 13) skipped --- +// } +// } +// function inside() { +// /*HIGHLIGHTS*/[|this|]; +// (function (_) { +// this; +// })([|this|]); +// } +// } +// +// // --- (line: 24) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis3.ts === +// --- (line: 13) skipped --- +// } +// } +// function inside() { +// [|this|]; +// (function (_) { +// this; +// })(/*HIGHLIGHTS*/[|this|]); +// } +// } +// +// // --- (line: 24) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc new file mode 100644 index 0000000000..71a4333334 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc @@ -0,0 +1,556 @@ +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = /*HIGHLIGHTS*/[|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// /*HIGHLIGHTS*/[|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis4.ts === +// --- (line: 43) skipped --- +// } +// +// class A { +// public b = [|this|].method1; +// +// public method1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 62) skipped --- + +// --- (line: 66) skipped --- +// } +// +// private method2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// /*HIGHLIGHTS*/[|this|].this; +// } +// } +// function inside() { +// // --- (line: 82) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc new file mode 100644 index 0000000000..12d80173a7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc @@ -0,0 +1,556 @@ +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = /*HIGHLIGHTS*/[|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// /*HIGHLIGHTS*/[|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// /*HIGHLIGHTS*/[|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// /*HIGHLIGHTS*/[|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => /*HIGHLIGHTS*/[|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if (/*HIGHLIGHTS*/[|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// /*HIGHLIGHTS*/[|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThis5.ts === +// --- (line: 85) skipped --- +// } +// } +// +// public static staticB = [|this|].staticMethod1; +// +// public static staticMethod1() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// [|this|].this; +// } +// } +// function inside() { +// // --- (line: 104) skipped --- + +// --- (line: 108) skipped --- +// } +// +// private static staticMethod2() { +// [|this|]; +// [|this|]; +// () => [|this|]; +// () => { +// if ([|this|]) { +// [|this|]; +// } +// else { +// /*HIGHLIGHTS*/[|this|].this; +// } +// } +// function inside() { +// // --- (line: 124) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc new file mode 100644 index 0000000000..b554a64c91 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc @@ -0,0 +1,317 @@ +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// /*HIGHLIGHTS*/[|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// /*HIGHLIGHTS*/[|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// /*HIGHLIGHTS*/[|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// /*HIGHLIGHTS*/[|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// /*HIGHLIGHTS*/[|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// /*HIGHLIGHTS*/[|return|]; +// [|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// /*HIGHLIGHTS*/[|return|] true; +// [|throw|] false; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow.ts === +// --- (line: 5) skipped --- +// throw 10; +// } +// catch (x) { +// [|return|] 100; +// } +// finally { +// throw 10; +// } +// } +// catch (x) { +// [|throw|] "Something"; +// } +// finally { +// [|throw|] "Also something"; +// } +// if (a > 0) { +// [|return|] (function () { +// return; +// return; +// return; +// // --- (line: 26) skipped --- + +// --- (line: 30) skipped --- +// })() || true; +// } +// +// [|throw|] 10; +// +// var unusued = [1, 2, 3, 4].map(x => { throw 4 }) +// +// [|return|]; +// [|return|] true; +// /*HIGHLIGHTS*/[|throw|] false; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc new file mode 100644 index 0000000000..db010fa874 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc @@ -0,0 +1,12 @@ +// === documentHighlights === +// === /getOccurrencesThrow2.ts === +// function f(a: number) { +// try { +// throw "Hello"; +// +// try { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// catch (x) { +// return 100; +// // --- (line: 10) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc new file mode 100644 index 0000000000..86ca2055fc --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc @@ -0,0 +1,39 @@ +// === documentHighlights === +// === /getOccurrencesThrow3.ts === +// function f(a: number) { +// try { +// /*HIGHLIGHTS*/[|throw|] "Hello"; +// +// try { +// throw 10; +// } +// catch (x) { +// return 100; +// } +// finally { +// [|throw|] 10; +// } +// } +// catch (x) { +// // --- (line: 16) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThrow3.ts === +// function f(a: number) { +// try { +// [|throw|] "Hello"; +// +// try { +// throw 10; +// } +// catch (x) { +// return 100; +// } +// finally { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// } +// catch (x) { +// // --- (line: 16) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc new file mode 100644 index 0000000000..ffe619c700 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc @@ -0,0 +1,102 @@ +// === documentHighlights === +// === /getOccurrencesThrow4.ts === +// --- (line: 19) skipped --- +// } +// if (a > 0) { +// return (function () { +// /*HIGHLIGHTS*/[|return|]; +// [|return|]; +// [|return|]; +// +// if (false) { +// [|return|] true; +// } +// [|throw|] "Hello!"; +// })() || true; +// } +// +// // --- (line: 34) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThrow4.ts === +// --- (line: 19) skipped --- +// } +// if (a > 0) { +// return (function () { +// [|return|]; +// /*HIGHLIGHTS*/[|return|]; +// [|return|]; +// +// if (false) { +// [|return|] true; +// } +// [|throw|] "Hello!"; +// })() || true; +// } +// +// // --- (line: 34) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThrow4.ts === +// --- (line: 19) skipped --- +// } +// if (a > 0) { +// return (function () { +// [|return|]; +// [|return|]; +// /*HIGHLIGHTS*/[|return|]; +// +// if (false) { +// [|return|] true; +// } +// [|throw|] "Hello!"; +// })() || true; +// } +// +// // --- (line: 34) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThrow4.ts === +// --- (line: 19) skipped --- +// } +// if (a > 0) { +// return (function () { +// [|return|]; +// [|return|]; +// [|return|]; +// +// if (false) { +// /*HIGHLIGHTS*/[|return|] true; +// } +// [|throw|] "Hello!"; +// })() || true; +// } +// +// // --- (line: 34) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesThrow4.ts === +// --- (line: 19) skipped --- +// } +// if (a > 0) { +// return (function () { +// [|return|]; +// [|return|]; +// [|return|]; +// +// if (false) { +// [|return|] true; +// } +// /*HIGHLIGHTS*/[|throw|] "Hello!"; +// })() || true; +// } +// +// // --- (line: 34) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow5.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow5.baseline.jsonc new file mode 100644 index 0000000000..99dc8e9e67 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow5.baseline.jsonc @@ -0,0 +1,12 @@ +// === documentHighlights === +// === /getOccurrencesThrow5.ts === +// --- (line: 32) skipped --- +// +// throw 10; +// +// var unusued = [1, 2, 3, 4].map(x => { /*HIGHLIGHTS*/[|throw|] 4 }) +// +// return; +// return true; +// throw false; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow6.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow6.baseline.jsonc new file mode 100644 index 0000000000..9ffa80d02c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow6.baseline.jsonc @@ -0,0 +1,51 @@ +// === documentHighlights === +// === /getOccurrencesThrow6.ts === +// /*HIGHLIGHTS*/[|throw|] 100; +// +// try { +// throw 0; +// var x = () => { throw 0; }; +// } +// catch (y) { +// var x = () => { throw 0; }; +// [|throw|] 200; +// } +// finally { +// [|throw|] 300; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow6.ts === +// [|throw|] 100; +// +// try { +// throw 0; +// var x = () => { throw 0; }; +// } +// catch (y) { +// var x = () => { throw 0; }; +// /*HIGHLIGHTS*/[|throw|] 200; +// } +// finally { +// [|throw|] 300; +// } + + + +// === documentHighlights === +// === /getOccurrencesThrow6.ts === +// [|throw|] 100; +// +// try { +// throw 0; +// var x = () => { throw 0; }; +// } +// catch (y) { +// var x = () => { throw 0; }; +// [|throw|] 200; +// } +// finally { +// /*HIGHLIGHTS*/[|throw|] 300; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow7.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow7.baseline.jsonc new file mode 100644 index 0000000000..ac78ae0dd3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow7.baseline.jsonc @@ -0,0 +1,112 @@ +// === documentHighlights === +// === /getOccurrencesThrow7.ts === +// try { +// /*HIGHLIGHTS*/[|throw|] 10; +// +// try { +// throw 10; +// } +// catch (x) { +// [|throw|] 10; +// } +// finally { +// [|throw|] 10; +// } +// } +// finally { +// [|throw|] 10; +// } +// +// [|throw|] 10; + + + +// === documentHighlights === +// === /getOccurrencesThrow7.ts === +// try { +// [|throw|] 10; +// +// try { +// throw 10; +// } +// catch (x) { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// finally { +// [|throw|] 10; +// } +// } +// finally { +// [|throw|] 10; +// } +// +// [|throw|] 10; + + + +// === documentHighlights === +// === /getOccurrencesThrow7.ts === +// try { +// [|throw|] 10; +// +// try { +// throw 10; +// } +// catch (x) { +// [|throw|] 10; +// } +// finally { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// } +// finally { +// [|throw|] 10; +// } +// +// [|throw|] 10; + + + +// === documentHighlights === +// === /getOccurrencesThrow7.ts === +// try { +// [|throw|] 10; +// +// try { +// throw 10; +// } +// catch (x) { +// [|throw|] 10; +// } +// finally { +// [|throw|] 10; +// } +// } +// finally { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// +// [|throw|] 10; + + + +// === documentHighlights === +// === /getOccurrencesThrow7.ts === +// try { +// [|throw|] 10; +// +// try { +// throw 10; +// } +// catch (x) { +// [|throw|] 10; +// } +// finally { +// [|throw|] 10; +// } +// } +// finally { +// [|throw|] 10; +// } +// +// /*HIGHLIGHTS*/[|throw|] 10; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc new file mode 100644 index 0000000000..64af032ca9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc @@ -0,0 +1,11 @@ +// === documentHighlights === +// === /getOccurrencesThrow8.ts === +// try { +// throw 10; +// +// try { +// /*HIGHLIGHTS*/[|throw|] 10; +// } +// catch (x) { +// throw 10; +// // --- (line: 9) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc new file mode 100644 index 0000000000..721e41c40c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc @@ -0,0 +1,33 @@ +// === documentHighlights === +// === /getOccurrencesYield.ts === +// function* f() { +// /*HIGHLIGHTS*/[|yield|] 100; +// [|yield|] [|yield|] 200; +// class Foo { +// *memberFunction() { +// return yield 1; +// // --- (line: 7) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesYield.ts === +// function* f() { +// [|yield|] 100; +// /*HIGHLIGHTS*/[|yield|] [|yield|] 200; +// class Foo { +// *memberFunction() { +// return yield 1; +// // --- (line: 7) skipped --- + + + +// === documentHighlights === +// === /getOccurrencesYield.ts === +// function* f() { +// [|yield|] 100; +// [|yield|] /*HIGHLIGHTS*/[|yield|] 200; +// class Foo { +// *memberFunction() { +// return yield 1; +// // --- (line: 7) skipped --- \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getPropertySymbolsFromBaseTypesDoesntCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getPropertySymbolsFromBaseTypesDoesntCrash.baseline.jsonc new file mode 100644 index 0000000000..8a4bdb1ec2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getPropertySymbolsFromBaseTypesDoesntCrash.baseline.jsonc @@ -0,0 +1,5 @@ +// === documentHighlights === +// === /file1.ts === +// class ClassA implements IInterface { +// private /*HIGHLIGHTS*/[|value|]: number; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/occurrences01.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/occurrences01.baseline.jsonc new file mode 100644 index 0000000000..55b9ef31ff --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/occurrences01.baseline.jsonc @@ -0,0 +1,81 @@ +// === documentHighlights === +// === /occurrences01.ts === +// foo: /*HIGHLIGHTS*/[|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 3: +// [|break|]; +// [|break|] foo; +// continue; +// continue foo; +// } + + + +// === documentHighlights === +// === /occurrences01.ts === +// foo: [|switch|] (10) { +// /*HIGHLIGHTS*/[|case|] 1: +// [|case|] 2: +// [|case|] 3: +// [|break|]; +// [|break|] foo; +// continue; +// continue foo; +// } + + + +// === documentHighlights === +// === /occurrences01.ts === +// foo: [|switch|] (10) { +// [|case|] 1: +// /*HIGHLIGHTS*/[|case|] 2: +// [|case|] 3: +// [|break|]; +// [|break|] foo; +// continue; +// continue foo; +// } + + + +// === documentHighlights === +// === /occurrences01.ts === +// foo: [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// /*HIGHLIGHTS*/[|case|] 3: +// [|break|]; +// [|break|] foo; +// continue; +// continue foo; +// } + + + +// === documentHighlights === +// === /occurrences01.ts === +// foo: [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 3: +// /*HIGHLIGHTS*/[|break|]; +// [|break|] foo; +// continue; +// continue foo; +// } + + + +// === documentHighlights === +// === /occurrences01.ts === +// foo: [|switch|] (10) { +// [|case|] 1: +// [|case|] 2: +// [|case|] 3: +// [|break|]; +// /*HIGHLIGHTS*/[|break|] foo; +// continue; +// continue foo; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/occurrences02.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/occurrences02.baseline.jsonc new file mode 100644 index 0000000000..642adeaae6 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/occurrences02.baseline.jsonc @@ -0,0 +1,29 @@ +// === documentHighlights === +// === /occurrences02.ts === +// function /*HIGHLIGHTS*/[|f|](x: typeof [|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /occurrences02.ts === +// function [|f|](x: typeof /*HIGHLIGHTS*/[|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /occurrences02.ts === +// function [|f|](x: typeof [|f|]) { +// /*HIGHLIGHTS*/[|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /occurrences02.ts === +// function [|f|](x: typeof [|f|]) { +// [|f|](/*HIGHLIGHTS*/[|f|]); +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc new file mode 100644 index 0000000000..6d4f8ba8f7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc @@ -0,0 +1,6 @@ +// === documentHighlights === +// === /B.ts === +// export default class /*HIGHLIGHTS*/[|C|] { +// test() { +// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/scopeOfUnionProperties.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/scopeOfUnionProperties.baseline.jsonc new file mode 100644 index 0000000000..5757a24e08 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/scopeOfUnionProperties.baseline.jsonc @@ -0,0 +1,5 @@ +// === documentHighlights === +// === /scopeOfUnionProperties.ts === +// function f(s: string | number) { +// s.[|constr/*HIGHLIGHTS*/uctor|] +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName3.baseline.jsonc new file mode 100644 index 0000000000..253af58c2a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName3.baseline.jsonc @@ -0,0 +1,156 @@ +// === findAllReferences === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// /*FIND ALL REFS*/[|div|]: any; +// } +// } +// +// const Comp = () => +// <[|div|]> +// Some content +// <[|div|]>More content +// ; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// [|div|]: any; +// } +// } +// +// const Comp = () => +// +// Some content +// <[|div|]>More content +// ; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// [|div|]: any; +// } +// } +// +// const Comp = () => +// <[|div|]> +// Some content +// More content +// ; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// [|div|]: any; +// } +// } +// +// const Comp = () => +// <[|div|]> +// Some content +// <[|div|]>More content +// ; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// namespace JSX { +// export interface Element { } +// export interface IntrinsicElements { +// [|div|]: any; +// } +// } +// +// const Comp = () => +// <[|div|]> +// Some content +// <[|div|]>More content +// ; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// --- (line: 4) skipped --- +// } +// } +// +// const /*FIND ALL REFS*/[|Comp|] = () => +//
+// Some content +//
More content
+//
; +// +// const x = <[|Comp|]> +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// --- (line: 4) skipped --- +// } +// } +// +// const [|Comp|] = () => +//
+// Some content +//
More content
+//
; +// +// const x = +// Content +// ; + + + +// === findAllReferences === +// === /a.tsx === +// --- (line: 4) skipped --- +// } +// } +// +// const [|Comp|] = () => +//
+// Some content +//
More content
+//
; +// +// const x = <[|Comp|]> +// Content +// ; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc new file mode 100644 index 0000000000..4ae1126485 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc @@ -0,0 +1,19 @@ +// === findAllReferences === +// === /A.ts === +// import [|B|] from "./B"; +// let b = new [|B|](); +// b.test(); + +// === /B.ts === +// export default class /*FIND ALL REFS*/[|C|] { +// test() { +// } +// } + + + +// === findAllReferences === +// === /A.ts === +// import /*FIND ALL REFS*/[|B|] from "./B"; +// let b = new [|B|](); +// b.test(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc new file mode 100644 index 0000000000..3cde049d52 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc @@ -0,0 +1,22 @@ +// === findRenameLocations === +// === /B.ts === +// export default class /*RENAME*/[|CRENAME|] { +// test() { +// } +// } + + + +// === findRenameLocations === +// === /A.ts === +// import /*RENAME*/[|BRENAME|] from "./B"; +// let b = new [|BRENAME|](); +// b.test(); + + + +// === findRenameLocations === +// === /A.ts === +// import [|BRENAME|] from "./B"; +// let b = new /*RENAME*/[|BRENAME|](); +// b.test(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff new file mode 100644 index 0000000000..f45fc22589 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff @@ -0,0 +1,8 @@ +--- old.renameDefaultImportDifferentName.baseline.jsonc ++++ new.renameDefaultImportDifferentName.baseline.jsonc +@@= skipped -19, +19 lines =@@ + // import [|BRENAME|] from "./B"; + // let b = new /*RENAME*/[|BRENAME|](); + // b.test(); +- +- \ No newline at end of file