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 207670

Summary: Reduce static initialization blocks usage in editor.fold
Product: editor Reporter: emi <emi>
Component: Code foldingAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal CC: err, jglick
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 205707    
Bug Blocks: 121357    

Description emi 2012-01-24 10:01:22 UTC
The way the FoldViewFactory is registered is quite odd, and seems to rely on a static initialization block call chain: FoldHierarchy.class loaded -> static initialization block -> ensureApiAccessorRegistered() -> ApiPackageAccessor.register -> FoldViewFactory.register().

I've added a comment on nbdev@ [1] and Jesse mentioned in reply [2] that this looks like a perfect candidate for Lookup usage.

My suggestion would have been to at least replace the static initialization block with a ModuleInstall, but Lookup is actually nicer.

Jesse quote:

EditorViewFactory.factories() should use Lookup.getDefault().lookupAll(EditorViewFactory.Factory.class), and FoldViewFactory.FoldFactory and its ilk (HighlightsViewFactory.HighlightsFactory, TestHighlightsViewFactory.FactoryImpl) should be registered using @ServiceProvider. (Which would also obviate the need for the int importance() attribute, since @SP.position could be used.)

End quote

1. http://netbeans.org/projects/www/lists/nbdev/archive/2012-01/message/53
2. http://netbeans.org/projects/www/lists/nbdev/archive/2012-01/message/54
Comment 1 Miloslav Metelka 2012-02-22 10:27:22 UTC
It was just a preliminary way until View Hierarchy SPI will be created (issue #205707).
In editor related modules we tend to register by using @MimeRegistration annotation so I would prefer that.
Comment 2 Svata Dedic 2012-02-22 10:54:43 UTC
OK, will wait :)
Comment 3 Svata Dedic 2014-07-15 05:16:30 UTC
Closing after 2 years. View hierarchy is still not a proper API. I am sure the relevant code will be converted when the SPI becomes public.