Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » ContentAssistant and partitioned documents(Issue during partition recognition if content assist is invoked on the last document character)
ContentAssistant and partitioned documents [message #802269] Sun, 19 February 2012 18:04
Filippo Pacifici is currently offline Filippo PacificiFriend
Messages: 1
Registered: February 2012
Junior Member

I am developing content assistant feature for a plugin:
I am using a SourceViewer, with an instance of Document attached.
The document is partitioned through an org.eclipse.jface.text.rules.FastPartitioner, and i am using an instance of org.eclipse.jface.text.contentassist.ContentAssistant.

As long as I try to use content assistant from any position in the document which is not the last character everything is fine:
-partitioning is correctly performed
-content assistant popup works fine

When I try, instead, to open content assistant popup on the last character of the document I don't manage to have the popup opened (no matter if I am in a crrect partition). More precisely what happens is:

1) ContentAssistant.computeCompletionProposals(ITextViewer, offset) is invoked (as usual), and the offset does not correspond to the offset of the last character of the document but at the position of the cursor (which is the offset of the last character + 1).

2) when fast partitioner is called to return the proper partition at that offset, it returns IDocument.DEFAULT_CONTENT_TYPE since the provided offset is out of the last partition of the document (which terminates at the last character of the document).

Here is the code snippet from FastPartitioner:
public ITypedRegion getPartition(int offset) {
   TypedPosition previous= (TypedPosition) category[category.length - 1];
   if (previous.includes(offset))
      return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
   int endOffset= previous.getOffset() + previous.getLength();
   return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);

previous.include(offset) returns since the last valid offset is the one of the last character in the document.

Do you think it is a bug in ContentAssistant? or am I missing something?


Previous Topic:Persistent Properties map empty
Next Topic:@since and dependencies in API tooling
Goto Forum:

Current Time: Thu Aug 18 10:19:19 GMT 2022

Powered by FUDForum. Page generated in 0.01996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top