Go to declaration across modules #80

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

Comments

Projects
None yet
2 participants
@robwhitby

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

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr Nov 26, 2013

Owner

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

Thanks!

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

This comment has been minimized.

Show comment
Hide comment
@robwhitby

robwhitby Dec 1, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr Dec 1, 2013

Owner

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.

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

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr Dec 1, 2013

Owner

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).

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

This comment has been minimized.

Show comment
Hide comment
@robwhitby

robwhitby Dec 1, 2013

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 :)

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

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr Dec 30, 2013

Owner

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

Owner

ligasgr commented Dec 30, 2013

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

@ligasgr ligasgr closed this in ea69192 May 25, 2014

@ligasgr

This comment has been minimized.

Show comment
Hide comment
@ligasgr

ligasgr May 25, 2014

Owner

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

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