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

VS Code Outline sometimes doesn't show for newly-opened files #1047

Closed
clarktank opened this issue Jun 29, 2018 · 13 comments
Closed

VS Code Outline sometimes doesn't show for newly-opened files #1047

clarktank opened this issue Jun 29, 2018 · 13 comments
Labels
in editor Relates to code editing or language features is bug
Milestone

Comments

@clarktank
Copy link

clarktank commented Jun 29, 2018

On Android Studio, on the left side, there is a section called "Structure" where it shows a Top Level of all your classes and methods. Could you bring it to VS code?

@DanTup
Copy link
Member

DanTup commented Jul 2, 2018

I found some screenshots of it, but couldn't figure out exactly what it's showing. Is it not the same as the Outline view?

screen shot 2018-07-02 at 7 41 53 am

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Jul 2, 2018
@clarktank
Copy link
Author

clarktank commented Jul 2, 2018

@DanTup Yes, that's exactly what I want. How did you enable that feature with Dart or Flutter extension? I have installed the Flutter 2.15.0 extension, but it doesn't have an outline section...

@DanTup
Copy link
Member

DanTup commented Jul 2, 2018

It's a VS Code feature - on the Explorer sidebar, right-click and tick Outline :) It uses the data we already supplied for the Document Symbol list.

It's currently a preview feature, so it may move - see microsoft/vscode#49923.

@DanTup DanTup closed this as completed Jul 2, 2018
@DanTup DanTup added duplicate and removed awaiting info Requires more information from the customer to progress labels Jul 2, 2018
@clarktank
Copy link
Author

I got it thanks :) It does work on my local files, but for example when I press F12 on StatefulWidget to go to its implementation, in this case framework.dart file, the outline doesn't show anything!

@DanTup
Copy link
Member

DanTup commented Jul 3, 2018

@clarktank Hmmm, that should work - and seems to here:

screen shot 2018-07-03 at 4 24 57 pm

Could you try capturing a log? Close framework.dart, Run the Dart: Capture Logs command, then F12 into the file, give it a few seconds, and then click Stop Logging and attach the log (after reviewing it for any sensitive info/code).

@clarktank
Copy link
Author

I don't know if it is useful, but here is a screenshot of my VS code...
2018-07-03 1

@DanTup
Copy link
Member

DanTup commented Jul 3, 2018

@scheglov Not sure if this is a race (or whether it should work). We opened a file (framework.dart inside Flutter) and called setPriorityFiles then immediately called search.getElementDeclarations (this is VS Code's new Outline feature - I guess it immediately requests the symbols when you open a file). That request happened before the server had started analyzing (from the new file being added as priority) so we ended up with an empty result.

[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] ==> {"id":"121","method":"analysis.setPriorityFiles","params":{"files":["C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","C:\\Users\\clarktank\\Apps\\stephen_1\\lib\\src\\app.dart"]}}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] ==> {"id":"122","method":"analysis.setSubscriptions","params":{"subscriptions":{"CLOSING_LABELS":["C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","C:\\Users\\clarktank\\Apps\\stephen_1\\lib\\src\\app.dart"],"FOLDING":["C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","C:\\Users\\clarktank\\Apps\\stephen_1\\lib\\src\\app.dart"],"OCCURRENCES":["C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","C:\\Users\\clarktank\\Apps\\stephen_1\\lib\\src\\app.dart"],"OUTLINE":["C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","C:\\Users\\clarktank\\Apps\\stephen_1\\lib\\src\\app.dart"]}}}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] ==> {"id":"123","method":"search.getElementDeclarations","params":{"file":"C:\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart"}}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] <== {"id":"121"}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] <== {"id":"122"}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] <== {"event":"server.status","params":{"analysis":{"isAnalyzing":true}}}
[11:47:24 GMT-0400 (Eastern Daylight Time)] [Analyzer] <== {"id":"123","result":{"declarations":[],"files":[]}}

I think it would be better if the setPriorityFiles request had somehow delayed the getElementDeclarations processing until after the re-analysis (though I don't know the complexity or impact of that)?

@DanTup DanTup reopened this Jul 3, 2018
@DanTup DanTup changed the title FR: Adding a Top Level Code Structure VS Code Outline sometimes doesn't show for newly-opened files Jul 3, 2018
@DanTup DanTup added is bug in editor Relates to code editing or language features and removed duplicate labels Jul 3, 2018
@scheglov
Copy link

scheglov commented Jul 3, 2018

I don't understand why this might happen.

search.getElementDeclarations does not depend on resolution, so it does not need the file to be a priority one. We just need that the file is "known" in one of the drivers / analysis roots, e.g. it is in a root, or in a package in dependencies.

@DanTup
Copy link
Member

DanTup commented Jul 4, 2018

Hmmm, that is strange then. The file must be reachable as it was returned in getNavigation. Maybe an instrumentation log will reveal more?

@clarktank Could you try enabling the Analaysis Server Instrumentation Log, restarting VS Code, reproducing, then providing the log?

Note: That log may include a lot more of your code than the previous log so do review if there might be anything sensitive in there (or you can email it if you don't want to post here - logs @ dartcode .org).

@clarktank
Copy link
Author

This time I didn't wait as much as last time, after pressing F12. Please, let men know, if you want me wait more...

@DanTup
Copy link
Member

DanTup commented Jul 5, 2018

@clarktank That's fine, it includes the important part showing the request/response for the data:

1530755229674:Req:{"id"::"30","method"::"search.getElementDeclarations","params"::{"file"::"C::\\Users\\clarktank\\Desktop\\Apps\\Flutter\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart"}}
1530755229676:Res:{"id"::"30","result"::{"declarations"::[],"files"::[]}}

@scheglov There's less in that log than I remembered; I thought it showed the files being analyzed. Anything more we can do debug?

@clarktank
Copy link
Author

I have upgraded to v2.6 and this problem is solved.

@DanTup
Copy link
Member

DanTup commented Jul 17, 2018

Great! I guess it was fixed by 623dcc9. We switched over to Outline information for the Document symbol list so that we could more easily map it to a tree and we'll wait up to 60 seconds after you open the file for the data to come through.

@DanTup DanTup closed this as completed Jul 17, 2018
@DanTup DanTup added this to the v2.16.0 milestone Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features is bug
Projects
None yet
Development

No branches or pull requests

3 participants