/*
 * Copyright (c) 2018, 2025, 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-ts-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.tsNodeTypes;ret[nt.NEW_EXPR]=this._onNew;return ret}_onNew(ruleCtx,node){var component,issue,status;var me,obj,start;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&&(status=ruleCtx.utils.metaLib.isClassDeprecated(component))){let comment,since;if(comment=ruleCtx.utils.utils.removeMarkup(status.description)){if(!comment.endsWith(PERIOD)){comment=" "+comment+PERIOD}comment=" "+comment}else if(!status.target&&status.value){let alternatives=" Alternative";alternatives+=status.value.length>1?"s are ":" is ";comment=alternatives+status.value.join(", ")+"."}else{comment=""};since=(since=status.since)?" (since "+since+")":"";issue=new ruleCtx.Issue(`Instantiation of deprecated JET class ${component}${since}.${comment}`);issue.setPosition(null,null,start.range[0],start.range[0]+component.length);ruleCtx.reporter.addIssue(issue,ruleCtx)}}}module.exports=Rule;