Re: completion in java for classes in the same package

ian martins <[email protected]> Fri, 18 Oct 2019 06:25:56 -0400
Newsgroups gmane.emacs.semantic
Message-ID <CAC=rjb6vEbLQigE0EU=w_y33CKAVhBP26i8J8LmzTC00Oi6=cA@mail.gmail.com>
--===============6594124744125150928==
Content-Type: multipart/alternative; boundary="0000000000001fde1f05952cc322"

--0000000000001fde1f05952cc322
Content-Type: text/plain; charset="UTF-8"

Eric, thanks for the quick response and thanks for the pointers. I'll see
what I can do.

On Mon, Oct 14, 2019 at 8:18 PM Eric Ludlam <[email protected]> wrote:

> On 10/14/19 3:12 PM, ian martins wrote:
> > Hello,
> >
> > I want to use semantic for completion in java, but it doesn't seem to
> > find classes in the same package as the class being visited in the
> > current buffer.
> >
> > For example, if I have the following package structure:
> >
> >      mypackage/MyClassA
> >               /MyClassB
> >
> > and I open MyClassA in a buffer and try to auto complete the methods of
> > an object of type MyClassB, semantic says
> > "semantic-analyze-possible-completions-default: Cannot find types for
> > `MyClassB classB'"
> >
> > I found that if I add an "import mypackage.MyClassB;" at the top of
> > MyClassA, it'll work. But this shouldn't be necessary. Is this
> intentional?
> >
> > I'm tested on
> > emacs 24.5, semantic 2.2 and
> > emacs 26.3, semantic 2.2.
>
> Hi Ian,
>
> I haven't been working on semantic in a few years, and I never did
> serious java development myself, but maybe I can provide a couple pointers.
>
> The base 'java' support with semantic is pretty simple, as per you
> discovering you need to be specific about what to import.  Think of it
> as assuming java acts like C.
>
> The semantic/db-javap.el support file had a range of semanticdb database
> tables designed to wrap directories and jar files so you can look up
> symbols. These were the wrappers that made semantic aware of some of the
> java library structure.  I don't recall the specifics, but reading
> through it, it looks like it has the feature you want via
> `semanticdb-table-java-directory' and some overrides for the symbol
> analyzer.
>
> This can be found in cedet from sourceforge.  I can't find the file in
> the version of cedet included with Emacs.
>
> I'm going to assume you are using semantic that is built into emacs
> since cedet from SF doesn't work well with newer versions of emacs due
> to the conversion of eieio.
>
> It might be possible to pull that one file over along with a copy of
> cedet-java.el and enable it.  It might need changes based on the changes
> to eieio.  I don't really know why it was left out of emacs.
>
> If you get it working, I'd recommend sending it along to emacs
> maintainers so it can be included.
>
> Eric
>

--0000000000001fde1f05952cc322
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Eric, thanks for the quick response and thanks for the poi=
nters. I&#39;ll see what I can do.<br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Mon, Oct 14, 2019 at 8:18 PM Eric =
Ludlam &lt;<a href=3D"mailto:[email protected]">[email protected]</=
a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On=
 10/14/19 3:12 PM, ian martins wrote:<br>
&gt; Hello,<br>
&gt; <br>
&gt; I want to use semantic for completion in java, but it doesn&#39;t seem=
 to <br>
&gt; find classes in the same package as the class being visited in the <br=
>
&gt; current buffer.<br>
&gt; <br>
&gt; For example, if I have the following package structure:<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0 mypackage/MyClassA<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/MyClassB<br>
&gt; <br>
&gt; and I open MyClassA in a buffer and try to auto complete the methods o=
f <br>
&gt; an object of type MyClassB, semantic says <br>
&gt; &quot;semantic-analyze-possible-completions-default: Cannot find types=
 for <br>
&gt; `MyClassB classB&#39;&quot;<br>
&gt; <br>
&gt; I found that if I add an &quot;import mypackage.MyClassB;&quot; at the=
 top of <br>
&gt; MyClassA, it&#39;ll work. But this shouldn&#39;t be necessary. Is this=
 intentional?<br>
&gt; <br>
&gt; I&#39;m tested on<br>
&gt; emacs 24.5, semantic 2.2 and<br>
&gt; emacs 26.3, semantic 2.2.<br>
<br>
Hi Ian,<br>
<br>
I haven&#39;t been working on semantic in a few years, and I never did <br>
serious java development myself, but maybe I can provide a couple pointers.=
<br>
<br>
The base &#39;java&#39; support with semantic is pretty simple, as per you =
<br>
discovering you need to be specific about what to import.=C2=A0 Think of it=
 <br>
as assuming java acts like C.<br>
<br>
The semantic/db-javap.el support file had a range of semanticdb database <b=
r>
tables designed to wrap directories and jar files so you can look up <br>
symbols. These were the wrappers that made semantic aware of some of the <b=
r>
java library structure.=C2=A0 I don&#39;t recall the specifics, but reading=
 <br>
through it, it looks like it has the feature you want via <br>
`semanticdb-table-java-directory&#39; and some overrides for the symbol <br=
>
analyzer.<br>
<br>
This can be found in cedet from sourceforge.=C2=A0 I can&#39;t find the fil=
e in <br>
the version of cedet included with Emacs.<br>
<br>
I&#39;m going to assume you are using semantic that is built into emacs <br=
>
since cedet from SF doesn&#39;t work well with newer versions of emacs due =
<br>
to the conversion of eieio.<br>
<br>
It might be possible to pull that one file over along with a copy of <br>
cedet-java.el and enable it.=C2=A0 It might need changes based on the chang=
es <br>
to eieio.=C2=A0 I don&#39;t really know why it was left out of emacs.<br>
<br>
If you get it working, I&#39;d recommend sending it along to emacs <br>
maintainers so it can be included.<br>
<br>
Eric<br>
</blockquote></div>

--0000000000001fde1f05952cc322--


--===============6594124744125150928==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============6594124744125150928==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic

--===============6594124744125150928==--