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

项目:intellij-ce-playground    文件:ModifierChooser.java   
private static boolean shouldSuggestModifiers(PsiElement element) {
  PsiElement parent = element.getParent();
  while (parent != null && (parent instanceof PsiJavaCodeReferenceElement ||
                            parent instanceof PsiErrorElement || parent instanceof PsiTypeElement ||
                            parent instanceof PsiMethod || parent instanceof PsiVariable ||
                            parent instanceof PsiDeclarationStatement || parent instanceof PsiImportList ||
                            parent instanceof PsiDocComment ||
                            element.getText().equals(parent.getText()))) {
    parent = parent.getParent();
    if (parent instanceof JspClassLevelDeclarationStatement) {
      parent = parent.getContext();
    }
  }

  if (parent == null) return false;

  PsiElement prev = FilterPositionUtil.searchNonSpaceNonCommentBack(element);

  if (parent instanceof PsiJavaFile || parent instanceof PsiClass) {
    if (prev == null || JavaKeywordCompletion.END_OF_BLOCK.getValue().isAcceptable(element, prev.getParent())) {
      return true;
    }
  }

  return false;
}
项目: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    文件:ModifierChooser.java   
private static boolean shouldSuggestModifiers(PsiElement element) {
  PsiElement parent = element.getParent();
  while (parent != null && (parent instanceof PsiJavaCodeReferenceElement ||
                            parent instanceof PsiErrorElement || parent instanceof PsiTypeElement ||
                            parent instanceof PsiMethod || parent instanceof PsiVariable ||
                            parent instanceof PsiDeclarationStatement || parent instanceof PsiImportList ||
                            parent instanceof PsiDocComment ||
                            element.getText().equals(parent.getText()))) {
    parent = parent.getParent();
    if (parent instanceof JspClassLevelDeclarationStatement) {
      parent = parent.getContext();
    }
  }

  if (parent == null) return false;

  PsiElement prev = FilterPositionUtil.searchNonSpaceNonCommentBack(element);

  if (parent instanceof PsiJavaFile || parent instanceof PsiClass) {
    if (prev == null || JavaCompletionData.END_OF_BLOCK.isAcceptable(element, prev.getParent())) {
      return true;
    }
  }

  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;
}
项目:consulo-javaee    文件:JspClassImpl.java   
@NotNull
@Override
public List<PsiMethod> getOwnMethods()
{
    List<PsiMethod> methods = new ArrayList<>();
    PsiStatement[] statements = getHolderMethod().getBody().getStatements();
    for(PsiStatement statement : statements)
    {
        if(statement instanceof JspClassLevelDeclarationStatement)
        {
            statement.acceptChildren(new JavaElementVisitor()
            {
                @Override
                public void visitMethod(PsiMethod method)
                {
                    methods.add(method);
                }
            });
        }
    }
    return methods;
}
项目:consulo-javaee    文件:JspClassImpl.java   
@NotNull
@Override
@RequiredReadAction
public List<PsiField> getOwnFields()
{
    List<PsiField> fields = buildImplicitFields();
    PsiStatement[] statements = getHolderMethod().getBody().getStatements();
    for(PsiStatement statement : statements)
    {
        if(statement instanceof JspClassLevelDeclarationStatement)
        {
            statement.acceptChildren(new JavaElementVisitor()
            {
                @Override
                public void visitField(PsiField field)
                {
                    fields.add(field);
                }
            });
        }
    }
    return fields;
}
项目:consulo-javaee    文件:JspClassImpl.java   
@NotNull
@Override
@RequiredReadAction
public List<PsiClass> getOwnInnerClasses()
{
    List<PsiClass> classes = new ArrayList<>();

    PsiStatement[] statements = getHolderMethod().getBody().getStatements();
    for(PsiStatement statement : statements)
    {
        if(statement instanceof JspClassLevelDeclarationStatement)
        {
            statement.acceptChildren(new JavaElementVisitor()
            {
                @Override
                public void visitClass(PsiClass aClass)
                {
                    classes.add(aClass);
                }
            });
        }
    }
    return classes;
}
项目:intellij-ce-playground    文件:JavaKeywordCompletion.java   
@NotNull
@Override
protected ElementFilter compute() {
  return new OrFilter(
    new AfterElementFilter(new TextFilter("{")),
    new ScopeFilter(new ClassFilter(JspClassLevelDeclarationStatement.class)));
}
项目:intellij-ce-playground    文件:JavaSpacePropertyProcessor.java   
@Override
public void visitStatement(PsiStatement statement) {
  if (myRole2 == ChildRole.CLOSING_SEMICOLON) {
    createSpaceInCode(false);
  }

  if (statement instanceof JspClassLevelDeclarationStatement) {
    processClassBody();
  }
}
项目:tools-idea    文件:JavaSpacePropertyProcessor.java   
@Override public void visitStatement(PsiStatement statement) {
  if (myRole2 == ChildRole.CLOSING_SEMICOLON) {
    createSpaceInCode(false);
  }

  if (statement instanceof JspClassLevelDeclarationStatement) {
    processClassBody();
  }
}