Package com.google.gwt.core.ext.soyc

Examples of com.google.gwt.core.ext.soyc.Range


        int permutedStart = statementRanges.start(j);
        int permutedEnd = statementRanges.end(j);
        int originalStart = originalStatementRanges.start(reorderedIndices[j]);
        int originalEnd = originalStatementRanges.end(reorderedIndices[j]);

        statementShifts.put(new Range(originalStart, originalEnd),
            new Range(permutedStart, permutedEnd));
      }

      Range[] oldStatementRanges = statementShifts.keySet().toArray(new Range[0]);
      Arrays.sort(oldStatementRanges, Range.SOURCE_ORDER_COMPARATOR);

      List<Range> oldExpressionRanges = Lists.newArrayList(sourceInfoMap.getRanges());
      Collections.sort(oldExpressionRanges, Range.SOURCE_ORDER_COMPARATOR);

      // iterate over expression ranges and shift
      List<Range> updatedRanges = Lists.newArrayList();
      Range entireProgram =
          new Range(0, oldStatementRanges[oldStatementRanges.length - 1].getEnd());
      for (int i = 0, j = 0; j < oldExpressionRanges.size(); j++) {
        Range oldExpression = oldExpressionRanges.get(j);
        if (oldExpression.equals(entireProgram)) {
          updatedRanges.add(oldExpression);
          continue;
        }

        Range oldStatement = oldStatementRanges[i];
        Range newStatement = statementShifts.get(oldStatement);
        int shift = newStatement.getStart() - oldStatement.getStart();

        Range oldExpressionRange = oldExpressionRanges.get(j);
        Range newExpressionRange = new Range(oldExpressionRange.getStart() + shift,
            oldExpressionRange.getEnd() + shift, oldExpressionRange.getSourceInfo());
        updatedRanges.add(newExpressionRange);
      }

      sourceInfoMap =
View Full Code Here


    boolean addEntry = node instanceof HasSourceInfo;
    int start = addEntry ? out.getPosition() : 0;
    T toReturn = super.doAccept(node);
    if (addEntry) {
      SourceInfo info = ((HasSourceInfo) node).getSourceInfo();
      sourceInfoMap.put(new Range(start, out.getPosition()), info);
    }
    return toReturn;
  }
View Full Code Here

   * process.
   */
  private void popAndRecord(Stack<RangeInfo> dependencyScope, int fragment)
      throws IOException {
    RangeInfo rangeInfo = dependencyScope.pop();
    Range toStore = rangeInfo.range;

    /*
     * Make a new Range for the gap between the popped Range and whatever we
     * last stored.
     */
    if (lastEnd < toStore.getStart()) {
      Range newRange = new Range(lastEnd, toStore.getStart());
      assert !dependencyScope.isEmpty();

      SourceInfo gapInfo = dependencyScope.peek().info;
      recordStory(gapInfo, fragment, newRange.length(), newRange);

      lastEnd += newRange.length();
    }

    /*
     * Store as much of the current Range as we haven't previously stored. The
     * Max.max() is there to take care of the tail end of Ranges that have had a
     * sub-range previously stored.
     */
    if (lastEnd < toStore.getEnd()) {
      Range newRange = new Range(Math.max(lastEnd, toStore.getStart()),
          toStore.getEnd());
      recordStory(rangeInfo.info, fragment, newRange.length(), newRange);
      lastEnd += newRange.length();
    }
  }
View Full Code Here

        int permutedStart = statementRanges.start(j);
        int permutedEnd = statementRanges.end(j);
        int originalStart = originalStatementRanges.start(reorderedIndices[j]);
        int originalEnd = originalStatementRanges.end(reorderedIndices[j]);

        statementShifts.put(new Range(originalStart, originalEnd),
            new Range(permutedStart, permutedEnd));
      }

      Range[] oldStatementRanges = statementShifts.keySet().toArray(new Range[0]);
      Arrays.sort(oldStatementRanges, Range.SOURCE_ORDER_COMPARATOR);

      Range[] oldExpressionRanges = sourceInfoMap.keySet().toArray(new Range[0]);
      Arrays.sort(oldExpressionRanges, Range.SOURCE_ORDER_COMPARATOR);


      // iterate over expression ranges and shift
      Map<Range, SourceInfo> updatedInfoMap = new HashMap<Range, SourceInfo>();
      Range entireProgram =
        new Range(0, oldStatementRanges[oldStatementRanges.length - 1].getEnd());
      for (int i = 0, j = 0; j < oldExpressionRanges.length; j++) {
        Range oldExpression = oldExpressionRanges[j];
        if (oldExpression.equals(entireProgram)) {
          updatedInfoMap.put(oldExpression, sourceInfoMap.get(oldExpression));
          continue;
        }

        if (!oldStatementRanges[i].contains(oldExpressionRanges[j])) {
          // expression should fall in the next statement
          i++;
          assert oldStatementRanges[i].contains(oldExpressionRanges[j]);
        }

        Range oldStatement = oldStatementRanges[i];
        Range newStatement = statementShifts.get(oldStatement);
        int shift = newStatement.getStart() - oldStatement.getStart();

        Range oldExpressionRange = oldExpressionRanges[j];
        Range newExpressionRange = new Range(oldExpressionRange.getStart() + shift,
            oldExpressionRange.getEnd() + shift);
        updatedInfoMap.put(newExpressionRange, sourceInfoMap.get(oldExpressionRange));
      }

      sourceInfoMap = new JsSourceMap(updatedInfoMap);
