/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-method-displayname"};ruleDef.prototype.getShortDescription=function(){return"Check component has display name defined for methods"};ruleDef.prototype.getDescription=function(){return"This rule checks that methods have a display name supplied to make the user experience in Visual Builder as useful as possible"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);if(componentType==="composite"){this._checkMethods(context,meta.methods)}}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkMethods(context,componentInfo.methods)}};ruleDef.prototype._checkMethods=function(context,methods){let issue;if(methods){Object.keys(methods).forEach(methodName=>{if(!methods[methodName].displayName&&!["setProperty","getProperty","setProperties"].includes(methodName)){issue=new context.Issue(`displayName for method '${methodName}' should be defined`);context.reporter.addIssue(issue,context)}})}};module.exports=ruleDef;