@Override public void visitFieldReference(FieldReference node) { lombok.ast.Select select = new lombok.ast.Select(); select.astIdentifier(toIdentifier(node.token, node.nameSourcePosition)); select.astOperand((lombok.ast.Expression) toTree(node.receiver)); set(node, setPosition(node, select)); }
@Override public void visitFieldReference(FieldReference node) { lombok.ast.Select select = new lombok.ast.Select(); select.astIdentifier(toIdentifier(node.token, node.nameSourcePosition)); select.astOperand((lombok.ast.Expression) toTree(node.receiver)); set(node, setPosition(node, select)); }
@Override public void visitFieldReference(FieldReference node) { lombok.ast.Select select = new lombok.ast.Select(); select.astIdentifier(toIdentifier(node.token, node.nameSourcePosition)); select.astOperand((lombok.ast.Expression) toTree(node.receiver)); set(node, setPosition(node, select)); }
@Override public boolean visitSelect(Select node) { // R.type.name if (node.astOperand() instanceof Select) { Select select = (Select) node.astOperand(); if (select.astOperand() instanceof VariableReference) { VariableReference reference = (VariableReference) select.astOperand(); if (reference.astIdentifier().astValue().equals(R_CLASS)) { String type = select.astIdentifier().astValue(); if (type.equals(MENU_TYPE)) { String name = node.astIdentifier().astValue(); // Reclassify icons in the given menu as action bar icons if (mMenuToIcons != null) { Collection<String> icons = mMenuToIcons.get(name); if (icons != null) { if (mActionBarIcons == null) { mActionBarIcons = Sets.newHashSet(); } mActionBarIcons.addAll(icons); } } } } } } return super.visitSelect(node); } }
private List<String> unwrapSelectChain(Select s) { List<String> list = Lists.newArrayList(); while (s != null) { list.add(s.astIdentifier().astValue()); Expression parent = s.astOperand(); if (parent instanceof Select) { s = (Select) parent; } else if (parent instanceof Identifier) { s = null; list.add(((Identifier)parent).astValue()); } else if (parent == null) { break; } else { throw new ResolutionException(parent, "Identifies expected here, not a " + parent.getClass().getSimpleName()); } } Collections.reverse(list); return list; } }
private List<String> unwrapSelectChain(Select s) { List<String> list = Lists.newArrayList(); while (s != null) { list.add(s.astIdentifier().astValue()); Expression parent = s.astOperand(); if (parent instanceof Select) { s = (Select) parent; } else if (parent instanceof Identifier) { s = null; list.add(((Identifier)parent).astValue()); } else if (parent == null) { break; } else { throw new ResolutionException(parent, "Identifies expected here, not a " + parent.getClass().getSimpleName()); } } Collections.reverse(list); return list; } }
@Override public boolean visitSelect(Select node) { if (node.astIdentifier().astValue().equals("layout") //$NON-NLS-1$ && node.astOperand() instanceof VariableReference && ((VariableReference) node.astOperand()).astIdentifier().astValue() .equals("R") //$NON-NLS-1$ && node.getParent() instanceof Select) { String layout = ((Select) node.getParent()).astIdentifier().astValue(); registerLayoutActivity(layout, mClassFqn); } return false; }
private List<String> unwrapSelectChain(Select s) { List<String> list = Lists.newArrayList(); while (s != null) { list.add(s.astIdentifier().astValue()); Expression parent = s.astOperand(); if (parent instanceof Select) { s = (Select) parent; } else if (parent instanceof Identifier) { s = null; list.add(((Identifier)parent).astValue()); } else if (parent == null) { break; } else { throw new ResolutionException(parent, "Identifies expected here, not a " + parent.getClass().getSimpleName()); } } Collections.reverse(list); return list; } }
@Override public boolean visitSelect(Select node) { String description = node.astIdentifier().astValue(); boolean isIfRoom = description.equals("SHOW_AS_ACTION_IF_ROOM"); //$NON-NLS-1$ boolean isAlways = description.equals("SHOW_AS_ACTION_ALWAYS"); //$NON-NLS-1$ if ((isIfRoom || isAlways) && node.astOperand().toString().equals("MenuItem")) { //$NON-NLS-1$ if (isAlways) { if (mContext.getDriver().isSuppressed(mContext, ISSUE, node)) { return super.visitSelect(node); } if (mAlwaysFields == null) { mAlwaysFields = new ArrayList<Location>(); } mAlwaysFields.add(mContext.getLocation(node)); } else { mHasIfRoomRefs = true; } } return super.visitSelect(node); } }
@Override public boolean visitBinaryExpression(BinaryExpression node) { BinaryOperator operator = node.astOperator(); if (operator == BinaryOperator.ASSIGN || operator == BinaryOperator.OR_ASSIGN) { Expression left = node.astLeft(); String variable; if (left instanceof Select && ((Select) left).astOperand() instanceof This) { variable = ((Select) left).astIdentifier().astValue(); } else { variable = left.toString(); } mVariables.add(variable); } return super.visitBinaryExpression(node); } }
private lombok.ast.Expression toSelect(char[][] tokens, long[] positions) { if (tokens.length < 2) return null; if (tokens.length != positions.length) throw new IllegalStateException("bug"); lombok.ast.Identifier current0 = toIdentifier(tokens[0], positions[0]); lombok.ast.Expression current = new lombok.ast.VariableReference().astIdentifier(current0); current.setPosition(current0.getPosition()); for (int i = 1; i < tokens.length; i++) { lombok.ast.Select select = new lombok.ast.Select().astIdentifier(toIdentifier(tokens[i], positions[i])); select.astOperand(current); current = select; } return current; }
private lombok.ast.Expression toSelect(char[][] tokens, long[] positions) { if (tokens.length < 2) return null; if (tokens.length != positions.length) throw new IllegalStateException("bug"); lombok.ast.Identifier current0 = toIdentifier(tokens[0], positions[0]); lombok.ast.Expression current = new lombok.ast.VariableReference().astIdentifier(current0); current.setPosition(current0.getPosition()); for (int i = 1; i < tokens.length; i++) { lombok.ast.Select select = new lombok.ast.Select().astIdentifier(toIdentifier(tokens[i], positions[i])); select.astOperand(current); current = select; } return current; }
private lombok.ast.Expression toSelect(char[][] tokens, long[] positions) { if (tokens.length < 2) return null; if (tokens.length != positions.length) throw new IllegalStateException("bug"); lombok.ast.Identifier current0 = toIdentifier(tokens[0], positions[0]); lombok.ast.Expression current = new lombok.ast.VariableReference().astIdentifier(current0); current.setPosition(current0.getPosition()); for (int i = 1; i < tokens.length; i++) { lombok.ast.Select select = new lombok.ast.Select().astIdentifier(toIdentifier(tokens[i], positions[i])); select.astOperand(current); current = select; } return current; }
@Override public boolean visitSelect(Select node) { int start = posOfStructure(node.astIdentifier(), ".", true); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, treeMaker.Select(toExpression(node.astOperand()), toName(node.astIdentifier())))); }
@Override public boolean visitSelect(Select node) { int start = posOfStructure(node.astIdentifier(), ".", true); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, treeMaker.Select(toExpression(node.astOperand()), toName(node.astIdentifier())))); }
@Override public boolean visitSelect(Select node) { int start = posOfStructure(node.astIdentifier(), ".", true); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, treeMaker.Select(toExpression(node.astOperand()), toName(node.astIdentifier())))); }
private void updateRestrictionFlags(lombok.ast.Node node, NameReference ref) { ref.bits &= ~ASTNode.RestrictiveFlagMASK; ref.bits |= Binding.VARIABLE; if (node.getParent() instanceof lombok.ast.MethodInvocation) { if (((lombok.ast.MethodInvocation)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } if (node.getParent() instanceof lombok.ast.Select) { if (((lombok.ast.Select)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } }
private void updateRestrictionFlags(lombok.ast.Node node, NameReference ref) { ref.bits &= ~ASTNode.RestrictiveFlagMASK; ref.bits |= Binding.VARIABLE; if (node.getParent() instanceof lombok.ast.MethodInvocation) { if (((lombok.ast.MethodInvocation)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } if (node.getParent() instanceof lombok.ast.Select) { if (((lombok.ast.Select)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } }
private void updateRestrictionFlags(lombok.ast.Node node, NameReference ref) { ref.bits &= ~ASTNode.RestrictiveFlagMASK; ref.bits |= Binding.VARIABLE; if (node.getParent() instanceof lombok.ast.MethodInvocation) { if (((lombok.ast.MethodInvocation)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } if (node.getParent() instanceof lombok.ast.Select) { if (((lombok.ast.Select)node.getParent()).astOperand() == node) { ref.bits |= Binding.TYPE; } } }
/** Adds any variables referenced in the given expression into the given list */ private static void addReferencedVariables(Collection<String> variables, Expression expression) { if (expression instanceof BinaryExpression) { BinaryExpression binary = (BinaryExpression) expression; addReferencedVariables(variables, binary.astLeft()); addReferencedVariables(variables, binary.astRight()); } else if (expression instanceof UnaryExpression) { UnaryExpression unary = (UnaryExpression) expression; addReferencedVariables(variables, unary.astOperand()); } else if (expression instanceof VariableReference) { VariableReference reference = (VariableReference) expression; variables.add(reference.astIdentifier().astValue()); } else if (expression instanceof Select) { Select select = (Select) expression; if (select.astOperand() instanceof This) { variables.add(select.astIdentifier().astValue()); } } }