Code review comment: Do we have a better way to differentiate a resource function

Code under review:
private void emitTransactionParticipantBeginIfApplicable(BLangBlockStmt body) {
        BLangNode parent = body.parent;
        if (parent == null) {
            return;
        }
        
        if (parent instanceof BLangFunction) {
            Set<Flag> flagSet = ((BLangFunction) parent).flagSet;
            if (flagSet != null && flagSet.contains(Flag.RESOURCE)) {
                return;
            }
            BLangFunction function = (BLangFunction) parent;
            List<BLangAnnotationAttachment> participantAnnotation = function.annAttachments.stream()
                    .filter(a -> Transactions.isTransactionsAnnotation(a.pkgAlias.value, a.annotationName.value))
                    .collect(Collectors.toList());
            if (participantAnnotation.isEmpty()) {
                
                return;
            }

            transactionIndex++;
            BLangAnnotationAttachment annotation = participantAnnotation.get(0);
            Operand abortedFuncRegIndex = new RegIndex(-1, TypeTags.INVOKABLE);
            Operand committedFuncRegIndex = new RegIndex(-1, TypeTags.INVOKABLE);

            for (BLangRecordKeyValue keyValuePair : ((BLangRecordLiteral) annotation.expr).getKeyValuePairs()) {
                if (((BLangLiteral) keyValuePair.getKey()).value.equals(Transactions.TRX_ONABORT_FUNC)) {
                    abortedFuncRegIndex.value = getFuncRefCPIndex(
                            (BInvokableSymbol) ((BLangSimpleVarRef) keyValuePair.getValue()).symbol);
                }
                if (((BLangLiteral) keyValuePair.getKey()).value.equals(Transactions.TRX_ONCOMMIT_FUNC)) {
                    committedFuncRegIndex.value = getFuncRefCPIndex(
                            (BInvokableSymbol) ((BLangSimpleVarRef) keyValuePair.getValue()).symbol);
                }
            }
            
            Operand transactionIndexOperand = getOperand(transactionIndex);
            Operand transactionType = getOperand(Transactions.TransactionType.PARTICIPANT.value);
            RegIndex retryCountRegIndex = getRegIndex(TypeTags.INT);
            this.emit(InstructionCodes.TR_BEGIN, transactionType, transactionIndexOperand, retryCountRegIndex,
                    committedFuncRegIndex, abortedFuncRegIndex);
        }
    }

Line commented on: if (flagSet != null && flagSet.contains(Flag.RESOURCE)) {

Revised code:
private void emitTransactionParticipantBeginIfApplicable(BLangBlockStmt body) {
        BLangNode parent = body.parent;
        if (parent == null || parent.getKind() != NodeKind.FUNCTION) {
            return;
        }
        BLangFunction function = (BLangFunction) parent;
        List<BLangAnnotationAttachment> participantAnnotation = function.annAttachments.stream()
                .filter(a -> Transactions.isTransactionsAnnotation(a.pkgAlias.value, a.annotationName.value))
                .collect(Collectors.toList());
        if (participantAnnotation.isEmpty()) {
            
            return;
        }

        transactionIndex++;
        BLangAnnotationAttachment annotation = participantAnnotation.get(0);
        Operand abortedFuncRegIndex = new RegIndex(-1, TypeTags.INVOKABLE);
        Operand committedFuncRegIndex = new RegIndex(-1, TypeTags.INVOKABLE);

        for (BLangRecordKeyValue keyValuePair : ((BLangRecordLiteral) annotation.expr).getKeyValuePairs()) {
            if (((BLangLiteral) keyValuePair.getKey()).value.equals(Transactions.TRX_ONABORT_FUNC)) {
                abortedFuncRegIndex.value = getFuncRefCPIndex(
                        (BInvokableSymbol) ((BLangSimpleVarRef) keyValuePair.getValue()).symbol);
            }
            if (((BLangLiteral) keyValuePair.getKey()).value.equals(Transactions.TRX_ONCOMMIT_FUNC)) {
                committedFuncRegIndex.value = getFuncRefCPIndex(
                        (BInvokableSymbol) ((BLangSimpleVarRef) keyValuePair.getValue()).symbol);
            }
        }
        
        Operand transactionIndexOperand = getOperand(transactionIndex);
        int participantType = getParticipantTypeTag(function);
        Operand transactionType = getOperand(participantType);
        RegIndex retryCountRegIndex = getRegIndex(TypeTags.INT);
        this.emit(InstructionCodes.TR_BEGIN, transactionType, transactionIndexOperand, retryCountRegIndex,
                committedFuncRegIndex, abortedFuncRegIndex);
    }