Skip to main content

why_no_members

Function why_no_members 

Source
pub fn why_no_members(
    index: &ProjectIndex,
    scopes: &ScopeTree,
    root: &CppSyntaxNode,
    path: &Path,
    offset: ReadingOffset,
) -> String
Expand description

What the completion made of a cursor — the one diagnosis this layer is worth logging.

A . whose answer is the names in scope is the shape a user reported as “补全明显错误”: the popup is full of things that cannot follow the operator, and nothing in it says whether the type could not be worked out, the class could not be found, or the cursor was never read as a member access at all. Those three have different fixes, and the reason is thrown away by the time a client sees an answer with no members in it.

Asked of the same reader the answer came from, and that is the whole of why this function takes root and not the set: the member list is produced together with the reason it came out empty, so the sentence a log shows is about this query rather than about a second one that may disagree with it. Measured on a live server: the diagnostic said “the cursor is not a member access at all” while the completion beside it was listing the members — because the diagnostic asked the index layer, whose tree-only shape reader does not accept a cursor drawn on the operator’s own column, and the feature asks the context reader, which does.

Only asked when the answer contained no members, so the cost is one extra query on exactly the keystrokes a reader would complain about.