public class DefaultJavaFoldingStructureProvider extends java.lang.Object implements IJavaFoldingStructureProvider, IJavaFoldingStructureProviderExtension
Clients may instantiate or subclass. Subclasses must make sure to always call the superclass' code when overriding methods that are marked with "subclasses may extend".
Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext
A context that contains the information needed to compute the folding structure of an
IJavaScriptUnit or an IClassFile. |
protected static class |
DefaultJavaFoldingStructureProvider.JavaProjectionAnnotation
A
ProjectionAnnotation for JavaScript code. |
| Constructor and Description |
|---|
DefaultJavaFoldingStructureProvider()
Creates a new folding provider.
|
| Modifier and Type | Method and Description |
|---|---|
protected IRegion |
alignRegion(IRegion region,
DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
Aligns
region to start and end at a line offset. |
void |
collapseComments()
Collapses all comments.
|
void |
collapseElements(IJavaScriptElement[] elements)
Collapses the given elements.
|
void |
collapseMembers()
Collapses all members except for top level types.
|
protected void |
computeFoldingStructure(IJavaScriptElement element,
DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
Computes the folding structure for a given
JavaScript element. |
protected IRegion[] |
computeProjectionRanges(ISourceReference reference,
DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
Computes the projection ranges for a given
ISourceReference. |
protected Position |
createCommentPosition(IRegion aligned)
Creates a comment folding position from an
aligned
region. |
protected Position |
createMemberPosition(IRegion aligned,
IMember member)
Creates a folding position that remembers its member from an
aligned
region. |
void |
expandElements(IJavaScriptElement[] elements)
Expands the given elements.
|
protected void |
handleProjectionDisabled()
Called whenever projection is disabled, for example when the provider is
uninstalled, when the viewer issues a
projectionDisabled message and before
enabling the provider. |
protected void |
handleProjectionEnabled()
Called whenever projection is enabled, for example when the viewer issues a
projectionEnabled message. |
void |
initialize()
(Re-)initializes the structure provided by the receiver.
|
void |
install(ITextEditor editor,
ProjectionViewer viewer)
Installs this structure provider on the given editor and viewer.
|
protected boolean |
isInstalled()
Returns
true if the provider is installed, false otherwise. |
void |
uninstall()
Uninstalls this structure provider.
|
public DefaultJavaFoldingStructureProvider()
installed on an editor/viewer pair before it
can be used, and uninstalled when not used any longer.
The projection state may be reset by calling initialize().
public void install(ITextEditor editor,
ProjectionViewer viewer)
viewer and enable / disable generation of projection
structure accordingly.
Subclasses may extend.
install in interface IJavaFoldingStructureProvidereditor - the editor that this provider works onviewer - the projection viewer that displays the annotations created
by this structure providerpublic void uninstall()
Subclasses may extend.
uninstall in interface IJavaFoldingStructureProviderprotected final boolean isInstalled()
true if the provider is installed, false otherwise.true if the provider is installed, false otherwiseprotected void handleProjectionEnabled()
projectionEnabled message. When the provider
is already enabled when this method is called, it is first
disabled.
Subclasses may extend.
protected void handleProjectionDisabled()
uninstalled, when the viewer issues a
projectionDisabled message and before
enabling the provider. Implementations must be prepared to
handle multiple calls to this method even if the provider is already disabled.
Subclasses may extend.
public final void initialize()
IJavaFoldingStructureProviderinitialize in interface IJavaFoldingStructureProviderprotected void computeFoldingStructure(IJavaScriptElement element, DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
JavaScript element. Computed
projection annotations are
added
to the computation context.
Subclasses may extend or replace. The default implementation creates projection annotations for the following elements:
element - the JavaScript element to compute the folding structure forctx - the computation contextprotected final IRegion[] computeProjectionRanges(ISourceReference reference, DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
ISourceReference. More than one
range or none at all may be returned. If there are no foldable regions, an empty array is
returned.
The last region in the returned array (if not empty) describes the region for the java element that implements the source reference. Any preceding regions describe javadoc comments of that JavaScript element.
reference - a JavaScript element that is a source referencectx - the folding contextprotected final Position createCommentPosition(IRegion aligned)
aligned
region.aligned - an aligned regionalignedprotected final Position createMemberPosition(IRegion aligned,
IMember member)
aligned
region.aligned - an aligned regionmember - the member to rememberalignedprotected final IRegion alignRegion(IRegion region,
DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext ctx)
region to start and end at a line offset. The region's start is
decreased to the next line offset, and the end offset increased to the next line start or the
end of the document. null is returned if region is
null itself or does not comprise at least one line delimiter, as a single line
cannot be folded.region - the region to align, may be nullctx - the folding contextregion that is aligned with line
offsets, null if the region is too small to be foldable (e.g. covers
only one line)public final void collapseMembers()
IJavaFoldingStructureProviderExtensioncollapseMembers in interface IJavaFoldingStructureProviderExtensionpublic final void collapseComments()
IJavaFoldingStructureProviderExtensioncollapseComments in interface IJavaFoldingStructureProviderExtensionpublic final void collapseElements(IJavaScriptElement[] elements)
IJavaFoldingStructureProviderExtensioncollapseElements in interface IJavaFoldingStructureProviderExtensionelements - the JavaScript elements to collapse (the array and its elements must not be
modified)public final void expandElements(IJavaScriptElement[] elements)
IJavaFoldingStructureProviderExtensionexpandElements in interface IJavaFoldingStructureProviderExtensionelements - the JavaScript elements to expand (the array and its elements must not be modified)Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.