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

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


   * 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


    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

    lastTypeEndPosition = typeEndPosition;

    List<Range> extractedRanges = Lists.newArrayList();

    while (!ranges.isEmpty()) {
      Range range = ranges.getFirst();
      if (range.getStart() < typeStartPosition || range.getStart() >= typeEndPosition) {
        break;
      }
      if (range.getEnd() <= typeStartPosition || range.getEnd() > typeEndPosition) {
        break;
      }

      ranges.removeFirst();

      // Normalize range position relative to the beginning of the type that contains it.
      Range typeOffsetNormalizedRange =
          range.createNormalizedCopy(typeStartPosition, typeStartLineNumber);
      extractedRanges.add(typeOffsetNormalizedRange);
    }

    int typeBytes = typeEndPosition - typeStartPosition;
View Full Code Here

  private void skipTo(int rangeEndPosition) {
    assert lastTypeEndPosition <= rangeEndPosition : "You can only skip forward.";

    while (!ranges.isEmpty()) {
      Range range = ranges.getFirst();

      if (range.getStart() >= rangeEndPosition) {
        break;
      }
      if (range.getEnd() > rangeEndPosition) {
        break;
      }

      ranges.removeFirst();
    }
View Full Code Here

  private final List<Range> ranges = Lists.newArrayList();
  private int lines;

  public void append(JsSourceMap jsSourceMap) {
    for (Range normalizedRange : jsSourceMap.getRanges()) {
      Range offsetRange = normalizedRange.createOffsetCopy(bytes, lines);
      ranges.add(offsetRange);
    }
    bytes += jsSourceMap.getBytes();
    lines += jsSourceMap.getLines();
  }
View Full Code Here

      JsSourceMapBuilder jsSourceMapBuilder, String statement) {
    String typeName =
        statement.replace(" />", "").replace("<", "").replace(">", "").replace("\n", "");

    statementRangesBuilder.addStartPosition(sb.length());
    List<Range> ranges = Lists.newArrayList(new Range(0, statement.length(), lines, 0, lines + 1,
        statement.length(), SourceOrigin.create(0, statement.length(), 0, typeName)));
    jsSourceMapBuilder.append(new JsSourceMap(ranges, statement.length(), 1));
    sb.append(statement);
    statementRangesBuilder.addEndPosition(sb.length());
View Full Code Here

      return toReturn;
    }
    parentStack.remove(parentStack.size() - 1);

    SourceInfo info = ((JsNode) node).getSourceInfo();
    Range range = new Range(beforePosition, out.getPosition(), beforeLine, beforeColumn,
        out.getLine(), out.getColumn(), info);

    if (out.getPosition() <= beforePosition || beforeLine < 0 || out.getLine() < 0) {
      // Skip bogus entries.
      // JavaClassHierarchySetupUtil:prototypesByTypeId is pruned here. Maybe others too?
View Full Code Here

  @Override
  protected void billChildToHere() {
    if (previousRange != null && previousRange.getEnd() < out.getPosition()) {
      // Expand overlapping range.
      Range expandedRange =
          previousRange.withNewEnd(out.getPosition(), out.getLine(), out.getColumn());
      Range removedRange = ranges.removeLast();
      assert removedRange == previousRange;
      ranges.add(expandedRange);
      previousRange = expandedRange;
    }
  }
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

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.