Mike Sandman wrote:

What I have so far is that inside the inherited selectContentTypePlugin(...) method of RubySourceViewer, TextUtilities.getContentType(...) is returning c_string when you double click inside double-quoted text, otherwise it always returns __dftl_partition_content_type.  This makes some sense as the fDoubleClickStrategies map contains some RubyDoubleClickSelector objects as seen in the debugger.
[snip]

What I am trying to understand is why is c_string being returned when you double-click double-quoted text?
This is a code snippet (which I have yet to make sense of) from DefaultPartitioner

    public ITypedRegion getPartition(int offset) {
        checkInitialization();

        try {

            Position[] category = fDocument.getPositions(fPositionCategory);

            if (category == null || category.length == 0)
                return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);

            int index= fDocument.computeIndexInCategory(fPositionCategory, offset);

            if (index < category.length) {

                TypedPosition next= (TypedPosition) category[index];

                if (offset == next.offset)
                    return new TypedRegion(next.getOffset(), next.getLength(), next.getType());

                if (index == 0)
                    return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);

                TypedPosition previous= (TypedPosition) category[index - 1];
                if (previous.includes(offset))
                    return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());

                int endOffset= previous.getOffset() + previous.getLength();
                return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
            }

            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);

        } catch (BadPositionCategoryException x) {
        } catch (BadLocationException x) {
        }

        return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
    }


In this case fDocument is the RDT's PartiallySynchronizedDocument.  The bottom line is that if you double click on double-quoted text, the getPartition(...) method above returns an ITypedRegion object that has its type set to c_string, otherwise the returned ITypedRegion object's type is __dftl_partition_content_type.  As I mention in a previous email, when c_string is returned, fDoubleClickStrategies fails to yield a RubyDoubleClickSelector and viola, no highlighting.

Anyone have any thoughts?  Perhaps we should provide our own partitioner?  I still need to understand where c_string comes from.

-mike

Reply via email to