com.intellij.psi.PsiReturnStatement Java Examples
The following examples show how to use
com.intellij.psi.PsiReturnStatement.
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: RequiredPropAnnotator.java From litho with Apache License 2.0 | 6 votes |
/** * If element is a {@link PsiStatement} with {@code Component.create()} call, finds missing * required props for it. * * @param element element to verify * @param errorHandler handles a list of missing required props and reference to the {@code * Component.create()} call in the statement * @param generatedClassResolver returns generated Litho class, or null if the provided method * doesn't belong to any */ static void annotate( PsiElement element, BiConsumer<Collection<String>, PsiReferenceExpression> errorHandler, Function<PsiMethodCallExpression, PsiClass> generatedClassResolver) { if (element instanceof PsiDeclarationStatement) { Arrays.stream(((PsiDeclarationStatement) element).getDeclaredElements()) .filter(PsiVariable.class::isInstance) .map(declaredVariable -> ((PsiVariable) declaredVariable).getInitializer()) .forEach( expression -> handleIfMethodCall(expression, errorHandler, generatedClassResolver)); } else if (element instanceof PsiExpressionStatement) { handleIfMethodCall( ((PsiExpressionStatement) element).getExpression(), errorHandler, generatedClassResolver); } else if (element instanceof PsiReturnStatement) { handleIfMethodCall( ((PsiReturnStatement) element).getReturnValue(), errorHandler, generatedClassResolver); } }
Example #2
Source File: PsiJavaElementVisitor.java From KodeBeagle with Apache License 2.0 | 6 votes |
@Override public final void visitElement(final PsiElement element) { super.visitElement(element); if (startOffset <= element.getTextOffset() && element.getTextOffset() <= endOffset) { if (element.getNode().getElementType().equals(JavaElementType.FIELD)) { visitPsiFields((PsiField) element); } else if (element.getNode().getElementType(). equals(JavaElementType.DECLARATION_STATEMENT)) { visitPsiDeclarationStatement((PsiDeclarationStatement) element); } else if (element.getNode().getElementType().equals(JavaElementType.CATCH_SECTION)) { visitPsiCatchSection((PsiCatchSection) element); } else if (element.getNode().getElementType(). equals(JavaElementType.RETURN_STATEMENT)) { visitPsiReturnStatement((PsiReturnStatement) element); } else { visitExpression(element); } } }
Example #3
Source File: PsiJavaElementVisitor.java From KodeBeagle with Apache License 2.0 | 5 votes |
private void visitPsiReturnStatement(final PsiReturnStatement element) { PsiExpression returnValue = element.getReturnValue(); if (returnValue != null) { PsiType returnType = returnValue.getType(); if (returnType != null) { String qualifiedName = removeSpecialSymbols(returnType.getCanonicalText()); addInMap(qualifiedName, emptySet); } } }
Example #4
Source File: ReturnStatementTranslator.java From java2typescript with Apache License 2.0 | 5 votes |
public static void translate(PsiReturnStatement element, TranslationContext ctx) { ctx.print("return"); if (element.getReturnValue() != null) { ctx.append(' '); ExpressionTranslator.translate(element.getReturnValue(),ctx); } ctx.append(";\n"); }
Example #5
Source File: InstanceOfBranchingStatement.java From IntelliJDeodorant with MIT License | 4 votes |
public boolean instanceOf(PsiStatement statement) { return statement instanceof PsiBreakStatement || statement instanceof PsiContinueStatement || statement instanceof PsiReturnStatement; }
Example #6
Source File: InstanceOfReturnStatement.java From IntelliJDeodorant with MIT License | 4 votes |
public boolean instanceOf(PsiStatement statement) { return statement instanceof PsiReturnStatement; }