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

Go to declaration across modules #80

Closed
robwhitby opened this issue Nov 26, 2013 · 7 comments
Closed

Go to declaration across modules #80

robwhitby opened this issue Nov 26, 2013 · 7 comments
Assignees

Comments

@robwhitby
Copy link

Auto-complete correctly suggests variables and functions from imported modules, but the go to declaration feature doesn't work, it just says "Cannot find declaration to go to".

@ligasgr
Copy link
Owner

ligasgr commented Nov 26, 2013

Hi, will take a look at it.
Would you be able to prepare an example project that simulates it?

Thanks!

@ghost ghost assigned ligasgr Nov 26, 2013
@robwhitby
Copy link
Author

Hi, thanks and sorry for the delay getting back to you. Should "go to declaration" work across files? Maybe I don't have something setup right.

Create a library module lib.xq

xquery version "3.0";
module namespace lib = "lib";

declare variable $foo := "foo";
declare function bar() as xs:string { "bar" };

and a main module main.xq

xquery version "3.0";
import module namespace lib="lib" at "lib.xq";

$lib:foo, 
lib:bar()

The auto-complete works fine - typing lib: suggests foo and bar, but the go to declaration doesn't work on either foo or bar.

I'm using 0.0.9 btw.

Thanks again
Rob

@ligasgr
Copy link
Owner

ligasgr commented Dec 1, 2013

Hi,

No worries.

As I thought the issue is not really related to the multi-module setup but the fact that marklogic has a bit more relaxed rules around variable declaration.
I prepared the logic for resolution of variables according to xquery language spec (http://www.w3.org/TR/xquery-30/#id-variable-declarations) which says:
"All variable names declared in a library module must (when expanded) be in the target namespace of the library module [err:XQST0048]. "
But marklogic doesn't throw this error (checked just a moment ago).

If in your library module you'll add prefix in your variable declaration then it'll start working fine.

Anyway... I'll try making resolution more relaxed as I think that most of marklogic xquery code uses this "feature" of not having to add prefix in variable declaration.

@ligasgr
Copy link
Owner

ligasgr commented Dec 1, 2013

After some reading... It's probably a hidden feature nowhere described similar to defaulting function namespace for library modules to module namespace (http://docs.marklogic.com/guide/xquery/enhanced#id_20838).

@robwhitby
Copy link
Author

ah I see, thanks for looking into it. I didn't realise it was a MarkLogic thing to default variables and functions to the library namespace - I write all my code like that :)

@ligasgr
Copy link
Owner

ligasgr commented Dec 30, 2013

Will require selecting xquery "flavour" (creating a facet) for solving. Will go with next release.

@ligasgr
Copy link
Owner

ligasgr commented May 25, 2014

Set in [File | Settings | Project settings | XQuery | Other | XQuery flavour] value MarkLogic and should work fine now.

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

No branches or pull requests

2 participants