org.eclipse.jdt.core.dom.ArrayInitializer Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.ArrayInitializer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 6 votes |
public boolean visit(ArrayInitializer expr) { /* * ArrayInitializer: { [ Expression { , Expression} [ , ]] } */ activateDiffStyle(expr); appendOpenCurlyBracket(); for (int i = 0; i < expr.expressions().size(); i++) { handleExpression((Expression) expr.expressions().get(i)); if (i < expr.expressions().size() - 1) { appendComma(); } } appendClosedCurlyBracket(); deactivateDiffStyle(expr); return false; }
Example #2
Source File: MissingAnnotationAttributesProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Expression newDefaultExpression(AST ast, ITypeBinding type, ImportRewriteContext context) { if (type.isPrimitive()) { String name= type.getName(); if ("boolean".equals(name)) { //$NON-NLS-1$ return ast.newBooleanLiteral(false); } else { return ast.newNumberLiteral("0"); //$NON-NLS-1$ } } if (type == ast.resolveWellKnownType("java.lang.String")) { //$NON-NLS-1$ return ast.newStringLiteral(); } if (type.isArray()) { ArrayInitializer initializer= ast.newArrayInitializer(); initializer.expressions().add(newDefaultExpression(ast, type.getElementType(), context)); return initializer; } if (type.isAnnotation()) { MarkerAnnotation annotation= ast.newMarkerAnnotation(); annotation.setTypeName(ast.newName(getImportRewrite().addImport(type, context))); return annotation; } return ast.newNullLiteral(); }
Example #3
Source File: JavaASTUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") private static boolean containsAnnotationValue(Expression annotationValue, String value) { if (annotationValue.getNodeType() == ASTNode.STRING_LITERAL) { String valueString = ((StringLiteral) annotationValue).getLiteralValue(); return value.equals(valueString); } else if (annotationValue.getNodeType() == ASTNode.ARRAY_INITIALIZER) { // If the annotation value is actually an array, check each element List<Expression> warningTypes = ((ArrayInitializer) annotationValue).expressions(); for (Expression warningType : warningTypes) { if (containsAnnotationValue(warningType, value)) { return true; } } } return false; }
Example #4
Source File: UiBinderJavaValidator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") private void validateUiHandlerFieldExistenceInUiXml( MethodDeclaration uiHandlerDecl) { Annotation annotation = JavaASTUtils.findAnnotation(uiHandlerDecl, UiBinderConstants.UI_HANDLER_TYPE_NAME); if (annotation instanceof SingleMemberAnnotation) { SingleMemberAnnotation uiHandlerAnnotation = (SingleMemberAnnotation) annotation; Expression exp = uiHandlerAnnotation.getValue(); if (exp instanceof StringLiteral) { validateFieldExistenceInUiXml( (TypeDeclaration) uiHandlerDecl.getParent(), exp, ((StringLiteral) exp).getLiteralValue()); } else if (exp instanceof ArrayInitializer) { for (Expression element : (List<Expression>) ((ArrayInitializer) exp).expressions()) { if (element instanceof StringLiteral) { validateFieldExistenceInUiXml( (TypeDeclaration) uiHandlerDecl.getParent(), element, ((StringLiteral) element).getLiteralValue()); } } } } }
Example #5
Source File: ClientBundleValidator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") private void validateSourceAnnotationValues(Annotation annotation) throws JavaModelException { Expression exp = JavaASTUtils.getAnnotationValue(annotation); if (exp == null) { return; } // There will usually just be one string value if (exp instanceof StringLiteral) { validateSourceAnnotationValue((StringLiteral) exp); } // But there could be multiple values; if so, check each one. if (exp instanceof ArrayInitializer) { ArrayInitializer array = (ArrayInitializer) exp; for (Expression item : (List<Expression>) array.expressions()) { if (item instanceof StringLiteral) { validateSourceAnnotationValue((StringLiteral) item); } } } }
Example #6
Source File: StringFormatGenerator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void complete() throws CoreException { super.complete(); ReturnStatement rStatement= fAst.newReturnStatement(); String formatClass; if (getContext().is50orHigher()) formatClass= "java.lang.String"; //$NON-NLS-1$ else formatClass= "java.text.MessageFormat"; //$NON-NLS-1$ MethodInvocation formatInvocation= createMethodInvocation(addImport(formatClass), "format", null); //$NON-NLS-1$ StringLiteral literal= fAst.newStringLiteral(); literal.setLiteralValue(buffer.toString()); formatInvocation.arguments().add(literal); if (getContext().is50orHigher()) { formatInvocation.arguments().addAll(arguments); } else { ArrayCreation arrayCreation= fAst.newArrayCreation(); arrayCreation.setType(fAst.newArrayType(fAst.newSimpleType(addImport("java.lang.Object")))); //$NON-NLS-1$ ArrayInitializer initializer= fAst.newArrayInitializer(); arrayCreation.setInitializer(initializer); initializer.expressions().addAll(arguments); formatInvocation.arguments().add(arrayCreation); } rStatement.setExpression(formatInvocation); toStringMethod.getBody().statements().add(rStatement); }
Example #7
Source File: SuperTypeConstraintsCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public final void endVisit(final ArrayInitializer node) { final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isArray()) { final ConstraintVariable2 ancestor= fModel.createIndependentTypeVariable(binding.getElementType()); if (ancestor != null) { node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor); Expression expression= null; ConstraintVariable2 descendant= null; final List<Expression> expressions= node.expressions(); for (int index= 0; index < expressions.size(); index++) { expression= expressions.get(index); descendant= (ConstraintVariable2) expression.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (descendant != null) fModel.createSubtypeConstraint(descendant, ancestor); } } } }
Example #8
Source File: FullConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public ITypeConstraint[] create(ArrayInitializer arrayInitializer){ ITypeBinding arrayBinding= arrayInitializer.resolveTypeBinding(); Assert.isTrue(arrayBinding.isArray()); List<Expression> expressions= arrayInitializer.expressions(); List<ITypeConstraint> constraints= new ArrayList<ITypeConstraint>(); Type type= getTypeParent(arrayInitializer); ConstraintVariable typeVariable= fConstraintVariableFactory.makeTypeVariable(type); for (int i= 0; i < expressions.size(); i++) { Expression each= expressions.get(i); ITypeConstraint[] c= fTypeConstraintFactory.createSubtypeConstraint( fConstraintVariableFactory.makeExpressionOrTypeVariable(each, getContext()), typeVariable); constraints.addAll(Arrays.asList(c)); } return constraints.toArray(new ITypeConstraint[constraints.size()]); }
Example #9
Source File: ExtractTempRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private RefactoringStatus checkExpression() throws JavaModelException { Expression selectedExpression= getSelectedExpression().getAssociatedExpression(); if (selectedExpression != null) { final ASTNode parent= selectedExpression.getParent(); if (selectedExpression instanceof NullLiteral) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals); } else if (selectedExpression instanceof ArrayInitializer) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer); } else if (selectedExpression instanceof Assignment) { if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment); else return null; } else if (selectedExpression instanceof SimpleName) { if ((((SimpleName) selectedExpression)).isDeclaration()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations); if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression); } else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources); } } return null; }
Example #10
Source File: ArrayCreationWriter.java From juniversal with MIT License | 5 votes |
@Override public void write(ArrayCreation arrayCreation) { // TODO: C# doesn't support an exact equivalent to Integer[], with boxed integers (or other primitive types). // Consider disallowing arrays of that type to be created, instead forcing the dev to either create an // Object[] if they want boxed types or an int[] if they want primitive types List<?> dimensions = arrayCreation.dimensions(); // TODO: Support multidimensional arrays if (dimensions.size() > 1) throw new JUniversalException("Multidimensional arrays not currently supported"); matchAndWrite("new"); copySpaceAndComments(); writeNode(arrayCreation.getType().getElementType()); copySpaceAndComments(); matchAndWrite("["); writeNodes(arrayCreation.dimensions()); copySpaceAndComments(); matchAndWrite("]"); // TODO: Check all syntax combinations here @Nullable ArrayInitializer arrayInitializer = arrayCreation.getInitializer(); if (arrayInitializer != null) { copySpaceAndComments(); writeNode(arrayInitializer); } }
Example #11
Source File: CodeBlock.java From SimFix with GNU General Public License v2.0 | 5 votes |
private ArrayInitial visit(ArrayInitializer node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); ArrayInitial arrayInitial = new ArrayInitial(startLine, endLine, node); List<Expr> expressions = new ArrayList<>(); for(Object object : node.expressions()){ Expr expr = (Expr) process((ASTNode) object); expr.setParent(arrayInitial); expressions.add(expr); } arrayInitial.setExpressions(expressions); return arrayInitial; }
Example #12
Source File: BindingSignatureVisitor.java From JDeodorant with MIT License | 5 votes |
public boolean visit(ArrayInitializer expr) { List expressions = expr.expressions(); for (int i = 0; i < expressions.size(); i++) { handleExpression((Expression) expressions.get(i)); } return false; }
Example #13
Source File: SuppressWarningsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addRemoveUnusedSuppressWarningProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot()); if (!(coveringNode instanceof StringLiteral)) return; StringLiteral literal= (StringLiteral) coveringNode; if (coveringNode.getParent() instanceof MemberValuePair) { coveringNode= coveringNode.getParent(); } ASTNode parent= coveringNode.getParent(); ASTRewrite rewrite= ASTRewrite.create(coveringNode.getAST()); if (parent instanceof SingleMemberAnnotation) { rewrite.remove(parent, null); } else if (parent instanceof NormalAnnotation) { NormalAnnotation annot= (NormalAnnotation) parent; if (annot.values().size() == 1) { rewrite.remove(annot, null); } else { rewrite.remove(coveringNode, null); } } else if (parent instanceof ArrayInitializer) { rewrite.remove(coveringNode, null); } else { return; } String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_remove_annotation_label, literal.getLiteralValue()); Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_ANNOTATION, image); proposals.add(proposal); }
Example #14
Source File: SuppressWarningsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean addSuppressArgument(ASTRewrite rewrite, Expression value, StringLiteral newStringLiteral) { if (value instanceof ArrayInitializer) { ListRewrite listRewrite= rewrite.getListRewrite(value, ArrayInitializer.EXPRESSIONS_PROPERTY); listRewrite.insertLast(newStringLiteral, null); } else if (value instanceof StringLiteral) { ArrayInitializer newArr= rewrite.getAST().newArrayInitializer(); newArr.expressions().add(rewrite.createMoveTarget(value)); newArr.expressions().add(newStringLiteral); rewrite.replace(value, newArr, null); } else { return false; } return true; }
Example #15
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ITypeBinding getTargetTypeForArrayInitializer(ArrayInitializer arrayInitializer) { ASTNode initializerParent= arrayInitializer.getParent(); while (initializerParent instanceof ArrayInitializer) { initializerParent= initializerParent.getParent(); } if (initializerParent instanceof ArrayCreation) { return ((ArrayCreation) initializerParent).getType().getElementType().resolveBinding(); } else if (initializerParent instanceof VariableDeclaration) { ITypeBinding typeBinding= ((VariableDeclaration) initializerParent).getName().resolveTypeBinding(); if (typeBinding != null) { return typeBinding.getElementType(); } } return null; }
Example #16
Source File: CodeAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected final void checkSelectedNodes() { super.checkSelectedNodes(); RefactoringStatus status= getStatus(); if (status.hasFatalError()) return; ASTNode node= getFirstSelectedNode(); if (node instanceof ArrayInitializer) { status.addFatalError(RefactoringCoreMessages.CodeAnalyzer_array_initializer, JavaStatusContext.create(fCUnit, node)); } }
Example #17
Source File: IntroduceParameterRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private RefactoringStatus checkExpression() { //TODO: adjust error messages (or generalize for all refactorings on expression-selections?) Expression selectedExpression= fSelectedExpression; if (selectedExpression instanceof Name && selectedExpression.getParent() instanceof ClassInstanceCreation) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_name_in_new); //TODO: let's just take the CIC automatically (no ambiguity -> no problem -> no dialog ;-) if (selectedExpression instanceof NullLiteral) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals); } else if (selectedExpression instanceof ArrayInitializer) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer); } else if (selectedExpression instanceof Assignment) { if (selectedExpression.getParent() instanceof Expression) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment); else return null; } else if (selectedExpression instanceof SimpleName){ if ((((SimpleName)selectedExpression)).isDeclaration()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations); if (selectedExpression.getParent() instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || selectedExpression.getParent() instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression); } return null; }
Example #18
Source File: PromoteTempToFieldRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Expression getTempInitializerCopy(ASTRewrite rewrite) { final Expression initializer= (Expression) rewrite.createCopyTarget(getTempInitializer()); if (initializer instanceof ArrayInitializer && ASTNodes.getDimensions(fTempDeclarationNode) > 0) { ArrayCreation arrayCreation= rewrite.getAST().newArrayCreation(); arrayCreation.setType((ArrayType) ASTNodeFactory.newType(rewrite.getAST(), fTempDeclarationNode)); arrayCreation.setInitializer((ArrayInitializer) initializer); return arrayCreation; } return initializer; }
Example #19
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(ArrayInitializer node) { if (skipNode(node)) { return; } processSequential(node, node.expressions()); }
Example #20
Source File: SuperTypeConstraintsCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final void endVisit(final ArrayCreation node) { final ConstraintVariable2 ancestor= (ConstraintVariable2) node.getType().getProperty(PROPERTY_CONSTRAINT_VARIABLE); node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor); final ArrayInitializer initializer= node.getInitializer(); if (initializer != null) { final ConstraintVariable2 descendant= (ConstraintVariable2) initializer.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (descendant != null) fModel.createSubtypeConstraint(descendant, ancestor); } }
Example #21
Source File: ExtractTempRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private RefactoringStatus checkExpression() throws JavaModelException { Expression selectedExpression = getSelectedExpression().getAssociatedExpression(); if (selectedExpression != null) { final ASTNode parent = selectedExpression.getParent(); if (selectedExpression instanceof NullLiteral) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals); } else if (selectedExpression instanceof ArrayInitializer) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer); } else if (selectedExpression instanceof Assignment) { if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression)) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment); } else { return null; } } else if (selectedExpression instanceof SimpleName) { if ((((SimpleName) selectedExpression)).isDeclaration()) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations); } if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression); } } else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources); } } return null; }
Example #22
Source File: ExtractFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private RefactoringStatus checkExpression() throws JavaModelException { Expression selectedExpression = getSelectedExpression().getAssociatedExpression(); if (selectedExpression != null) { final ASTNode parent = selectedExpression.getParent(); if (selectedExpression instanceof NullLiteral) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals); } else if (selectedExpression instanceof ArrayInitializer) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer); } else if (selectedExpression instanceof Assignment) { if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression)) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment); } else { return null; } } else if (selectedExpression instanceof SimpleName) { if ((((SimpleName) selectedExpression)).isDeclaration()) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations); } if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression); } } else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources); } } return null; }
Example #23
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(final ArrayInitializer node) { this.appendToBuffer("#["); this.visitAllSeparatedByComma(node.expressions()); this.appendToBuffer("]"); return false; }
Example #24
Source File: JavaASTVisitor.java From SnowGraph with Apache License 2.0 | 4 votes |
private void parseExpression(MethodInfo methodInfo, Expression expression) { if (expression == null) { return; }//System.out.println(expression.toString()+" "+Annotation.nodeClassForType(expression.getNodeType())); if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { List<Expression> expressions = ((ArrayInitializer) expression).expressions(); for (Expression expression2 : expressions) { parseExpression(methodInfo, expression2); } } if (expression.getNodeType() == ASTNode.CAST_EXPRESSION) { parseExpression(methodInfo, ((CastExpression) expression).getExpression()); } if (expression.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION) { parseExpression(methodInfo, ((ConditionalExpression) expression).getExpression()); parseExpression(methodInfo, ((ConditionalExpression) expression).getElseExpression()); parseExpression(methodInfo, ((ConditionalExpression) expression).getThenExpression()); } if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) { parseExpression(methodInfo, ((InfixExpression) expression).getLeftOperand()); parseExpression(methodInfo, ((InfixExpression) expression).getRightOperand()); } if (expression.getNodeType() == ASTNode.INSTANCEOF_EXPRESSION) { parseExpression(methodInfo, ((InstanceofExpression) expression).getLeftOperand()); } if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) { parseExpression(methodInfo, ((ParenthesizedExpression) expression).getExpression()); } if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) { parseExpression(methodInfo, ((PostfixExpression) expression).getOperand()); } if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) { parseExpression(methodInfo, ((PrefixExpression) expression).getOperand()); } if (expression.getNodeType() == ASTNode.THIS_EXPRESSION) { parseExpression(methodInfo, ((ThisExpression) expression).getQualifier()); } if (expression.getNodeType() == ASTNode.METHOD_INVOCATION) { List<Expression> arguments = ((MethodInvocation) expression).arguments(); IMethodBinding methodBinding = ((MethodInvocation) expression).resolveMethodBinding(); if (methodBinding != null) methodInfo.methodCalls.add(methodBinding); for (Expression exp : arguments) parseExpression(methodInfo, exp); parseExpression(methodInfo, ((MethodInvocation) expression).getExpression()); } if (expression.getNodeType() == ASTNode.ASSIGNMENT) { parseExpression(methodInfo, ((Assignment) expression).getLeftHandSide()); parseExpression(methodInfo, ((Assignment) expression).getRightHandSide()); } if (expression.getNodeType() == ASTNode.QUALIFIED_NAME) { if (((QualifiedName) expression).getQualifier().resolveTypeBinding() != null) { String name = ((QualifiedName) expression).getQualifier().resolveTypeBinding().getQualifiedName() + "." + ((QualifiedName) expression).getName().getIdentifier(); methodInfo.fieldUsesSet.add(name); } parseExpression(methodInfo, ((QualifiedName) expression).getQualifier()); } }
Example #25
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(ArrayInitializer node) { if (skipNode(node)) return; processSequential(node, node.expressions()); }
Example #26
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 4 votes |
private void handleExpression(Expression expression) { if (expression instanceof ArrayAccess) { visit((ArrayAccess) expression); } else if (expression instanceof ArrayCreation) { visit((ArrayCreation) expression); } else if (expression instanceof ArrayInitializer) { visit((ArrayInitializer) expression); } else if (expression instanceof Assignment) { visit((Assignment) expression); } else if (expression instanceof BooleanLiteral) { visit((BooleanLiteral) expression); } else if (expression instanceof CastExpression) { visit((CastExpression) expression); } else if (expression instanceof CharacterLiteral) { visit((CharacterLiteral) expression); } else if (expression instanceof ClassInstanceCreation) { visit((ClassInstanceCreation) expression); } else if (expression instanceof ConditionalExpression) { visit((ConditionalExpression) expression); } else if (expression instanceof FieldAccess) { visit((FieldAccess) expression); } else if (expression instanceof InfixExpression) { visit((InfixExpression) expression); } else if (expression instanceof InstanceofExpression) { visit((InstanceofExpression) expression); } else if (expression instanceof MethodInvocation) { visit((MethodInvocation) expression); } else if (expression instanceof NullLiteral) { visit((NullLiteral) expression); } else if (expression instanceof NumberLiteral) { visit((NumberLiteral) expression); } else if (expression instanceof ParenthesizedExpression) { visit((ParenthesizedExpression) expression); } else if (expression instanceof PostfixExpression) { visit((PostfixExpression) expression); } else if (expression instanceof PrefixExpression) { visit((PrefixExpression) expression); } else if ((expression instanceof QualifiedName)) { visit((QualifiedName) expression); } else if (expression instanceof SimpleName) { visit((SimpleName) expression); } else if (expression instanceof StringLiteral) { visit((StringLiteral) expression); } else if (expression instanceof SuperFieldAccess) { visit((SuperFieldAccess) expression); } else if (expression instanceof SuperMethodInvocation) { visit((SuperMethodInvocation) expression); } else if (expression instanceof ThisExpression) { visit((ThisExpression) expression); } else if (expression instanceof TypeLiteral) { visit((TypeLiteral) expression); } else if (expression instanceof VariableDeclarationExpression) { visit((VariableDeclarationExpression) expression); } }
Example #27
Source File: BindingSignatureVisitor.java From JDeodorant with MIT License | 4 votes |
private void handleExpression(Expression expression) { if (expression instanceof ArrayAccess) { visit((ArrayAccess) expression); } else if (expression instanceof ArrayCreation) { visit((ArrayCreation) expression); } else if (expression instanceof ArrayInitializer) { visit((ArrayInitializer) expression); } else if (expression instanceof Assignment) { visit((Assignment) expression); } else if (expression instanceof BooleanLiteral) { visit((BooleanLiteral) expression); } else if (expression instanceof CastExpression) { visit((CastExpression) expression); } else if (expression instanceof CharacterLiteral) { visit((CharacterLiteral) expression); } else if (expression instanceof ClassInstanceCreation) { visit((ClassInstanceCreation) expression); } else if (expression instanceof ConditionalExpression) { visit((ConditionalExpression) expression); } else if (expression instanceof FieldAccess) { visit((FieldAccess) expression); } else if (expression instanceof InfixExpression) { visit((InfixExpression) expression); } else if (expression instanceof InstanceofExpression) { visit((InstanceofExpression) expression); } else if (expression instanceof MethodInvocation) { visit((MethodInvocation) expression); } else if (expression instanceof NullLiteral) { visit((NullLiteral) expression); } else if (expression instanceof NumberLiteral) { visit((NumberLiteral) expression); } else if (expression instanceof ParenthesizedExpression) { visit((ParenthesizedExpression) expression); } else if (expression instanceof PostfixExpression) { visit((PostfixExpression) expression); } else if (expression instanceof PrefixExpression) { visit((PrefixExpression) expression); } else if ((expression instanceof QualifiedName)) { visit((QualifiedName) expression); } else if (expression instanceof SimpleName) { visit((SimpleName) expression); } else if (expression instanceof StringLiteral) { visit((StringLiteral) expression); } else if (expression instanceof SuperFieldAccess) { visit((SuperFieldAccess) expression); } else if (expression instanceof SuperMethodInvocation) { visit((SuperMethodInvocation) expression); } else if (expression instanceof ThisExpression) { visit((ThisExpression) expression); } else if (expression instanceof TypeLiteral) { visit((TypeLiteral) expression); } else if (expression instanceof VariableDeclarationExpression) { visit((VariableDeclarationExpression) expression); } }
Example #28
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public boolean visit(final ArrayCreation node) { ArrayType at = node.getType(); int dims = at.getDimensions(); if ((dims > 1)) { StringConcatenation _builder = new StringConcatenation(); _builder.append("/* FIXME Only one dimensional arrays are supported. "); _builder.append(node); _builder.append("*/"); this.appendToBuffer(_builder.toString()); this.addProblem(node, "Only one dimension arrays are supported."); return false; } ArrayInitializer _initializer = node.getInitializer(); boolean _tripleNotEquals = (_initializer != null); if (_tripleNotEquals) { if (this.fallBackStrategy) { this.appendToBuffer("("); } node.getInitializer().accept(this); if (this.fallBackStrategy) { this.appendToBuffer(" as "); at.accept(this); this.appendToBuffer(")"); } } else { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("new"); String _xifexpression = null; boolean _isPrimitiveType = node.getType().getElementType().isPrimitiveType(); if (_isPrimitiveType) { Type _elementType = node.getType().getElementType(); _xifexpression = StringExtensions.toFirstUpper(((PrimitiveType) _elementType).getPrimitiveTypeCode().toString()); } _builder_1.append(_xifexpression); _builder_1.append("ArrayOfSize("); this.appendToBuffer(_builder_1.toString()); List _dimensions = node.dimensions(); (((Expression[])Conversions.unwrapArray(((Iterable<Expression>) _dimensions), Expression.class))[0]).accept(this); this.appendToBuffer(")"); } return false; }
Example #29
Source File: TreedBuilder.java From compiler with Apache License 2.0 | 4 votes |
@Override public boolean visit(ArrayInitializer node) { if (node.expressions().size() > 10) return false; return super.visit(node); }
Example #30
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(ArrayInitializer node) { return visitNode(node); }