Eclipse开发 - 获取编辑器中当前显示的行数

时间:2017-09-22 09:40:58

标签: java eclipse-plugin editor lines

我想在Eclipse IDE中的编辑器中获取有关当前显示行的信息:

enter image description here

编辑器显示16行,但hw1.c有30行。

到目前为止,我可以通过调用以下方式获取文档的总行数:

reference.getEditor(false).getDocumentProvider().getDocument(
    reference.getEditor(false).getEditorInput()).getNumberOfLines()

但此调用始终返回行数(即样本为30)。

有没有办法获得当前显示行的数量(即样本为16)?我检查了IDocument接口,但没有找到任何方法。

每次显示行更改时,我还需要更新。

由于

1 个答案:

答案 0 :(得分:0)

你只是想检查你写了多少LOC?如果是这样,请看一下:

after transition