public AstNode newWrapperAstNode(List<AstNode> e1) { AstNode astNode = new AstNode(WRAPPER_AST_NODE, WRAPPER_AST_NODE.toString(), null); for (AstNode child : e1) { astNode.addChild(child); } return astNode; }
protected final PreciseIssue addIssue(Token token, String message) { return addIssue(new AstNode(token), message); }
protected final PreciseIssue addIssue(Token token, String message) { return addIssue(new AstNode(token), message); }
public static AstNode mockAstNode(String name) { return new AstNode(GenericTokenType.IDENTIFIER, name, mockToken(LITERAL, "dummy")); }
public final PreciseIssue addIssue(Token token, String message) { return addIssue(new AstNode(token), message); }
public static AstNode mockAstNode(String name) { return new AstNode(GenericTokenType.IDENTIFIER, name, mockToken(LITERAL, "dummy")); }
public AstNode newWrapperAstNode(AstNode e1, AstNode e2) { AstNode astNode = new AstNode(WRAPPER_AST_NODE, WRAPPER_AST_NODE.toString(), null); astNode.addChild(e1); astNode.addChild(e2); return astNode; }
public AstNode newWrapperAstNode(Optional<List<AstNode>> e1, AstNode e2) { if (e1.isPresent()) { AstNode astNode = new AstNode(WRAPPER_AST_NODE, WRAPPER_AST_NODE.toString(), null); for (AstNode child : e1.get()) { astNode.addChild(child); } astNode.addChild(e2); return astNode; } else { return e2; } }
public AstNode newWrapperAstNode(AstNode e1, Optional<AstNode> e2) { AstNode astNode = new AstNode(WRAPPER_AST_NODE, WRAPPER_AST_NODE.toString(), null); astNode.addChild(e1); if (e2.isPresent()) { astNode.addChild(e2.get()); } return astNode; }
public AstNode newWrapperAstNode2(AstNode e1, Optional<TemplateCharactersTreeImpl> e2, TemplateExpressionTreeImpl e3) { AstNode astNode = new AstNode(WRAPPER_AST_NODE, WRAPPER_AST_NODE.toString(), null); astNode.addChild(e1); if (e2.isPresent()) { astNode.addChild(e2.get()); } astNode.addChild(e3); return astNode; }
private void lookForDuplications(List<Token> fieldNames, List<Token> methodNames) { List<TokenWithTypeInfo> allTokensWithInfo = mergeLists(fieldNames, methodNames); Collections.sort(allTokensWithInfo, new LineComparator()); for (int i = 1; i < allTokensWithInfo.size(); i++){ for (int j = i-1; j >= 0; j--){ TokenWithTypeInfo token1 = allTokensWithInfo.get(j); TokenWithTypeInfo token2 = allTokensWithInfo.get(i); if (differOnlyByCapitalization(token1.getValue(), token2.getValue())){ addIssue(token2.token, getMessage(token1, token2)) .secondary(new AstNode(token1.token), "Original"); break; } } } }
private void lookForDuplications(List<Token> fieldNames, List<Token> methodNames) { List<TokenWithTypeInfo> allTokensWithInfo = mergeLists(fieldNames, methodNames); Collections.sort(allTokensWithInfo, new LineComparator()); for (int i = 1; i < allTokensWithInfo.size(); i++){ for (int j = i-1; j >= 0; j--){ TokenWithTypeInfo token1 = allTokensWithInfo.get(j); TokenWithTypeInfo token2 = allTokensWithInfo.get(i); if (differOnlyByCapitalization(token1.getValue(), token2.getValue())){ addIssue(token2.token, getMessage(token1, token2)) .secondary(new AstNode(token1.token), "Original"); break; } } } }
@Override public AstNode createNonTerminal(GrammarRuleKey ruleKey, Rule rule, List<Object> children, int startIndex, int endIndex) { Token token = null; for (Object child : children) { if (child instanceof AstNode && ((AstNode) child).hasToken()) { token = ((AstNode) child).getToken(); break; } } AstNode astNode = new AstNode(rule, ruleKey.toString(), token); for (Object child : children) { astNode.addChild((AstNode) child); } astNode.setFromIndex(startIndex); astNode.setToIndex(endIndex); return astNode; }
@Override public AstNode createNonTerminal(GrammarRuleKey ruleKey, Rule rule, List<Object> children, int startIndex, int endIndex) { Token token = null; for (Object child : children) { if (child instanceof AstNode && ((AstNode) child).hasToken()) { token = ((AstNode) child).getToken(); break; } } AstNode astNode = new AstNode(rule, ruleKey.toString(), token); for (Object child : children) { astNode.addChild((AstNode) child); } astNode.setFromIndex(startIndex); astNode.setToIndex(endIndex); return astNode; }
private AstNode visitTerminal(ParseNode node) { Token token = tokens.get(node.getStartIndex()); // For compatibility with SSLR < 1.19, TokenType should be checked only for TokenTypeExpression: if ((node.getMatcher() instanceof TokenTypeExpression) && token.getType().hasToBeSkippedFromAst(null)) { return null; } AstNode astNode = new AstNode(token); astNode.setFromIndex(node.getStartIndex()); astNode.setToIndex(node.getEndIndex()); return astNode; }
private AstNode visitTerminal(ParseNode node) { Token token = tokens.get(node.getStartIndex()); // For compatibility with SSLR < 1.19, TokenType should be checked only for TokenTypeExpression: if ((node.getMatcher() instanceof TokenTypeExpression) && token.getType().hasToBeSkippedFromAst(null)) { return null; } AstNode astNode = new AstNode(token); astNode.setFromIndex(node.getStartIndex()); astNode.setToIndex(node.getEndIndex()); return astNode; }
private AstNode visitTerminal(ParseNode node) { Token token = tokens.get(node.getStartIndex()); // For compatibility with SSLR < 1.19, TokenType should be checked only for TokenTypeExpression: if ((node.getMatcher() instanceof TokenTypeExpression) && token.getType().hasToBeSkippedFromAst(null)) { return null; } AstNode astNode = new AstNode(token); astNode.setFromIndex(node.getStartIndex()); astNode.setToIndex(node.getEndIndex()); return astNode; }
private void computeDocumentNode(Object contextNode) { if (documentNode == null) { if (isElement(contextNode)) { AstNode root = (AstNode) contextNode; while (root.getParent() != null) { root = root.getParent(); } documentNode = new AstNode(null, "[root]", null); documentNode.addChild(root); } else if (isAttribute(contextNode)) { Attribute attribute = (Attribute) contextNode; computeDocumentNode(attribute.getAstNode()); } } }
private void computeDocumentNode(Object contextNode) { if (documentNode == null) { if (isElement(contextNode)) { AstNode root = (AstNode) contextNode; while (root.getParent() != null) { root = root.getParent(); } documentNode = new AstNode(null, "[root]", null); documentNode.addChild(root); } else if (isAttribute(contextNode)) { Attribute attribute = (Attribute) contextNode; computeDocumentNode(attribute.getAstNode()); } } }
@Override public AstNode createTerminal(Input input, int startIndex, int endIndex, List<Trivia> trivias, TokenType type) { int[] lineAndColumn = input.lineAndColumnAt(startIndex); Token token = Token.builder() .setType(type == null ? UNDEFINED_TOKEN_TYPE : type) .setLine(lineAndColumn[0]) .setColumn(lineAndColumn[1] - 1) .setValueAndOriginalValue(input.substring(startIndex, endIndex)) .setURI(input.uri()) .setGeneratedCode(false) .setTrivia(trivias) .build(); AstNode astNode = new AstNode(token); astNode.setFromIndex(startIndex); astNode.setToIndex(endIndex); return astNode; }