List of usage examples for org.eclipse.jdt.core.dom AST newConditionalExpression
public ConditionalExpression newConditionalExpression()
From source file:org.eclipse.objectteams.otdt.internal.ui.assist.OTQuickFixes.java
License:Open Source License
/** * A method spec has no signature, infer the signature for a missing method * from the resolved method at the other side of the method mapping. *//*from w ww. j a v a 2s . c o m*/ private void inferMethodSignature(NewMethodCompletionProposal proposal, MethodSpec spec, IMethodBinding resolvedMethod, boolean isRoleSide) { AST ast = spec.getAST(); ImportRewrite imports = proposal.getImportRewrite(); if (imports == null) imports = proposal.createImportRewrite( (CompilationUnit) ASTResolving.findAncestor(spec, ASTNode.COMPILATION_UNIT)); ITypeBinding roleTypeBinding = ((RoleTypeDeclaration) ASTResolving.findAncestor(spec, ASTNode.ROLE_TYPE_DECLARATION)).resolveBinding(); ITypeBinding[] roles = roleTypeBinding.getDeclaringClass().getDeclaredTypes(); // preset return type and parameter types from the resolved method: ITypeBinding returnType = resolvedMethod.getReturnType(); proposal.returnType = proposal.proposeType(imports, ast, returnType, NewMethodCompletionProposal.getKEY_TYPE(), roles, isRoleSide); ITypeBinding[] parameterTypes = resolvedMethod.getParameterTypes(); proposal.parameterTypes = new Type[parameterTypes.length]; List<Expression> arguments = new ArrayList<Expression>(parameterTypes.length); for (int i = 0; i < parameterTypes.length; i++) { proposal.parameterTypes[i] = proposal.proposeType(imports, ast, parameterTypes[i], "arg_type_" + i, //$NON-NLS-1$ roles, isRoleSide); arguments.add(ast.newConditionalExpression()); // dummy expr that will be filtered out in StubUtility.getVariableNameSuggestions() } proposal.setFArguments(arguments); // ensure we will loop properly in NewMethodCorrectionProposal.addNewParameters(ASTRewrite, List, List) }
From source file:org.jboss.forge.roaster.model.impl.expressions.TernaryImpl.java
License:Open Source License
@Override public ConditionalExpression materialize(AST ast) { if (isMaterialized()) { return ternary; }//from w ww .ja v a 2 s . c o m ternary = ast.newConditionalExpression(); if (condition != null) { ternary.setExpression(wireAndGetExpression(condition, this, ast)); } if (onTrue != null) { ternary.setThenExpression(wireAndGetExpression(onTrue, this, ast)); } if (onFalse != null) { ternary.setElseExpression(wireAndGetExpression(onFalse, this, ast)); } return ternary; }