Package com.github.jknack.antlr4ide.lang

Examples of com.github.jknack.antlr4ide.lang.RuleRef


    Grammar grammar = createMock(Grammar.class);
    ParserRule rule1 = createMock(ParserRule.class);
    Return returns = createMock(Return.class);
    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    RuleRef ruleRef = createMock(RuleRef.class);
    ParserRule expr = createMock(ParserRule.class);
    ActionElement actionElement = createMock(ActionElement.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(null);

    ruleBodyList.add(ruleRef);
    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(ruleRef.getReference()).andReturn(expr);

    expect(expr.getName()).andReturn("expr");

    expect(actionElement.getBody()).andReturn("{int v = $expr.v;}");
View Full Code Here


  @Test
  public void undefinedParserRule() {
    ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
    ParserRule rule = createMock(ParserRule.class);
    RuleRef ref = createMock(RuleRef.class);

    expect(diagnosticContext.getLinkText()).andReturn("some");
    expect(diagnosticContext.getContext()).andReturn(ref);

    expect(ref.eContainer()).andReturn(null);
    expect(ref.eContainer()).andReturn(rule);

    Object[] mocks = {diagnosticContext, ref, rule };

    replay(mocks);
View Full Code Here

  @Test
  public void undefinedLexerRule() {
    ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
    LexerRule rule = createMock(LexerRule.class);
    RuleRef ref = createMock(RuleRef.class);

    expect(diagnosticContext.getLinkText()).andReturn("ID");
    expect(diagnosticContext.getContext()).andReturn(ref);

    expect(ref.eContainer()).andReturn(null);
    expect(ref.eContainer()).andReturn(rule);

    Object[] mocks = {diagnosticContext, ref, rule };

    replay(mocks);
View Full Code Here

  @Test
  public void implicitTokenDefinition() {
    ILinkingDiagnosticContext diagnosticContext = createMock(ILinkingDiagnosticContext.class);
    ParserRule rule = createMock(ParserRule.class);
    RuleRef ref = createMock(RuleRef.class);

    expect(diagnosticContext.getLinkText()).andReturn("ID");
    expect(diagnosticContext.getContext()).andReturn(ref);

    expect(ref.eContainer()).andReturn(null);
    expect(ref.eContainer()).andReturn(rule);

    Object[] mocks = {diagnosticContext, ref, rule };

    replay(mocks);
View Full Code Here

  }

  @Test
  public void missingArgumentsOnRuleReference() throws Exception {
    ParserRule reference = createMock(ParserRule.class);
    RuleRef ruleRef = createMock(RuleRef.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(ruleRef.getReference()).andReturn(reference);
    expect(ruleRef.getArgs()).andReturn(null);
    expect(ruleRef.eClass()).andReturn(eClass);

    expect(reference.getName()).andReturn("rule");
    expect(reference.getArgs()).andReturn("[int a, int b]");

    expect(eClass.getEStructuralFeature("reference")).andReturn(feature);
View Full Code Here

  }

  @Test
  public void ruleHasNoDefinedParameters() throws Exception {
    ParserRule reference = createMock(ParserRule.class);
    RuleRef ruleRef = createMock(RuleRef.class);
    EClass eClass = createMock(EClass.class);
    EStructuralFeature feature = createMock(EStructuralFeature.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(ruleRef.getReference()).andReturn(reference);
    expect(ruleRef.getArgs()).andReturn("[a, b]");
    expect(ruleRef.eClass()).andReturn(eClass);

    expect(reference.getName()).andReturn("rule");
    expect(reference.getArgs()).andReturn(null);

    expect(eClass.getEStructuralFeature("args")).andReturn(feature);
View Full Code Here

TOP

Related Classes of com.github.jknack.antlr4ide.lang.RuleRef

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.