apazureck / openui5vscodeTypescriptTools

Tools for openui5 to enhance productivity using VS Code
MIT License
22 stars 5 forks source link

modules ("Go to definition") support #21

Closed antonsn closed 7 years ago

antonsn commented 7 years ago

Could you please provide module support so that "Go to definition" will work for openui5 project when define is used.

There are extensions like https://marketplace.visualstudio.com/items?itemName=lici.require-js but it seems they do not work for openui5 project.

antonsn commented 7 years ago

In other words if I created my own module like below :

sap.ui.define([
    "sap/m/Dialog",
    "./utilities"

], function (Dialog, utilities) {
    "use strict";

    return {
         myFunction :
.....

it would be very useful to be able to navigate to myFunction from another file.

And the same with typescript

apazureck commented 7 years ago

Are you meaning A this:

  1. Put cursor on "./utilities"
  2. Module file gets opened

Or do you mean B you are using your module defined here an want to go to this particular myFunction method from another module?

As I understood from your mail from before you wanted to do the first one. This is no problem.

But navigating to the functions would be a little more tricky, as I would have to get the corresponding module first and have to look for the method. If you want this feature I would recommend using typescript before javascript. VSCode for example uses typescript declarations to provide javascript intellisense / symbols / etc.

As the UI5 syntax is far from any common standard (ES5/6) I am not sure, if any plugin / symbol provider out on the marketplace plays along with that. And to be honest I don't want to get into that for now, as it is a huge heap of work to get it running well and I have a lot of other stuff to do before that, sorry. But as always: Contribution is very welcome.

So long story short: A is possible in the near future, B not so much.

Cheers

antonsn commented 7 years ago

I see. Looks complicated.

I found one plugin/symbol provider https://marketplace.visualstudio.com/items?itemName=lici.require-js that supports define/require and works for javascript . But it is not possible to use for ui5 because it doesn't take into account application name which should be specified to reference library like "myApplicationName/module". If I remove myApplicationNameit works. But then application will not work.

so:

defining myModule:


sap.ui.define([], function () {
     return {
      call : function() 
         ......

Using myModule:

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "myApplicationName/myModule"

], function (Controller,  m) {
    return Controller.extend("myApplicationName.view.Jobs", {
        onInit: function () {
                      m.call()  <--- goto definition

does not work but:

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "myModule"

], function (Controller,  m) {
    return Controller.extend("myApplicationName.view.Jobs", {
        onInit: function () {
                      m.call()  <--- goto definition

works

Now I do not know what would be the best thing to do. What do you think?

apazureck commented 7 years ago

Yes, that is the key.

As far as I know it is not possible to call another extension's (goto, symbol, diagnostic, etc.) providers, as each implementation varies. In the SAPUI case you would have to write your own provider from scratch.

But that would be a neat feature for js programmers. I have an idea: I'll have a look at the provider from the require extension, aks them if I can copy it into this project and modify the file stripping the application name from the require or define tags. The modified text is forwarded to the provider from the require js extension and it should do the magic behind.

I'll put it on my agenda. Maybe I can put this in the next two weeks.

apazureck commented 7 years ago

Hi @antonsn,

Sorry for the long delay. I had much going on and did not have time to take care of your issue. But I will work on that the next weeks. Hopefully I will get this done in June. It is now on prio 1, so it is not forgotten :)

anacierdem commented 7 years ago

Nice to see my provider getting some attention :)

apazureck commented 7 years ago

Hi @antonsn,

I implemented the go to module. It is available setting the extension to insiders mode. Could you provide me with a text project to try it out?

apazureck commented 7 years ago

Hi @antonsn,

As I did not get any reply I'll close that issue. Reopen a new one if it does not work.

antonsn commented 7 years ago

Great! It works! Thanks!

antonsn commented 7 years ago

Thank you. It works!

was on vacation , have not seen your post

On 24 July 2017 at 00:23, Andreas Pazureck notifications@github.com wrote:

Hi @antonsn https://github.com/antonsn,

As I did not get any reply I'll close that issue. Reopen a new one if it does not work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apazureck/openui5vscodeTypescriptTools/issues/21#issuecomment-317286634, or mute the thread https://github.com/notifications/unsubscribe-auth/AL_tV_zsex2lgvjqOzsgdAHhwiyi6Bo4ks5sQ8fpgaJpZM4MrfmV .

apazureck commented 7 years ago

no problemo, thank you for the feedback!