Child pages
  • [debugger] Restoring line number support in Debugger
Skip to end of metadata
Go to start of metadata

Below you can see a part of a report, that In-Portal debugger generates on each page load (only when debugging is enabled).

Among other things this report also have file information (name and line number) from which a particular record was added into debugger report. As you can see they are clickable, however to be able to open each file a special Launchy (https://addons.mozilla.org/en-us/firefox/addon/launchy/) Firefox extension needs to be installed.

Problem

All seems nice, but line number, specified next to filename in debugger report isn't passed along to a program, that will open that file. Because of this developer need:

  1. to remember line number from a debugger report
  2. open file in Launchy
  3. use "Go To Line ..." menu of an editor, where file was opened to go to a line number, that he previously remembered

Doing all that on a regular basis might result in developer forgetting what's for he opened a file in first place.

At Intechnic we are using PHPStorm (http://www.jetbrains.com/phpstorm/) as our IDE. Among many other features it also support command-line invocation (see http://www.jetbrains.com/phpstorm/webhelp/working-with-phpstorm-features-from-command-line.html). According to documentation the only way the line number can be passed to IDE is through "–line" parameter:

PhpStorm.exe C:\SamplesProjects\MetersToInchesConverter.php --line 3

Different IDE most likely will use different way of specifying line number in command line. To be compatible with most of IDE debugger don't pass line number to IDE at all.

Solution

I've been "Command-line Launcher" tool (http://shellrunner.com/2012/11/16/open-files-from-the-command-line-in-phpstorm/), that is created automatically upon PHPStorm installation, but also can be created on request (e.g. if it's missing). I never noticed, but this tool is actually a wrapper script around PhpStorm main executable, that allows it to support larger variety of command-line option formats (same options, but typed in different ways). Along them I've found out one, that allowed "filename:line_number" notation to be used (same as you saw in debugger report before):

pstorm C:\SamplesProjects\MetersToInchesConverter.php:3

Note, that in this example I used newly created wrapper script "pstorm" instead of "PhpStorm.exe". After finding that the only thing, that was needed is to pass line number, from debugger, which was pretty simple.

debugger_file_line_number_fix.patch

Related Tasks

INP-1242 - Getting issue details... STATUS

1 Comment

  1. With line number being passed on to the editor things indeed works better, but still there is a way for improvement.

    For example due usage of Launchy Firefox add-on we have 2 problems:

    1. it works only on Firefox
    2. to open a file in editor you need to perform following steps each time (see image below):
      1. right click on link (this is a link, and naturally I want to left click on it)
      2. from a long context menu (menu size depends on installed add-on count, but it's usually pretty big) I need to:
        1. find Launchy sub-menu
        2. select then only editor, available from there (if there is only editor, then why it's in sub-menu) 

    As iTunes user I see, that there is nice "View in iTunes" button on each app detail page (e.g. https://itunes.apple.com/us/app/practical-photoshop-techniques/id451457447?mt=8), that will launch iTunes app, that is installed locally.

    After investigating that subject I've found out, that it's done via "protocol handlers". Basically an app can register itself as handler if any protocol it likes to. After some coding I've created an app for Mac and set of scripts for Windows, that would do that for PhpStorm. For more details please visit https://github.com/aik099/PhpStormProtocol.

    To be able to use all of above you need following adding_custom_ide_support.patch patch to your In-Portal installation.