Skip to content

Content assist proposals sometimes invoked at test comment instead of test DSL #345

@trancexpress

Description

@trancexpress

Opening an issue since I don't see a discussions section for Xpect.

We have more or less the following test DSL:

    keyword1 name1 {
        // Verify that keyword2.property10, keyword2.property20, keyword2.property30 and
        // keyword2.property40 are not shown.
        // XPECT proposals at 'keyword2.|' --> property1, property2, property3
        // XPECT proposals at '=|' --> value1, value2
        // Verify that safety lines are shown for keyword2.property1
        keyword2.property1 = value1;
    }

When I remove the 2nd XPECT statement, or run this test with my JUnit 5 changes (see #343), the test fails. It fails due due to the wrong offset provided by org.eclipse.xpect.parameter.OffsetProvider.getMatchedOffset().

The region in the fail case is within the comment "// Verify that safety lines are shown for keyword2.property1". The region in the pass case is the actually relevant test DSL "keyword2.property1 = value1;".

What is the defined behavior here? Is there some way to mark Xpect comments as Xpect comments and not as potential DSL comments? To "fix" the test fail, I've moved the "confusing" comment to be above the XPECTstatement:

    keyword1 name1 {
        // Verify that keyword2.property10, keyword2.property20, keyword2.property30 and
        // keyword2.property40 are not shown.
        // Verify that safety lines are shown for keyword2.property1
        // XPECT proposals at 'keyword2.|' --> property1, property2, property3
        // XPECT proposals at '=|' --> value1, value2
        keyword2.property1 = value1;
    }

I also don't know why this behavior shows up only without the 2nd XPECT statement with JUnit 4 XpectRunner, but always with my JUnit 5 alternative.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions