private boolean isResultNumber(BinaryNode binaryNode) { boolean bResult = false; TokenType tokenType = binaryNode.tokenType(); Node lhs = binaryNode.lhs(); Node rhs = binaryNode.rhs(); if ((tokenType == TokenType.BIT_OR || tokenType == TokenType.BIT_AND) && ((lhs instanceof LiteralNode && ((LiteralNode) lhs).isNumeric()) || (rhs instanceof LiteralNode && ((LiteralNode) rhs).isNumeric()))) { bResult = true; } else if (tokenType == TokenType.DIV || tokenType == TokenType.MUL || tokenType == TokenType.SUB ){ bResult = true; } else { if (lhs instanceof BinaryNode) { bResult = isResultNumber((BinaryNode) lhs); } else if (rhs instanceof BinaryNode) { bResult = isResultNumber((BinaryNode) rhs); } } return bResult; }
@Override public boolean enterAccessNode(AccessNode accessNode) { BinaryNode node = getPath().get(getPath().size() - 1) instanceof BinaryNode ? (BinaryNode)getPath().get(getPath().size() - 1) : null; if (!(node != null && node.tokenType() == TokenType.ASSIGN)) { if (accessNode.getBase() instanceof IdentNode && ModelUtils.THIS.equals(((IdentNode)accessNode.getBase()).getName())) { //NOI18N String iNode = accessNode.getProperty(); JsObject current = modelBuilder.getCurrentDeclarationFunction(); JsObject property = current.getProperty(iNode); if (property == null && current.getParent() != null && (current.getParent().getJSKind() == JsElement.Kind.CONSTRUCTOR || current.getParent().getJSKind() == JsElement.Kind.OBJECT)) { current = current.getParent(); property = current.getProperty(iNode); if (property == null && ModelUtils.PROTOTYPE.equals(current.getName())) { current = current.getParent(); property = current.getProperty(iNode); } } if (property == null && current.getParent() == null) { // probably we are in global space and there is used this property = modelBuilder.getGlobal().getProperty(iNode); } if (property != null && !property.getModifiers().contains(Modifier.PRIVATE)) { // we don't want to add occurrences for cases like var buf = this.buf. See issue #267694 ((JsObjectImpl)property).addOccurrence(new OffsetRange(accessNode.getFinish() - iNode.length(), accessNode.getFinish())); } } } return super.enterAccessNode(accessNode); }
if (getPreviousFromPath(pathIndex + 3) instanceof BinaryNode) { BinaryNode bNode = (BinaryNode) getPreviousFromPath(pathIndex + 3); if (bNode.tokenType() == TokenType.ASSIGN) { if (bNode.lhs() instanceof AccessNode) { List<Identifier> identifier = getName((AccessNode) bNode.lhs(), parserResult);
Node lhs = binaryNode.lhs(); Node rhs = binaryNode.rhs(); if (lhs instanceof LiteralNode.ArrayLiteralNode && binaryNode.tokenType() == TokenType.ASSIGN) { } else if (lhs instanceof ObjectNode && binaryNode.tokenType() == TokenType.ASSIGN) { } else if (lPropertyNode.getValue() instanceof BinaryNode) { BinaryNode bNode = (BinaryNode)lPropertyNode.getValue(); if (bNode.tokenType() == TokenType.ASSIGN && bNode.lhs() instanceof IdentNode) { processBinaryNode(lhs, rhs, binaryNode.tokenType());
&& ((BinaryNode)lastVisited).tokenType() != TokenType.ASSIGN) { pathIndex++; lastVisited = getPath().get(pathSize - pathIndex);
private boolean isResultString(BinaryNode binaryNode) { boolean bResult = false; TokenType tokenType = binaryNode.tokenType(); Node lhs = binaryNode.lhs(); Node rhs = binaryNode.rhs(); if (tokenType == TokenType.ADD && ((lhs instanceof LiteralNode && ((LiteralNode) lhs).isString()) || (rhs instanceof LiteralNode && ((LiteralNode) rhs).isString()))) { bResult = true; } else { if (lhs instanceof JoinPredecessorExpression) { lhs = ((JoinPredecessorExpression)lhs).getExpression(); } if (rhs instanceof JoinPredecessorExpression) { rhs = ((JoinPredecessorExpression)rhs).getExpression(); } if (lhs instanceof BinaryNode) { bResult = isResultString((BinaryNode) lhs); } else if (rhs instanceof BinaryNode) { bResult = isResultString((BinaryNode) rhs); } } return bResult; }
private boolean isKeyAndValueEquals(PropertyNode pNode) { if (pNode.getKey() instanceof IdentNode && pNode.getValue() instanceof IdentNode) { IdentNode key = (IdentNode)pNode.getKey(); IdentNode value = (IdentNode)pNode.getValue(); return key.getName().equals(value.getName()) && key.getStart() == value.getStart(); } if (pNode.getKey() instanceof IdentNode && pNode.getValue() instanceof BinaryNode && ((BinaryNode)pNode.getValue()).tokenType() == TokenType.ASSIGN && ((BinaryNode)pNode.getValue()).lhs() instanceof IdentNode) { IdentNode key = (IdentNode)pNode.getKey(); IdentNode value = (IdentNode)((BinaryNode)pNode.getValue()).lhs(); return key.getName().equals(value.getName()) && key.getStart() == value.getStart(); } return false; }
|| (previousVisited instanceof BinaryNode && ((BinaryNode)previousVisited).tokenType() == TokenType.COMMARIGHT)) { JsObjectImpl objectScope = ModelElementFactory.createAnonymousObject(parserResult, objectNode, modelBuilder); modelBuilder.setCurrentObject(objectScope); && ((BinaryNode)lastVisited).tokenType() != TokenType.ASSIGN) { pathIndex++; lastVisited = getPath().get(pathSize - pathIndex);
if (lastVisited instanceof BinaryNode) { BinaryNode bNode = (BinaryNode)lastVisited; onLeftSite = bNode.tokenType() == TokenType.ASSIGN && bNode.lhs().equals(accessNode);
return false; TokenType tokenType = binaryNode.tokenType(); if (tokenType == TokenType.EQ || tokenType == TokenType.EQ_STRICT || tokenType == TokenType.NE || tokenType == TokenType.NE_STRICT