Skip to content

[CP] [stable] Fix analysis server plugins not receiving setContextRoots (or having wrong roots) #56547

@DanTup

Description

@DanTup

Commit(s) to merge

Target

stable

Prepared changelist for beta/stable

https://dart-review.googlesource.com/c/sdk/+/381760

Issue Description

Recent changes to the analysis server result in fewer analysis contexts being created to improve performance. Analysis contexts were also used by analysis server plugins and when no analysis context is created at the location where a plugin should be enabled, it would instead be enabled for the parent context, resulting in the wrong folders having the plugins enabled, and potentially triggering a race condition because the same plugin may be assigned to the same root multiple times.

The result was that analysis server plugins could be nonfunctional, or given the wrong root folders to analyze.

What is the fix

This fix is to ensure that analysis contexts are created at all locations where plugins are enabled (or changed from the parent context).

Why cherry-pick

Without the cherry pick, analysis server plugins may not work at all, or may be enabled for folders that they should not (potentially producing spurious results).

Risk

Medium? I'm not sure what the scale is here. It's not the most trivial cherry-pick, however the changes in behaviour should be limited to only when plugins are used (although the extra check for plugins applies to all contexts) and the change includes several new tests covering the reported error conditions and some additional cases.

(cc @bwilkerson @srawlins @pq in case they have opinions on this)

Issue link(s)

#56475

Extra Info

No response

Metadata

Metadata

Labels

cherry-pick-approvedLabel for approved cherrypick requestcherry-pick-reviewIssue that need cherry pick triage to approvelegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions