use of org.jetbrains.plugins.groovy.lang.psi.api.statements.GrSynchronizedStatement in project intellij-community by JetBrains.
the class GrSynchronizedFixer method apply.
@Override
public void apply(@NotNull Editor editor, @NotNull GroovySmartEnterProcessor processor, @NotNull PsiElement psiElement) {
GrSynchronizedStatement synchronizedStatement = PsiTreeUtil.getParentOfType(psiElement, GrSynchronizedStatement.class);
if (synchronizedStatement == null || synchronizedStatement.getBody() != null)
return;
if (!PsiTreeUtil.isAncestor(synchronizedStatement.getMonitor(), psiElement, false))
return;
final Document doc = editor.getDocument();
PsiElement eltToInsertAfter = synchronizedStatement.getRParenth();
String text = "{\n}";
if (eltToInsertAfter == null) {
eltToInsertAfter = synchronizedStatement.getMonitor();
text = "){\n}";
}
doc.insertString(eltToInsertAfter.getTextRange().getEndOffset(), text);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.GrSynchronizedStatement in project intellij-community by JetBrains.
the class GroovySynchronizedUnwrapper method doUnwrap.
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
GrOpenBlock body = ((GrSynchronizedStatement) element).getBody();
context.extractFromCodeBlock(body, element);
context.delete(element);
}
Aggregations