Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.editor.language
Class SmartIndentProvider

java.lang.Object
  extended by oracle.javatools.editor.language.SmartIndentProvider


public abstract class SmartIndentProvider
extends java.lang.Object

The SmartIndentProvider interface provides the necessary routines that let language-specific implementations intelligently determine the proper indentation for any given line should be.

Note that "smart" indentation takes the place of the regular auto-indentation behavior when defined by an implementation AND enabled by that implementation. It is up to each implementation to define properties and options for whether to use smart indentation for that language. This allows us flexibility in enabling smart indentation independently for various language implementations that provide it.

This interface is defined for two situations in which an auto-indentation or reindentation of a line may occur:

It is up to each implementation to determine whether reindenting or auto-indenting makes sense in these situations. Also, the implementation should also provide properties to give the user more flexibility in when auto-indenting or reindenting occurs.

See Also:
LanguageModule, LanguageSupport

Field Summary
protected  LanguageSupport support
          The umbrella LanguageSupport instance.

 

Constructor Summary
protected SmartIndentProvider(LanguageSupport support)
          Constructs a new SmartIndentProvider

 

Method Summary
protected  BasicDocument getDocument()
          Private utility routine to fetch the document.
abstract  int getIndentForLine(int line, int indentSize)
          Calculates what the indentation for the specified line should be based on the provided indent size.
protected  TextBuffer getTextBuffer()
          Private utility routine to fetch the text buffer for the document.
protected  java.lang.String getUseSmartIndentPropertyName()
          Fetches the name of the (boolean) property stored in the EditorProperties that we use to check whether smart indent is enabled or not.
abstract  boolean isAutoReindentTriggerChar(char charTyped)
          Fetches whether the char typed by the user should be considered a trigger character for reindenting the current line.
 boolean isSmartIndentEnabled(BasicEditorPane editor)
          Fetches whether smart indentation is enabled for this language implementation's smart indent provider.
 boolean shouldAutoIndentNewLine()
          Fetches whether the new line should be auto-indented when a new line is inserted (typed) by the user.
 boolean shouldAutoReindentOldLine()
          Fetches whether the old (original) line should be reindented when a new line is inserted (typed) by the user.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

support

protected LanguageSupport support
The umbrella LanguageSupport instance.

Constructor Detail

SmartIndentProvider

protected SmartIndentProvider(LanguageSupport support)
Constructs a new SmartIndentProvider
Parameters:
support - the language support this indent provider is used for

Method Detail

getTextBuffer

protected final TextBuffer getTextBuffer()
Private utility routine to fetch the text buffer for the document.
Returns:
the text buffer to use

getDocument

protected final BasicDocument getDocument()
Private utility routine to fetch the document.
Returns:
the text buffer to use

getUseSmartIndentPropertyName

protected final java.lang.String getUseSmartIndentPropertyName()
Fetches the name of the (boolean) property stored in the EditorProperties that we use to check whether smart indent is enabled or not.
Returns:
the name of the smart indent editor property

isSmartIndentEnabled

public final boolean isSmartIndentEnabled(BasicEditorPane editor)
Fetches whether smart indentation is enabled for this language implementation's smart indent provider. If it is not enabled, the editor will default to the regular auto or non-auto indentation behavior.

The editor is provided so that if this (whether smart indentation is on or not) is stored as an editor property, it can be retrieved from the editor using BasicEditorPane.getProperty() or BasicEditorPane.getBooleanProperty().

Parameters:
editor - the current editor to use for fetching properties
Returns:
whether smart indentation is enabled for this language

shouldAutoReindentOldLine

public boolean shouldAutoReindentOldLine()
Fetches whether the old (original) line should be reindented when a new line is inserted (typed) by the user. If this method returns true, the the caller will call back to reindent the line, probably by calling reindentLine().
Returns:
whether we should reindent the old line when a new line is typed

shouldAutoIndentNewLine

public boolean shouldAutoIndentNewLine()
Fetches whether the new line should be auto-indented when a new line is inserted (typed) by the user. If this method returns true, then the caller will call back to indent the line or get an indentation level.
Returns:
whether we should auto-indent the new line when a new line is typed

isAutoReindentTriggerChar

public abstract boolean isAutoReindentTriggerChar(char charTyped)
Fetches whether the char typed by the user should be considered a trigger character for reindenting the current line. If this method returns true, the caller will call back to reindent the line, probably by calling reindentLine().
Parameters:
charTyped - the character that was just typed
Returns:
whether the typed character is a trigger for auto-reindenting the current line

getIndentForLine

public abstract int getIndentForLine(int line,
                                     int indentSize)
Calculates what the indentation for the specified line should be based on the provided indent size. Since the document may or not be associated with an editor, it is the caller's responsibility to provide the indent size. Note that this method does not change the line indentation in the document, simply calculates what it should be.
Parameters:
line - the line in the document to calculate the indent for
indentSize - the size of a single indent to use
Returns:
the ideal indent size for ths line in equivalent space characters

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


Copyright © 1997, 2012, Oracle. All rights reserved.