Git Product home page Git Product logo

Comments (7)

randy3k avatar randy3k commented on May 26, 2024

Ya, you are right. we would need to check the current scope at

languageserver/R/utils.R

Lines 45 to 53 in c6d3edc

check_scope <- function(uri, document, position) {
if (is_rmarkdown(uri)) {
line <- position$line
!identical(sum(vapply(
document$content[1:(line + 1)], startsWith, integer(1), "```")) %% 2, 0)
} else {
TRUE
}
}

from languageserver.

andycraig avatar andycraig commented on May 26, 2024

I'm using the version of languageserver on CRAN. When I hold Ctrl and hover over print in the below code, it works as expected (I get the hover definition, and if I click it opens a file with the definition):

xml_find_all(x, "base::print")

When I do the same for

xml_find_all(x, "descendant::expr")

I get basically the same error:

[Error - 18:02:34] Request textDocument/definition failed.
  Message: {"message":"there is no package called ‘descendant’","call":{}}

  Code: -32603 

I don't have the package descendant installed, so I think that's the problem. (I tried installing it, but it doesn't seem to be on CRAN.) @renkun-ken Do you have it installed?

Moving the mouse over expr without Ctrl held down, I don't get any hover popup but I also don't get an error showing. The code for hover_reply includes a tryCatch that is probably catching an identical error. I think I removed the equivalent tryCatch in the definition code, so I've introduced an inconsistency there. @randy3k If you want, I could do a PR to put it back in (also for the symbol reply functions).

from languageserver.

renkun-ken avatar renkun-ken commented on May 26, 2024

@andycraig, thanks for your testing. My point is that I'm not sure if it makes sense to provide definition of foo::bar in string literals, since the code I provide here is really an XPath expression rather than R code, or it could be some C++ code, or anything.

from languageserver.

andycraig avatar andycraig commented on May 26, 2024

@renkun-ken Ah, beg your pardon. No wonder descendant isn’t on CRAN! Re-reading the issue I now see what you mean.

from languageserver.

renkun-ken avatar renkun-ken commented on May 26, 2024

Thanks! I test it and it works well now.

from languageserver.

randy3k avatar randy3k commented on May 26, 2024

Actually it doesn’t work for multi line strings. But they are not common plus the search would be costly. This is good enough for now.

from languageserver.

renkun-ken avatar renkun-ken commented on May 26, 2024

Multi-line strings can be handled by parsed xml doc, i.e., xpath query if the cursor is in the range of a string literal, but it requires that the document is syntactically correct to be parseable. It think it's good enough too.

from languageserver.

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.