使用foreach或regex在Eclipse RCPTT中进行验证

时间:2018-05-09 17:11:24

标签: eclipse eclipse-rcptt

在RCPTT中录制后,我有以下脚本:

get-editor "test.c" | get-text-viewer | get-property "markers['31'][0].Type" 
| equals "text-to-verify" | verify-true

markers['31'][0].Type的价值来自markers['0'][0].Type - markers['45'][0].Type,数字是动态的。

我想检查任何标记类型是否包含特定值。

但我无法使用.*foreach

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

// This will store the comma separated list
global [val indices 0]
// Set to expected size of indices (10)
global [val list_size [int 10]]

loop [val index [int 1]] {
    global [val indices [concat $indices "," $index]] -override
    if [$index | lt $list_size] {
        recur [$index | plus 1]
    }
}

$indices | split -sep "," | foreach [val item] {
    with [get-editor "test.c" | get-text-viewer] {
        try {
            get-property [concat "markers['" $item "'][0].Type"]
             | equals "text-to-verify" | verify-true
        }
        -catch {
            // You will need to fine-tune this catch to not allow every sort of problems
        }
    }
}