org.eclipse.emf.codegen.merge.java.facade.ast
Class ASTJCompilationUnit.NodeCommenter.LineBreakInserter

java.lang.Object
  extended by org.eclipse.emf.codegen.merge.java.facade.ast.ASTJCompilationUnit.NodeCommenter.LineBreakInserter
Enclosing class:
ASTJCompilationUnit.NodeCommenter

protected class ASTJCompilationUnit.NodeCommenter.LineBreakInserter
extends java.lang.Object

Class that inserts extra line breaks between nodes when nodes are being commented out.

See Also:
createLineBreakBeforeNode(ITrackedNodePosition, ASTNode), createLineBreakAfterNode(ITrackedNodePosition, ASTNode)

Field Summary
protected  char[] charContent
           
 
Constructor Summary
protected ASTJCompilationUnit.NodeCommenter.LineBreakInserter()
           
 
Method Summary
protected  InsertEdit createLineBreakAfterNode(org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition nodePosition, org.eclipse.jdt.core.dom.ASTNode node)
          Creates line break at the end of the node when there is another node declared at the same line.
protected  InsertEdit createLineBreakBeforeNode(org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition nodePosition, org.eclipse.jdt.core.dom.ASTNode node)
          Creates line break at the beginning of the node when there is another node declared at the same line.
protected  java.lang.String createLineBreakString(int startOfLineOffset, boolean isCommentedOut)
          Creates line break string containing line delimiter, line comment string if isCommentedOut is true, and same indent string as the line that break is inserted at.
protected  java.lang.String createLineBreakString(java.lang.String lineDelimiter, int startOfLineOffset, boolean isCommentedOut)
          Creates line break string containing line delimiter, line comment string if isCommentedOut is true, and indent string that is the same as of the line that break is inserted at.
protected  IDocument getDocument()
           
protected  java.lang.String getIndent(int lineStart)
           
protected  boolean isWhitespace(int start, int end)
          Determines if there are only whitespace characters in the given range in char array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charContent

protected char[] charContent
Constructor Detail

ASTJCompilationUnit.NodeCommenter.LineBreakInserter

protected ASTJCompilationUnit.NodeCommenter.LineBreakInserter()
Method Detail

getDocument

protected IDocument getDocument()
Returns:
document to be used to lookup line numbers and line information

createLineBreakBeforeNode

protected InsertEdit createLineBreakBeforeNode(org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition nodePosition,
                                               org.eclipse.jdt.core.dom.ASTNode node)
                                        throws BadLocationException
Creates line break at the beginning of the node when there is another node declared at the same line. The returned edit also contains "//" after the line break - the first line of the node becomes already commented out.

Parameters:
nodePosition -
node -
Returns:
InsertEdit or null if none required
Throws:
BadLocationException

createLineBreakAfterNode

protected InsertEdit createLineBreakAfterNode(org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition nodePosition,
                                              org.eclipse.jdt.core.dom.ASTNode node)
                                       throws BadLocationException
Creates line break at the end of the node when there is another node declared at the same line.

Parameters:
nodePosition -
node -
Returns:
InsertEdit or null if none required
Throws:
BadLocationException

getIndent

protected java.lang.String getIndent(int lineStart)
Parameters:
lineStart - the first character of the line excluding CR or LF characters.
Returns:
indent of the line starting at lineStart, empty string if there is no indent or lineStart is invalid position
See Also:
IndentManipulation.isIndentChar(char)

isWhitespace

protected boolean isWhitespace(int start,
                               int end)
Determines if there are only whitespace characters in the given range in char array.

Parameters:
start -
end -
Returns:
true if only whitespace characters are between start and end
See Also:
Character.isWhitespace(char)

createLineBreakString

protected java.lang.String createLineBreakString(int startOfLineOffset,
                                                 boolean isCommentedOut)
                                          throws BadLocationException
Creates line break string containing line delimiter, line comment string if isCommentedOut is true, and same indent string as the line that break is inserted at.

Parameters:
startOfLineOffset -
isCommentedOut -
Returns:
line break string
Throws:
BadLocationException

createLineBreakString

protected java.lang.String createLineBreakString(java.lang.String lineDelimiter,
                                                 int startOfLineOffset,
                                                 boolean isCommentedOut)
Creates line break string containing line delimiter, line comment string if isCommentedOut is true, and indent string that is the same as of the line that break is inserted at.

Parameters:
lineDelimiter -
startOfLineOffset -
isCommentedOut -
Returns:
line break string

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.