Eclipse - enhancing outline view by utilizing require.js define(...)

My code is structured within the define(...) function in the following format:

define(['angular'], function(angular) {
        function foo () {
            console.log("Hi") ; 
        }
        function foo2 () {
            console.log("Hi") ; 
        }
        function foo3 () {
            console.log("Hi") ; 
        }
} )

Eclipse does not display any outline view for this structure, meaning it shows nothing. How can I get Eclipse to support this format and direct me to all function and variable declarations?

Here is a screenshot of my current outline view:

Answer №1

The default Eclipse plugins for JavaScript, JSDT Plugins, do not support RequireJS. I recommend trying out tern.java (authored by me), which provides support for RequireJS. You will benefit from features such as RequireJS completion, hyperlinking, hovering, and validation.

For Angular users, I suggest installing AngularJS Eclipse 0.8.0 (unreleased) based on tern.java. While the Outline problem persists with tern.java, feel free to submit any issues or ideas to enhance tern.java.

Answer №2

If you're looking for additional options, consider giving the Aptana Studio plugin a test drive. It provides a wide range of helpful tools for front-end web development.

Answer №4

If you want to improve the organization of your JavaScript code, consider adding JsDoc "@memberOf" before the inner function.
Check out the example below where you can find the "doValidation" and "put" functions in the outline view under the "MyNameSpace" class.

To learn more about JsDoc, visit this link:

View a snapshot from SuiteScript 2.0 RestLet integrated with RequireJS here: Snapshot from SuiteScript 2.0 RestLet. SuiteScript2.0 is integrated with RequireJS

Below is an actual code sample:

"use strict"; // Ensures that JavaScript code is executed in "strict mode"
/**
 *@NApiVersion 2.x
 *@NScriptType Restlet
 */
