2014-03-03 114 views
2

我正在使用IntelliJ IDEA的Grails项目。运行Grails 2.3.5。当在一个领域类使用dirtyPropertyNames,的IntelliJ给我一个警告,“不能解析符号‘dirtyPropertyNames’”dirtyPropertyNames“无法解析符号”IntelliJ

这里是我的代码:

def getDirtyProperties(User user) { 
    def dirtyProperties = user.dirtyPropertyNames 
    return dirtyProperties 
} 

什么这里是我的问题?谢谢。

回答

3

你需要一个更智能的IDE :)方法在那里,你知道,因为代码运行。它被添加到MetaClass中,所以通过反射不可见。 IDE必须对动态方法进行特殊处理,显然这是错过了。

+0

谢谢。无论如何要让这个警告消失吗? – AnthonyM

+0

您应该将其报告为其错误跟踪器中的错误。我相信这会很容易增加人们对这是一个有效的域类方法的认识 –

1
Settings -> Inspections -> Groovy -> 
          Probable bugs -> Access to Unresolved expression 

不检查,你应该是好的。我不会为了只取消检查而这样做,因为我不确定其他检查会产生什么影响。 :)