Open wmm125 opened 6 years ago
Reproduced with the following shorten input:
public class AccountSetupNoteDialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(context)
.setPositiveButton(
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final Callback a = (Callback) getActivity();
}
})
}
}
The output:
[jet@localhost]~/var/ctags% u-ctags --options=NONE --java-kinds=+l --file-scope=yes -u --fields=-anfs+n -o - /tmp/foo.java
u-ctags --options=NONE --java-kinds=+l --file-scope=yes -u --fields=-anfs+n -o - /tmp/foo.java
u-ctags: Notice: No options will be read from files or environment
AccountSetupNoteDialogFragment /tmp/foo.java /^public class AccountSetupNoteDialogFragment {$/;" c line:1
onCreateDialog /tmp/foo.java /^ public Dialog onCreateDialog(Bundle savedInstanceState) {$/;" m line:2
AccountSetupNoteDialogFragment /tmp/foo.java /^public class AccountSetupNoteDialogFragment {$/;" c line:1
onCreateDialog /tmp/foo.java /^ public Dialog onCreateDialog(Bundle savedInstanceState) {$/;" m line:2
If the lines inside onCall
method empty, it is not reproduced:
[jet@localhost]~/var/ctags% cat /tmp/foo.java
cat /tmp/foo.java
public class AccountSetupNoteDialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(context)
.setPositiveButton(
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
}
}
[jet@localhost]~/var/ctags% u-ctags --options=NONE --java-kinds=+l --file-scope=yes -u --fields=-anfs+n -o - /tmp/foo.java
u-ctags --options=NONE --java-kinds=+l --file-scope=yes -u --fields=-anfs+n -o - /tmp/foo.java
u-ctags: Notice: No options will be read from files or environment
AccountSetupNoteDialogFragment /tmp/foo.java /^public class AccountSetupNoteDialogFragment {$/;" c line:1
onCreateDialog /tmp/foo.java /^ public Dialog onCreateDialog(Bundle savedInstanceState) {$/;" m line:2
So I guess this is a bug of Java parser.
This is not reproduced in Exuberant-ctags.
The shorten input I made misses a semicolon. It should be:
public class AccountSetupNoteDialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(context)
.setPositiveButton(
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final Callback a = (Callback) getActivity();
}
});
}
}
For the above code, new Java parser I tested in #1847 emits following tags:
AccountSetupNoteDialogFragment baz.java /^public class AccountSetupNoteDialogFragment {$/;" c line:1
onCreateDialog baz.java /^ public Dialog onCreateDialog(Bundle savedInstanceState) {$/;" m line:2
__anon37c95d920201 baz.java /^ new DialogInterface.OnClickListener() {$/;" c line:5
onClick baz.java /^ public void onClick(DialogInterface dialog, int which) {$/;" m line:6
a baz.java /^ final Callback a = (Callback) getActivity();$/;" l line:7
The new parser doesn't emit the duplicated tags. It takes more time to merge the experimental code. But it solves the issue you reported. If you are interested in trying the code, let me know.
I'm running universal ctags in interactive on a java code (also available at: https://raw.githubusercontent.com/ShadeWalker/Tango_AL813/master/packages/apps/Email/src/com/android/email/activity/setup/AccountSetupNoteDialogFragment.java) and I got 36 json output tags when expected result is only 16. This behavior can not be reproduced in non interactive mode.
The name of the parser:
The command line you used to run ctags:
The content of input file:
Interactive mode header:
The tags output you are not satisfied with:
The tags output you expect:
The version of ctags:
How do you get ctags binary:
Building it locally with no code change, only enabling json output