java类org.antlr.v4.runtime.tree.TerminalNodeImpl的实例源码

AbstractWhereClauseListener.java 文件源码 项目:dragoman 阅读 14 收藏 0 点赞 0 评论 0
@Override
public void enterPattern_matcher(SQLParser.Pattern_matcherContext ctx) {
  super.enterPattern_matcher(ctx);
  for (int i = 0; i < ctx.getChildCount(); i++) {
    ParseTree child = ctx.getChild(i);
    if (child instanceof TerminalNodeImpl) {
      if (isNot(child.getText())) {
        currentPredicate.negate();
      }
      break;
    }
  }

  if (currentPredicate.isNegated()) {
    currentPredicate.setOperator("not like");
  } else {
    currentPredicate.setOperator("like");
  }
  skipNextTerminal = true;
}
Utilities.java 文件源码 项目:Tarski 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Cloning expression to create new same expression.
 */
public static ExprContext cloneExprContext(final ExprContext expr) {

  final ExprContext clone = createContextType(expr);

  clone.copyFrom(expr);

  for (final ParseTree child : expr.children) {
    if (child instanceof TerminalNode) {
      clone.addChild(new TerminalNodeImpl(((TerminalNode) child).getSymbol()));
    } else if (child instanceof ExprContext) {
      final ExprContext cloneChild = cloneExprContext((ExprContext) child);
      clone.addChild(cloneChild);
      setLeftRight(clone, cloneChild);
    } else if (child instanceof Token) {
      clone.addChild(new CommonToken((Token) child));
    }
  }
  return clone;
}
Utilities.java 文件源码 项目:Tarski 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Creating conjunction expression.
 */
public static ConjunctionContext createConjunctionContext(final ExprContext leftContext,
    final ExprContext rightContext) {

  final ConjunctionContext conjunctionContext = new ConjunctionContext(new ExprContext());
  final TerminalNodeImpl andNode = new TerminalNodeImpl(new CommonToken(10, "and"));

  // Setting context parents.
  leftContext.parent = conjunctionContext;
  andNode.parent = conjunctionContext;
  rightContext.parent = conjunctionContext;

  conjunctionContext.left = leftContext;
  conjunctionContext.right = rightContext;

  // Adding conjunction expression's children.
  conjunctionContext.addChild(leftContext);
  conjunctionContext.addChild(andNode);
  conjunctionContext.addChild(rightContext);

  return conjunctionContext;
}
Utilities.java 文件源码 项目:Tarski 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creating disjunction expression.
 */
public static DisjunctionContext createDisjunctionContext(final ExprContext leftContext,
    final ExprContext rightContext) {

  final DisjunctionContext disjunctionContext = new DisjunctionContext(new ExprContext());
  final TerminalNodeImpl orNode = new TerminalNodeImpl(new CommonToken(12, "or"));

  // Setting context parents.
  leftContext.parent = disjunctionContext;
  rightContext.parent = disjunctionContext;
  orNode.parent = disjunctionContext;

  disjunctionContext.left = leftContext;
  disjunctionContext.right = rightContext;

  // Adding disjunction expression's children.
  disjunctionContext.addChild(leftContext);
  disjunctionContext.addChild(orNode);
  disjunctionContext.addChild(rightContext);

  return disjunctionContext;
}
Utilities.java 文件源码 项目:Tarski 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Creating negation expression.
 */
public static NegationContext createNegationContext(final ExprContext expr) {

  final NegationContext negationContext = new NegationContext(new ExprContext());
  final TerminalNodeImpl notNode = new TerminalNodeImpl(new CommonToken(FOLParser.NOT, "not"));

  // Setting context parents.
  notNode.parent = negationContext;
  expr.parent = negationContext;

  // Adding negation expression's children.
  negationContext.addChild(notNode);
  negationContext.addChild(expr);

  return negationContext;
}
Utilities.java 文件源码 项目:Tarski 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Creating parentheses expression.
 */
public static ParenthesesContext createParenthesesContext(final ExprContext expr) {

  final ParenthesesContext parenthesesContext = new ParenthesesContext(new ExprContext());
  final TerminalNodeImpl leftParenthes = new TerminalNodeImpl(new CommonToken(FOLParser.LP, "("));
  final TerminalNodeImpl rightParenthes =
      new TerminalNodeImpl(new CommonToken(FOLParser.RP, ")"));

  // Setting context parents.
  leftParenthes.parent = parenthesesContext;
  rightParenthes.parent = parenthesesContext;
  expr.parent = parenthesesContext;

  // Adding parentheses expression's children.
  parenthesesContext.addChild(leftParenthes);
  parenthesesContext.addChild(expr);
  parenthesesContext.addChild(rightParenthes);

  return parenthesesContext;
}
GoLangTreeListener.java 文件源码 项目:clarpse 阅读 14 收藏 0 点赞 0 评论 0
/**
 * Searches the children of the given context for a context of the given clazz
 * type and returns its Text Value. If there are multiple relevant child nodes,
 * we will return the text value for one of them at random.
 */
public String getChildContextText(RuleContext ctx) {

    if (ctx == null) {
        return "";
    }
    if (ctx instanceof TypeNameContext) {
        return ctx.getText();
    }

    String s = "";
    for (int i = 0; i < ctx.getChildCount(); i++) {
        if (!(ctx.getChild(i) instanceof TerminalNodeImpl)) {
            try {
                String t = getChildContextText((RuleContext) ctx.getChild(i));
                if (!t.isEmpty()) {
                    s += t + ",";
                }
            } catch (Exception e) {
                // do nothing
            }
        }
    }
    return s.replaceAll(",$", "");
}
CustomChecksTest.java 文件源码 项目:sonar-tsql-plugin 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void testCheckEndingWIthSemicolon2() {
    Rule r = new Rule();
    RuleImplementation rImpl = new RuleImplementation();
    rImpl.getNames().getTextItem().add(Select_statementContext.class.getSimpleName());
    rImpl.setRuleMatchType(RuleMatchType.CLASS_ONLY);
    r.setRuleImplementation(rImpl);
    RuleImplementation child = new RuleImplementation();
    child.setDistance(1);
    child.setIndex(-1);
    child.setDistanceCheckType(RuleDistanceIndexMatchType.EQUALS);
    child.setIndexCheckType(RuleDistanceIndexMatchType.EQUALS);
    child.getTextToFind().getTextItem().add(";");
    child.setTextCheckType(TextCheckType.STRICT);
    child.setRuleMatchType(RuleMatchType.CLASS_ONLY);
    child.setRuleResultType(RuleResultType.FAIL_IF_NOT_FOUND);
    child.getNames().getTextItem().add(TerminalNodeImpl.class.getSimpleName());
    rImpl.getChildrenRules().getRuleImplementation().add(child);
    String s = "SELECT * from dbo.test where name like '%test%'";
    TsqlIssue[] issues = Antlr4Utils.verify2(r, s);
    Assert.assertEquals(1, issues.length);

}
ArrayTypeRef.java 文件源码 项目:JavaModel 阅读 15 收藏 0 点赞 0 评论 0
public static TypeRef fromAntlrNode(Java8Parser.UnannArrayTypeContext antlrNode) {
    if (antlrNode.unannPrimitiveType() != null){

        long nDims = antlrNode.dims().children.stream().filter((c)->c instanceof TerminalNodeImpl).map((c) -> (TerminalNodeImpl)c)
                .filter((c)->c.getText().equals("[")).count();

        // TODO consider annotations
        // TODO consider multiple dimensions
        if (antlrNode.dims().annotation() != null && !antlrNode.dims().annotation().isEmpty()){
            throw new UnsupportedOperationException();
        }

        return fromAntlrNode(PrimitiveTypeRef.fromAntlrNode(antlrNode.unannPrimitiveType()), nDims);
    } else {
        throw new UnsupportedOperationException();
    }
}
ArrayTypeRef.java 文件源码 项目:JavaModel 阅读 15 收藏 0 点赞 0 评论 0
public static TypeRef fromAntlrNode(Java8Parser.ArrayTypeContext antlrNode) {
    if (antlrNode.primitiveType() != null){

        long nDims = antlrNode.dims().children.stream().filter((c)->c instanceof TerminalNodeImpl).map((c) -> (TerminalNodeImpl)c)
                .filter((c)->c.getText().equals("[")).count();

        // TODO consider annotations
        // TODO consider multiple dimensions
        if (antlrNode.dims().annotation() != null && !antlrNode.dims().annotation().isEmpty()){
            throw new UnsupportedOperationException();
        }

        return fromAntlrNode(PrimitiveTypeRef.fromAntlrNode(antlrNode.primitiveType()), nDims);
    } else {
        throw new UnsupportedOperationException();
    }
}
BraceStyleListener.java 文件源码 项目:tailor 阅读 19 收藏 0 点赞 0 评论 0
private void verifyInitializerBraceStyle(SwiftParser.InitializerDeclarationContext ctx) {
    // Check if there is an element between the parameter clause and open brace (i.e. 'throws' or 'rethrows')
    // (Issue #405)
    ParseTree leftSibling = ParseTreeUtil.getLeftSibling(ctx.initializerBody());
    if (leftSibling instanceof TerminalNodeImpl) {
        verifyCodeBlockOpenBraceStyle(
            ctx.initializerBody().codeBlock(),
            ((TerminalNodeImpl) leftSibling).getSymbol(),
            Messages.INITIALIZER_BODY);
    } else {
        verifyCodeBlockOpenBraceStyle(ctx.initializerBody().codeBlock(), ctx.parameterClause().getStop(),
            Messages.INITIALIZER_BODY);
    }

    verifyBodyCloseBraceStyle(ctx.initializerBody().codeBlock(), Messages.INITIALIZER_BODY);
}
BraceStyleListener.java 文件源码 项目:tailor 阅读 22 收藏 0 点赞 0 评论 0
private void verifyEnumBraceStyle(ParserRuleContext ctx) {
    for (ParseTree child : ctx.children) {
        if (child instanceof TerminalNodeImpl && child.getText().equals("{")) {
            Token openBrace = ((TerminalNodeImpl) child).getSymbol();
            Location openBraceLocation = ListenerUtil.getTokenLocation(openBrace);
            ParserRuleContext leftSibling = (ParserRuleContext) ParseTreeUtil.getLeftSibling(child);
            Location leftSiblingLocation = ListenerUtil.getContextStopLocation(leftSibling);

            if (openBraceLocation.line != leftSiblingLocation.line) {
                printer.warn(Rules.BRACE_STYLE, Messages.ENUM + Messages.OPEN_BRACE_STYLE, openBraceLocation);
            } else if (checkLeftSpaces(leftSibling.getStop(), openBrace, 1)) {
                printer.error(Rules.BRACE_STYLE, Messages.OPEN_BRACE + Messages.SPACE_BEFORE, openBraceLocation);
            }
            break;
        }
    }

    ParseTree lastChild = ParseTreeUtil.getLastChild(ctx);
    verifyCloseBraceStyle(lastChild, ParseTreeUtil.getLeftSibling(lastChild), Messages.ENUM);
}
BraceStyleListener.java 文件源码 项目:tailor 阅读 17 收藏 0 点赞 0 评论 0
private void verifyCloseBraceStyle(ParseTree closeBrace, ParseTree closeBraceLeftSibling, String constructName) {
    Token closeBraceToken = ((TerminalNodeImpl)closeBrace).getSymbol();
    Location closeBraceLocation = ListenerUtil.getTokenLocation(closeBraceToken);

    if (commentLeftOfCloseBrace(closeBraceToken)) {
        this.printer.warn(Rules.BRACE_STYLE, constructName + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
        return;
    }

    Location closeBraceLeftSiblingLocation = ListenerUtil.getParseTreeStopLocation(closeBraceLeftSibling);
    if (closeBraceLocation.line == closeBraceLeftSiblingLocation.line) {
        if (!closeBraceLeftSibling.getText().equals("{")) {
            this.printer.warn(Rules.BRACE_STYLE, constructName + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
        } else if (closeBraceLocation.column - closeBraceLeftSiblingLocation.column != 1) {
            this.printer.warn(Rules.BRACE_STYLE, Messages.EMPTY_BODY, closeBraceLeftSiblingLocation);
        }
    }
}
BraceStyleListener.java 文件源码 项目:tailor 阅读 19 收藏 0 点赞 0 评论 0
private void verifyClosureCloseBraceStyle(SwiftParser.ClosureExpressionContext ctx) {
    ParseTree closeBrace = ParseTreeUtil.getLastChild(ctx);
    Token closeBraceToken = ((TerminalNodeImpl) closeBrace).getSymbol();
    Location closeBraceLocation = ListenerUtil.getTokenLocation(closeBraceToken);
    Location openBraceLocation = ListenerUtil.getLocationOfChildToken(ctx, 0);

    if (openBraceLocation.line != closeBraceLocation.line && commentLeftOfCloseBrace(closeBraceToken)) {
        this.printer.warn(Rules.BRACE_STYLE, Messages.CLOSURE + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
        return;
    }

    Location leftSiblingLocation = ListenerUtil.getParseTreeStopLocation(ParseTreeUtil.getLeftSibling(closeBrace));
    if (leftSiblingLocation.line == closeBraceLocation.line && openBraceLocation.line != closeBraceLocation.line) {
        this.printer.warn(Rules.BRACE_STYLE, Messages.CLOSURE + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
    }
}
Utilities.java 文件源码 项目:WP3 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Cloning expression to create new same expression.
 */
public static ExprContext cloneExprContext(final ExprContext expr) {

  final ExprContext clone = createContextType(expr);

  clone.copyFrom(expr);

  for (final ParseTree child : expr.children) {
    if (child instanceof TerminalNode) {
      clone.addChild(new TerminalNodeImpl(((TerminalNode) child).getSymbol()));
    } else if (child instanceof ExprContext) {
      final ExprContext cloneChild = cloneExprContext((ExprContext) child);
      clone.addChild(cloneChild);
      setLeftRight(clone, cloneChild);
    } else if (child instanceof Token) {
      clone.addChild(new CommonToken((Token) child));
    }
  }
  return clone;
}
Utilities.java 文件源码 项目:WP3 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Creating conjunction expression.
 */
public static ConjunctionContext createConjunctionContext(final ExprContext leftContext,
    final ExprContext rightContext) {

  final ConjunctionContext conjunctionContext = new ConjunctionContext(new ExprContext());
  final TerminalNodeImpl andNode = new TerminalNodeImpl(new CommonToken(10, "and"));

  // Setting context parents.
  leftContext.parent = conjunctionContext;
  andNode.parent = conjunctionContext;
  rightContext.parent = conjunctionContext;

  conjunctionContext.left = leftContext;
  conjunctionContext.right = rightContext;

  // Adding conjunction expression's children.
  conjunctionContext.addChild(leftContext);
  conjunctionContext.addChild(andNode);
  conjunctionContext.addChild(rightContext);

  return conjunctionContext;
}
Utilities.java 文件源码 项目:WP3 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Creating disjunction expression.
 */
public static DisjunctionContext createDisjunctionContext(final ExprContext leftContext,
    final ExprContext rightContext) {

  final DisjunctionContext disjunctionContext = new DisjunctionContext(new ExprContext());
  final TerminalNodeImpl orNode = new TerminalNodeImpl(new CommonToken(12, "or"));

  // Setting context parents.
  leftContext.parent = disjunctionContext;
  rightContext.parent = disjunctionContext;
  orNode.parent = disjunctionContext;

  disjunctionContext.left = leftContext;
  disjunctionContext.right = rightContext;

  // Adding disjunction expression's children.
  disjunctionContext.addChild(leftContext);
  disjunctionContext.addChild(orNode);
  disjunctionContext.addChild(rightContext);

  return disjunctionContext;
}
Utilities.java 文件源码 项目:WP3 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Creating negation expression.
 */
public static NegationContext createNegationContext(final ExprContext expr) {

  final NegationContext negationContext = new NegationContext(new ExprContext());
  final TerminalNodeImpl notNode = new TerminalNodeImpl(new CommonToken(FOLParser.NOT, "not"));

  // Setting context parents.
  notNode.parent = negationContext;
  expr.parent = negationContext;

  // Adding negation expression's children.
  negationContext.addChild(notNode);
  negationContext.addChild(expr);

  return negationContext;
}
Utilities.java 文件源码 项目:WP3 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Creating parentheses expression.
 */
public static ParenthesesContext createParenthesesContext(final ExprContext expr) {

  final ParenthesesContext parenthesesContext = new ParenthesesContext(new ExprContext());
  final TerminalNodeImpl leftParenthes = new TerminalNodeImpl(new CommonToken(FOLParser.LP, "("));
  final TerminalNodeImpl rightParenthes =
      new TerminalNodeImpl(new CommonToken(FOLParser.RP, ")"));

  // Setting context parents.
  leftParenthes.parent = parenthesesContext;
  rightParenthes.parent = parenthesesContext;
  expr.parent = parenthesesContext;

  // Adding parentheses expression's children.
  parenthesesContext.addChild(leftParenthes);
  parenthesesContext.addChild(expr);
  parenthesesContext.addChild(rightParenthes);

  return parenthesesContext;
}
RemoveParameterSolver.java 文件源码 项目:Purify 阅读 15 收藏 0 点赞 0 评论 0
/**
 * Remove the separator (,) between arguments. 
 *  
 * @param file Source file to edit.
 * @param context ExpressionList context.
 * @param index Parameter index of the argument ("a", "b") "a" = 0, "b" = 1
 */
private void removeCallSeparator(SourceFile file, 
        ExpressionListContext context, int index) {
    ParseTree item = null;

    // Remove separator after argument.
    if (index == 0 && context.getChildCount() >= index + 1) {
        item = context.getChild(index + 1);
    } else if (context.getChildCount() >= index - 1) {
        item = context.getChild(index - 1);
    }

    if (item instanceof TerminalNodeImpl && 
            item.getText().equals(",")) {
        file.getRewriter().delete(((TerminalNodeImpl)item).getPayload());
    }
}
AbstractWhereClauseListener.java 文件源码 项目:dragoman 阅读 14 收藏 0 点赞 0 评论 0
@Override
public void enterIn_predicate(SQLParser.In_predicateContext ctx) {
  super.enterIn_predicate(ctx);
  enterInClause();
  for (int i = 0; i < ctx.getChildCount(); i++) {
    ParseTree child = ctx.getChild(i);
    if (child instanceof TerminalNodeImpl) {
      if (isNot(child.getText())) {
        currentPredicate.negate();
      }
      break;
    }
  }
  currentPredicate.inOperator();
}
AbstractWhereClauseListener.java 文件源码 项目:dragoman 阅读 16 收藏 0 点赞 0 评论 0
@Override
public void enterNull_predicate(SQLParser.Null_predicateContext ctx) {
  super.enterNull_predicate(ctx);

  enterNullClause();
  for (int i = 0; i < ctx.getChildCount(); i++) {
    ParseTree child = ctx.getChild(i);
    if (child instanceof TerminalNodeImpl) {
      if (isNot(child.getText())) {
        currentPredicate.negate();
      }
    }
  }
  currentPredicate.nullOperator();
}
QueryVisitorImpl.java 文件源码 项目:CacheStore 阅读 23 收藏 0 点赞 0 评论 0
private boolean checkWhereStatement(@NotNull QueryParser.WhereStatementContext ctx) {
    if ( ctx != null && ctx.getChildCount() > 1) {
        //visit predicate
        Result result = visit(ctx.predicate());
        //check if not in front predicate
        if ( ctx.getChild(1) instanceof TerminalNodeImpl )
            return ! (Boolean) result.getValue() ;
        else
            return (Boolean) result.getValue() ;
    }
    else
        return true;
}
Select_or_valuesGenerator.java 文件源码 项目:antsdb 阅读 62 收藏 0 点赞 0 评论 0
private static RuleContext createColumnName_(Expr_functionContext rule, OutputField field) {
    Column_name_Context column_name_ = new Column_name_Context(rule.getParent(), rule.invokingState);
    Column_nameContext column_name = new Column_nameContext(column_name_.getParent(), rule.invokingState);
    IdentifierContext identifier = new IdentifierContext(column_name, rule.invokingState);
    CommonToken token = CommonTokenFactory.DEFAULT.create(
            MysqlParser.BACKTICK_QUOTED_IDENTIFIER, 
            '`' + field.name + '`' );
    TerminalNode term = new TerminalNodeImpl(token);
    identifier.addChild(term);
    column_name.addChild(identifier);
    column_name_.addChild(column_name);
    return column_name_;
}
CustomChecksTest.java 文件源码 项目:sonar-tsql-plugin 阅读 15 收藏 0 点赞 0 评论 0
@Test
public void testCheckEndingWithSemicolon() {
    Rule r = new Rule();
    r.setKey("Example1");
    r.setInternalKey("Example1");
    r.setDescription("Select statement should end with semicolon");
    r.setName("Select statement should end with semicolon");
    RuleImplementation rImpl = new RuleImplementation();
    rImpl.getNames().getTextItem().add(Select_statementContext.class.getSimpleName());
    rImpl.setRuleMatchType(RuleMatchType.CLASS_ONLY);
    r.setRuleImplementation(rImpl);
    RuleImplementation child = new RuleImplementation();
    child.setDistance(1);
    child.setIndex(-1);
    child.setDistanceCheckType(RuleDistanceIndexMatchType.EQUALS);
    child.setIndexCheckType(RuleDistanceIndexMatchType.EQUALS);
    child.getTextToFind().getTextItem().add(";");
    child.setTextCheckType(TextCheckType.STRICT);
    child.setRuleMatchType(RuleMatchType.TEXT_AND_CLASS);
    child.setRuleResultType(RuleResultType.FAIL_IF_NOT_FOUND);
    child.getNames().getTextItem().add(TerminalNodeImpl.class.getSimpleName());
    rImpl.getChildrenRules().getRuleImplementation().add(child);
    rImpl.getCompliantRulesCodeExamples().getRuleCodeExample().add("SELECT * from dbo.test where name like '%test%';");
    rImpl.getViolatingRulesCodeExamples().getRuleCodeExample().add("SELECT * from dbo.test where name like '%test%'");

    String s = "SELECT * from dbo.test where name like '%test%';";
    //System.out.println(Antlr4Utils.ruleImplToString(r));
    TsqlIssue[] issues = Antlr4Utils.verify2(r, s);

    //TsqlIssue[] issues = Antlr4Utils.verifyWithPrinting(r, s);
    Assert.assertEquals(0, issues.length);
//  Antlr4Utils.print(Antlr4Utils.get("SELECT * from dbo.test;"), 0);

}
PreProcessor.java 文件源码 项目:WAM 阅读 18 收藏 0 点赞 0 评论 0
public static void fixParenthesized(ExprContext ctx){
    PredicateContext pred = new PredicateContext(ctx, 0);
    PrednameContext functor = new PrednameContext(pred, 0);
    ParenthesizedContext paren = (ParenthesizedContext)ctx.getChild(0);

    functor.children = new ArrayList<ParseTree>(); 
    pred.children = new ArrayList<ParseTree>();

    functor.children.add(new TerminalNodeImpl(new CommonToken(0,""))); // Nameless functor

    pred.children.add(functor);
    pred.children.add(paren);

    ctx.children.set(0, pred);
}
ParseTreeUtil.java 文件源码 项目:tailor 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Returns the starting token of the construct represented by node.
 *
 * @param node A node
 * @return Start token
 */
public static Token getStartTokenForNode(ParseTree node) {
    if (node instanceof TerminalNodeImpl) {
        return ((TerminalNodeImpl) node).getSymbol();
    } else {
        return ((ParserRuleContext) node).getStart();
    }
}
ParseTreeUtil.java 文件源码 项目:tailor 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Returns the last token of the construct represented by node.
 *
 * @param node A node
 * @return Stop token
 */
public static Token getStopTokenForNode(ParseTree node) {
    if (node instanceof TerminalNodeImpl) {
        return ((TerminalNodeImpl) node).getSymbol();
    } else {
        return ((ParserRuleContext) node).getStop();
    }
}
CommaWhitespaceListener.java 文件源码 项目:tailor 阅读 14 收藏 0 点赞 0 评论 0
@Override
public void enterTypeInheritanceClause(SwiftParser.TypeInheritanceClauseContext ctx) {
    if (ctx.classRequirement() != null && ctx.typeInheritanceList() != null) {
        Token left = ParseTreeUtil.getStopTokenForNode(ctx.classRequirement());
        Token right = ParseTreeUtil.getStartTokenForNode(ctx.typeInheritanceList());
        Token comma = ((TerminalNodeImpl) ctx.getChild(2)).getSymbol();

        verifyCommaLeftAssociation(left, right, comma);
    }

    if (ctx.typeInheritanceList() != null) {
        checkWhitespaceAroundCommaSeparatedList(ctx.typeInheritanceList());
    }
}
ColonWhitespaceListener.java 文件源码 项目:tailor 阅读 15 收藏 0 点赞 0 评论 0
@Override
public void enterDictionaryLiteralItem(SwiftParser.DictionaryLiteralItemContext ctx) {
    Token left = ctx.expression(0).getStop();
    Token right = ctx.expression(1).getStart();
    Token colon = ((TerminalNodeImpl) ctx.getChild(1)).getSymbol();

    verifyColonLeftAssociation(left, right, colon);
}


问题


面经


文章

微信
公众号

扫码关注公众号