Gert-dev / php-ide-serenata

Atom IDE package that integrates the Serenata server to provide PHP code assistance
https://serenata.gitlab.io/
Other
275 stars 19 forks source link

Extract for loop as method throws: Uncaught TypeError: Cannot read property 'some' of undefined #458

Open iwasherefirst2 opened 5 years ago

iwasherefirst2 commented 5 years ago

Hi,

I installed the plugin and everything works fine. I also can extract methods. Except when I try to select a for loop like this:

  for ($i=0; $i < 20; $i++) {
      $this->roll(0);
    }

If I click alt+m and enter a name for the extracted method and hit extract, atom scrolls to the bottom but no new method is inserted. Now for each click in the document the following error message is thrown:

Uncaught TypeError: Cannot read property 'some' of undefined

grafik

/usr/share/atom/resources/app/static/<embedded>:11
Hide Stack Trace
TypeError: Cannot read property 'some' of undefined
    at SnippetExpansion.t.exports.SnippetExpansion.cursorMoved (/usr/share/atom/resources/app/static/<embedded>:11:948501)
    at /usr/share/atom/resources/app/static/<embedded>:11:947907
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at Selection.markerDidChange (/usr/share/atom/resources/app/static/<embedded>:11:543689)
    at Selection.marker.onDidChange.e (/usr/share/atom/resources/app/static/<embedded>:11:528938)
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at DisplayMarker.t.exports.DisplayMarker.notifyObservers (/usr/share/atom/resources/app/static/<embedded>:14:3181496)
    at /usr/share/atom/resources/app/static/<embedded>:14:3176998
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at Marker.t.exports.Marker.emitChangeEvent (/usr/share/atom/resources/app/static/<embedded>:14:67803)
    at Marker.t.exports.Marker.update (/usr/share/atom/resources/app/static/<embedded>:14:66857)
    at Marker.t.exports.Marker.setHeadPosition (/usr/share/atom/resources/app/static/<embedded>:14:63016)
    at DisplayMarker.t.exports.DisplayMarker.setHeadBufferPosition (/usr/share/atom/resources/app/static/<embedded>:14:3178851)
    at DisplayMarker.t.exports.DisplayMarker.setHeadScreenPosition (/usr/share/atom/resources/app/static/<embedded>:14:3179083)
    at changePosition (/usr/share/atom/resources/app/static/<embedded>:11:519079)
    at Cursor.changePosition (/usr/share/atom/resources/app/static/<embedded>:11:527504)
    at Cursor.setScreenPosition (/usr/share/atom/resources/app/static/<embedded>:11:519045)
    at moveCursors.n (/usr/share/atom/resources/app/static/<embedded>:11:30282)
    at Array.forEach (<anonymous>)
    at transact (/usr/share/atom/resources/app/static/<embedded>:11:33144)
    at TextBuffer.transact (/usr/share/atom/resources/app/static/<embedded>:11:489188)
    at TextEditor.transact (/usr/share/atom/resources/app/static/<embedded>:11:24215)
    at TextEditor.moveCursors (/usr/share/atom/resources/app/static/<embedded>:11:33112)
    at TextEditor.setCursorScreenPosition (/usr/share/atom/resources/app/static/<embedded>:11:30265)
    at TextEditorComponent.didMouseDownOnContent (/usr/share/atom/resources/app/static/<embedded>:11:95495)

This is what I tried so far:

Every time I could reproduce the issue. I am using Ubuntu 18.04.

Also I noticed, that whenever I extract a method, the method is inserted at the bottom of the file below the class. So I actually always need to copy and paste the method from outsite to inside of my class. Is this intended?

Gert-dev commented 5 years ago

Definitely not intentional, though the refactoring code is somewhat outdated since it has been pending to be replaced with server-side refactoring functionality for a while and I must admit I don't use the method extraction functionality that often, hence the minor bugs that are creeping up.

Marking as bug, since this should be fixed at some point - either by fixing it in the current implementation or providing the new, server-side implementation that doesn't have this bug.