wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

Extension doesnt work on Windows 10 #36

Closed AncientSwordRage closed 5 years ago

AncientSwordRage commented 5 years ago

Does the extension not work on windows? I'm not sure why else it wouldn't recognise the syscall?

[2018-11-03 19:51:26.898] [renderer1] [error] [{"errno":-4094,"code":"UNKNOWN","syscall":"stat","path":"\\\\d:\\multivariate-hypergeo\\src\\PopulationInput.js"}]
[2018-11-03 19:51:26.913] [renderer1] [error] [{"fileOperationResult":1,"options":{"acceptTextOnly":true}}]
[2018-11-03 19:51:26.930] [renderer1] [error] [{"fileOperationResult":1,"options":{"acceptTextOnly":true}}]
borislit commented 5 years ago

Hey @AncientSwordRage ! I havent tried running it on Windows just yet. Ill try getting a Windows and see if the issue is reproducible. Meanwhile, do you mind running the application code locally as described here: https://github.com/wix/vscode-glean#contribute and see if you can find the cause of the issue? It would be super helpful. Thanks

AncientSwordRage commented 5 years ago

@borislit I have the extension up and running in debug mode in a separate project, but I don't know how I tell the other instance of VSCode to use that as my extension so I can debug it in situ ...?

Any more steps you want me to take?

borislit commented 5 years ago

Basically, once You click the play button (see the screenshot), it should open another instance of vscode, where you can play with the extension. The extension used in the new window should be the local version and not the one from the app market.

image

Its important note, that your VScode is set to open new projects in a separate window, you should turn it off

image

AncientSwordRage commented 5 years ago

So I've run through the codea few times, and it looks like it's creating the content for the new file, and the replacement snippet, but it's not actually inserting any text. I didn't see any errors.

Sometimes the paths it was finding seemed to be formed like d:/path\with\odd\slashes with some of the slashes backwards. Other than that it seemed ok. Still doesn't replace the selected text with the component though.

borislit commented 5 years ago

First of all, thanks for your time! Second of all, can you please place a breakpoint here: https://github.com/wix/vscode-glean/blob/a07eb2e383e372b3f1bda790b6424a6910acf1aa/src/code-actions.ts#L108

And see what do you get in a text variable?

AncientSwordRage commented 5 years ago

First of all, thanks for your time! Second of all, can you please place a breakpoint here: https://github.com/wix/vscode-glean/blob/a07eb2e383e372b3f1bda790b6424a6910acf1aa/src/code-actions.ts#L108

And see what do you get in a text variable?

I get this as the text variable:

"<PopulationInput  totalPopulation={this.state.totalPopulation}   handleTotalPopChange={this.handleTotalPopChange}/>"
borislit commented 5 years ago

hmm that seems fine. Perhaps we should try looking into target path resolution here: https://github.com/wix/vscode-glean/blob/a07eb2e383e372b3f1bda790b6424a6910acf1aa/src/code-actions.ts#L22

what value to you get here? is it correct?

AncientSwordRage commented 5 years ago

Here what I've got:

filePath
"d:\multivariate-hypergeo/src/PopulationInput.js"

Just so you know, I've picked /src from the folder picker, as the other option ( "d:\multivariate-hypergeo\src\PopulationInput.js" make me create a new file) doesn't seem to work and the whole function then fails with

RangeError: Maximum call stack size exceeded
message:"Maximum call stack size exceeded"
stack:"RangeError: Maximum call stack size exceeded\n\tat normalizeStringWin32 (path.js:33:30)\n\tat Object.resolve (path.js:339:20)\n\tat Object._makeLong (path.js:697:32)\n\tat fs.mkdirSync (fs.js:885:35)\n\tat Object.exports.wrapFsWithAsar.fs.mkdirSync (ELECTRON_ASAR.js:702:16)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:71:13)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:78:17)\n\tat sync (C:\Users\username\vscode-glean\node_modules\mkdirp\index.js:...
__proto__:Error {constructor: , name: "RangeError", message: "", …}

which seems like a problem

borislit commented 5 years ago

@AncientSwordRage can you try reversing the slashes in the right direction in the debugger (right before it writes to file) and see if it helps?

Just so you know, I've picked /src from the folder picker, as the other option ( "d:\multivariate-hypergeo\src\PopulationInput.js" make me create a new file) doesn't seem to work and the whole function then fails with

Didn't quite get that. Can you elaborate?

AncientSwordRage commented 5 years ago

Hi @borislit not at my computer atm. What I meant was that when I clicked the lightbulb and selected 'Extract Component' it opens the folder selector drop down, that has either '"d:\multivariate-hypergeo\src' or '/src'. If I pick the absolute path, I have to create a new file when it goes to the file selector. If instead at the folder selector stage, I click '/src' then I can choose any file in the '"d:\multivariate-hypergeo\src' folder.

