Package org.eclipse.jface.text.formatter
Class ContextBasedFormattingStrategy
- java.lang.Object
-
- org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy
-
- All Implemented Interfaces:
IFormattingStrategy,IFormattingStrategyExtension
public abstract class ContextBasedFormattingStrategy extends java.lang.Object implements IFormattingStrategy, IFormattingStrategyExtension
Formatting strategy for context based content formatting. Retrieves the preferences set on the formatting context'sFormattingContextProperties.CONTEXT_PREFERENCESproperty and makes them available to subclasses.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description ContextBasedFormattingStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidformat()Formats the region with the properties indicated in the formatting context previously supplied byformatterStarts(IFormattingContext).java.lang.Stringformat(java.lang.String content, boolean start, java.lang.String indentation, int[] positions)Formats the given string.voidformatterStarts(java.lang.String indentation)Informs the strategy about the start of a formatting process in which it will participate.voidformatterStarts(IFormattingContext context)Informs the strategy about the start of a formatting process in which it will participate.voidformatterStops()Informs the strategy that the formatting process in which it has participated has been finished.java.util.Map<java.lang.String,java.lang.String>getPreferences()Returns the preferences used for the current formatting step.
-
-
-
Method Detail
-
format
public void format()
Description copied from interface:IFormattingStrategyExtensionFormats the region with the properties indicated in the formatting context previously supplied byformatterStarts(IFormattingContext).- Specified by:
formatin interfaceIFormattingStrategyExtension
-
format
public java.lang.String format(java.lang.String content, boolean start, java.lang.String indentation, int[] positions)Description copied from interface:IFormattingStrategyFormats the given string. During the formatting process this strategy must update the given character positions according to the changes applied to the given string.- Specified by:
formatin interfaceIFormattingStrategy- Parameters:
content- the initial string to be formattedstart- indicates whether the beginning of content is a line start in its documentindentation- the indentation string to be usedpositions- the character positions to be updated- Returns:
- the formatted string
-
formatterStarts
public void formatterStarts(IFormattingContext context)
Description copied from interface:IFormattingStrategyExtensionInforms the strategy about the start of a formatting process in which it will participate.- Specified by:
formatterStartsin interfaceIFormattingStrategyExtension- Parameters:
context- the formatting context used in the corresponding formatting process.
-
formatterStarts
public void formatterStarts(java.lang.String indentation)
Description copied from interface:IFormattingStrategyInforms the strategy about the start of a formatting process in which it will participate.- Specified by:
formatterStartsin interfaceIFormattingStrategy- Parameters:
indentation- the indent string of the first line at which the overall formatting process starts.
-
formatterStops
public void formatterStops()
Description copied from interface:IFormattingStrategyInforms the strategy that the formatting process in which it has participated has been finished.- Specified by:
formatterStopsin interfaceIFormattingStrategy- Specified by:
formatterStopsin interfaceIFormattingStrategyExtension
-
getPreferences
public final java.util.Map<java.lang.String,java.lang.String> getPreferences()
Returns the preferences used for the current formatting step.- Returns:
- The preferences for the current formatting step
-
-