Open file in Eclipse via URL handler

In my project, I have a special JSP that displays a stacktrace exception in case of an Exception.

Is there a way to use a URL handler or something else where Eclipse will open the file? Maybe with xdg-open?

I am using Eclipse 4.3 on Kubuntu Linux.

+4
source share
1 answer

I ended up with this solution:

  • Change xdebug.ini(it should be somewhere like /etc/php/7.0/mods-available/xdebug.ini), add:

    xdebug.file_link_format="xdebug://%f(%l)"
    

    Reboot the server or php-fpm. For Apache on Ubuntu use sudo service apache2 restart.

  • eclipse-launch.sh. URL- Eclipse. , , , eclise. /home/user path="..." :

    #! /bin/bash
    
    arg=$1
    path="/home/user/eclipse/eclipse-neon/"
    
    # file name directly followed by a line number in parenthesis
    regex="//([^(]*)\(([0-9]+)\)"
    
    if [[ $arg =~ $regex ]]
    then
        file=${BASH_REMATCH[1]}
        line=${BASH_REMATCH[2]}
        $path/eclipse --launcher.openFile "$file"+"$line"
    else
        msg="Unsupported URL: $arg"
        zenity --info --text="$msg"
    
        # alternatives:
        # notify-send "$msg" # another notification program
        # $path/eclipse # just run eclipse
    fi
    

    Eclipse: http://help.eclipse.org/mars/index.jsp?topic=/org.eclipse.platform.doc.isv//product_open_file.htm

  • : chmod +a eclipse-launch.sh

  • xdebug.desktop ~/.local/share/applications/. xdg-open (Chrome xdg-open ).

    [Desktop Entry]
    Comment=
    Exec=/home/user/eclipse/eclipse-neon/eclipse-launch.sh "%u"
    Icon=/home/user/eclipse/eclipse-neon/eclipse/icon.xpm
    Name=Eclipse xdebug Launch
    NoDisplay=false
    StartupNotify=true
    Terminal=0
    TerminalOptions=
    Type=Application
    MimeType=x-scheme-handler/xdebug;
    
  • xdg-mime default xdebug.desktop x-scheme-handler/xdebug. ~.local/share/applications/mimeapps.list [Default Applications]. x-scheme-handler/xdebug=xdebug.desktop

  • Firefox : https://xdebug.org/docs/all_settings#file_link_format

    • about:config
    • network.protocol-handler.expose.xdebug false
    • xdebug:///Firefox , eclipse-launch.sh.
0

Source: https://habr.com/ru/post/1536436/


All Articles