private ISourceNode findSourceCoverageForElement(Object element) {
   // Do we have a coverage info for the editor input?
   ICoverageNode coverage = CoverageTools.getCoverageInfo(element);
   if (coverage instanceof ISourceNode) {
     return (ISourceNode) coverage;
   }
   return null;
 }
  public static void dumpJacoco() throws IOException {

    ExecutionDataFiles executionDataFiles = new ExecutionDataFiles();

    // final FileOutputStream localFile = new FileOutputStream(DESTFILE);
    // final ExecutionDataWriter localWriter = new ExecutionDataWriter(
    // localFile);
    int port =
        TomcatLauncherPlugin.getDefault()
            .getPreferenceStore()
            .getInt(TomcatLauncherPlugin.JacocoAgentPort);
    // Open a socket to the coverage agent:
    final Socket socket = new Socket(InetAddress.getByName(ADDRESS), port);
    final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
    final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());

    MemoryExecutionDataSource memoryExecutionDataSource = new MemoryExecutionDataSource();

    reader.setSessionInfoVisitor(memoryExecutionDataSource);
    reader.setExecutionDataVisitor(memoryExecutionDataSource);

    // reader.setSessionInfoVisitor(localWriter);
    // reader.setExecutionDataVisitor(localWriter);

    // Send a dump command and read the response:
    writer.visitDumpCommand(true, false);
    reader.read();

    socket.close();

    try {
      IExecutionDataSource source = executionDataFiles.newFile(memoryExecutionDataSource);
      ISessionManager sessionManager = CoverageTools.getSessionManager();
      ILaunchConfiguration launchconfig = null;
      CoverageSession Coveragesession =
          new CoverageSession(
              "tomcat coverage" + getNow(), TomcatBootstrap.getSrcRoots(), source, launchconfig);
      // SessionImporter importer=new
      // SessionImporter(sessionManager,executionDataFiles);
      // importer.importSession(s);
      // ICoverageSession session=
      ILaunch launch = null;
      // setIjavaProject

      sessionManager.addSession(Coveragesession, true, launch);

    } catch (CoreException e) {
      TomcatLauncherPlugin.log(e);
    }

    // localFile.close();
  }
 public void disconnect(IDocument document) {
   if (this.document != document) {
     throw new IllegalArgumentException(
         "Can't disconnect from different document."); //$NON-NLS-1$
   }
   for (final CoverageAnnotation ca : annotations) {
     document.removePosition(ca.getPosition());
   }
   if (--openConnections == 0) {
     CoverageTools.removeJavaCoverageListener(coverageListener);
     document.removeDocumentListener(documentListener);
   }
 }
 public void connect(IDocument document) {
   if (this.document != document) {
     throw new IllegalArgumentException("Can't connect to different document."); // $NON-NLS-1$
   }
   for (final CoverageAnnotation ca : annotations) {
     try {
       document.addPosition(ca.getPosition());
     } catch (BadLocationException ex) {
       EclEmmaUIPlugin.log(ex);
     }
   }
   if (openConnections++ == 0) {
     CoverageTools.addJavaCoverageListener(coverageListener);
     document.addDocumentListener(documentListener);
   }
 }