org.eclipse.jdt.core.dom.ReturnStatement Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.ReturnStatement.
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: ReturnTypeSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public ITypeBinding getTypeBinding(AST ast) { boolean couldBeObject= false; for (int i= 0; i < fResult.size(); i++) { ReturnStatement node= fResult.get(i); Expression expr= node.getExpression(); if (expr != null) { ITypeBinding binding= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (binding != null) { return binding; } else { couldBeObject= true; } } else { return ast.resolveWellKnownType("void"); //$NON-NLS-1$ } } if (couldBeObject) { return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } return ast.resolveWellKnownType("void"); //$NON-NLS-1$ }
Example #2
Source File: MethodObject.java From JDeodorant with MIT License | 6 votes |
public FieldInstructionObject isGetter() { if(getMethodBody() != null) { List<AbstractStatement> abstractStatements = getMethodBody().getCompositeStatement().getStatements(); if(abstractStatements.size() == 1 && abstractStatements.get(0) instanceof StatementObject) { StatementObject statementObject = (StatementObject)abstractStatements.get(0); Statement statement = statementObject.getStatement(); if(statement instanceof ReturnStatement) { ReturnStatement returnStatement = (ReturnStatement) statement; if((returnStatement.getExpression() instanceof SimpleName || returnStatement.getExpression() instanceof FieldAccess) && statementObject.getFieldInstructions().size() == 1 && statementObject.getMethodInvocations().size() == 0 && statementObject.getLocalVariableDeclarations().size() == 0 && statementObject.getLocalVariableInstructions().size() == 0 && this.constructorObject.parameterList.size() == 0) { return statementObject.getFieldInstructions().get(0); } } } } return null; }
Example #3
Source File: ReturnTypeSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public ITypeBinding getTypeBinding(AST ast) { boolean couldBeObject= false; for (int i= 0; i < fResult.size(); i++) { ReturnStatement node= fResult.get(i); Expression expr= node.getExpression(); if (expr != null) { ITypeBinding binding= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (binding != null) { return binding; } else { couldBeObject= true; } } else { return ast.resolveWellKnownType("void"); //$NON-NLS-1$ } } if (couldBeObject) { return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } return ast.resolveWellKnownType("void"); //$NON-NLS-1$ }
Example #4
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public boolean visit(final ReturnStatement node) { this.appendToBuffer("return"); Expression _expression = node.getExpression(); boolean _tripleNotEquals = (_expression != null); if (_tripleNotEquals) { this.appendSpaceToBuffer(); node.getExpression().accept(this); this.appendSpaceToBuffer(); } else { final ASTNode parent = node.getParent(); final boolean isIfElse = ((parent instanceof IfStatement) && (((IfStatement) parent).getElseStatement() != null)); if (((!isIfElse) && (!(parent instanceof SwitchStatement)))) { this.appendToBuffer(";"); } } return false; }
Example #5
Source File: InferTypeArgumentsConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void endVisit(ReturnStatement node) { Expression expression= node.getExpression(); if (expression == null) return; ConstraintVariable2 expressionCv= getConstraintVariable(expression); if (expressionCv == null) return; MethodDeclaration methodDeclaration= (MethodDeclaration) ASTNodes.getParent(node, ASTNode.METHOD_DECLARATION); if (methodDeclaration == null) return; IMethodBinding methodBinding= methodDeclaration.resolveBinding(); if (methodBinding == null) return; ReturnTypeVariable2 returnTypeCv= fTCModel.makeReturnTypeVariable(methodBinding); if (returnTypeCv == null) return; fTCModel.createElementEqualsConstraints(returnTypeCv, expressionCv); }
Example #6
Source File: MethodDeclarationUtility.java From JDeodorant with MIT License | 6 votes |
public static SimpleName isGetter(MethodDeclaration methodDeclaration) { Block methodBody = methodDeclaration.getBody(); List<SingleVariableDeclaration> parameters = methodDeclaration.parameters(); if(methodBody != null) { List<Statement> statements = methodBody.statements(); if(statements.size() == 1 && parameters.size() == 0) { Statement statement = statements.get(0); if(statement instanceof ReturnStatement) { ReturnStatement returnStatement = (ReturnStatement)statement; Expression returnStatementExpression = returnStatement.getExpression(); if(returnStatementExpression instanceof SimpleName) { return (SimpleName)returnStatementExpression; } else if(returnStatementExpression instanceof FieldAccess) { FieldAccess fieldAccess = (FieldAccess)returnStatementExpression; return fieldAccess.getName(); } } } } return null; }
Example #7
Source File: ReturnTypeSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static void addMethodReturnsVoidProposals(IInvocationContext context, IProblemLocationCore problem, Collection<ChangeCorrectionProposal> proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof ReturnStatement)) { return; } ReturnStatement returnStatement= (ReturnStatement) selectedNode; Expression expression= returnStatement.getExpression(); if (expression == null) { return; } BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methDecl= (MethodDeclaration) decl; Type retType= methDecl.getReturnType2(); if (retType == null || retType.resolveBinding() == null) { return; } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, IProposalRelevance.METHOD_RETURNS_VOID, proposals); } }
Example #8
Source File: PreconditionExaminer.java From JDeodorant with MIT License | 6 votes |
private void extractReturnTypeBinding(PDGNode pdgNode, List<ITypeBinding> returnedTypeBindings) { if(pdgNode instanceof PDGExitNode) { PDGExitNode exitNode = (PDGExitNode)pdgNode; ReturnStatement returnStatement = (ReturnStatement)exitNode.getASTStatement(); Expression returnedExpression = returnStatement.getExpression(); if(returnedExpression != null && !(returnedExpression instanceof NullLiteral)) { ITypeBinding typeBinding = returnedExpression.resolveTypeBinding(); if(typeBinding != null) { boolean alreadyContained = false; for(ITypeBinding binding : returnedTypeBindings) { if(binding.isEqualTo(typeBinding)) { alreadyContained = true; break; } } if(!alreadyContained) returnedTypeBindings.add(typeBinding); } } } }
Example #9
Source File: CFG.java From JDeodorant with MIT License | 6 votes |
private CFGNode createNonCompositeNode(StatementObject statement) { CFGNode currentNode; Statement astStatement = statement.getStatement(); if(astStatement instanceof ReturnStatement) currentNode = new CFGExitNode(statement); else if(astStatement instanceof SwitchCase) currentNode = new CFGSwitchCaseNode(statement); else if(astStatement instanceof BreakStatement) currentNode = new CFGBreakNode(statement); else if(astStatement instanceof ContinueStatement) currentNode = new CFGContinueNode(statement); else if(astStatement instanceof ThrowStatement) currentNode = new CFGThrowNode(statement); else currentNode = new CFGNode(statement); directlyNestedNodeInBlock(currentNode); return currentNode; }
Example #10
Source File: PreconditionExaminer.java From JDeodorant with MIT License | 6 votes |
public static Set<PDGNode> extractConditionalReturnStatements(Set<? extends GraphNode> nodes) { Set<PDGNode> conditionalReturnStatements = new TreeSet<PDGNode>(); for(GraphNode node : nodes) { PDGNode pdgNode = (PDGNode)node; CFGNode cfgNode = pdgNode.getCFGNode(); if(cfgNode instanceof CFGExitNode) { ReturnStatement returnStatement = (ReturnStatement)cfgNode.getASTStatement(); Expression expression = returnStatement.getExpression(); if(expression != null) { PDGNode controlParentNode = pdgNode.getControlDependenceParent(); if(controlParentNode instanceof PDGControlPredicateNode) { conditionalReturnStatements.add(pdgNode); } } } } return conditionalReturnStatements; }
Example #11
Source File: ReturnTypeSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static void addMethodRetunsVoidProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof ReturnStatement)) { return; } ReturnStatement returnStatement= (ReturnStatement) selectedNode; Expression expression= returnStatement.getExpression(); if (expression == null) { return; } BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methDecl= (MethodDeclaration) decl; Type retType= methDecl.getReturnType2(); if (retType == null || retType.resolveBinding() == null) { return; } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, IProposalRelevance.METHOD_RETURNS_VOID, proposals); } }
Example #12
Source File: NecessaryParenthesesChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) { if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) { // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ... return false; } if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.MESSAGE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == SwitchStatement.EXPRESSION_PROPERTY || locationInParent == SwitchCase.EXPRESSION_PROPERTY || locationInParent == ArrayAccess.INDEX_PROPERTY || locationInParent == ThrowStatement.EXPRESSION_PROPERTY || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { return false; } return true; }
Example #13
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 #14
Source File: GenerateHashCodeEqualsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private MethodDeclaration createGetOuterHelper() { String outerTypeName= fType.getDeclaringClass().getTypeDeclaration().getName(); MethodDeclaration helperMethod= fAst.newMethodDeclaration(); helperMethod.modifiers().addAll(ASTNodeFactory.newModifiers(fAst, Modifier.PRIVATE)); helperMethod.setName(fAst.newSimpleName(METHODNAME_OUTER_TYPE)); helperMethod.setConstructor(false); helperMethod.setReturnType2(fAst.newSimpleType(fAst.newSimpleName(outerTypeName))); Block body= fAst.newBlock(); helperMethod.setBody(body); ThisExpression thisExpression= fAst.newThisExpression(); thisExpression.setQualifier(fAst.newSimpleName(outerTypeName)); ReturnStatement endReturn= fAst.newReturnStatement(); endReturn.setExpression(thisExpression); body.statements().add(endReturn); return helperMethod; }
Example #15
Source File: QuickAssistProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static Block getBlockBodyForLambda(Expression bodyExpr, ITypeBinding returnTypeBinding, AST ast) { Statement statementInBlockBody; if (ast.resolveWellKnownType("void").isEqualTo(returnTypeBinding)) { //$NON-NLS-1$ ExpressionStatement expressionStatement = ast.newExpressionStatement(bodyExpr); statementInBlockBody = expressionStatement; } else { ReturnStatement returnStatement = ast.newReturnStatement(); returnStatement.setExpression(bodyExpr); statementInBlockBody = returnStatement; } Block blockBody = ast.newBlock(); blockBody.statements().add(statementInBlockBody); return blockBody; }
Example #16
Source File: SelfEncapsulateFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private MethodDeclaration createGetterMethod(AST ast, ASTRewrite rewriter, String lineDelimiter) throws CoreException { FieldDeclaration field = ASTNodes.getParent(fFieldDeclaration, FieldDeclaration.class); Type type = field.getType(); MethodDeclaration result = ast.newMethodDeclaration(); result.setName(ast.newSimpleName(fGetterName)); result.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiers())); Type returnType = DimensionRewrite.copyTypeAndAddDimensions(type, fFieldDeclaration.extraDimensions(), rewriter); result.setReturnType2(returnType); Block block = ast.newBlock(); result.setBody(block); String body = CodeGeneration.getGetterMethodBodyContent(fField.getCompilationUnit(), getTypeName(field.getParent()), fGetterName, fField.getElementName(), lineDelimiter); if (body != null) { body = body.substring(0, body.lastIndexOf(lineDelimiter)); ASTNode getterNode = rewriter.createStringPlaceholder(body, ASTNode.BLOCK); block.statements().add(getterNode); } else { ReturnStatement rs = ast.newReturnStatement(); rs.setExpression(ast.newSimpleName(fField.getElementName())); block.statements().add(rs); } if (fGenerateJavadoc) { String string = CodeGeneration.getGetterComment(fField.getCompilationUnit(), getTypeName(field.getParent()), fGetterName, fField.getElementName(), ASTNodes.asString(type), StubUtility.getBaseName(fField), lineDelimiter); if (string != null) { Javadoc javadoc = (Javadoc) fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC); result.setJavadoc(javadoc); } } return result; }
Example #17
Source File: ExtractTempRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void replaceSelectedExpressionWithTempDeclaration() throws CoreException { ASTRewrite rewrite = fCURewrite.getASTRewrite(); Expression selectedExpression = getSelectedExpression().getAssociatedExpression(); // whole expression selected Expression initializer = (Expression) rewrite.createMoveTarget(selectedExpression); VariableDeclarationStatement tempDeclaration = createTempDeclaration(initializer); ASTNode replacement; ASTNode parent = selectedExpression.getParent(); boolean isParentLambda = parent instanceof LambdaExpression; AST ast = rewrite.getAST(); if (isParentLambda) { Block blockBody = ast.newBlock(); blockBody.statements().add(tempDeclaration); if (!Bindings.isVoidType(((LambdaExpression) parent).resolveMethodBinding().getReturnType())) { List<VariableDeclarationFragment> fragments = tempDeclaration.fragments(); SimpleName varName = fragments.get(0).getName(); ReturnStatement returnStatement = ast.newReturnStatement(); returnStatement.setExpression(ast.newSimpleName(varName.getIdentifier())); blockBody.statements().add(returnStatement); } replacement = blockBody; } else if (ASTNodes.isControlStatementBody(parent.getLocationInParent())) { Block block = ast.newBlock(); block.statements().add(tempDeclaration); replacement = block; } else { replacement = tempDeclaration; } ASTNode replacee = isParentLambda || !ASTNodes.hasSemicolon((ExpressionStatement) parent, fCu) ? selectedExpression : parent; rewrite.replace(replacee, replacement, fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable)); }
Example #18
Source File: CFG.java From JDeodorant with MIT License | 5 votes |
private boolean previousNodesContainBreakOrReturn(List<CFGNode> previousNodes, CompositeStatementObject composite) { for(CFGNode previousNode : previousNodes) { Statement statement = previousNode.getASTStatement(); if((statement instanceof BreakStatement || statement instanceof ReturnStatement) && directlyNestedNode(previousNode, composite)) return true; } return false; }
Example #19
Source File: CreateDoPrivilegedBlockResolution.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private Block createRunMethodBody(ASTRewrite rewrite, ClassInstanceCreation classLoaderCreation) { AST ast = rewrite.getAST(); Block methodBody = ast.newBlock(); ReturnStatement returnStatement = ast.newReturnStatement(); List<Statement> statements = checkedList(methodBody.statements()); statements.add(returnStatement); returnStatement.setExpression((ClassInstanceCreation) rewrite.createCopyTarget(classLoaderCreation)); return methodBody; }
Example #20
Source File: BuildMethodBodyCreatorFragment.java From SparkBuilderGenerator with MIT License | 5 votes |
public Block createBody(AST ast, TypeDeclaration originalType) { ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation(); newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(originalType.getName().toString()))); newClassInstanceCreation.arguments().add(ast.newThisExpression()); ReturnStatement statement = ast.newReturnStatement(); statement.setExpression(newClassInstanceCreation); Block block = ast.newBlock(); block.statements().add(statement); return block; }
Example #21
Source File: CodeSearch.java From SimFix with GNU General Public License v2.0 | 5 votes |
public boolean visit(ReturnStatement node) { int start = _unit.getLineNumber(node.getStartPosition()); if(start == _extendedLine){ _extendedStatement = node; return false; } return true; }
Example #22
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Block createMethodStub(final MethodDeclaration method, final AST ast) { final Block body= ast.newBlock(); final Expression expression= ASTNodeFactory.newDefaultExpression(ast, method.getReturnType2(), method.getExtraDimensions()); if (expression != null) { final ReturnStatement returnStatement= ast.newReturnStatement(); returnStatement.setExpression(expression); body.statements().add(returnStatement); } return body; }
Example #23
Source File: SourceProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(ReturnStatement node) { Expression expression= node.getExpression(); if (!(ASTNodes.isLiteral(expression) || expression instanceof Name)) { fMustEvalReturnedExpression= true; } if (Invocations.isInvocation(expression) || expression instanceof ClassInstanceCreation) { fReturnValueNeedsLocalVariable= false; } fReturnExpressions.add(expression); return false; }
Example #24
Source File: SourceProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean needsReturnedExpressionParenthesis(ASTNode parent, StructuralPropertyDescriptor locationInParent) { ASTNode last= getLastStatement(); if (last instanceof ReturnStatement) { return NecessaryParenthesesChecker.needsParentheses(((ReturnStatement)last).getExpression(), parent, locationInParent); } return false; }
Example #25
Source File: ASTNodeMatcher.java From JDeodorant with MIT License | 5 votes |
public boolean match(ReturnStatement node, Object other) { if (node.getExpression() instanceof ConditionalExpression && other instanceof IfStatement) { TernaryControlStructure nodeTernaryControlStructure = new TernaryControlStructure(node); return ifMatch(nodeTernaryControlStructure, other); } return super.match(node, other); }
Example #26
Source File: PreconditionExaminer.java From JDeodorant with MIT License | 5 votes |
private void conditionalReturnStatement(NodeMapping nodeMapping, PDGNode node) { CFGNode cfgNode = node.getCFGNode(); if(cfgNode instanceof CFGExitNode) { ReturnStatement returnStatement = (ReturnStatement)cfgNode.getASTStatement(); if(returnStatement.getExpression() == null) { PreconditionViolation violation = new StatementPreconditionViolation(node.getStatement(), PreconditionViolationType.CONDITIONAL_RETURN_STATEMENT); nodeMapping.addPreconditionViolation(violation); preconditionViolations.add(violation); } } }
Example #27
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
Example #28
Source File: AdvancedQuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Expression getBooleanExpression(ASTNode node) { if (!(node instanceof Expression)) { return null; } // check if the node is a location where it can be negated StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == QualifiedName.NAME_PROPERTY) { node= node.getParent(); locationInParent= node.getLocationInParent(); } while (locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { node= node.getParent(); locationInParent= node.getLocationInParent(); } Expression expression= (Expression) node; if (!isBoolean(expression)) { return null; } if (expression.getParent() instanceof InfixExpression) { return expression; } if (locationInParent == Assignment.RIGHT_HAND_SIDE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == MethodInvocation.ARGUMENTS_PROPERTY || locationInParent == ConstructorInvocation.ARGUMENTS_PROPERTY || locationInParent == SuperMethodInvocation.ARGUMENTS_PROPERTY || locationInParent == EnumConstantDeclaration.ARGUMENTS_PROPERTY || locationInParent == SuperConstructorInvocation.ARGUMENTS_PROPERTY || locationInParent == ClassInstanceCreation.ARGUMENTS_PROPERTY || locationInParent == ConditionalExpression.EXPRESSION_PROPERTY || locationInParent == PrefixExpression.OPERAND_PROPERTY) { return expression; } return null; }
Example #29
Source File: FullConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public ITypeConstraint[] create(ReturnStatement returnStatement){ if (returnStatement.getExpression() == null) return new ITypeConstraint[0]; ConstraintVariable returnTypeVariable= fConstraintVariableFactory.makeReturnTypeVariable(returnStatement); return fTypeConstraintFactory.createSubtypeConstraint( fConstraintVariableFactory.makeExpressionOrTypeVariable(returnStatement.getExpression(), getContext()), returnTypeVariable); }
Example #30
Source File: StringConcatenationGenerator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void complete() throws CoreException { super.complete(); ReturnStatement returnStatement= fAst.newReturnStatement(); returnStatement.setExpression(toStringExpressionBuilder.getExpression()); toStringMethod.getBody().statements().add(returnStatement); }