define(
    [
            'N/record', 'N/error'
    ],

/**
 * @param {record} record 
 */
function(record, error)
{
    /**
     * @memberOf myNameSpace
     */
    function doValidation(args, argNames, methodName)
    {
        for (var i = 0; i < args.length; i++)
        {
            if (!args[i] && args[i] !== 0)
            {
                throw error.create(
                    {
                        name : 'MISSING_REQ_ARG',
                        message : 'Missing a required argument: [' + argNames[i] + '] for method: ' + methodName
                    });
            }
        }
    }
    // Upsert a NetSuite record from request param
    /**
     * @memberOf myNameSpace
     */
    function put(context)
    {
        doValidation(
            [
                    context.recordtype, context.id
            ],
            [
                    'recordtype', 'id'
            ], 'PUT');
        var rec = record.load(
            {
                type : context.recordtype,
                id : context.id
            });
        for ( var fldName in context)
            if (context.hasOwnProperty(fldName))
            {
                if (fldName !== 'recordtype' && fldName !== 'id')
                {
                    rec.setValue(fldName, context[fldName]);
                }
            }
        rec.save();
        return JSON.stringify(rec);
    }
    return (
        {
            post : post
        });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript text converter using split() method

I have a large amount of data in text format, similar to the following: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e0b0d1b0c1b131f17124f3e19131f1712501d1113">[email protected]</a>:token1 | Time = US | Alphabe ...

Is it causing issues having the same version of jQuery included multiple times?

Within my HTML file, referred to as x.html, I've included other HTML files as well. In x.html, I have integrated the jquery library version 1.4.1. It seems that this same version of jquery is also being included from the other HTML files. Even though ...

An issue has occurred while trying to execute the npm start command within PhpStorm

When I try to run npm start on Windows' command prompt, it works fine. However, I encounter errors when running it in the PhpStorm Terminal. You can see the errors here. Is this a result of them being different platforms or could it be related to som ...

Issues with Rails not successfully sending AJAX data to the controller

I am new to AJAX, so please bear with me while I try to figure this out. My goal is to send data from a chat message box to two places – the chat box itself and to a method in my Rails backend. This way, I can display the message in real-time and also st ...

The issue I am facing is that when I click on a checkbox, only one of them seems to respond

When I click the button, only the first checkbox event is being checked while the rest of them are not. Can someone please provide some guidance on how to fix this issue? $("#cascadeChange").click(function() { //alert("Clicked"); ...

Exploring Nested Collections with KnockoutJs in an Asp.net MVC Environment

I have the following .net class: public class JobDetailsDTO { public string JobName { get; set; } public string CompanyName { get; set; } public String[] IndustryName; } I am trying to connect this to a Knockout JS model, but my nested collec ...

Retrieving the maximum values from JSON data using D3

Currently, I am working with D3 and JSON data by using a function that looks like this: d3.json("http://api.json", function(jsondata) { var data = jsondata.map(function(d) { return d.number; }); After executing this, the value of the data becomes ["2", ...

Removing a similar object from an array using JavaScript

Working on a d3 force graph, I aimed for smooth updates using the method shown in the Modifying a Force Layout example. However, my goal was to achieve dynamic updating behavior unlike the static example provided. After calling initializeGraphData(json); i ...

Building forms within an AngularJS directive

I recently developed an AngularJS directive that includes a form. This form consists of a required text field along with two additional child forms. Each child form also contains a required text field. The distinguishing factor between the two child forms ...

The validation errors in the form of CodeIgniter are not being displayed by the JavaScript variable

Currently, I am utilizing the built-in validation_errors() function in CodeIgniter for my login form. The validation errors are displaying correctly in my view, but when I try to echo them into a JavaScript variable within the script to customize notificat ...

The return value of a jQuery post request is consistently false

When I click on a tag, my code returns true but the data variable is false. Can you explain why this is happening? $('#AddProvince').click(function () { var url = '@Url.Action("SetProvinceList")'; var id = $('#Province&apo ...

Encountering an issue with inability to resolve the 'react-navigation-stack' module. Still seeking a solution to this problem

Having trouble with my react navigation in react native. I've already added npm react-navigation-stack and also npm install --save react-native-gesture-handler react-native-reanimated react-native-screens. The error message I'm getting is: Unab ...

Error: props.addPost does not exist as a function

Help Needed with React Error: props.addPost is not a function. I am trying to add a new post in my app. Please assist me. import React from "react"; import classes from "./MyPosts.module.css"; import { Post } from "./Post/Post.jsx& ...

A guide to implementing infinite scrolling with vue-infinite-loading in Nuxt.js (Vue.js)

Currently, I am working on developing a web application using Nuxt.js (Vue.js). Initially, to set up the project, I used the command: vue init nuxt/express MyProject ~page/help.vue <template> <div> <p v-for="item in list"> ...

Using AJAX for uploading files upon a change event rather than upon submission

Below is the code I have been using to implement an iframe for ajax file upload without refreshing the page upon form submission. The current code works as expected. window.onload=init; function init() { document.getElementById('form').onsubmi ...

Ways to isolate and limit the application of CSS in React and Gatsby to specific pages instead of having it affect the global scope

At the moment, I'm working on integrating a keen-slider library(https://www.npmjs.com/package/keen-slider). To install it, we have to include import 'keen-slider/keen-slider.min.css'. This essentially adds the CSS globally to our project. Ho ...

What could be causing the strange output from my filtered Object.values() function?

In my Vue3 component, I created a feature to showcase data using chips. The input is an Object with keys as indexes and values containing the element to be displayed. Here is the complete code documentation: <template> <div class="row" ...

Opt for a line break over a semicolon when using jQuery

I need assistance with breaking the line wherever a semicolon is present. var locdata = { "locations": [{ "id": 0, "name": 'USA', "cx": 100, "cy": 100, "address":'545, 8t ...

What is the best way to access all of a class's properties in JavaScript?

Is there a way to retrieve all the properties of a class using JavaScript? For example, if I have a class like this: .menu { color: black; width: 10px; } How can I extract "color: black; width: 10px;" as a string using JavaScript? Thanks in advance! ...

MVC - The challenge of users repeatedly clicking the Submit button

In my MVC application, there are multiple pages where users submit a form by clicking a Submit button. Occasionally, users may click the button multiple times if they don't see an immediate response, causing the form to be submitted twice. To address ...