> On Jan 9, 2015, at 1:02 AM, Hugo Parente Lima <[email protected]> wrote:
> 
> Hi,
> 
> I'm writing (and using on my daily job) a QtCreator plugin[1] for the Ruby 
> language, the syntax highlighting doesn't support hereDoc style string, 
> hereDoc strings are those perl style string like:
> 
> foo = <<abc
> I'm a multiline string
> Hello
> abc
> 
> The problem is: the parser need to store more than an integer in the state, 
> because the string "abc" can be any string, so when parsing the line with 
> just "abc" it needs to know that it's inside a hereDoc string (the block 
> state does that) and it needs to know what's the string used to stop the 
> hereDoc string.
> 
> So my question is: It's safe to use QTextBlock::setUserData or 
> TextEditor::SyntaxHighlighter::setCurrentBlockUserData to store such data or 
> it was used internally or by other QtCreator plugins?
> 
> grep shows any use of "setCurrentBlockUserData" but "setUserData”.

The text editor base sets a custom text document layout on the document 
(TextEditor::TextDocumentLayout), and also custom user data on the text blocks 
(user data of type TextEditor::TextBlockUserData). This custom text block user 
data can be accessed with TextDocumentLayout::userData(block) and many parts in 
Qt Creator do that.
Partly also the base text editor, which saves information about 
bookmarks/breakpoints and any other marks there.

So, just setting QTextBlock::setUserData will break things.  
SyntaxHighlighter::setCurrentBlockUserData(QTextBlockUserData *data) should 
probably be removed (most probably it’s just there because the class was copied 
and modified from QSyntaxHighlighter).

I do not know much about highlighters though. They use the custom 
TextBlockUserData for some of their state. You could probably think about 
adding something there. On the other hand, we should probably also care about 
keeping that small. Saving the delimiter string in your syntax highlighter with 
a unique integer id, and augmenting your currentBlockState int with that id 
(OR-ing the “within a comment” with the shifted unique id) might also work.

Br, Eike

> Thanks.
> 
> [1] http://hugopl.github.io/RubyCreator/
> 
> -- 
> Hugo Parente Lima
> 
> _______________________________________________
> Qt-creator mailing list
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
Eike Ziller, Senior Software Engineer - Digia, Qt
 
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 
144331 B

_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/qt-creator

Reply via email to