* org.eclipse.core.runtime.IProgressMonitor)
*/
public List computeCompletionProposals(
CompletionProposalInvocationContext context,
IProgressMonitor monitor) {
ITextViewer textViewer = context.getViewer();
int documentPosition = context.getInvocationOffset();
setErrorMessage(null);
fTextViewer = textViewer;
IndexedRegion treeNode = null;
try{
treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition);
}catch(Exception e){}
Node node = (Node) treeNode;
while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
&& (node.getParentNode() != null)) {
node = node.getParentNode();
}
IDOMNode xmlnode = (IDOMNode) node;
ContentAssistRequest contentAssistRequest = null;
IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
ITextRegion completionRegion = getCompletionRegion(documentPosition,
node);
String matchString = getMatchString(sdRegion, completionRegion,
documentPosition);
// Handle empty Documents
if (completionRegion == null) {
if (((treeNode == null) || (((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE))
&& (completionRegion == null)
&& ((xmlnode == null) || (xmlnode.getChildNodes() == null) || (xmlnode
.getChildNodes().getLength() == 0))) {
IStructuredModel sModel = null;
try {
if (textViewer.getDocument() instanceof IStructuredDocument) {
sModel = StructuredModelManager.getModelManager()
.getModelForRead(
(IStructuredDocument) textViewer
.getDocument());
}
if (sModel != null) {
IDOMDocument docNode = ((IDOMModel) sModel)
.getDocument();