public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
setErrorMessage(null);
IDocument document = viewer.getDocument();
try {
IRegion region = document.getPartition(offset);
// search backwards to document start or partition of type TML - this is neccessary bc. our current script may contain TMLscript comments
ITypedRegion prevPartition = null;
int previousOffset = region.getOffset() - 1;
while (previousOffset > 0) {
prevPartition = document.getPartition(previousOffset);
if (prevPartition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
break;
}
previousOffset = prevPartition.getOffset() - 1;
}
if (prevPartition != null) {
region = new Region(previousOffset+1, region.getOffset() - previousOffset + region.getLength() - 1);
}
VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(Plugin.getDefault().getActiveFile());
TMLScriptRegion tmlScriptRegion = TMLScriptRegion.parse(region, document, offset, versionCompliance);
System.out.println(tmlScriptRegion.toString());