module unused - Incorrect report #10

Open
opened 2022-06-07 18:05:31 +01:00 by apb · 3 comments
Owner
module namespace _ = 'upload';
import  module namespace util = 'utils' at "../../lib/utils.xqm";

declare function _:about(){
 util:render("about.txq")
};

[W04] Unused module "utils"

<XQuery>
    <Module>
        <LibraryModule>
            <ModuleDecl>
                <TOKEN>module</TOKEN>
                <WS> </WS>
                <TOKEN>namespace</TOKEN>
                <WS> </WS>
                <NCName>
                    <NCName>_</NCName>
                </NCName>
                <WS> </WS>
                <TOKEN>=</TOKEN>
                <WS> </WS>
                <URILiteral>
                    <StringLiteral>'upload'</StringLiteral>
                </URILiteral>
                <Separator>
                    <TOKEN>;</TOKEN>
                </Separator>
            </ModuleDecl>
            <WS>
</WS>
            <Prolog>
                <Import>
                    <ModuleImport>
                        <TOKEN>import</TOKEN>
                        <WS>  </WS>
                        <TOKEN>module</TOKEN>
                        <WS> </WS>
                        <TOKEN>namespace</TOKEN>
                        <WS> </WS>
                        <NCName>
                            <NCName>util</NCName>
                        </NCName>
                        <WS> </WS>
                        <TOKEN>=</TOKEN>
                        <WS> </WS>
                        <URILiteral>
                            <StringLiteral>'utils'</StringLiteral>
                        </URILiteral>
                        <WS> </WS>
                        <TOKEN>at</TOKEN>
                        <WS> </WS>
                        <URILiteral>
                            <StringLiteral>"../../lib/utils.xqm"</StringLiteral>
                        </URILiteral>
                    </ModuleImport>
                </Import>
                <Separator>
                    <TOKEN>;</TOKEN>
                </Separator>
                <WS>

</WS>
                <AnnotatedDecl>
                    <TOKEN>declare</TOKEN>
                    <WS> </WS>
                    <FunctionDecl>
                        <TOKEN>function</TOKEN>
                        <WS> </WS>
                        <EQName>_:about</EQName>
                        <TOKEN>(</TOKEN>
                        <TOKEN>)</TOKEN>
                        <FunctionBody>
                            <EnclosedExpr>
                                <TOKEN>{</TOKEN>
                                <WS>
 </WS>
                                <Expr>
                                    <ExprSingle>
                                        <FunctionCall>
                                            <FunctionEQName>
                                                <EQName>util:render</EQName>
                                            </FunctionEQName>
                                            <ArgumentList>
                                                <TOKEN>(</TOKEN>
                                                <Argument>
                                                    <ExprSingle>
                                                        <Literal>
                                                            <StringLiteral>"about.txq"</StringLiteral>
                                                        </Literal>
                                                    </ExprSingle>
                                                </Argument>
                                                <TOKEN>)</TOKEN>
                                            </ArgumentList>
                                        </FunctionCall>
                                    </ExprSingle>
                                </Expr>
                                <WS>
</WS>
                                <TOKEN>}</TOKEN>
                            </EnclosedExpr>
                        </FunctionBody>
                    </FunctionDecl>
                </AnnotatedDecl>
                <Separator>
                    <TOKEN>;</TOKEN>
                </Separator>
            </Prolog>
        </LibraryModule>
    </Module>
    <WS>
</WS>
    <EOF>
   </EOF>
