Cleanup (formatting)

This commit is contained in:
Roman Shevchenko
2016-06-30 17:59:42 +03:00
parent 45f6d1425b
commit a57358e2e3
@@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessarySemicolonInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
public String getDisplayName() {
@@ -159,25 +158,18 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
registerError(element, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
private void findUnnecessarySemicolonsAfterEnumConstants(
@NotNull PsiClass aClass) {
private void findUnnecessarySemicolonsAfterEnumConstants(@NotNull PsiClass aClass) {
PsiElement child = aClass.getFirstChild();
while (child != null) {
if (child instanceof PsiJavaToken) {
final PsiJavaToken token = (PsiJavaToken)child;
final IElementType tokenType = token.getTokenType();
if (tokenType.equals(JavaTokenType.SEMICOLON)) {
final PsiElement prevSibling =
skipBackwardWhiteSpacesAndComments(child);
final PsiElement prevSibling = skipBackwardWhiteSpacesAndComments(child);
if (!(prevSibling instanceof PsiEnumConstant)) {
if (prevSibling instanceof PsiJavaToken) {
final PsiJavaToken javaToken =
(PsiJavaToken)prevSibling;
final IElementType prevTokenType =
javaToken.getTokenType();
if (!JavaTokenType.COMMA.equals(prevTokenType)
&& !JavaTokenType.LBRACE.equals(
prevTokenType)) {
final IElementType prevTokenType = ((PsiJavaToken)prevSibling).getTokenType();
if (!JavaTokenType.COMMA.equals(prevTokenType) && !JavaTokenType.LBRACE.equals(prevTokenType)) {
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
@@ -192,17 +184,13 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
}
@Nullable
private static PsiElement skipForwardWhiteSpacesAndComments(
PsiElement element) {
return PsiTreeUtil.skipSiblingsForward(element,
PsiWhiteSpace.class, PsiComment.class);
private static PsiElement skipForwardWhiteSpacesAndComments(PsiElement element) {
return PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace.class, PsiComment.class);
}
@Nullable
private static PsiElement skipBackwardWhiteSpacesAndComments(
PsiElement element) {
return PsiTreeUtil.skipSiblingsBackward(element,
PsiWhiteSpace.class, PsiComment.class);
private static PsiElement skipBackwardWhiteSpacesAndComments(PsiElement element) {
return PsiTreeUtil.skipSiblingsBackward(element, PsiWhiteSpace.class, PsiComment.class);
}
@Override