resize(nextSection, null, distance);
}
}
} else {
if (section.nextIs(WhiteSpace.class, Instruction.class)) {
WhiteSpace whiteSpaceSection = (WhiteSpace) Section
.getNextIs__staticData(0);
whiteSpaceSection.setVirtualLength(distance);
}
}
// Go forward.
section = nextSection;
continue;
}
if (section instanceof Instruction) {
// Parameter aligning
if (section.nextIs(WhiteSpace.class)) {
if (nextSection.nextIs(Parameter.class)) {
resize(section, (WhiteSpace) nextSection,
parameterDistance + reserve);
} else {
// Comment aligning
if (nextSection.nextIs(Comment.class)) {
resize(section, (WhiteSpace) nextSection,
parameterDistance + reserve
+ commentDistance + reserve);
}
}
}
// Go forward.
section = nextSection;
continue;
}
if (section instanceof Parameter) {
// Comment aligning
final int distance = commentDistance + reserve;
if (section.nextIs(WhiteSpace.class, Comment.class)) {
resize(section, (WhiteSpace) nextSection, distance);
}
}
section = nextSection;
}
// Connect position objects to document.
section = base;
while (section != null) {
Section nextSection = section.getNextSection();
try {
document.addPosition(section.getPosition());
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
section = nextSection;
}
// Rewrite white-space sections.
section = base;
while (section != null) {
Section nextSection = section.getNextSection();
if (section instanceof WhiteSpace) {
WhiteSpace whiteSpace = (WhiteSpace) section;
if (whiteSpace.getVirtualLength() >= 0) {
int offset = whiteSpace.getOffset();
int length = whiteSpace.getLength();
String text = whiteSpace.getVirtualString();
try {
document.replace(offset, length, text);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();