ctags icon indicating copy to clipboard operation
ctags copied to clipboard

Java: Local classes are ignored

Open pyropeter opened this issue 8 years ago • 5 comments

Steps to reproduce:

  • Go to https://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html
  • Copy the first code block (class HelloWorldAnonymousClasses) into a file
  • Run ctags

Expected:

I expect ctags to create four tags for greet. It only creates one, inside the interface definition.

The option --kinds-Java=l, which is described with local variables, surprisingly influences this: An additional tag is emitted for the greet implementation inside EnglishGreeting. Still no tags are created for the implementations inside the anonymous classes.

pyropeter avatar Apr 16 '18 18:04 pyropeter

Thank you for reporting. Reproduced. Could you give me shorter input?

masatake avatar Apr 17 '18 04:04 masatake

It seems that fixing this is not so easy.

masatake avatar Apr 17 '18 23:04 masatake

The input is recorded as a test case triggering the bug. See #1756.

masatake avatar May 23 '18 16:05 masatake

I'm working on reimplenting the java parser with using a parser generator. What I got today is what you wanted:)

I have to work on this item more.

[yamato@master]~/var/ctags-peg/Units/parser-java.r/anonymous-class.b% cat input.java 
cat input.java 
// See #1739
public class input {
    interface greeting {
	public void greet(String word);
    }

    public void hello () {
	greeting g = new greeting() {
		public void greet (String word) {
		}
	};
	g.greet("hello");
    }
    public void bye () {
	greeting h = new greeting() {
		public void greet (String word) {
		}
	};
	h.greet("bye");
    }

}
[yamato@master]~/var/ctags-peg/Units/parser-java.r/anonymous-class.b% ../../../ctags --kinds-Java=+l --sort=no --fields=+liK -o - input.java
../../../ctags --kinds-Java=+l --sort=no --fields=+liK -o - input.java
input	input.java	/^public class input {$/;"	class	language:Java
greeting	input.java	/^    interface greeting {$/;"	interface	language:Java	class:input
greet	input.java	/^	public void greet(String word);$/;"	method	language:Java	interface:input.greeting
hello	input.java	/^    public void hello () {$/;"	method	language:Java	class:input
g	input.java	/^	greeting g = new greeting() {$/;"	local	language:Java	method:input.hello
AnonymousClass88b977650101	input.java	/^	greeting g = new greeting() {$/;"	class	language:Java	method:input.hello	inherits:greeting
greet	input.java	/^		public void greet (String word) {$/;"	method	language:Java	class:input.hello.AnonymousClass88b977650101
bye	input.java	/^    public void bye () {$/;"	method	language:Java	class:input
h	input.java	/^	greeting h = new greeting() {$/;"	local	language:Java	method:input.bye
AnonymousClass88b977650201	input.java	/^	greeting h = new greeting() {$/;"	class	language:Java	method:input.bye	inherits:greeting
greet	input.java	/^		public void greet (String word) {$/;"	method	language:Java	class:input.bye.AnonymousClass88b977650201

masatake avatar Aug 20 '18 09:08 masatake

I have measured the performance of the new Java parser. Too slow. 30 ~ 50 times slower than the current implementation.

I have to rewrite a new one without the parser generator.

masatake avatar Feb 07 '19 11:02 masatake