How to include the standard jdk library in emacs semantics?

I am using Emacs 23.2. This is how I load semantics:

(setq semantic-default-submodes '(global-semantic-idle-scheduler-mode global-semanticdb-minor-mode global-semantic-idle-summary-mode global-semantic-mru-bookmark-mode)) (semantic-mode 1) 

So, if I create a simple java file and visit it, I get code completion for locally defined methods and classes. But I can't figure out how to make semantic knowledge of jdk libraries. For example, if I try semantic-ia-complete-symbol for a String variable, I get Cannot find types for 'String blah' .

Does anyone know how to load jdk libraries in semanticdb, so that it is possible to execute code on standard object types like String?

+6
java emacs emacs-semantic
source share
3 answers

Starting with CEDET 1.1, Semantic supports getting class information through javap. You need to set the variable cedet-java-jdk-root in JAVA_HOME and fill in the semanticdb-javap-classpath variable with a list of paths to the Java banks of the system, for example rt.jar , etc.

article (in Russian, but you can get a translation ) about setting up Semantic up to complete Java - please see more details there.

+3
source share

If you unzip src.zip, which is in $ JAVA_HOME, you can add a receipt for your java mode as follows:

 (add-hook 'java-mode-hook '(lambda () (semantic-add-system-include (getenv "JAVA_HOME") 'java-mode))) 

It solves the problem for me with Emacs 23.3 and CEDET 1.1.

+1
source share

I have not tried CEDET after a while, so I will blindly ask a few questions that may give an idea of ​​your problem.

  • I assume the JDK is on your way and can Emacs find it?
  • Since the JDK is basically a bunch of jar files without source code, can semantic analysis of this? Example: if you create your own Class1.java , compile it into Class1.class , and then remove Class1.java when you write Class2.java and reference some methods from Class1 , can Semantic find them?
  • Have you tried JDEE ?
0
source share

All Articles