Skip to content

Commit d624060

Browse files
pass include candidates to code coverage reporter
1 parent 695829f commit d624060

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

sqldev/src/main/java/org/utplsql/sqldev/menu/UtplsqlController.xtend

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,34 @@ class UtplsqlController implements Controller {
296296
}
297297
}
298298

299+
def List<String> dependencies(String name, String connectionName) {
300+
var List<String> ret = null
301+
if (connectionName !== null) {
302+
val dao = new UtplsqlDao(Connections.instance.getConnection(connectionName))
303+
ret = dao.includes(name)
304+
}
305+
return ret
306+
}
307+
308+
def List<String> dependencies(Context context, String connectionName) {
309+
val HashSet<String> ret = new HashSet<String>
310+
for (i : 0 ..< context.selection.length) {
311+
val element = context.selection.get(i)
312+
if (element instanceof PlSqlNode) {
313+
val dep = dependencies(element.objectName, connectionName)
314+
for (d : dep) {
315+
ret.add(d)
316+
}
317+
} else if (element instanceof ChildObjectElement) {
318+
val dep = dependencies(element.URL.memberObject, connectionName)
319+
for (d : dep) {
320+
ret.add(d)
321+
}
322+
}
323+
}
324+
return ret.toList.sortBy[it]
325+
}
326+
299327
def codeCoverage(Context context) {
300328
val view = context.view
301329
val node = context.node
@@ -307,7 +335,6 @@ class UtplsqlController implements Controller {
307335
var String owner = null;
308336
if (node instanceof DatabaseSourceNode) {
309337
connectionName = node.connectionName
310-
owner = node.owner
311338
} else if (view instanceof Worksheet) {
312339
connectionName = view.connectionName
313340
}
@@ -316,17 +343,20 @@ class UtplsqlController implements Controller {
316343
val parser = new UtplsqlParser(component.text, if (preferences.checkRunUtplsqlTest) {Connections.instance.getConnection(connectionName)} else {null}, owner)
317344
val position = component.caretPosition
318345
val path = parser.getPathAt(position)
319-
val reporter = new CodeCoverageReporter(path.pathList, connectionName)
320-
reporter.runAsync
346+
val object = parser.getObjectAt(position)
347+
val includeObjectList = dependencies(object.name, connectionName)
348+
val reporter = new CodeCoverageReporter(path.pathList, includeObjectList, connectionName)
349+
reporter.showParameterWindow
321350
}
322351
} else if (view instanceof DBNavigatorWindow) {
323352
val url=context.URL
324353
if (url !== null) {
325354
val connectionName = url.connectionName
326355
logger.fine('''connectionName: «connectionName»''')
327356
val pathList=context.pathList.dedupPathList
328-
val reporter = new CodeCoverageReporter(pathList, connectionName)
329-
reporter.runAsync
357+
val includeObjectList = dependencies(context, connectionName)
358+
val reporter = new CodeCoverageReporter(pathList, includeObjectList, connectionName)
359+
reporter.showParameterWindow
330360
}
331361
}
332362
}

0 commit comments

Comments
 (0)