Re: Implementing folding for custom tags based language.

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

the FoldManager is the lower-level API to implement. If you plan to use
more integration points (navigator, ...) then CSL is the way to go at
the moment.

If implementing FoldManager, you may consider to use
FoldOperation.update instead of add+remove+bookkeeping in your own code.
The update() operation does a diff and performs add/remove for you.

Dne 2.12.2016 v 16:39 Volodymyr napsal(a):
> I also implemented custom FoldTypeProvider, but it doesn't make much
> sense, since the folds returned in StructureScanner to not carry the tag
> name.

I don't understand; the StructureScanner returns a map, whose keys are
fold type IDs. If your foldType.code() matches the map key, those
OffsetRanges will be converted to folds of that type.

Using FoldTemplate allows you to (re)define appearance of the fold. Note
that you should be able to define your own type with code "tags" for
your mime type; then you can override the FoldTemplate (if you do not
like < > delimiters).

> 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?)))
The best would be to implement it. Please elaborate a little on that
topic and I might be able to give you some starting pointers.

> 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.
> 
The StructureScanner is designed to process the whole file, as a part of
the parsing infrastructure. If you can keep partial data and invalidate
their parts based on edits, go for it and cache what you can; you can
then implement some sort of partial parse for your MIME type.

-S.
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.