Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Mar 19, 2024
1 parent 4a2701a commit c37977e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/shared/modules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const isPolymorphicReducer = compose(
getPath(['tags'])
)

const isXUsesMethod = compose(
const isAllowFocusMethod = compose(
option(false),
map(_ => true),
chain(find(and(
Expand Down Expand Up @@ -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 => {

Expand Down Expand Up @@ -1435,8 +1435,8 @@ export {
isPublicEventMethod,
hasPublicAPIs,
hasPublicInterfaces,
isXUsesMethod,
hasXUsesMethods,
isAllowFocusMethod,
hasAllowFocusMethods,
isPolymorphicReducer,
isPolymorphicPullMethod,
isTemporalSetMethod,
Expand Down

0 comments on commit c37977e

Please sign in to comment.