Package org.eclipse.xtext

Examples of org.eclipse.xtext.AbstractRule


    boolean _notEquals = (!Objects.equal(_version, null));
    if (_notEquals) {
      final List<INode> nodes = NodeModelUtils.findNodesForFeature(iu, TargetPlatformPackage.Literals.IU__VERSION);
      INode _head = IterableExtensions.<INode>head(nodes);
      EObject _grammarElement = _head.getGrammarElement();
      AbstractRule _rule = ((RuleCall) _grammarElement).getRule();
      String _name = _rule.getName();
      boolean _equals = "STRING".equals(_name);
      if (_equals) {
        this.warning("Usage of strings is deprecated for version range. You should remove the quotes.", iu,
          TargetPlatformPackage.Literals.IU__VERSION,
          TargetPlatformValidator.DEPRECATE__STRINGS_ON_IU_VERSION);
View Full Code Here


  public boolean isString(INode node) {
    EObject grammarElement = node.getGrammarElement();
    if (!(grammarElement instanceof RuleCall)) {
      return false;
    }
    AbstractRule rule = ((RuleCall) grammarElement).getRule();
    if (!(rule instanceof TerminalRule)) {
      return false;
    }
    TerminalRule terminalRule = (TerminalRule) rule;
    return "STRING".equals(terminalRule.getName());
View Full Code Here

    final EObject grammarElement = _grammarElement;
    boolean _matched = false;
    if (!_matched) {
      if (grammarElement instanceof RuleCall) {
        _matched=true;
        AbstractRule _rule = ((RuleCall)grammarElement).getRule();
        TerminalRule _tEXTRule = this.grammarAccess.getTEXTRule();
        _switchResult = Objects.equal(_rule, _tEXTRule);
      }
    }
    if (!_matched) {
View Full Code Here

   * USE THIS
   *
   * @since 2.1
   */
  protected boolean isElementOfDatatypeRule(final EObject grammarElement) {
    final AbstractRule rule = EcoreUtil2.getContainerOfType(grammarElement, AbstractRule.class);
    return GrammarUtil.isDatatypeRule(rule);
  }
View Full Code Here

  protected void emitHiddenTokens(List<INode> hiddens /* Set<INode> comments, */) {
    if(hiddens == null)
      return;
    boolean lastNonWhitespace = true;
    AbstractRule ws = hiddenTokenHelper.getWhitespaceRuleFor(null, "");
    INode prevCommentNode = null;
    for(INode node : hiddens)
      if(tokenUtil.isCommentNode(node)) {
        if(lastNonWhitespace) {
          String wsString = commentReconcilement != null
View Full Code Here

  protected List<INode> getHiddenNodesBetween(INode from, INode to) {
    List<INode> result = getHiddenNodesBetween2(from, to);
    result = reconcileComments(result, lastNodes[1], from, to);
    if(result == null) {
      AbstractRule ws = hiddenTokenHelper.getWhitespaceRuleFor(null, "");
      // only emit hidden whitespace, or visible whitespace where this is overridden using
      // isImpliedWhitespace
      // boolean implied = currentHidden != null && currentHidden.contains(ws);
      boolean impliedFrom = hiddenInLastNode != null && hiddenInLastNode.contains(ws);
      boolean impliedTo = currentHidden != null && currentHidden.contains(ws);
View Full Code Here

  protected void pop() {
    RuleCall top = stack.remove(stack.size() - 1);

    // if the rule call on top defines hidden, it pushed on the hidden stack, and state needs to
    // be restored
    final AbstractRule r = top.getRule();
    if(r instanceof ParserRule && ((ParserRule) r).isDefinesHiddenTokens()) {
      currentHidden = hiddenStack.remove(hiddenStack.size() - 1);
    }
  }
View Full Code Here

  protected void push(RuleCall rc) {
    stack.add(rc);

    // if rule defines hidden, remember previous hidden, and set the new as current
    final AbstractRule r = rc.getRule();
    if(r instanceof ParserRule && ((ParserRule) r).isDefinesHiddenTokens()) {
      hiddenStack.add(currentHidden);
      currentHidden = ((ParserRule) r).getHiddenTokens();
    }
  }
View Full Code Here

    private static final ICommentFormatterAdvice defaultAdvice = new ICommentFormatterAdvice.DefaultCommentAdvice();

    @Override
    public CommentType classify(EObject grammarElement) {
      if(grammarElement != null && grammarElement instanceof AbstractRule) {
        AbstractRule rule = (AbstractRule) grammarElement;

        if("ML_COMMENT".equals(rule.getName()))
          return CommentType.Multiline;
        if("SL_COMMENT".equals(rule.getName()))
          return CommentType.SingleLine;
      }
      return CommentType.Unknown;

    }
View Full Code Here

  public void highlight(INode o, IHighlightedPositionAcceptor acceptor) {
    // what in grammar created this node
    EObject gElem = o.getGrammarElement();

    ruleCall: if(gElem instanceof RuleCall) {
      AbstractRule rule = ((RuleCall) gElem).getRule();
      // String ruleName = ((RuleCall) gElem).getRule().getName();

      if(rule == null)
        break ruleCall;
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.AbstractRule

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.