Exemplo n.º 1
0
 public static void load(Collection<FileDesc> files, Path root, int blocSize, Pattern pattern)
     throws IOException {
   root = root.toAbsolutePath().normalize();
   Visitor visitor = new Visitor(root, blocSize, pattern);
   Files.walkFileTree(root, visitor);
   for (Future<FileDesc> future : visitor.futures()) {
     try {
       files.add(future.get());
     } catch (Exception e) {
       log.error("", e);
     }
   }
 }
Exemplo n.º 2
0
 /** Visit each predecessor of this node applying the given visitor. Breadth first. */
 private <Alpha, Beta> void doVisitPredecessors(
     Visitor<Alpha, Beta> visitor, Alpha arg1, Beta arg2, Set<GraphNode> seen) {
   if (seen.add(this)) {
     Collection<GraphNode> allKill = null;
     for (Iterator<GraphNode> i = pred.iterator(); i.hasNext(); ) {
       GraphNode pred = i.next();
       List<GraphNode> kill = visitor.visit(pred, this, arg1, arg2);
       if (kill != null) {
         if (allKill == null) allKill = new ArrayList<GraphNode>();
         allKill.addAll(kill);
       }
     }
     if (allKill != null) pred.removeAll(allKill);
     for (Iterator<GraphNode> i = pred.iterator(); i.hasNext(); ) {
       GraphNode pred = i.next();
       pred.doVisitPredecessors(visitor, arg1, arg2, seen);
     }
   }
 }
