Skip to content

Static imports are overwritten when using content assist #177

@eric-milles

Description

@eric-milles

An issue I keep running into in the Groovy editor is that static imports get mangled when using content assist or pasting a block of code that modifies the imports. I have a small example below that should demonstrate the issue. When trying to add "@TypeChecked" using content assist, the static import is cut off, resulting in compiler errors. (I am using 2.9.2 in MarsSR2.)

Before (cursor is after TypeCh and content assist is used to complete):

import static org.mockito.Mockito.mock
import org.junit.Test
@TypeCh
final class WeakReferenceSetTests {
    @Test
    void testAddAndEmpty() {
        WeakReferenceSet set = new WeakReferenceSet()
        assert set.empty
        set << mock(ConcreteType)
        assert !set.empty
    }
}

After (notice the ".mock" has been removed from the static import):

import static org.mockito.Mockito
import groovy.transform.TypeChecked;
import org.junit.Test
@TypeChecked
final class WeakReferenceSetTests
{
    @Test
    void testAddAndEmpty() {
        WeakReferenceSet set = new WeakReferenceSet()
        assert set.empty
        set << mock(ConcreteType)
        assert !set.empty
    }
}

Also, the import keystroke (Ctrl-Shift-M) does not seem to be working for Groovy files. Is this supposed to work or is it unimplemented?

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