How does Eclipse do code completion specific to third-party frameworks?

雨燕双飞 提交于 2019-12-06 11:26:22

问题


How does the Eclipse editor work to enable code completion? For example, within the XML editor for Hibernate property files, if I ctrl-space within a tag, a list of possible value relevant to hibernate will show up.

I understand that the XML editor is pre-configured to understand xml tag, but how about tag specific to a particular framework? How does Eclipse know about that?


回答1:


I believe that the eclipse XML editor gets the content assist information from any referenced DTDs, or XMLSchema information it associates with the XML file. Try this experiment: Remove the DOCTYPE entry at the beginning of the file and see if content assist still works.




回答2:


If you're interested in writing your own content assistants, you may want to start by reading the following:

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/editors_contentassist.htm

In a nutshell, like most things in Eclipse, this is a platform hook. When you press the button, it queries all the registered assistants (I'm simplifying here), and they provide suggestions based on the current element or even the current content.

When writing a source editor or viewer for a particular language or document type, it is common to provide at least some rudimentary content assistants.




回答3:


Removed the DOCTYPE entry at the beginning of the file and im now able to see the commands while typing ctrl+space...




回答4:


To add to Uri's answer, you can define your own editor for your own language with XText as long as you have a simple EBNF grammar language for your DSL (domain specific language).

You will have:

  • syntax coloring,
  • model navigation (F3, etc.),
  • code completion,
  • outline view, and
  • code templates.



回答5:


Here is a solution you can work. Actually I was facing a same problem with struts.xml file. I was not able to produce tags by cntrl+space

what i did was...

go to Preferences...Java...Editor...Content Assist...Advanced

check all the check-boxes ON and press OK.

sometimes the problem persists due to some false alarming in eclipse. If it happens, just delete your xml file and create a new one in same location.

I hope it will help.




回答6:


I had the same issue while using the struts.xml file. I got fix when I tried below... Go to “Preferences>Java>Editor>Content Assist>Advanced“. Make sure “Java Non Types Proposals” are ticked on both the places as shown in the image below then click Apply and OK button:-



来源:https://stackoverflow.com/questions/2308744/how-does-eclipse-do-code-completion-specific-to-third-party-frameworks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!