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 - Reduce static initialization blocks usage in editor.fold
Summary: Reduce static initialization blocks usage in editor.fold
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Code folding (show other bugs)
Version: 7.0
Hardware: PC All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on: 205707
Blocks: 121357
  Show dependency tree
 
Reported: 2012-01-24 10:01 UTC by emi
Modified: 2014-07-15 05:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.