```
val editorFilter: PartialFunction[Any /*result of textEditor */, AbstractTemplateEditor] = { case e: AbstractTemplateEditor => e }
val editor = (textEditor collect editorFilter) orElse (EditorHelper.findEditorOfDocument(viewer.getDocument()) collect editorFilter)
```