}
public static List<ICompletionProposal> computeCloseTagProposals(IDocument document, int offset) throws BadLocationException {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
IRegion region = document.getPartition(offset);
// fallback to current edit line if partition has length 0 - for e.g. end of document
if (region.getLength() == 0) {
region = document.getLineInformationOfOffset(offset);
}
// search backwards for a tmltag with body which might need to be closed
int pos = offset - 1;
while (pos >= 0) {
ITypedRegion previousRegion = document.getPartition(pos);
if (previousRegion.getType().equals(TMLPartitionScanner.TML_TAG_START) && !isTMLPartitionClosed(previousRegion, document)) {
String alreadyTyped = document.get(region.getOffset(), offset-region.getOffset());
if (alreadyTyped.contains("\n")) {
alreadyTyped = alreadyTyped.substring(alreadyTyped.lastIndexOf("\n"));
}
int posEnd = alreadyTyped.lastIndexOf(">");
if (posEnd != -1) {
alreadyTyped = alreadyTyped.substring(posEnd + 1);
}
posEnd = alreadyTyped.lastIndexOf("<");
if (posEnd != -1) {
alreadyTyped = alreadyTyped.substring(posEnd);
} else {
alreadyTyped = "";
}
String tagName = TMLPartitionScanner.determineTMLTagName(previousRegion, document);
if (document.getLineOfOffset(offset) == document.getLineOfOffset(region.getOffset())) {
// completion in same line
int start = previousRegion.getOffset() + previousRegion.getLength();
int end = offset;
String typedBody = document.get(start, end - start);
if (typedBody.trim().equals("")) {