com.aptana.ide.editor.js.formatting
Class JSCodeFormatter

java.lang.Object
  extended by com.aptana.ide.editors.unified.BaseFormatter
      extended by com.aptana.ide.editor.js.formatting.JSCodeFormatter
All Implemented Interfaces:
ICodeFormatter

public class JSCodeFormatter
extends BaseFormatter

JavaScript code formatter class

Author:
Pavel Petrochenko, Kevin Sawicki (ksawicki@aptana.com)

Constructor Summary
JSCodeFormatter()
           
 
Method Summary
 void addMarkedNode(IParseNode node, IFormattingCallback cb)
           
 void configureWriter(int level, java.lang.String indentString, int indentSize)
          Configures the underlying source writer
 java.lang.String createNestedMark()
           
 java.lang.String format(java.lang.String source, boolean isSelection, java.util.Map options, org.eclipse.core.resources.IProject project, java.lang.String separator)
           
 java.lang.String format(java.lang.String source, java.util.Map options, org.eclipse.core.resources.IProject project, java.lang.String separator)
           
 java.lang.String format(java.lang.String wholeSource, java.lang.String contentToFormat, IParseNode parseNode, LexemeList lexemes, IParseNode[] comments, JSCodeFormatterOptions options, java.lang.String separator)
          Format based on a root parse node, a list of lexemes, and a list of comments
 java.lang.String formatGivenNode(java.lang.String source, IParseNode parse, java.lang.String lineDelimeter)
           
 int getCurrentIndentationLevel()
           
 boolean handlesNested()
           
 
Methods inherited from class com.aptana.ide.editors.unified.BaseFormatter
getEndLineBreaks, getStartLineBreaks, isFormattingCorrect, isLexemeOfType, logError, normalizeCarriageReturns
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSCodeFormatter

public JSCodeFormatter()
Method Detail

addMarkedNode

public void addMarkedNode(IParseNode node,
                          IFormattingCallback cb)
Parameters:
node -
cb -

configureWriter

public void configureWriter(int level,
                            java.lang.String indentString,
                            int indentSize)
Configures the underlying source writer

Parameters:
level -
indentString -
indentSize -

format

public java.lang.String format(java.lang.String source,
                               boolean isSelection,
                               java.util.Map options,
                               org.eclipse.core.resources.IProject project,
                               java.lang.String separator)
isSelection - TODO
options - TODO
project - TODO
separator - TODO
Returns:
formatted code
See Also:
ICodeFormatter.format(java.lang.String, boolean, Map, IProject, String)

format

public java.lang.String format(java.lang.String source,
                               java.util.Map options,
                               org.eclipse.core.resources.IProject project,
                               java.lang.String separator)
Parameters:
source -
options -
project -
separator -
Returns:
- formatted string

format

public java.lang.String format(java.lang.String wholeSource,
                               java.lang.String contentToFormat,
                               IParseNode parseNode,
                               LexemeList lexemes,
                               IParseNode[] comments,
                               JSCodeFormatterOptions options,
                               java.lang.String separator)
Format based on a root parse node, a list of lexemes, and a list of comments

Parameters:
wholeSource -
contentToFormat -
parseNode -
lexemes -
comments -
options -
separator -
Returns:
- formatted string

formatGivenNode

public java.lang.String formatGivenNode(java.lang.String source,
                                        IParseNode parse,
                                        java.lang.String lineDelimeter)
Parameters:
source -
parse -
lineDelimeter -
Returns:
formatted source

createNestedMark

public java.lang.String createNestedMark()
Returns:
mark for a nested language content
See Also:
ICodeFormatter.createNestedMark()

handlesNested

public boolean handlesNested()
Returns:
true if nested languages are handled by formatter itself
See Also:
ICodeFormatter.handlesNested()

getCurrentIndentationLevel

public int getCurrentIndentationLevel()
Returns:
indent level of writer