Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to parse groovy file with multiline docstrings? #2908

Closed
xhujerr opened this issue Mar 10, 2021 · 4 comments
Closed

How to parse groovy file with multiline docstrings? #2908

xhujerr opened this issue Mar 10, 2021 · 4 comments

Comments

@xhujerr
Copy link

xhujerr commented Mar 10, 2021

I'm trying create tags for a groovy file(s).

I followed SO question How can I get groovy methods with generics to work with ctags (universal ctags)?

and created options file:

-RV

--languages=+Java

--language-force=Java
--langmap=java:.groovy
--excmd=pattern

--exclude=.git
--exclude=*.js
--exclude=*.bak
--exclude=*.orig

When I try to run it I unfortunately get an error:

OPENING aws/cfn_custom.groovy as Java language file [new]
aws/cfn_custom.groovy: failed to find match for '(' at line 60

The failure is within a multiline docstring:

Doc = '''
...
some text [link](https://example.com) some text
...
'''

I'm a very beginner with ctags, so I'm probably doing it all wrong.
But is there a way to instruct ctags to ignore multiline docstrings?

The command line you used to run ctags:

ctags --options=NONE -RV --languages=+Java --language-force=Java --langmap=java:.groovy --excmd=pattern --exclude=Makefile --exclude=*.js --exclude=*.bak --exclude=*.orig --exclude=. -f ./groovy.ctags.test work.groovy 

The content of input file:

Doc = '''
...
some text [link](https://example.com) some text
...
'''

The tags output you are not satisfied with:

ctags: Notice: No options will be read from files or environment
  Option: --languages=+Java
    Enabled languages: + Java
  Option: --language-force=Java
  Option: --langmap=java:.groovy
    Setting Java language map:
  Option: --excmd=pattern
  Option: --exclude=Makefile
    adding exclude pattern: Makefile
  Option: --exclude=*.js
    adding exclude pattern: *.js
  Option: --exclude=*.bak
    adding exclude pattern: *.bak
  Option: --exclude=*.orig
    adding exclude pattern: *.orig
  Option: --exclude=.
    adding exclude pattern: .
  Option: -f ./groovy.ctags.test
Reading command line arguments
OPENING work.groovy as Java language file [new]
Initialize parser: Java
Initialize parser: CPreProcessor
work.groovy: failed to find match for '(' at line 3
sorting tag file
system ("sort -u -o './groovy.ctags.test' './groovy.ctags.test'")

The tags output you expect:

the ctags won't fail on the input file, but gracefully ignore the text in between ''' and ''' (including new lines).

The version of ctags:

$ ctags --version
Universal Ctags 5.9.0(p5.9.20210307.0), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Mar 10 2021, 13:59:47
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc

How do you get ctags binary:

Building it locally, via GNU/Linux Ubuntu distribution

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"

following SO question https://stackoverflow.com/a/34401367/775066

also tried binary from ubuntu package:
universal-ctags | 0+git20181215-2 | http://de.archive.ubuntu.com/ubuntu focal/universe amd64 Packages

@masatake
Copy link
Member

But is there a way to instruct ctags to ignore multiline docstrings?

No, as far as using the Java parser for parsing Groovy input files.

aws/cfn_custom.groovy: failed to find match for '(' at line 60

Java parser just reports the input is broken as Java source code.

@xhujerr
Copy link
Author

xhujerr commented Mar 10, 2021

AFAIK there's no parser for groovy files, correct?

So how do I parse a groovy file?

@masatake
Copy link
Member

AFAIK there's no parser for groovy files, correct?

Yes.

So how do I parse a groovy file?

A. write a parser for Groovy and link it to ctags, or
B. wait for someone writing Groovy parser.

These choices are applicable to any languages which ctags doesn't support.

See also #1566 .

@xhujerr
Copy link
Author

xhujerr commented Mar 10, 2021

See also #1566 .

Yeah, I saw that Groovy isn't the most wanted :-)

In the end I found my .ctags syntax file for Groovy language (exuberant-ctags) and that is working for me.

Btw. I use ctags in Kate CTags Plugin
How to configure ctags in Kate?
I think I didn't see Kate in Software using ctags

Thanks for you help and a patience with a newbie
And thanks for developing ctags

@xhujerr xhujerr closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants