

package com.equadon.intellij.mips.lang.psi.mixins;

import com.equadon.intellij.mips.lang.psi.MipsElementTypes;
import com.equadon.intellij.mips.lang.psi.MipsNumberLiteral;
import com.equadon.intellij.mips.lang.psi.impl.MipsNamedElementImpl;
import com.intellij.lang.ASTNode;

import org.jetbrains.annotations.NotNull;

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

public class MipsNumberRangeMixin extends MipsNamedElementImpl {
  public MipsNumberRangeMixin(@NotNull ASTNode node) {
    super(node);
  }

  public MipsNumberLiteral getRangeStart() {
    return findChildByType(MipsElementTypes.NUMBER_LITERAL);
  }

  public MipsNumberLiteral getRangeEnd() {
    List<MipsNumberLiteral> numbers = new ArrayList<>(findChildrenByType(MipsElementTypes.NUMBER_LITERAL));

    return (numbers.size() == 2) ? numbers.get(1) : null;
  }
}
