private String getReferencesSource(IFile refFile) throws CoreException {
   FileEditorInput input = new FileEditorInput(refFile);
   FileDocumentProvider provider = new FileDocumentProvider();
   provider.connect(input);
   IDocument document = provider.getDocument(input);
   return document.get();
 }
 protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
   super.doSynchronize(element, monitor);
   parseDocument(element);
 }
  private void doSaveFileResource(
      IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
      throws CoreException {
    IDocument storageDocument = null;
    String statementSQL = document.get();
    if (statementSQL == null) statementSQL = "";

    String encodedConnection = null;
    IFile fileResource = null;
    SQLEditor sqlEditor = null;

    if (encodedConnection == null) {
      // get encodedConnection from SQLEditor
      IEditorPart editor =
          PlatformUI.getWorkbench()
              .getActiveWorkbenchWindow()
              .getActivePage()
              .findEditor((IEditorInput) element);
      if ((editor != null) && (editor instanceof SQLEditor)) {
        sqlEditor = (SQLEditor) editor;
        ISQLEditorConnectionInfo connectionInfo = sqlEditor.getConnectionInfo();
        if (connectionInfo != null) encodedConnection = connectionInfo.encode();
      }
    }

    if (element instanceof IFileEditorInput) fileResource = ((IFileEditorInput) element).getFile();

    if (((encodedConnection == null) && element instanceof SQLScrapbookEditorInput)) {
      // get encodedConnection from SQLScrapbookEditorInput
      ISQLEditorConnectionInfo connectionInfo =
          ((SQLScrapbookEditorInput) element).getConnectionInfo();
      if (connectionInfo != null) encodedConnection = connectionInfo.encode();
    }

    if ((encodedConnection == null)
        && (fileResource != null)
        && !"sqlpage".equalsIgnoreCase(fileResource.getFileExtension())) {
      // get encodedConnection from PersistentProperty
      if (fileResource.exists()) {
        encodedConnection = SQLFileUtil.getEncodedConnectionInfo(fileResource);
      }
    }

    if (encodedConnection == null) encodedConnection = "";

    if ((fileResource != null) && "sqlpage".equalsIgnoreCase(fileResource.getFileExtension())) {
      // Do xml document (*.sqlpage file) with only encodedConnection and statementSQL
      Map map = new HashMap();
      map.put("encodedConnection", encodedConnection);

      String pageXML = SQLUtility.getOutputSQLPageXML(statementSQL, map);
      storageDocument = new Document(pageXML);
    }

    if ((encodedConnection != null)
        && (fileResource != null)
        && !"sqlpage".equalsIgnoreCase(fileResource.getFileExtension())) {
      // Save PersistentProperty encodedConnection for not *.sqlpage
      SQLFileUtil.setEncodedConnectionInfo(fileResource, encodedConnection);
    }

    if (storageDocument == null) storageDocument = document;

    super.doSaveDocument(monitor, element, storageDocument, overwrite);
  }