使用显示模块模式时,如何查看eclipse中的轮廓? [英] How can I view the outline in eclipse when using the revealing module pattern?

查看:142
本文介绍了使用显示模块模式时,如何查看eclipse中的轮廓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重构一些我们拥有的Javascript代码,其中包括改变它以利用显示的模块模式。代码看起来很整洁,它的工作正常,但在大纲视图中我看不到功能。我看到顶级命名空间var为var,但是您无法扩展它以查看其中的函数。



让我们说代码看起来像这样: p>

  function myFunc1(){} 
function myFunc2(){}
/ pre>

在这种情况下,您将在大纲视图中看到这两个功能。但是如果你把它改成这样的话:

  var myNamespace = function()
{
function myFunc1 ){}
函数myFunc2(){}

返回{
名称:myNamespace,
myFunc1:myFunc1,
myFunc2:myFunc2
}
}();

然后,大纲视图只显示了myNamespace var。我已经尝试寻找,但找不到一个实际上会显示我层次结构的视图。有没有人知道要查看这种情况的方法,还是eclipse无法做到这一点?

解决方案

添加:

  / ** 
* @memberOf myNamespace
* /

在每个功能定义之前恢复层次结构。



您将在这里找到更有趣的标签来记录您的代码:

我如何将JsDoc引入JavaScript项目 - 并找到我的Eclipse Outline


I'm currently refactoring some Javascript code we have and amongst other things I've changed it to make use of the revealing module pattern. The code is looking much tidier and it works fine but I can't see the functions anymore in the outline view. I see the top level namespace var as a var but you can't expand it to see the functions within.

Lets say the code used to look like this:

function myFunc1() {}
function myFunc2() {}

In this case you see both functions in the outline view. But if you change it to this:

var myNamespace = function()
{
  function myFunc1() {}
  function myFunc2() {}

  return {
    name: "myNamespace",
    myFunc1: myFunc1,
    myFunc2: myFunc2
  }
}();

Then the outline view just shows you the myNamespace var. I've tried looking but can't find a view that will actually show me the hierarchy correctly. Does anyone know of a way to view this or is it a case of eclipse not being able to do this?

解决方案

Add:

/**
 * @memberOf myNamespace
 */

before each function definition to restore the hierarchy.

You will find more interesting tags to document your code here:
How I Introduced JsDoc into a JavaScript project – and found my Eclipse Outline

这篇关于使用显示模块模式时,如何查看eclipse中的轮廓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