private static boolean labeledStatementsAreEquivalent(
     @NotNull PsiLabeledStatement statement1, @NotNull PsiLabeledStatement statement2) {
   final PsiIdentifier identifier1 = statement1.getLabelIdentifier();
   final PsiIdentifier identifier2 = statement2.getLabelIdentifier();
   final String text1 = identifier1.getText();
   final String text2 = identifier2.getText();
   return text1.equals(text2);
 }
 private static boolean continueStatementsAreEquivalent(
     @NotNull PsiContinueStatement statement1, @NotNull PsiContinueStatement statement2) {
   final PsiIdentifier identifier1 = statement1.getLabelIdentifier();
   final PsiIdentifier identifier2 = statement2.getLabelIdentifier();
   if (identifier1 == null) {
     return identifier2 == null;
   }
   if (identifier2 == null) {
     return false;
   }
   final String text1 = identifier1.getText();
   final String text2 = identifier2.getText();
   return text1.equals(text2);
 }
 @Override
 public void visitBreakStatement(@NotNull PsiBreakStatement statement) {
   final PsiIdentifier labelIdentifier = statement.getLabelIdentifier();
   if (labelIdentifier == null) {
     return;
   }
   final String labelText = labelIdentifier.getText();
   if (labelText == null || labelText.length() == 0) {
     return;
   }
   final PsiStatement exitedStatement = statement.findExitedStatement();
   if (exitedStatement == null) {
     return;
   }
   final PsiStatement labelEnabledParent =
       PsiTreeUtil.getParentOfType(
           statement,
           PsiForStatement.class,
           PsiDoWhileStatement.class,
           PsiForeachStatement.class,
           PsiWhileStatement.class,
           PsiSwitchStatement.class);
   if (labelEnabledParent == null) {
     return;
   }
   if (exitedStatement.equals(labelEnabledParent)) {
     registerStatementError(statement);
   }
 }
Ejemplo n.º 4
0
 @NotNull
 public static Identifier identifierToIdentifier(@Nullable PsiIdentifier identifier) {
   if (identifier == null) return Identifier.EMPTY_IDENTIFIER;
   return new IdentifierImpl(identifier.getText());
 }