Java 类com.intellij.psi.PsiSynchronizedStatement 实例源码

项目:intellij-ce-playground    文件:SynchronizeOnLockInspection.java   
@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);
}
项目:tools-idea    文件:NestedSynchronizedStatementInspection.java   
@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);
}
项目:tools-idea    文件:EmptySynchronizedStatementInspection.java   
@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);
}
项目:tools-idea    文件:SynchronizeOnLockInspection.java   
@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);
}
项目:consulo-java    文件:MissingSynchronizedBodyFixer.java   
@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(), "{}");
}
项目:consulo-java    文件:NestedSynchronizedStatementInspection.java   
@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);
}
项目:consulo-java    文件:EmptySynchronizedStatementInspection.java   
@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);
}
项目:consulo-java    文件:SynchronizeOnLockInspection.java   
@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);
}
项目:intellij-ce-playground    文件:JavaSynchronizedUnwrapper.java   
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
  PsiCodeBlock body = ((PsiSynchronizedStatement)element).getBody();
  context.extractFromCodeBlock(body, element);

  context.delete(element);
}
项目:intellij-ce-playground    文件:MissingSynchronizedBodyFixer.java   
@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(), "{}");
}
项目:intellij-ce-playground    文件:NestedSynchronizedStatementInspection.java   
@Override
public void visitSynchronizedStatement(@NotNull PsiSynchronizedStatement statement) {
  super.visitSynchronizedStatement(statement);
  if (isNestedStatement(statement, PsiSynchronizedStatement.class)) {
    registerStatementError(statement);
  }
}
项目:intellij-ce-playground    文件:EmptySynchronizedStatementInspection.java   
@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);
}
项目:tools-idea    文件:JavaSynchronizedUnwrapper.java   
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
  PsiCodeBlock body = ((PsiSynchronizedStatement)element).getBody();
  context.extractFromCodeBlock(body, element);

  context.delete(element);
}
项目:tools-idea    文件:MissingSynchronizedBodyFixer.java   
@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(), "{}");
}
项目:consulo-java    文件:JavaSynchronizedUnwrapper.java   
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
  PsiCodeBlock body = ((PsiSynchronizedStatement)element).getBody();
  context.extractFromCodeBlock(body, element);

  context.delete(element);
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
    mVisitor.report("PsiSynchronizedStatement", statement.getText(), statement);
    super.visitStatement(statement);
}
项目:intellij-ce-playground    文件:JavaSynchronizedUnwrapper.java   
@Override
public boolean isApplicableTo(PsiElement e) {
  return e instanceof PsiSynchronizedStatement;
}
项目:tools-idea    文件:JavaSynchronizedUnwrapper.java   
@Override
public boolean isApplicableTo(PsiElement e) {
  return e instanceof PsiSynchronizedStatement;
}
项目:consulo-java    文件:JavaSynchronizedUnwrapper.java   
@Override
public boolean isApplicableTo(PsiElement e) {
  return e instanceof PsiSynchronizedStatement;
}