Java 类com.intellij.psi.impl.source.jsp.jspJava.JspTemplateStatement 实例源码

项目:intellij-ce-playground    文件:StatementMover.java   
private static boolean statementCanBePlacedAlong(final PsiElement element) {
  if (element instanceof JspTemplateStatement) {
    PsiElement neighbour = element.getPrevSibling();
    // we can place statement inside scriptlet only
    return neighbour != null && !(neighbour instanceof JspTemplateStatement);
  }
  if (element instanceof PsiBlockStatement) return false;
  final PsiElement parent = element.getParent();
  if (parent instanceof JspClassLevelDeclarationStatement) return false;
  if (parent instanceof PsiCodeBlock) return true;
  if (parent instanceof PsiIfStatement &&
      (element == ((PsiIfStatement)parent).getThenBranch() || element == ((PsiIfStatement)parent).getElseBranch())) {
    return true;
  }
  if (parent instanceof PsiWhileStatement && element == ((PsiWhileStatement)parent).getBody()) {
    return true;
  }
  if (parent instanceof PsiDoWhileStatement && element == ((PsiDoWhileStatement)parent).getBody()) {
    return true;
  }
  // know nothing about that
  return false;
}
项目:tools-idea    文件:StatementMover.java   
private static boolean statementCanBePlacedAlong(final PsiElement element) {
  if (element instanceof JspTemplateStatement) {
    PsiElement neighbour = element.getPrevSibling();
    // we can place statement inside scriptlet only
    return neighbour != null && !(neighbour instanceof JspTemplateStatement);
  }
  if (element instanceof PsiBlockStatement) return false;
  final PsiElement parent = element.getParent();
  if (parent instanceof JspClassLevelDeclarationStatement) return false;
  if (parent instanceof PsiCodeBlock) return true;
  if (parent instanceof PsiIfStatement &&
      (element == ((PsiIfStatement)parent).getThenBranch() || element == ((PsiIfStatement)parent).getElseBranch())) {
    return true;
  }
  if (parent instanceof PsiWhileStatement && element == ((PsiWhileStatement)parent).getBody()) {
    return true;
  }
  if (parent instanceof PsiDoWhileStatement && element == ((PsiDoWhileStatement)parent).getBody()) {
    return true;
  }
  // know nothing about that
  return false;
}