Cleanup (minor optimization)

This commit is contained in:
Roman Shevchenko
2017-02-16 13:39:01 +01:00
parent c472e7bab5
commit 5352e315e0
2 changed files with 7 additions and 14 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -521,19 +521,12 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
static HighlightInfo checkPackageAnnotationContainingFile(final PsiPackageStatement statement) {
if (statement.getAnnotationList() == null) {
return null;
}
PsiFile file = statement.getContainingFile();
if (file != null && !PsiPackage.PACKAGE_INFO_FILE.equals(file.getName())) {
String description = JavaErrorMessages.message("invalid.package.annotation.containing.file");
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR);
builder.range(statement.getAnnotationList().getTextRange());
builder.descriptionAndTooltip(description);
return builder.create();
static HighlightInfo checkPackageAnnotationContainingFile(PsiPackageStatement statement, PsiFile file) {
PsiModifierList annotationList = statement.getAnnotationList();
if (annotationList != null && !PsiPackage.PACKAGE_INFO_FILE.equals(file.getName())) {
String message = JavaErrorMessages.message("invalid.package.annotation.containing.file");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotationList.getTextRange()).descriptionAndTooltip(message).create();
}
return null;
}
@@ -982,7 +982,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
@Override
public void visitPackageStatement(PsiPackageStatement statement) {
super.visitPackageStatement(statement);
myHolder.add(AnnotationsHighlightUtil.checkPackageAnnotationContainingFile(statement));
myHolder.add(AnnotationsHighlightUtil.checkPackageAnnotationContainingFile(statement, myFile));
}
@Override