private void handleEnterBetweenTags(IDocument doc,
DocumentCommand docCommand) {
if (doc instanceof ICFDocument
&& this.isUseSmartIndent()) {
ICFDocument cfd = (ICFDocument) doc;
CFEPartitioner partitioner = (CFEPartitioner) cfd
.getDocumentPartitioner();
CFEPartition prevPartition = partitioner
.getPreviousPartition(docCommand.offset);
CFEPartition nextPartition = null;
if (prevPartition != null) {
nextPartition = partitioner
.getNextPartition(prevPartition.offset);
}
//System.out.println("Command at offset: " + docCommand.offset);
//System.out.println(prevPartition);
//System.out.println(nextPartition);
if (nextPartition != null
&& prevPartition != null) {
if (prevPartition.getType().endsWith("start_tag_end")) {
try {
boolean doIndent = true;
if (nextPartition.getType().endsWith("end_tag")
&& nextPartition.offset == docCommand.offset) {
doIndent = false;
}
if (doc.getLineOfOffset(prevPartition.offset) != doc
.getLineOfOffset(docCommand.offset)) {
doIndent = false;
}
if (doIndent) {
CFEPartition closer = partitioner
.getCloser(prevPartition);
if (closer != null) {
String prevLineWhitespace = getPrevLineWhiteSpace(
doc, docCommand.offset);
docCommand.text += indentString
+ guessNewIndentWhitespace(prevLineWhitespace);
return;
}
}
} catch (BadLocationException e) {
//
}
}
if (nextPartition.getType().endsWith("end_tag")
&& nextPartition.offset == docCommand.offset) {
try {
CFEPartition opener = partitioner
.getOpener(nextPartition);
if (opener == null) {
return;