gpt4 book ai didi

java - 通过 URL 处理程序在 Eclipse 中打开文件

转载 作者:搜寻专家 更新时间:2023-11-01 03:52:12 25 4
gpt4 key购买 nike

在我的项目中,我有一个特殊的 JSP,它在出现异常时显示异常堆栈跟踪。

有没有办法使用 URL 处理程序或其他可以让 Eclipse 打开文件的东西?也许使用 xdg-open

我在 Kubuntu Linux 上使用 Eclipse 4.3。

最佳答案

我最终得到了这个解决方案:

  1. 编辑xdebug.ini(应该是/etc/php/7.0/mods-available/xdebug.ini),添加:

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

    重新启动您的服务器或 php-fpm。对于 Ubuntu 上的 Apache,使用 sudo service apache2 restart

  2. 创建 eclipse-launch.sh。它旨在解析 URL 并将文件传递给 Eclipse。你可以随意命名,放在任何你想放的地方,我已经放在eclise目录下了。请务必将 /home/user 替换为您的实际主目录,将 path="..." 替换为实际的 eclipse 路径:

    #! /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/guide/product_open_file.htm

  3. 赋予文件可执行权限:chmod +a eclipse-launch.sh

  4. ~/.local/share/applications/ 创建 xdebug.desktop。它将被 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;
  5. 运行 xdg-mime default xdebug.desktop x-scheme-handler/xdebug。这应该将一个条目添加到 ~.local/share/applications/mimeapps.list[Default Applications] 部分。该条目本身应该类似于 x-scheme-handler/xdebug=xdebug.desktop

  6. 对于 Firefox,请按照此处的说明进行操作:https://xdebug.org/docs/all_settings#file_link_format

    • 打开about:config
    • 添加一个新的 boolean 值设置 network.protocol-handler.expose.xdebug 并将其设置为 false
    • 第一次单击 xdebug:///链接时,Firefox 会提示您选择要运行的应用程序,指向创建的 eclipse-launch.sh 文件。

关于java - 通过 URL 处理程序在 Eclipse 中打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23058940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com