All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.emf.codegen.jet.JETCommentItem Maven / Gradle / Ivy

/**
 * Copyright (c) 2019 Eclipse contributors and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 */
package org.eclipse.emf.codegen.jet;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * @since 2.19
 */
public class JETCommentItem extends JETRootItem
{
  private List lineItems;

  JETCommentItem(JETMark start, JETMark stop)
  {
    super(start, stop);
  }

  void addLineItem(int start, int stop)
  {
    JETMark commentStart = getStart();

    JETReader reader = commentStart.reader;
    JETMark mark = reader.mark();
    reader.reset(commentStart);
    int index = 0;
    while (index < start)
    {
      reader.nextChar();
      ++index;
    }

    JETMark offsetStart = reader.mark();

    while (index < stop)
    {
      reader.nextChar();
      ++index;
    }

    JETMark offsetEnd = reader.mark();
    reader.reset(mark);

    if (lineItems == null)
    {
      lineItems = new ArrayList();
    }

    JETSubItem lineItem = new JETSubItem(offsetStart, offsetEnd);
    lineItem.setParent(this);
    lineItems.add(lineItem);
  }

  public List getLineItems()
  {
    return lineItems == null ? Collections. emptyList() : Collections.unmodifiableList(lineItems);

  }

  @Override
  public List getChildren()
  {
    return getLineItems();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy