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

Outline view is rendered as a flat list rather than a nested (tree) structure. #268

Closed
norru opened this issue Jul 15, 2019 · 11 comments
Closed

Comments

@norru
Copy link
Contributor

norru commented Jul 15, 2019

Outline view is rendered as a flat list rather than a nested (tree) structure.

  • latest Corrosion Snapshot
  • rls 1.37.0 (124483d 2019-07-01)
  • rustc 1.38.0-nightly (83e4eed16 2019-07-14)

Selection_202

@mickaelistria
Copy link
Contributor

Can you please share in the log that response to the document/symbols request? Either information is there and not used (LSP4E's fault) or it's not there at all (RLS' fault)

@akurtakov
Copy link
Member

This sounds more like RLS issue than corrosion.

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

Here's a snippet from a public project (cannot disclose details about my private ones)

Selection_203

The information seems to be there, but laid out in a weird way. Is documentSymbol response supposed to be a tree?

//! Result and Error types.

use std::ffi::CStr;

/// Error type for this crate.
#[derive(Debug, Clone)]
pub enum Error {
    /// A generic error, with a description string.
    Generic(String),
}

impl Error {
    /// Construct an `Error` from a malloc-allocated C string, then free the C string.
    pub(crate) fn take(x: *const libc::c_char) -> Self {
        unsafe {
            let msg = CStr::from_ptr(x).to_string_lossy().into_owned();
            libc::free(x as *mut _);
            Error::Generic(msg)
        }
    }
}

impl std::error::Error for Error {
    fn description(&self) -> &str {
        use self::Error::*;
        match *self {
            Generic(ref x) => x,
        }
    }
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        use self::Error::*;
        match *self {
            Generic(ref x) => f.pad(x),
        }
    }
}

/// Result type for this crate.
pub type Result<T> = std::result::Result<T, Error>;
[t=1563191487277] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","id":"11","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs"}}}
[t=1563191487278] org.eclipse.corrosion.rls to LSP4E:
{"jsonrpc":"2.0","id":"11","result":[{"name":"Generic","kind":22,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":8,"character":4},"end":{"line":8,"character":11}}},"containerName":"Error"},{"name":"Error","kind":10,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":6,"character":9},"end":{"line":6,"character":14}}},"containerName":"error"},{"name":"__self_0","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":8,"character":12},"end":{"line":8,"character":18}}}},{"name":"__self_0","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":8,"character":12},"end":{"line":8,"character":18}}}},{"name":"x","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":13,"character":23},"end":{"line":13,"character":24}}}},{"name":"take","kind":6,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":13,"character":18},"end":{"line":13,"character":22}}}},{"name":"msg","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":15,"character":16},"end":{"line":15,"character":19}}}},{"name":"self","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":23,"character":20},"end":{"line":23,"character":24}}}},{"name":"description","kind":6,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":23,"character":7},"end":{"line":23,"character":18}}},"containerName":"Error"},{"name":"x","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":26,"character":24},"end":{"line":26,"character":25}}}},{"name":"self","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":32,"character":12},"end":{"line":32,"character":16}}}},{"name":"f","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":32,"character":18},"end":{"line":32,"character":19}}}},{"name":"fmt","kind":6,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":32,"character":7},"end":{"line":32,"character":10}}},"containerName":"Display"},{"name":"x","kind":13,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":35,"character":24},"end":{"line":35,"character":25}}}},{"name":"Result","kind":26,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":41,"character":9},"end":{"line":41,"character":15}}},"containerName":"error"},{"name":"T","kind":26,"location":{"uri":"file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs","range":{"start":{"line":41,"character":16},"end":{"line":41,"character":17}}}}]}

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

{
  "jsonrpc": "2.0",
  "id": "11",
  "result": [
    {
      "name": "Generic",
      "kind": 22,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 8,
            "character": 4
          },
          "end": {
            "line": 8,
            "character": 11
          }
        }
      },
      "containerName": "Error"
    },
    {
      "name": "Error",
      "kind": 10,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 6,
            "character": 9
          },
          "end": {
            "line": 6,
            "character": 14
          }
        }
      },
      "containerName": "error"
    },
    {
      "name": "__self_0",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 8,
            "character": 12
          },
          "end": {
            "line": 8,
            "character": 18
          }
        }
      }
    },
    {
      "name": "__self_0",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 8,
            "character": 12
          },
          "end": {
            "line": 8,
            "character": 18
          }
        }
      }
    },
    {
      "name": "x",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 13,
            "character": 23
          },
          "end": {
            "line": 13,
            "character": 24
          }
        }
      }
    },
    {
      "name": "take",
      "kind": 6,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 13,
            "character": 18
          },
          "end": {
            "line": 13,
            "character": 22
          }
        }
      }
    },
    {
      "name": "msg",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 15,
            "character": 16
          },
          "end": {
            "line": 15,
            "character": 19
          }
        }
      }
    },
    {
      "name": "self",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 23,
            "character": 20
          },
          "end": {
            "line": 23,
            "character": 24
          }
        }
      }
    },
    {
      "name": "description",
      "kind": 6,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 23,
            "character": 7
          },
          "end": {
            "line": 23,
            "character": 18
          }
        }
      },
      "containerName": "Error"
    },
    {
      "name": "x",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 26,
            "character": 24
          },
          "end": {
            "line": 26,
            "character": 25
          }
        }
      }
    },
    {
      "name": "self",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 32,
            "character": 12
          },
          "end": {
            "line": 32,
            "character": 16
          }
        }
      }
    },
    {
      "name": "f",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 32,
            "character": 18
          },
          "end": {
            "line": 32,
            "character": 19
          }
        }
      }
    },
    {
      "name": "fmt",
      "kind": 6,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 32,
            "character": 7
          },
          "end": {
            "line": 32,
            "character": 10
          }
        }
      },
      "containerName": "Display"
    },
    {
      "name": "x",
      "kind": 13,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 35,
            "character": 24
          },
          "end": {
            "line": 35,
            "character": 25
          }
        }
      }
    },
    {
      "name": "Result",
      "kind": 26,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 41,
            "character": 9
          },
          "end": {
            "line": 41,
            "character": 15
          }
        }
      },
      "containerName": "error"
    },
    {
      "name": "T",
      "kind": 26,
      "location": {
        "uri": "file:///home/norru/Projects/3rdParty/openexr-rs/src/error.rs",
        "range": {
          "start": {
            "line": 41,
            "character": 16
          },
          "end": {
            "line": 41,
            "character": 17
          }
        }
      }
    }
  ]
}

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

RLS is not implementing children in documentSymbol

palantir/python-language-server#537

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

RLS implements containerName instead. The "parent" of any node can be found by referencing a combination of containerName and location ranges.

rust-lang/rls#86

@mickaelistria
Copy link
Contributor

RLS implements containerName instead. The "parent" of any node can be found by referencing a combination of containerName and location ranges.

The specification clearly states that the containerName is a "decoration" and isn't intended to be used to build a hierarchy. This is even more true for the example you shared because some container names reference elements that aren't local symbols in the file (like namespaces).

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

@mickaelistria I do agree that the right course of action would be for RLS to implement children. Thing is, they could reject, or postpone, the request (i've posted a question in rust-lang/rls#909) saying that the outline tree could be implemented client side by leveraging the current structure.

@norru
Copy link
Contributor Author

norru commented Jul 15, 2019

Looks like the RLS team will implement children at some point in the future. At the moment it's blocked by rust-lang/rls#1377.

@akurtakov
Copy link
Member

Now that corrosion uses rust-analyzer is this one fixed for you?

@akurtakov
Copy link
Member

Closing due to lack of interest from reporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants