I am currently developing a plugin in which I need a function to only execute when my cursor is within a javadoc comment partition.
I have tried to execute IDocument.computePartitioning() as well as IDocument.getContentType(). So far the only partition type that is returning is the default content type. I can see that, although the IDocument instance is correct, the getDocumentPartitioner() method returns null.
My question is, my IDocument clearly contains IJavaPartitions as it's a .java file. How can I access this partitioner in order to determine what partition my cursor is located within?
You can use the
computePartitioningmethod oforg.eclipse.jface.text.TextUtilitiesto get the region(s) for a range:This will deal with any
IDocumentExtension3You can also get the partitioning name from the
TextViewer/SourceViewerby calling thegetDocumentPartitioningmethod.