From 7a4b3e2df8f75bbbab9ef21336deddb4bf5d794c Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:21:39 -0500 Subject: [PATCH 01/23] merged server from main --- internal/ast/ast.go | 8 ++++++++ internal/lsp/server.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 91fefba966..145c4acf1f 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -3123,6 +3123,10 @@ func (node *ThrowStatement) computeSubtreeFacts() SubtreeFacts { return propagateSubtreeFacts(node.Expression) } +func IsThrowStatement(node *Node) bool { + return node.Kind == KindThrowStatement +} + // TryStatement type TryStatement struct { @@ -6085,6 +6089,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/lsp/server.go b/internal/lsp/server.go index 5b6198a885..7a51463b87 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -459,6 +459,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) @@ -621,6 +622,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ RenameProvider: &lsproto.BooleanOrRenameOptions{ Boolean: ptrTo(true), }, + DocumentHighlightProvider: &lsproto.BooleanOrDocumentHighlightOptions{ + Boolean: ptrTo(true), + }, }, } @@ -800,6 +804,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...) } From 0b437c2cd7284185b810ee9c9ae8824e29ffc350 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:22:27 -0500 Subject: [PATCH 02/23] implemented highlights and helper functions --- internal/ls/documenthighlights.go | 681 ++++++++++++++++++++++++++++++ 1 file changed, 681 insertions(+) create mode 100644 internal/ls/documenthighlights.go diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go new file mode 100644 index 0000000000..3d08657823 --- /dev/null +++ b/internal/ls/documenthighlights.go @@ -0,0 +1,681 @@ +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.Kind == ast.KindJsxOpeningElement || (node.Parent.Kind == ast.KindJsxClosingElement && node.Parent.TagName() == node) { + documentHighlights := []*lsproto.DocumentHighlight{} + // does doc highlights use KindRead for everything ? + kind := lsproto.DocumentHighlightKindRead + if node.Parent.Kind == ast.KindJsxOpeningElement { + documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(node.Parent, sourceFile), + Kind: &kind, + }) + } + if node.Parent.Kind == ast.KindJsxClosingElement { + documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(node.Parent, sourceFile), + Kind: &kind, + }) + } + return lsproto.DocumentHighlightsOrNull{ + DocumentHighlights: &documentHighlights, + }, nil + } + + documentHighlights := l.getSemanticDocumentHighlights(ctx, position, node, program, sourceFile) + if documentHighlights == nil { + 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 +} + +// TODO: capitalize get ? +func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { + var highlights []*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 + } + + for _, entry := range referenceEntries { + for _, ref := range entry.references { + kind := lsproto.DocumentHighlightKindRead + if ref.node != nil { + highlights = append(highlights, &lsproto.DocumentHighlight{ + Range: *l.createLspRangeFromNode(ref.node, sourceFile), + Kind: &kind, + }) + } + } + } + return highlights +} + +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, false) + }, 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 { + symbolDecls := []*ast.Node{} + if ast.CanHaveSymbol(decl) { + symbol := decl.Symbol() + if ast.CanHaveSymbol(decl) && symbol != nil && symbol.Declarations != 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. + for j := ifKeyword.Pos() - 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 { + var keywords []*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() + } + + // 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) { + var result []*ast.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 + + if catchClause == nil && tryBlock != nil { + result = append(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 block, also include return keywords. + 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 +} + +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 { + var keywords []*ast.Node + tryStatement := node.AsTryStatement() + + 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 { + var keywords []*ast.Node + switchStatement := node.AsSwitchStatement() + + 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 ownsBreakOrContinueStatement(switchStatement.AsNode(), statement) && statement.Kind == ast.KindBreakStatement { + 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 []*ast.Node{} + } + return flatMapChildren(node, nil, 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 { + // Walk up ancestors to find the owner node. + return ast.FindAncestor(statement, func(node *ast.Node) bool { + switch node.Kind { + case ast.KindSwitchStatement: + if statement.Kind == ast.KindContinueStatement { + return false + } + // falls through + 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 { + return true + } + return isLabeledBy(node, statement.Label().Text()) + default: + // Don't cross function boundaries. + return ast.IsFunctionLike(node) + } + }) +} + +// Helper function to check if a node is labeled by a given label name. +func isLabeledBy(node *ast.Node, labelName string) bool { + return ast.FindAncestor(node.Parent, func(owner *ast.Node) bool { + if !ast.IsLabeledStatement(owner) { + return false + } + return owner.Label().Text() == labelName + }) != nil +} + +func getBreakOrContinueStatementOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { + owner := getBreakOrContinueOwner(node) + if 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 { + 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 { + parentFunc := ast.FindAncestor(node.Parent, ast.IsFunctionLike).AsFunctionDeclaration() + if parentFunc == nil { + return nil + } + + var keywords []*ast.Node + modifiers := parentFunc.Modifiers().Nodes + if len(modifiers) != 0 { + for _, modifier := range modifiers { + 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 { /* TODO */ + 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 { /* TODO */ + var result []*ast.Node + + nodesToSearch := getNodesToSearchForModifier(node, 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 + } + + switch container.Kind { + case ast.KindModuleBlock, ast.KindSourceFile, ast.KindBlock, ast.KindCaseClause, ast.KindDefaultClause: + // If abstract modifier and class declaration, include members and the declaration itself + if (modifierFlag&ast.ModifierFlagsAbstract) != 0 && ast.IsClassDeclaration(declaration) { + result = append(result, declaration) + result = append(result, declaration.Members()...) + } else { + result = 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()...) + } + case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindTypeLiteral: + nodes := container.Members() + 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, nodes...) + result = append(result, constructor.Parameters()...) + } else { + result = append(result, nodes...) + } + } else if (modifierFlag & ast.ModifierFlagsAbstract) != 0 { + result = append(result, nodes...) + result = append(result, container) + } else { + result = append(result, nodes...) + } + default: + // Syntactically invalid positions or unsupported containers + return nil + } + + return result +} + +func modifierToFlag(kind ast.Kind) ast.ModifierFlags { + switch kind { + case ast.KindPublicKeyword: + return ast.ModifierFlagsPublic + case ast.KindPrivateKeyword: + return ast.ModifierFlagsPrivate + case ast.KindProtectedKeyword: + return ast.ModifierFlagsProtected + case ast.KindStaticKeyword: + return ast.ModifierFlagsStatic + case ast.KindReadonlyKeyword: + return ast.ModifierFlagsReadonly + case ast.KindAbstractKeyword: + return ast.ModifierFlagsAbstract + case ast.KindExportKeyword: + return ast.ModifierFlagsExport + case ast.KindDeclareKeyword: + return ast.ModifierFlagsAmbient + case ast.KindDefaultKeyword: + return ast.ModifierFlagsDefault + case ast.KindConstKeyword: + return ast.ModifierFlagsConst + case ast.KindAsyncKeyword: + return ast.ModifierFlagsAsync + default: + return ast.ModifierFlagsNone + } +} + +func findModifier(node *ast.Node, kind ast.Kind) *ast.Node { + if ast.CanHaveModifiers(node) && node.Modifiers() != nil { + for _, modifier := range node.Modifiers().Nodes { + if modifier.Kind == kind { + return modifier + } + } + } + return nil +} From 7342e5914844f39fd0b115ba3ac37d6f88a91721 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Tue, 9 Sep 2025 17:23:41 -0500 Subject: [PATCH 03/23] fourslash testing for doc highlights --- .../fourslash/_scripts/convertFourslash.mts | 16 +++++ internal/fourslash/baselineutil.go | 3 + internal/fourslash/fourslash.go | 69 +++++++++++++++++++ .../fourslash/tests/documentHighlight_test.go | 18 +++++ internal/ls/documenthighlights.go | 1 - 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 internal/fourslash/tests/documentHighlight_test.go diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 3d0743a40b..60a18ed1e4 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1097,6 +1097,12 @@ interface VerifyBaselineSignatureHelpCmd { kind: "verifyBaselineSignatureHelp"; } +interface VerifyBaselineDocumentHighlightsCmd { + kind: "verifyBaselineDocumentHighlights"; + markers: string[]; + ranges?: boolean; +} + interface GoToCmd { kind: "goTo"; // !!! `selectRange` and `rangeStart` require parsing variables and `test.ranges()[n]` @@ -1119,6 +1125,7 @@ interface VerifyQuickInfoCmd { type Cmd = | VerifyCompletionsCmd | VerifyBaselineFindAllReferencesCmd + | VerifyBaselineDocumentHighlightsCmd | VerifyBaselineGoToDefinitionCmd | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd @@ -1160,6 +1167,13 @@ function generateBaselineFindAllReferences({ markers, ranges }: VerifyBaselineFi return `f.VerifyBaselineFindAllReferences(t, ${markers.join(", ")})`; } +function generateBaselineDocumentHighlights({ markers, ranges }: VerifyBaselineDocumentHighlightsCmd): string { + if (ranges || markers.length === 0) { + return `f.VerifyBaselineDocumentHighlights(t)`; + } + return `f.VerifyBaselineDocumentHighlights(t, ${markers.join(", ")})`; +} + function generateBaselineGoToDefinition({ markers, ranges }: VerifyBaselineGoToDefinitionCmd): string { if (ranges || markers.length === 0) { return `f.VerifyBaselineGoToDefinition(t)`; @@ -1191,6 +1205,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/baselineutil.go b/internal/fourslash/baselineutil.go index d9c625f69d..ccbdefec9f 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io/fs" + "os" "regexp" "slices" "strings" @@ -142,6 +143,7 @@ func (f *FourslashTest) getBaselineContentForFile( spanToContextId map[documentSpan]int, options baselineFourslashLocationsOptions, ) string { + fmt.Fprintf(os.Stderr, "TC\n") details := []*baselineDetail{} detailPrefixes := map[baselineDetail]string{} detailSuffixes := map[baselineDetail]string{} @@ -245,6 +247,7 @@ func (f *FourslashTest) getBaselineContentForFile( continue } } + fmt.Fprintf(os.Stderr, "Detail: %+v\n", detail) textWithContext.add(detail) textWithContext.pos = detail.pos // Prefix diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index c64cd1f72d..7f9d6de713 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1093,6 +1093,75 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { baseline.Run(t, f.baseline.getBaselineFileName(), f.baseline.content.String(), baseline.Options{}) } +func (f *FourslashTest) VerifyBaselineDocumentHighlights( + t *testing.T, + markers ...string, +) { + t.Logf("Inside doc highlights\n") + referenceLocations := f.lookupMarkersOrGetRanges(t, markers) + + if f.baseline != nil { + t.Fatalf("Error during test '%s': Another baseline is already in progress", t.Name()) + } else { + f.baseline = &baselineFromTest{ + content: &strings.Builder{}, + baselineName: "documentHighlights/" + strings.TrimPrefix(t.Name(), "Test"), + ext: ".baseline.jsonc", + } + } + + defer func() { + f.baseline = nil + }() + + for _, markerOrRange := range referenceLocations { + f.GoToMarkerOrRange(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.baseline.addResult("documentHighlights", f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ + marker: markerOrRange.GetMarker(), + markerName: "/*HIGHLIGHTS*/", + })) + } + + baseline.Run(t, f.baseline.getBaselineFileName(), f.baseline.content.String(), baseline.Options{}) +} + // 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/documentHighlight_test.go b/internal/fourslash/tests/documentHighlight_test.go new file mode 100644 index 0000000000..4067307c8a --- /dev/null +++ b/internal/fourslash/tests/documentHighlight_test.go @@ -0,0 +1,18 @@ +package fourslash + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentHighlights(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/*1*/function /*2*/f(x: typeof /*3*/f) { + /*4*/f(/*5*/f); +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineDocumentHighlights(t, "1", "2", "3", "4", "5") +} diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 3d08657823..894e620a9c 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -48,7 +48,6 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen return lsproto.DocumentHighlightsOrNull{DocumentHighlights: &documentHighlights}, nil } -// TODO: capitalize get ? func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { var highlights []*lsproto.DocumentHighlight options := refOptions{use: referenceUseReferences} From 45906a234ac096876fc3cf05a93f954ad58f3d7a Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 10 Sep 2025 08:26:19 -0700 Subject: [PATCH 04/23] fix compare LSP positions --- internal/ls/utilities.go | 2 +- ...ortProvider_referencesCrash.baseline.jsonc | 2 +- ...FindAllReferencesImportMeta.baseline.jsonc | 2 +- ...OverloadedFunctionParameter.baseline.jsonc | 2 +- .../FindAllReferencesLinkTag1.baseline.jsonc | 16 ++++----- .../FindAllReferencesLinkTag2.baseline.jsonc | 10 +++--- .../FindAllReferencesLinkTag3.baseline.jsonc | 10 +++--- ...cesNonExistentExportBinding.baseline.jsonc | 2 +- ...indAllReferencesTripleSlash.baseline.jsonc | 14 ++++++++ .../FindAllRefsEnumMember.baseline.jsonc | 2 +- ...RefsForFunctionExpression01.baseline.jsonc | 8 ++--- .../FindAllRefsForImportCall.baseline.jsonc | 2 +- ...indAllRefsForImportCallType.baseline.jsonc | 2 +- ...FindAllRefsInsideTemplates1.baseline.jsonc | 2 +- ...FindAllRefsInsideTemplates2.baseline.jsonc | 4 +-- .../FindAllRefsInsideWithBlock.baseline.jsonc | 2 +- .../FindAllRefsIsDefinition.baseline.jsonc | 10 +++--- .../FindAllRefsJsDocImportTag.baseline.jsonc | 2 +- .../FindAllRefsJsDocImportTag2.baseline.jsonc | 2 +- .../FindAllRefsJsDocImportTag3.baseline.jsonc | 2 +- .../FindAllRefsJsDocImportTag4.baseline.jsonc | 2 +- ...odulesOverlappingSpecifiers.baseline.jsonc | 2 +- ...indingElementPropertyName03.baseline.jsonc | 2 +- ...indingElementPropertyName10.baseline.jsonc | 2 +- .../FindAllRefsOnDecorators.baseline.jsonc | 2 +- .../FindAllRefsPrimitiveJsDoc.baseline.jsonc | 2 +- .../FindAllRefsReExport_broken.baseline.jsonc | 12 +++++++ .../FindAllRefsThisKeyword.baseline.jsonc | 2 +- ...efsThisKeywordMultipleFiles.baseline.jsonc | 8 ++--- ...eParameterInMergedInterface.baseline.jsonc | 4 +-- .../FindReferencesAfterEdit.baseline.jsonc | 36 +++++++++++++++++++ ...encesDefinitionDisplayParts.baseline.jsonc | 6 ++-- .../FindReferencesSeeTagInTs.baseline.jsonc | 2 +- ...sDefinitionOfBindingPattern.baseline.jsonc | 2 +- ...nitionOfInterfaceClassMerge.baseline.jsonc | 2 +- ...encesIsDefinitionOfVariable.baseline.jsonc | 4 +-- ...DefinitionShorthandProperty.baseline.jsonc | 2 +- ...xtuallyTypedUnionProperties.baseline.jsonc | 2 +- .../ReferencesForLabel6.baseline.jsonc | 2 +- .../RemoteGetReferences.baseline.jsonc | 4 +-- .../TsxFindAllReferences4.baseline.jsonc | 2 +- ...oToDefinitionDynamicImport3.baseline.jsonc | 2 +- ...oToDefinitionDynamicImport4.baseline.jsonc | 2 +- ...finitionExternalModuleName5.baseline.jsonc | 2 +- .../GoToDefinitionMember.baseline.jsonc | 2 +- .../GoToDefinitionMetaProperty.baseline.jsonc | 4 +-- .../GoToDefinitionModifiers.baseline.jsonc | 14 ++++---- ...itionSignatureAlias_require.baseline.jsonc | 4 +-- .../goToDef/GoToDefinitionThis.baseline.jsonc | 2 +- ...GoToDefinitionTypePredicate.baseline.jsonc | 2 +- .../GoToDefinitionTypeofThis.baseline.jsonc | 2 +- .../GoToDefinitionYield4.baseline.jsonc | 2 +- ...tionInObjectBindingPattern1.baseline.jsonc | 2 +- ...tionInObjectBindingPattern2.baseline.jsonc | 6 ++-- 54 files changed, 154 insertions(+), 92 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 566352b0bb..d92bb5b03f 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -28,7 +28,7 @@ func ComparePositions(pos, other lsproto.Position) int { if lineComp := cmp.Compare(pos.Line, other.Line); lineComp != 0 { return lineComp } - return cmp.Compare(pos.Line, other.Line) + return cmp.Compare(pos.Character, other.Character) } // Implements a cmp.Compare like function for two *lsproto.Range diff --git a/testdata/baselines/reference/fourslash/findAllRef/AutoImportProvider_referencesCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/AutoImportProvider_referencesCrash.baseline.jsonc index fa07b16bfd..74063b82c8 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/AutoImportProvider_referencesCrash.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/AutoImportProvider_referencesCrash.baseline.jsonc @@ -9,4 +9,4 @@ // === /home/src/workspaces/project/b/b.ts === // /// -// new A/*FIND ALL REFS*/[|A|](); +// new [|A|]/*FIND ALL REFS*/(); diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesImportMeta.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesImportMeta.baseline.jsonc index 42c49a22d3..a79adfcfcc 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesImportMeta.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesImportMeta.baseline.jsonc @@ -3,4 +3,4 @@ // // Haha that's so meta! // -// let x = import.meta/*FIND ALL REFS*/[|meta|]; +// let x = import.[|meta|]/*FIND ALL REFS*/; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc index 868da34a9c..643bfe6613 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc @@ -5,6 +5,6 @@ // * @param {unknown} x // * @returns {unknown} // */ -// function foo(x/*FIND ALL REFS*/[|x|]) { +// function foo([|x|]/*FIND ALL REFS*/) { // return [|x|]; // } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag1.baseline.jsonc index 8ea93a9256..42069eeb85 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag1.baseline.jsonc @@ -2,7 +2,7 @@ // === /findAllReferencesLinkTag1.ts === // class C { -// m/*FIND ALL REFS*/[|m|]() { } +// [|m|]/*FIND ALL REFS*/() { } // n = 1 // static s() { } // /** @@ -26,7 +26,7 @@ // class C { // m() { } -// n/*FIND ALL REFS*/[|n|] = 1 +// [|n|]/*FIND ALL REFS*/ = 1 // static s() { } // /** // * {@link m} @@ -52,7 +52,7 @@ // class C { // m() { } // n = 1 -// static s/*FIND ALL REFS*/[|s|]() { } +// static [|s|]/*FIND ALL REFS*/() { } // /** // * {@link m} // * @see {m} @@ -79,7 +79,7 @@ // } // // interface I { -// a/*FIND ALL REFS*/[|a|]() +// [|a|]/*FIND ALL REFS*/() // b: 1 // /** // * {@link a} @@ -95,7 +95,7 @@ // // interface I { // a() -// b/*FIND ALL REFS*/[|b|]: 1 +// [|b|]/*FIND ALL REFS*/: 1 // /** // * {@link a} // * @see {a} @@ -115,7 +115,7 @@ // function ref() { } // /** @see {r2} */ // function d3() { } -// function r2/*FIND ALL REFS*/[|r2|]() { } +// function [|r2|]/*FIND ALL REFS*/() { } // } @@ -124,7 +124,7 @@ // === findAllReferences === // === /findAllReferencesLinkTag1.ts === -// class C/*FIND ALL REFS*/[|C|] { +// class [|C|]/*FIND ALL REFS*/ { // m() { } // n = 1 // static s() { } @@ -169,7 +169,7 @@ // r() { } // } // -// interface I/*FIND ALL REFS*/[|I|] { +// interface [|I|]/*FIND ALL REFS*/ { // a() // b: 1 // /** diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc index ea6869acf9..f0d369461d 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc @@ -6,7 +6,7 @@ // This = class { // show() { } // } -// m/*FIND ALL REFS*/[|m|]() { } +// [|m|]/*FIND ALL REFS*/() { } // } // /** // * @see {Consider.prototype.m} @@ -21,7 +21,7 @@ // namespace NPR { // export class Consider { // This = class { -// show/*FIND ALL REFS*/[|show|]() { } +// [|show|]/*FIND ALL REFS*/() { } // } // m() { } // } @@ -35,7 +35,7 @@ // namespace NPR { // export class Consider { -// This/*FIND ALL REFS*/[|This|] = class { +// [|This|]/*FIND ALL REFS*/ = class { // show() { } // } // m() { } @@ -48,7 +48,7 @@ // === /findAllReferencesLinkTag2.ts === // namespace NPR { -// export class Consider/*FIND ALL REFS*/[|Consider|] { +// export class [|Consider|]/*FIND ALL REFS*/ { // This = class { // show() { } // } @@ -80,7 +80,7 @@ // === findAllReferences === // === /findAllReferencesLinkTag2.ts === -// namespace NPR/*FIND ALL REFS*/[|NPR|] { +// namespace [|NPR|]/*FIND ALL REFS*/ { // export class Consider { // This = class { // show() { } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag3.baseline.jsonc index 16b0623ff3..705765b241 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag3.baseline.jsonc @@ -6,7 +6,7 @@ // This = class { // show() { } // } -// m/*FIND ALL REFS*/[|m|]() { } +// [|m|]/*FIND ALL REFS*/() { } // } // /** // * {@linkcode Consider.prototype.[|m|]} @@ -24,7 +24,7 @@ // namespace NPR { // export class Consider { // This = class { -// show/*FIND ALL REFS*/[|show|]() { } +// [|show|]/*FIND ALL REFS*/() { } // } // m() { } // } @@ -38,7 +38,7 @@ // namespace NPR { // export class Consider { -// This/*FIND ALL REFS*/[|This|] = class { +// [|This|]/*FIND ALL REFS*/ = class { // show() { } // } // m() { } @@ -51,7 +51,7 @@ // === /findAllReferencesLinkTag3.ts === // namespace NPR { -// export class Consider/*FIND ALL REFS*/[|Consider|] { +// export class [|Consider|]/*FIND ALL REFS*/ { // This = class { // show() { } // } @@ -83,7 +83,7 @@ // === findAllReferences === // === /findAllReferencesLinkTag3.ts === -// namespace NPR/*FIND ALL REFS*/[|NPR|] { +// namespace [|NPR|]/*FIND ALL REFS*/ { // export class Consider { // This = class { // show() { } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc index 6f44ed40d7..39199dbee6 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc @@ -1,4 +1,4 @@ // === findAllReferences === // === /bar.ts === -// import { Foo/*FIND ALL REFS*/[|Foo|] } from "./foo"; +// import { [|Foo|]/*FIND ALL REFS*/ } from "./foo"; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc new file mode 100644 index 0000000000..ff21e68ef0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc @@ -0,0 +1,14 @@ +// === findAllReferences === +// === /a.ts === + +// /// +// /// + + + + +// === findAllReferences === +// === /a.ts === + +// /// +// /// diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsEnumMember.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsEnumMember.baseline.jsonc index fce503b58b..37857947e8 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsEnumMember.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsEnumMember.baseline.jsonc @@ -20,4 +20,4 @@ // === /findAllRefsEnumMember.ts === // enum E { [|A|], B } -// const e: E.A = E./*FIND ALL REFS*/[|A|] = E.[|A|]; +// const e: E.[|A|] = E./*FIND ALL REFS*/[|A|]; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForFunctionExpression01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForFunctionExpression01.baseline.jsonc index 5420705574..b87a54edce 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForFunctionExpression01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForFunctionExpression01.baseline.jsonc @@ -21,7 +21,7 @@ // === findAllReferences === // === /file1.ts === -// var foo = function foo(a = /*FIND ALL REFS*/[|foo|](a = [|foo|](), b = () => [|foo|]) { +// var foo = function [|foo|](a = /*FIND ALL REFS*/[|foo|](), b = () => [|foo|]) { // [|foo|]([|foo|], [|foo|]); // } @@ -31,7 +31,7 @@ // === findAllReferences === // === /file1.ts === -// var foo = function foo(a = foo(), b = () => /*FIND ALL REFS*/[|foo|](a = [|foo|](), b = () => [|foo|]) { +// var foo = function [|foo|](a = [|foo|](), b = () => /*FIND ALL REFS*/[|foo|]) { // [|foo|]([|foo|], [|foo|]); // } @@ -52,7 +52,7 @@ // === /file1.ts === // var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { -// foo(/*FIND ALL REFS*/[|foo|]([|foo|], [|foo|]); +// [|foo|](/*FIND ALL REFS*/[|foo|], [|foo|]); // } @@ -62,5 +62,5 @@ // === /file1.ts === // var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { -// foo(foo, /*FIND ALL REFS*/[|foo|]([|foo|], [|foo|]); +// [|foo|]([|foo|], /*FIND ALL REFS*/[|foo|]); // } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCall.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCall.baseline.jsonc index 373d783fab..eeaa45f0e4 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCall.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCall.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /app.ts === -// export function he/*FIND ALL REFS*/[|hello|]() {}; +// export function [|he/*FIND ALL REFS*/llo|]() {}; // === /direct-use.ts === diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCallType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCallType.baseline.jsonc index 736676b75a..3b134b8e89 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCallType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsForImportCallType.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /app.ts === -// export function he/*FIND ALL REFS*/[|hello|]() {}; +// export function [|he/*FIND ALL REFS*/llo|]() {}; // === /indirect-use.ts === diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates1.baseline.jsonc index 66422cec63..41a93f2506 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates1.baseline.jsonc @@ -29,4 +29,4 @@ // === /findAllRefsInsideTemplates1.ts === // var [|x|] = 10; -// var y = `${ x } ${ /*FIND ALL REFS*/[|x|] } ${ [|x|] }` +// var y = `${ [|x|] } ${ /*FIND ALL REFS*/[|x|] }` diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates2.baseline.jsonc index 2f308122c1..846f0a7c87 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideTemplates2.baseline.jsonc @@ -29,7 +29,7 @@ // === /findAllRefsInsideTemplates2.ts === // function [|f|](...rest: any[]) { } -// f `${ /*FIND ALL REFS*/[|f|] `${ [|f|] } ${ [|f|] }` +// [|f|] `${ /*FIND ALL REFS*/[|f|] } ${ [|f|] }` @@ -38,4 +38,4 @@ // === /findAllRefsInsideTemplates2.ts === // function [|f|](...rest: any[]) { } -// f `${ f } ${ /*FIND ALL REFS*/[|f|] `${ [|f|] } ${ [|f|] }` +// [|f|] `${ [|f|] } ${ /*FIND ALL REFS*/[|f|] }` diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideWithBlock.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideWithBlock.baseline.jsonc index d35e86b4d2..5d7c031f52 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideWithBlock.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsInsideWithBlock.baseline.jsonc @@ -50,4 +50,4 @@ // y++; // also reference for y should be ignored // } // -// x = /*FIND ALL REFS*/[|x|] = [|x|] + 1; +// [|x|] = /*FIND ALL REFS*/[|x|] + 1; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsIsDefinition.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsIsDefinition.baseline.jsonc index 640e9faa8d..35488ee0eb 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsIsDefinition.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsIsDefinition.baseline.jsonc @@ -3,7 +3,7 @@ // declare function [|foo|](a: number): number; // declare function [|foo|](a: string): string; -// declare function foo/*FIND ALL REFS*/[|foo|](a: string | number): string | number; +// declare function [|foo|]/*FIND ALL REFS*/(a: string | number): string | number; // // function foon(a: number): number; // function foon(a: string): string; @@ -29,7 +29,7 @@ // // function [|foon|](a: number): number; // function [|foon|](a: string): string; -// function foon/*FIND ALL REFS*/[|foon|](a: string | number): string | number { +// function [|foon|]/*FIND ALL REFS*/(a: string | number): string | number { // return a // } // @@ -49,7 +49,7 @@ // // foo; foon; // -// export const bar/*FIND ALL REFS*/[|bar|] = 123; +// export const [|bar|]/*FIND ALL REFS*/ = 123; // console.log({ [|bar|] }); // // interface IFoo { @@ -66,7 +66,7 @@ // console.log({ bar }); // // interface IFoo { -// foo/*FIND ALL REFS*/[|foo|](): void; +// [|foo|]/*FIND ALL REFS*/(): void; // } // class Foo implements IFoo { // constructor(n: number) @@ -110,6 +110,6 @@ // constructor(n: number) // constructor() // constructor(n: number?) { } -// foo/*FIND ALL REFS*/[|foo|](): void { } +// [|foo|]/*FIND ALL REFS*/(): void { } // static init() { return new this() } // } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc index 194115ed98..d2337a4dcc 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc @@ -6,6 +6,6 @@ // */ // // /** -// * @param { A/*FIND ALL REFS*/[|A|] } a +// * @param { [|A|]/*FIND ALL REFS*/ } a // */ // function f(a) {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag2.baseline.jsonc index a2ec533fb8..31938d9d3c 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag2.baseline.jsonc @@ -13,7 +13,7 @@ // import [|Component|] from './component.js'; // // /** -// * @extends Component/*FIND ALL REFS*/[|Component|] +// * @extends [|Component|]/*FIND ALL REFS*/ // */ // export class Player extends [|Component|] {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag3.baseline.jsonc index 7ad3975207..10771f398c 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag3.baseline.jsonc @@ -13,7 +13,7 @@ // import { [|Component|] } from './component.js'; // // /** -// * @extends Component/*FIND ALL REFS*/[|Component|] +// * @extends [|Component|]/*FIND ALL REFS*/ // */ // export class Player extends [|Component|] {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag4.baseline.jsonc index b5667df472..00dad63ffb 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag4.baseline.jsonc @@ -4,6 +4,6 @@ // import * as [|C|] from './component.js'; // // /** -// * @extends C/*FIND ALL REFS*/[|C|].Component +// * @extends [|C|]/*FIND ALL REFS*/.Component // */ // export class Player extends Component {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc index 3084b91d0c..f7cf770d52 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc @@ -13,4 +13,4 @@ // // https://github.com/microsoft/TypeScript/issues/5551 // import { resolve as resolveUrl } from "idontcare"; -// import { resolve/*FIND ALL REFS*/[|resolve|] } from "whatever"; +// import { [|resolve|]/*FIND ALL REFS*/ } from "whatever"; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName03.baseline.jsonc index 693b834f7f..58c28b0f61 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName03.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName03.baseline.jsonc @@ -21,4 +21,4 @@ // } // // var foo: I; -// var [ { property1: prop1 }, { /*FIND ALL REFS*/[|property1|]: prop1 }, { [|property1|], property2 } ] = [foo, foo]; +// var [ { [|property1|]: prop1 }, { /*FIND ALL REFS*/[|property1|], property2 } ] = [foo, foo]; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName10.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName10.baseline.jsonc index 8e72d7afce..e31ad68b38 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName10.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsObjectBindingElementPropertyName10.baseline.jsonc @@ -48,5 +48,5 @@ // value: any; // } // -// function f ({ next: { /*FIND ALL REFS*/[|next|]: { [|next|]: x} }: Recursive) { +// function f ({ [|next|]: { /*FIND ALL REFS*/[|next|]: x} }: Recursive) { // } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsOnDecorators.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsOnDecorators.baseline.jsonc index 0ed9171424..8c02da7df4 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsOnDecorators.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsOnDecorators.baseline.jsonc @@ -80,7 +80,7 @@ // === /b.ts === -// @decorator @/*FIND ALL REFS*/[|decorator|] @[|decorator|]("again") +// @[|decorator|] @/*FIND ALL REFS*/[|decorator|]("again") // class C { // @[|decorator|] // method() {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsPrimitiveJsDoc.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsPrimitiveJsDoc.baseline.jsonc index a4a258ac83..3996cc5d59 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsPrimitiveJsDoc.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsPrimitiveJsDoc.baseline.jsonc @@ -41,4 +41,4 @@ // * @param {[|number|]} n // * @returns {[|number|]} // */ -// function f(n: number): /*FIND ALL REFS*/[|number|]): [|number|] {} +// function f(n: [|number|]): /*FIND ALL REFS*/[|number|] {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc new file mode 100644 index 0000000000..3f5ad70a2c --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc @@ -0,0 +1,12 @@ +// === findAllReferences === +// === /a.ts === + +// /*FIND ALL REFS*/export { x }; + + + + +// === findAllReferences === +// === /a.ts === + +// export { /*FIND ALL REFS*/x }; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeyword.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeyword.baseline.jsonc index 85287fafda..7b2b4938eb 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeyword.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeyword.baseline.jsonc @@ -59,7 +59,7 @@ // this; // function f(this) { // return this; -// function g(this) { return /*FIND ALL REFS*/[|this|]) { return [|this|]; } +// function g([|this|]) { return /*FIND ALL REFS*/[|this|]; } // } // class C { // static x() { diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeywordMultipleFiles.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeywordMultipleFiles.baseline.jsonc index 84f2d2a7eb..26a96ba35a 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeywordMultipleFiles.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsThisKeywordMultipleFiles.baseline.jsonc @@ -9,7 +9,7 @@ // === findAllReferences === // === /file1.ts === -// this; /*FIND ALL REFS*/[|this|]; [|this|]; +// [|this|]; /*FIND ALL REFS*/[|this|]; @@ -45,7 +45,7 @@ // === findAllReferences === // === /file3.ts === -// ((x = this, y) => /*FIND ALL REFS*/[|this|], y) => [|this|])([|this|], [|this|]); +// ((x = [|this|], y) => /*FIND ALL REFS*/[|this|])([|this|], [|this|]); // // different 'this' // function f(this) { return this; } @@ -55,7 +55,7 @@ // === findAllReferences === // === /file3.ts === -// ((x = this, y) => this)(/*FIND ALL REFS*/[|this|], y) => [|this|])([|this|], [|this|]); +// ((x = [|this|], y) => [|this|])(/*FIND ALL REFS*/[|this|], [|this|]); // // different 'this' // function f(this) { return this; } @@ -65,6 +65,6 @@ // === findAllReferences === // === /file3.ts === -// ((x = this, y) => this)(this, /*FIND ALL REFS*/[|this|], y) => [|this|])([|this|], [|this|]); +// ((x = [|this|], y) => [|this|])([|this|], /*FIND ALL REFS*/[|this|]); // // different 'this' // function f(this) { return this; } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsTypeParameterInMergedInterface.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsTypeParameterInMergedInterface.baseline.jsonc index db5de047a8..5297bb58fe 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsTypeParameterInMergedInterface.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsTypeParameterInMergedInterface.baseline.jsonc @@ -10,7 +10,7 @@ // === findAllReferences === // === /findAllRefsTypeParameterInMergedInterface.ts === -// interface I { a: /*FIND ALL REFS*/[|T|]> { a: [|T|] } +// interface I<[|T|]> { a: /*FIND ALL REFS*/[|T|] } // interface I<[|T|]> { b: [|T|] } @@ -29,4 +29,4 @@ // === /findAllRefsTypeParameterInMergedInterface.ts === // interface I<[|T|]> { a: [|T|] } -// interface I { b: /*FIND ALL REFS*/[|T|]> { b: [|T|] } +// interface I<[|T|]> { b: /*FIND ALL REFS*/[|T|] } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc new file mode 100644 index 0000000000..9123c0f239 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc @@ -0,0 +1,36 @@ +// === findAllReferences === +// === /a.ts === + +// interface A { +// /*FIND ALL REFS*/[|foo|]: string; +// } + + +// === /b.ts === + +// /// +// +// +// function foo(x: A) { +// x.[|foo|] +// } + + + + +// === findAllReferences === +// === /a.ts === + +// interface A { +// [|foo|]: string; +// } + + +// === /b.ts === + +// /// +// +// +// function foo(x: A) { +// x./*FIND ALL REFS*/[|foo|] +// } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesDefinitionDisplayParts.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesDefinitionDisplayParts.baseline.jsonc index 7f74b72a6d..172064d933 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesDefinitionDisplayParts.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesDefinitionDisplayParts.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findReferencesDefinitionDisplayParts.ts === -// class Gre/*FIND ALL REFS*/[|Greeter|] { +// class [|Gre/*FIND ALL REFS*/eter|] { // someFunction() { this; } // } // @@ -14,7 +14,7 @@ // === /findReferencesDefinitionDisplayParts.ts === // class Greeter { -// someFunction() { th/*FIND ALL REFS*/[|this|]; } +// someFunction() { [|th/*FIND ALL REFS*/is|]; } // } // // type Options = "option 1" | "option 2"; @@ -46,5 +46,5 @@ // type Options = "option 1" | "option 2"; // let myOption: Options = "option 1"; // -// some/*FIND ALL REFS*/[|someLabel|]: +// [|some/*FIND ALL REFS*/Label|]: // break [|someLabel|]; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc index 6659580478..e5279dd8e3 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc @@ -1,7 +1,7 @@ // === findAllReferences === // === /findReferencesSeeTagInTs.ts === -// function doStuffWithStuff/*FIND ALL REFS*/[|doStuffWithStuff|](stuff: { quantity: number }) {} +// function [|doStuffWithStuff|]/*FIND ALL REFS*/(stuff: { quantity: number }) {} // // declare const stuff: { quantity: number }; // /** @see {doStuffWithStuff} */ diff --git a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfBindingPattern.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfBindingPattern.baseline.jsonc index 25461975f6..c7b8e2bd4f 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfBindingPattern.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfBindingPattern.baseline.jsonc @@ -10,7 +10,7 @@ // === findAllReferences === // === /getOccurrencesIsDefinitionOfBindingPattern.ts === -// const { x, y } = { /*FIND ALL REFS*/[|x|], y } = { [|x|]: 1, y: 2 }; +// const { [|x|], y } = { /*FIND ALL REFS*/[|x|]: 1, y: 2 }; // const z = x; diff --git a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index e28de949ad..a71eb71d6e 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -135,5 +135,5 @@ // return this.p + this.m + n; // } // } -// let i: Numbers = new /*FIND ALL REFS*/[|Numbers|] = new [|Numbers|](); +// let i: [|Numbers|] = new /*FIND ALL REFS*/[|Numbers|](); // let x = i.f(i.p + i.m); diff --git a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfVariable.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfVariable.baseline.jsonc index 9d0216986b..35e18bfa6b 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfVariable.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/GetOccurrencesIsDefinitionOfVariable.baseline.jsonc @@ -138,7 +138,7 @@ // var assignmentRightHandSide2 = 1 + [|x|]; // // [|x|] = 1; -// x = /*FIND ALL REFS*/[|x|] = [|x|] + [|x|]; +// [|x|] = /*FIND ALL REFS*/[|x|] + [|x|]; // // [|x|] == 1; // [|x|] <= 1; @@ -162,7 +162,7 @@ // var assignmentRightHandSide2 = 1 + [|x|]; // // [|x|] = 1; -// x = x + /*FIND ALL REFS*/[|x|] = [|x|] + [|x|]; +// [|x|] = [|x|] + /*FIND ALL REFS*/[|x|]; // // [|x|] == 1; // [|x|] <= 1; diff --git a/testdata/baselines/reference/fourslash/findAllRef/IsDefinitionShorthandProperty.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/IsDefinitionShorthandProperty.baseline.jsonc index 3bbe7e857d..6569db3419 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/IsDefinitionShorthandProperty.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/IsDefinitionShorthandProperty.baseline.jsonc @@ -20,4 +20,4 @@ // === /isDefinitionShorthandProperty.ts === // const [|x|] = 1; -// const y: { x: number } = { /*FIND ALL REFS*/[|x|]: number } = { [|x|] }; +// const y: { [|x|]: number } = { /*FIND ALL REFS*/[|x|] }; diff --git a/testdata/baselines/reference/fourslash/findAllRef/ReferencesForContextuallyTypedUnionProperties.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/ReferencesForContextuallyTypedUnionProperties.baseline.jsonc index 65e37f9a5f..00561940b6 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/ReferencesForContextuallyTypedUnionProperties.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/ReferencesForContextuallyTypedUnionProperties.baseline.jsonc @@ -300,7 +300,7 @@ // var c = { [|common|]: 0, b: 0 }; // // // Array literal -// var ar: Array = [{ a: 0, common: "" }, { b: 0, /*FIND ALL REFS*/[|common|]: "" }, { b: 0, [|common|]: 0 }]; +// var ar: Array = [{ a: 0, [|common|]: "" }, { b: 0, /*FIND ALL REFS*/[|common|]: 0 }]; // // // Nested object literal // var ob: { aorb: A|B } = { aorb: { b: 0, [|common|]: 0 } }; diff --git a/testdata/baselines/reference/fourslash/findAllRef/ReferencesForLabel6.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/ReferencesForLabel6.baseline.jsonc index c2cc04b2ae..5b42b3469d 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/ReferencesForLabel6.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/ReferencesForLabel6.baseline.jsonc @@ -35,6 +35,6 @@ // === /referencesForLabel6.ts === // labela: while (true) { -// labelb: while (false) { break /*FIND ALL REFS*/[|labelb|]: while (false) { break [|labelb|]; } +// [|labelb|]: while (false) { break /*FIND ALL REFS*/[|labelb|]; } // break labelc; // } diff --git a/testdata/baselines/reference/fourslash/findAllRef/RemoteGetReferences.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/RemoteGetReferences.baseline.jsonc index a9c778558f..c8cc669747 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/RemoteGetReferences.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/RemoteGetReferences.baseline.jsonc @@ -536,7 +536,7 @@ // //Increments // remotefooCls.remoteclsSVar++; // remotemodTest.remotemodVar++; -// remoteglobalVar = /*FIND ALL REFS*/[|remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; +// [|remoteglobalVar|] = /*FIND ALL REFS*/[|remoteglobalVar|] + [|remoteglobalVar|]; // // //ETC - Other cases // [|remoteglobalVar|] = 3; @@ -612,7 +612,7 @@ // //Increments // remotefooCls.remoteclsSVar++; // remotemodTest.remotemodVar++; -// remoteglobalVar = remoteglobalVar + /*FIND ALL REFS*/[|remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; +// [|remoteglobalVar|] = [|remoteglobalVar|] + /*FIND ALL REFS*/[|remoteglobalVar|]; // // //ETC - Other cases // [|remoteglobalVar|] = 3; diff --git a/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc index 41588be2b5..7ecfaf83ee 100644 --- a/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc @@ -78,4 +78,4 @@ // } // // -// var x = ; +// var x = <[|MyClass|] name='hello'>; diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport3.baseline.jsonc index 1c3067b56d..f9336d9e62 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport3.baseline.jsonc @@ -2,4 +2,4 @@ // === /foo.ts === // export function bar() { return "bar"; } -// import('./foo').then(({ ba/*GO TO DEFINITION*/[|bar|] }) => undefined); +// import('./foo').then(({ [|ba/*GO TO DEFINITION*/r|] }) => undefined); diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport4.baseline.jsonc index 1c3067b56d..f9336d9e62 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionDynamicImport4.baseline.jsonc @@ -2,4 +2,4 @@ // === /foo.ts === // export function bar() { return "bar"; } -// import('./foo').then(({ ba/*GO TO DEFINITION*/[|bar|] }) => undefined); +// import('./foo').then(({ [|ba/*GO TO DEFINITION*/r|] }) => undefined); diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc index d8b35efe1a..b9caefd3b2 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc @@ -1,6 +1,6 @@ // === goToDefinition === // === /a.ts === -// declare module "external/*GO TO DEFINITION*/[|"external"|] { +// declare module [|"external/*GO TO DEFINITION*/"|] { // class Foo { } // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc index 2e1b2688af..ae021631ab 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc @@ -2,5 +2,5 @@ // === /a.ts === // class A { -// private z/*GO TO DEFINITION*/[|z|]: string; +// private [|z|]/*GO TO DEFINITION*/: string; // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMetaProperty.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMetaProperty.baseline.jsonc index 64438cdf2f..f9420cf118 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMetaProperty.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMetaProperty.baseline.jsonc @@ -29,7 +29,7 @@ // === /a.ts === // import.meta; -// function f() { new.t/*GO TO DEFINITION*/[|f|]() { new.target; } +// function [|f|]() { new.t/*GO TO DEFINITION*/arget; } @@ -56,4 +56,4 @@ // === /b.ts === // import.m; -// class c { constructor() { new.t/*GO TO DEFINITION*/[|c|] { constructor() { new.target; } } +// class [|c|] { constructor() { new.t/*GO TO DEFINITION*/arget; } } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc index 44c9df60f1..53a4fd0a57 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc @@ -13,7 +13,7 @@ // === goToDefinition === // === /a.ts === -// export class A/*GO TO DEFINITION*/[|A|] { +// export class [|A|]/*GO TO DEFINITION*/ { // // private z: string; // @@ -41,7 +41,7 @@ // export class A { // -// private z/*GO TO DEFINITION*/[|z|]: string; +// private [|z|]/*GO TO DEFINITION*/: string; // // readonly x: string; // @@ -73,7 +73,7 @@ // // private z: string; // -// readonly x/*GO TO DEFINITION*/[|x|]: string; +// readonly [|x|]/*GO TO DEFINITION*/: string; // // async a() { } // @@ -105,7 +105,7 @@ // // readonly x: string; // -// async a/*GO TO DEFINITION*/[|a|]() { } +// async [|a|]/*GO TO DEFINITION*/() { } // // override b() {} // @@ -138,7 +138,7 @@ // // async a() { } // -// override b/*GO TO DEFINITION*/[|b|]() {} +// override [|b|]/*GO TO DEFINITION*/() {} // // public async c() { } // } @@ -200,7 +200,7 @@ // // override b() {} // -// public async c/*GO TO DEFINITION*/[|c|]() { } +// public async [|c|]/*GO TO DEFINITION*/() { } // } // // export function foo() { } @@ -227,4 +227,4 @@ // public async c() { } // } // -// export function foo/*GO TO DEFINITION*/[|foo|]() { } +// export function [|foo|]/*GO TO DEFINITION*/() { } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionSignatureAlias_require.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionSignatureAlias_require.baseline.jsonc index b25869586f..c578da7514 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionSignatureAlias_require.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionSignatureAlias_require.baseline.jsonc @@ -1,7 +1,7 @@ // === goToDefinition === // === /a.js === -// [|module.exports = function f() {}|][|f|]() {} +// [|module.exports = function [|f|]() {}|] // === /b.js === @@ -15,7 +15,7 @@ // === goToDefinition === // === /a.js === -// [|module.exports = function f() {}|][|f|]() {} +// [|module.exports = function [|f|]() {}|] // === /bar.ts === diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionThis.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionThis.baseline.jsonc index 777b49ba3f..d0f6ad2f1e 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionThis.baseline.jsonc @@ -34,5 +34,5 @@ // } // class C { // constructor() { return this; } -// get self(this: number) { return /*GO TO DEFINITION*/[|this|]: number) { return this; } +// get self([|this|]: number) { return /*GO TO DEFINITION*/this; } // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypePredicate.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypePredicate.baseline.jsonc index 435ad196c3..06030ad664 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypePredicate.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypePredicate.baseline.jsonc @@ -2,7 +2,7 @@ // === /goToDefinitionTypePredicate.ts === // class A {} -// function f(parameter: any): /*GO TO DEFINITION*/[|parameter|]: any): parameter is A { +// function f([|parameter|]: any): /*GO TO DEFINITION*/parameter is A { // return typeof parameter === "string"; // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypeofThis.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypeofThis.baseline.jsonc index 727f6f5880..03a7182e97 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypeofThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionTypeofThis.baseline.jsonc @@ -34,5 +34,5 @@ // } // class C { // constructor() { type X = typeof this; } -// get self(this: number) { type X = typeof /*GO TO DEFINITION*/[|this|]: number) { type X = typeof this; } +// get self([|this|]: number) { type X = typeof /*GO TO DEFINITION*/this; } // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionYield4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionYield4.baseline.jsonc index 895b2cff68..624d2127a2 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionYield4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionYield4.baseline.jsonc @@ -2,5 +2,5 @@ // === /goToDefinitionYield4.ts === // function* gen() { -// class C { [/*GO TO DEFINITION*/[|[yield 10]|]() {} } +// class C { [|[/*GO TO DEFINITION*/yield 10]|]() {} } // } diff --git a/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern1.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern1.baseline.jsonc index 7d088998b8..0421bd3223 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern1.baseline.jsonc @@ -5,4 +5,4 @@ // interface Test { // prop2: number // } -// bar(({pr/*GO TO DEFINITION*/[|prop2|]})=>{}); +// bar(({[|pr/*GO TO DEFINITION*/op2|]})=>{}); diff --git a/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern2.baseline.jsonc index 7eff2010c1..f39402524e 100644 --- a/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDef/GotoDefinitionInObjectBindingPattern2.baseline.jsonc @@ -1,7 +1,7 @@ // === goToDefinition === // === /gotoDefinitionInObjectBindingPattern2.ts === -// var p0 = ({a/*GO TO DEFINITION*/[|aa|]}) => {console.log(aa)}; +// var p0 = ({[|a/*GO TO DEFINITION*/a|]}) => {console.log(aa)}; // function f2({ a1, b1 }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} @@ -11,7 +11,7 @@ // === /gotoDefinitionInObjectBindingPattern2.ts === // var p0 = ({aa}) => {console.log(aa)}; -// function f2({ a/*GO TO DEFINITION*/[|a1|], b1 }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} +// function f2({ [|a/*GO TO DEFINITION*/1|], b1 }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} @@ -20,4 +20,4 @@ // === /gotoDefinitionInObjectBindingPattern2.ts === // var p0 = ({aa}) => {console.log(aa)}; -// function f2({ a1, b/*GO TO DEFINITION*/[|b1|] }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} +// function f2({ a1, [|b/*GO TO DEFINITION*/1|] }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} From a20e054da26cabc7bc45219e493487cbf72af77a Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 10 Sep 2025 08:34:30 -0700 Subject: [PATCH 05/23] fix tests --- internal/fourslash/_scripts/failingTests.txt | 2 -- .../gen/findAllReferencesTripleSlash_test.go | 2 +- .../gen/findAllRefsReExport_broken_test.go | 2 +- ...indAllReferencesTripleSlash.baseline.jsonc | 14 -------- .../FindAllRefsReExport_broken.baseline.jsonc | 12 ------- .../FindReferencesAfterEdit.baseline.jsonc | 36 ------------------- 6 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 14401cec42..a704de7162 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -167,7 +167,6 @@ TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction TestFindAllReferencesDynamicImport1 -TestFindAllReferencesTripleSlash TestFindAllReferencesUmdModuleAsGlobalConst TestFindAllRefsCommonJsRequire TestFindAllRefsCommonJsRequire2 @@ -175,7 +174,6 @@ TestFindAllRefsCommonJsRequire3 TestFindAllRefsExportEquals TestFindAllRefsForDefaultExport03 TestFindAllRefsModuleDotExports -TestFindAllRefsReExport_broken TestFindAllRefs_importType_typeofImport TestFindReferencesAfterEdit TestFindReferencesBindingPatternInJsdocNoCrash1 diff --git a/internal/fourslash/tests/gen/findAllReferencesTripleSlash_test.go b/internal/fourslash/tests/gen/findAllReferencesTripleSlash_test.go index 6c418d4bb6..eec32bef82 100644 --- a/internal/fourslash/tests/gen/findAllReferencesTripleSlash_test.go +++ b/internal/fourslash/tests/gen/findAllReferencesTripleSlash_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllReferencesTripleSlash(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @checkJs: true // @Filename: /node_modules/@types/globals/index.d.ts diff --git a/internal/fourslash/tests/gen/findAllRefsReExport_broken_test.go b/internal/fourslash/tests/gen/findAllRefsReExport_broken_test.go index a864f48650..8584434558 100644 --- a/internal/fourslash/tests/gen/findAllRefsReExport_broken_test.go +++ b/internal/fourslash/tests/gen/findAllRefsReExport_broken_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsReExport_broken(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @Filename: /a.ts /*1*/export { /*2*/x };` diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc deleted file mode 100644 index ff21e68ef0..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc +++ /dev/null @@ -1,14 +0,0 @@ -// === findAllReferences === -// === /a.ts === - -// /// -// /// - - - - -// === findAllReferences === -// === /a.ts === - -// /// -// /// diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc deleted file mode 100644 index 3f5ad70a2c..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc +++ /dev/null @@ -1,12 +0,0 @@ -// === findAllReferences === -// === /a.ts === - -// /*FIND ALL REFS*/export { x }; - - - - -// === findAllReferences === -// === /a.ts === - -// export { /*FIND ALL REFS*/x }; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc deleted file mode 100644 index 9123c0f239..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesAfterEdit.baseline.jsonc +++ /dev/null @@ -1,36 +0,0 @@ -// === findAllReferences === -// === /a.ts === - -// interface A { -// /*FIND ALL REFS*/[|foo|]: string; -// } - - -// === /b.ts === - -// /// -// -// -// function foo(x: A) { -// x.[|foo|] -// } - - - - -// === findAllReferences === -// === /a.ts === - -// interface A { -// [|foo|]: string; -// } - - -// === /b.ts === - -// /// -// -// -// function foo(x: A) { -// x./*FIND ALL REFS*/[|foo|] -// } From c076d4be0d61c5010b79adee378f425c771c2a04 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 10 Sep 2025 08:44:20 -0700 Subject: [PATCH 06/23] update baselines --- .../FindAllReferencesTripleSlash.baseline.jsonc | 14 ++++++++++++++ .../FindAllRefsReExport_broken.baseline.jsonc | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc new file mode 100644 index 0000000000..ff21e68ef0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesTripleSlash.baseline.jsonc @@ -0,0 +1,14 @@ +// === findAllReferences === +// === /a.ts === + +// /// +// /// + + + + +// === findAllReferences === +// === /a.ts === + +// /// +// /// diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc new file mode 100644 index 0000000000..3f5ad70a2c --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsReExport_broken.baseline.jsonc @@ -0,0 +1,12 @@ +// === findAllReferences === +// === /a.ts === + +// /*FIND ALL REFS*/export { x }; + + + + +// === findAllReferences === +// === /a.ts === + +// export { /*FIND ALL REFS*/x }; From 6d814bb428d80f3f65a74099c249a95c4414a647 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 17 Sep 2025 12:32:14 -0500 Subject: [PATCH 07/23] documentHighlights with fourslash tests --- internal/checker/checker.go | 8 +- internal/checker/utilities.go | 2 +- .../fourslash/_scripts/convertFourslash.mts | 97 ++- internal/fourslash/_scripts/failingTests.txt | 18 + internal/fourslash/baselineutil.go | 3 - internal/fourslash/fourslash.go | 48 +- .../fourslash/tests/documentHighlight_test.go | 7 +- ...entHighlightAtInheritedProperties1_test.go | 22 + ...entHighlightAtInheritedProperties2_test.go | 22 + ...entHighlightAtInheritedProperties3_test.go | 26 + ...entHighlightAtInheritedProperties4_test.go | 26 + ...entHighlightAtInheritedProperties5_test.go | 30 + ...entHighlightAtInheritedProperties6_test.go | 30 + ...ghtAtParameterPropertyDeclaration1_test.go | 33 + ...ghtAtParameterPropertyDeclaration2_test.go | 34 + ...ghtAtParameterPropertyDeclaration3_test.go | 34 + .../documentHighlightDefaultInKeyword_test.go | 19 + .../documentHighlightDefaultInSwitch_test.go | 23 + .../gen/documentHighlightInExport1_test.go | 19 + .../gen/documentHighlightInKeyword_test.go | 24 + .../gen/documentHighlightInTypeExport_test.go | 28 + .../gen/documentHighlightJSDocTypedef_test.go | 32 + ...tHighlightMultilineTemplateStrings_test.go | 21 + .../documentHighlightTemplateStrings_test.go | 29 + ...documentHighlightVarianceModifiers_test.go | 19 + .../tests/gen/documentHighlights01_test.go | 21 + ...ocumentHighlightsInvalidGlobalThis_test.go | 20 + ...HighlightsInvalidModifierLocations_test.go | 26 + ...htsTypeParameterInHeritageClause01_test.go | 19 + .../gen/documentHighlights_33722_test.go | 27 + .../gen/documentHighlights_40082_test.go | 21 + .../documentHighlights_filesToSearch_test.go | 21 + .../gen/emptyExportFindReferences_test.go | 21 + .../tests/gen/findAllRefsForModule_test.go | 26 + .../gen/findReferencesJSXTagName3_test.go | 36 + .../gen/getOccurrencesAbstract01_test.go | 28 + .../gen/getOccurrencesAbstract02_test.go | 28 + .../gen/getOccurrencesAbstract03_test.go | 29 + .../tests/gen/getOccurrencesAfterEdit_test.go | 26 + .../gen/getOccurrencesAsyncAwait2_test.go | 24 + .../gen/getOccurrencesAsyncAwait3_test.go | 20 + .../gen/getOccurrencesAsyncAwait_test.go | 35 + ...urrencesClassExpressionConstructor_test.go | 29 + ...tOccurrencesClassExpressionPrivate_test.go | 33 + ...etOccurrencesClassExpressionPublic_test.go | 33 + ...currencesClassExpressionStaticThis_test.go | 62 ++ ...etOccurrencesClassExpressionStatic_test.go | 35 + .../getOccurrencesClassExpressionThis_test.go | 60 ++ .../tests/gen/getOccurrencesConst01_test.go | 24 + .../tests/gen/getOccurrencesConst04_test.go | 21 + .../gen/getOccurrencesConstructor2_test.go | 34 + .../gen/getOccurrencesConstructor_test.go | 34 + .../tests/gen/getOccurrencesDeclare1_test.go | 69 ++ .../tests/gen/getOccurrencesDeclare2_test.go | 70 ++ .../tests/gen/getOccurrencesDeclare3_test.go | 77 ++ .../tests/gen/getOccurrencesExport1_test.go | 69 ++ .../tests/gen/getOccurrencesExport2_test.go | 70 ++ .../tests/gen/getOccurrencesExport3_test.go | 77 ++ .../tests/gen/getOccurrencesIfElse2_test.go | 38 + .../tests/gen/getOccurrencesIfElse3_test.go | 38 + .../gen/getOccurrencesIfElseBroken_test.go | 25 + .../tests/gen/getOccurrencesIfElse_test.go | 38 + .../getOccurrencesLoopBreakContinue2_test.go | 79 ++ .../getOccurrencesLoopBreakContinue3_test.go | 79 ++ .../getOccurrencesLoopBreakContinue4_test.go | 79 ++ .../getOccurrencesLoopBreakContinue5_test.go | 79 ++ .../getOccurrencesLoopBreakContinue_test.go | 79 ++ .../getOccurrencesModifiersNegatives1_test.go | 50 ++ ...ccurrencesNonStringImportAssertion_test.go | 19 + ...currencesNonStringImportAttributes_test.go | 19 + ...getOccurrencesOfAnonymousFunction2_test.go | 25 + .../getOccurrencesOfAnonymousFunction_test.go | 21 + .../gen/getOccurrencesOfDecorators_test.go | 25 + .../getOccurrencesOfUndefinedSymbol_test.go | 29 + .../tests/gen/getOccurrencesPrivate1_test.go | 70 ++ .../tests/gen/getOccurrencesPrivate2_test.go | 70 ++ ...urrencesPropertyInAliasedInterface_test.go | 34 + .../gen/getOccurrencesProtected1_test.go | 70 ++ .../gen/getOccurrencesProtected2_test.go | 70 ++ .../tests/gen/getOccurrencesPublic1_test.go | 70 ++ .../tests/gen/getOccurrencesPublic2_test.go | 70 ++ .../tests/gen/getOccurrencesReadonly1_test.go | 20 + .../tests/gen/getOccurrencesReadonly2_test.go | 20 + .../tests/gen/getOccurrencesReadonly3_test.go | 26 + .../tests/gen/getOccurrencesReturn2_test.go | 35 + .../tests/gen/getOccurrencesReturn3_test.go | 35 + .../tests/gen/getOccurrencesReturn_test.go | 35 + .../gen/getOccurrencesSetAndGet2_test.go | 39 + .../gen/getOccurrencesSetAndGet3_test.go | 39 + .../tests/gen/getOccurrencesSetAndGet_test.go | 39 + .../tests/gen/getOccurrencesStatic1_test.go | 70 ++ .../getOccurrencesStringLiteralTypes_test.go | 19 + .../gen/getOccurrencesStringLiterals_test.go | 19 + .../tests/gen/getOccurrencesSuper2_test.go | 66 ++ .../tests/gen/getOccurrencesSuper3_test.go | 29 + .../gen/getOccurrencesSuperNegatives_test.go | 36 + .../tests/gen/getOccurrencesSuper_test.go | 66 ++ .../getOccurrencesSwitchCaseDefault2_test.go | 34 + .../getOccurrencesSwitchCaseDefault3_test.go | 32 + .../getOccurrencesSwitchCaseDefault_test.go | 34 + .../tests/gen/getOccurrencesThis2_test.go | 156 ++++ .../tests/gen/getOccurrencesThis3_test.go | 156 ++++ .../tests/gen/getOccurrencesThis4_test.go | 156 ++++ .../tests/gen/getOccurrencesThis5_test.go | 156 ++++ .../tests/gen/getOccurrencesThis_test.go | 156 ++++ .../tests/gen/getOccurrencesThrow2_test.go | 58 ++ .../tests/gen/getOccurrencesThrow3_test.go | 58 ++ .../tests/gen/getOccurrencesThrow4_test.go | 58 ++ .../tests/gen/getOccurrencesThrow5_test.go | 58 ++ .../tests/gen/getOccurrencesThrow6_test.go | 30 + .../tests/gen/getOccurrencesThrow7_test.go | 35 + .../tests/gen/getOccurrencesThrow8_test.go | 35 + .../tests/gen/getOccurrencesThrow_test.go | 58 ++ .../tests/gen/getOccurrencesYield_test.go | 29 + ...rtySymbolsFromBaseTypesDoesntCrash_test.go | 21 + .../tests/gen/jsdocTypedefTagServices_test.go | 32 + .../fourslash/tests/gen/occurrences01_test.go | 26 + .../fourslash/tests/gen/occurrences02_test.go | 20 + ...aration-with-variable-entity-names_test.go | 44 + .../renameDefaultImportDifferentName_test.go | 28 + .../tests/gen/scopeOfUnionProperties_test.go | 19 + internal/ls/documenthighlights.go | 78 +- internal/ls/findallreferences.go | 2 +- ...lightAtInheritedProperties1.baseline.jsonc | 15 + ...lightAtInheritedProperties2.baseline.jsonc | 15 + ...lightAtInheritedProperties3.baseline.jsonc | 49 ++ ...lightAtInheritedProperties4.baseline.jsonc | 49 ++ ...lightAtInheritedProperties5.baseline.jsonc | 82 ++ ...lightAtInheritedProperties6.baseline.jsonc | 63 ++ ...rameterPropertyDeclaration1.baseline.jsonc | 165 ++++ ...rameterPropertyDeclaration2.baseline.jsonc | 109 +++ ...rameterPropertyDeclaration3.baseline.jsonc | 109 +++ ...ntHighlightDefaultInKeyword.baseline.jsonc | 11 + ...entHighlightDefaultInSwitch.baseline.jsonc | 21 + .../documentHighlightInKeyword.baseline.jsonc | 31 + ...ghtMultilineTemplateStrings.baseline.jsonc | 7 + ...tHighlightVarianceModifiers.baseline.jsonc | 11 + .../documentHighlights.baseline.jsonc | 37 + .../documentHighlights01.baseline.jsonc | 29 + ...htsInvalidModifierLocations.baseline.jsonc | 44 + ...ParameterInHeritageClause01.baseline.jsonc | 18 + .../documentHighlights_33722.baseline.jsonc | 5 + ...entHighlights_filesToSearch.baseline.jsonc | 9 + .../findReferencesJSXTagName3.baseline.jsonc | 116 +++ .../getOccurrencesAbstract01.baseline.jsonc | 67 ++ .../getOccurrencesAbstract02.baseline.jsonc | 48 ++ .../getOccurrencesAbstract03.baseline.jsonc | 69 ++ .../getOccurrencesAfterEdit.baseline.jsonc | 22 + .../getOccurrencesAsyncAwait.baseline.jsonc | 87 ++ .../getOccurrencesAsyncAwait2.baseline.jsonc | 57 ++ ...encesClassExpressionPrivate.baseline.jsonc | 82 ++ ...rencesClassExpressionPublic.baseline.jsonc | 82 ++ ...rencesClassExpressionStatic.baseline.jsonc | 69 ++ ...esClassExpressionStaticThis.baseline.jsonc | 92 ++ ...urrencesClassExpressionThis.baseline.jsonc | 303 +++++++ .../getOccurrencesConst01.baseline.jsonc | 19 + .../getOccurrencesConst04.baseline.jsonc | 27 + .../getOccurrencesDeclare1.baseline.jsonc | 66 ++ .../getOccurrencesDeclare2.baseline.jsonc | 11 + .../getOccurrencesDeclare3.baseline.jsonc | 73 ++ .../getOccurrencesExport1.baseline.jsonc | 182 ++++ .../getOccurrencesExport2.baseline.jsonc | 11 + .../getOccurrencesExport3.baseline.jsonc | 54 ++ .../getOccurrencesIfElse.baseline.jsonc | 158 ++++ .../getOccurrencesIfElse2.baseline.jsonc | 23 + .../getOccurrencesIfElse3.baseline.jsonc | 31 + .../getOccurrencesIfElseBroken.baseline.jsonc | 57 ++ ...ccurrencesLoopBreakContinue.baseline.jsonc | 130 +++ ...currencesLoopBreakContinue2.baseline.jsonc | 102 +++ ...currencesLoopBreakContinue3.baseline.jsonc | 200 +++++ ...currencesLoopBreakContinue4.baseline.jsonc | 301 +++++++ ...currencesLoopBreakContinue5.baseline.jsonc | 21 + ...urrencesModifiersNegatives1.baseline.jsonc | 813 ++++++++++++++++++ ...cesNonStringImportAssertion.baseline.jsonc | 4 + ...esNonStringImportAttributes.baseline.jsonc | 4 + ...rrencesOfAnonymousFunction2.baseline.jsonc | 25 + .../getOccurrencesOfDecorators.baseline.jsonc | 10 + ...ccurrencesOfUndefinedSymbol.baseline.jsonc | 9 + .../getOccurrencesPrivate1.baseline.jsonc | 195 +++++ .../getOccurrencesPrivate2.baseline.jsonc | 31 + ...sPropertyInAliasedInterface.baseline.jsonc | 85 ++ .../getOccurrencesProtected1.baseline.jsonc | 183 ++++ .../getOccurrencesProtected2.baseline.jsonc | 45 + .../getOccurrencesPublic1.baseline.jsonc | 285 ++++++ .../getOccurrencesPublic2.baseline.jsonc | 33 + .../getOccurrencesReadonly1.baseline.jsonc | 5 + .../getOccurrencesReadonly2.baseline.jsonc | 5 + .../getOccurrencesReadonly3.baseline.jsonc | 34 + .../getOccurrencesReturn.baseline.jsonc | 57 ++ .../getOccurrencesReturn2.baseline.jsonc | 69 ++ .../getOccurrencesReturn3.baseline.jsonc | 11 + .../getOccurrencesSetAndGet.baseline.jsonc | 25 + .../getOccurrencesSetAndGet2.baseline.jsonc | 31 + .../getOccurrencesSetAndGet3.baseline.jsonc | 29 + .../getOccurrencesStatic1.baseline.jsonc | 45 + .../getOccurrencesSuper.baseline.jsonc | 235 +++++ .../getOccurrencesSuper2.baseline.jsonc | 60 ++ .../getOccurrencesSuper3.baseline.jsonc | 51 ++ ...etOccurrencesSuperNegatives.baseline.jsonc | 61 ++ ...ccurrencesSwitchCaseDefault.baseline.jsonc | 195 +++++ ...currencesSwitchCaseDefault2.baseline.jsonc | 117 +++ ...currencesSwitchCaseDefault3.baseline.jsonc | 157 ++++ .../getOccurrencesThis.baseline.jsonc | 19 + .../getOccurrencesThis2.baseline.jsonc | 129 +++ .../getOccurrencesThis3.baseline.jsonc | 31 + .../getOccurrencesThis4.baseline.jsonc | 556 ++++++++++++ .../getOccurrencesThis5.baseline.jsonc | 556 ++++++++++++ .../getOccurrencesThrow.baseline.jsonc | 317 +++++++ .../getOccurrencesThrow2.baseline.jsonc | 12 + .../getOccurrencesThrow3.baseline.jsonc | 39 + .../getOccurrencesThrow4.baseline.jsonc | 102 +++ .../getOccurrencesThrow5.baseline.jsonc | 12 + .../getOccurrencesThrow6.baseline.jsonc | 51 ++ .../getOccurrencesThrow7.baseline.jsonc | 112 +++ .../getOccurrencesThrow8.baseline.jsonc | 11 + .../getOccurrencesYield.baseline.jsonc | 33 + ...olsFromBaseTypesDoesntCrash.baseline.jsonc | 5 + .../occurrences01.baseline.jsonc | 81 ++ .../occurrences02.baseline.jsonc | 29 + ...eDefaultImportDifferentName.baseline.jsonc | 6 + .../scopeOfUnionProperties.baseline.jsonc | 5 + .../FindReferencesJSXTagName3.baseline.jsonc | 171 ++++ ...ortProvider_referencesCrash.baseline.jsonc | 2 +- ...findAllReferencesImportMeta.baseline.jsonc | 2 +- .../findAllRefsEnumMember.baseline.jsonc | 2 +- ...RefsForFunctionExpression01.baseline.jsonc | 2 +- ...findAllRefsInsideTemplates1.baseline.jsonc | 2 +- ...findAllRefsInsideTemplates2.baseline.jsonc | 2 +- .../findAllRefsInsideWithBlock.baseline.jsonc | 2 +- ...odulesOverlappingSpecifiers.baseline.jsonc | 2 +- ...indingElementPropertyName03.baseline.jsonc | 2 +- ...indingElementPropertyName10.baseline.jsonc | 2 +- .../findAllRefsPrimitiveJsDoc.baseline.jsonc | 2 +- ...eParameterInMergedInterface.baseline.jsonc | 2 +- ...encesDefinitionDisplayParts.baseline.jsonc | 2 +- .../findReferencesJSXTagName3.baseline.jsonc | 156 ++++ ...nitionOfInterfaceClassMerge.baseline.jsonc | 2 +- ...DefinitionShorthandProperty.baseline.jsonc | 2 +- ...eDefaultImportDifferentName.baseline.jsonc | 19 + ...oToDefinitionDynamicImport3.baseline.jsonc | 2 +- ...oToDefinitionDynamicImport4.baseline.jsonc | 2 +- .../goToDefinitionMetaProperty.baseline.jsonc | 2 +- .../goToDefinitionThis.baseline.jsonc | 2 +- .../goToDefinitionTypeofThis.baseline.jsonc | 2 +- .../goToDefinitionYield4.baseline.jsonc | 2 +- ...tionInObjectBindingPattern1.baseline.jsonc | 2 +- ...tionInObjectBindingPattern2.baseline.jsonc | 2 +- ...eDefaultImportDifferentName.baseline.jsonc | 22 + ...ultImportDifferentName.baseline.jsonc.diff | 8 + .../renameExportSpecifier2.baseline.jsonc | 2 +- ...renameExportSpecifier2.baseline.jsonc.diff | 6 +- .../renameImportAndExport.baseline.jsonc | 2 +- .../renameImportAndExport.baseline.jsonc.diff | 3 +- ...eImportAndExportInDiffFiles.baseline.jsonc | 2 +- ...rtAndExportInDiffFiles.baseline.jsonc.diff | 3 +- .../renameImportOfExportEquals.baseline.jsonc | 5 +- ...meImportOfExportEquals.baseline.jsonc.diff | 11 +- .../renameImportRequire.baseline.jsonc | 8 +- .../renameImportRequire.baseline.jsonc.diff | 15 +- 259 files changed, 14034 insertions(+), 116 deletions(-) create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties1_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties2_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties3_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties4_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties5_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtInheritedProperties6_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration1_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration2_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightAtParameterPropertyDeclaration3_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightDefaultInKeyword_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightDefaultInSwitch_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightInExport1_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightInKeyword_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightInTypeExport_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightJSDocTypedef_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightMultilineTemplateStrings_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightTemplateStrings_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightVarianceModifiers_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlights01_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightsInvalidGlobalThis_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightsInvalidModifierLocations_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlightsTypeParameterInHeritageClause01_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlights_33722_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlights_40082_test.go create mode 100644 internal/fourslash/tests/gen/documentHighlights_filesToSearch_test.go create mode 100644 internal/fourslash/tests/gen/emptyExportFindReferences_test.go create mode 100644 internal/fourslash/tests/gen/findAllRefsForModule_test.go create mode 100644 internal/fourslash/tests/gen/findReferencesJSXTagName3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAbstract01_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAbstract02_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAbstract03_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAfterEdit_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAsyncAwait2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesAsyncAwait_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionConstructor_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionPrivate_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionPublic_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionStaticThis_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionStatic_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesClassExpressionThis_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesConst01_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesConst04_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesConstructor2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesConstructor_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesDeclare1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesDeclare2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesDeclare3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesExport1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesExport2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesExport3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesIfElse2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesIfElse3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesIfElseBroken_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesIfElse_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue4_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue5_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesLoopBreakContinue_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesModifiersNegatives1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesNonStringImportAssertion_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesNonStringImportAttributes_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesOfAnonymousFunction_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesOfDecorators_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesOfUndefinedSymbol_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesPrivate1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesPrivate2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesPropertyInAliasedInterface_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesProtected1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesProtected2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesPublic1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesPublic2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReadonly1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReadonly2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReadonly3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReturn2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReturn3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesReturn_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSetAndGet2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSetAndGet3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSetAndGet_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesStatic1_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesStringLiteralTypes_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesStringLiterals_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSuper2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSuper3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSuperNegatives_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSuper_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesSwitchCaseDefault_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThis2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThis3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThis4_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThis5_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThis_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow2_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow3_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow4_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow5_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow6_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow7_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow8_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesThrow_test.go create mode 100644 internal/fourslash/tests/gen/getOccurrencesYield_test.go create mode 100644 internal/fourslash/tests/gen/getPropertySymbolsFromBaseTypesDoesntCrash_test.go create mode 100644 internal/fourslash/tests/gen/jsdocTypedefTagServices_test.go create mode 100644 internal/fourslash/tests/gen/occurrences01_test.go create mode 100644 internal/fourslash/tests/gen/occurrences02_test.go create mode 100644 internal/fourslash/tests/gen/qualifiedName_import-declaration-with-variable-entity-names_test.go create mode 100644 internal/fourslash/tests/gen/renameDefaultImportDifferentName_test.go create mode 100644 internal/fourslash/tests/gen/scopeOfUnionProperties_test.go create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties4.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties5.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtInheritedProperties6.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightAtParameterPropertyDeclaration3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInKeyword.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightDefaultInSwitch.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightInKeyword.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightMultilineTemplateStrings.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightVarianceModifiers.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlights01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsInvalidModifierLocations.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlightsTypeParameterInHeritageClause01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_33722.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlights_filesToSearch.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract02.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAbstract03.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAfterEdit.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPrivate.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionPublic.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStatic.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionStaticThis.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesClassExpressionThis.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesConst04.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesDeclare3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesExport3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElse3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue4.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesLoopBreakContinue5.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesModifiersNegatives1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAssertion.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesNonStringImportAttributes.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfAnonymousFunction2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfDecorators.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesOfUndefinedSymbol.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPrivate2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPropertyInAliasedInterface.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesProtected2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesPublic2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReadonly3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesReturn3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSetAndGet3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesStatic1.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuper3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSuperNegatives.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesSwitchCaseDefault3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis4.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThis5.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow2.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow4.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow5.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow6.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow7.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesThrow8.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesYield.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getPropertySymbolsFromBaseTypesDoesntCrash.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/occurrences01.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/occurrences02.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/renameDefaultImportDifferentName.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/scopeOfUnionProperties.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findReferencesJSXTagName3.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/renameDefaultImportDifferentName.baseline.jsonc create mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc create mode 100644 testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameDefaultImportDifferentName.baseline.jsonc.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 9844cbc289..cc3940f315 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, 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 @@ -15715,9 +15715,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) || IsWriteAccess(location)) { var t *Type - if isWriteAccess(location) && location.Kind == ast.KindPropertyAccessExpression { + if IsWriteAccess(location) && location.Kind == ast.KindPropertyAccessExpression { t = c.checkPropertyAccessExpression(location, CheckModeNormal, true /*writeOnly*/) } else { t = c.getTypeOfExpression(location) @@ -15735,7 +15735,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) && IsWriteAccess(location.Parent) { return c.getWriteTypeOfSymbol(symbol) } } diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 10f1c6c0c7..ba59c5bf8c 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -1078,7 +1078,7 @@ func isWriteOnlyAccess(node *ast.Node) bool { return accessKind(node) == AccessKindWrite } -func isWriteAccess(node *ast.Node) bool { +func IsWriteAccess(node *ast.Node) bool { return accessKind(node) != AccessKindRead } diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index efd834c32f..281a1f0ecd 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,90 @@ 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 = parseBaselineDocumentHighlightsArg(elem); + if (!newArg) { + return undefined; + } + newArgs.push(newArg); + } + } + else if (ts.isObjectLiteralExpression(arg)) { + // User preferences case, but multiple files isn't implemented in corsa yet + } + else if (strArg = parseBaselineDocumentHighlightsArg(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 parseBaselineDocumentHighlightsArg(arg: ts.Expression): string | undefined { + if (ts.isStringLiteral(arg)) { + return getGoStringLiteral(arg.text); + } + else if (ts.isIdentifier(arg) || (ts.isElementAccessExpression(arg) && ts.isIdentifier(arg.expression))) { + const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; + const file = arg.getSourceFile(); + const varStmts = file.statements.filter(ts.isVariableStatement); + for (const varStmt of varStmts) { + for (const decl of varStmt.declarationList.declarations) { + if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { + for (let i = 0; i < decl.name.elements.length; i++) { + const elem = decl.name.elements[i]; + if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { + // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` + if (elem.dotDotDotToken === undefined) { + return `f.Ranges()[${i}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` + if (ts.isElementAccessExpression(arg)) { + return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; + } + // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` + return `ToAny(f.Ranges()[${i}:])...`; + } + } + } + } + } + const init = getNodeOfKind(arg, ts.isCallExpression); + if (init) { + const result = getRangesByTextArg(init); + if (result) { + return result; + } + } + } + else if (ts.isCallExpression(arg)) { + const result = getRangesByTextArg(arg); + if (result) { + return result; + } + } + console.error(`Unrecognized argument in verify.baselineRename: ${arg.getText()}`); + return undefined; +} + function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [VerifyBaselineGoToDefinitionCmd] | undefined { const newArgs = []; for (const arg of args) { @@ -1264,8 +1350,8 @@ interface VerifyBaselineRenameCmd { interface VerifyBaselineDocumentHighlightsCmd { kind: "verifyBaselineDocumentHighlights"; - markers: string[]; - ranges?: boolean; + args: string[]; + preferences: string; } interface GoToCmd { @@ -1339,11 +1425,8 @@ function generateBaselineFindAllReferences({ markers, ranges }: VerifyBaselineFi return `f.VerifyBaselineFindAllReferences(t, ${markers.join(", ")})`; } -function generateBaselineDocumentHighlights({ markers, ranges }: VerifyBaselineDocumentHighlightsCmd): string { - if (ranges || markers.length === 0) { - return `f.VerifyBaselineDocumentHighlights(t)`; - } - return `f.VerifyBaselineDocumentHighlights(t, ${markers.join(", ")})`; +function generateBaselineDocumentHighlights({ args, preferences }: VerifyBaselineDocumentHighlightsCmd): string { + return `f.VerifyBaselineDocumentHighlights(t, ${preferences}, ${args.join(", ")})`; } function generateBaselineGoToDefinition({ markers, ranges }: VerifyBaselineGoToDefinitionCmd): string { diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 909240a459..e712c8e33d 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,14 @@ TestGetJavaScriptQuickInfo6 TestGetJavaScriptQuickInfo7 TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 +TestGetOccurrencesAsyncAwait3 +TestGetOccurrencesClassExpressionConstructor +TestGetOccurrencesConstructor +TestGetOccurrencesConstructor2 +TestGetOccurrencesIfElseBroken +TestGetOccurrencesOfAnonymousFunction +TestGetOccurrencesStringLiteralTypes +TestGetOccurrencesStringLiterals TestGetQuickInfoForIntersectionTypes TestHoverOverComment TestImportCompletionsPackageJsonExportsSpecifierEndsInTs @@ -264,6 +280,7 @@ TestJsdocThrowsTagCompletion TestJsdocTypedefTag TestJsdocTypedefTag2 TestJsdocTypedefTagNamespace +TestJsdocTypedefTagServices TestJsxFindAllReferencesOnRuntimeImportWithPaths1 TestLetQuickInfoAndCompletionList TestLocalFunction @@ -329,6 +346,7 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto +TestQualifiedName_import_declaration_with_variable_entity_names TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 8c51cc5210..fcfbaca77c 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io/fs" - "os" "regexp" "slices" "strings" @@ -211,7 +210,6 @@ func (f *FourslashTest) getBaselineContentForFile( spanToContextId map[lsproto.Range]int, options baselineFourslashLocationsOptions, ) string { - fmt.Fprintf(os.Stderr, "TC\n") details := []*baselineDetail{} detailPrefixes := map[*baselineDetail]string{} detailSuffixes := map[*baselineDetail]string{} @@ -285,7 +283,6 @@ func (f *FourslashTest) getBaselineContentForFile( continue } } - fmt.Fprintf(os.Stderr, "Detail: %+v\n", detail) textWithContext.add(detail) textWithContext.pos = detail.pos // Prefix diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 1dac790046..2fff230f31 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1033,27 +1033,37 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { func (f *FourslashTest) VerifyBaselineDocumentHighlights( t *testing.T, - markers ...string, + preferences *ls.UserPreferences, + markerOrRangeOrNames ...MarkerOrRangeOrName, ) { - t.Logf("Inside doc highlights\n") - referenceLocations := f.lookupMarkersOrGetRanges(t, markers) - - if f.baseline != nil { - t.Fatalf("Error during test '%s': Another baseline is already in progress", t.Name()) - } else { - f.baseline = &baselineFromTest{ - content: &strings.Builder{}, - baselineName: "documentHighlights/" + strings.TrimPrefix(t.Name(), "Test"), - ext: ".baseline.jsonc", + 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) } } - defer func() { - f.baseline = nil - }() + f.verifyBaselineDocumentHighlights(t, preferences, markerOrRanges) +} - for _, markerOrRange := range referenceLocations { - f.GoToMarkerOrRange(t, markerOrRange) +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{ @@ -1091,13 +1101,11 @@ func (f *FourslashTest) VerifyBaselineDocumentHighlights( } // Add result to baseline - f.baseline.addResult("documentHighlights", f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ - marker: markerOrRange.GetMarker(), + f.addResultToBaseline(t, "documentHighlights", f.getBaselineForLocationsWithFileContents(spans, baselineFourslashLocationsOptions{ + marker: markerOrRange, markerName: "/*HIGHLIGHTS*/", })) } - - baseline.Run(t, f.baseline.getBaselineFileName(), f.baseline.content.String(), baseline.Options{}) } // Collects all named markers if provided, or defaults to anonymous ranges diff --git a/internal/fourslash/tests/documentHighlight_test.go b/internal/fourslash/tests/documentHighlight_test.go index 4067307c8a..ef7b6a66e2 100644 --- a/internal/fourslash/tests/documentHighlight_test.go +++ b/internal/fourslash/tests/documentHighlight_test.go @@ -4,15 +4,16 @@ 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(t *testing.T) { t.Parallel() defer testutil.RecoverAndFail(t, "Panic on fourslash test") - const content = `/*1*/function /*2*/f(x: typeof /*3*/f) { - /*4*/f(/*5*/f); + const content = `[|function|] [|f|](x: typeof [|f|]) { + [|f|]([|f|]); }` f := fourslash.NewFourslash(t, nil /*capabilities*/, content) - f.VerifyBaselineDocumentHighlights(t, "1", "2", "3", "4", "5") + f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, ToAny(f.Ranges())...) } 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..33f8d1dbb8 --- /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() + t.Skip() + 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 index 894e620a9c..3111c1e9a3 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/lsutil" @@ -21,7 +22,6 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen if node.Parent.Kind == ast.KindJsxOpeningElement || (node.Parent.Kind == ast.KindJsxClosingElement && node.Parent.TagName() == node) { documentHighlights := []*lsproto.DocumentHighlight{} - // does doc highlights use KindRead for everything ? kind := lsproto.DocumentHighlightKindRead if node.Parent.Kind == ast.KindJsxOpeningElement { documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ @@ -58,23 +58,48 @@ func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, pos for _, entry := range referenceEntries { for _, ref := range entry.references { - kind := lsproto.DocumentHighlightKindRead if ref.node != nil { - highlights = append(highlights, &lsproto.DocumentHighlight{ - Range: *l.createLspRangeFromNode(ref.node, sourceFile), - Kind: &kind, - }) + 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) + + // If this is a plain range (Span), always treat it as a reference. + kind := lsproto.DocumentHighlightKindText + if entry.kind == entryKindRange { + return entry.fileName, &lsproto.DocumentHighlight{ + Range: *entry.textRange, + Kind: &kind, + } + } + + // Determine write access for node references. + if checker.IsWriteAccess(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) + result := l.getIfElseOccurrences(node.Parent.AsIfStatement(), sourceFile) + return result } return nil case ast.KindReturnKeyword: @@ -100,7 +125,7 @@ func (l *LanguageService) getSyntacticDocumentHighlights(node *ast.Node, sourceF 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, false) + return ast.IsIterationStatement(n, true) }, getLoopBreakContinueOccurrences, sourceFile) case ast.KindConstructorKeyword: return l.getFromAllDeclarations(ast.IsConstructorDeclaration, []ast.Kind{ast.KindConstructorKeyword}, node, sourceFile) @@ -185,7 +210,11 @@ func (l *LanguageService) getIfElseOccurrences(ifStatement *ast.IfStatement, sou shouldCombine := true // Avoid recalculating getStart() by iterating backwards. - for j := ifKeyword.Pos() - 1; j >= elseKeyword.End(); j-- { + 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 @@ -281,7 +310,9 @@ func aggregateOwnedThrowStatements(node *ast.Node, sourceFile *ast.SourceFile) [ catchClause := statement.CatchClause finallyBlock := statement.FinallyBlock - if catchClause == nil && tryBlock != nil { + if catchClause != nil { + result = append(result, aggregateOwnedThrowStatements(catchClause, sourceFile)...) + } else if tryBlock != nil { result = append(result, aggregateOwnedThrowStatements(tryBlock, sourceFile)...) } if finallyBlock != nil { @@ -422,7 +453,7 @@ func aggregateAllBreakAndContinueStatements(node *ast.Node, sourceFile *ast.Sour if ast.IsFunctionLike(node) { return []*ast.Node{} } - return flatMapChildren(node, nil, aggregateAllBreakAndContinueStatements) + return flatMapChildren(node, sourceFile, aggregateAllBreakAndContinueStatements) } func ownsBreakOrContinueStatement(owner *ast.Node, statement *ast.Node) bool { @@ -435,11 +466,11 @@ func ownsBreakOrContinueStatement(owner *ast.Node, statement *ast.Node) bool { func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { // Walk up ancestors to find the owner node. - return ast.FindAncestor(statement, func(node *ast.Node) bool { + return ast.FindAncestorOrQuit(statement, func(node *ast.Node) ast.FindAncestorResult { switch node.Kind { case ast.KindSwitchStatement: if statement.Kind == ast.KindContinueStatement { - return false + return ast.FindAncestorFalse } // falls through fallthrough @@ -449,24 +480,30 @@ func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { ast.KindWhileStatement, ast.KindDoStatement: // If the statement is labeled, check if the node is labeled by the statement's label. - if statement.Label() == nil { - return true + if statement.Label() == nil || isLabeledBy(node, statement.Label().Text()) { + return ast.FindAncestorTrue } - return isLabeledBy(node, statement.Label().Text()) + return ast.FindAncestorFalse default: // Don't cross function boundaries. - return ast.IsFunctionLike(node) + if ast.IsFunctionLike(node) { + return ast.FindAncestorQuit + } + return ast.FindAncestorFalse } }) } // Helper function to check if a node is labeled by a given label name. func isLabeledBy(node *ast.Node, labelName string) bool { - return ast.FindAncestor(node.Parent, func(owner *ast.Node) bool { + return ast.FindAncestorOrQuit(node.Parent, func(owner *ast.Node) ast.FindAncestorResult { if !ast.IsLabeledStatement(owner) { - return false + return ast.FindAncestorQuit + } + if owner.Label().Text() == labelName { + return ast.FindAncestorTrue } - return owner.Label().Text() == labelName + return ast.FindAncestorFalse }) != nil } @@ -493,6 +530,7 @@ func getLoopBreakContinueOccurrences(node *ast.Node, sourceFile *ast.SourceFile) loopTokens := getChildrenFromNonJSDocNode(node, sourceFile) for i := len(loopTokens) - 1; i >= 0; i-- { if loopTokens[i].Kind == ast.KindWhileKeyword { + keywords = append(keywords, loopTokens[i]) break } } diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 8f099d691f..db870f40a6 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -1037,7 +1037,7 @@ func getReferencedSymbolsForSymbol(originalSymbol *ast.Symbol, node *ast.Node, s state := newState(sourceFiles, sourceFilesSet, node, checker /*, cancellationToken*/, searchMeaning, options) var exportSpecifier *ast.Node - if !isForRenameWithPrefixAndSuffixText(options) || len(symbol.Declarations) == 0 { + if isForRenameWithPrefixAndSuffixText(options) && len(symbol.Declarations) != 0 { exportSpecifier = core.Find(symbol.Declarations, ast.IsExportSpecifier) } if exportSpecifier != nil { 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/documentHighlights.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc new file mode 100644 index 0000000000..ac0a558f1c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc @@ -0,0 +1,37 @@ +// === documentHighlights === +// === /documentHighlights.ts === +// /*HIGHLIGHTS*/function f(x: typeof f) { +// f(f); +// } + + + +// === documentHighlights === +// === /documentHighlights.ts === +// function /*HIGHLIGHTS*/[|f|](x: typeof [|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /documentHighlights.ts === +// function [|f|](x: typeof /*HIGHLIGHTS*/[|f|]) { +// [|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /documentHighlights.ts === +// function [|f|](x: typeof [|f|]) { +// /*HIGHLIGHTS*/[|f|]([|f|]); +// } + + + +// === documentHighlights === +// === /documentHighlights.ts === +// function [|f|](x: typeof [|f|]) { +// [|f|](/*HIGHLIGHTS*/[|f|]); +// } \ 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..ac702db577 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc @@ -0,0 +1,116 @@ +// === 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
+// ; +// // --- (line: 13) skipped --- + + + +// === 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: 8) skipped --- +//
+// 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: 12) skipped --- +// +// 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/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/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc new file mode 100644 index 0000000000..c1c381e16a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc @@ -0,0 +1,57 @@ +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// /*HIGHLIGHTS*/[|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// /*HIGHLIGHTS*/[|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// /*HIGHLIGHTS*/[|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) +// else \ 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/findAllRef/FindReferencesJSXTagName3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc new file mode 100644 index 0000000000..cbb48095ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc @@ -0,0 +1,171 @@ +// === 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 +// ; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc index c94061dd44..a1f16deccb 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/autoImportProvider_referencesCrash.baseline.jsonc @@ -6,4 +6,4 @@ // === /home/src/workspaces/project/b/b.ts === // /// -// new [|A|]/*FIND ALL REFS*/(); +// new [|A|]/*FIND ALL REFS*/(); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesImportMeta.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesImportMeta.baseline.jsonc index cae6177126..f0113af254 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesImportMeta.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllReferencesImportMeta.baseline.jsonc @@ -2,4 +2,4 @@ // === /findAllReferencesImportMeta.ts === // // Haha that's so meta! // -// let x = import.[|meta|]/*FIND ALL REFS*/; +// let x = import.[|meta|]/*FIND ALL REFS*/; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumMember.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumMember.baseline.jsonc index 0d469c231e..caca53e1d7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumMember.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsEnumMember.baseline.jsonc @@ -15,4 +15,4 @@ // === findAllReferences === // === /findAllRefsEnumMember.ts === // enum E { [|A|], B } -// const e: E.[|A|] = E./*FIND ALL REFS*/[|A|]; +// const e: E.[|A|] = E./*FIND ALL REFS*/[|A|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc index 2db6944693..f02db6604a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc @@ -50,4 +50,4 @@ // === /file1.ts === // var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { // [|foo|]([|foo|], /*FIND ALL REFS*/[|foo|]); -// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc index 7127070a44..d70f81e56a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates1.baseline.jsonc @@ -22,4 +22,4 @@ // === findAllReferences === // === /findAllRefsInsideTemplates1.ts === // var [|x|] = 10; -// var y = `${ [|x|] } ${ /*FIND ALL REFS*/[|x|] }` +// var y = `${ [|x|] } ${ /*FIND ALL REFS*/[|x|] }` \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc index 7ba6ecfe55..9d2e0aa91d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideTemplates2.baseline.jsonc @@ -29,4 +29,4 @@ // === findAllReferences === // === /findAllRefsInsideTemplates2.ts === // function [|f|](...rest: any[]) { } -// [|f|] `${ [|f|] } ${ /*FIND ALL REFS*/[|f|] }` +// [|f|] `${ [|f|] } ${ /*FIND ALL REFS*/[|f|] }` \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc index f80c4ace38..118d6ab98c 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsInsideWithBlock.baseline.jsonc @@ -43,4 +43,4 @@ // y++; // also reference for y should be ignored // } // -// [|x|] = /*FIND ALL REFS*/[|x|] + 1; +// [|x|] = /*FIND ALL REFS*/[|x|] + 1; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc index 5cb2afacc5..6aaee5897e 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsMissingModulesOverlappingSpecifiers.baseline.jsonc @@ -10,4 +10,4 @@ // === /findAllRefsMissingModulesOverlappingSpecifiers.ts === // // https://github.com/microsoft/TypeScript/issues/5551 // import { resolve as resolveUrl } from "idontcare"; -// import { [|resolve|]/*FIND ALL REFS*/ } from "whatever"; +// import { [|resolve|]/*FIND ALL REFS*/ } from "whatever"; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName03.baseline.jsonc index 1636521922..4a97e32610 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName03.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName03.baseline.jsonc @@ -18,4 +18,4 @@ // } // // var foo: I; -// var [ { [|property1|]: prop1 }, { /*FIND ALL REFS*/[|property1|], property2 } ] = [foo, foo]; +// var [ { [|property1|]: prop1 }, { /*FIND ALL REFS*/[|property1|], property2 } ] = [foo, foo]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName10.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName10.baseline.jsonc index 3bd91603bb..369cf2fa1d 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName10.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsObjectBindingElementPropertyName10.baseline.jsonc @@ -42,4 +42,4 @@ // } // // function f ({ [|next|]: { /*FIND ALL REFS*/[|next|]: x} }: Recursive) { -// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrimitiveJsDoc.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrimitiveJsDoc.baseline.jsonc index c77c546be0..0b90e046e7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrimitiveJsDoc.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsPrimitiveJsDoc.baseline.jsonc @@ -34,4 +34,4 @@ // * @param {[|number|]} n // * @returns {[|number|]} // */ -// function f(n: [|number|]): /*FIND ALL REFS*/[|number|] {} +// function f(n: [|number|]): /*FIND ALL REFS*/[|number|] {} \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypeParameterInMergedInterface.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypeParameterInMergedInterface.baseline.jsonc index ebbc4ffdaf..2573cb4e41 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypeParameterInMergedInterface.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypeParameterInMergedInterface.baseline.jsonc @@ -22,4 +22,4 @@ // === findAllReferences === // === /findAllRefsTypeParameterInMergedInterface.ts === // interface I<[|T|]> { a: [|T|] } -// interface I<[|T|]> { b: /*FIND ALL REFS*/[|T|] } +// interface I<[|T|]> { b: /*FIND ALL REFS*/[|T|] } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc index cbea0be9ca..01bbfdfb3a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findReferencesDefinitionDisplayParts.baseline.jsonc @@ -40,4 +40,4 @@ // let myOption: Options = "option 1"; // // [|some/*FIND ALL REFS*/Label|]: -// break [|someLabel|]; +// break [|someLabel|]; \ 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/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc index 9c0c4f521d..0482d27845 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/getOccurrencesIsDefinitionOfInterfaceClassMerge.baseline.jsonc @@ -121,4 +121,4 @@ // } // } // let i: [|Numbers|] = new /*FIND ALL REFS*/[|Numbers|](); -// let x = i.f(i.p + i.m); +// let x = i.f(i.p + i.m); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionShorthandProperty.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionShorthandProperty.baseline.jsonc index f195e45c8e..837a87c67a 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionShorthandProperty.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/isDefinitionShorthandProperty.baseline.jsonc @@ -15,4 +15,4 @@ // === findAllReferences === // === /isDefinitionShorthandProperty.ts === // const [|x|] = 1; -// const y: { [|x|]: number } = { /*FIND ALL REFS*/[|x|] }; +// const y: { [|x|]: number } = { /*FIND ALL REFS*/[|x|] }; \ 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/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc index 366b662a7e..80f46261ba 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport3.baseline.jsonc @@ -1,4 +1,4 @@ // === goToDefinition === // === /foo.ts === // export function bar() { return "bar"; } -// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); +// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc index 366b662a7e..80f46261ba 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionDynamicImport4.baseline.jsonc @@ -1,4 +1,4 @@ // === goToDefinition === // === /foo.ts === // export function bar() { return "bar"; } -// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); +// import('./foo').then(({ [|ba/*GOTO DEF*/r|] }) => undefined); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMetaProperty.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMetaProperty.baseline.jsonc index b13dbc11a2..a148da853a 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMetaProperty.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionMetaProperty.baseline.jsonc @@ -43,4 +43,4 @@ // === goToDefinition === // === /b.ts === // import.m; -// class [|c|] { constructor() { new.t/*GOTO DEF*/arget; } } +// class [|c|] { constructor() { new.t/*GOTO DEF*/arget; } } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionThis.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionThis.baseline.jsonc index 8828c8b020..0b3dc0c246 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionThis.baseline.jsonc @@ -30,4 +30,4 @@ // class C { // constructor() { return this; } // get self([|this|]: number) { return /*GOTO DEF*/this; } -// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeofThis.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeofThis.baseline.jsonc index 774bf8f7d2..d27141f9f7 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeofThis.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionTypeofThis.baseline.jsonc @@ -30,4 +30,4 @@ // class C { // constructor() { type X = typeof this; } // get self([|this|]: number) { type X = typeof /*GOTO DEF*/this; } -// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc index 1574e1cdc3..a3f9d8721b 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/goToDefinitionYield4.baseline.jsonc @@ -2,4 +2,4 @@ // === /goToDefinitionYield4.ts === // function* gen() { // class C { [|[/*GOTO DEF*/yield 10]|]() {} } -// } +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern1.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern1.baseline.jsonc index 03415cd875..abb98b47fe 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern1.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern1.baseline.jsonc @@ -4,4 +4,4 @@ // interface Test { // prop2: number // } -// bar(({[|pr/*GOTO DEF*/op2|]})=>{}); +// bar(({[|pr/*GOTO DEF*/op2|]})=>{}); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc index 9c2c595c59..2cde751515 100644 --- a/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/goToDefinition/gotoDefinitionInObjectBindingPattern2.baseline.jsonc @@ -15,4 +15,4 @@ // === goToDefinition === // === /gotoDefinitionInObjectBindingPattern2.ts === // var p0 = ({aa}) => {console.log(aa)}; -// function f2({ a1, [|b/*GOTO DEF*/1|] }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} +// function f2({ a1, [|b/*GOTO DEF*/1|] }: { a1: number, b1: number } = { a1: 0, b1: 0 }) {} \ 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 diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc index 155c542abf..e93e34e686 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc @@ -2,5 +2,5 @@ // @useAliasesForRename: false // === /a.ts === -// const [|nameRENAME|] = {}; +// const name = {}; // export { name/*RENAME*/ }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff index 2fd41bf05f..c425ba1e81 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff @@ -1,12 +1,14 @@ --- old.renameExportSpecifier2.baseline.jsonc +++ new.renameExportSpecifier2.baseline.jsonc -@@= skipped -2, +2 lines =@@ +@@= skipped -1, +1 lines =@@ + // @useAliasesForRename: false // === /a.ts === - // const [|nameRENAME|] = {}; +-// const [|nameRENAME|] = {}; -// export { [|nameRENAME|]/*RENAME*/ }; - -// === /b.ts === -// import { [|nameRENAME|] } from './a'; -// const x = [|nameRENAME|].toString(); ++// const name = {}; +// export { name/*RENAME*/ }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc index f2c7a402dd..b046b76ff8 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc @@ -7,5 +7,5 @@ // === findRenameLocations === // === /renameImportAndExport.ts === -// import [|aRENAME|] from "module"; +// import a from "module"; // export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff index 7579be5fcf..4e1d8a05d1 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff @@ -11,7 +11,6 @@ // === findRenameLocations === // === /renameImportAndExport.ts === --// import a from "module"; + // import a from "module"; -// export { /*START PREFIX*/a as /*RENAME*/[|aRENAME|] }; -+// import [|aRENAME|] from "module"; +// export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc index 3df1b40965..1ba8a72349 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc @@ -17,5 +17,5 @@ // === findRenameLocations === // === /b.ts === -// import { /*START PREFIX*/a as [|aRENAME|] } from './a'; +// import { a } from './a'; // export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff index bbe6b24e4e..59a9f21310 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff @@ -19,7 +19,6 @@ // === findRenameLocations === // === /b.ts === --// import { a } from './a'; + // import { a } from './a'; -// export { /*START PREFIX*/a as /*RENAME*/[|aRENAME|] }; -+// import { /*START PREFIX*/a as [|aRENAME|] } from './a'; +// export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc index 98bee31a7f..757ada73a5 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc @@ -48,11 +48,10 @@ // === findRenameLocations === // === /renameImportOfExportEquals.ts === -// --- (line: 4) skipped --- -// export = N; +// --- (line: 5) skipped --- // } // declare module "a" { -// import * as [|NRENAME|] from "mod"; +// import * as N from "mod"; // export { /*RENAME*/N }; // Renaming N here would rename // } // declare module "b" { diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff index e3008bc1a8..f45a3df09d 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff @@ -45,16 +45,11 @@ - // === findRenameLocations === - // === /renameImportOfExportEquals.ts === --// --- (line: 5) skipped --- -+// --- (line: 4) skipped --- -+// export = N; +@@= skipped -15, +13 lines =@@ // } // declare module "a" { --// import * as N from "mod"; + // import * as N from "mod"; -// export { /*START PREFIX*/N as /*RENAME*/[|NRENAME|] }; // Renaming N here would rename -+// import * as [|NRENAME|] from "mod"; +// export { /*RENAME*/N }; // Renaming N here would rename // } // declare module "b" { @@ -65,7 +60,7 @@ // } -@@= skipped -55, +54 lines =@@ +@@= skipped -40, +40 lines =@@ // } // declare module "mod" { // export = N; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc index 9a6afde3d1..4842e09142 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc @@ -27,9 +27,9 @@ // === findRenameLocations === // === /a.ts === -// import [|eRENAME|] = require("mod4"); -// [|eRENAME|]; -// a = { /*START PREFIX*/e: [|eRENAME|] }; +// import e = require("mod4"); +// e; +// a = { e }; // export { /*RENAME*/e }; @@ -43,5 +43,5 @@ // === findRenameLocations === // === /b.ts === -// import { /*START PREFIX*/e as [|eRENAME|] } from "./a"; +// import { e } from "./a"; // export { /*RENAME*/e }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff index f7fe0c1be4..b56aee56a4 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff @@ -27,19 +27,15 @@ - // === findRenameLocations === - // === /a.ts === --// import e = require("mod4"); --// e; --// a = { e }; +@@= skipped -9, +9 lines =@@ + // import e = require("mod4"); + // e; + // a = { e }; -// export { /*START PREFIX*/e as /*RENAME*/[|eRENAME|] }; - -// === /b.ts === -// import { [|eRENAME|] } from "./a"; -// export { [|eRENAME|] as e/*END SUFFIX*/ }; -+// import [|eRENAME|] = require("mod4"); -+// [|eRENAME|]; -+// a = { /*START PREFIX*/e: [|eRENAME|] }; +// export { /*RENAME*/e }; @@ -54,7 +50,6 @@ // === findRenameLocations === // === /b.ts === --// import { e } from "./a"; + // import { e } from "./a"; -// export { /*START PREFIX*/e as /*RENAME*/[|eRENAME|] }; -+// import { /*START PREFIX*/e as [|eRENAME|] } from "./a"; +// export { /*RENAME*/e }; \ No newline at end of file From 1dade87a3b8066081b63f4fb9e52afb2f72a15f0 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 17 Sep 2025 12:50:08 -0500 Subject: [PATCH 08/23] fixed minor change --- internal/ls/findallreferences.go | 2 +- .../renameExportSpecifier2.baseline.jsonc | 2 +- .../renameExportSpecifier2.baseline.jsonc.diff | 6 ++---- .../renameImportAndExport.baseline.jsonc | 2 +- .../renameImportAndExport.baseline.jsonc.diff | 3 ++- ...enameImportAndExportInDiffFiles.baseline.jsonc | 2 +- ...ImportAndExportInDiffFiles.baseline.jsonc.diff | 3 ++- .../renameImportOfExportEquals.baseline.jsonc | 5 +++-- ...renameImportOfExportEquals.baseline.jsonc.diff | 11 ++++++++--- .../renameImportRequire.baseline.jsonc | 8 ++++---- .../renameImportRequire.baseline.jsonc.diff | 15 ++++++++++----- 11 files changed, 35 insertions(+), 24 deletions(-) diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index db870f40a6..8f099d691f 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -1037,7 +1037,7 @@ func getReferencedSymbolsForSymbol(originalSymbol *ast.Symbol, node *ast.Node, s state := newState(sourceFiles, sourceFilesSet, node, checker /*, cancellationToken*/, searchMeaning, options) var exportSpecifier *ast.Node - if isForRenameWithPrefixAndSuffixText(options) && len(symbol.Declarations) != 0 { + if !isForRenameWithPrefixAndSuffixText(options) || len(symbol.Declarations) == 0 { exportSpecifier = core.Find(symbol.Declarations, ast.IsExportSpecifier) } if exportSpecifier != nil { diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc index e93e34e686..155c542abf 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc @@ -2,5 +2,5 @@ // @useAliasesForRename: false // === /a.ts === -// const name = {}; +// const [|nameRENAME|] = {}; // export { name/*RENAME*/ }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff index c425ba1e81..2fd41bf05f 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameExportSpecifier2.baseline.jsonc.diff @@ -1,14 +1,12 @@ --- old.renameExportSpecifier2.baseline.jsonc +++ new.renameExportSpecifier2.baseline.jsonc -@@= skipped -1, +1 lines =@@ - // @useAliasesForRename: false +@@= skipped -2, +2 lines =@@ // === /a.ts === --// const [|nameRENAME|] = {}; + // const [|nameRENAME|] = {}; -// export { [|nameRENAME|]/*RENAME*/ }; - -// === /b.ts === -// import { [|nameRENAME|] } from './a'; -// const x = [|nameRENAME|].toString(); -+// const name = {}; +// export { name/*RENAME*/ }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc index b046b76ff8..f2c7a402dd 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc @@ -7,5 +7,5 @@ // === findRenameLocations === // === /renameImportAndExport.ts === -// import a from "module"; +// import [|aRENAME|] from "module"; // export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff index 4e1d8a05d1..7579be5fcf 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExport.baseline.jsonc.diff @@ -11,6 +11,7 @@ // === findRenameLocations === // === /renameImportAndExport.ts === - // import a from "module"; +-// import a from "module"; -// export { /*START PREFIX*/a as /*RENAME*/[|aRENAME|] }; ++// import [|aRENAME|] from "module"; +// export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc index 1ba8a72349..3df1b40965 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc @@ -17,5 +17,5 @@ // === findRenameLocations === // === /b.ts === -// import { a } from './a'; +// import { /*START PREFIX*/a as [|aRENAME|] } from './a'; // export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff index 59a9f21310..bbe6b24e4e 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportAndExportInDiffFiles.baseline.jsonc.diff @@ -19,6 +19,7 @@ // === findRenameLocations === // === /b.ts === - // import { a } from './a'; +-// import { a } from './a'; -// export { /*START PREFIX*/a as /*RENAME*/[|aRENAME|] }; ++// import { /*START PREFIX*/a as [|aRENAME|] } from './a'; +// export { /*RENAME*/a }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc index 757ada73a5..98bee31a7f 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc @@ -48,10 +48,11 @@ // === findRenameLocations === // === /renameImportOfExportEquals.ts === -// --- (line: 5) skipped --- +// --- (line: 4) skipped --- +// export = N; // } // declare module "a" { -// import * as N from "mod"; +// import * as [|NRENAME|] from "mod"; // export { /*RENAME*/N }; // Renaming N here would rename // } // declare module "b" { diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff index f45a3df09d..e3008bc1a8 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportOfExportEquals.baseline.jsonc.diff @@ -45,11 +45,16 @@ -@@= skipped -15, +13 lines =@@ + // === findRenameLocations === + // === /renameImportOfExportEquals.ts === +-// --- (line: 5) skipped --- ++// --- (line: 4) skipped --- ++// export = N; // } // declare module "a" { - // import * as N from "mod"; +-// import * as N from "mod"; -// export { /*START PREFIX*/N as /*RENAME*/[|NRENAME|] }; // Renaming N here would rename ++// import * as [|NRENAME|] from "mod"; +// export { /*RENAME*/N }; // Renaming N here would rename // } // declare module "b" { @@ -60,7 +65,7 @@ // } -@@= skipped -40, +40 lines =@@ +@@= skipped -55, +54 lines =@@ // } // declare module "mod" { // export = N; diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc index 4842e09142..9a6afde3d1 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc @@ -27,9 +27,9 @@ // === findRenameLocations === // === /a.ts === -// import e = require("mod4"); -// e; -// a = { e }; +// import [|eRENAME|] = require("mod4"); +// [|eRENAME|]; +// a = { /*START PREFIX*/e: [|eRENAME|] }; // export { /*RENAME*/e }; @@ -43,5 +43,5 @@ // === findRenameLocations === // === /b.ts === -// import { e } from "./a"; +// import { /*START PREFIX*/e as [|eRENAME|] } from "./a"; // export { /*RENAME*/e }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff index b56aee56a4..f7fe0c1be4 100644 --- a/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/findRenameLocations/renameImportRequire.baseline.jsonc.diff @@ -27,15 +27,19 @@ -@@= skipped -9, +9 lines =@@ - // import e = require("mod4"); - // e; - // a = { e }; + // === findRenameLocations === + // === /a.ts === +-// import e = require("mod4"); +-// e; +-// a = { e }; -// export { /*START PREFIX*/e as /*RENAME*/[|eRENAME|] }; - -// === /b.ts === -// import { [|eRENAME|] } from "./a"; -// export { [|eRENAME|] as e/*END SUFFIX*/ }; ++// import [|eRENAME|] = require("mod4"); ++// [|eRENAME|]; ++// a = { /*START PREFIX*/e: [|eRENAME|] }; +// export { /*RENAME*/e }; @@ -50,6 +54,7 @@ // === findRenameLocations === // === /b.ts === - // import { e } from "./a"; +-// import { e } from "./a"; -// export { /*START PREFIX*/e as /*RENAME*/[|eRENAME|] }; ++// import { /*START PREFIX*/e as [|eRENAME|] } from "./a"; +// export { /*RENAME*/e }; \ No newline at end of file From e9d2bd6dd2d296b8b8166f7ffb00dc37981d377a Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 17 Sep 2025 13:09:01 -0500 Subject: [PATCH 09/23] removed unused baselines --- .../getOccurrencesIfElseBroken.baseline.jsonc | 57 ----- ...OverloadedFunctionParameter.baseline.jsonc | 10 - .../FindAllReferencesLinkTag2.baseline.jsonc | 106 -------- ...cesNonExistentExportBinding.baseline.jsonc | 4 - .../FindAllRefsJsDocImportTag.baseline.jsonc | 11 - .../FindReferencesJSXTagName3.baseline.jsonc | 171 ------------- .../FindReferencesSeeTagInTs.baseline.jsonc | 8 - .../TsxFindAllReferences4.baseline.jsonc | 81 ------ ...indAllReferencesTripleSlash.baseline.jsonc | 14 -- .../FindAllRefsReExport_broken.baseline.jsonc | 12 - ...finitionExternalModuleName5.baseline.jsonc | 6 - .../GoToDefinitionMember.baseline.jsonc | 6 - .../GoToDefinitionModifiers.baseline.jsonc | 230 ------------------ 13 files changed, 716 deletions(-) delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/FindAllReferencesTripleSlash.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/FindAllRefsReExport_broken.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc deleted file mode 100644 index c1c381e16a..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc +++ /dev/null @@ -1,57 +0,0 @@ -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// /*HIGHLIGHTS*/[|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// /*HIGHLIGHTS*/[|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// /*HIGHLIGHTS*/[|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) -// else \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc deleted file mode 100644 index 643bfe6613..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesJsOverloadedFunctionParameter.baseline.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -// === findAllReferences === -// === /foo.js === - -// --- (line: 9) skipped --- -// * @param {unknown} x -// * @returns {unknown} -// */ -// function foo([|x|]/*FIND ALL REFS*/) { -// return [|x|]; -// } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc deleted file mode 100644 index f0d369461d..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesLinkTag2.baseline.jsonc +++ /dev/null @@ -1,106 +0,0 @@ -// === findAllReferences === -// === /findAllReferencesLinkTag2.ts === - -// namespace NPR { -// export class Consider { -// This = class { -// show() { } -// } -// [|m|]/*FIND ALL REFS*/() { } -// } -// /** -// * @see {Consider.prototype.m} -// // --- (line: 10) skipped --- - - - - -// === findAllReferences === -// === /findAllReferencesLinkTag2.ts === - -// namespace NPR { -// export class Consider { -// This = class { -// [|show|]/*FIND ALL REFS*/() { } -// } -// m() { } -// } -// // --- (line: 8) skipped --- - - - - -// === findAllReferences === -// === /findAllReferencesLinkTag2.ts === - -// namespace NPR { -// export class Consider { -// [|This|]/*FIND ALL REFS*/ = class { -// show() { } -// } -// m() { } -// // --- (line: 7) skipped --- - - - - -// === findAllReferences === -// === /findAllReferencesLinkTag2.ts === - -// namespace NPR { -// export class [|Consider|]/*FIND ALL REFS*/ { -// This = class { -// show() { } -// } -// m() { } -// } -// /** -// * @see {Consider.prototype.m} -// * {@link [|Consider|]#m} -// * @see {Consider#This#show} -// * {@link [|Consider|].This.show} -// * @see {NPR.Consider#This#show} -// * {@link NPR.[|Consider|].This#show} -// * @see {NPR.Consider#This.show} # doesn't parse trailing . -// * @see {NPR.Consider.This.show} -// */ -// export function ref() { } -// } -// /** -// * {@link NPR.[|Consider|]#This#show hello hello} -// * {@link NPR.[|Consider|].This#show} -// * @see {NPR.Consider#This.show} # doesn't parse trailing . -// * @see {NPR.Consider.This.show} -// */ -// export function outerref() { } - - - - -// === findAllReferences === -// === /findAllReferencesLinkTag2.ts === - -// namespace [|NPR|]/*FIND ALL REFS*/ { -// export class Consider { -// This = class { -// show() { } -// // --- (line: 5) skipped --- - - -// --- (line: 10) skipped --- -// * @see {Consider#This#show} -// * {@link Consider.This.show} -// * @see {NPR.Consider#This#show} -// * {@link [|NPR|].Consider.This#show} -// * @see {NPR.Consider#This.show} # doesn't parse trailing . -// * @see {NPR.Consider.This.show} -// */ -// export function ref() { } -// } -// /** -// * {@link [|NPR|].Consider#This#show hello hello} -// * {@link [|NPR|].Consider.This#show} -// * @see {NPR.Consider#This.show} # doesn't parse trailing . -// * @see {NPR.Consider.This.show} -// */ -// export function outerref() { } diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc deleted file mode 100644 index 39199dbee6..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllReferencesNonExistentExportBinding.baseline.jsonc +++ /dev/null @@ -1,4 +0,0 @@ -// === findAllReferences === -// === /bar.ts === - -// import { [|Foo|]/*FIND ALL REFS*/ } from "./foo"; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc deleted file mode 100644 index d2337a4dcc..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindAllRefsJsDocImportTag.baseline.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -// === findAllReferences === -// === /a.js === - -// /** -// * @import { A } from "./b"; -// */ -// -// /** -// * @param { [|A|]/*FIND ALL REFS*/ } a -// */ -// function f(a) {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc deleted file mode 100644 index cbb48095ea..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesJSXTagName3.baseline.jsonc +++ /dev/null @@ -1,171 +0,0 @@ -// === 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 -// ; diff --git a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc deleted file mode 100644 index e5279dd8e3..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/FindReferencesSeeTagInTs.baseline.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -// === findAllReferences === -// === /findReferencesSeeTagInTs.ts === - -// function [|doStuffWithStuff|]/*FIND ALL REFS*/(stuff: { quantity: number }) {} -// -// declare const stuff: { quantity: number }; -// /** @see {doStuffWithStuff} */ -// if (stuff.quantity) {} diff --git a/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc deleted file mode 100644 index 7ecfaf83ee..0000000000 --- a/testdata/baselines/reference/fourslash/findAllRef/TsxFindAllReferences4.baseline.jsonc +++ /dev/null @@ -1,81 +0,0 @@ -// === findAllReferences === -// === /file.tsx === - -// --- (line: 3) skipped --- -// } -// interface ElementAttributesProperty { props } -// } -// /*FIND ALL REFS*/class MyClass { -// props: { -// name?: string; -// size?: number; -// // --- (line: 11) skipped --- - - - - -// === findAllReferences === -// === /file.tsx === - -// --- (line: 3) skipped --- -// } -// interface ElementAttributesProperty { props } -// } -// class /*FIND ALL REFS*/[|MyClass|] { -// props: { -// name?: string; -// size?: number; -// } -// -// -// var x = <[|MyClass|] name='hello'>; - - - - -// === findAllReferences === -// === /file.tsx === - -// --- (line: 10) skipped --- -// } -// -// -// var x = /*FIND ALL REFS*/; - - - - -// === findAllReferences === -// === /file.tsx === - -// --- (line: 3) skipped --- -// } -// interface ElementAttributesProperty { props } -// } -// class [|MyClass|] { -// props: { -// name?: string; -// size?: number; -// } -// -// -// var x = ; - - - - -// === findAllReferences === -// === /file.tsx === - -// --- (line: 3) skipped --- -// } -// interface ElementAttributesProperty { props } -// } -// class [|MyClass|] { -// props: { -// name?: string; -// size?: number; -// } -// -// -// var x = <[|MyClass|] name='hello'>; diff --git a/testdata/baselines/reference/fourslash/findAllReferences/FindAllReferencesTripleSlash.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/FindAllReferencesTripleSlash.baseline.jsonc deleted file mode 100644 index ff21e68ef0..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/FindAllReferencesTripleSlash.baseline.jsonc +++ /dev/null @@ -1,14 +0,0 @@ -// === findAllReferences === -// === /a.ts === - -// /// -// /// - - - - -// === findAllReferences === -// === /a.ts === - -// /// -// /// diff --git a/testdata/baselines/reference/fourslash/findAllReferences/FindAllRefsReExport_broken.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/FindAllRefsReExport_broken.baseline.jsonc deleted file mode 100644 index 3f5ad70a2c..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/FindAllRefsReExport_broken.baseline.jsonc +++ /dev/null @@ -1,12 +0,0 @@ -// === findAllReferences === -// === /a.ts === - -// /*FIND ALL REFS*/export { x }; - - - - -// === findAllReferences === -// === /a.ts === - -// export { /*FIND ALL REFS*/x }; diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc deleted file mode 100644 index b9caefd3b2..0000000000 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionExternalModuleName5.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /a.ts === - -// declare module [|"external/*GO TO DEFINITION*/"|] { -// class Foo { } -// } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc deleted file mode 100644 index ae021631ab..0000000000 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionMember.baseline.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -// === goToDefinition === -// === /a.ts === - -// class A { -// private [|z|]/*GO TO DEFINITION*/: string; -// } diff --git a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc b/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc deleted file mode 100644 index 53a4fd0a57..0000000000 --- a/testdata/baselines/reference/fourslash/goToDef/GoToDefinitionModifiers.baseline.jsonc +++ /dev/null @@ -1,230 +0,0 @@ -// === goToDefinition === -// === /a.ts === - -// /*GO TO DEFINITION*/export class [|A|] { -// -// private z: string; -// -// // --- (line: 5) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// export class [|A|]/*GO TO DEFINITION*/ { -// -// private z: string; -// -// // --- (line: 5) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// export class A { -// -// /*GO TO DEFINITION*/private [|z|]: string; -// -// readonly x: string; -// -// // --- (line: 7) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// export class A { -// -// private [|z|]/*GO TO DEFINITION*/: string; -// -// readonly x: string; -// -// // --- (line: 7) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// export class A { -// -// private z: string; -// -// /*GO TO DEFINITION*/readonly [|x|]: string; -// -// async a() { } -// -// // --- (line: 9) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// export class A { -// -// private z: string; -// -// readonly [|x|]/*GO TO DEFINITION*/: string; -// -// async a() { } -// -// // --- (line: 9) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 3) skipped --- -// -// readonly x: string; -// -// /*GO TO DEFINITION*/async [|a|]() { } -// -// override b() {} -// -// // --- (line: 11) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 3) skipped --- -// -// readonly x: string; -// -// async [|a|]/*GO TO DEFINITION*/() { } -// -// override b() {} -// -// // --- (line: 11) skipped --- - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 5) skipped --- -// -// async a() { } -// -// /*GO TO DEFINITION*/override [|b|]() {} -// -// public async c() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 5) skipped --- -// -// async a() { } -// -// override [|b|]/*GO TO DEFINITION*/() {} -// -// public async c() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 7) skipped --- -// -// override b() {} -// -// /*GO TO DEFINITION*/public async [|c|]() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 7) skipped --- -// -// override b() {} -// -// public/*GO TO DEFINITION*/ async [|c|]() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 7) skipped --- -// -// override b() {} -// -// public as/*GO TO DEFINITION*/ync [|c|]() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 7) skipped --- -// -// override b() {} -// -// public async [|c|]/*GO TO DEFINITION*/() { } -// } -// -// export function foo() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 10) skipped --- -// public async c() { } -// } -// -// exp/*GO TO DEFINITION*/ort function [|foo|]() { } - - - - -// === goToDefinition === -// === /a.ts === - -// --- (line: 10) skipped --- -// public async c() { } -// } -// -// export function [|foo|]/*GO TO DEFINITION*/() { } From 45cd07b0e9e76b5e69db0a13fc828e5a370fe5bc Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 18 Sep 2025 16:28:46 -0500 Subject: [PATCH 10/23] removed repeated test --- .../fourslash/tests/documentHighlight_test.go | 19 ---------- .../documentHighlights.baseline.jsonc | 37 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 internal/fourslash/tests/documentHighlight_test.go delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc diff --git a/internal/fourslash/tests/documentHighlight_test.go b/internal/fourslash/tests/documentHighlight_test.go deleted file mode 100644 index ef7b6a66e2..0000000000 --- a/internal/fourslash/tests/documentHighlight_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package fourslash - -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(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/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc deleted file mode 100644 index ac0a558f1c..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/documentHighlights.baseline.jsonc +++ /dev/null @@ -1,37 +0,0 @@ -// === documentHighlights === -// === /documentHighlights.ts === -// /*HIGHLIGHTS*/function f(x: typeof f) { -// f(f); -// } - - - -// === documentHighlights === -// === /documentHighlights.ts === -// function /*HIGHLIGHTS*/[|f|](x: typeof [|f|]) { -// [|f|]([|f|]); -// } - - - -// === documentHighlights === -// === /documentHighlights.ts === -// function [|f|](x: typeof /*HIGHLIGHTS*/[|f|]) { -// [|f|]([|f|]); -// } - - - -// === documentHighlights === -// === /documentHighlights.ts === -// function [|f|](x: typeof [|f|]) { -// /*HIGHLIGHTS*/[|f|]([|f|]); -// } - - - -// === documentHighlights === -// === /documentHighlights.ts === -// function [|f|](x: typeof [|f|]) { -// [|f|](/*HIGHLIGHTS*/[|f|]); -// } \ No newline at end of file From 48e31633aa91a2d0fadda91f4463a3448e5fc4e8 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 18 Sep 2025 16:32:05 -0500 Subject: [PATCH 11/23] fixed var declaration and nil checking nits --- internal/ls/documenthighlights.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 3111c1e9a3..99fa3ebaff 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -21,7 +21,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen node := astnav.GetTouchingPropertyName(sourceFile, position) if node.Parent.Kind == ast.KindJsxOpeningElement || (node.Parent.Kind == ast.KindJsxClosingElement && node.Parent.TagName() == node) { - documentHighlights := []*lsproto.DocumentHighlight{} + var documentHighlights []*lsproto.DocumentHighlight kind := lsproto.DocumentHighlightKindRead if node.Parent.Kind == ast.KindJsxOpeningElement { documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ @@ -41,7 +41,7 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen } documentHighlights := l.getSemanticDocumentHighlights(ctx, position, node, program, sourceFile) - if documentHighlights == nil { + if len(documentHighlights) == 0 { documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile) } // if nil is passed here we never generate an error, just pass an empty higlight @@ -173,7 +173,7 @@ func (l *LanguageService) highlightSpans(nodes []*ast.Node, sourceFile *ast.Sour 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 { - symbolDecls := []*ast.Node{} + var symbolDecls []*ast.Node if ast.CanHaveSymbol(decl) { symbol := decl.Symbol() if ast.CanHaveSymbol(decl) && symbol != nil && symbol.Declarations != nil { From 318a6f797059b363ac9ef679ac7119b913691ddb Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 18 Sep 2025 16:48:14 -0500 Subject: [PATCH 12/23] moved isWriteAccess and helpers from checker to ast --- internal/ast/ast.go | 85 +++++++++++++++++++++++++++++++ internal/checker/checker.go | 14 ++--- internal/checker/utilities.go | 85 ------------------------------- internal/ls/documenthighlights.go | 3 +- 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index ac58bde2d2..699186afc2 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -2188,6 +2188,91 @@ type ( JsxAttributeList = NodeList // NodeList[*JsxAttributeLike] ) +func IsWriteOnlyAccess(node *Node) bool { + return accessKind(node) == AccessKindWrite +} + +func IsWriteAccess(node *Node) bool { + return accessKind(node) != AccessKindRead +} + +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 { diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 30354b93f1..d41a643def 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) @@ -13280,7 +13280,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) } @@ -15715,9 +15715,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) @@ -15735,7 +15735,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) } } @@ -26707,7 +26707,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/utilities.go b/internal/checker/utilities.go index ba59c5bf8c..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/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 99fa3ebaff..83717445d9 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -5,7 +5,6 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" - "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/lsutil" @@ -82,7 +81,7 @@ func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *l } // Determine write access for node references. - if checker.IsWriteAccess(entry.node) { + if ast.IsWriteAccess(entry.node) { kind = lsproto.DocumentHighlightKindWrite } From 2d661ce38e50ca3f536fe4de1f0721c35bbbdc81 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Mon, 22 Sep 2025 11:02:01 -0500 Subject: [PATCH 13/23] refactored renameArg and docHighlightArg into markerOrRangeArg --- .../fourslash/_scripts/convertFourslash.mts | 57 ++----------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 281a1f0ecd..407bdeca3c 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -787,7 +787,7 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V let strArg; if (strArg = getArrayLiteralExpression(arg)) { for (const elem of strArg.elements) { - const newArg = parseBaselineDocumentHighlightsArg(elem); + const newArg = parseBaselineMarkerOrRangeArg(elem); if (!newArg) { return undefined; } @@ -797,7 +797,7 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V else if (ts.isObjectLiteralExpression(arg)) { // User preferences case, but multiple files isn't implemented in corsa yet } - else if (strArg = parseBaselineDocumentHighlightsArg(arg)) { + else if (strArg = parseBaselineMarkerOrRangeArg(arg)) { newArgs.push(strArg); } else { @@ -817,53 +817,6 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V }]; } -function parseBaselineDocumentHighlightsArg(arg: ts.Expression): string | undefined { - if (ts.isStringLiteral(arg)) { - return getGoStringLiteral(arg.text); - } - else if (ts.isIdentifier(arg) || (ts.isElementAccessExpression(arg) && ts.isIdentifier(arg.expression))) { - const argName = ts.isIdentifier(arg) ? arg.text : (arg.expression as ts.Identifier).text; - const file = arg.getSourceFile(); - const varStmts = file.statements.filter(ts.isVariableStatement); - for (const varStmt of varStmts) { - for (const decl of varStmt.declarationList.declarations) { - if (ts.isArrayBindingPattern(decl.name) && decl.initializer?.getText().includes("ranges")) { - for (let i = 0; i < decl.name.elements.length; i++) { - const elem = decl.name.elements[i]; - if (ts.isBindingElement(elem) && ts.isIdentifier(elem.name) && elem.name.text === argName) { - // `const [range_0, ..., range_n, ...] = test.ranges();` and arg is `range_n` - if (elem.dotDotDotToken === undefined) { - return `f.Ranges()[${i}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest[n]` - if (ts.isElementAccessExpression(arg)) { - return `f.Ranges()[${i + parseInt(arg.argumentExpression!.getText())}]`; - } - // `const [range_0, ..., ...rest] = test.ranges();` and arg is `rest` - return `ToAny(f.Ranges()[${i}:])...`; - } - } - } - } - } - const init = getNodeOfKind(arg, ts.isCallExpression); - if (init) { - const result = getRangesByTextArg(init); - if (result) { - return result; - } - } - } - else if (ts.isCallExpression(arg)) { - const result = getRangesByTextArg(arg); - if (result) { - return result; - } - } - console.error(`Unrecognized argument in verify.baselineRename: ${arg.getText()}`); - return undefined; -} - function parseBaselineGoToDefinitionArgs(args: readonly ts.Expression[]): [VerifyBaselineGoToDefinitionCmd] | undefined { const newArgs = []; for (const arg of args) { @@ -929,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; } @@ -944,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 { @@ -982,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); } From 508be4de3f661ad20ed77ce23e2b0276115c2206 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Mon, 22 Sep 2025 11:46:45 -0500 Subject: [PATCH 14/23] fixed jsx case handling --- internal/ls/documenthighlights.go | 15 +++++++---- .../findReferencesJSXTagName3.baseline.jsonc | 26 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 83717445d9..0e516efff9 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -19,18 +19,23 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen position := int(l.converters.LineAndCharacterToPosition(sourceFile, documentPosition)) node := astnav.GetTouchingPropertyName(sourceFile, position) - if node.Parent.Kind == ast.KindJsxOpeningElement || (node.Parent.Kind == ast.KindJsxClosingElement && node.Parent.TagName() == node) { + if node.Parent != nil && (node.Parent.Kind == ast.KindJsxClosingElement || (node.Parent.Kind == ast.KindJsxOpeningElement && node.Parent.TagName() == node)) { var documentHighlights []*lsproto.DocumentHighlight + var openingElement, closingElement *ast.Node kind := lsproto.DocumentHighlightKindRead - if node.Parent.Kind == ast.KindJsxOpeningElement { + if ast.IsJsxElement(node.Parent.Parent) { + openingElement = node.Parent.Parent.AsJsxElement().OpeningElement + closingElement = node.Parent.Parent.AsJsxElement().ClosingElement + } + if openingElement != nil { documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ - Range: *l.createLspRangeFromNode(node.Parent, sourceFile), + Range: *l.createLspRangeFromNode(openingElement, sourceFile), Kind: &kind, }) } - if node.Parent.Kind == ast.KindJsxClosingElement { + if closingElement != nil { documentHighlights = append(documentHighlights, &lsproto.DocumentHighlight{ - Range: *l.createLspRangeFromNode(node.Parent, sourceFile), + Range: *l.createLspRangeFromNode(closingElement, sourceFile), Kind: &kind, }) } diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc index ac702db577..e2ffbc30f3 100644 --- a/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/documentHighlights/findReferencesJSXTagName3.baseline.jsonc @@ -28,8 +28,11 @@ // [||] // Some content //
More content
-//
; -// // --- (line: 13) skipped --- +// [||]; +// +// const x = +// Content +// ; @@ -39,7 +42,7 @@ // const Comp = () => //
// Some content -// [||]More content
+// [||]More content[||] // ; // // const x = @@ -54,7 +57,7 @@ // const Comp = () => //
// Some content -//
More content[||] +// [|
|]More content[||] //
; // // const x = @@ -65,8 +68,11 @@ // === documentHighlights === // === /a.tsx === -// --- (line: 8) skipped --- -//
+// --- (line: 5) skipped --- +// } +// +// const Comp = () => +// [|
|] // Some content //
More content
// [||]; @@ -103,14 +109,16 @@ // // const x = [||] // Content -// ; +// [||]; // === documentHighlights === // === /a.tsx === -// --- (line: 12) skipped --- +// --- (line: 10) skipped --- +//
More content
+//
; // -// const x = +// const x = [||] // Content // [||]; \ No newline at end of file From 9b512a5a3b2691fd1ee1fac60580fb6a22826eb9 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:16:48 -0400 Subject: [PATCH 15/23] added isWriteAccessForReference logic --- internal/ast/ast.go | 153 ++++++++++++++++++++++++++++++ internal/checker/services.go | 26 +---- internal/ls/documenthighlights.go | 2 +- internal/ls/findallreferences.go | 2 +- internal/ls/utilities.go | 26 ----- 5 files changed, 156 insertions(+), 53 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 699186afc2..6aa647cdf1 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -2196,6 +2196,159 @@ 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 { 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/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 0e516efff9..1b6596678b 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -86,7 +86,7 @@ func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *l } // Determine write access for node references. - if ast.IsWriteAccess(entry.node) { + if ast.IsWriteAccessForReference(entry.node) { kind = lsproto.DocumentHighlightKindWrite } diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 8f099d691f..3556461e02 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) })) 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 } From ea32d431f41ed6e3beb0483fb672914260837584 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 24 Sep 2025 14:32:31 -0400 Subject: [PATCH 16/23] cleaned up comments --- internal/fourslash/_scripts/convertFourslash.mts | 2 +- internal/ls/documenthighlights.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 407bdeca3c..a131e17b5a 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -795,7 +795,7 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V } } else if (ts.isObjectLiteralExpression(arg)) { - // User preferences case, but multiple files isn't implemented in corsa yet + // !! todo when multiple files supported in lsp } else if (strArg = parseBaselineMarkerOrRangeArg(arg)) { newArgs.push(strArg); diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 1b6596678b..bdf10d09d3 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -76,8 +76,7 @@ func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, pos func (l *LanguageService) toDocumentHighlight(entry *referenceEntry) (string, *lsproto.DocumentHighlight) { entry = l.resolveEntry(entry) - // If this is a plain range (Span), always treat it as a reference. - kind := lsproto.DocumentHighlightKindText + kind := lsproto.DocumentHighlightKindRead if entry.kind == entryKindRange { return entry.fileName, &lsproto.DocumentHighlight{ Range: *entry.textRange, From d446a936a4aed3d25937d4d70201fc6bb2f290cc Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:03:26 -0400 Subject: [PATCH 17/23] documenthighlights.go code and comment cleanup --- internal/ls/documenthighlights.go | 114 +++++++++++------------------- 1 file changed, 43 insertions(+), 71 deletions(-) diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index bdf10d09d3..2563f64206 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -20,13 +20,13 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen node := astnav.GetTouchingPropertyName(sourceFile, position) if node.Parent != nil && (node.Parent.Kind == ast.KindJsxClosingElement || (node.Parent.Kind == ast.KindJsxOpeningElement && node.Parent.TagName() == node)) { - var documentHighlights []*lsproto.DocumentHighlight var openingElement, closingElement *ast.Node - kind := lsproto.DocumentHighlightKindRead 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), @@ -53,13 +53,13 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen } func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, position int, node *ast.Node, program *compiler.Program, sourceFile *ast.SourceFile) []*lsproto.DocumentHighlight { - var highlights []*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 { @@ -101,8 +101,7 @@ func (l *LanguageService) getSyntacticDocumentHighlights(node *ast.Node, sourceF switch node.Kind { case ast.KindIfKeyword, ast.KindElseKeyword: if ast.IsIfStatement(node.Parent) { - result := l.getIfElseOccurrences(node.Parent.AsIfStatement(), sourceFile) - return result + return l.getIfElseOccurrences(node.Parent.AsIfStatement(), sourceFile) } return nil case ast.KindReturnKeyword: @@ -178,8 +177,7 @@ func (l *LanguageService) getFromAllDeclarations(nodeTest func(*ast.Node) bool, return l.useParent(node.Parent, nodeTest, func(decl *ast.Node, sf *ast.SourceFile) []*ast.Node { var symbolDecls []*ast.Node if ast.CanHaveSymbol(decl) { - symbol := decl.Symbol() - if ast.CanHaveSymbol(decl) && symbol != nil && symbol.Declarations != nil { + if symbol := decl.Symbol(); symbol != nil { for _, d := range symbol.Declarations { if nodeTest(d) { outer: @@ -242,14 +240,14 @@ func (l *LanguageService) getIfElseOccurrences(ifStatement *ast.IfStatement, sou } func getIfElseKeywords(ifStatement *ast.IfStatement, sourceFile *ast.SourceFile) []*ast.Node { - var keywords []*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) @@ -306,17 +304,17 @@ func aggregateOwnedThrowStatements(node *ast.Node, sourceFile *ast.SourceFile) [ return []*ast.Node{node} } if ast.IsTryStatement(node) { - var result []*ast.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 = append(result, aggregateOwnedThrowStatements(catchClause, sourceFile)...) + result = aggregateOwnedThrowStatements(catchClause, sourceFile) } else if tryBlock != nil { - result = append(result, aggregateOwnedThrowStatements(tryBlock, sourceFile)...) + result = aggregateOwnedThrowStatements(tryBlock, sourceFile) } if finallyBlock != nil { result = append(result, aggregateOwnedThrowStatements(finallyBlock, sourceFile)...) @@ -332,6 +330,7 @@ func aggregateOwnedThrowStatements(node *ast.Node, sourceFile *ast.SourceFile) [ 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 { @@ -359,7 +358,8 @@ func getThrowOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node } } - // If the owner is a function block, also include return keywords. + // 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) @@ -373,6 +373,9 @@ func getThrowOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node 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 { @@ -397,9 +400,9 @@ func getThrowStatementOwner(throwStatement *ast.Node) *ast.Node { } func getTryCatchFinallyOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { - var keywords []*ast.Node tryStatement := node.AsTryStatement() + var keywords []*ast.Node token := lsutil.GetFirstToken(node, sourceFile) if token.Kind == ast.KindTryKeyword { keywords = append(keywords, token) @@ -423,9 +426,9 @@ func getTryCatchFinallyOccurrences(node *ast.Node, sourceFile *ast.SourceFile) [ } func getSwitchCaseDefaultOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { - var keywords []*ast.Node switchStatement := node.AsSwitchStatement() + var keywords []*ast.Node token := lsutil.GetFirstToken(node, sourceFile) if token.Kind == ast.KindSwitchKeyword { keywords = append(keywords, token) @@ -440,7 +443,7 @@ func getSwitchCaseDefaultOccurrences(node *ast.Node, sourceFile *ast.SourceFile) breakAndContinueStatements := aggregateAllBreakAndContinueStatements(clause, sourceFile) for _, statement := range breakAndContinueStatements { - if ownsBreakOrContinueStatement(switchStatement.AsNode(), statement) && statement.Kind == ast.KindBreakStatement { + if statement.Kind == ast.KindBreakStatement && ownsBreakOrContinueStatement(switchStatement.AsNode(), statement) { keywords = append(keywords, lsutil.GetFirstToken(statement, sourceFile)) } } @@ -454,7 +457,7 @@ func aggregateAllBreakAndContinueStatements(node *ast.Node, sourceFile *ast.Sour return []*ast.Node{node} } if ast.IsFunctionLike(node) { - return []*ast.Node{} + return nil } return flatMapChildren(node, sourceFile, aggregateAllBreakAndContinueStatements) } @@ -468,14 +471,12 @@ func ownsBreakOrContinueStatement(owner *ast.Node, statement *ast.Node) bool { } func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { - // Walk up ancestors to find the owner 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 } - // falls through fallthrough case ast.KindForStatement, ast.KindForInStatement, @@ -497,7 +498,8 @@ func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { }) } -// Helper function to check if a node is labeled by a given label name. +// 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) { @@ -511,8 +513,7 @@ func isLabeledBy(node *ast.Node, labelName string) bool { } func getBreakOrContinueStatementOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { - owner := getBreakOrContinueOwner(node) - if owner != nil { + if owner := getBreakOrContinueOwner(node); owner != nil { switch owner.Kind { case ast.KindForStatement, ast.KindForInStatement, ast.KindForOfStatement, ast.KindDoStatement, ast.KindWhileStatement: return getLoopBreakContinueOccurrences(owner, sourceFile) @@ -558,9 +559,10 @@ func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []* } var keywords []*ast.Node - modifiers := parentFunc.Modifiers().Nodes - if len(modifiers) != 0 { - for _, modifier := range modifiers { + + modifiers := parentFunc.Modifiers() + if modifiers != nil { + for _, modifier := range modifiers.Nodes { if modifier.Kind == ast.KindAsyncKeyword { keywords = append(keywords, modifier) } @@ -582,13 +584,14 @@ func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []* return keywords } -func getYieldOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { /* TODO */ +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) { @@ -614,10 +617,10 @@ func traverseWithoutCrossingFunction(node *ast.Node, sourceFile *ast.SourceFile, } } -func getModifierOccurrences(kind ast.Kind, node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { /* TODO */ +func getModifierOccurrences(kind ast.Kind, node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { var result []*ast.Node - nodesToSearch := getNodesToSearchForModifier(node, modifierToFlag(kind)) + nodesToSearch := getNodesToSearchForModifier(node, ast.ModifierToFlag(kind)) for _, n := range nodesToSearch { modifier := findModifier(n, kind) if modifier != nil { @@ -635,14 +638,14 @@ func getNodesToSearchForModifier(declaration *ast.Node, modifierFlag ast.Modifie return nil } + // Types of node whose children might have modifiers. switch container.Kind { case ast.KindModuleBlock, ast.KindSourceFile, ast.KindBlock, ast.KindCaseClause, ast.KindDefaultClause: - // If abstract modifier and class declaration, include members and the declaration itself + // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag&ast.ModifierFlagsAbstract) != 0 && ast.IsClassDeclaration(declaration) { - result = append(result, declaration) - result = append(result, declaration.Members()...) + return append(append(result, declaration.Members()...), declaration) } else { - result = append(result, container.Statements()...) + return append(result, container.Statements()...) } case ast.KindConstructor, ast.KindMethodDeclaration, ast.KindFunctionDeclaration: // Parameters and, if inside a class, also class members @@ -650,10 +653,15 @@ func getNodesToSearchForModifier(declaration *ast.Node, modifierFlag ast.Modifie 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 @@ -661,57 +669,21 @@ func getNodesToSearchForModifier(declaration *ast.Node, modifierFlag ast.Modifie } } if constructor != nil { - result = append(result, nodes...) result = append(result, constructor.Parameters()...) - } else { - result = append(result, nodes...) } } else if (modifierFlag & ast.ModifierFlagsAbstract) != 0 { - result = append(result, nodes...) result = append(result, container) - } else { - result = append(result, nodes...) } + return result default: // Syntactically invalid positions or unsupported containers return nil } - - return result -} - -func modifierToFlag(kind ast.Kind) ast.ModifierFlags { - switch kind { - case ast.KindPublicKeyword: - return ast.ModifierFlagsPublic - case ast.KindPrivateKeyword: - return ast.ModifierFlagsPrivate - case ast.KindProtectedKeyword: - return ast.ModifierFlagsProtected - case ast.KindStaticKeyword: - return ast.ModifierFlagsStatic - case ast.KindReadonlyKeyword: - return ast.ModifierFlagsReadonly - case ast.KindAbstractKeyword: - return ast.ModifierFlagsAbstract - case ast.KindExportKeyword: - return ast.ModifierFlagsExport - case ast.KindDeclareKeyword: - return ast.ModifierFlagsAmbient - case ast.KindDefaultKeyword: - return ast.ModifierFlagsDefault - case ast.KindConstKeyword: - return ast.ModifierFlagsConst - case ast.KindAsyncKeyword: - return ast.ModifierFlagsAsync - default: - return ast.ModifierFlagsNone - } } func findModifier(node *ast.Node, kind ast.Kind) *ast.Node { - if ast.CanHaveModifiers(node) && node.Modifiers() != nil { - for _, modifier := range node.Modifiers().Nodes { + if modifiers := node.Modifiers(); modifiers != nil { + for _, modifier := range modifiers.Nodes { if modifier.Kind == kind { return modifier } From 1dcecaffb0284251f153457e046dfc8da1da8a06 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:19:11 -0400 Subject: [PATCH 18/23] Update internal/fourslash/_scripts/convertFourslash.mts Co-authored-by: Isabel Duan --- internal/fourslash/_scripts/convertFourslash.mts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index a131e17b5a..86c547d5c1 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -795,7 +795,8 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V } } else if (ts.isObjectLiteralExpression(arg)) { - // !! todo when multiple files supported in lsp + // !!! todo when multiple files supported in lsp + } else if (strArg = parseBaselineMarkerOrRangeArg(arg)) { newArgs.push(strArg); From 0ec6d31f920f7c7d5df3219fd8be37add6b69919 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Wed, 24 Sep 2025 17:27:22 -0400 Subject: [PATCH 19/23] removed extraneous newline --- internal/fourslash/_scripts/convertFourslash.mts | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 86c547d5c1..919d72b777 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -796,7 +796,6 @@ function parseBaselineDocumentHighlightsArgs(args: readonly ts.Expression[]): [V } else if (ts.isObjectLiteralExpression(arg)) { // !!! todo when multiple files supported in lsp - } else if (strArg = parseBaselineMarkerOrRangeArg(arg)) { newArgs.push(strArg); From 2dd55880dbd5d432f9905a2d71a433d5d21cc656 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:21:40 -0400 Subject: [PATCH 20/23] minor test fix --- internal/fourslash/_scripts/failingTests.txt | 1 - .../tests/gen/getOccurrencesAsyncAwait3_test.go | 2 +- internal/ls/documenthighlights.go | 9 +++------ .../getOccurrencesAsyncAwait3.baseline.jsonc | 6 ++++++ 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesAsyncAwait3.baseline.jsonc diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index e712c8e33d..278f859e52 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -209,7 +209,6 @@ TestGetJavaScriptQuickInfo6 TestGetJavaScriptQuickInfo7 TestGetJavaScriptQuickInfo8 TestGetJavaScriptSyntacticDiagnostics24 -TestGetOccurrencesAsyncAwait3 TestGetOccurrencesClassExpressionConstructor TestGetOccurrencesConstructor TestGetOccurrencesConstructor2 diff --git a/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go index 33f8d1dbb8..018d7214d7 100644 --- a/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go +++ b/internal/fourslash/tests/gen/getOccurrencesAsyncAwait3_test.go @@ -9,7 +9,7 @@ import ( func TestGetOccurrencesAsyncAwait3(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `a/**/wait 100; async function f() { diff --git a/internal/ls/documenthighlights.go b/internal/ls/documenthighlights.go index 2563f64206..8469c0935d 100644 --- a/internal/ls/documenthighlights.go +++ b/internal/ls/documenthighlights.go @@ -18,7 +18,6 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen 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) { @@ -43,7 +42,6 @@ func (l *LanguageService) ProvideDocumentHighlights(ctx context.Context, documen DocumentHighlights: &documentHighlights, }, nil } - documentHighlights := l.getSemanticDocumentHighlights(ctx, position, node, program, sourceFile) if len(documentHighlights) == 0 { documentHighlights = l.getSyntacticDocumentHighlights(node, sourceFile) @@ -58,7 +56,6 @@ func (l *LanguageService) getSemanticDocumentHighlights(ctx context.Context, pos if referenceEntries == nil { return nil } - var highlights []*lsproto.DocumentHighlight for _, entry := range referenceEntries { for _, ref := range entry.references { @@ -553,11 +550,11 @@ func getLoopBreakContinueOccurrences(node *ast.Node, sourceFile *ast.SourceFile) } func getAsyncAndAwaitOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node { - parentFunc := ast.FindAncestor(node.Parent, ast.IsFunctionLike).AsFunctionDeclaration() - if parentFunc == nil { + parent := ast.FindAncestor(node.Parent, ast.IsFunctionLike) + if parent == nil { return nil } - + parentFunc := parent.AsFunctionDeclaration() var keywords []*ast.Node modifiers := parentFunc.Modifiers() 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 From f8c43e107f21b2eb8b823d69e1942ec4fd9515c1 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:15:36 -0400 Subject: [PATCH 21/23] fixed out of bounds in findReferencedSymbolsForNode --- internal/fourslash/_scripts/failingTests.txt | 1 - ...dName_import-declaration-with-variable-entity-names_test.go | 2 +- internal/ls/findallreferences.go | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 278f859e52..01fba7165e 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -345,7 +345,6 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto -TestQualifiedName_import_declaration_with_variable_entity_names TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 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 index bc4c7a1445..6acc245a7b 100644 --- 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 @@ -11,7 +11,7 @@ import ( 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; diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index 3556461e02..256da67860 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -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 { From e903fae47103e408a703601108eab8ad73f85c6b Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:18:20 -0400 Subject: [PATCH 22/23] reupdated failing tests --- internal/fourslash/_scripts/failingTests.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 01fba7165e..278f859e52 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -345,6 +345,7 @@ TestPathCompletionsTypesVersionsWildcard4 TestPathCompletionsTypesVersionsWildcard5 TestPathCompletionsTypesVersionsWildcard6 TestProtoVarVisibleWithOuterScopeUnderscoreProto +TestQualifiedName_import_declaration_with_variable_entity_names TestQuickInfoAlias TestQuickInfoAssertionNodeNotReusedWhenTypeNotEquivalent1 TestQuickInfoBindingPatternInJsdocNoCrash1 From 016ab912cba6fe90a060832d3f35b1b29b1da898 Mon Sep 17 00:00:00 2001 From: John Favret <64748847+johnfav03@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:27:07 -0400 Subject: [PATCH 23/23] fixed ci check for convertfourslash --- ...edName_import-declaration-with-variable-entity-names_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 6acc245a7b..bc4c7a1445 100644 --- 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 @@ -11,7 +11,7 @@ import ( 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;