示例#1
0
  /**
   * Refreshes the view after a file has been saved.
   *
   * @param root root directory
   * @param ctx database context
   * @throws InterruptedException interruption
   */
  void parse(final IOFile root, final Context ctx) throws InterruptedException {
    final long id = ++parseId;
    final HashSet<String> parsed = new HashSet<>();
    final TreeMap<String, InputInfo> errs = new TreeMap<>();

    // collect files to be parsed
    final ProjectCache pc = cache(root);
    final StringList mods = new StringList(), lmods = new StringList();
    for (final String path : pc) {
      final IOFile file = new IOFile(path);
      if (file.hasSuffix(IO.XQSUFFIXES)) (file.hasSuffix(IO.XQMSUFFIX) ? lmods : mods).add(path);
    }
    mods.add(lmods);

    // parse modules
    for (final String path : mods) {
      if (id != parseId) throw new InterruptedException();
      if (parsed.contains(path)) continue;

      final IOFile file = new IOFile(path);
      try (final TextInput ti = new TextInput(file)) {
        // parse query
        try (final QueryContext qc = new QueryContext(ctx)) {
          final String input = ti.cache().toString();
          final boolean lib = QueryProcessor.isLibrary(input);
          qc.parse(input, lib, path, null);
          // parsing was successful: remember path
          parsed.add(path);
          for (final byte[] mod : qc.modParsed) parsed.add(Token.string(mod));
        } catch (final QueryException ex) {
          // parsing failed: remember path
          final InputInfo ii = ex.info();
          errs.put(path, ii);
          parsed.add(ii.path());
        }
      } catch (final IOException ex) {
        // file may not be accessible
        Util.debug(ex);
      }
    }
    errors = errs;
  }
示例#2
0
文件: Util.java 项目: ngrstad/basex
 /**
  * Returns a string and replaces all % characters by the specified extensions (see {@link
  * TokenBuilder#addExt} for details).
  *
  * @param str string to be extended
  * @param ext text text extensions
  * @return extended string
  */
 public static String info(final Object str, final Object... ext) {
   return Token.string(inf(str, ext));
 }
示例#3
0
文件: Util.java 项目: ngrstad/basex
 /**
  * Prints a string to standard output, followed by a newline.
  *
  * @param str output string
  * @param ext text optional extensions
  */
 public static void outln(final Object str, final Object... ext) {
   out((str instanceof byte[] ? Token.string((byte[]) str) : str) + NL, ext);
 }