/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at . */
import { containsLocation, containsPosition } from "./utils/contains";
import { getSymbols } from "./getSymbols";
function findSymbols(source) {
const { functions, comments } = getSymbols(source);
return { functions, comments };
}
/**
* Returns the location for a given function path. If the path represents a
* function declaration, the location will begin after the function identifier
* but before the function parameters.
*/
function getLocation(func) {
const location = { ...func.location };
// if the function has an identifier, start the block after it so the
// identifier is included in the "scope" of its parent
const identifierEnd = func?.identifier?.loc?.end;
if (identifierEnd) {
location.start = identifierEnd;
}
return location;
}
/**
* Find the nearest location containing the input position and
* return inner locations under that nearest location
*
* @param {Array