Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Command vscode.executeDocumentSymbolProvider Incomplete Parsing #58915

Open
yyx1111 opened this issue Jun 18, 2024 · 4 comments
Open

Command vscode.executeDocumentSymbolProvider Incomplete Parsing #58915

yyx1111 opened this issue Jun 18, 2024 · 4 comments
Assignees
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@yyx1111
Copy link

yyx1111 commented Jun 18, 2024

A case was found that could not be parsed in its entirety:
A d.ts of typescript, path \node_modules\typescript\lib\lib.es5.d.ts.
The last ‘interface Date’ is parsed incorrectly, and a subset of this interface is not parsed either.

steps to reproduce:

  1. npm i typescript -S
  2. open file "\node_modules\typescript\lib\lib.es5.d.ts"
  3. open outline view, Scroll down to the end
  4. Final "Data" has no children

abc

@jrieken jrieken assigned mjbvz and unassigned jrieken Jun 18, 2024
@mjbvz mjbvz transferred this issue from microsoft/vscode Jun 18, 2024
@mjbvz mjbvz removed their assignment Jun 18, 2024
@RyanCavanaugh
Copy link
Member

Simpler repro that's demonstrative

interface Foo {
    bar(): void;
}
interface Baz { }

interface Foo {
    bar(s?: string): void;
}

image

{
    "seq": 0,
    "type": "response",
    "command": "navtree",
    "request_seq": 22,
    "success": true,
    "body": {
        "text": "<global>",
        "kind": "script",
        "kindModifiers": "",
        "spans": [
            {
                "start": {
                    "line": 1,
                    "offset": 1
                },
                "end": {
                    "line": 8,
                    "offset": 4
                }
            }
        ],
        "childItems": [
            {
                "text": "Baz",
                "kind": "interface",
                "kindModifiers": "",
                "spans": [
                    {
                        "start": {
                            "line": 4,
                            "offset": 1
                        },
                        "end": {
                            "line": 4,
                            "offset": 18
                        }
                    }
                ],
                "nameSpan": {
                    "start": {
                        "line": 4,
                        "offset": 11
                    },
                    "end": {
                        "line": 4,
                        "offset": 14
                    }
                }
            },
            {
                "text": "Foo",
                "kind": "interface",
                "kindModifiers": "",
                "spans": [
                    {
                        "start": {
                            "line": 1,
                            "offset": 1
                        },
                        "end": {
                            "line": 3,
                            "offset": 2
                        }
                    },
                    {
                        "start": {
                            "line": 6,
                            "offset": 1
                        },
                        "end": {
                            "line": 8,
                            "offset": 2
                        }
                    }
                ],
                "nameSpan": {
                    "start": {
                        "line": 1,
                        "offset": 11
                    },
                    "end": {
                        "line": 1,
                        "offset": 14
                    }
                },
                "childItems": [
                    {
                        "text": "bar",
                        "kind": "method",
                        "kindModifiers": "",
                        "spans": [
                            {
                                "start": {
                                    "line": 2,
                                    "offset": 5
                                },
                                "end": {
                                    "line": 2,
                                    "offset": 17
                                }
                            },
                            {
                                "start": {
                                    "line": 7,
                                    "offset": 5
                                },
                                "end": {
                                    "line": 7,
                                    "offset": 27
                                }
                            }
                        ],
                        "nameSpan": {
                            "start": {
                                "line": 2,
                                "offset": 5
                            },
                            "end": {
                                "line": 2,
                                "offset": 8
                            }
                        }
                    }
                ]
            }
        ]
    }
}

@mjbvz We're sending back two copies of bar that have unambiguously different parent Foo declarations based on the span. Is it incorrect to coalesce like this? What's the expected response shape in this situation?

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Jun 18, 2024
@yyx1111
Copy link
Author

yyx1111 commented Jun 19, 2024

interface Foo {
bar(): void;
}
interface Baz { }

interface Foo {
bar(s?: string): void;
}

let symbols = await vscode.commands.executeCommand(
"vscode.executeDocumentSymbolProvider",
uri
);
20240619150647594
The second "interface Foo"
selectionRange: should be {start:[5,10],end:[5,13]}, should not be {start:[5,0],end:[7,1]}

@DanielRosenwasser
Copy link
Member

I think for

interface Foo {
    bar(): void;
}
interface Baz { }

interface Foo {
    bar(s?: string): void;
}

Showing the following:

image

feels like a bug on VS Code itself. But I think there is also a question on whether TypeScript should create two separate entries for Foo.

@yyx1111
Copy link
Author

yyx1111 commented Jun 22, 2024

This is the case with many d.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

5 participants