BBx-Kitchen / bbj-language-server

BBj Language Server
MIT License
7 stars 6 forks source link

structural issue related to SWITCH CASE inside a method #185

Closed StephanWald closed 1 day ago

StephanWald commented 4 weeks ago

This class is flagged a problem for unclear reasons:

rem --------------------------------------------------------------------------
rem Program    : DialogUtils.bbj
rem Description: Dialog Utilities
rem Project    : BASIS Europe Utilities
rem
rem Author(s)  : R.Lance
rem Created    : 07.2011
rem Copyright Basis Europe Distribution GmbH, Saarbruecken, GERMANY
rem --------------------------------------------------------------------------

rem package DialogWizard

use ::DialogWizard/Control.bbj::Control
use ::translations/bbtranslator.bbj::BBTranslator
use java.util.HashMap

rem /** 
rem * DialogUtils
rem * 
rem * Dialog Utilities Class
rem * 
rem * @author R.Lance
rem * @version 1.0
rem */
class public DialogUtils

    rem /**
    rem * Method buildDialogProperties:
    rem * Create property files given a BBTranslator object and a set of controls
    rem * @param BBTranslator BBTranslator object
    rem * @param BBjVector Vector of controls (built in getAllControlsRecursive())
    rem */
    method public static void buildDialogProperties(BBTranslator pTranslator!, BBjVector pCtrlVect!)
        declare HashMap controlMap!

        for c=0 to ctrlCount
            controlMap!=cast(HashMap,pCtrlVect!.getItem(c))
            name$=cast(BBjString,controlMap!.get("ConstructedName"))
            ctrl!=cast(BBjControl,controlMap!.get("ControlInstance"))
            if ctrl!<>null() then
                if ctrl!.getControlType()=ctrl!.STATIC_TEXT_TYPE and name$="StaticText" then
                    name$=name$+"_"+str(ctrl!.getID())
                endif
                switch ctrl!.getControlType()
                    case ctrl!.LISTBUTTON_TYPE
                    case ctrl!.LISTEDIT_TYPE
                    case ctrl!.LISTBOX_TYPE
                        if ctrl!.getBoundRecordSet(err=*next)=null() then
                            textVect!=ctrl!.getAllItems()
                            textCount=textVect!.size()
                            if textCount=0 continue
                            for t=0 to textCount-1
                                text$=cast(BBjString,textVect!.getItem(t))
                                text2$=pTranslator!.getTranslation(name$+"_item_"+str(t),text$,#TRUE,forceAdd)
                                textVect!.setItem(t,text2$)
                            next t
                            ctrl!.removeAllItems()
                            ctrl!.insertItems(0,textVect!)
                        endif
                        text$=ctrl!.getToolTipText()
                        if text$<>"" then
                            text2$=pTranslator!.getTranslation(name$+"_tooltip",text$,#TRUE,forceAdd)
                            ctrl!.setToolTipText(text2$)
                        endif
                    break
                    case ctrl!.TOP_TYPE
                    case ctrl!.BARCHART_TYPE
                    case ctrl!.LINECHART_TYPE
                    case ctrl!.PIECHART_TYPE
                        text$=ctrl!.getTitle()
                        if text$<>"" then
                            text2$=pTranslator!.getTranslation(name$+"_title",text$,#TRUE,forceAdd)
                            ctrl!.setTitle(text2$)
                        endif
                    break
                    case ctrl!.BUTTON_TYPE
                    case ctrl!.CHECKBOX_TYPE
                    case ctrl!.GROUPBOX_TYPE
                    case ctrl!.MENUBUTTON_TYPE
                    case ctrl!.RADIOBUTTON_TYPE
                    case ctrl!.STATIC_TEXT_TYPE
                    case ctrl!.TOOLBUTTON_TYPE
                        text$=ctrl!.getText()
                        if text$<>"" then
                            if pos("BITMAP="=text$)=0 then
                                text2$=pTranslator!.getTranslation(name$+"_text",text$,#TRUE,forceAdd)
                                ctrl!.setText(text2$)
                            endif
                        endif
                        text$=ctrl!.getToolTipText()
                        if text$<>"" then
                            text2$=pTranslator!.getTranslation(name$+"_tooltip",text$,#TRUE,forceAdd)
                            ctrl!.setToolTipText(text2$)
                        endif
                    break
                    case ctrl!.TREE_TYPE
                        text$=ctrl!.getToolTipText()
                        if text$<>"" then
                            text2$=pTranslator!.getTranslation(name$+"_tooltip",text$,#TRUE,forceAdd)
                            ctrl!.setToolTipText(text2$)
                        endif
                        rem ...needs to be recursive...BBjTree::getRoot() has been requested...
                        n=0,n=ctrl!.getNumChildren(0,err=*next)
                        if n=0 continue
                        for i=0 to n-1
                            node=ctrl!.getChildAt(0,i)
                            text$=ctrl!.getNodeText(node)
                            text2$=pTranslator!.getTranslation(name$+"_node_"+str(node),text$,#TRUE,forceAdd)
                            ctrl!.setNodeText(node,text2$)
                        endif
                    break
                    case ctrl!.TABCTRL_TYPE
                        text$=ctrl!.getToolTipText()
                        if text$<>"" then
                            text2$=pTranslator!.getTranslation(name$+"_tooltip",text$,#TRUE,forceAdd)
                            ctrl!.setToolTipText(text2$)
                        endif
                        n=ctrl!.getNumTabs()
                        if n=0 continue
                        for t=0 to n-1
                            text$=ctrl!.getTitleAt(t)
                            if text$<>"" then
                                text2$=pTranslator!.getTranslation(name$+"_tab_"+str(t),text$,#TRUE,forceAdd)
                                ctrl!.setTitleAt(t,text2$)
                            endif
                        next t
                    break
                    case ctrl!.GRID_TYPE
                    break
                    case ctrl!.MENU_TYPE
                    break
                    case default
                    break
                swend
            endif
        next c

    methodend

classend

When I remote the SWITCH...SWEND part, the problem is solved.

image

Lotes commented 4 days ago

It is again the case default. If you add an ; after it, it will work. I think the solution is to make the semicolon optional at that position, like we do for other case statements.