From c37977e9f9019e3aea03d9026a9913d4408a7930 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Tue, 19 Mar 2024 01:44:02 -0400 Subject: [PATCH] review fix --- .../declarations-override/{x-uses.h => allowsFocus.h} | 0 .../templates/declarations/{x-uses.h => allowsFocus.h} | 0 .../cpp/templates/methods/{x-uses.cpp => allowsFocus.cpp} | 0 src/macrofier/engine.mjs | 6 +++--- src/shared/modules.mjs | 8 ++++---- 5 files changed, 7 insertions(+), 7 deletions(-) rename languages/cpp/templates/declarations-override/{x-uses.h => allowsFocus.h} (100%) rename languages/cpp/templates/declarations/{x-uses.h => allowsFocus.h} (100%) rename languages/cpp/templates/methods/{x-uses.cpp => allowsFocus.cpp} (100%) diff --git a/languages/cpp/templates/declarations-override/x-uses.h b/languages/cpp/templates/declarations-override/allowsFocus.h similarity index 100% rename from languages/cpp/templates/declarations-override/x-uses.h rename to languages/cpp/templates/declarations-override/allowsFocus.h diff --git a/languages/cpp/templates/declarations/x-uses.h b/languages/cpp/templates/declarations/allowsFocus.h similarity index 100% rename from languages/cpp/templates/declarations/x-uses.h rename to languages/cpp/templates/declarations/allowsFocus.h diff --git a/languages/cpp/templates/methods/x-uses.cpp b/languages/cpp/templates/methods/allowsFocus.cpp similarity index 100% rename from languages/cpp/templates/methods/x-uses.cpp rename to languages/cpp/templates/methods/allowsFocus.cpp diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index 73129035..efe4607a 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -29,7 +29,7 @@ import isString from 'crocks/core/isString.js' import predicates from 'crocks/predicates/index.js' const { isObject, isArray, propEq, pathSatisfies, propSatisfies } = predicates -import { isRPCOnlyMethod, isProviderInterfaceMethod, getProviderInterface, getPayloadFromEvent, providerHasNoParameters, isTemporalSetMethod, hasMethodAttributes, getMethodAttributes, isEventMethodWithContext, getSemanticVersion, getSetterFor, getProvidedCapabilities, isPolymorphicPullMethod, hasPublicAPIs, isXUsesMethod, hasXUsesMethods, createPolymorphicMethods, isExcludedMethod, isCallsMetricsMethod } from '../shared/modules.mjs' +import { isRPCOnlyMethod, isProviderInterfaceMethod, getProviderInterface, getPayloadFromEvent, providerHasNoParameters, isTemporalSetMethod, hasMethodAttributes, getMethodAttributes, isEventMethodWithContext, getSemanticVersion, getSetterFor, getProvidedCapabilities, isPolymorphicPullMethod, hasPublicAPIs, isAllowFocusMethod, hasAllowFocusMethods, createPolymorphicMethods, isExcludedMethod, isCallsMetricsMethod } from '../shared/modules.mjs' import isEmpty from 'crocks/core/isEmpty.js' import { getPath as getJsonPath, getLinkedSchemaPaths, getSchemaConstraints, isSchema, localizeDependencies, isDefinitionReferencedBySchema, mergeAnyOf, mergeOneOf, getSafeEnumKeyName } from '../shared/json-schema.mjs' @@ -108,7 +108,7 @@ const getTemplate = (name, templates) => { } const getTemplateTypeForMethod = (method, type, templates) => { - const name = method.tags ? (isXUsesMethod(method) && Object.keys(templates).find(name => name.startsWith(`/${type}/x-uses.`))) ? 'x-uses' : (method.tags.map(tag => tag.name.split(":").shift()).find(tag => Object.keys(templates).find(name => name.startsWith(`/${type}/${tag}.`)))) || 'default' : 'default' + const name = method.tags ? (isAllowFocusMethod(method) && Object.keys(templates).find(name => name.startsWith(`/${type}/allowsFocus.`))) ? 'allowsFocus' : (method.tags.map(tag => tag.name.split(":").shift()).find(tag => Object.keys(templates).find(name => name.startsWith(`/${type}/${tag}.`)))) || 'default' : 'default' const path = `/${type}/${name}` return getTemplate(path, templates) } @@ -1723,7 +1723,7 @@ function insertCapabilityMacros(template, capabilities, method, module) { function generateXUsesInterfaces(json, templates) { let template = '' - if (hasXUsesMethods(json)) { + if (hasAllowFocusMethods(json)) { const suffix = state.destination ? state.destination.split('.').pop() : '' template = getTemplate(suffix ? `/sections/xuses-interfaces.${suffix}` : '/sections/xuses-interfaces', templates) if (!template) { diff --git a/src/shared/modules.mjs b/src/shared/modules.mjs index 8413cf75..768356f0 100644 --- a/src/shared/modules.mjs +++ b/src/shared/modules.mjs @@ -289,7 +289,7 @@ const isPolymorphicReducer = compose( getPath(['tags']) ) -const isXUsesMethod = compose( +const isAllowFocusMethod = compose( option(false), map(_ => true), chain(find(and( @@ -369,7 +369,7 @@ const getPublicEvents = compose( const hasPublicInterfaces = json => json.methods && json.methods.filter(m => m.tags && m.tags.find(t=>t['x-provides'])).length > 0 const hasPublicAPIs = json => hasPublicInterfaces(json) || (json.methods && json.methods.filter( method => !method.tags.find(tag => tag.name === 'rpc-only')).length > 0) -const hasXUsesMethods = json => json.methods && json.methods.filter(m => isXUsesMethod(m)).length > 0 +const hasAllowFocusMethods = json => json.methods && json.methods.filter(m => isAllowFocusMethod(m)).length > 0 const eventDefaults = event => { @@ -1435,8 +1435,8 @@ export { isPublicEventMethod, hasPublicAPIs, hasPublicInterfaces, - isXUsesMethod, - hasXUsesMethods, + isAllowFocusMethod, + hasAllowFocusMethods, isPolymorphicReducer, isPolymorphicPullMethod, isTemporalSetMethod,