php-ide-serenata icon indicating copy to clipboard operation
php-ide-serenata copied to clipboard

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

Open niels-numbers opened this issue 7 years ago • 1 comments

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:

  • Tried it on Atom 1.31.2
  • Tried it on latest release Atom 1.32.2
  • Deinstalled the plugin and reinstalled it
  • Restarted my PC and Atom
  • Created a new projekt and initialized a new Serenate projekt
  • Tried it in different files

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?

niels-numbers avatar Nov 26 '18 11:11 niels-numbers

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.

Gert-dev avatar Dec 12 '18 17:12 Gert-dev