All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core_functions_unclassified.meta.getAllPackageableElements.pure Maven / Gradle / Ivy

There is a newer version: 4.67.9
Show newest version
// Copyright 2023 Goldman Sachs
//
// 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.

function {doc.doc = 'Get all the elements of a package.  If recursive is true, then elements belonging to sub-packages are also returned; otherwise, only elements from the package itself are returned.  The package itself is never returned.'}
         meta::pure::functions::meta::getAllPackageElements(pkg:Package[1], recursive:Boolean[1]):PackageableElement[*]
{
    if($recursive, |$pkg->getAllPackageElements_Recursive(), |$pkg.children)
}

function <> meta::pure::functions::meta::getAllPackageElements_Recursive(pkg:Package[1]):PackageableElement[*]
{
    // HACK children of a package should be PackageableElements, but sometimes they are not.
    $pkg.children->map(child:Any[1] | $child->match([
                                              p:Package[1] | $p->getAllPackageElements_Recursive()->add($p),
                                              p:PackageableElement[1] | $p,
                                              a:Any[1] | []
                                             ]))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy