Giter Site home page Giter Site logo

Comments (1)

WillLillis avatar WillLillis commented on June 6, 2024

I'm also running into this issue using 0.13.0-dev.29+bb19bee. It looks like zls is ignoring the initialization accesses to the struct's fields when it searches for references as part of the renaming request. These references are also missing when using the server's textDocument/reference capability. I'm not super familiar with the language/ zls code base yet, but after a bit of poking around it looks like the references are missed here:

fn referenceNode(self: *const Context, tree: Ast, node: Ast.Node.Index) error{OutOfMemory}!void {
const builder = self.builder;
const handle = self.handle;
const node_tags = tree.nodes.items(.tag);
const datas = tree.nodes.items(.data);
const token_tags = tree.tokens.items(.tag);
const starts = tree.tokens.items(.start);
switch (node_tags[node]) {
.identifier,
.test_decl,
=> {
const identifier_token = Analyser.getDeclNameToken(tree, node) orelse return;
if (token_tags[identifier_token] != .identifier) return;
const child = (try builder.analyser.lookupSymbolGlobal(
handle,
offsets.tokenToSlice(tree, identifier_token),
starts[identifier_token],
)) orelse return;
if (builder.decl_handle.eql(child)) {
try builder.add(handle, identifier_token);
}
},
.field_access => {
const lhs = try builder.analyser.resolveTypeOfNode(.{ .node = datas[node].lhs, .handle = handle }) orelse return;
const deref_lhs = try builder.analyser.resolveDerefType(lhs) orelse lhs;
const symbol = offsets.tokenToSlice(tree, datas[node].rhs);
const child = (try deref_lhs.lookupSymbol(builder.analyser, symbol)) orelse return;
if (builder.decl_handle.eql(child)) {
try builder.add(handle, datas[node].rhs);
}
},
else => {},
}
}
};

If I add a .assign_destructure arm to the switch block, it looks like that matches up with the missing references to the field initializations (I'm still not 100% confident, though). Still working on how to properly add the appropriate information to the references builder, but hopefully this helps narrow down the issue :) Nevermind, definitely not .assign_destructure.

Related #1700

from zls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.