Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include standard jdk library in emacs semantic?

I'm using Emacs 23.2. Here's how I'm loading semantic:

(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 aware of jdk libraries. For example, if I try semantic-ia-complete-symbol on a String variable, I get Cannot find types for 'String blah'.

Does anyone know how to load the jdk libraries into semanticdb so code completion of standard object types like String are available?

like image 608
Upgradingdave Avatar asked Nov 13 '10 17:11

Upgradingdave


2 Answers

Starting with CEDET 1.1, Semantic has support for retrieving class information through javap. You need to setup cedet-java-jdk-root variable to JAVA_HOME, and populate semanticdb-javap-classpath variable with list of paths to Java's system jars, like rt.jar, etc.

There is an article (in Russian, but you can get translation) about setting Semantic up for Java completion - please look there for more details.

like image 174
Alex Ott Avatar answered Oct 27 '22 01:10

Alex Ott


If you unzip src.zip that is found in $JAVA_HOME you can add a hook for you java mode like this:

(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.

like image 29
Kjell Andreassen Avatar answered Oct 26 '22 23:10

Kjell Andreassen