Added a few more interesting sample queries

This commit is contained in:
Peter Villadsen 2024-02-29 12:13:08 -08:00
Родитель 05a7360431
Коммит 29270051da
6 изменённых файлов: 184 добавлений и 22 удалений

Просмотреть файл

@ -8,14 +8,26 @@
(: @Category Mandatory :)
(: @Language Xpp :)
declare function local:SourceLines($s as xs:string, $fromLine as xs:integer, $toLine as xs:integer) as xs:string
{
let $lines := tokenize($s, '(\r\n?|\n\r?)')
return string-join($lines[position() >= max((1, $fromLine - 3))
and position() <= min((count($lines), $toLine + 3)) ], '&#10;' )
};
<EmptyIfParts Category='Mandatory' href='docs.microsoft.com/Socratex/EmptyIfParts' Version='1.0'>
{
for $c in /*
for $m in $c//Method
for $e in $m//(IfStatement | IfThenElseStatement)/(CompoundStatement | EmptyStatement)
where not($e/*)
return <EmptyIfPart Artifact='{$c/@Artifact}' Method='{$m/@Name}'
for $c in /*
for $m in $c//Method
for $e in $m//(IfStatement | IfThenElseStatement)/(CompoundStatement | EmptyStatement)
where not($e/*)
return <EmptyIfPart Artifact='{$c/@Artifact}' Method='{$m/@Name}'
StartLine='{$e/@StartLine}' StartCol='{$e/@StartCol}'
EndLine='{$e/@EndLine}' EndCol='{$e/@EndCol}'/>
EndLine='{$e/@EndLine}' EndCol='{$e/@EndCol}'>
{
concat('&#10;', local:SourceLines($c/@Source, $e/@StartLine, $e/@EndLine), '&#10;')
}
</EmptyIfPart>
}
</EmptyIfParts>

Просмотреть файл

@ -0,0 +1,8 @@
<Entities>
{
for $e in /Entity
return <Entity Artifact='{$e/@Artifact}'
StartLine='{$e/@StartLine}' EndLine='{$e/@EndLine}'
StartCol='{$e/@StartCol}' EndCol='{$e/@EndCol}' />
}
</Entities>

Просмотреть файл

@ -0,0 +1,6 @@
let $packages := distinct-values(/Class/@Package)
for $p in $packages
return $p || ',' || sum(/(Class | Form | Query | Table)[@Package=$p]/@EndLine)

Просмотреть файл

@ -21,21 +21,21 @@
-- 3) Use the "Export data…" facility on the database (under tasks) in MSSQL. It does work (and you can provide a query) but it is cumbersome to set up.
select LOWER('/' + sourceModule.Module + source.[Path]) as ":START_ID", 
LOWER('/' + targetModule.Module + target.[Path]) as ":END_ID",
select LOWER('/' + sourceModule.Module + source.[Path]) as ":START_ID",
LOWER('/' + targetModule.Module + target.[Path]) as ":END_ID",
'CALLS' as ":TYPE",
       count(target.Path) as "Count:int"
from dbo.[References] as refs
join dbo.[Names] as source on refs.SourceId = source.Id
join dbo.Modules as sourceModule on source.ModuleId = sourceModule.Id
join dbo.[Names] as target on refs.TargetId = target.Id
join dbo.Modules as targetModule on target.ModuleId = targetModule.Id
-- Call. Even references to fields are marked as calls, prompting filtering below.
where refs.kind = 1 
count(target.Path) as "Count:int"
from dbo.[References] as refs
join dbo.[Names] as source on refs.SourceId = source.Id
join dbo.Modules as sourceModule on source.ModuleId = sourceModule.Id
join dbo.[Names] as target on refs.TargetId = target.Id
join dbo.Modules as targetModule on target.ModuleId = targetModule.Id
-- Call. Even references to fields are marked as calls, prompting filtering below.
where refs.kind = 1
and targetModule.Module not like 'kerneltypemodule' -- exclude .NET calls
and (target.Path like '/Classes/%/Methods/%'
or target.Path like '/Tables/%/Methods/%'
or target.Path like '/Queries/%/Methods/%'
or target.Path like '/Forms/%/Methods/%'
or target.Path like '/Views/%/Methods/%')
group by source.Path, sourceModule.Module, target.Path, targetModule.Module
and (target.Path like '/Classes/%/Methods/%'
or target.Path like '/Tables/%/Methods/%'
or target.Path like '/Queries/%/Methods/%'
or target.Path like '/Forms/%/Methods/%'
or target.Path like '/Views/%/Methods/%')
group by source.Path, sourceModule.Module, target.Path, targetModule.Module

Просмотреть файл

@ -0,0 +1,12 @@
<Entities>
{
for $e in /Entity
return <Entity Artifact='{$e/@Artifact}'
StartLine='{$e/@StartLine}' EndLine='{$e/@EndLine}'
StartCol='{$e/@StartCol}' EndCol='{$e/@EndCol}' >
{
$e/Metadata//ViewMetadata/DataSources//Table
}
</Entity>
}
</Entities>

Просмотреть файл

@ -0,0 +1,124 @@
<R>
{
for $c in /(Class | Table | Query | Form)
for $m in $c//Method
let $name := $m/@Name
where lower-case($m/@Name) = ("next",
"while",
"guid",
"int",
"int64",
"str",
"container",
"real",
"date",
"utcdatetime",
"void",
"anytype",
"null",
"super",
"class",
"interface",
"implements",
"extends",
"like",
"div",
"mod",
"in",
"do",
"throw",
"try",
"catch",
"switch",
"case",
"default",
"if",
"else",
"print",
"break",
"breakpoint",
"continue",
"return",
"f",
"retry",
"select",
"delete_from",
"from",
"index",
"hint",
"firstfast",
"reverse",
"firstonly",
"firstonly1",
"firstonly10",
"firstonly100",
"firstonly1000",
"fceliterals",
"fcenestedloop",
"fceselectder",
"fceplaceholders",
"fupdate",
"nofetch",
"repeatableread",
"optimisticlock",
"pessimisticlock",
"generateonly",
"crosscompany",
"where",
"der",
"group",
"by",
"asc",
"desc",
"outer",
"exists",
"notexists",
"join",
"count",
"avg",
"sum",
"minof",
"maxof",
"insert_recdset",
"update_recdset",
"setting",
"ttsbegin",
"ttscommit",
"ttsabt",
"flush",
"next",
"changecompany",
"private",
"protected",
"public",
"final",
"abstract",
"static",
"display",
"edit",
"server",
"client",
"true",
"false",
"eventhandler",
"delegate",
"as",
"is",
"byref",
"unchecked",
"validtimestate",
"finally",
"namespace",
"using",
"const",
"readonly",
"internal",
"var" )
order by $name
return <NamedMethod Artifact='{$c/@Artifact}'
Name='{$m/@Name}'
StartLine='{$m/@StartLine}' EndLine='{$m/@EndLine}'
StartCol='{$m/@StartCol}' EndCol='{$m/@EndCol}'
/>
}
</R>