Implementing folding for custom tags based language.

Volodymyr <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
Hi, 

I need to implement folding for a new html like language. 

I've read Gj's post about it - https://blogs.oracle.com/geertjan/entry/org_netbeans_modules_csl_api, where it is said: 
"When using the CSL API, you should not use org.netbeans.spi.editor.fold.FoldManager directly. It is too heavyweight, when compared to the alternative provided by the CSL API:  org.netbeans.modules.csl.api.StructureScanner." 

However I am finding hard time to understand how to do it if I need to make the folds to look the same way as it is in HTML editor (in collapsed mode, e.g. "<head ... 5 lines />"). With the FoldManager it is easier, since you have more control over what folds look like. In structure scanner I only seem to have an ability to add folds, but not how they are presented. Here is a part of my code: 

public Map<String, List<OffsetRange>> folds(ParserResult info) { 
        Map<String, List<OffsetRange>> folds = new HashMap<>(); 

        .... 
        .... 

        folds.put("tags", ranges); 
        return folds; 
    } 

And it produces folds that look this way: <... 5 lines />. 

I also implemented custom FoldTypeProvider, but it doesn't make much sense, since the folds returned in StructureScanner to not carry the tag name. 

Is using the FoldManager directly is the only option I am left with? 

Couple of other questions: 

1. In other IDE's you can collapse a fold with clicking at the end of the fold range, I find it very useful, does anybody know if this is going to be implemented in NetBeans sometime? What ways there is to sort of push it, if I do not have that much of experience with NetBeans to do it myself?))) 
2. Is there a way (if I somehow stick to StructureScanner) to rescan for folds only when a file gets saved? When the file is big enough it feels like an overkill to rescan it on each char typed. 

Thanks a lot. 

/Volodymyr.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.