archimatetool / archi-scripting-plugin

jArchi - Scripting for Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
118 stars 33 forks source link

The collection.parents() method does not accept a selector while the docs state it does #133

Closed JasperSurmont closed 1 month ago

JasperSurmont commented 1 month ago

Version of jArchi, Operating System

Version 1.5, Windows 11

Expected Behaviour

According to the docs, the collection.parents() also has an optional selector argument.

Actual Behaviour

I get the following error:

org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (parents) on
com.archimatetool.script.dom.model.EObjectProxyCollection failed due to: Arity error - expected: 0 actual: 1

Steps to Reproduce the Behaviour (with attached test files/script)

  1. As far as I've found, works in any model (but I'll attach one just for certainty)
  2. In the script, call $(<any selector>).parents(<any selector>), e.g. $('element').parents('folder')
  3. See the error output

Example script jarchi-bug.zip

Phillipus commented 1 month ago

Hi,

thanks for the heads up.

the documentation is wrong (a copy and paste error) and I've updated the wiki now.

collection.parents(selector) is not actually implemented. I can implement it for the next version of jArchi but you can achieve the same result with:

collection.parents().filter(selector)

JasperSurmont commented 1 month ago

Thanks for the quick response 😄

That works indeed, thanks.