I can update you with screenshots when I'm back at my computer, and answer your request about reversing the slashes.

AncientSwordRage commented 5 years ago

Selecting a folder:

folder selection

If I select the top option (absolute path):

file selection - abs folder path Suggests to create a new file (doesn't work)

If I select /src then I get this option: file selection - src folder path

And that is what errors, and fails to create or move the component (see range error above). This even happens when 'fixing' the slashes

borislit commented 5 years ago

@AncientSwordRage can you please provide the code of the origin file and the snippet you are trying to export? Ill have a window machine today

AncientSwordRage commented 5 years ago

Here's the repo/code snippet:

https://github.com/AncientSwordRage/multivaria/blob/master/src/VariableManager.js#L138-L145

borislit commented 5 years ago

@AncientSwordRage works on mac. Anyways, ill debug it in the evening and see where it get me. Ill keep you posted

AncientSwordRage commented 5 years ago

@borislit were you able to debug it?

borislit commented 5 years ago

@AncientSwordRage not yet. Ill get home in few hours and get to it

AncientSwordRage commented 5 years ago

@borislit thanks, I just noticed you'd renamed it, that was all.

borislit commented 5 years ago

@AncientSwordRage I've pushed a fixed. Should be in https://github.com/wix/vscode-glean/tree/v4.2.1

The issue seems to be a wrong VScode SDK API i've used to resolve file path URI. Somehow it worked on Mac, but failed on Windows. See the fix here: https://github.com/wix/vscode-glean/commit/29b808ab44385a53e1a3b40c88e5ce27cd4e49fc

Please validate :)

AncientSwordRage commented 5 years ago

@borislit Thanks for the update. I can confirm I no longer get the above error, but I'm now seeing this inthe output window:

[2018-11-05 23:02:19.762] [renderer1] [error] Cannot read property 'superClass' of undefined: TypeError: Cannot read property 'superClass' of undefined
    at isSupportedComponent (C:\Users\username\.vscode\extensions\wix.glean-4.2.1\out\modules\jsx.js:152:28)
    at Object.isStatefulComp (C:\Users\username\.vscode\extensions\wix.glean-4.2.1\out\modules\jsx.js:158:9)
    at CompleteActionProvider.provideCodeActions (C:\Users\username\.vscode\extensions\wix.glean-4.2.1\out\extension.js:33:19)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:501:615
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:108:368
    at new n.Class.derive._oncancel (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:85:776)
    at Object.t.asThenable (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:108:333)
    at e.provideCodeActions (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:501:574)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:516:103
    at e._withAdapter (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:512:91)
    at e.$provideCodeActions (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:516:65)
    at t._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:888)
    at t._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:640:554)
    at t._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:639:60)
    at t._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:638:59)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:635:926
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:98:138
    at e.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:99:496)
    at a (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:213)
    at Socket._socketDataListener (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:432)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

Not sure what's going wrong this time. What steps did you take to make it work for you?

borislit commented 5 years ago

@AncientSwordRage I've simply took the content of your file, selected the snippet to extract and ran the extract command. Can you please provide the exact steps you've tried to perform?

borislit commented 5 years ago

@williamluke4 please post see the comment above

AncientSwordRage commented 5 years ago

@borislit images for steps are here: https://github.com/wix/vscode-glean/issues/36#issuecomment-435714480

I selected the code, click the lightbulb, select 'extract component', click '/src', then select , PopulationInput.js'.

If I can figure out how to record the screen I'll do that. In the mean time would you be able to check out the whole repo and see if it still works?

borislit commented 5 years ago

@AncientSwordRage sure. To be sure, the snippet you've tried to extract is the one in https://github.com/wix/vscode-glean/issues/36#issuecomment-435806476 ? To record the screen i use https://getkap.co/

AncientSwordRage commented 5 years ago

@borislit I'll have to record it tonight (GMT) insha'Allah.

Yes that is the exact snippet

borislit commented 5 years ago

@AncientSwordRage can you please try the latest version? I've tried it on your project and it worked.

williamluke4 commented 5 years ago

@borislit I can confirm upgrading to 4.2.2 fixed this issue

borislit commented 5 years ago

@williamluke4 @AncientSwordRage yey! :) Couldnt be happier. Thank You for your effort! Your contribution is highly appreciated!

borislit commented 5 years ago

@AncientSwordRage can you confirm you are good?

AncientSwordRage commented 5 years ago

YUP THAT'S FIXED!

Thanks for helping me out!

borislit commented 5 years ago

@AncientSwordRage Thank you!