Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/ls/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -1647,20 +1647,24 @@ func getContainingObjectLiteralElementWorker(node *ast.Node) *ast.Node {
switch node.Kind {
case ast.KindStringLiteral, ast.KindNoSubstitutionTemplateLiteral, ast.KindNumericLiteral:
if node.Parent.Kind == ast.KindComputedPropertyName {
if ast.IsObjectLiteralElement(node.Parent.Parent) {
if isObjectLiteralOrJsxElement(node.Parent.Parent) {
return node.Parent.Parent
}
return nil
}
fallthrough
case ast.KindIdentifier:
if ast.IsObjectLiteralElement(node.Parent) && (node.Parent.Parent.Kind == ast.KindObjectLiteralExpression || node.Parent.Parent.Kind == ast.KindJsxAttributes) && node.Parent.Name() == node {
if isObjectLiteralOrJsxElement(node.Parent) && (node.Parent.Parent.Kind == ast.KindObjectLiteralExpression || node.Parent.Parent.Kind == ast.KindJsxAttributes) && node.Parent.Name() == node {
return node.Parent
}
}
return nil
}

func isObjectLiteralOrJsxElement(node *ast.Node) bool {
return ast.IsObjectLiteralElement(node) || ast.IsJsxAttribute(node) || ast.IsJsxSpreadAttribute(node)
}

// Return a function that returns true if the given node has not been seen
func nodeSeenTracker() func(*ast.Node) bool {
var seen collections.Set[*ast.Node]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@
// }
// interface LinkProps extends ClickableProps {
// goTo: string;
// // --- (line: 16) skipped ---
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton [|onClick|]={()=>{}} />;
// let opt = <MainButton [|onClick|]={()=>{}} ignore-prop />;
// let opt = <MainButton goTo="goTo" />;
// let opt = <MainButton wrong />;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
// isOpen?: boolean;
// };
// span: { n: string; };
// // --- (line: 9) skipped ---
// }
// }
// var x = <div [|name|]="hello" />;
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// }
//
//
// var x = <MyClass name='hello'/>;
// var x = <MyClass [|name|]='hello'/>;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
// propString: string
// optional?: boolean
// }
// // --- (line: 12) skipped ---
// declare function Opt(attributes: OptionPropBag): JSX.Element;
// let opt = <Opt />;
// let opt1 = <Opt [|propx|]={100} propString />;
// let opt2 = <Opt [|propx|]={100} optional/>;
// let opt3 = <Opt wrong />;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// // --- (line: 19) skipped ---
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton onClick={()=>{}} />;
// let opt = <MainButton onClick={()=>{}} ignore-prop />;
// let opt = <MainButton [|goTo|]="goTo" />;
// let opt = <MainButton [|goTo|] />;
// let opt = <MainButton wrong />;
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@
// isOpen?: boolean;
// };
// span: { n: string; };
// // --- (line: 9) skipped ---
// }
// }
// var x = <div [|nameRENAME|]="hello" />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 7) skipped ---
// declare module JSX {
// interface Element { }
// interface IntrinsicElements {
// div: {
// [|nameRENAME|]?: string;
// isOpen?: boolean;
// };
// span: { n: string; };
// }
// }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
// }
//
//
// var x = <MyClass name='hello'/>;
// var x = <MyClass [|nameRENAME|]='hello'/>;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 10) skipped ---
// --- (line: 5) skipped ---
// }
// class MyClass {
// props: {
// [|nameRENAME|]?: string;
// size?: number;
// }
//
//
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,44 @@
// propString: string
// optional?: boolean
// }
// // --- (line: 12) skipped ---
// declare function Opt(attributes: OptionPropBag): JSX.Element;
// let opt = <Opt />;
// let opt1 = <Opt [|propxRENAME|]={100} propString />;
// let opt2 = <Opt [|propxRENAME|]={100} optional/>;
// let opt3 = <Opt wrong />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 10) skipped ---
// --- (line: 4) skipped ---
// interface ElementAttributesProperty { props; }
// }
// interface OptionPropBag {
// [|propxRENAME|]: number
// propString: string
// optional?: boolean
// }
// declare function Opt(attributes: OptionPropBag): JSX.Element;
// let opt = <Opt />;
// let opt1 = <Opt /*RENAME*/[|propxRENAME|]={100} propString />;
// let opt2 = <Opt propx={100} optional/>;
// let opt2 = <Opt [|propxRENAME|]={100} optional/>;
// let opt3 = <Opt wrong />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 11) skipped ---
// --- (line: 4) skipped ---
// interface ElementAttributesProperty { props; }
// }
// interface OptionPropBag {
// [|propxRENAME|]: number
// propString: string
// optional?: boolean
// }
// declare function Opt(attributes: OptionPropBag): JSX.Element;
// let opt = <Opt />;
// let opt1 = <Opt propx={100} propString />;
// let opt1 = <Opt [|propxRENAME|]={100} propString />;
// let opt2 = <Opt /*RENAME*/[|propxRENAME|]={100} optional/>;
// let opt3 = <Opt wrong />;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,59 @@
// }
// interface LinkProps extends ClickableProps {
// goTo: string;
// // --- (line: 16) skipped ---
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton [|onClickRENAME|]={()=>{}} />;
// let opt = <MainButton [|onClickRENAME|]={()=>{}} ignore-prop />;
// let opt = <MainButton goTo="goTo" />;
// let opt = <MainButton wrong />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 18) skipped ---
// --- (line: 8) skipped ---
// className?: string;
// }
// interface ButtonProps extends ClickableProps {
// [|onClickRENAME|](event?: React.MouseEvent<HTMLButtonElement>): void;
// }
// interface LinkProps extends ClickableProps {
// goTo: string;
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton /*RENAME*/[|onClickRENAME|]={()=>{}} />;
// let opt = <MainButton onClick={()=>{}} ignore-prop />;
// let opt = <MainButton [|onClickRENAME|]={()=>{}} ignore-prop />;
// let opt = <MainButton goTo="goTo" />;
// let opt = <MainButton wrong />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 19) skipped ---
// --- (line: 8) skipped ---
// className?: string;
// }
// interface ButtonProps extends ClickableProps {
// [|onClickRENAME|](event?: React.MouseEvent<HTMLButtonElement>): void;
// }
// interface LinkProps extends ClickableProps {
// goTo: string;
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton onClick={()=>{}} />;
// let opt = <MainButton [|onClickRENAME|]={()=>{}} />;
// let opt = <MainButton /*RENAME*/[|onClickRENAME|]={()=>{}} ignore-prop />;
// let opt = <MainButton goTo="goTo" />;
// let opt = <MainButton wrong />;
Expand All @@ -47,13 +77,28 @@
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// // --- (line: 19) skipped ---
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton onClick={()=>{}} />;
// let opt = <MainButton onClick={()=>{}} ignore-prop />;
// let opt = <MainButton [|goToRENAME|]="goTo" />;
// let opt = <MainButton wrong />;



// === findRenameLocations ===
// === /file.tsx ===
// --- (line: 20) skipped ---
// --- (line: 11) skipped ---
// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
// }
// interface LinkProps extends ClickableProps {
// [|goToRENAME|]: string;
// }
// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
// declare function MainButton(linkProps: LinkProps): JSX.Element;
// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
// let opt = <MainButton />;
// let opt = <MainButton children="chidlren" />;
// let opt = <MainButton onClick={()=>{}} />;
// let opt = <MainButton onClick={()=>{}} ignore-prop />;
Expand Down
Loading