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

kotlin: add basic regex parser #2769

Merged
merged 5 commits into from
Dec 26, 2020

Conversation

dolik-rce
Copy link
Contributor

Hello,

I'm a Kotlin programmer using Geany as my IDE and for a long time I've been missing support this wonderful language. I've got some spare free time around Christmas, so I've decided to try and add a simple regex parser for Kotlin. Also, others have requested support for Kotlin in #1566.

I have tried to read all the docs related to contributions, but it is quite extensive and I'm pretty sure that I must have missed some parts 🙂 Please let me know if there is something missing from the code, before it could be merged. I'll try to fix any imperfections ASAP.

@masatake masatake self-requested a review December 22, 2020 14:25
@masatake masatake self-assigned this Dec 22, 2020
@coveralls
Copy link

coveralls commented Dec 22, 2020

Coverage Status

Coverage increased (+0.01%) to 87.212% when pulling aa1f1cd on dolik-rce:kotlin-parser into 165f7e3 on universal-ctags:master.

# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a URL for the language reference page of Kotlin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

optlib/kotlin.ctags Outdated Show resolved Hide resolved
optlib/kotlin.ctags Outdated Show resolved Hide resolved
@masatake
Copy link
Member

Thank you for your contribution. Knowing some writing a parser with mtable-regex that I designed is my greatest pleasure.

Though I don't know Kotlin, the parser looks good. I'm always surprised that people write a parser by reading the documents written in my bad English:-) I will take more time to verify the consistency of the transition between tables.

Have you tried to fill scope fields?
If you have not done yet I would like you to read scope= related description in https://docs.ctags.io/en/latest/man/ctags-optlib.7.html#flags-for-regex-lang-option . If you fill the scope fields, Geany may be able to build a "tree" from the information.

Here is an example illustrating the concept of scope.
input.c:

struct point {
   int x;
   int y;
};

tags output:

$ u-ctags --fields=+Z -o - input.c
point	input.c	/^struct point {$/;"	s	file:
x	input.c	/^	int x;$/;"	m	scope:struct:point	typeref:typename:int	file:
y	input.c	/^	int y;$/;"	m	scope:struct:point	typeref:typename:int	file:

Could you recommend to me a larger open-source software project using Kotlin?
I would like to register it to our codebase (https://github.com/universal-ctags/codebase).

@dolik-rce
Copy link
Contributor Author

Thank you for your quick replies @masatake.

English is not my first language either, but your documentation is great. It was quite easy to follow, considering how extensive the ctags options are.

I think, without the mtable-regex it would be almost impossible to write the parser for Kotlin. Switching contexts makes it much easier.

Regarding the scopes: I've been looking into it, but it's not going to be easy. Kotlin allows nested definitions (for both classes and functions) and often uses anonymous constructs (lot of lambdas, but also anonymous classes) so tracking the scope will be tricky. Therefore I chose to submit this simpler version first and maybe try to add scope later.

For the codebase, I can recommend you for eaxmple dokka, which is a documentation engine for Kotlin. It's not really large, but I can't think of any better example right now... Most of the Kotlin usage is still for Android apps, which I don't know much. I'm a back-end developer, using Kotlin for proprietary servers.

@dolik-rce
Copy link
Contributor Author

I see the code is failing on OS X and cygwin. Is there something that needs to be done differently for those platforms?

dolik-rce added a commit to dolik-rce/codebase that referenced this pull request Dec 22, 2020
Follow up from universal-ctags/ctags#2769. After some research it seems that Kotlin itself is still the biggest opensource project written in Kotlin.
@masatake
Copy link
Member

I'll inspect the reason of the failure.

@masatake
Copy link
Member

See 8992b8c (#2770).
It seems that you cannot use \s. Please replace it with [[:space:]] or [ \t].

@masatake
Copy link
Member

@codecov
Copy link

codecov bot commented Dec 23, 2020

Codecov Report

Merging #2769 (aa1f1cd) into master (165f7e3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2769      +/-   ##
==========================================
+ Coverage   87.11%   87.13%   +0.01%     
==========================================
  Files         192      193       +1     
  Lines       40892    40941      +49     
==========================================
+ Hits        35625    35674      +49     
  Misses       5267     5267              
Impacted Files Coverage Δ
optlib/kotlin.c 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 165f7e3...aa1f1cd. Read the comment docs.

@masatake masatake merged commit 13d5446 into universal-ctags:master Dec 26, 2020
@masatake
Copy link
Member

Thank you.

raven42 added a commit to raven42/tagbar that referenced this pull request Jan 5, 2021
Closes preservim#632

Support for kotlin type was recently added into universal ctags
(universal-ctags/ctags#2769)

Currently there is no scope information in the ctags definition. So the
`scope2kind` and `kind2scope` settings are not functional. If support is
added, then these definitions can be updated to include that info.

Note: these kind definitions are based on the output from `ctags
--list-kinds=kotlin` which is slightly different than the definitions
provided in preservim#632. So this may not be fully compatible with the custom
ctags configuration from that issue. The default definition for
univercal ctags should be used instead.
alerque pushed a commit to preservim/tagbar that referenced this pull request Jan 6, 2021
Closes #632

Support for kotlin type was recently added into universal ctags
(universal-ctags/ctags#2769)

Currently there is no scope information in the ctags definition. So the
`scope2kind` and `kind2scope` settings are not functional. If support is
added, then these definitions can be updated to include that info.

Note: these kind definitions are based on the output from `ctags
--list-kinds=kotlin` which is slightly different than the definitions
provided in #632. So this may not be fully compatible with the custom
ctags configuration from that issue. The default definition for
univercal ctags should be used instead.
dev-hann added a commit to dev-hann/tagbar that referenced this pull request Sep 18, 2023
Closes preservim#632

Support for kotlin type was recently added into universal ctags
(universal-ctags/ctags#2769)

Currently there is no scope information in the ctags definition. So the
`scope2kind` and `kind2scope` settings are not functional. If support is
added, then these definitions can be updated to include that info.

Note: these kind definitions are based on the output from `ctags
--list-kinds=kotlin` which is slightly different than the definitions
provided in preservim#632. So this may not be fully compatible with the custom
ctags configuration from that issue. The default definition for
univercal ctags should be used instead.
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

Successfully merging this pull request may close these issues.

None yet

3 participants