Package com.orange.wink.util

Examples of com.orange.wink.util.FileObject


          lt.setLineStart(scope.getLineStart());
        }
      }

      if (!lt.isVirtual()) {
        FileObject fo = null;
        WinkJsFile jf = null;
        String ltSource;
        int linesSize = -1;

        try {
          if (Constants.optimDontKeepJsFile) {
            fo = FileManager.getFileObject(sourceName);
            if ((lt.getLineEnd() == -1)) {
              linesSize = fo.getLines().size();
            }
          } else {
            jf = getJsFile(sourceName);
            if ((lt.getLineEnd() == -1)) {
              linesSize = jf.getLines().size();
            }
          }

          final int lns = (lt.getLineStart() == -1) ? 1 : lt.getLineStart();
          final int lne = (lt.getLineEnd() == -1) ? linesSize : lt.getLineEnd();

          if (Constants.optimDontKeepJsFile) {
            ltSource = fo.getLinesAsString(lns, lne);
          } else {
            ltSource = jf.getLinesAsString(lns, lne);
          }

          ParserUtils.updateLiteralLines(lt, ltSource, lns);
          if (lt.getLineStart() == -1 || lt.getLineEnd() == -1) {
            throw new WinkParseException("Bad literal lines [" + lt.getNamespace() + "] identified (L:" + lt.getLineStart() + ", " + lt.getLineEnd() + ")");
          }

          String las;
          if (Constants.optimDontKeepJsFile) {
            las = fo.getLinesAsString(lt.getLineStart(), lt.getLineEnd());
          } else {
            las = jf.getLinesAsString(lt.getLineStart(), lt.getLineEnd());
          }
          ParserUtils.updateLiteralChars(lt, las);
        } catch (final IOException e) {
View Full Code Here


    if (!(o instanceof FunctionObject || o instanceof LiteralObject)) {
      return;
    }
    if (!(o instanceof GlobalObject)) {
      WinkJsFile jf;
      FileObject fo;
      String lines, source;
      try {
        if (Constants.optimDontKeepJsFile) {
          fo = FileManager.getFileObject(o.getSourceName());
          lines = fo.getLinesAsString(o.getLineStart(), o.getLineEnd());
        } else {
          jf = getJsFile(o.getSourceName());
          lines = jf.getLinesAsString(o.getLineStart(), o.getLineEnd());
        }
View Full Code Here

        final LinkedHashMap<Integer, Integer> blocks = ParserUtils.getBlockLines(fileContent.toString(), validateIdentifier);
        if (blocks.size() == 0) {
          continue;
        }

        final FileObject fo = FileManager.getFileObject(filename);

        int ptrline = 1;
        for (final Integer s : blocks.keySet()) {
          final Integer e = blocks.get(s);

          final String lines = fo.getLinesAsString(s, e);
          // System.out.println("deleteValidateProperties: " + s +
          // " -> " + e + "\n" + lines);

          int x;
          int pos = 0;
          int charStart = 0;
          int charEnd = 0;
          boolean inBlock = false;
          int lp = 0, rp = 0;
          final StringReader r = new StringReader(lines);

          while ((x = r.read()) != -1) {
            final char c = (char) x;
            if (c == '{') {
              if (lp == 0) {
                charStart = pos;
                inBlock = true;
              }
              lp++;
            } else if (inBlock && c == '}') {
              rp++;
            }
            if (inBlock) {
              if (lp == rp) {
                charEnd = pos + 1;
                break;
              }
            }
            pos++;
          }
          final String block = lines.substring(charStart, charEnd);
          // System.out.println("deleteValidateProperties: " +
          // charStart + " -> " + charEnd + "\n" + block);

          if (block.length() < replacement.length()) {
            System.err.println("WARN - cannot replace " + validateIdentifier + ", not enough space");
            continue;
          }

          contentReplaced.append(fo.getLinesAsString(ptrline, (s - 1)));
          contentReplaced.append(lines.substring(0, charStart));
          contentReplaced.append(replacement);
          contentReplaced.append(lines.substring(charEnd));
          ptrline = e + 1;
        }
        contentReplaced.append(fo.getLinesAsString(ptrline));

        FileManager.writeIntoFile(contentReplaced.toString(), filename);
      } catch (final IOException e) {
        throw new WinkBuildException(e);
      }
View Full Code Here

TOP

Related Classes of com.orange.wink.util.FileObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.