@Override public void visitSynchronizedStatement( @NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); final PsiExpression lockExpression = statement.getLockExpression(); if (lockExpression == null) { return; } final String type = TypeUtils.expressionHasTypeOrSubtype( lockExpression, "java.util.concurrent.locks.Lock", "java.util.concurrent.locks.ReadWriteLock"); if (type == null) { return; } registerError(lockExpression, type); }
@Override public void visitSynchronizedStatement( @NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); final PsiElement containingSynchronizedStatement = PsiTreeUtil.getParentOfType(statement, PsiSynchronizedStatement.class); if (containingSynchronizedStatement == null) { return; } final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(statement, PsiMethod.class); final PsiMethod containingContainingMethod = PsiTreeUtil.getParentOfType(containingSynchronizedStatement, PsiMethod.class); if (containingMethod == null || containingContainingMethod == null || !containingMethod.equals(containingContainingMethod)) { return; } registerStatementError(statement); }
@Override public void visitSynchronizedStatement( @NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); if (FileTypeUtils.isInJsp(statement.getContainingFile())) { return; } final PsiCodeBlock body = statement.getBody(); if (body == null) { return; } final PsiStatement[] statements = body.getStatements(); if (statements.length > 0) { return; } registerStatementError(statement); }
@Override public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException { if(!(psiElement instanceof PsiSynchronizedStatement)) { return; } PsiSynchronizedStatement syncStatement = (PsiSynchronizedStatement) psiElement; final Document doc = editor.getDocument(); PsiElement body = syncStatement.getBody(); if(body != null) { return; } doc.insertString(syncStatement.getTextRange().getEndOffset(), "{}"); }
@Override public void visitSynchronizedStatement( @NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); /* if (JspPsiUtil.isInJspFile(statement.getContainingFile())) { return; }*/ final PsiCodeBlock body = statement.getBody(); if (body == null) { return; } final PsiStatement[] statements = body.getStatements(); if (statements.length > 0) { return; } registerStatementError(statement); }
@Override protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException { PsiCodeBlock body = ((PsiSynchronizedStatement)element).getBody(); context.extractFromCodeBlock(body, element); context.delete(element); }
@Override public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException { if (!(psiElement instanceof PsiSynchronizedStatement)) return; PsiSynchronizedStatement syncStatement = (PsiSynchronizedStatement) psiElement; final Document doc = editor.getDocument(); PsiElement body = syncStatement.getBody(); if (body != null) return; doc.insertString(syncStatement.getTextRange().getEndOffset(), "{}"); }
@Override public void visitSynchronizedStatement(@NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); if (isNestedStatement(statement, PsiSynchronizedStatement.class)) { registerStatementError(statement); } }
@Override public void visitSynchronizedStatement(@NotNull PsiSynchronizedStatement statement) { super.visitSynchronizedStatement(statement); final PsiCodeBlock body = statement.getBody(); if (body == null) { return; } final PsiStatement[] statements = body.getStatements(); if (statements.length > 0) { return; } registerStatementError(statement); }
@Override public void visitSynchronizedStatement(PsiSynchronizedStatement statement) { mVisitor.report("PsiSynchronizedStatement", statement.getText(), statement); super.visitStatement(statement); }
@Override public boolean isApplicableTo(PsiElement e) { return e instanceof PsiSynchronizedStatement; }