如何在Atom编辑器中查找引用(或用法)? [英] How to find references (or usages) in Atom editor?
问题描述
IDE最着名的功能之一就是您知道在项目中查找变量,函数或类的引用(或用法)。我一直在尝试Atom Atom)。我喜欢它,到目前为止。但是,我找不到一种方法来访问var / function的引用(或用法)或JavaScript代码中的类。 Atom编辑器中没有此功能吗?我在下面给出两个例子。
One of the most famous features of IDEs is as you know finding references (or usages) of variables, functions or classes in a project. I have been trying Atom Atom) for a while. I like it so far. But, I could not find a way to access to references (or usages) of var/function or a class in JavaScript code. Isn't this feature available in Atom editor? I give two examples below.
a)在下面的简单代码中,Atom没有带我title的声明。我通过右键单击标题来制作转到声明
a) In the following simple code, Atom does not take me the declaration of "title". I am making "Go to Declaration" by right clicking on the word "title"
Template.docAddForm.events({
'submit .js-add-doc':function(event){
const title = event.target.doctitle.value; // The declaration of "title"
Session.set('docTitle', title); // Cannot access the declaration of "title" in Atom
}
});
另一个例子。我无法访问以下代码中导入的commons.js中声明的用户对象的声明。
Another example. I cannot access to declaration of Users object which is a Collection declared in imported "commons.js" in the following code.
import { Meteor } from 'meteor/meteor';
import {Users} from '../lib/commons.js';
/** PUBLICATIONS **/
Meteor.publish('users', function () {
return Users.find({}, {fields: {_id: 0}});
});
推荐答案
编辑:对于要使用goto包,你必须在项目的根目录中生成一个 .tags
文件。启用 symbol-gen
包在Atom中执行此操作,然后使用 cmd-alt-g
生成符号。然后 goto
快捷方式(并右键单击>转到声明)将起作用。
EDIT: For the goto package to work, you have to generate a .tags
file in the root of your project. Enable the symbol-gen
package to do so within Atom, and then use cmd-alt-g
to generate the symbols. Then the goto
shortcuts (and right click > "Go to Declaration") will work.
默认情况下,应启用 goto 软件包以跳转到变量实例化。
The goto package should be enabled by default to jump to variable instantiation.
cmd-r
- 转到文件符号
cmd-r
- Goto File Symbol
cmd-shift-r
- 转到项目符号
cmd-shift-r
- Goto Project Symbol
cmd -alt-down
- 转到声明
至于查找变量用法,我认为这取决于你正在使用的语言。例如, atom-ternjs
将向您展示JavaScript的变量用法(以及更多)。
As for finding variable usage, I believe that would depend on the language you're using. For example, atom-ternjs
would show you variable usage (and a lot more) for JavaScript.
这篇关于如何在Atom编辑器中查找引用(或用法)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!