Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 207670 - Reduce static initialization blocks usage in editor.fold
Reduce static initialization blocks usage in editor.fold
Product: editor
Classification: Unclassified
Component: Code folding
PC All
: P3 (vote)
: 7.4
Assigned To: Svata Dedic
Depends on: 205707
Blocks: 121357
  Show dependency treegraph
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


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

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.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo