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

项目:intellij-ce-playground    文件:CaseColonFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
  if (psiElement instanceof PsiSwitchLabelStatement &&
      ((PsiSwitchLabelStatement)psiElement).getCaseValue() != null &&
      !psiElement.getText().endsWith(":")) {
    editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), ":");
  }
}
项目:intellij-ce-playground    文件:DefaultNotLastCaseInSwitchInspection.java   
@Override
public void visitSwitchStatement(
  @NotNull PsiSwitchStatement statement) {
  super.visitSwitchStatement(statement);
  final PsiCodeBlock body = statement.getBody();
  if (body == null) {
    return;
  }
  final PsiStatement[] statements = body.getStatements();
  boolean labelSeen = false;
  for (int i = statements.length - 1; i >= 0; i--) {
    final PsiStatement child = statements[i];
    if (child instanceof PsiSwitchLabelStatement) {
      final PsiSwitchLabelStatement label =
        (PsiSwitchLabelStatement)child;
      if (label.isDefaultCase()) {
        if (labelSeen) {
          registerStatementError(label);
        }
        return;
      }
      else {
        labelSeen = true;
      }
    }
  }
}
项目:tools-idea    文件:DefaultNotLastCaseInSwitchInspection.java   
@Override
public void visitSwitchStatement(
  @NotNull PsiSwitchStatement statement) {
  super.visitSwitchStatement(statement);
  final PsiCodeBlock body = statement.getBody();
  if (body == null) {
    return;
  }
  final PsiStatement[] statements = body.getStatements();
  boolean labelSeen = false;
  for (int i = statements.length - 1; i >= 0; i--) {
    final PsiStatement child = statements[i];
    if (child instanceof PsiSwitchLabelStatement) {
      final PsiSwitchLabelStatement label =
        (PsiSwitchLabelStatement)child;
      if (label.isDefaultCase()) {
        if (labelSeen) {
          registerStatementError(label);
        }
        return;
      }
      else {
        labelSeen = true;
      }
    }
  }
}
项目:consulo-java    文件:SwitchLabelColonFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException
{
    if(psiElement instanceof PsiSwitchLabelStatement && !psiElement.getText().endsWith(":"))
    {
        PsiSwitchLabelStatement statement = (PsiSwitchLabelStatement) psiElement;
        if(statement.getCaseValue() != null || statement.isDefaultCase())
        {
            editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), ":");
        }
    }
}
项目:consulo-java    文件:DefaultNotLastCaseInSwitchInspection.java   
@Override
public void visitSwitchStatement(
  @NotNull PsiSwitchStatement statement) {
  super.visitSwitchStatement(statement);
  final PsiCodeBlock body = statement.getBody();
  if (body == null) {
    return;
  }
  final PsiStatement[] statements = body.getStatements();
  boolean labelSeen = false;
  for (int i = statements.length - 1; i >= 0; i--) {
    final PsiStatement child = statements[i];
    if (child instanceof PsiSwitchLabelStatement) {
      final PsiSwitchLabelStatement label =
        (PsiSwitchLabelStatement)child;
      if (label.isDefaultCase()) {
        if (labelSeen) {
          registerStatementError(label);
        }
        return;
      }
      else {
        labelSeen = true;
      }
    }
  }
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
    mVisitor.report("PsiSwitchLabelStatement", statement.getText(), statement);
    super.visitStatement(statement);
}