简体   繁体   中英

Groovy Grails Tool Suite: `static mapping` code block breaks syntax highlighting and content assist

When you add a static mapping code block to a grails domain class, the content assist and syntax highlighting does not work anymore for this domain class. This does not only affect the .groovy domain class file but also the rest of the workspace.

Steps to reproduce:

  • create a new project with two domain classes Test1 and Test2 being in the same package.
  • Add the following code:

Test1.groovy

package org.test

class Test1 {
    Test2 someOtherObject
    String someProperty

    def doSomethingWithSomeProperty(){
        someOtherObject.someMethod.replaceAll(/hello/, '$1 friend') 
        someProperty 
    }
}

Test1.groovy

package org.test

class Test2 {

    String getSomeMethod(){ 
        return 'hello' 
    }
}

Everything should work fine so far. In Test1 someProperty and someMethod are highlighted in blue, as they are both either a property or an implicitly called get method.

Now, if you add a static mapping code block to Test2 , the syntax highlighting of someMethod call in Test1 will switch from blue to black-italic. Also, content assist does not work anymore; the replaceAll is underlined because someMethod is not actually recognized.

This already restricts usability, but if you add another static mapping code block to Test1 , the method of Test will not even be recognized anymore. As soon as you remove the block, everything works fine again.

I've set the priority to major because this is slowing down all working processes significantly, although it may seem trivial at the first glance. Typos happen more frequently if you do not have the content assist telling you about it. If this is not a major bug, just set it to minor.

I already filed an issue for that , but if anybody knows a workaround, please let me know.

EDIT: Sorry, I forgot to add version and operating environment information:

OS: Windows 7 x64

IDE: GGTS 3.5.1

Grails: 2.4.x

EDIT 2: Not reproducible with grails 1.3.7.

It sounds like you're having problems with the groovy eclipse plugin. You might be better off submitting a bug here instead: http://jira.codehaus.org/browse/GRECLIPSE

GGTS is just eclipse with Spring and Groovy plugins already installed.

You could try updating to the latest developer snapshot to see if that fixes the problem. Just use the update site for the version of eclipse you're using.

http://groovy.codehaus.org/Eclipse+Plugin#EclipsePlugin-DevelopmentSnapshotBuilds

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM