简体   繁体   English

GSP页面中针对模型对象的Groovy / Grails工具套件(GGTS)代码辅助

[英]Groovy/Grails Tools Suite (GGTS) code-assist in GSP pages for model objects

I am a newbie in Grails, and still learning. 我是Grails的新手,现在还在学习。

I have the following code for the model: 我对模型有以下代码:

class Book {

    static constraints = {

    }

    String title
    String author
}

and controller: 和控制器:

class KillController {

    def index() { render "kill world"  }

    def view() {
        def book = new Book( author: "Mike", title: "nuff sed")
        [ model: book ]
    }
}

And for view.gsp , I have the following: 对于view.gsp ,我有以下内容:

<html>
    <body>
        Author: ${ model.author }<br />
        Title : ${ model.title }
    </body>
</html>

Everything is working, and the correct output is produced. 一切正常,并产生正确的输出。 However, in the GSP editor, when I type ${ model. } 但是,在GSP编辑器中,当我键入${ model. } ${ model. } , I don't get any proposals from code-assist. ${ model. } ,我没有得到从代码协助任何建议。 Pressing ctrl+space after typing the dot does not help. 键入点后按Ctrl +空格键无济于事。

Pressing Ctrl+space inside ${ } works though, and it correctly recognizes model as a Book object. 但是,在${ }按Ctrl + space可以起作用,并且可以正确地将model识别为Book对象。

Is code assist for models not yet supported in the GSP editor? GSP编辑器尚不支持针对模型的代码辅助吗? Thanks! 谢谢! :D :D

This is a bug. 这是一个错误。 It should be working and it does in many other situations. 它应该可以工作,并且在许多其他情况下也可以。 When I try it, I do see that an exception is being thrown: 尝试时,我确实看到正在引发异常:

org.eclipse.core.runtime.OperationCanceledException
at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.checkCancel(GroovyProposalTypeSearchRequestor.java:356)
at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.processAcceptedPackages(GroovyProposalTypeSearchRequestor.java:618)
at org.codehaus.groovy.eclipse.codeassist.processors.PackageCompletionProcessor.generateProposals(PackageCompletionProcessor.java:56)
at org.codehaus.groovy.eclipse.codeassist.requestor.GroovyCompletionProposalComputer.computeCompletionProposals(GroovyCompletionProposalComputer.java:162)
at org.grails.ide.eclipse.editor.gsp.adapter.CodeCompletionDelegate.codeComplete(CodeCompletionDelegate.java:71)
at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.codeComplete(GroovyCompilationUnit.java:598)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:359)
at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeJavaCompletionProposals(JSPJavaCompletionProposalComputer.java:237)
at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeCompletionProposals(JSPJavaCompletionProposalComputer.java:114)
at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:284)
at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:290)
at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.collectProposals(StructuredContentAssistProcessor.java:475)
at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.computeCompletionProposals(StructuredContentAssistProcessor.java:254)
at org.eclipse.wst.sse.ui.internal.contentassist.CompoundContentAssistProcessor.computeCompletionProposals(CompoundContentAssistProcessor.java:127)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498)
...

I'll have to see what is going on here. 我必须看看这里发生了什么。


UPDATE: 更新:

Raised this issue: https://issuetracker.springsource.com/browse/STS-3337 提出了这个问题: https : //issuetracker.springsource.com/browse/STS-3337

Found the problem and pushed a fix. 找到了问题并提出了解决方案。 Will be available in next snapshot build. 在下一个快照版本中将可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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