小编use*_*101的帖子

如何从Eclipse插件获取资源路径

我正在使用Eclipse Plugin-in-project开发一个Eclipse插件,它将在工具栏中添加一个菜单项.

我的插件项目依赖于一个文件,该文件位于同一个插件项目中,我想要该文件的路径.

下面是我用来获取路径的示例代码:

Bundle bundle = Platform.getBundle("com.feat.eclipse.plugin");
URL fileURL = bundle.getEntry("webspy/lib/file.txt");
File file = null;
String path=null;
try {
    file = new File(FileLocator.resolve(fileURL).toURI());
    path = file.getAbsolutePath();
} catch (URISyntaxException e1) {
    e1.printStackTrace();
} catch (IOException e1) {
    e1.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

从Eclipse Run as> Eclipse Application运行时,它给了我正确的路径.但是当我将我的插件导出为jar并将其添加到我的Eclipse插件文件夹中时,它没有给我正确的路径.

请帮我解决这个问题!

eclipse eclipse-plugin

5
推荐指数
1
解决办法
1339
查看次数

如何根据空手道中的过滤器从jsonarray中删除对象

我想根据过滤器从 json 数组中删除一个对象,尝试了下面的代码但没有用

* def json = [ { "id": "0a7936ed", "code": "test", "label": "test", "type": "sell" }, { "id": "7bc1909b2", "code": "test2", "label": "test2", "type": "Buy" } ]
Run Code Online (Sandbox Code Playgroud)

我想删除代码等于测试的对象

* def fun = function(){ karate.remove('json', $.[?(@.code=='test')]") }
* call fun
Run Code Online (Sandbox Code Playgroud)

获取异常如下:

com.intuit.karate.exception.KarateException: javascript function call failed: String index out of range: -1
    at com.intuit.karate.Script.evalFunctionCall(Script.java:1622)
    at com.intuit.karate.Script.call(Script.java:1573)
    at com.intuit.karate.Script.callAndUpdateConfigAndAlsoVarsIfMapReturned(Script.java:1690)
    at com.intuit.karate.StepDefs.callAndUpdateConfigAndVars(StepDefs.java:582)
Run Code Online (Sandbox Code Playgroud)

请建议我如何过滤它并删除对象。提前致谢..

karate

1
推荐指数
1
解决办法
2661
查看次数

标签 统计

eclipse ×1

eclipse-plugin ×1

karate ×1