Universal-Variability-Language / uvl-lsp

Language server protocol for the Universal Variability Language (UVL)
MIT License
10 stars 4 forks source link

UVLS crashes in constraint auto-completion #128

Open st-vi opened 10 months ago

st-vi commented 10 months ago

I recognized the error when working with the elevator example from the feature IDE book.

features
    Elevator {abstract}
        mandatory
            Behavior {abstract}
                mandatory
                    Modes {abstract}
                        alternative
                            Sabbath
                            FIFO
                            ShortestPath
                optional
                    Service
                    Priorities {abstract}
                        or
                            RushHour
                            FloorPriority
                            PersonPriority
        optional
            VoiceOutput
            CallButtons {abstract}
                alternative
                    DirectedCall
                    UndirectedCall
            Security {abstract}
                mandatory
                    Permission {abstract}
                        or
                            FloorPermission
                            PermissionControl
            Safety {abstract}
                optional
                    Overloaded

constraints
    CallButtons | Sabbath
    DirectedCall => ShortestPath
    UndirectedCall => FIFO | ShortestPath

When writing new constraints the server crashes. It seems to be related to the length of the feature model.

For example the model

    Elevator {abstract}
        mandatory
            Behavior {abstract}
                mandatory
                    Modes {abstract}
                        alternative
                            Sabbath
                            FIFO
                            ShortestPath
                optional
                    Service
                    Priorities {abstract}
                        or
                            RushHour
                            FloorPriority
                            PersonPriority
        optional
            VoiceOutput
            CallButtons {abstract}
                alternative
                    DirectedCall
                    UndirectedCall
            Security {abstract}
                mandatory
                    Permission {abstract}
                        or
                            FloorPermission
                            PermissionControl
            Safety {abstract}
                optional
                    Overloaded

constraints

crashes when starting to write the constraint CallButtons

but when we remove two features (does not matter which ones, I think) like this

    Elevator {abstract}
        mandatory
            Behavior {abstract}
                mandatory
                    Modes {abstract}
                        alternative
                            Sabbath
                optional
                    Service
                    Priorities {abstract}
                        or
                            RushHour
                            FloorPriority
                            PersonPriority
        optional
            VoiceOutput
            CallButtons {abstract}
                alternative
                    DirectedCall
                    UndirectedCall
            Security {abstract}
                mandatory
                    Permission {abstract}
                        or
                            FloorPermission
                            PermissionControl
            Safety {abstract}
                optional
                    Overloaded

constraints

everything is fine when writing the constraint.

I could reproduce this error with different feature models that have a certain length.

ThiBruUU commented 10 months ago

Copying feature models may lead to errors. In the current example, the PersonPriority feature results in an error. The error is shown in the image below. Normally, as can be seen, it is always read out line by line. However, by copying the feature model, a blank line is incorrectly inserted here. Error_PersonPriority

If you look at the corresponding code, which looks at the lines read out, it is clear that these two strings that are passed in one line cannot be processed. Error_PersonPriority_Code

If you delete the line with this feature and write the feature again by hand, at least for me no errors are thrown and the constraint completion works correctly.

If that still doesn't help, please try again if the entire feature model is written by hand.

ThiBruUU commented 10 months ago

How should such problems be dealt with? Apparently the problem occurs more often when content (feature models) is copied and pasted. @SundermannC

SundermannC commented 10 months ago

Thank you for checking! For me, it seems like the fix should target the unexpected blank line. Handling it later, when the error occurs, does not seem optimal.

Do we know what causes the added blank line?