public SyntaxNodeException(String message, Throwable cause, ISyntaxNode syntaxNode) { this(message, cause, syntaxNode == null ? null : syntaxNode.getSourceLocation(), syntaxNode == null ? null : syntaxNode.getModule()); this.syntaxNode = syntaxNode; }
public ILocation getParamTypeLocation(int paramNum) { // 0-th child is param type, 1-st child is param name. See ParameterDeclarationNodeBinder ISyntaxNode typeNode = children[paramNum].getSyntaxNode().getChild(0); while (typeNode.getNumberOfChildren() == 1 && !(typeNode instanceof IdentifierNode)) { // Get type node for array typeNode = typeNode.getChild(0); } return typeNode.getSourceLocation(); }
public IBoundNode bind(ISyntaxNode node, IBindingContext bindingContext) throws Exception { if (node.getNumberOfChildren() != 2) { throw SyntaxNodeExceptionUtils.createError("Binary node must have 2 subnodes", node); } int index = node.getType().lastIndexOf('.'); String methodName = node.getType().substring(index + 1); IBoundNode[] children = bindChildren(node, bindingContext); return bindOperator(node, methodName, children[0], children[1], bindingContext); }
private static ISyntaxNode getIdentifierSyntaxNode(ISyntaxNode syntaxNode) { if (!(syntaxNode instanceof IdentifierNode)) { if ("function".equals(syntaxNode.getType())) { syntaxNode = syntaxNode.getChild(syntaxNode.getNumberOfChildren() - 1); } } return syntaxNode; }
return; if ("chain.suffix.dot.identifier".equals(syntaxNode.getType())) { try { String fieldName = tryFixChainWithPackage(syntaxNode, bindingContext).toString(); Field field = BinaryNode.class.getDeclaredField("left"); field.setAccessible(true); if (!(syntaxNode.getParent() instanceof BinaryNode)){ throw new IllegalStateException(); field.set(syntaxNode.getParent(), new IdentifierNode("identifier", syntaxNode.getSourceLocation(), fieldName, syntaxNode.getModule())); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { int n = syntaxNode.getNumberOfChildren(); for (int i = 0; i < n; i++) { rec(syntaxNode.getChild(i), bindingContext); int n = syntaxNode.getNumberOfChildren(); for (int i = 0; i < n; i++) { rec(syntaxNode.getChild(i), bindingContext);
private static IBoundNode[] makeLocalVarsFromWhere(ISyntaxNode whereNode, IBindingContext bindingContext) throws Exception { int n = whereNode.getNumberOfChildren(); IBoundNode[] boundNodes = new IBoundNode[n + 1]; for (int i = 0; i < n; i++) { boundNodes[i] = makeLocalVar(whereNode.getChild(i), bindingContext); } return boundNodes; }
public IOpenSourceCodeModule getModule() { if (module != null) { return module; } if (parent != null) { return parent.getModule(); } return null; }
@Override public String getStringValue(ISyntaxNode syntaxNode) { return syntaxNode.getType(); } }
public IBoundNode bind(ISyntaxNode node, IBindingContext bindingContext) throws Exception { return bindChildNode(node.getChild(0), bindingContext); } }
public ILocation getLocation() { if (node != null) { ISyntaxNode syntaxNode = node.getSyntaxNode(); if (syntaxNode != null) { return syntaxNode.getSourceLocation(); } } return null; }
private IBoundNode validateNode(ISyntaxNode node, IBindingContext bindingContext) { if (node.getNumberOfChildren() < 1) { return makeErrorNode("New node should have at least one subnode", node, bindingContext); } return null; } }
private ISyntaxNode getModuleNode(TableSyntaxNode node) { ISyntaxNode moduleNode = node; while (moduleNode != null) { if (moduleNode instanceof XlsModuleSyntaxNode) { break; } else { moduleNode = moduleNode.getParent(); } } return moduleNode; }
return; if ("chain.suffix.dot.identifier".equals(syntaxNode.getType())) { try { String fieldName = tryFixChainWithPackage(syntaxNode, bindingContext).toString(); Field field = BinaryNode.class.getDeclaredField("left"); field.setAccessible(true); if (!(syntaxNode.getParent() instanceof BinaryNode)){ throw new IllegalStateException(); field.set(syntaxNode.getParent(), new IdentifierNode("identifier", syntaxNode.getSourceLocation(), fieldName, syntaxNode.getModule())); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { int n = syntaxNode.getNumberOfChildren(); for (int i = 0; i < n; i++) { rec(syntaxNode.getChild(i), bindingContext); int n = syntaxNode.getNumberOfChildren(); for (int i = 0; i < n; i++) { rec(syntaxNode.getChild(i), bindingContext);
private static IBoundNode[] makeLocalVarsFromWhere(ISyntaxNode whereNode, IBindingContext bindingContext) throws Exception { int n = whereNode.getNumberOfChildren(); IBoundNode[] boundNodes = new IBoundNode[n + 1]; for (int i = 0; i < n; i++) { boundNodes[i] = makeLocalVar(whereNode.getChild(i), bindingContext); } return boundNodes; }
public IOpenSourceCodeModule getModule() { if (module != null) { return module; } if (parent != null) { return parent.getModule(); } return null; }
public IBoundNode bind(ISyntaxNode node, IBindingContext bindingContext) throws Exception { if ("list".equals(node.getType())) { IBoundNode[] children = bindChildren(node, bindingContext); String[] res = new String[children.length]; for (int i = 0; i < res.length; i++) { res[i] = (String) ((LiteralBoundNode) children[i]).getValue(); } return new LiteralBoundNode(node, res, JavaOpenClass.getOpenClass(String[].class)); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < node.getNumberOfChildren(); i++) { ISyntaxNode child = node.getChild(i); if (i > 0) { sb.append(' '); } sb.append(((IdentifierNode) child).getIdentifier()); } return new LiteralBoundNode(node, sb.toString(), JavaOpenClass.STRING); }
private boolean isStrictMatch(ISyntaxNode node) { return !node.getType().contains(".nostrict"); }