/*
 * 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 RULENAME="oj-js-ojcomp-deprecated";const DESCRIPTION="Deprecated JET component classes should not be instantiated";const SHORT_DESCRIPTION="Deprecated JET component classes should not be instantiated";const PERIOD=".";var nt;class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){var ret={};nt=regCtx.jsNodeTypes;ret[nt.NEW_EXPR]=this._onNew;return ret}_onNew(ruleCtx,node){var component,issue,status,comment,since;var me,obj,start,pos;me=node.callee;if(me.type===nt.MEMBER_EXPR){obj=me.object;if(obj&&obj.type===nt.IDENTIFIER){if(obj.name==="oj"){if(me.property&&me.property.name){component="oj."+me.property.name;start=obj}}}}else if(me.type===nt.IDENTIFIER){component=me.name;start=me}if(component){if(status=ruleCtx.utils.metaLib.isClassDeprecated(component)){comment=ruleCtx.utils.utils.removeMarkup(status.description);since=status.since;since=since?"(since "+since+") ":"";issue=new ruleCtx.Issue(`Instantiation of deprecated ${since}JET class ${component}. ${comment} ${comment.endsWith(PERIOD)?"":PERIOD}`);let ft=ruleCtx.filepath.substring(ruleCtx.filepath.lastIndexOf(".")+1);start=ft==="ts"?start.range[0]:start.start;pos=ruleCtx.utils.utils.getRowColFromIndex(ruleCtx.data,start,ft);issue.setPosition(pos.row,pos.col,start,start+component.length);ruleCtx.reporter.addIssue(issue,ruleCtx)}}}}module.exports=Rule;