facebook

JavaScript go to definition not working

  1. CodeMix & Angular IDE
  2.  > 
  3. Getting Help
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #615757 Reply

    raphi
    Participant

    I have the problem that I cannot go to definition of functions that are not in the same file.
    I try to do it with ctrl + click. I tried this with multiple projects. functions in the same js file seem to work.

    For example I have a project tree like this
    -project
    -projectfunctions.js
    -webresources
    -functions.js (here is the function i cannot go to definition)

    I am running Eclipse 2018-12 (4.10.0) and newest CodeMix version (2019.6.11)

    Thanks for your help!

    Greets,
    Raphi

    #615758 Reply

    Hi raphi,

    I have a few questions in order to help you better.
    Are you using Angular, React or any other library/framework?
    Are you using NodeJS or is this just a simple Web project?

    Cheers,
    Sal

    #615943 Reply

    raphi
    Participant

    Hi Sal,

    it’s a normal Web project. Only Javascript and JQuery.

    Greets,
    Raphi

    • This reply was modified 5 years, 5 months ago by raphi.
    #615967 Reply

    Hi raphi,

    Thanks for the info.
    I’m attaching a sample project where you can see go to definition working for JS files, please try it on the some() function in src/main.js let me know if it works fine for you.
    Also note that due the possibility of function and variable collision, jump to definition currently works on JS files that are in the same directory.

    Cheers,
    Sal

    Attachments:
    You must be logged in to view attached files.
    #616005 Reply

    raphi
    Participant

    Hi Sal,

    I tried the go to definition on your project like you described it… It doesn’t work :/

    Okay that’s bad cause it worked before also with functions in other projects. I don’t need that it looks up functions in every project (cause that will give collisions -> I also saw that sometimes it went to a definition in another project and not the referenced). I just want that it works with referenced projects (like you see in the picture attached).

    But as I can see now it looks like it doesn’t work at all. Neither for referenced projects nor in JS files in the same folder (like the project you sent to me).

    Hopefully there will be a solution for this issue.

    Thanks,
    Raphi

    Attachments:
    You must be logged in to view attached files.
    #616018 Reply

    support-swapna
    Moderator

    Raphi,

    To get the navigation working for JS files, you can create a file named jsconfig.json in the project’s root and paste the below content to the file :

    {
        "compilerOptions": {
            "target": "es6"
        },
        "exclude": [
            "node_modules"
        ]
    }

    This should help fix the issue. You can give it a try on the sample project sent by Sal.

    Please let us know how it works for you.

    –Swapna
    Genuitec Support

    #616022 Reply

    raphi
    Participant

    Hi,

    with the jsconfig.json it works for js files in the same project (whole project) 🙂

    Is there any possibility to get it working for js files in referenced projects like I described it before?
    Or can I maybe define that too in the jsconfig.json file?

    I have a lot of functions in the webresources project, wich I use in different projects… That would be awesome!

    Thanks,
    Raphi

    #616250 Reply

    Hi raphi,

    You can enable referencing to JS files in other projects by adding a “includes” property with glob patterns and listing the files that are meant to be taken into account.

    Let’s say that i’m working 3 projects, cmwebjsa (my main project), cmwebjsb and cmwebjsc.
    I can put a jsconfig.json file at the root of cmwebjsa with the following content in order to reference functions from cmwebjsb and cmwebjsc as well.

    
    {
      "compilerOptions": {
        "target": "es6"
      },
      "exclude": [
        "node_modules"
      ],
      "include": [
        "src/**/*.js", // Required in order to work with the js files of cmwebjsa (tweak as needed)
        "../cmwebjsb/src/**/*.js",
        "../cmwebjsc/src/**/*.js"
      ]
    }
    

    I’m attaching an example project which you can use to test.

    Cheers,
    Sal

    Attachments:
    You must be logged in to view attached files.
    #616306 Reply

    raphi
    Participant

    Hi Sal,

    thank you very much this works!
    You guys are awesome 🙂

    Greets,
    Raphi

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: JavaScript go to definition not working

You must be logged in to post in the forum log in