コード例 #1
0
 public static ISourceLocation findLocation(IPackageFragmentRoot root) throws JavaModelException {
   if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
     IPath path = EclEmmaCorePlugin.getAbsolutePath(root.getPath());
     return new SourceLocation(path, new Path(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH));
   } else {
     IPath path = root.getSourceAttachmentPath();
     if (path != null) {
       path = EclEmmaCorePlugin.getAbsolutePath(path);
       return new SourceLocation(path, root.getSourceAttachmentRootPath());
     } else {
       return null;
     }
   }
 }
コード例 #2
0
 public void stop() {
   writer = null;
   try {
     serverSocket.close();
   } catch (IOException e) {
     EclEmmaCorePlugin.getInstance()
         .getLog()
         .log(EclEmmaStatus.AGENTSERVER_STOP_ERROR.getStatus(e));
   }
   cancel();
 }
コード例 #3
0
 public void extract(IProgressMonitor monitor) throws CoreException {
   if (isArchive()) {
     monitor.beginTask(NLS.bind(CoreMessages.ExtractingSourceArchive_task, path), 1);
     String prefix = rootpath == null ? "" : rootpath.toString(); // $NON-NLS-1$
     byte[] buffer = new byte[0x1000];
     IPath srcfolder = EclEmmaCorePlugin.getInstance().getStateFiles().getSourceFolder(path);
     if (!srcfolder.toFile().exists()) {
       try {
         ZipInputStream zip = new ZipInputStream(new FileInputStream(path.toFile()));
         while (true) {
           ZipEntry entry = zip.getNextEntry();
           if (entry == null) break;
           if (!entry.isDirectory()
               && entry.getName().startsWith(prefix)
               && entry.getName().endsWith(JAVA_EXT)) {
             IPath path = srcfolder.append(entry.getName().substring(prefix.length()));
             path.removeLastSegments(1).toFile().mkdirs();
             OutputStream out = new FileOutputStream(path.toFile());
             int len;
             while ((len = zip.read(buffer)) != -1) {
               out.write(buffer, 0, len);
             }
             out.close();
           }
           zip.closeEntry();
         }
         zip.close();
       } catch (IOException e) {
         throw new CoreException(EclEmmaStatus.SOURCE_EXTRACTION_ERROR.getStatus(path, e));
       }
     }
     path = srcfolder;
     rootpath = null;
   }
   monitor.done();
 }