View Full Code Here

    // Write some JavaScript (changing the position).
    T toReturn = super.generateAndBill(node, nameToBillTo);

    if (out.getPosition() > beforePosition) {
      // Something was printed, so bill it.
      Range javaScriptRange = new Range(beforePosition, out.getPosition(),
        beforeLine, beforeColumn, out.getLine(), out.getColumn());
      SourceInfo target = ((HasSourceInfo) node).getSourceInfo();
      sourceInfoMap.put(javaScriptRange, target);

      previousChildKey = javaScriptRange; // Report this child to its parent.
View Full Code Here

  @Override
  protected void billChildToHere() {
    if (previousChildKey != null && previousChildKey.getEnd() < out.getPosition()) {
      SourceInfo value = sourceInfoMap.get(previousChildKey);
      Range newKey = previousChildKey.withNewEnd(out.getPosition(), out.getLine(),
          out.getColumn());
      sourceInfoMap.remove(previousChildKey);
      sourceInfoMap.put(newKey, value);
      previousChildKey = newKey;
    }
View Full Code Here

   * the right length, possibly sub-dividing the super-enclosing Range in the
   * process.
   */
  private void popAndRecord(Stack<RangeInfo> dependencyScope, int fragment) throws IOException {
    RangeInfo rangeInfo = dependencyScope.pop();
    Range toStore = rangeInfo.range;

    /*
     * Make a new Range for the gap between the popped Range and whatever we
     * last stored.
     */
    if (lastEnd < toStore.getStart()) {
      Range newRange = new Range(lastEnd, toStore.getStart());
      assert !dependencyScope.isEmpty();

      SourceInfo gapInfo = dependencyScope.peek().info;
      recordStory(gapInfo, fragment, newRange.length(), newRange);

      lastEnd += newRange.length();
    }

    /*
     * Store as much of the current Range as we haven't previously stored. The
     * Max.max() is there to take care of the tail end of Ranges that have had a
     * sub-range previously stored.
     */
    if (lastEnd < toStore.getEnd()) {
      Range newRange = new Range(Math.max(lastEnd, toStore.getStart()), toStore.getEnd());
      recordStory(rangeInfo.info, fragment, newRange.length(), newRange);
      lastEnd += newRange.length();
    }
  }
View Full Code Here

   * process.
   */
  private void popAndRecord(Stack<RangeInfo> dependencyScope, int fragment)
      throws IOException {
    RangeInfo rangeInfo = dependencyScope.pop();
    Range toStore = rangeInfo.range;

    /*
     * Make a new Range for the gap between the popped Range and whatever we
     * last stored.
     */
    if (lastEnd < toStore.getStart()) {
      Range newRange = new Range(lastEnd, toStore.getStart());
      assert !dependencyScope.isEmpty();

      SourceInfo gapInfo = dependencyScope.peek().info;
      recordStory(gapInfo, fragment, newRange.length(), newRange, builder);

      lastEnd += newRange.length();
    }

    /*
     * Store as much of the current Range as we haven't previously stored. The
     * Max.max() is there to take care of the tail end of Ranges that have had a
     * sub-range previously stored.
     */
    if (lastEnd < toStore.getEnd()) {
      Range newRange = new Range(Math.max(lastEnd, toStore.getStart()),
          toStore.getEnd());
      recordStory(rangeInfo.info, fragment, newRange.length(), newRange, builder);
      lastEnd += newRange.length();
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.soyc.Range

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.