This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 108030 - Not possible to detect to which FoldOperation an instance of Fold belongs to
Summary: Not possible to detect to which FoldOperation an instance of Fold belongs to
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Miloslav Metelka
Depends on:
Reported: 2007-06-25 15:28 UTC by Marek Fukala
Modified: 2008-03-04 11:58 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Patch adding FoldOperation.owns(Fold) (10.28 KB, patch)
2008-03-03 14:25 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2007-06-25 15:28:33 UTC
Having a possibility to detect to which FoldOperation an instance of Fold belongs to, resp. which FoldManager created
the Fold would easy usecases when there are more FoldManager implementations bound to one mimetype.

Currently the problem can be partially solved by using Fold.getFoldType() which however returns an instance of final
class so no class instance resolution can be used. The problem gets worser in case of a generic FoldManager
implementation like Schlieman has which creates the FoldType-s based on some external metadata.

The only generic way I found is:

                        Fold f = fold.getFold (i);
                        try {
                            //no ISE thrown - my fold
                            l.add (f.getType());
                        } catch (IllegalStateException e) {
                            //not my fold

If for example getExtraInfo() is called on fold which wasn't created by this FoldManager, the ISE it thrown, so I know
that this is not my fold. This solution is IMHO no elegant enought, I would expect something like:

Fold.isCreatedBy(FoldOperation) or somethin similar.
Comment 1 Vitezslav Stejskal 2007-06-26 13:18:16 UTC
Marku, how important is fixing this issue? Does it block other issues? It's likely to require a small API change. Using
exceptions for flow control is an antipattern we should avoid of course. Feel free to make it P2 if it's important to
fix it soon.
Comment 2 Marek Fukala 2007-06-26 14:01:48 UTC
It would be nice if resolved to the upcoming beta, or at least to final release. Not critical.
Comment 3 Miloslav Metelka 2008-03-03 14:24:58 UTC
I've implemented FoldOperation.owns(Fold). Diff attached. Marku if you need it into 6.1 please raise the priority. Thanks.
Comment 4 Miloslav Metelka 2008-03-03 14:25:59 UTC
Created attachment 57677 [details]
Patch adding FoldOperation.owns(Fold)
Comment 5 Marek Fukala 2008-03-03 16:35:14 UTC
So far it looks like I do not really need it. So if it takes too much of your time now we can put it off to The
patch look fine to me.
Comment 6 Miloslav Metelka 2008-03-04 11:58:32 UTC
No, I have it prepared on disk so I just commit it.;node=3fc9a480f2f3