Exemplo n.º 3
0
 public Context convert(
     WhereClause whereClause,
     MapperService mapperService,
     IndexFieldDataService indexFieldDataService,
     IndexCache indexCache)
     throws UnsupportedFeatureException {
   Context ctx = new Context(inputSymbolVisitor, mapperService, indexFieldDataService, indexCache);
   if (whereClause.noMatch()) {
     ctx.query = Queries.newMatchNoDocsQuery();
   } else if (!whereClause.hasQuery()) {
     ctx.query = Queries.newMatchAllQuery();
   } else {
     ctx.query = VISITOR.process(whereClause.query(), ctx);
   }
   if (LOGGER.isTraceEnabled()) {
     if (whereClause.hasQuery()) {
       LOGGER.trace(
           "WHERE CLAUSE [{}] -> LUCENE QUERY [{}] ",
           SymbolFormatter.format(whereClause.query()),
           ctx.query);
     }
   }
   return ctx;
 }
 public void accept(Visitor visitor) {
   visitor.visitLocalVariableTable_attribute(this);
 }
 public <ARG, RET, EXN extends Exception> RET accept(Visitor<ARG, RET, EXN> vis, ARG arg)
     throws EXN {
   return vis.visit((PostExpArgs) this, arg);
 }
  /**
   * Creates a locale specific properties file within the fragment project based on the content of
   * the host plug-in's properties file.
   *
   * @param fragmentProject
   * @param locale
   * @throws CoreException
   * @throws IOException
   */
  private void createLocaleSpecificPropertiesFile(
      final IProject fragmentProject, IPluginModelBase plugin, final Locale locale)
      throws CoreException, IOException {
    final IFolder localeResourceFolder =
        fragmentProject.getFolder(RESOURCE_FOLDER_PARENT).getFolder(locale.toString());

    // Case 1: External plug-in
    if (plugin instanceof ExternalPluginModelBase) {
      final String installLocation = plugin.getInstallLocation();
      // Case 1a: External plug-in is a jar file
      if (new File(installLocation).isFile()) {
        ZipFile zf = new ZipFile(installLocation);
        for (Enumeration e = zf.entries(); e.hasMoreElements(); ) {
          worked();

          ZipEntry zfe = (ZipEntry) e.nextElement();
          String name = zfe.getName();

          String[] segments = name.split(SLASH);
          IPath path = Path.fromPortableString(join(SLASH, segments, 0, segments.length - 1));
          String resourceName = segments[segments.length - 1];
          String localizedResourceName = localeSpecificName(resourceName, locale);
          if (propertiesFilter.include(name)) {

            createParents(fragmentProject, path);
            IFile file = fragmentProject.getFile(path.append(localizedResourceName));
            InputStream is = zf.getInputStream(zfe);
            file.create(is, false, getProgressMonitor());
          } else if (resourceFilter.include(name)) {
            IPath target = localeResourceFolder.getFullPath().append(path).append(resourceName);
            createParents(fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
            IFile file = fragmentProject.getFile(target.removeFirstSegments(1));
            file.create(zf.getInputStream(zfe), false, getProgressMonitor());
          }
        }
      }
      // Case 1b: External plug-in has a folder structure
      else {
        Visitor visitor =
            new Visitor() {
              public void visit(File file) throws CoreException, FileNotFoundException {
                worked();

                String relativePath =
                    file.getAbsolutePath()
                        .substring(installLocation.length())
                        .replaceAll(File.separator, SLASH);
                String[] segments = relativePath.split(SLASH);
                IPath path = Path.fromPortableString(join(SLASH, segments, 0, segments.length - 1));
                String resourceName = segments[segments.length - 1];
                String localizedResourceName = localeSpecificName(resourceName, locale);

                if (propertiesFilter.include(
                    relativePath + (file.isDirectory() ? SLASH : EMPTY_STRING))) {
                  createParents(fragmentProject, path);
                  IFile iFile = fragmentProject.getFile(path.append(localizedResourceName));
                  iFile.create(new FileInputStream(file), false, getProgressMonitor());
                } else if (resourceFilter.include(
                    relativePath + (file.isDirectory() ? SLASH : EMPTY_STRING))) {
                  IPath target = localeResourceFolder.getFullPath().append(relativePath);
                  createParents(
                      fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
                  IFile iFile = fragmentProject.getFile(target.removeFirstSegments(1));
                  iFile.create(new FileInputStream(file), false, getProgressMonitor());
                }

                if (file.isDirectory()) {
                  File[] children = file.listFiles();
                  for (int i = 0; i < children.length; i++) {
                    visit(children[i]);
                  }
                }
              }
            };

        visitor.visit(new File(installLocation));
      }
    }
    // Case 2: Workspace plug-in
    else {
      final IProject project = plugin.getUnderlyingResource().getProject();

      project.accept(
          new IResourceVisitor() {
            public boolean visit(IResource resource) throws CoreException {
              worked();

              IPath parent = resource.getFullPath().removeLastSegments(1).removeFirstSegments(1);
              if (propertiesFilter.include(resource)) {
                String segment = localeSpecificName(resource.getFullPath().lastSegment(), locale);
                IPath fragmentResource =
                    fragmentProject.getFullPath().append(parent).append(segment);

                createParents(fragmentProject, parent);
                resource.copy(fragmentResource, true, getProgressMonitor());
              } else if (resourceFilter.include(resource)) {
                IPath target =
                    localeResourceFolder
                        .getFullPath()
                        .append(parent)
                        .append(resource.getFullPath().lastSegment());
                createParents(fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
                resource.copy(target, true, getProgressMonitor());
              }
              return true;
            }
          });
    }
  }
Exemplo n.º 7
0
 public void accept(Visitor visitor) {
   visitor.visitGroup();
 }
Exemplo n.º 8
0
 @Override
 public void accept(Visitor visitor) {
   visitor.visit(this);
 }
Exemplo n.º 9
0
 /** Visit each predecessor of this node applying the given visitor. */
 public <Alpha, Beta> void visitPredecessors(Visitor<Alpha, Beta> visitor, Alpha arg1, Beta arg2) {
   List<GraphNode> kill = visitor.visit(this, null, arg1, arg2);
   if (kill != null) pred.removeAll(kill);
   doVisitPredecessors(visitor, arg1, arg2, new HashSet<GraphNode>());
 }
Exemplo n.º 10
0
  public void visit(Visitor v) {

    v.action(this);
  }
Exemplo n.º 11
0
 public void accept(Visitor visitor) {
   visitor.visitConElementB(this);
 }
Exemplo n.º 12
0
 /**
  * Visitor method
  *
  * @param v visitor object
  * @return result of visiting this node
  * @see visitor.Visitor
  */
 public Object accept(Visitor v) {
   return v.visit(this);
 }
 public <ARG, RET, EXN extends Exception> RET accept(Visitor<ARG, RET, EXN> vis, ARG arg)
     throws EXN {
   return vis.visit((DotMethodCallExp) this, arg);
 }
 public <ARG, RET, EXN extends Exception> RET accept(Visitor<ARG, RET, EXN> vis, ARG arg)
     throws EXN {
   return vis.visit((ClsPatDef) this, arg);
 }
Exemplo n.º 15
0
 /**
  * Allows a visitor to traverse the tree
  *
  * @param visitor the visitor to accept
  */
 public <T> T acceptVisitor(Visitor<T> visitor) {
   return visitor.visit(this);
 }
Exemplo n.º 16
0
 public void acceptWithoutResponse(Visitor visitor) {
   visitor.visit(this);
 }