Search in sources :

Example 1 with PsiSynchronizedStatement

use of com.intellij.psi.PsiSynchronizedStatement in project intellij-community by JetBrains.

the class MissingSynchronizedBodyFixer method apply.

@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(), "{}");
}
Also used : PsiSynchronizedStatement(com.intellij.psi.PsiSynchronizedStatement) Document(com.intellij.openapi.editor.Document) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PsiSynchronizedStatement

use of com.intellij.psi.PsiSynchronizedStatement in project intellij-community by JetBrains.

the class JavaSynchronizedUnwrapper method doUnwrap.

@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
    PsiCodeBlock body = ((PsiSynchronizedStatement) element).getBody();
    context.extractFromCodeBlock(body, element);
    context.delete(element);
}
Also used : PsiSynchronizedStatement(com.intellij.psi.PsiSynchronizedStatement) PsiCodeBlock(com.intellij.psi.PsiCodeBlock)

Aggregations

PsiSynchronizedStatement (com.intellij.psi.PsiSynchronizedStatement)2 Document (com.intellij.openapi.editor.Document)1 PsiCodeBlock (com.intellij.psi.PsiCodeBlock)1 PsiElement (com.intellij.psi.PsiElement)1