com.aptana.ide.editor.jscomment.formatting
Class JSCommentAutoIndentStrategy

java.lang.Object
  extended by com.aptana.ide.editors.unified.UnifiedAutoIndentStrategy
      extended by com.aptana.ide.editor.jscomment.formatting.JSCommentAutoIndentStrategy
All Implemented Interfaces:
IPreferenceClient, org.eclipse.jface.text.IAutoEditStrategy
Direct Known Subclasses:
ScriptDocAutoIndentStrategy

public class JSCommentAutoIndentStrategy
extends UnifiedAutoIndentStrategy


Field Summary
protected  java.lang.String linePrefix
          linePrefix
 
Fields inherited from class com.aptana.ide.editors.unified.UnifiedAutoIndentStrategy
configuration, context, sourceViewer
 
Constructor Summary
JSCommentAutoIndentStrategy(EditorFileContext context, org.eclipse.jface.text.source.SourceViewerConfiguration configuration, org.eclipse.jface.text.source.ISourceViewer sourceViewer)
           
 
Method Summary
 void customizeDocumentCommand(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.DocumentCommand command)
           
protected  org.eclipse.jface.text.IRegion findPrefixRange(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.IRegion line)
          Returns the range of the multiline comment prefix on the given line in document.
protected  LexemeList getLexemeList()
          Creates a lexeme list
 org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
          Returns the current preference store
protected  void indentAfterCommentEnd(org.eclipse.jface.text.IDocument d, org.eclipse.jface.text.DocumentCommand c)
          Unindents a typed slash ('/') if it forms the end of a comment.
protected  void indentAfterNewLine(org.eclipse.jface.text.IDocument d, org.eclipse.jface.text.DocumentCommand c)
          Copies the indentation of the previous line and adds a star.
protected  boolean indentCloseToken(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.text.DocumentCommand c, int offset, int lineOffset, int firstNonWS)
          indentCloseToken
protected  boolean isNewComment(org.eclipse.jface.text.IDocument document, int commandOffset)
          Guesses if the command operates within a newly created javadoc comment or not.
 
Methods inherited from class com.aptana.ide.editors.unified.UnifiedAutoIndentStrategy
autoTriggerAssist, canCloseBracket, canOverwriteBracket, closeBracket, findEndOfWhiteSpace, getAutoInsertCharacters, getAutoOverwriteCharacters, getIndentationAtOffset, getIndentationString, getIndentForCurrentLine, getIndentString, hideContentAssistPopup, indentAfterOpenBrace, isAutoInsertEnabled, isValidAutoInsertLocation, overwriteBracket, triggerContentAssistPopup, triggerContextAssistPopup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linePrefix

protected java.lang.String linePrefix
linePrefix

Constructor Detail

JSCommentAutoIndentStrategy

public JSCommentAutoIndentStrategy(EditorFileContext context,
                                   org.eclipse.jface.text.source.SourceViewerConfiguration configuration,
                                   org.eclipse.jface.text.source.ISourceViewer sourceViewer)
Parameters:
context -
configuration -
sourceViewer -
Method Detail

customizeDocumentCommand

public void customizeDocumentCommand(org.eclipse.jface.text.IDocument document,
                                     org.eclipse.jface.text.DocumentCommand command)
Specified by:
customizeDocumentCommand in interface org.eclipse.jface.text.IAutoEditStrategy
Overrides:
customizeDocumentCommand in class UnifiedAutoIndentStrategy
See Also:
IAutoEditStrategy.customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)

indentCloseToken

protected boolean indentCloseToken(org.eclipse.jface.text.IDocument doc,
                                   org.eclipse.jface.text.DocumentCommand c,
                                   int offset,
                                   int lineOffset,
                                   int firstNonWS)
indentCloseToken

Parameters:
doc -
c -
offset -
lineOffset -
firstNonWS -
Returns:
boolean

indentAfterNewLine

protected void indentAfterNewLine(org.eclipse.jface.text.IDocument d,
                                  org.eclipse.jface.text.DocumentCommand c)
Copies the indentation of the previous line and adds a star. If the javadoc just started on this line add standard method tags and close the javadoc.

Overrides:
indentAfterNewLine in class UnifiedAutoIndentStrategy
Parameters:
d - the document to work on
c - the command to deal with

isNewComment

protected boolean isNewComment(org.eclipse.jface.text.IDocument document,
                               int commandOffset)
Guesses if the command operates within a newly created javadoc comment or not. If in doubt, it will assume that the javadoc is new.

Parameters:
document - the document
commandOffset - the command offset
Returns:
true if the comment should be closed, false if not

indentAfterCommentEnd

protected void indentAfterCommentEnd(org.eclipse.jface.text.IDocument d,
                                     org.eclipse.jface.text.DocumentCommand c)
Unindents a typed slash ('/') if it forms the end of a comment.

Parameters:
d - the document
c - the command

findPrefixRange

protected org.eclipse.jface.text.IRegion findPrefixRange(org.eclipse.jface.text.IDocument document,
                                                         org.eclipse.jface.text.IRegion line)
                                                  throws org.eclipse.jface.text.BadLocationException
Returns the range of the multiline comment prefix on the given line in document. The prefix greedily matches the following regex pattern: \w*\*\w*, that is, any number of whitespace characters, followed by an asterix ('*'), followed by any number of whitespace characters.

Parameters:
document - the document to which line refers
line - the line from which to extract the prefix range
Returns:
an IRegion describing the range of the prefix on the given line
Throws:
org.eclipse.jface.text.BadLocationException - if accessing the document fails

getPreferenceStore

public org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
Description copied from class: UnifiedAutoIndentStrategy
Returns the current preference store

Specified by:
getPreferenceStore in interface IPreferenceClient
Specified by:
getPreferenceStore in class UnifiedAutoIndentStrategy
Returns:
The current preference store, or null if not found
See Also:
UnifiedAutoIndentStrategy.getPreferenceStore()

getLexemeList

protected LexemeList getLexemeList()
Description copied from class: UnifiedAutoIndentStrategy
Creates a lexeme list

Specified by:
getLexemeList in class UnifiedAutoIndentStrategy
Returns:
LexemeList
See Also:
UnifiedAutoIndentStrategy.getLexemeList()