@Override
  protected ContentAssistRequest computeCompletionProposals(
      String matchString,
      ITextRegion completionRegion,
      IDOMNode treeNode,
      IDOMNode xmlnode,
      CompletionProposalInvocationContext context) {
    ContentAssistRequest contentAssistRequest =
        super.computeCompletionProposals(matchString, completionRegion, treeNode, xmlnode, context);
    if (contentAssistRequest != null) return contentAssistRequest;

    String regionType = completionRegion.getType();
    if (DOMRegionContext.XML_CDATA_TEXT.equals(regionType)) {
      Node parentNode = xmlnode.getParentNode();
      Node statementNode = MybatipseXmlUtil.findEnclosingStatementNode(parentNode);
      if (statementNode == null) return null;

      int offset = context.getInvocationOffset();
      ITextViewer viewer = context.getViewer();
      contentAssistRequest =
          new ContentAssistRequest(
              xmlnode,
              parentNode,
              ContentAssistUtils.getStructuredDocumentRegion(viewer, offset),
              completionRegion,
              offset,
              0,
              matchString);
      proposeStatementText(contentAssistRequest, statementNode);
    }
    return contentAssistRequest;
  }
  @Override
  public List computeCompletionProposals(
      CompletionProposalInvocationContext context, IProgressMonitor monitor) {
    final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

    IFile file = DOMUtils.getFile(context.getDocument());
    if (file != null) {
      IProject project = file.getProject();
      if (IDETernProject.hasTernNature(project)) {

        IDocument document = context.getDocument();
        IResource resource = file;
        if (resource.getType() == IResource.FILE) {
          IFile scriptFile = (IFile) resource;

          try {

            IDETernProject ternProject = IDETernProject.getTernProject(project);

            TernCompletionsQuery query =
                new TernCompletionsQuery(
                    ternProject.getFileManager().getFileName(scriptFile),
                    context.getInvocationOffset());
            query.setTypes(true);
            query.setDocs(true);
            query.setUrls(true);
            query.setOrigins(true);
            query.setCaseInsensitive(true);
            query.setLineCharPositions(true);
            query.setExpandWordForward(false);

            int startOffset = context.getInvocationOffset();
            ternProject.request(
                query,
                scriptFile,
                document,
                startOffset,
                new JSTernCompletionCollector(proposals, startOffset));
            return proposals;

          } catch (Exception e) {
            Trace.trace(Trace.SEVERE, "Error while JSDT Tern completion.", e);
          }
        }
      }
    }
    return proposals;
  }
 @Override
 public List computeContextInformation(
     CompletionProposalInvocationContext context, IProgressMonitor monitor) {
   return Arrays.asList(
       computeContextInformation(context.getViewer(), context.getInvocationOffset()));
 }