Eclipse变量插件问题

Eclipse变量插件问题

 

最近在研究JDT的源代码,因为首先感兴趣的是调试相关的功能,所以在查看JDT的源代码之前,首先看到Eclipse上的两篇比较不错的文章:

《We Have Lift-off  The Launching Framework in Eclipse》和

《How to Write an Eclipse Debugger》

前面一篇讲解了Eclipse的”启动框架”,后一篇讲解了Eclipse的调试框架。后一篇中,作者有个示例插件,我下下来调试,学习。在学习过程中,碰到一个奇怪的问题,就是我修改了plugin.xml文件后,却并不能生效,例如,这是原先的内容:

<extension

         point="org.eclipse.core.variables.valueVariables">

      <variable

    initialValue="c:\perl\bin\perl.exe"

            name="perlExecutable"

            description="Path to Perl executablein the local file system">

      </variable>

   </extension>

 

我修改为:

<extension

         point="org.eclipse.core.variables.valueVariables">

      <variable

            initialValue="D:\app\Administrator\product\11.2.0\dbhome_1\perl\bin\"

            name="perlExecutable"

            description="Path to Perl executablein the local file system">

      </variable>

   </extension>

 

第一次修改生效了,然后第二次我是在,“被调试的Eclipse进程”执行的时候修改为:

<extension

         point="org.eclipse.core.variables.valueVariables">

      <variable

            initialValue="D:\app\Administrator\product\11.2.0\dbhome_1\perl\bin\perl.exe"

            name="perlExecutable"

            description="Path to Perl executablein the local file system">

      </variable>

   </extension>

 

结果,没有起作用,而且后面无论我怎么操作,这个值就一直保持为: D:\app\Administrator\product\11.2.0\dbhome_1\perl\bin\。无论我是重启Eclipse也好,还是加-clean参数,都无济于事,百度和google了好长时间,也没找到问题所在,无奈之下,只好去查看org.eclipse.core.variables.valueVariables的源代码,终于发现了问题所在。请看以下代码:

/**

     * Load contributedvariables and persisted variables

     */

    private synchronized void initialize() {

       if (fDynamicVariables == null) {

           fInternalChange = true;

           fDynamicVariables = new HashMap(5);

           fValueVariables = new HashMap(5);

           loadContributedValueVariables();

           loadPersistedValueVariables();

           loadDynamicVariables();

       InstanceScope.INSTANCE.getNode(VariablesPlugin.PI_CORE_VARIABLES).addPreferenceChangeListener(this);

           fInternalChange = false;

       }

    }

 

这里,在StringVariableManager 初始化的时候会先加载插件中的变量,然后再加载“持久化的变量值”。跟踪loadPersistedValueVariables()会发现perlExecutable 的值为D:\app\Administrator\product\11.2.0\dbhome_1\perl\bin\

因此,修改后并不起作用。总会被覆盖掉,那么要怎么清除这个值呢?

 

Eclipse的Preferences的值是保存在以下位置的:

${workspace}\.metadata\.plugins\org.eclipse.core.runtime\.settings

 

打开org.eclipse.core.variables.prefs文件,是个xml文件,保存的就是变量的值。删掉这个文件,自然就会读取插件文件中定义的值。

 

总结:

   Eclipse的VariablesPlugin 会将定义的变量存储在工作空间的preferences中,如果修改plugin.xml文件中的变量值没有生效,最好检查一下工作空间中是否已经保存了值,如果保存了,需要删除这个文件,才能生效。

 

//*****************************************************************/

//**  本人原创文章,转摘请保留本段内容,万分感谢!

//**  microdreamsoft(Lin Shaohua):

//**  由于本人水平有限,欢迎各位高手指正。

//**  本人所有原创文章将发布在以下blog:

//**   http://hi.baidu.com/microdreamsoft

//**   http://blog.csdn.net/hydream

//**   http://www.cnblogs.com/MicroDreamSoft/

//**   http://websoso.bokee.com

//**   http://89727175.qzone.qq.com

//**   http://751728871.qzone.qq.com

//*****************************************************************/
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值