atomist-attic / rug

DEPRECATED Runtime for Rugs
GNU General Public License v3.0
53 stars 13 forks source link

When a path expression in JavaType() fails, let it be empty #578

Closed jessitron closed 7 years ago

jessitron commented 7 years ago

When my path expression had no matches, instead of an empty result, I got an exception:

com.atomist.rug.RugRuntimeException: <unknown>: No child with name 'methodDeclaration' in JavaClassOrInterfaceMutableView

Maybe it's falling back to looking for methods or children on the view, and then failing when that doesn't work.

The path expression was: /JavaType()//methodDeclaration[/methodHeader/methodDeclarator/Identifier[@value='${methodName}']] (where a method by that name was not found)

This might be specific to JavaType() where it has a special MutableView? not sure. Either way, it's unexpected.

jessitron commented 7 years ago

(this is not high priority)

jessitron commented 7 years ago

further note which may provide a clue: That path expression does not match even when the methodName is correct.

This one does: /JavaFile()/typeDeclaration/classDeclaration/normalClassDeclaration/classBody/classBodyDeclaration/classMemberDeclaration/methodDeclaration[/methodHeader/methodDeclarator/Identifier[@value='peelTest']]

So maybe there's a problem with // descendants

jessitron commented 7 years ago

hmm I just noticed that I was trying JavaType() and the good path expression is JavaFile()

oops