UNPKG

@codeque/core

Version:

Multiline code search for every language. Structural code search for JavaScript, TypeScript, HTML and CSS

56 lines (50 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.matchHashWithWildcard = void 0; var _matchStringOrIdentifierAliases = require("../../searchStages/matchStringOrIdentifierAliases"); /* * Adds support for matching color Hash with wildcard * Q: {color: $$ } C: {color: #000 } */ const matchHashWithWildcard = ({ queryNode, fileNode, searchSettings, matchContext }, _, { fileKeysToTraverseForOtherMatches, log }) => { if (queryNode?.type === 'Identifier' && fileNode?.type === 'Hash') { const { wildcardUtils } = searchSettings.parserSettings; const { caseInsensitive } = searchSettings; const queryNodeStringContent = queryNode.name; const fileNodeStringContent = fileNode.value; const wildcardsMeta = wildcardUtils.getStringWildcardsFromString(queryNodeStringContent); if (wildcardsMeta.length > 0) { const levelMatch = (0, _matchStringOrIdentifierAliases.matchStringOrIdentifierAliases)({ queryValue: queryNodeStringContent, fileValue: fileNodeStringContent, wildcardsMeta, matchContext, wildcardUtils, caseInsensitive }); if (levelMatch) { return { levelMatch, queryKeysToTraverseForValidatingMatch: [], fileKeysToTraverseForValidatingMatch: [], fileKeysToTraverseForOtherMatches }; } } } }; exports.matchHashWithWildcard = matchHashWithWildcard;