romainl / ctags-patterns-for-javascript Goto Github PK
View Code? Open in Web Editor NEWExuberant Ctags Patterns for JavaScript
License: MIT License
Exuberant Ctags Patterns for JavaScript
License: MIT License
Hi,
How to use your script with mjs files?
Working well with js files but not mjs files.
I'm not sure exactly when, but somewhere in the last several months the following regex pattern disappeared from the file that is now 'ctagsrc':
--regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)(.*)[ \t]*[{]/\1/M,Method,Methods/b
It is still listed in the readme though.
Without it, support for the following patterns is lost:
method_name() {
method_name(params) {
I've noticed that implicit return functions are not being folded. For example:
someFunc = () =>
foo !== 'bar' ||
baz < 42;
I got the following error when I use it with universal ctags:
ctags: Kind letter 'F' used in regex definition "^[ ]*function[ ]*\([A-Za-z0-9_$]\{1,\}\)[ (]" of JavaScript language is reserved in ctags main
Doesn't look like there's support for async/await style functions. For instance, This isn't getting picked up:
const myFn = async function({
val1: mappingVal,
val2,
val3
}) {
// ...
})
Hi, first of all, thanks for making such a comprehensive set of ctags rules. Much appreciated.
I have some components in my library defined like so:
import { Box, styled } from '@smooth-ui/core-sc'
import Theme from 'theme'
const FramedBox = styled(Box)`
border: 1px solid ${Theme.black800};
border-radius: 0px 5pt 5pt 5pt;
padding: 0px 5% 0px 5%;
display: grid;
grid-template-columns: 45% 45%;
grid-gap: 5%;
overflow-y: auto;
@media(min-width: 769px){
height: 50vh;
}
@media (max-width: 992px){
grid-template-columns: 100%;
}
`
export default FramedBox
But when I try and Ctrl + ]
on a consuming file, it says that E426: tag not found: FramedBox
Is there some additional customization I need to make this work?
For example:
export const AppRoot = () => <div>AppRoot</div>
const FooBar = "FooBar"
will only index the variables as App
and Foo
.
In the regex for function definitions (specifically looked at arrow functions but could also apply to others, didn't look):
--regex-javascript=/^[ \t]*var[ \t]\{1,\}\([a-z_$][A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b
--regex-javascript=/^[ \t]*let[ \t]\{1,\}\([a-z_$][A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b
--regex-javascript=/^[ \t]*const[ \t]\{1,\}\([a-z_$][A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b
Why does the first character of the function need to be lower cased? I specifically have a React component definition:
const MyModal = ({ prop1, prop2 }) => {
}
export default MyModal
This definition is skipped because of the capital case component function name.
Hi, I followed the instructions under the "Try" section of the readme.
After running make tags
, the generated tags file only had this
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /[email protected]/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
Comp01 index.js /^var Comp01 = styled(Box)`$/;" v
Constr_var index.js /^var Constr_var = function() {$/;" c
Constr_var.constr_var_meth index.js /^ this.constr_var_meth = function() {$/;" m
OUT Makefile /^OUT = @echo `date +[\\ %F\\ -\\ %T\\ ]`$/;" m
SHELL Makefile /^SHELL := \/bin\/bash$/;" m
class_constr_meth index.js /^ this.class_constr_meth = function(){$/;" f
class_meth_equal index.js /^ class_meth_equal = function($/;" f
const index.js /^const Constr_const = function() {$/;" c
const index.js /^const function_const = function() {$/;" f
const.body test.js /^ const config = { method, body: JSON.stringify(body) }$/;" p
const.constr_const_meth index.js /^ this.constr_const_meth = function() {$/;" m
function_basic index.js /^function function_basic() {$/;" f
let index.js /^let Constr_let = function() {$/;" c
let.constr_let_meth index.js /^ this.constr_let_meth = function() {$/;" m
obj_lit.obj_lit_prop_array index.js /^ obj_lit_prop_array: [$/;" p
obj_lit.obj_lit_prop_number index.js /^ obj_lit_prop_number: 123,$/;" p
obj_lit.obj_lit_prop_string index.js /^ obj_lit_prop_string : "eee",$/;" p
obj_lit_inline.obj_lit_inline_prop index.js /^var obj_lit_inline = { obj_lit_inline_prop: 1 };$/;" p
this_prop.this_inner_prop index.js /^ this_inner_prop: "bar"$/;" p
this_prop_method index.js /^this.this_prop_method = function($/;" f
var_declaration index.js /^var var_declaration;$/;" v
var_declaration_inlined_1_of_2 index.js /^var var_declaration_inlined_1_of_2, var_declaration_inlined_2_of_2;$/;" v
var_declaration_inlined_1_of_2_trailing_space index.js /^var var_declaration_inlined_1_of_2_trailing_space , var_declaration_inlined_2_of_2_trailing_space ;$/;" v
var_declaration_inlined_1_of_3 index.js /^var var_declaration_inlined_1_of_3, var_declaration_inlined_2_of_3, var_declaration_inlined_3_of_3;$/;" v
var_declaration_inlined_1_of_3_trailing_space index.js /^var var_declaration_inlined_1_of_3_trailing_space , var_declaration_inlined_2_of_3_trailing_space , var_declaratio
n_inlined_3_of_3_trailing_space ;$/;" v
var_declaration_trailing_space index.js /^var var_declaration_trailing_space ;$/;" v
var_var_regexp index.js /^var var_var_regexp = \/regexp\/;$/;" v
Here is my ctags --version
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Sep 17 2017, 20:48:43
Addresses: <[email protected]>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
How do I go about debugging why it isn't recognizing all the patterns?
This works:
extractEmailsFromString(text, options = { isWrappedLessThanGreaterThan: false, }) {
if (options.isWrappedLessThanGreaterThan) {
return text.match(/(<[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+>)/gi);
}
return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
}
But this doesn't work:
extractEmailsFromString(text, options = {
isWrappedLessThanGreaterThan: false,
}) {
if (options.isWrappedLessThanGreaterThan) {
return text.match(/(<[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+>)/gi);
}
return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
}
I know ctags works on a line by line basis, so is this just not possible to implement? Thanks for making this project!
Method properties http://es6-features.org/#MethodProperties does not seem to be picked up by the available rules. In something like this:
const obj = {
foo () {
console.log('bar')
}
}
Only "obj" will be picked up, not "foo".
I found this issue on the Flow repo and I was wondering if the ctags-patterns-for-javascript project might be a good way to solve the problem?
See http://www.gnu.org/software/grep/manual/html_node/Basic-vs-Extended.html for a couple of advices.
Is there a reason that default exports aren't supported by this?
async function foo() {
}
let bar;
I couldn't generate tags. Here's the error:
ctags: Warning: Don't reuse the kind letter `C' in a language JavaScript (old: "constant", new: "Class")
ctags: Warning: Don't reuse the kind letter `C' in a language JavaScript (old: "constant", new: "Class")
ctags: Warning: Don't reuse the kind letter `E' in a language JavaScript (old: "Export", new: "export")
ctags: Kind letter 'F' used in regex definition "^[ ]*function[ ]*([A-Za-z0-9_$]+)[ \(]" of JavaScript language is reserved in ctags main
make: *** [tags] Error 1
My ctags version
Universal Ctags 0.0.0(f480eed), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Jun 9 2017, 10:46:28
URL: https://ctags.io/
Optional compiled features: +wildcards, +regex, +multibyte, +option-directory, +coproc, +xpath, +case-insensitive-filenames
The following code on a class is being recongised as a property, not a function/method
// in some class
someMethod = (
one,
two,
three
) => {
// body
};
I'm pretty unfamiliar with the syntax for ctags regex and was wondering if there's a reason that the following wouldn't work?
export class Foo {
// ...
}
I'd expect to be able to reach Foo
as a class if that makes sense.
The following function is not matched:
module.exports = function sum (a, b) {
return a + b
}
I've done a rule to match that case as a function, but don't know if you didn't want to support on purpose since this is also the case for export default function name1(…) { … }
as you pointed out on issue #7.
Wouldn't make sense to create an default export
tag type and put them together on that new tag type? What do you think?
(We could try to create a rule only for default named exports with body definition once the ones that doesn't have definition would be already taken by another rules)
The following code using flow doesn't match.
function test(): Boolean {
...
}
Example:
testobj = {
func1: () => {
console.log('test1');
},
func2: () => {
console.log('test2');
}
};
In this case func1 is recognized but func2 is not.
Interesting that if the call inside func1 is removed then both func1 and func2 are recognized:
testobj = {
func1: () => {
},
func2: () => {
console.log('test2');
}
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.