<commit_before>(:
 : Copyright (C) 2020 <NAME>
 :
 : Licensed under the Apache License, Version 2.0 (the "License");
 : you may not use this file except in compliance with the License.
 : You may obtain a copy of the License at
 :
 : http://www.apache.org/licenses/LICENSE-2.0
 :
 : Unless required by applicable law or agreed to in writing, software
 : distributed under the License is distributed on an "AS IS" BASIS,
 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 : See the License for the specific language governing permissions and
 : limitations under the License.
 :)
xquery version "1.0-ml";
declare namespace o = "http://reecedunn.co.uk/xquery/options";
declare option o:implementation "marklogic/6.0";

(: Add/remove a breakpoint for a request. :)

declare variable $requestId as xs:unsignedLong external;
declare variable $register as xs:boolean external;
declare variable $exprUri as xs:string external;
declare variable $exprLine as xs:nonNegativeInteger external;
declare variable $exprColumn as xs:nonNegativeInteger external;

let $status := dbg:status($requestId)/dbg:request/dbg:request-status
let $_ := if ($status = "running") then dbg:break($requestId) else ()

let $result := try {
    let $expr :=
        for $expressionId in dbg:line($requestId, $exprUri, $exprLine)
        let $expr := dbg:expr($requestId, $expressionId)
        where $expr/dbg:line eq $exprLine and $expr/dbg:column eq $exprColumn
        return $expr
    let $_ :=
        if (exists($expr)) then
            if ($register) then
                dbg:break($requestId, $expr[1]/dbg:expr-id)
            else
                dbg:clear($requestId, $expr[1]/dbg:expr-id)
        else ()
    return true()
} catch ($e) {
    (: Can throw a "Module not found" error. :)
    false()
}

let $_ := if ($status = "running") then dbg:continue($requestId) else ()
return $result<commit_msg>Return false from breakpoint.xqy if the expression does not exist.<commit_after>(:
 : Copyright (C) 2020 <NAME>
 :
 : Licensed under the Apache License, Version 2.0 (the "License");
 : you may not use this file except in compliance with the License.
 : You may obtain a copy of the License at
 :
 : http://www.apache.org/licenses/LICENSE-2.0
 :
 : Unless required by applicable law or agreed to in writing, software
 : distributed under the License is distributed on an "AS IS" BASIS,
 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 : See the License for the specific language governing permissions and
 : limitations under the License.
 :)
xquery version "1.0-ml";
declare namespace o = "http://reecedunn.co.uk/xquery/options";
declare option o:implementation "marklogic/6.0";

(: Add/remove a breakpoint for a request. :)

declare variable $requestId as xs:unsignedLong external;
declare variable $register as xs:boolean external;
declare variable $exprUri as xs:string external;
declare variable $exprLine as xs:nonNegativeInteger external;
declare variable $exprColumn as xs:nonNegativeInteger external;

let $status := dbg:status($requestId)/dbg:request/dbg:request-status
let $_ := if ($status = "running") then dbg:break($requestId) else ()

let $result := try {
    let $expr :=
        for $expressionId in dbg:line($requestId, $exprUri, $exprLine)
        let $expr := dbg:expr($requestId, $expressionId)
        where $expr/dbg:line eq $exprLine and $expr/dbg:column eq $exprColumn
        return $expr
    return if (exists($expr)) then
        let $_ :=
            if ($register) then
                dbg:break($requestId, $expr[1]/dbg:expr-id)
            else
                dbg:clear($requestId, $expr[1]/dbg:expr-id)
        return true()
    else
        false()
} catch ($e) {
    (: Can throw a "Module not found" error. :)
    false()
}

let $_ := if ($status = "running") then dbg:continue($requestId) else ()
return $result
{'fraction_non_alphanumeric': 0.11388817315124967, 'fraction_numerical': 0.007214635403246586, 'mean_word_length': 3.5832349468713107, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5031334', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1082, 'n_words': 408}