</XQuery>
```xquery module namespace _ = 'upload'; import module namespace util = 'utils' at "../../lib/utils.xqm"; declare function _:about(){ util:render("about.txq") }; ``` [W04] Unused module "utils" ```xml <XQuery> <Module> <LibraryModule> <ModuleDecl> <TOKEN>module</TOKEN> <WS> </WS> <TOKEN>namespace</TOKEN> <WS> </WS> <NCName> <NCName>_</NCName> </NCName> <WS> </WS> <TOKEN>=</TOKEN> <WS> </WS> <URILiteral> <StringLiteral>'upload'</StringLiteral> </URILiteral> <Separator> <TOKEN>;</TOKEN> </Separator> </ModuleDecl> <WS> </WS> <Prolog> <Import> <ModuleImport> <TOKEN>import</TOKEN> <WS> </WS> <TOKEN>module</TOKEN> <WS> </WS> <TOKEN>namespace</TOKEN> <WS> </WS> <NCName> <NCName>util</NCName> </NCName> <WS> </WS> <TOKEN>=</TOKEN> <WS> </WS> <URILiteral> <StringLiteral>'utils'</StringLiteral> </URILiteral> <WS> </WS> <TOKEN>at</TOKEN> <WS> </WS> <URILiteral> <StringLiteral>"../../lib/utils.xqm"</StringLiteral> </URILiteral> </ModuleImport> </Import> <Separator> <TOKEN>;</TOKEN> </Separator> <WS> </WS> <AnnotatedDecl> <TOKEN>declare</TOKEN> <WS> </WS> <FunctionDecl> <TOKEN>function</TOKEN> <WS> </WS> <EQName>_:about</EQName> <TOKEN>(</TOKEN> <TOKEN>)</TOKEN> <FunctionBody> <EnclosedExpr> <TOKEN>{</TOKEN> <WS> </WS> <Expr> <ExprSingle> <FunctionCall> <FunctionEQName> <EQName>util:render</EQName> </FunctionEQName> <ArgumentList> <TOKEN>(</TOKEN> <Argument> <ExprSingle> <Literal> <StringLiteral>"about.txq"</StringLiteral> </Literal> </ExprSingle> </Argument> <TOKEN>)</TOKEN> </ArgumentList> </FunctionCall> </ExprSingle> </Expr> <WS> </WS> <TOKEN>}</TOKEN> </EnclosedExpr> </FunctionBody> </FunctionDecl> </AnnotatedDecl> <Separator> <TOKEN>;</TOKEN> </Separator> </Prolog> </LibraryModule> </Module> <WS> </WS> <EOF> </EOF> </XQuery> ```
apb added the
bug
label 2022-06-07 18:06:57 +01:00
apb changed title from Incorrect module unused to Incorrect module unused report 2022-06-07 18:08:34 +01:00
apb changed title from Incorrect module unused report to module unused - Incorrect report 2022-06-07 18:16:52 +01:00
Author
Owner

handlers.js - uncalled

exports.FunctionCallHandler = function(translator, sctx, node, arity){
    return {
        EQName: function(eqname){
            var value = TreeOps.flatten(eqname);
            translator.apply(function(){
                var qname = sctx.resolveQName(value, node.pos);
                if(qname.uri !== '') {
                    sctx.root.namespaces[qname.uri].used = true;
                }
                sctx.addFunctionCall(qname, arity, eqname.pos);
            });
        }
    };
};
handlers.js - uncalled ```javascript exports.FunctionCallHandler = function(translator, sctx, node, arity){ return { EQName: function(eqname){ var value = TreeOps.flatten(eqname); translator.apply(function(){ var qname = sctx.resolveQName(value, node.pos); if(qname.uri !== '') { sctx.root.namespaces[qname.uri].used = true; } sctx.addFunctionCall(qname, arity, eqname.pos); }); } }; }; ```
Author
Owner
nameclash util = https://docs.basex.org/wiki/Utility_Module
Author
Owner
(: xqdoc generation test :)
import module namespace xqdc = 'quodatum:xqdoca.model.xqdoc' at "../main/lib/xqdoc-from-ast.xqm";
declare variable $src:="C:\tmp\xqdoca\dba\modules\F000002\xqparse.xml";
doc($src)=>xqdc:create()

xqdc reported unused

``` (: xqdoc generation test :) import module namespace xqdc = 'quodatum:xqdoca.model.xqdoc' at "../main/lib/xqdoc-from-ast.xqm"; declare variable $src:="C:\tmp\xqdoca\dba\modules\F000002\xqparse.xml"; doc($src)=>xqdc:create() ``` xqdc reported unused
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: apb/vscode-basex#10
No description provided.